From: Alexander Ebert Date: Tue, 2 May 2017 08:45:26 +0000 (+0200) Subject: Fixed selection handling in Chrome 58 X-Git-Tag: 2.1.15~8 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ba6938177329765e1844ef549e2e72ba5908085;p=GitHub%2FWoltLab%2FWCF.git Fixed selection handling in Chrome 58 --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 2053268f3e..b3a039ed08 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -1350,6 +1350,31 @@ RedactorPlugins.wmonkeypatch = function() { $(document).find('span.redactor-nodes-marker').each($removeEmptyTextNodes); this.$editor.find('span.redactor-nodes-marker').each($removeEmptyTextNodes); }).bind(this); + + this.selection.createMarkers = (function() { + this.selection.get(); + + var node1 = this.selection.getMarker(1); + + this.selection.setMarker(this.range, node1, true); + if (this.range.collapsed === false) + { + var node2 = this.selection.getMarker(2); + this.selection.setMarker(this.range, node2, false); + + // Chrome 58 fails if the selection contains the first marker + var range = document.createRange(); + range.setStartAfter(node1); + range.setEndBefore(node2); + + var selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + + } + + this.savedSel = this.$editor.html(); + }).bind(this); }, /**