Fixed the auto insert of pasted/dropped images in the editor
authorAlexander Ebert <ebert@woltlab.com>
Fri, 16 Aug 2019 14:31:11 +0000 (16:31 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 16 Aug 2019 14:31:11 +0000 (16:31 +0200)
wcfsetup/install/files/js/WCF.Attachment.js

index 34cf0c472083b7de51af4e17179a521733edfaea..a653f0888e169ba548bbfd758187a53b769fb75f 100644 (file)
@@ -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) {