From: Alexander Ebert Date: Tue, 17 Mar 2015 08:51:11 +0000 (+0100) Subject: Improved handling of [tt]...[/tt] X-Git-Tag: 2.1.2~38 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8d47774ad627ac794e5df78211803420f5672c3f;p=GitHub%2FWoltLab%2FWCF.git Improved handling of [tt]...[/tt] --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 23ea557727..13f13033d1 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -1303,7 +1303,35 @@ RedactorPlugins.wbbcode = function() { var $value = $cachedCode.value; // [tt] - //$value = $value.replace(/^\[tt\](.*)\[\/tt\]/, '$1'); + $value = $value.replace(/^\[tt\]([\s\S]+)\[\/tt\]/, (function(match, content) { + var $tmp = content.split("\n"); + content = ''; + + for (var $i = 0, $length = $tmp.length; $i < $length; $i++) { + var $line = $tmp[$i]; + + if ($line.length) { + if (content.length) content += '

'; + + content += '[tt]' + $line + '[/tt]'; + } + else { + if ($i === 0 || ($i + 1) === $length) { + // ignore the first and last empty element + continue; + } + + if (content.match(/\[\/tt\]$/)) { + content += '

' + this.opts.invisibleSpace + ''; + } + else { + content += '


'; + } + } + } + + return content; + }).bind(this)); // [code] $value = $value.replace(/^\[code([^\]]*)\]([\S\s]*)\[\/code\]$/, (function(matches, parameters, content) { diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js index 2485356f5e..7ea3d5e511 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbutton.js @@ -161,6 +161,7 @@ RedactorPlugins.wbutton = function() { if ($eventData.cancel === false) { var $selectedHtml = this.selection.getHtml(); + $selectedHtml = $selectedHtml.replace(/

@@@wcf_empty_line@@@<\/p>/g, '


'); // TODO: this behaves pretty weird at this time, fix or remove if (false && $bbcode === 'tt') {