mirror of
https://github.com/hansjone/mind-map.git
synced 2026-10-09 04:30:46 +08:00
feat: add PNG/SVG export and expandable card property tips
Toolbar exports PNG (fit+raster) and SVG; card click expands full fields, hover shows property tooltips, double-click opens the editor. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
23ff27122f
commit
4c9bd5b86f
22 changed files with 978 additions and 315 deletions
|
|
@ -390,6 +390,35 @@ export function startMindMapServer(
|
|||
}
|
||||
});
|
||||
|
||||
app.get("/api/canvases/:id/export.svg", async (c) => {
|
||||
try {
|
||||
const id = c.req.param("id");
|
||||
const result = (await runTool(
|
||||
"mindmap_export",
|
||||
{ format: "svg", canvasId: id },
|
||||
{ store, broadcast, defaultCanvasId: id },
|
||||
)) as {
|
||||
ok?: boolean;
|
||||
svg?: string;
|
||||
title?: string;
|
||||
};
|
||||
if (!result?.ok || typeof result.svg !== "string") {
|
||||
return c.json({ ok: false, error: "export_failed" }, 400);
|
||||
}
|
||||
const safe =
|
||||
String(result.title ?? "mindmap").replace(/[\\/:*?"<>|]+/g, "_") ||
|
||||
"mindmap";
|
||||
return new Response(result.svg, {
|
||||
headers: {
|
||||
"Content-Type": "image/svg+xml; charset=utf-8",
|
||||
"Content-Disposition": `attachment; filename="${safe}.svg"`,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return c.json({ ok: false, error: "not_found" }, 404);
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/api/tools/:name", async (c) => {
|
||||
const name = c.req.param("name");
|
||||
const args = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue