From 9a089bce763f1bcc1da3a8d90a1152a39c7d0f5e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 24 Aug 2016 11:09:53 +0200 Subject: [PATCH] Fixed encoding issues with pasted code --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 + .../redactor2/plugins/WoltLabClean.js | 59 +++++++++++++++++++ .../3rdParty/redactor2/plugins/WoltLabCode.js | 4 ++ .../redactor2/plugins/WoltLabPaste.js | 13 +++- 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index c43230fdea..aa9bf0fda4 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -14,6 +14,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabBlock.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabButton.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCaret.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabClean.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabCode.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabColor.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabDropdown.js?v={@LAST_UPDATE_TIME}', @@ -162,6 +163,7 @@ 'WoltLabAttachment', 'WoltLabAutosave', 'WoltLabCaret', + 'WoltLabClean', 'WoltLabCode', 'WoltLabColor', 'WoltLabDropdown', diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js new file mode 100644 index 0000000000..383a377908 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -0,0 +1,59 @@ +$.Redactor.prototype.WoltLabClean = function() { + "use strict"; + + return { + init: function () { + var mpOnSet = this.clean.onSet; + this.clean.onSet = (function (html) { + return mpOnSet.call(this, html.replace(/\u200B/g, '')); + }).bind(this); + + var mpOnSync = this.clean.onSync; + this.clean.onSync = (function (html) { + var div, replacements = {}; + if (html.indexOf('