diff --git a/ts/WoltLabSuite/Core/Component/Quote/List.ts b/ts/WoltLabSuite/Core/Component/Quote/List.ts index dcfa6fd67e5..5d3693adb70 100644 --- a/ts/WoltLabSuite/Core/Component/Quote/List.ts +++ b/ts/WoltLabSuite/Core/Component/Quote/List.ts @@ -11,7 +11,7 @@ import { listenToCkeditor, dispatchToCkeditor } from "WoltLabSuite/Core/Component/Ckeditor/Event"; import { getTabMenu } from "WoltLabSuite/Core/Component/Message/MessageTabMenu"; import { getPhrase } from "WoltLabSuite/Core/Language"; -import { setActiveEditor, removeQuoteStatus } from "WoltLabSuite/Core/Component/Quote/Message"; +import { setActiveEditor, removeQuoteStatus, removeActiveEditor } from "WoltLabSuite/Core/Component/Quote/Message"; import { getQuotes, getMessage, @@ -156,5 +156,7 @@ export function setup(editorId: string, containerId?: string): void { setActiveEditor(ckeditor, ckeditor.features.quoteBlock); } }); + }).destroy(() => { + removeActiveEditor(editor); }); } diff --git a/ts/WoltLabSuite/Core/Component/Quote/Message.ts b/ts/WoltLabSuite/Core/Component/Quote/Message.ts index 7ca07fcc823..ad1407f79c7 100644 --- a/ts/WoltLabSuite/Core/Component/Quote/Message.ts +++ b/ts/WoltLabSuite/Core/Component/Quote/Message.ts @@ -110,6 +110,16 @@ export function setActiveEditor(editor?: CKEditor, supportDirectInsert: boolean activeEditor = editor; } +export function removeActiveEditor(editorSource: HTMLElement): void { + if (!activeEditor) { + return; + } + + if (activeEditor.sourceElement === editorSource) { + setActiveEditor(); + } +} + export function removeQuoteStatus(key: string): void { quoteMessageButtons.get(key)?.classList.remove("active"); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/List.js index 42ea0a3efd2..611f35b2331 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/List.js @@ -122,6 +122,8 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Component/Ckeditor/Eve (0, Message_1.setActiveEditor)(ckeditor, ckeditor.features.quoteBlock); } }); + }).destroy(() => { + (0, Message_1.removeActiveEditor)(editor); }); } }); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/Message.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/Message.js index e6c299521c0..1c0e40b56a9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/Message.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/Message.js @@ -12,6 +12,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Dom/Util", "WoltLabSui Object.defineProperty(exports, "__esModule", { value: true }); exports.registerContainer = registerContainer; exports.setActiveEditor = setActiveEditor; + exports.removeActiveEditor = removeActiveEditor; exports.removeQuoteStatus = removeQuoteStatus; Util_1 = tslib_1.__importDefault(Util_1); let selectedMessage; @@ -66,6 +67,14 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Dom/Util", "WoltLabSui copyQuote.querySelector(".jsQuoteManagerQuoteAndInsert").hidden = !supportDirectInsert; activeEditor = editor; } + function removeActiveEditor(editorSource) { + if (!activeEditor) { + return; + } + if (activeEditor.sourceElement === editorSource) { + setActiveEditor(); + } + } function removeQuoteStatus(key) { quoteMessageButtons.get(key)?.classList.remove("active"); }