diff --git a/src/components/DockBuilder/DockBuilder.jsx b/src/components/DockBuilder/DockBuilder.jsx index 969f7b1..ffcb428 100644 --- a/src/components/DockBuilder/DockBuilder.jsx +++ b/src/components/DockBuilder/DockBuilder.jsx @@ -103,11 +103,17 @@ export const DockBuilder = () => { // }, [ editor ] ); const toJSON = () => { - // TODO: download the json file - // TODO: get json of editor content - // TODO: Ensure dockData is included in the json - // TODO: save the json to the local storage as dock - // TODO: name the file as paradise_dock_.dock + // Get JSON of editor content, including dockData and snapClone + const json = editorMemo.toJSON(["dockData", "snapClone"]); + const data = JSON.stringify(json, null, 2); + // Save to localStorage + 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_.dock + anchor.click(); }; const uploadFile = (e) => {