From b1d86e2cf865b608dbb6e7dcb0abac18f2c42edc Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 2 Mar 2015 12:58:42 +0100 Subject: [PATCH] Fixed browsers creating invalid HTML when indenting the first item --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 6a136402c2..54c1f1894a 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -30,6 +30,7 @@ RedactorPlugins.wmonkeypatch = function() { this.wmonkeypatch.code(); this.wmonkeypatch.dropdown(); this.wmonkeypatch.image(); + this.wmonkeypatch.indent(); this.wmonkeypatch.inline(); this.wmonkeypatch.insert(); this.wmonkeypatch.keydown(); @@ -637,6 +638,25 @@ RedactorPlugins.wmonkeypatch = function() { }).bind(this); }, + /** + * Partially overwrites the 'indent' module. + * + * - prevent browsers from screwing up the DOM when indenting the only item + */ + indent: function() { + // indent.increaseLists + var $mpIncrease = this.indent.increase; + this.indent.increase = (function() { + var $block = this.selection.getBlock(); + if ($block && $block.tagName === 'LI') { + // do not allow indenting the first list item because it yields invalid HTML + if ($block.parentElement.firstChild !== $block) { + $mpIncrease.call(this); + } + } + }).bind(this); + }, + /** * Partially overwrites the 'inline' module. * -- 2.20.1