From: Alexander Ebert Date: Tue, 20 Dec 2016 12:00:04 +0000 (+0100) Subject: Strip links after return key in Firefox X-Git-Tag: 3.0.0_RC_2~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=40854dd467ca6912103dd55202f6d1c9f3728bdb;p=GitHub%2FWoltLab%2FWCF.git Strip links after return key in Firefox --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js index 97298981b9..7df1da8fd3 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js @@ -105,6 +105,45 @@ $.Redactor.prototype.WoltLabKeydown = function() { // firefox enter into inline element if (this.detect.isFirefox() && this.utils.isInline(this.keydown.parent)) { this.keydown.insertBreakLine(e); + + // WoltLab modification: strip links on return + setTimeout((function () { + var block = this.selection.block(); + var current = this.selection.inline(); + + while (current && current !== block) { + if (current.nodeName === 'A') { + // check if this is an empty link + var remove = false; + if (current.childNodes.length === 0) { + remove = true; + } + else if (current.textContent.replace(/\u200B/g, '') === '') { + remove = true; + + // check if there are only elements + elBySelAll('*', current, function (element) { + if (element.nodeName !== 'SPAN') { + remove = false; + } + }); + } + + if (remove) { + while (current.childNodes.length) { + current.parentNode.insertBefore(current.childNodes[0], current); + } + + elRemove(current); + + break; + } + } + + current = current.parentNode; + } + }).bind(this), 1); + return; }