From: Alexander Ebert Date: Sat, 29 Nov 2014 21:01:59 +0000 (+0100) Subject: Manually preserving special characters being replaced by Redactor X-Git-Tag: 2.1.0_Beta_1~115 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a55e743b8488e79a27aca8534e794a6b0b301028;p=GitHub%2FWoltLab%2FWCF.git Manually preserving special characters being replaced by Redactor --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 893c39f281..2d5495971f 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -220,16 +220,47 @@ RedactorPlugins.wmonkeypatch = function() { * - convert
to

during paste */ clean: function() { + // these characters are replaced by this.clean.onSet() and this.clean.onPaste() -- #1980 + var $protectedSpecialCharacters = function(text) { + text = text.replace(/\u201D/g, '__wcf_preserve_character_1__'); + text = text.replace(/\u201C/g, '__wcf_preserve_character_2__'); + text = text.replace(/\u2018/g, '__wcf_preserve_character_3__'); + text = text.replace(/\u2019/g, '__wcf_preserve_character_4__'); + + return text; + }; + + var $restoreSpecialCharacters = function(text) { + text = text.replace(/__wcf_preserve_character_1__/g, '\u201D'); + text = text.replace(/__wcf_preserve_character_2__/g, '\u201C'); + text = text.replace(/__wcf_preserve_character_3__/g, '\u2018'); + text = text.replace(/__wcf_preserve_character_4__/g, '\u2019'); + + return text; + }; + // clean.onPaste var $mpOnPaste = this.clean.onPaste; this.clean.onPaste = (function(html, setMode) { this.opts.replaceDivs = true; + html = $protectedSpecialCharacters(html); + html = $mpOnPaste.call(this, html, setMode); this.opts.replaceDivs = false; - return html; + return $restoreSpecialCharacters(html); + }).bind(this); + + // clean.onSet + var $mpOnSet = this.clean.onSet; + this.clean.onSet = (function(html) { + html = $protectedSpecialCharacters(html); + + html = $mpOnSet.call(this, html); + + return $restoreSpecialCharacters(html); }).bind(this); // clean.setVerified