From 2435a4e918503608cbe6ae4951010de9810b0bb5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 16 Aug 2019 16:31:11 +0200 Subject: [PATCH] Fixed the auto insert of pasted/dropped images in the editor --- wcfsetup/install/files/js/WCF.Attachment.js | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 34cf0c4720..a653f0888e 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -172,22 +172,24 @@ if (COMPILER_TARGET_DEFAULT) { // show tab this._fileListSelector.closest('.messageTabMenu').messageTabMenu('showTab', 'attachments', true); + var callbackUploadId = (function(uploadId) { + if (replace === null) { + this._autoInsert.push(uploadId); + } + else { + this._replaceOnLoad[uploadId] = replace; + } + + data.uploadID = uploadId; + }).bind(this); + if (data.file) { - $uploadID = this._upload(undefined, data.file); + $uploadID = this._upload(undefined, data.file, undefined, callbackUploadId); } else { - $uploadID = this._upload(undefined, undefined, data.blob); + $uploadID = this._upload(undefined, undefined, data.blob, callbackUploadId); replace = data.replace || null; } - - if (replace === null) { - this._autoInsert.push($uploadID); - } - else { - this._replaceOnLoad[$uploadID] = replace; - } - - data.uploadID = $uploadID; }, /** @@ -291,7 +293,7 @@ if (COMPILER_TARGET_DEFAULT) { /** * @see WCF.Upload._upload() */ - _upload: function (event, file, blob) { + _upload: function (event, file, blob, callbackUploadId) { var _super = this._super.bind(this); require([ @@ -407,6 +409,10 @@ if (COMPILER_TARGET_DEFAULT) { this._createButton(); } + if (typeof callbackUploadId === 'function') { + callbackUploadId(uploadID); + } + return uploadID; }).bind(this)) .catch(function (error) { -- 2.20.1