From 1ee52daba65cdb2906a0789591259e0c04b234af Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 27 Dec 2014 12:46:57 +0100 Subject: [PATCH] Removing markers can yield empty text nodes, slowing down rendering --- .../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 bdacccb906..7043fbd9a2 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -36,6 +36,7 @@ RedactorPlugins.wmonkeypatch = function() { this.wmonkeypatch.modal(); this.wmonkeypatch.paste(); this.wmonkeypatch.observe(); + this.wmonkeypatch.selection(); this.wmonkeypatch.utils(); // templates @@ -790,6 +791,25 @@ RedactorPlugins.wmonkeypatch = function() { }).bind(this); }, + /** + * Partially overwrites the 'selection' module. + * + * - remove superflous empty text nodes caused by the selection markers (#2083) + */ + selection: function() { + // 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(); + }); + }).bind(this); + }, + /** * Partially overwrites the 'utils' module. * -- 2.20.1