From be96e1adb776d88e02b928d5348ce40ef7799f73 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 20 Oct 2015 12:08:58 +0200 Subject: [PATCH] Fixed selection issue in Chrome and Firefox --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) 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 { -- 2.20.1