From 8e683f76edced16c5738b57e38e49677301b0283 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 6 Jan 2015 15:49:22 +0100 Subject: [PATCH] Fixed modifying link text on insert --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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); }, /** -- 2.20.1