feat(mermaid): recenter even when under error

This commit is contained in:
Elian Doran 2025-03-22 14:34:42 +02:00
parent 82cb31da53
commit 5a72d66321
No known key found for this signature in database

View File

@ -81,22 +81,21 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
let svg: string = ""; let svg: string = "";
try { try {
svg = await this.renderSvg(content); 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) { } catch (e: unknown) {
// Rendering failed. // Rendering failed.
this.setError((e as Error)?.message); 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); await this.#setupPanZoom(!recenter);
} }
@ -169,6 +168,7 @@ export default abstract class AbstractSvgSplitTypeWidget extends AbstractSplitTy
zoomInstance.pan(pan); zoomInstance.pan(pan);
} else { } else {
// New instance, reposition properly. // New instance, reposition properly.
zoomInstance.resize();
zoomInstance.center(); zoomInstance.center();
zoomInstance.fit(); zoomInstance.fit();
} }