From e63d3489b0679b1e07d79f25cb793cead64f25d6 Mon Sep 17 00:00:00 2001 From: CobriMediaJulien <56324041+CobriMediaJulien@users.noreply.github.com> Date: Sun, 8 Dec 2024 22:52:51 +0100 Subject: [PATCH] Better Canvas search to prevent metadata beeing searched in fulltext --- .../expressions/note_content_fulltext.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/services/search/expressions/note_content_fulltext.ts b/src/services/search/expressions/note_content_fulltext.ts index 106d5d3e3..546191a3c 100644 --- a/src/services/search/expressions/note_content_fulltext.ts +++ b/src/services/search/expressions/note_content_fulltext.ts @@ -133,6 +133,30 @@ class NoteContentFulltextExp extends Expression { content = content.replace(/ /g, ' '); } + else if (type === 'mindMap' && mime === 'application/json') { + console.log("mindMap", content); + let mindMapcontent = JSON.parse (content); + console.log("mindMap", mindMapcontent); + let topic = mindMapcontent.nodedata.topic; + console.log("topic22", topic); + content = utils.normalize(topic.toString()); + } + else if (type === 'canvas' && mime === 'application/json') { + interface Element { + type: string; + text?: string; // Optional since not all objects have a `text` property + 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 + console.log(texts) + } + return content.trim(); }