From: Alexander Ebert Date: Mon, 8 May 2023 14:33:26 +0000 (+0200) Subject: Sync the implementation of the number of paragraphs marked for removal X-Git-Tag: 6.0.0_Alpha_1~136^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c3dd207d8913797c88b7709b9e5785cc588ff0ea;p=GitHub%2FWoltLab%2FWCF.git Sync the implementation of the number of paragraphs marked for removal --- diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts index fee08a6a5e..cb7f75c273 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Cleanup.ts @@ -105,18 +105,11 @@ function reduceSpacerParagraphs(paragraphs: HTMLParagraphElement[]): void { // can safely remove it. candidate.remove(); } else { - let numberOfParagraphsToRemove: number; - // We need to reduce the number of paragraphs by half, unless it // is an uneven number in which case we need to remove one // additional paragraph. - if (offset % 2 === 1) { - // 2 -> 1, 4 -> 2 - numberOfParagraphsToRemove = Math.ceil(offset / 2); - } else { - // 3 -> 1, 5 -> 2 - numberOfParagraphsToRemove = Math.ceil(offset / 2) + 1; - } + const totalNumberOfParagraphs = offset + 1; + const numberOfParagraphsToRemove = Math.ceil(totalNumberOfParagraphs / 2); const removeParagraphs = paragraphs.slice(i, i + numberOfParagraphsToRemove); removeParagraphs.forEach((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 3e0f18b1d0..ccbe5f0a33 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Cleanup.js @@ -93,18 +93,11 @@ define(["require", "exports", "tslib", "../../Dom/Util"], function (require, exp candidate.remove(); } else { - let numberOfParagraphsToRemove; // We need to reduce the number of paragraphs by half, unless it // is an uneven number in which case we need to remove one // additional paragraph. - if (offset % 2 === 1) { - // 2 -> 1, 4 -> 2 - numberOfParagraphsToRemove = Math.ceil(offset / 2); - } - else { - // 3 -> 1, 5 -> 2 - numberOfParagraphsToRemove = Math.ceil(offset / 2) + 1; - } + const totalNumberOfParagraphs = offset + 1; + const numberOfParagraphsToRemove = Math.ceil(totalNumberOfParagraphs / 2); const removeParagraphs = paragraphs.slice(i, i + numberOfParagraphsToRemove); removeParagraphs.forEach((paragraph) => { paragraph.remove();