Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 1f57aaf

Browse files
committed
feat(code): proper search for read-only notes
1 parent 41f142a commit 1f57aaf

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

apps/client/src/widgets/find.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,16 @@ export default class FindWidget extends NoteContextAwareWidget {
247247
}
248248

249249
async getHandler() {
250-
if (this.note?.type === "render") {
251-
return this.htmlHandler;
252-
}
253-
254-
const readOnly = await this.noteContext?.isReadOnly();
255-
256-
if (readOnly) {
257-
return this.htmlHandler;
258-
} else {
259-
return this.note?.type === "code" ? this.codeHandler : this.textHandler;
250+
switch (this.note?.type) {
251+
case "render":
252+
return this.htmlHandler;
253+
case "code":
254+
return this.codeHandler;
255+
case "text":
256+
return this.textHandler;
257+
default:
258+
const readOnly = await this.noteContext?.isReadOnly();
259+
return readOnly ? this.htmlHandler : this.textHandler;
260260
}
261261
}
262262

apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
9999
}
100100
}
101101

102+
async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) {
103+
if (!this.isNoteContext(ntxId)) {
104+
return;
105+
}
106+
107+
await this.initialized;
108+
109+
resolve(this.codeEditor);
110+
}
111+
102112
async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
103113
if (loadResults.isOptionReloaded("codeNoteTheme")) {
104114
const themeId = options.get("codeNoteTheme");

apps/client/src/widgets/type_widgets/editable_code.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
7171
};
7272
}
7373

74-
async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) {
75-
if (!this.isNoteContext(ntxId)) {
76-
return;
77-
}
78-
79-
await this.initialized;
80-
81-
resolve(this.codeEditor);
82-
}
83-
8474
buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) {
8575
const items: TouchBarItem[] = [];
8676
const note = this.note;

0 commit comments

Comments
 (0)