Skip to content

Build your personal knowledge base with Trilium Notes

feat(mermaid): recenter even when under error

Elian Doran5a72d6632103
diff --git a/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts b/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts
index b0a4cd69dd..47d7b5d0be 100644
--- a/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts
+++ b/src/public/app/widgets/type_widgets/abstract_svg_split_type_widget.ts
@@ -81,22 +81,21 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
let svg: string = "";
try {
svg = await this.renderSvg(content);
+
+ // Rendering was succesful.
+ this.setError(null);
+
+ if (svg === this.svg) {
+ return;
+ }
+
+ this.svg = svg;
+ this.$renderContainer.html(svg);
} catch (e: unknown) {
// Rendering failed.
this.setError((e as Error)?.message);
- return;
}
- // Rendering was succesful.
- this.setError(null);
-
- if (svg === this.svg) {
- return;
- }
-
- this.svg = svg;
-
- this.$renderContainer.html(svg);
await this.#setupPanZoom(!recenter);
}
@@ -169,6 +168,7 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
zoomInstance.pan(pan);
} else {
// New instance, reposition properly.
+ zoomInstance.resize();
zoomInstance.center();
zoomInstance.fit();
}