From 2b6df8a486fbaeef6d9c6ec00831021752f94d08 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 12 Sep 2016 15:04:24 +0200 Subject: [PATCH] Improved pasting in Chrome --- .../js/3rdParty/redactor2/plugins/WoltLabPaste.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js index 52285e2a28..9cf606ab2c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js @@ -62,23 +62,30 @@ $.Redactor.prototype.WoltLabPaste = function() { return false; } - if (!clipboard.items || !clipboard.items.length) { return; } + var isWebkitPaste = false; var file = clipboard.items[0].getAsFile(); if (file === null) { - return false; + if (this.detect.isWebkit() && clipboard.items.length > 1) { + file = clipboard.items[1].getAsFile(); + isWebkitPaste = true; + } + + if (file === null) { + return false; + } } var reader = new FileReader(); reader.readAsDataURL(file); - reader.onload = $.proxy(this.paste.insertFromClipboard, this); + reader.onload = this.paste.insertFromClipboard.bind(this); - return true; + return (isWebkitPaste === false); }).bind(this); this.paste.insertFromClipboard = (function (e) { -- 2.20.1