From 5716492c497a55c1128f44a22d55df1b914d8ae2 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 22 Feb 2015 11:02:08 +0100 Subject: [PATCH] Dropping empty
  • after pasting --- .../files/js/3rdParty/redactor/plugins/wutil.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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); + } + } + } } }; }; -- 2.20.1