Cleanup of superfluous whitespaces after pasting
authorAlexander Ebert <ebert@woltlab.com>
Fri, 6 Oct 2017 10:44:08 +0000 (12:44 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 6 Oct 2017 10:44:08 +0000 (12:44 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index f0de39ad39c4cc0a1820c24eb0cb848b96e49556..55f876316fc430f21d45372c35baac2e536f85b2 100644 (file)
@@ -236,6 +236,18 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                        }).bind(this), 50);
                                }
                                
+                               // cleanup any stray text fragments caused by paragraphs
+                               // being replaced by the clipboard contents
+                               var node, badNodes = [];
+                               var editor = this.core.editor()[0];
+                               for (i = 0, length = editor.childNodes.length; i < length; i++) {
+                                       node = editor.childNodes[i];
+                                       if (node.nodeType === Node.TEXT_NODE && node.textContent === '\u200B') {
+                                               badNodes.push(node);
+                                       }
+                               }
+                               badNodes.forEach(elRemove);
+                               
                                this.rtePaste = false;
                        }).bind(this);