fix saving mermaid attachment

This commit is contained in:
zadam
2023-01-24 23:09:00 +01:00
parent 3c57f08ef7
commit 0bfb2631df
4 changed files with 40 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import libraryLoader from "../services/library_loader.js";
import NoteContextAwareWidget from "./note_context_aware_widget.js";
import froca from "../services/froca.js";
import server from "../services/server.js";
const TPL = `<div class="mermaid-widget">
<style>
@@ -76,6 +77,14 @@ export default class MermaidWidget extends NoteContextAwareWidget {
const renderedSvg = await this.renderSvg();
this.$display.html(renderedSvg);
// not awaiting intentionally
// this is pretty hacky since we update attachment on render
// but if nothing changed this should not trigger DB write and sync
server.put(`notes/${note.noteId}/attachments/mermaidSvg`, {
mime: 'image/svg+xml',
content: renderedSvg
});
await wheelZoomLoaded;
this.$display.attr("id", `mermaid-render-${idCounter}`);