mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 17:08:58 +01:00
chore(react/type_widget): save mindmap attachment
This commit is contained in:
parent
3417e37f16
commit
7d99a92bd9
@ -25,7 +25,21 @@ export default function MindMap({ note }: TypeWidgetProps) {
|
|||||||
const apiRef = useRef<MindElixirInstance>(null);
|
const apiRef = useRef<MindElixirInstance>(null);
|
||||||
const spacedUpdate = useEditorSpacedUpdate({
|
const spacedUpdate = useEditorSpacedUpdate({
|
||||||
note,
|
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) => {
|
onContentChange: (content) => {
|
||||||
let newContent: MindElixirData;
|
let newContent: MindElixirData;
|
||||||
if (content) {
|
if (content) {
|
||||||
|
|||||||
@ -48,27 +48,6 @@ export default class MindMapWidget extends TypeWidget {
|
|||||||
this.mind = mind;
|
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() {
|
async renderSvg() {
|
||||||
return await this.mind!.exportSvg().text();
|
return await this.mind!.exportSvg().text();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user