Improved behavior of headings in the editor
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 Nov 2017 21:28:10 +0000 (22:28 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 Nov 2017 21:28:10 +0000 (22:28 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js

index 302749db4c5a148e29177b48823f6e27db413895..cc5dd5563b66e5d328c07647292e30236d5ea8f4 100644 (file)
@@ -57,8 +57,18 @@ $.Redactor.prototype.WoltLabBlock = function() {
                                
                                var replaced = mpFormatCollapsed.call(this, tag, attr, value, type);
                                
-                               for (var i = 0, length = replaced.length; i < length; i++) {
-                                       this.WoltLabBlock._paragraphize(replaced[i]);
+                               var length = replaced.length;
+                               if (length === 1 && replaced[0].nodeName.match(/^H[1-6]$/)) {
+                                       var hX = replaced[0];
+                                       // <hX><br></hX> behaves weird
+                                       if (hX.childElementCount === 1 && hX.children[0].nodeName === 'BR' && this.utils.isEmpty(hX.innerHTML)) {
+                                               hX.innerHTML = '\u200B';
+                                       }
+                               }
+                               else {
+                                       for (var i = 0; i < length; i++) {
+                                               this.WoltLabBlock._paragraphize(replaced[i]);
+                                       }
                                }
                                
                                this.caret.end(replaced);