From 0ce51dffb787d7e0a02ecf823ed70b43aab25bfb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 22 Aug 2016 16:22:56 +0200 Subject: [PATCH] Fixed pasting into code in Firefox --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 ++ .../install/files/acp/templates/wysiwyg.tpl | 2 ++ .../redactor2/plugins/WoltLabPaste.js | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 365c0c00cc..2ecbda226c 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -25,6 +25,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabModal.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabPaste.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}', @@ -168,6 +169,7 @@ 'WoltLabInlineCode', 'WoltLabLink', 'WoltLabModal', + 'WoltLabPaste', 'WoltLabQuote', 'WoltLabSize', 'WoltLabSmiley', diff --git a/wcfsetup/install/files/acp/templates/wysiwyg.tpl b/wcfsetup/install/files/acp/templates/wysiwyg.tpl index 365c0c00cc..2ecbda226c 100644 --- a/wcfsetup/install/files/acp/templates/wysiwyg.tpl +++ b/wcfsetup/install/files/acp/templates/wysiwyg.tpl @@ -25,6 +25,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabModal.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabPaste.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}', @@ -168,6 +169,7 @@ 'WoltLabInlineCode', 'WoltLabLink', 'WoltLabModal', + 'WoltLabPaste', 'WoltLabQuote', 'WoltLabSize', 'WoltLabSmiley', diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js new file mode 100644 index 0000000000..2c2693794b --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -0,0 +1,30 @@ +$.Redactor.prototype.WoltLabPaste = function() { + "use strict"; + + return { + init: function () { + var clipboardData = null; + + var mpInit = this.paste.init; + this.paste.init = (function (e) { + clipboardData = e.originalEvent.clipboardData.getData('text/plain'); + + mpInit.call(this, e); + }).bind(this); + + var mpGetPasteBoxCode = this.paste.getPasteBoxCode; + this.paste.getPasteBoxCode = (function (pre) { + var returnValue = mpGetPasteBoxCode.call(this, pre); + + if (pre && !returnValue) { + return clipboardData; + } + + return returnValue; + }).bind(this); + + // rebind paste event + this.core.editor().off('paste.redactor').on('paste.redactor', this.paste.init.bind(this)); + } + }; +}; -- 2.20.1