From 66c2b9bb9682fadb0156c2fae4c3a242ae103be2 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 19 Feb 2015 16:19:01 +0100 Subject: [PATCH] Fixed handling of tables when converting HTML -> BBCode --- .../files/js/3rdParty/redactor/plugins/wbbcode.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) { -- 2.20.1