diff --git a/apps/client/src/widgets/find.ts b/apps/client/src/widgets/find.ts index 094a0a197..7580ba3a6 100644 --- a/apps/client/src/widgets/find.ts +++ b/apps/client/src/widgets/find.ts @@ -247,16 +247,16 @@ export default class FindWidget extends NoteContextAwareWidget { } async getHandler() { - if (this.note?.type === "render") { - return this.htmlHandler; - } - - const readOnly = await this.noteContext?.isReadOnly(); - - if (readOnly) { - return this.htmlHandler; - } else { - return this.note?.type === "code" ? this.codeHandler : this.textHandler; + switch (this.note?.type) { + case "render": + return this.htmlHandler; + case "code": + return this.codeHandler; + case "text": + return this.textHandler; + default: + const readOnly = await this.noteContext?.isReadOnly(); + return readOnly ? this.htmlHandler : this.textHandler; } } diff --git a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts index a2210081b..88e128079 100644 --- a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts +++ b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts @@ -99,6 +99,16 @@ export default class AbstractCodeTypeWidget extends TypeWidget { } } + async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) { + if (!this.isNoteContext(ntxId)) { + return; + } + + await this.initialized; + + resolve(this.codeEditor); + } + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { if (loadResults.isOptionReloaded("codeNoteTheme")) { const themeId = options.get("codeNoteTheme"); diff --git a/apps/client/src/widgets/type_widgets/editable_code.ts b/apps/client/src/widgets/type_widgets/editable_code.ts index 3f037ce34..9f4ff53cb 100644 --- a/apps/client/src/widgets/type_widgets/editable_code.ts +++ b/apps/client/src/widgets/type_widgets/editable_code.ts @@ -71,16 +71,6 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { }; } - async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) { - if (!this.isNoteContext(ntxId)) { - return; - } - - await this.initialized; - - resolve(this.codeEditor); - } - buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) { const items: TouchBarItem[] = []; const note = this.note;