Improved pasting in Chrome
authorAlexander Ebert <ebert@woltlab.com>
Mon, 12 Sep 2016 13:04:24 +0000 (15:04 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 12 Sep 2016 13:04:24 +0000 (15:04 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index 52285e2a288e95018ebdd7f0f9e2610999030272..9cf606ab2c54e0d586d879df99900e487f76d249 100644 (file)
@@ -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) {