From: Alexander Ebert Date: Mon, 22 Aug 2016 14:22:56 +0000 (+0200) Subject: Fixed pasting into code in Firefox X-Git-Tag: 3.0.0_Beta_1~579 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0ce51dffb787d7e0a02ecf823ed70b43aab25bfb;p=GitHub%2FWoltLab%2FWCF.git Fixed pasting into code in Firefox --- 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)); + } + }; +};