mirror of
https://github.com/zadam/trilium.git
synced 2026-01-02 20:54:24 +01:00
fix(mindmap): switching between read-only and editable mode
This commit is contained in:
parent
76bd6a5ab9
commit
a6fc54cb81
@ -111,7 +111,7 @@ function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef
|
||||
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
|
||||
const apiRef = useRef<MindElixirInstance>(null);
|
||||
|
||||
useEffect(() => {
|
||||
function reinitialize() {
|
||||
if (!containerRef.current) return;
|
||||
|
||||
const mind = new VanillaMindElixir({
|
||||
@ -127,8 +127,22 @@ function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef
|
||||
if (externalApiRef) {
|
||||
externalApiRef.current = mind;
|
||||
}
|
||||
}
|
||||
|
||||
return () => mind.destroy();
|
||||
useEffect(() => {
|
||||
reinitialize();
|
||||
return () => {
|
||||
apiRef.current?.destroy();
|
||||
apiRef.current = null;
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const data = apiRef.current?.getData();
|
||||
reinitialize();
|
||||
if (data) {
|
||||
apiRef.current?.init(data);
|
||||
}
|
||||
}, [ editable ]);
|
||||
|
||||
// On change listener.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user