Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/type_widget): save mindmap attachment

Elian Doran7d99a92bd9aa
diff --git a/apps/client/src/widgets/type_widgets/MindMap.tsx b/apps/client/src/widgets/type_widgets/MindMap.tsx
index 0883325c9b..ef6358ec21 100644
--- a/apps/client/src/widgets/type_widgets/MindMap.tsx
+++ b/apps/client/src/widgets/type_widgets/MindMap.tsx
@@ -25,7 +25,21 @@ export default function MindMap({ note }: TypeWidgetProps) {
const apiRef = useRef<MindElixirInstance>(null);
const spacedUpdate = useEditorSpacedUpdate({
note,
- getData: () => ({ content: apiRef.current?.getDataString() }),
+ getData: () => {
+ if (!apiRef.current) return;
+ return {
+ content: apiRef.current.getDataString(),
+ attachments: [
+ {
+ role: "image",
+ title: "mindmap-export.svg",
+ mime: "image/svg+xml",
+ content: apiRef.current.exportSvg().text(),
+ position: 0
+ }
+ ]
+ }
+ },
onContentChange: (content) => {
let newContent: MindElixirData;
if (content) {
diff --git a/apps/client/src/widgets/type_widgets_old/mind_map.ts b/apps/client/src/widgets/type_widgets_old/mind_map.ts
index c06ec2313f..59a9bb6468 100644
--- a/apps/client/src/widgets/type_widgets_old/mind_map.ts
+++ b/apps/client/src/widgets/type_widgets_old/mind_map.ts
@@ -48,27 +48,6 @@ export default class MindMapWidget extends TypeWidget {
this.mind = mind;
}
- async getData() {
- const mind = this.mind;
- if (!mind) {
- return;
- }
-
- const svgContent = await this.renderSvg();
- return {
- content: mind.getDataString(),
- attachments: [
- {
- role: "image",
- title: "mindmap-export.svg",
- mime: "image/svg+xml",
- content: svgContent,
- position: 0
- }
- ]
- };
- }
-
async renderSvg() {
return await this.mind!.exportSvg().text();
}