Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(mermaid): one more case of "Matrix is not inversible"
Elian Doran219753039d33
diff --git a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsxindex ae7a4649e7..a3170d9459 100644--- a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx+++ b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx@@ -136,12 +136,16 @@ function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svgconst lastPanZoom = useRef<{ pan: SvgPanZoom.Point, zoom: number }>();const lastNoteId = useRef<string>();const zoomRef = useRef<SvgPanZoom.Instance>();+ const width = useElementSize(containerRef);// Set up pan & zoom.useEffect(() => {+ if (zoomRef.current || width?.width === 0) return;+const shouldPreservePanZoom = (lastNoteId.current === noteId);const svgEl = containerRef.current?.querySelector("svg");if (!svgEl) return;+const zoomInstance = svgPanZoom(svgEl, {zoomEnabled: true,controlIconsEnabled: false@@ -163,14 +167,14 @@ function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svgpan: zoomInstance.getPan(),zoom: zoomInstance.getZoom()}+ zoomRef.current = undefined;zoomInstance.destroy();};- }, [ svg ]);+ }, [ svg, width ]);// React to container changes.- const width = useElementSize(containerRef);useEffect(() => {- if (!zoomRef.current || (width?.width ?? 0) === 0) return;+ if (!zoomRef.current || (width?.width ?? 0) < 1) return;zoomRef.current.resize().fit().center();}, [ width ]);