From: Alexander Ebert Date: Fri, 16 Oct 2015 11:21:36 +0000 (+0200) Subject: Added workaround for superflous newlines in Firefox X-Git-Tag: 2.1.8~17 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d99d7d1e1fe43562f423c6d4a9c8e7f1b15efe9a;p=GitHub%2FWoltLab%2FWCF.git Added workaround for superflous newlines in Firefox --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 232026cf55..92b6287cb0 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -2308,6 +2308,23 @@ RedactorPlugins.wbbcode = function() { this.selection.get(); var $selectedText = this.selection.getText(); + if ($.browser.mozilla) { + // window.getSelection().toString() returns superflous newlines + $selectedText = $selectedText.replace(/\r/g, '').replace(/\u200b/g, ''); + $selectedText = $selectedText.replace(/(\n+)/g, function(match, newlines) { + var count = newlines.match(/\n/g).length; + count = ~~(count / 2); + + newlines = ''; + while (count > 0) { + newlines += "\n"; + count--; + } + + return newlines; + }); + } + this.selection.save(); this.modal.show();