From 9ba6938177329765e1844ef549e2e72ba5908085 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 2 May 2017 10:45:26 +0200 Subject: [PATCH] Fixed selection handling in Chrome 58 --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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); }, /** -- 2.20.1