mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 15:24:24 +01:00
fix(search): add null check for canvas elements in fulltext search (#8090)
This commit is contained in:
commit
9ef4ab9983
@ -315,13 +315,18 @@ class NoteContentFulltextExp extends Expression {
|
|||||||
[key: string]: any; // Other properties that may exist
|
[key: string]: any; // Other properties that may exist
|
||||||
}
|
}
|
||||||
|
|
||||||
let canvasContent = JSON.parse(content);
|
const canvasContent = JSON.parse(content);
|
||||||
const elements: Element[] = canvasContent.elements;
|
const elements = canvasContent.elements;
|
||||||
|
|
||||||
|
if (Array.isArray(elements)) {
|
||||||
const texts = elements
|
const texts = elements
|
||||||
.filter((element: Element) => element.type === "text" && element.text) // Filter for 'text' type elements with a 'text' property
|
.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
|
.map((element: Element) => element.text!); // Use `!` to assert `text` is defined after filtering
|
||||||
|
|
||||||
content = normalize(texts.toString());
|
content = normalize(texts.join(" "));
|
||||||
|
} else {
|
||||||
|
content = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return content.trim();
|
return content.trim();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user