From d3f5024601b71b724e8430f6e2122bd42fcadcbc Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 31 Jan 2019 12:14:30 +0100 Subject: [PATCH] Support tables in the code formatter --- .../files/js/3rdParty/redactor2/plugins/WoltLabSource.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js index a56e5294fa..ac5ed4e824 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js @@ -125,7 +125,7 @@ $.Redactor.prototype.WoltLabSource = function() { }, format: function (html) { - var blockTags = ['ul', 'ol', 'li']; + var blockTags = ['ul', 'ol', 'li', 'table', 'tbody', 'thead', 'tr', 'td', 'th']; this.block.tags.forEach(function(tag) { blockTags.push(tag); }); @@ -134,7 +134,7 @@ $.Redactor.prototype.WoltLabSource = function() { // block tags that are recognized as block tags, but both // newline and indentation matches inline elements - var blocksAsInline = ['p', 'li']; + var blocksAsInline = ['p', 'li', 'td', 'th']; var patternTagAttributes = '[^\'">]*(?:(?:"[^"]*"|\'[^\']*\')[^\'">]*)*'; @@ -154,6 +154,9 @@ $.Redactor.prototype.WoltLabSource = function() { return '\n<' + tag + attributes + '>' + (blocksAsInline.indexOf(tag) === -1 ? '\n' : ''); }); + // Remove empty lines between two adjacent block elements. + html = html.replace(new RegExp('(<(?:' + blockTags + ')(?:' + patternTagAttributes + ')>\n)\n+(?=<(?:' + blockTags + ')(?:' + patternTagAttributes + ')>)', 'g'), '$1'); + // avoid empty newline at quote start html = html.replace(/]*)>\n\t*\n(\t*)

\n$2