From: Alexander Ebert Date: Tue, 20 Oct 2015 10:08:58 +0000 (+0200) Subject: Fixed selection issue in Chrome and Firefox X-Git-Tag: 2.1.8~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=be96e1adb776d88e02b928d5348ce40ef7799f73;p=GitHub%2FWoltLab%2FWCF.git Fixed selection issue in Chrome and Firefox --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index 92531a9655..e7bd0dcda1 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -943,23 +943,20 @@ RedactorPlugins.wmonkeypatch = function() { }).bind(this); // link.set - /*var $mpSet = this.link.set; + var $mpSet = this.link.set; this.link.set = (function(text, link, target) { $mpSet.call(this, text, link, target); - if (text.length && this.link.text !== text) { - this.selection.get(); - - var $current = this.selection.getCurrent(); - if ($current.nodeType === Node.TEXT_NODE) { - $current = $current.parentElement; - } - - if ($current.tagName === 'A') { - $($current).text(text); + var selection = window.getSelection(); + if (selection.rangeCount) { + var range = selection.getRangeAt(0); + if (!range.collapsed) { + range.collapse(false); + + this.wutil.saveSelection(); } } - }).bind(this);*/ + }).bind(this); }, /** @@ -1211,7 +1208,7 @@ RedactorPlugins.wmonkeypatch = function() { } // iOS sometimes pastes right into the marker, this work-around will unwrap the pasted content - if (marker.innerHTML.length) { + if ($.browser.iOS && marker.innerHTML.length) { marker.outerHTML = marker.innerHTML; } else {