Backspacing inside quotes in Firefox failed for `<br>`
authorAlexander Ebert <ebert@woltlab.com>
Sat, 30 Dec 2017 20:56:24 +0000 (21:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 30 Dec 2017 20:56:24 +0000 (21:56 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js

index c9ea6d1e6ee7ca4fb0b1e40ef4eb04687bad8b7b..993903dd798e76fdae4b62f1f2641bf2850663b0 100644 (file)
@@ -640,11 +640,24 @@ $.Redactor.prototype.WoltLabKeydown = function() {
                                                                if (sibling.nodeName === 'P') {
                                                                        sibling.appendChild(this.marker.get());
                                                                        
+                                                                       var node;
                                                                        while (block.childNodes.length) {
-                                                                               sibling.appendChild(block.childNodes[0]);
+                                                                               node = block.childNodes[0];
+                                                                               
+                                                                               // avoid moving contents that follows a `<br>`
+                                                                               if (node.nodeName === 'BR') {
+                                                                                       elRemove(node);
+                                                                                       break;
+                                                                               }
+                                                                               
+                                                                               sibling.appendChild(node);
+                                                                       }
+                                                                       
+                                                                       // blocks may be non-empty if they contained a `<br>` somehwere after the original caret position
+                                                                       if (block.childNodes.length === 0) {
+                                                                               elRemove(block);
                                                                        }
                                                                        
-                                                                       elRemove(block);
                                                                        this.selection.restore();
                                                                }
                                                                else {