Fixed newline handling after `</table>`
authorAlexander Ebert <ebert@woltlab.com>
Tue, 4 Jul 2017 09:57:09 +0000 (11:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 4 Jul 2017 09:57:09 +0000 (11:57 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index a217571a78fb9ca82ade4b7c832b107b34505fe4..d8b768a2b8f141323cb9e4bd988895fba81e3323 100644 (file)
@@ -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 {