mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-18 20:56:18 +08:00
feat(mermaid): save SVG attachment only when needed
This commit is contained in:
parent
fd46cd7529
commit
3bbb2c3e80
@ -50,11 +50,20 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
|
|||||||
const blob = await note?.getBlob();
|
const blob = await note?.getBlob();
|
||||||
const content = blob?.content || "";
|
const content = blob?.content || "";
|
||||||
this.onContentChanged(content, true);
|
this.onContentChanged(content, true);
|
||||||
|
|
||||||
|
// Save the SVG when entering a note only when it does not have an attachment.
|
||||||
|
this.note?.getAttachments().then((attachments) => {
|
||||||
|
const attachmentName = `${this.attachmentName}.svg`;
|
||||||
|
if (!attachments.find((a) => a.title === attachmentName)) {
|
||||||
|
this.#saveSvg();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(): { content: string; } {
|
getData(): { content: string; } {
|
||||||
const data = super.getData();
|
const data = super.getData();
|
||||||
this.onContentChanged(data.content, false);
|
this.onContentChanged(data.content, false);
|
||||||
|
this.#saveSvg();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +98,6 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
|
|||||||
|
|
||||||
this.$renderContainer.html(svg);
|
this.$renderContainer.html(svg);
|
||||||
await this.#setupPanZoom(!recenter);
|
await this.#setupPanZoom(!recenter);
|
||||||
this.#saveSvg();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#saveSvg() {
|
#saveSvg() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user