mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-03 22:30:51 +08:00
feat(mermaid): recenter even when under error
This commit is contained in:
parent
82cb31da53
commit
5a72d66321
@ -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();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user