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 ] );
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_<timestamp here>.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_<timestamp here>.dock
anchor.click();
};
const uploadFile = (e) => {