From a55e743b8488e79a27aca8534e794a6b0b301028 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 29 Nov 2014 22:01:59 +0100 Subject: [PATCH] Manually preserving special characters being replaced by Redactor --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 -- 2.20.1