From: Alexander Ebert Date: Tue, 13 Jan 2015 11:50:20 +0000 (+0100) Subject: Fixed keydown handling and range after removing selection markers X-Git-Tag: 2.1.0_Beta_4~101 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8de7bc0ab444eada8fcf523d20ebc30a0ed81ae8;p=GitHub%2FWoltLab%2FWCF.git Fixed keydown handling and range after removing selection markers --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 8c23c3b95b..c35169bac6 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -1449,9 +1449,23 @@ RedactorPlugins.wbbcode = function() { $preventAndSelectQuote = true; } } - else if (current.previousElementSibling && current.previousElementSibling.tagName === 'BLOCKQUOTE') { - $quote = current.previousElementSibling; - $preventAndSelectQuote = true; + else { + var $scope = current; + if ($scope.nodeType === Node.TEXT_NODE) { + if (this.range.startOffset === 0 || (this.range.startOffset === 1 && $scope.textContent === '\u200b')) { + if (!$scope.previousSibling) { + $scope = $scope.parentElement; + } + } + } + + if ($scope.nodeType === Node.ELEMENT_NODE) { + var $previous = $scope.previousSibling; + if ($previous && $previous.nodeType === Node.ELEMENT_NODE && $previous.tagName === 'BLOCKQUOTE') { + $quote = $previous; + $preventAndSelectQuote = true; + } + } } if ($preventAndSelectQuote) { diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 91a447ac5c..51007c899f 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -868,14 +868,23 @@ RedactorPlugins.wmonkeypatch = function() { * - remove superflous empty text nodes caused by the selection markers (#2083) */ selection: function() { - var $removeEmptyTextNodes = function(index, marker) { + var $removeEmptyTextNodes = (function(index, marker) { var $nextSibling = marker.nextSibling; if ($nextSibling !== null && $nextSibling.nodeType === Node.TEXT_NODE && $nextSibling.length === 0) { $($nextSibling).remove(); } - $(marker).remove(); - }; + var $node = null; + if ((marker.id === 'selection-marker-1' && !this.$editor.find('#selection-marker-2').length) || marker.id === 'nodes-marker-1' && !this.$editor.find('#nodes-marker-2').length) { + $node = marker.previousSibling; + } + + $(marker).remove(); + + if ($node !== null) { + this.caret.set($node, $node.length, $node, $node.length); + } + }).bind(this); // selection.removeMarkers this.selection.removeMarkers = (function() {