From d99d7d1e1fe43562f423c6d4a9c8e7f1b15efe9a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 16 Oct 2015 13:21:36 +0200 Subject: [PATCH] Added workaround for superflous newlines in Firefox --- .../js/3rdParty/redactor/plugins/wbbcode.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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(); -- 2.20.1