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
fix(search): keep disabled built-in relations out of note.links
Elian Doranee67f41230e5
diff --git a/packages/trilium-core/src/services/search/expressions/linked_notes.ts b/packages/trilium-core/src/services/search/expressions/linked_notes.tsindex 1ac5288a22..55fb7658ff 100644--- a/packages/trilium-core/src/services/search/expressions/linked_notes.ts+++ b/packages/trilium-core/src/services/search/expressions/linked_notes.ts@@ -59,7 +59,11 @@ export default class LinkedNotesExp extends Expression {const LINK_RELATIONS = new Set([ "internalLink", "imageLink", "includeNoteLink", "relationMapLink" ]);const BUILTIN_RELATIONS = new Set(BUILTIN_ATTRIBUTES.filter((attr) => attr.type === "relation").map((attr) => attr.name));-/** A relation the user created, or one of `LINK_RELATIONS`; other built-in relations configure the note. */+/**+ * A relation the user created, or one of `LINK_RELATIONS`; other built-in relations configure the+ * note. A built-in relation disabled by safe import keeps its name behind a `disabled:` prefix.+ */export function isLink(relation: BAttribute) {- return LINK_RELATIONS.has(relation.name) || !BUILTIN_RELATIONS.has(relation.name);+ const name = relation.name.replace(/^disabled:/, "");+ return LINK_RELATIONS.has(name) || !BUILTIN_RELATIONS.has(name);}diff --git a/packages/trilium-core/src/services/search/services/search.spec.ts b/packages/trilium-core/src/services/search/services/search.spec.tsindex 3bc26b77fc..e03430b68b 100644--- a/packages/trilium-core/src/services/search/services/search.spec.ts+++ b/packages/trilium-core/src/services/search/services/search.spec.ts@@ -567,7 +567,8 @@ describe("Search", () => {const book = note("The Hobbit").relation("author", tolkien.note);const fromTemplate = note("Created from Tolkien").relation("template", tolkien.note);const savedSearch = note("Search under Tolkien", { type: "search" }).relation("ancestor", tolkien.note);- rootNote.child(tolkien).child(essay).child(book).child(fromTemplate).child(savedSearch);+ const imported = note("Imported widget").relation("disabled:widget", tolkien.note);+ rootNote.child(tolkien).child(essay).child(book).child(fromTemplate).child(savedSearch).child(imported);const titles = (query: string) => searchService.findResultsWithQuery(query, new SearchContext()).map((result) => becca.notes[result.noteId].title)