feat(mindmap): add PNG export

This commit is contained in:
Elian Doran 2025-03-22 16:35:07 +02:00
parent 67bfeda3d9
commit ab4e9db864
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View File

@ -11,7 +11,7 @@ const TPL = `
export default class PngExportButton extends NoteContextAwareWidget {
isEnabled() {
return super.isEnabled() && ["mermaid"].includes(this.note?.type ?? "") && this.note?.isContentAvailable() && this.noteContext?.viewScope?.viewMode === "default";
return super.isEnabled() && ["mermaid", "mindMap"].includes(this.note?.type ?? "") && this.note?.isContentAvailable() && this.noteContext?.viewScope?.viewMode === "default";
}
doRender() {

View File

@ -276,4 +276,14 @@ export default class MindMapWidget extends TypeWidget {
const svg = await this.renderSvg();
utils.downloadSvg(this.note.title, svg);
}
async exportPngEvent({ ntxId }: EventData<"exportPng">) {
if (!this.isNoteContext(ntxId) || this.note?.type !== "mindMap") {
return;
}
const svg = await this.renderSvg();
utils.downloadSvgAsPng(this.note.title, svg);
}
}