From: Alexander Ebert Date: Mon, 4 Feb 2019 12:10:54 +0000 (+0100) Subject: Convert bogus newlines in pasted text in Firefox X-Git-Tag: 3.1.8~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=84e4276ca13642a5d59c4b6140cb8a00ef051e06;p=GitHub%2FWoltLab%2FWCF.git Convert bogus newlines in pasted text in Firefox --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 775a4365ad..02f29c8ed1 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -90,6 +90,16 @@ $.Redactor.prototype.WoltLabClean = function() { } }); + // Firefox inserts bogus linebreaks instead of spaces at the end of spans, if there is an adjacent span. + elBySelAll('span', div, function (span) { + if (span.childNodes.length > 0) { + var lastNode = span.childNodes[span.childNodes.length - 1]; + if (lastNode.nodeType === Node.TEXT_NODE && lastNode.textContent.match(/\n$/)) { + lastNode.textContent = lastNode.textContent.replace(/\n+$/, (span.parentNode.lastChild === span ? '' : ' ')); + } + } + }); + html = div.innerHTML; html = html.replace(/

\u200B<\/p>/g, '


');