From 3a00dcd0d9836a3f8a2bc74074f9c5b2b54e0d44 Mon Sep 17 00:00:00 2001 From: Alexander Ebert <ebert@woltlab.com> Date: Tue, 4 Jul 2017 11:57:09 +0200 Subject: [PATCH] Fixed newline handling after `</table>` --- .../files/js/3rdParty/redactor/plugins/wbbcode.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js index a217571a78..d8b768a2b8 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js @@ -426,9 +426,14 @@ RedactorPlugins.wbbcode = function() { html = $tmp; + // empty lines following a table aren't recognized properly + html = html.replace(/<\/table>@@@wcf_empty_line@@@/g, '</table>@@@wcf_after_table_empty_line@@@'); + html = html.replace(/@@@wcf_empty_line@@@/g, '\n'); html = html.replace(/\n\n$/, '\n'); + html = html.replace(/@@@wcf_after_table_empty_line@@@/g, '\n\n'); + // convert all <br> into \n html = html.replace(/<br>$/, ''); html = html.replace(/<br>/g, '\n'); @@ -1246,8 +1251,8 @@ RedactorPlugins.wbbcode = function() { if ($line.match(/^<([a-z]+)/) || $line.match(/<\/([a-z]+)>$/)) { if (this.reIsBlock.test(RegExp.$1.toUpperCase()) || RegExp.$1.toUpperCase() === 'TABLE') { - // check if line starts and ends with the same tag, or ends with </p> - if ($line.match(/^<([a-z]+).*<\/\1>/)) { + // check if line starts and ends with the same tag, or ends with </p> or </table> + if ($line.match(/^<([a-z]+).*<\/\1>/) || $line.match(/<\/table>$/)) { data += $line; } else { -- 2.20.1