Skip to content

Commit

Permalink
save graph on pointer up
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Aug 8, 2024
1 parent 6fab659 commit ba684f6
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/editor/plugins/ToolbarPlugin/Dialogs/GraphDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ function GraphDialog({ editor, node }: { editor: LexicalEditor, node: GraphNode
setGeogebraAPI(api);
const container = document.querySelector<HTMLDivElement>('.ggb-container');
if (!container) return;
container.onclick = () => {
container.onpointerup = debounce(() => {
const value = api.getBase64();
saveToLocalStorage(value);
}
localStorage.setItem("geogebra", value);
}, 300);
}
};
useEffect(() => {
Expand Down Expand Up @@ -76,19 +76,10 @@ function GraphDialog({ editor, node }: { editor: LexicalEditor, node: GraphNode
}
};

const saveToLocalStorage = debounce(async (value: string) => {
localStorage.setItem("geogebra", value);
}, 300);

const clearLocalStorage = () => {
localStorage.removeItem("geogebra");
};

const restoreFromLocalStorage = () => {
const value = localStorage.getItem("geogebra");
if (value) geogebraAPI.setBase64(value);
};

useEffect(() => {

}, [node]);
Expand Down

0 comments on commit ba684f6

Please sign in to comment.