From f3233ec7f8d9ac0bbe1ca470cef8098cc2495776 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 18 Jan 2017 11:03:35 +0100 Subject: [PATCH] Fixed a few pasting issues --- .../3rdParty/redactor2/plugins/WoltLabClean.js | 17 +++++++++++++++++ .../3rdParty/redactor2/plugins/WoltLabPaste.js | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index cc9eb262f5..0e5472396a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -377,6 +377,23 @@ $.Redactor.prototype.WoltLabClean = function() { this.clean.removeSpans = function(html) { return html; }; + + var mpGetCurrentType = this.clean.getCurrentType; + this.clean.getCurrentType = (function(html, insert) { + var data = mpGetCurrentType.call(this, html, insert); + + if (this.utils.isCurrentOrParent(['kbd'])) { + data.inline = false; + data.block = false; + data.encode = true; + data.pre = true; + data.paragraphize = false; + data.images = false; + data.links = false; + } + + return data; + }).bind(this); } } }; diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index d3b3a2df42..3117a675c1 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -87,7 +87,10 @@ $.Redactor.prototype.WoltLabPaste = function() { if (this.detect.isWebkit() && clipboard.items.length > 1) { file = clipboard.items[1].getAsFile(); cancelPaste = true; - e.preventDefault(); + + if (file !== null) { + e.preventDefault(); + } } if (file === null) { @@ -120,6 +123,8 @@ $.Redactor.prototype.WoltLabPaste = function() { var transparentGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; var mpInsert = this.paste.insert; this.paste.insert = (function(html, data) { + if (isKbd) data.pre = true; + if (data.pre) { return mpInsert.call(this, html, data); } -- 2.20.1