diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsx index 2f9d122b6..88bca116e 100644 --- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx +++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx @@ -145,6 +145,14 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext refreshIncludedNote(containerRef.current, noteId); }); + useTriliumEvent("executeWithTextEditor", async ({ callback, resolve, ntxId: eventNtxId }) => { + if (eventNtxId !== ntxId) return; + const editor = await waitForEditor() as CKTextEditor | undefined; + if (!editor) return; + if (callback) callback(editor); + resolve(editor); + }); + async function waitForEditor() { await initialized.current; const editor = watchdogRef.current?.editor; diff --git a/apps/client/src/widgets/type_widgets_old/editable_text.ts b/apps/client/src/widgets/type_widgets_old/editable_text.ts index c37787b03..9e8890d08 100644 --- a/apps/client/src/widgets/type_widgets_old/editable_text.ts +++ b/apps/client/src/widgets/type_widgets_old/editable_text.ts @@ -36,24 +36,6 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { return this.watchdog?.editor; } - async executeWithTextEditorEvent({ callback, resolve, ntxId }: EventData<"executeWithTextEditor">) { - if (!this.isNoteContext(ntxId)) { - return; - } - - await this.initialized; - - if (!this.watchdog.editor) { - return; - } - - if (callback) { - callback(this.watchdog.editor as CKTextEditor); - } - - resolve(this.watchdog.editor as CKTextEditor); - } - async reinitialize() { const data = this.watchdog.editor?.getData(); await this.reinitializeWithData(data ?? "");