ISSUE 9: add download file functionality
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user