return false;
}
+function notifyOfDataChanges(editor: CKEditor5.ClassicEditor.ClassicEditor, element: HTMLElement): void {
+ editor.model.document.on("change:data", () => {
+ dispatchToCkeditor(element).changeData();
+ });
+}
+
export async function setupCkeditor(
element: HTMLElement,
features: Features,
}
setupSubmitShortcut(ckeditor);
+ notifyOfDataChanges(cke, element);
const enableDebug = window.ENABLE_DEBUG_MODE && window.ENABLE_DEVELOPER_TOOLS;
if (enableDebug && Devtools._internal_.editorInspector()) {
const enum EventNames {
Autosave = "ckeditor5:autosave",
Bbcode = "ckeditor5:bbcode",
+ ChangeData = "ckeditor5:change-data",
CollectMetaData = "ckeditor5:collect-meta-data",
Destroy = "ckeditor5:destroy",
DiscardRecoveredData = "ckeditor5:discard-recovered-data",
);
}
+ changeData(): void {
+ this.#element.dispatchEvent(new CustomEvent<void>(EventNames.ChangeData));
+ }
+
destroy(): void {
this.#element.dispatchEvent(new CustomEvent<void>(EventNames.Destroy));
}
return this;
}
+ changeData(callback: () => void): this {
+ this.#element.addEventListener(EventNames.ChangeData, () => {
+ callback();
+ });
+
+ return this;
+ }
+
collectMetaData(callback: (payload: CollectMetaDataEventPayload) => void): this {
this.#element.addEventListener(EventNames.CollectMetaData, (event: CustomEvent<CollectMetaDataEventPayload>) => {
callback(event.detail);