client,server: Set up SVG rendering for mindmap

This commit is contained in:
Elian Doran 2024-09-01 22:36:50 +03:00
parent ad88042e5b
commit 1437df7de1
No known key found for this signature in database
3 changed files with 15 additions and 3 deletions

View File

@ -34,7 +34,7 @@ async function getRenderedContent(entity, options = {}) {
else if (type === 'code') {
await renderCode(entity, $renderedContent);
}
else if (type === 'image' || type === 'canvas') {
else if (['image', 'canvas', 'mindMap'].includes(type)) {
renderImage(entity, $renderedContent, options);
}
else if (!options.tooltip && ['file', 'pdf', 'audio', 'video'].includes(type)) {

View File

@ -83,8 +83,18 @@ export default class MindMapWidget extends TypeWidget {
return;
}
const svgContent = await this.mind.exportSvg().text();
return {
content: mind.getDataString()
content: mind.getDataString(),
attachments: [
{
role: "image",
title: "mindmap-export.svg",
mime: "image/svg+xml",
content: svgContent,
position: 0
}
]
};
}

View File

@ -25,7 +25,7 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) {
if (!image) {
res.set('Content-Type', 'image/png');
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
} else if (!["image", "canvas", "mermaid"].includes(image.type)) {
} else if (![ "image", "canvas", "mermaid", "mindMap" ].includes(image.type)) {
return res.sendStatus(400);
}
@ -33,6 +33,8 @@ function returnImageInt(image: BNote | BRevision | null, res: Response) {
renderSvgAttachment(image, res, 'canvas-export.svg');
} else if (image.type === 'mermaid') {
renderSvgAttachment(image, res, 'mermaid-export.svg');
} else if (image.type === "mindMap") {
renderSvgAttachment(image, res, 'mindmap-export.svg');
} else {
res.set('Content-Type', image.mime);
res.set("Cache-Control", "no-cache, no-store, must-revalidate");