Strip trailing `<br>` in `<td>`
authorAlexander Ebert <ebert@woltlab.com>
Fri, 5 May 2023 09:56:34 +0000 (11:56 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 8 May 2023 16:34:04 +0000 (18:34 +0200)
ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js

index 88edda2f39b8331ba494e1e967201bf8c074ffd7..6ed22489e2b160dee20cab579b011847fe7cad94 100644 (file)
@@ -52,17 +52,17 @@ function removeTrailingBr(div: HTMLElement): void {
       return;
     }
 
-    const paragraph = br.closest("p");
-    if (paragraph === null) {
+    const paragraphOrTableCell = br.closest("p, td");
+    if (paragraphOrTableCell === null) {
       return;
     }
 
-    if (!DomUtil.isAtNodeEnd(br, paragraph)) {
+    if (!DomUtil.isAtNodeEnd(br, paragraphOrTableCell)) {
       return;
     }
 
-    if (paragraph.innerHTML === "<br>") {
-      paragraph.remove();
+    if (paragraphOrTableCell.tagName === "P" && paragraphOrTableCell.innerHTML === "<br>") {
+      paragraphOrTableCell.remove();
     } else {
       br.remove();
     }
index a40ec4aa1fb44525e16d4080e9f1505f9eb38a94..aff6a7c7aeee4089b860688218bb5be4c3e7b058 100644 (file)
@@ -49,15 +49,15 @@ define(["require", "exports", "tslib", "../../Dom/Util"], function (require, exp
             if (br.dataset.ckeFiller === "true") {
                 return;
             }
-            const paragraph = br.closest("p");
-            if (paragraph === null) {
+            const paragraphOrTableCell = br.closest("p, td");
+            if (paragraphOrTableCell === null) {
                 return;
             }
-            if (!Util_1.default.isAtNodeEnd(br, paragraph)) {
+            if (!Util_1.default.isAtNodeEnd(br, paragraphOrTableCell)) {
                 return;
             }
-            if (paragraph.innerHTML === "<br>") {
-                paragraph.remove();
+            if (paragraphOrTableCell.tagName === "P" && paragraphOrTableCell.innerHTML === "<br>") {
+                paragraphOrTableCell.remove();
             }
             else {
                 br.remove();