Fixed newline handling on paste
authorAlexander Ebert <ebert@woltlab.com>
Mon, 5 Dec 2016 11:40:17 +0000 (12:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 5 Dec 2016 11:40:17 +0000 (12:40 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js

index 40070d235f5f2f4d002ee76d582c09b9afbda511..687ecbc4fbea9de8d8c5ded0d465cca7748f54c1 100644 (file)
@@ -150,7 +150,7 @@ $.Redactor.prototype.WoltLabClean = function() {
                                });
                                
                                elBySelAll('br', div, function (br) {
-                                       br.parentNode.insertBefore(document.createTextNode('@@@WOLTLAB-BR-MARKER@@@'), br);
+                                       br.parentNode.insertBefore(document.createTextNode('@@@WOLTLAB-BR-MARKER@@@'), br.nextSibling);
                                });
                                
                                html = mpOnPaste.call(this, div.innerHTML, data, insert);
@@ -167,14 +167,13 @@ $.Redactor.prototype.WoltLabClean = function() {
                                                while (marker.nextSibling) {
                                                        p.appendChild(marker.nextSibling);
                                                }
-                                               p.appendChild(elCreate('br'));
                                                
-                                               parent.parentNode.insertBefore(p, parent.nextSibling);
-                                               
-                                               var previous = marker.previousElementSibling;
+                                               var previous = marker.previousSibling;
                                                if (previous && previous.nodeName === 'BR') {
                                                        elRemove(previous);
                                                }
+                                               
+                                               parent.parentNode.insertBefore(p, parent.nextSibling);
                                        }
                                        else {
                                                parent.insertBefore(elCreate('br'), marker);