From 629e611a95747e46bb09bbc0554e10330475d978 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 25 May 2014 13:44:35 +0200 Subject: [PATCH] Fixed various issues related to newlines and tables --- .../js/3rdParty/redactor/plugins/wbbcode.js | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) 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 -- 2.20.1