From: Alexander Ebert Date: Thu, 31 Jan 2019 11:14:30 +0000 (+0100) Subject: Support tables in the code formatter X-Git-Tag: 5.2.0_Alpha_1~328 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d3f5024601b71b724e8430f6e2122bd42fcadcbc;p=GitHub%2FWoltLab%2FWCF.git Support tables in the code formatter --- 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