Improved image pasting in IE11
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 11:23:46 +0000 (13:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 11:23:53 +0000 (13:23 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index a3b4a281f7566f1ab3d70be654c280848f474c35..208d03ef7611456f665cb9e2aac7b5b96de0909b 100644 (file)
@@ -50,42 +50,42 @@ $.Redactor.prototype.WoltLabPaste = function() {
                        this.paste.detectClipboardUpload = (function (e) {
                                e = e.originalEvent || e;
                                
-                               var clipboard = e.clipboardData;
-                               
+                               var file;
                                if (isIe) {
-                                       return (window.clipboardData.files.length > 0);
-                               }
-                               
-                               if (this.detect.isFirefox())
-                               {
-                                       return false;
+                                       if (!window.clipboardData.files.length) {
+                                               return false;
+                                       }
+                                       
+                                       file = window.clipboardData.files.item(0);
                                }
-                               
-                               // prevent safari fake url
-                               var types = clipboard.types;
-                               // WoltLab modification: `DataTransfer.types` is a `DOMStringList` in Edge
-                               if (Array.isArray(types) && types.indexOf('public.tiff') !== -1)
-                               {
-                                       e.preventDefault();
+                               else if (this.detect.isFirefox()) {
                                        return false;
                                }
-                               
-                               if (!clipboard.items || !clipboard.items.length)
-                               {
-                                       return;
-                               }
-                               
-                               var cancelPaste = false;
-                               var file = clipboard.items[0].getAsFile();
-                               if (file === null)
-                               {
-                                       if (this.detect.isWebkit() && clipboard.items.length > 1) {
-                                               file = clipboard.items[1].getAsFile();
-                                               cancelPaste = true;
+                               else {
+                                       var clipboard = e.clipboardData;
+                                       
+                                       // prevent safari fake url
+                                       var types = clipboard.types;
+                                       if (Array.isArray(types) && types.indexOf('public.tiff') !== -1) {
+                                               e.preventDefault();
+                                               return false;
+                                       }
+                                       
+                                       if (!clipboard.items || !clipboard.items.length) {
+                                               return;
                                        }
                                        
+                                       var cancelPaste = false;
+                                       file = clipboard.items[0].getAsFile();
                                        if (file === null) {
-                                               return false;
+                                               if (this.detect.isWebkit() && clipboard.items.length > 1) {
+                                                       file = clipboard.items[1].getAsFile();
+                                                       cancelPaste = true;
+                                               }
+                                               
+                                               if (file === null) {
+                                                       return false;
+                                               }
                                        }
                                }