Improved pasting in IE 11
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 10:12:05 +0000 (12:12 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Sep 2016 10:12:11 +0000 (12:12 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index 9c3a245dca4c81d98d524f0bb930882c15b0df39..e115de25d1fb4f713a21969a4de230a6d438eb1d 100644 (file)
@@ -5,11 +5,19 @@ $.Redactor.prototype.WoltLabPaste = function() {
                init: function () {
                        var clipboardData = null;
                        
+                       // IE 11
+                       var isIe = (document.documentMode && typeof window.clipboardData === 'object');
+                       
                        var mpInit = this.paste.init;
                        this.paste.init = (function (e) {
                                var isCode = (this.opts.type === 'pre' || this.utils.isCurrentOrParent('pre')) ? true : false;
                                if (isCode) {
-                                       clipboardData = e.originalEvent.clipboardData.getData('text/plain');
+                                       if (isIe) {
+                                               clipboardData = window.clipboardData.getData('Text');
+                                       }
+                                       else {
+                                               clipboardData = e.originalEvent.clipboardData.getData('text/plain');
+                                       }
                                        
                                        var mpCleanEncodeEntities = this.clean.encodeEntities;
                                        this.clean.encodeEntities = (function(str) {
@@ -42,10 +50,8 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                
                                var clipboard = e.clipboardData;
                                
-                               // WoltLab modification: allow Edge
-                               if (this.detect.isIe() && (this.detect.isIe() !== 'edge' || document.documentMode))
-                               {
-                                       return true;
+                               if (isIe) {
+                                       return (window.clipboardData.files.length > 0);
                                }