From d31b1307ab73f08cff9a828025588c825ed7f117 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 27 Dec 2014 14:46:07 +0100 Subject: [PATCH] There are two different methods causing empty text nodes --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 7043fbd9a2..d5b757fc80 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -797,16 +797,24 @@ RedactorPlugins.wmonkeypatch = function() { * - remove superflous empty text nodes caused by the selection markers (#2083) */ selection: function() { + var $removeEmptyTextNodes = function(index, marker) { + var $nextSibling = marker.nextSibling; + if ($nextSibling !== null && $nextSibling.nodeType === Node.TEXT_NODE && $nextSibling.length === 0) { + $($nextSibling).remove(); + } + + $(marker).remove(); + }; + // selection.removeMarkers this.selection.removeMarkers = (function() { - this.$editor.find('span.redactor-selection-marker').each(function(index, marker) { - var $nextSibling = marker.nextSibling; - if ($nextSibling !== null && $nextSibling.nodeType === Element.TEXT_NODE && $nextSibling.length === 0) { - $($nextSibling).remove(); - } - - $(marker).remove(); - }); + this.$editor.find('span.redactor-selection-marker').each($removeEmptyTextNodes); + }).bind(this); + + // selection.removeNodesMarkers + this.selection.removeNodesMarkers = (function() { + $(document).find('span.redactor-nodes-marker').each($removeEmptyTextNodes); + this.$editor.find('span.redactor-nodes-marker').each($removeEmptyTextNodes); }).bind(this); }, -- 2.20.1