From 9299ed7664688a1e866cef6a6ff86639a0588381 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 26 Oct 2017 16:11:44 +0200 Subject: [PATCH] Improved detection of HTML images pasted in Chrome --- .../3rdParty/redactor2/plugins/WoltLabPaste.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index 501487f438..66056bd087 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -62,7 +62,7 @@ $.Redactor.prototype.WoltLabPaste = function() { // remove document fragments if (pastedHtml.match(/^[\s\S]*?([\s\S]+)<\/body>\s*<\/html>$/)) { - pastedHtml = RegExp.$1; + pastedHtml = RegExp.$1.replace(/^\s*(?:)(.+)(?:)?\s*$/, '$1'); } } } @@ -168,6 +168,20 @@ $.Redactor.prototype.WoltLabPaste = function() { return; } + if (this.detect.isWebkit()) { + var item, hasFile = false, hasHtml = false; + for (var i = 0, length = clipboard.items.length; i < length; i++) { + item = clipboard.items[i]; + if (item.kind === 'string' && item.type === 'text/html') hasHtml = true; + else if (item.kind === 'file') hasFile = true; + } + + // pasted an `` element from clipboard + if (hasFile && hasHtml) { + return false; + } + } + var cancelPaste = false; file = clipboard.items[0].getAsFile(); if (file === null) { -- 2.20.1