From: Alexander Ebert Date: Thu, 19 Feb 2015 15:19:01 +0000 (+0100) Subject: Fixed handling of tables when converting HTML -> BBCode X-Git-Tag: 2.1.0_RC_2~24 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=66c2b9bb9682fadb0156c2fae4c3a242ae103be2;p=GitHub%2FWoltLab%2FWCF.git Fixed handling of tables when converting HTML -> BBCode --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index f180ef6348..727dc6048c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -230,7 +230,8 @@ RedactorPlugins.wbbcode = function() { */ convertFromHtml: function(html) { WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'beforeConvertFromHtml', { html: html }); - + console.debug(html); + console.debug(""); // remove data-redactor-tag="" attribute html = html.replace(/(<[^>]+?) data-redactor-tag="[^"]+"/g, '$1'); @@ -276,12 +277,16 @@ RedactorPlugins.wbbcode = function() { // remove empty links html = html.replace(/]*?><\/a>/g, ''); + // unwrap

+ html = html.replace(/

<\/p>

<\/p>/, '

'); + // handle empty paragraphs not followed by an empty one html = html.replace(/

<\/p>

(?!
)/g, '

@@@wcf_empty_line@@@

'); // remove
right in front of

(does not match


since it has been converted already) html = html.replace(/<\/p>/g, '

'); - + console.debug(html); // convert paragraphs into single lines var $parts = html.split(/(<\/?(?:div|p)>)/); var $tmp = ''; @@ -601,7 +606,7 @@ RedactorPlugins.wbbcode = function() { // [table] html = html.replace(/]*>/gi, '[table]\n'); - html = html.replace(/<\/table>/gi, '[/table]\n'); + html = html.replace(/<\/table>\n?/gi, '[/table]\n'); // remove html = html.replace(/([\s\S]*?)<\/tbody>/, function(match, p1) {