|
|
|
|
@ -131,52 +131,7 @@ class NoteContentFulltextExp extends Expression {
|
|
|
|
|
|
|
|
|
|
content = content.replace(/ /g, " ");
|
|
|
|
|
} else if (type === "mindMap" && mime === "application/json") {
|
|
|
|
|
let mindMapcontent = JSON.parse(content);
|
|
|
|
|
|
|
|
|
|
// 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 = normalize(topicsString.toString());
|
|
|
|
|
content = processMindmapContent(content);
|
|
|
|
|
} else if (type === "canvas" && mime === "application/json") {
|
|
|
|
|
interface Element {
|
|
|
|
|
type: string;
|
|
|
|
|
@ -215,4 +170,63 @@ class NoteContentFulltextExp extends Expression {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function processMindmapContent(content: string) {
|
|
|
|
|
let mindMapcontent;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
mindMapcontent = JSON.parse(content);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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[] {
|
|
|
|
|
if (!node) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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(", ");
|
|
|
|
|
|
|
|
|
|
return normalize(topicsString.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default NoteContentFulltextExp;
|
|
|
|
|
|