From: Alexander Ebert Date: Sun, 22 Feb 2015 10:02:08 +0000 (+0100) Subject: Dropping empty
  • after pasting X-Git-Tag: 2.1.0_RC_2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5716492c497a55c1128f44a22d55df1b914d8ae2;p=GitHub%2FWoltLab%2FWCF.git Dropping empty
  • after pasting --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 038c930411..26311b6c0e 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -934,7 +934,9 @@ RedactorPlugins.wutil = function() { }, /** - * Fixes the DOM by moving all non-element children of the editor into a paragraph. + * Fixes the DOM after pasting: + * - move all non-element children of the editor into a paragraph + * - pasting lists/list-items in lists can yield empty
  • */ fixDOM: function() { var $current = this.$editor[0].childNodes[0]; @@ -974,6 +976,17 @@ RedactorPlugins.wutil = function() { $p.append($current); } } + + var $listItems = this.$editor[0].getElementsByTagName('li'); + for (var $i = 0, $length = $listItems.length; $i < $length; $i++) { + var $listItem = $listItems[$i]; + if (!$listItem.innerHTML.length) { + var $parent = $listItem.parentElement; + if ($parent.children.length > 1) { + $listItem.parentElement.removeChild($listItem); + } + } + } } }; };