From 475374a04b20fb76808709b824860e5c27bd56f0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 18 Mar 2025 20:37:06 +0200 Subject: [PATCH] feat(mermaid): reduce flicker when editing chart --- src/public/app/widgets/mermaid.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/mermaid.ts b/src/public/app/widgets/mermaid.ts index caec38757..1b7fe7c6d 100644 --- a/src/public/app/widgets/mermaid.ts +++ b/src/public/app/widgets/mermaid.ts @@ -69,6 +69,8 @@ export default class MermaidWidget extends NoteContextAwareWidget { } async refreshWithNote(note: FNote) { + const isSameNote = (this.lastNote === note); + this.cleanup(); this.$errorContainer.hide(); @@ -79,7 +81,9 @@ export default class MermaidWidget extends NoteContextAwareWidget { ...(getMermaidConfig() as any) }); - this.$display.empty(); + if (!isSameNote) { + this.$display.empty(); + } this.$errorContainer.hide(); @@ -108,7 +112,6 @@ export default class MermaidWidget extends NoteContextAwareWidget { $svg.attr("width", "100%").attr("height", "100%"); // Enable pan to zoom. - const isSameNote = (this.lastNote === note); this.#setupPanZoom($svg[0], isSameNote); } catch (e: any) { console.warn(e);