From 5ee2636244d34301fd773d5d39ff0d43b2d747b4 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 May 2023 18:20:44 +0200 Subject: [PATCH] Fix the detection of `


` --- ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts | 8 +++++--- .../js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts index cb7f75c273..9b6447c646 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts @@ -70,9 +70,11 @@ function getPossibleSpacerParagraphs(div: HTMLElement): HTMLParagraphElement[] { const paragraphs: HTMLParagraphElement[] = []; div.querySelectorAll("p").forEach((paragraph) => { - if (paragraph.childElementCount === 1) { - const child = paragraph.children[0] as HTMLElement; - if (child.tagName === "BR" && child.dataset.ckeFiller !== "true") { + paragraph.normalize(); + + if (paragraph.childNodes.length === 1) { + const child = paragraph.childNodes[0]; + if (child instanceof HTMLBRElement && child.dataset.ckeFiller !== "true") { paragraphs.push(paragraph); } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js index ccbe5f0a33..46f0f41c68 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js @@ -63,9 +63,10 @@ define(["require", "exports", "tslib", "../../Dom/Util"], function (require, exp function getPossibleSpacerParagraphs(div) { const paragraphs = []; div.querySelectorAll("p").forEach((paragraph) => { - if (paragraph.childElementCount === 1) { - const child = paragraph.children[0]; - if (child.tagName === "BR" && child.dataset.ckeFiller !== "true") { + paragraph.normalize(); + if (paragraph.childNodes.length === 1) { + const child = paragraph.childNodes[0]; + if (child instanceof HTMLBRElement && child.dataset.ckeFiller !== "true") { paragraphs.push(paragraph); } } -- 2.20.1