From 26f466e17ac8e24f1089b3f9b361f4c2a7595a05 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 22 Jan 2024 13:17:26 +0100 Subject: [PATCH] Update the JS artifacts --- .../files/js/WoltLabSuite/Core/Component/Ckeditor.js | 6 ++++++ .../js/WoltLabSuite/Core/Component/Ckeditor/Event.js | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js index abdd6c17b5..86d1372fba 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor.js @@ -187,6 +187,11 @@ define(["require", "exports", "tslib", "./Ckeditor/Attachment", "./Ckeditor/Medi } return false; } + function notifyOfDataChanges(editor, element) { + editor.model.document.on("change:data", () => { + (0, Event_1.dispatchToCkeditor)(element).changeData(); + }); + } async function setupCkeditor(element, features, bbcodes, codeBlockLanguages, licenseKey) { if (instances.has(element)) { throw new TypeError(`Cannot initialize the editor for '${element.id}' twice.`); @@ -228,6 +233,7 @@ define(["require", "exports", "tslib", "./Ckeditor/Attachment", "./Ckeditor/Medi (0, Event_1.dispatchToCkeditor)(element).discardRecoveredData(); } (0, Keyboard_1.setupSubmitShortcut)(ckeditor); + notifyOfDataChanges(cke, element); const enableDebug = window.ENABLE_DEBUG_MODE && window.ENABLE_DEVELOPER_TOOLS; if (enableDebug && Devtools_1.default._internal_.editorInspector()) { void new Promise((resolve_2, reject_2) => { require(["@ckeditor/ckeditor5-inspector"], resolve_2, reject_2); }).then(tslib_1.__importStar).then((inspector) => { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Event.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Event.js index db3d3ede9c..7cb97273b3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Event.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Event.js @@ -21,6 +21,9 @@ define(["require", "exports"], function (require, exports) { detail: payload, })); } + changeData() { + this.#element.dispatchEvent(new CustomEvent("ckeditor5:change-data" /* EventNames.ChangeData */)); + } destroy() { this.#element.dispatchEvent(new CustomEvent("ckeditor5:destroy" /* EventNames.Destroy */)); } @@ -100,6 +103,12 @@ define(["require", "exports"], function (require, exports) { }); return this; } + changeData(callback) { + this.#element.addEventListener("ckeditor5:change-data" /* EventNames.ChangeData */, () => { + callback(); + }); + return this; + } collectMetaData(callback) { this.#element.addEventListener("ckeditor5:collect-meta-data" /* EventNames.CollectMetaData */, (event) => { callback(event.detail); -- 2.20.1