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
Update note_content_fulltext.ts
CobriMediaJulien24d5311b9f57
diff --git a/src/services/search/expressions/note_content_fulltext.ts b/src/services/search/expressions/note_content_fulltext.tsindex 11a8c09f34..9ede1a44a1 100644--- a/src/services/search/expressions/note_content_fulltext.ts+++ b/src/services/search/expressions/note_content_fulltext.ts@@ -12,6 +12,7 @@ import striptags from "striptags";import utils from "../../utils.js";import sql from "../../sql.js";+const ALLOWED_OPERATORS = ['=', '!=', '*=*', '*=', '=*', '%='];const cachedRegexes: Record<string, RegExp> = {};@@ -134,9 +135,55 @@ class NoteContentFulltextExp extends Expression {content = content.replace(/ /g, ' ');}else if (type === 'mindMap' && mime === 'application/json') {+let mindMapcontent = JSON.parse (content);- let topic = mindMapcontent.nodedata.topic;- content = utils.normalize(topic.toString());++ // Define interfaces for the JSON structure+ interface MindmapNode {+ id: string;+ topic: string;+ children: MindmapNode[]; // Recursive structure+ direction?: number;+ expanded?: boolean;+ }++ interface MindmapData {+ nodedata: MindmapNode;+ arrows: any[]; // If you know the structure, replace `any` with the correct type+ summaries: any[];+ direction: number;+ theme: {+ name: string;+ type: string;+ palette: string[];+ cssvar: Record<string, string>; // Object with string keys and string values+ };+ }++ // Recursive function to collect all topics+ function collectTopics(node: MindmapNode): string[] {+ // Collect the current node's topic+ let topics = [node.topic];++ // If the node has children, collect topics recursively+ if (node.children && node.children.length > 0) {+ for (const child of node.children) {+ topics = topics.concat(collectTopics(child));+ }+ }++ return topics;+ }+++ // Start extracting from the root node+ const topicsArray = collectTopics(mindMapcontent.nodedata);++ // Combine topics into a single string+ const topicsString = topicsArray.join(", ");+++ content = utils.normalize(topicsString.toString());}else if (type === 'canvas' && mime === 'application/json') {interface Element {@@ -145,12 +192,14 @@ class NoteContentFulltextExp extends Expression {id: string;[key: string]: any; // Other properties that may exist}- console.log("hier")+let canvasContent = JSON.parse (content);const elements: Element [] = canvasContent.elements;const texts = elements.filter((element: Element) => element.type === 'text' && element.text) // Filter for 'text' type elements with a 'text' property.map((element: Element) => element.text!); // Use `!` to assert `text` is defined after filtering++ content =utils.normalize(texts.toString())}