From: Alexander Ebert Date: Sun, 25 May 2014 11:44:35 +0000 (+0200) Subject: Fixed various issues related to newlines and tables X-Git-Tag: 2.1.0_Alpha_1~711^2~16 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=629e611a95747e46bb09bbc0554e10330475d978;p=GitHub%2FWoltLab%2FWCF.git Fixed various issues related to newlines and tables --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index 93e64da8d5..dff66094ba 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -137,7 +137,9 @@ RedactorPlugins.wbbcode = { */ _convertFromHtml: function() { var html = this.$source.val(); - + console.clear(); + console.debug("_convertFromHtml()"); + console.debug(html); // drop line break right before/after a
 tag (used by [code]-BBCode)
 		html = html.replace(/
\n
\n/g, '');
 		html = html.replace(/<\/pre>\n
\n/g, ''); @@ -225,6 +227,11 @@ RedactorPlugins.wbbcode = { html = html.replace(/]*>/gi, '[table]'); html = html.replace(/<\/table>/gi, '[/table]'); + // remove + html = html.replace(/([\s\S]*?)<\/tbody>/, function(match, p1) { + return $.trim(p1); + }); + // remove empty s html = html.replace(/<\/tr>/gi, ''); // [tr] @@ -395,6 +402,11 @@ RedactorPlugins.wbbcode = { data = data.replace(/\[list=(none|circle|square|disc|decimal|lower-roman|upper-roman|decimal-leading-zero|lower-greek|lower-latin|upper-latin|armenian|georgian)\]/gi, '
    '); data = data.replace(/\[\/list]/gi, '
'); + // trim whitespaces within [table] + data = data.replace(/\[table\]([\S\s]*?)\[\/table\]/gi, function(match, p1) { + return '[table]' + $.trim(p1) + '[/table]'; + }); + // [table] data = data.replace(/\[table\]/gi, ''); data = data.replace(/\[\/table\]/gi, '
'); @@ -405,6 +417,11 @@ RedactorPlugins.wbbcode = { data = data.replace(/\[td\]/gi, ''); data = data.replace(/\[\/td\]/gi, ''); + // trim whitespaces within + data = data.replace(/([\S\s]*?)<\/td>/gi, function(match, p1) { + return '' + $.trim(p1) + ''; + }); + // smileys for (var smileyCode in __REDACTOR_SMILIES) { $smileyCode = smileyCode.replace(//g, '>'); @@ -423,11 +440,17 @@ RedactorPlugins.wbbcode = { data = ''; for (var $i = 0, $length = $tmp.length; $i < $length; $i++) { var $line = $.trim($tmp[$i]); - if (!$line) { - $line = '
'; - } - data += '

' + $line + '

'; + if ($line.indexOf('<') === 0) { + data += $line; + } + else { + if (!$line) { + $line = '
'; + } + + data += '

' + $line + '

'; + } } // insert codes