From 089e9d8e694dd8a0448ed6eca0a7ed047f0dcaea Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 17 Jun 2017 20:22:26 +0200 Subject: [PATCH] Fixed newline handling inside joined bbcode tags --- .../files/js/3rdParty/redactor/plugins/wbbcode.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index decd4b4b43..0ec67fd2a2 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -656,6 +656,18 @@ RedactorPlugins.wbbcode = function() { if ($searchFor.length) { var $didReplace = true; + // remove newlines inside an opening and closing bbcode of the same exact type + while ($didReplace) { + $didReplace = false; + html = html.replace(new RegExp('\\[((?:' + $searchFor.join('|') + ')=[^\\]]+?)\\]\n\\[\\/\\1\\]', 'gi'), function(matches, bbcode) { + $didReplace = true; + + return '[' + bbcode + '][/' + bbcode + ']'; + }); + } + + // join adjacent bbcodes of the same exact type + $didReplace = true; while ($didReplace) { $didReplace = false; html = html.replace(new RegExp('\\[\\/((?:' + $searchFor.join('|') + ')=[^\\]]+?)\\]\n\\[\\1\\]', 'gi'), function() { -- 2.20.1