From f1ce58913a0846e5259e5ab971051495ee385314 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 22 Oct 2026 15:16:32 +0200 Subject: [PATCH] Highlight quotes in the quote list that are already inserted into the editor ref https://www.woltlab.com/community/thread/317377-markierung-bereits-eingef%C3%BCgter-zitate/ --- .../Core/Component/Ckeditor/Quote.ts | 8 ++-- ts/WoltLabSuite/Core/Component/Quote/List.ts | 37 +++++++++++++++++-- .../Core/Component/Quote/Message.ts | 6 ++- .../js/3rdParty/ckeditor/ckeditor5.bundle.js | 2 +- .../Core/Component/Ckeditor/Quote.js | 7 ++-- .../WoltLabSuite/Core/Component/Quote/List.js | 30 +++++++++++++-- .../Core/Component/Quote/Message.js | 6 ++- ...PreloadPhrasesCollectingListener.class.php | 1 + .../install/files/style/bbcode/quote.scss | 10 +++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 11 files changed, 91 insertions(+), 18 deletions(-) diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Quote.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Quote.ts index 036e79f5a87..a305c0d48a8 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Quote.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Quote.ts @@ -1,8 +1,8 @@ /** * Inserts quotes into the editor. * - * @author Alexander Ebert - * @copyright 2001-2023 WoltLab GmbH + * @author Alexander Ebert, Marcel Werk + * @copyright 2001-2026 WoltLab GmbH * @license GNU Lesser General Public License * @since 6.0 * @woltlabExcludeBundle tiny @@ -22,9 +22,10 @@ function insertQuote(editor: CKEditor, payload: InsertQuoteEventPayload) { author = escapeHTML(author); link = escapeHTML(link); + const quoteId = payload.uuid !== undefined ? ` data-quote-id="${escapeHTML(payload.uuid)}"` : ""; editor.insertHtml( - `${content} + `${content}


`, ); } @@ -50,6 +51,7 @@ export type InsertQuoteEventPayload = { content: string; isText: boolean; link: string; + uuid?: string; }; export function setup(element: HTMLElement): void { diff --git a/ts/WoltLabSuite/Core/Component/Quote/List.ts b/ts/WoltLabSuite/Core/Component/Quote/List.ts index fba84d1c166..c73543d1fc1 100644 --- a/ts/WoltLabSuite/Core/Component/Quote/List.ts +++ b/ts/WoltLabSuite/Core/Component/Quote/List.ts @@ -1,13 +1,14 @@ /** * Handles quotes for CKEditor 5 message fields. * - * @author Olaf Braun - * @copyright 2001-2024 WoltLab GmbH + * @author Olaf Braun, Marcel Werk + * @copyright 2001-2026 WoltLab GmbH * @license GNU Lesser General Public License * @since 6.2 * @woltlabExcludeBundle tiny */ +import { getCkeditor } from "WoltLabSuite/Core/Component/Ckeditor"; import { listenToCkeditor, dispatchToCkeditor } from "WoltLabSuite/Core/Component/Ckeditor/Event"; import { getTabMenu } from "WoltLabSuite/Core/Component/Message/MessageTabMenu"; import { getPhrase } from "WoltLabSuite/Core/Language"; @@ -19,6 +20,7 @@ import { markQuoteAsUsed, getUsedQuotes, } from "WoltLabSuite/Core/Component/Quote/Storage"; +import { debounce } from "WoltLabSuite/Core/Core"; import DomUtil from "WoltLabSuite/Core/Dom/Util"; import { escapeHTML } from "WoltLabSuite/Core/StringUtil"; @@ -40,6 +42,12 @@ class QuoteList { this.#formSubmitted(); }); + listenToCkeditor(this.#editor).changeData( + debounce(() => { + this.#markInsertedQuotes(); + }, 500), + ); + this.renderQuotes(); } @@ -57,12 +65,15 @@ class QuoteList { quotes.forEach((quote, uuid) => { const fragment = DomUtil.createFragmentFromHtml(` -
+