There are two different methods causing empty text nodes
authorAlexander Ebert <ebert@woltlab.com>
Sat, 27 Dec 2014 13:46:07 +0000 (14:46 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 27 Dec 2014 13:46:07 +0000 (14:46 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index 7043fbd9a280292e5a896ed6eaade824b6d562c1..d5b757fc80acd918ea650369aa308b45c36dff11 100644 (file)
@@ -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);
                },