Remove bogus `<br>` when outdenting a list in Firefox
authorAlexander Ebert <ebert@woltlab.com>
Thu, 4 Jan 2018 16:40:02 +0000 (17:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 4 Jan 2018 16:40:02 +0000 (17:40 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabIndent.js

index 0b53bf752cd717220a3d4f3930e513f5778d7d71..b1da114841d0a08dde900c4520a21904e3f3cc28 100644 (file)
@@ -103,6 +103,16 @@ $.Redactor.prototype.WoltLabIndent = function() {
                        }
                        
                        this.indent.normalize = (function() {
+                               // `document.execCommand('outdent')` can spawn a `<br>` if there is whitespace in the DOM
+                               // see https://bugzilla.mozilla.org/show_bug.cgi?id=1428073
+                               if (this.detect.isFirefox()) {
+                                       var block = this.selection.block();
+                                       if (block && block.nodeName === 'P') {
+                                               var br = block.previousElementSibling;
+                                               if (br && br.nodeName === 'BR') elRemove(br);
+                                       }
+                               }
+                               
                                this.core.editor().find('li').each($.proxy(function (i, s) {
                                        var $el = $(s);