From: Alexander Ebert Date: Tue, 6 Jan 2015 14:49:22 +0000 (+0100) Subject: Fixed modifying link text on insert X-Git-Tag: 2.1.0_Beta_3~23 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8e683f76edced16c5738b57e38e49677301b0283;p=GitHub%2FWoltLab%2FWCF.git Fixed modifying link text on insert --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index bd3f27ffa5..78bf3f02e3 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -648,10 +648,33 @@ RedactorPlugins.wmonkeypatch = function() { this.selection.get(); var $current = this.selection.getCurrent(); + if ($current.nodeType === Node.TEXT_NODE) { + $current = $current.parentElement; + } + if ($current.tagName === 'A') { this.caret.setAfter($current); } }).bind(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); + } + } + }).bind(this); }, /**