ISSUE 9: add download file functionality

This commit is contained in:
Ayobami
2025-07-02 18:17:26 +01:00
parent 0496a48623
commit ab2f477b7f
+11 -5
View File
@@ -103,11 +103,17 @@ export const DockBuilder = () => {
// }, [ editor ] ); // }, [ editor ] );
const toJSON = () => { const toJSON = () => {
// TODO: download the json file // Get JSON of editor content, including dockData and snapClone
// TODO: get json of editor content const json = editorMemo.toJSON(["dockData", "snapClone"]);
// TODO: Ensure dockData is included in the json const data = JSON.stringify(json, null, 2);
// TODO: save the json to the local storage as dock // Save to localStorage
// TODO: name the file as paradise_dock_<timestamp here>.dock localStorage.setItem("dock", data);
const blob = new Blob([data], { type: "application/json" });
const anchor = document.createElement("a");
const timestamp = Date.now();
anchor.href = URL.createObjectURL(blob);
anchor.download = `paradise_dock_${timestamp}.dock`; // TODO: name the file as paradise_dock_<timestamp here>.dock
anchor.click();
}; };
const uploadFile = (e) => { const uploadFile = (e) => {