Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(find): allow searching in view source
Elian Doran59994a58770f
diff --git a/apps/client/src/widgets/find.ts b/apps/client/src/widgets/find.tsindex d694d087ad..37756b4750 100644--- a/apps/client/src/widgets/find.ts+++ b/apps/client/src/widgets/find.ts@@ -195,7 +195,9 @@ export default class FindWidget extends NoteContextAwareWidget {return;}- if (!SUPPORTED_NOTE_TYPES.includes(this.note?.type ?? "")) {+ const isSourceView = this.noteContext?.viewScope?.viewMode === "source";++ if (!isSourceView && !SUPPORTED_NOTE_TYPES.includes(this.note?.type ?? "")) {return;}@@ -204,7 +206,7 @@ export default class FindWidget extends NoteContextAwareWidget {const isReadOnly = await this.noteContext?.isReadOnly();let selectedText = "";- if (this.note?.type === "code" && this.noteContext) {+ if ((this.note?.type === "code" || isSourceView) && this.noteContext) {const codeEditor = await this.noteContext.getCodeEditor();selectedText = codeEditor.getSelectedText();} else {@@ -249,6 +251,11 @@ export default class FindWidget extends NoteContextAwareWidget {}async getHandler() {+ // In source view, all note types render via a read-only CodeMirror editor.+ if (this.noteContext?.viewScope?.viewMode === "source") {+ return this.codeHandler;+ }+switch (this.note?.type) {case "render":return this.htmlHandler;@@ -362,7 +369,9 @@ export default class FindWidget extends NoteContextAwareWidget {}isEnabled() {- return super.isEnabled() && SUPPORTED_NOTE_TYPES.includes(this.note?.type ?? "");+ return super.isEnabled()+ && (SUPPORTED_NOTE_TYPES.includes(this.note?.type ?? "")+ || this.noteContext?.viewScope?.viewMode === "source");}async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {