Add Native File System API saving/exporting and opening (#388)

* Add Native File System API saving/exporting

* Add Native File System API opening

* Add origin trial token placeholder

* Reuse an opened file handle for better saving experience

* Fix file handle reuse to only kick in for Excalidraw files

* Remove reference
This commit is contained in:
Thomas Steiner 2020-01-17 11:25:05 +01:00 committed by GitHub
parent f4d4b323e1
commit 7ddc206b8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 143 additions and 39 deletions

View file

@ -40,7 +40,7 @@ export const actionChangeExportBackground: Action = {
export const actionSaveScene: Action = {
name: "saveScene",
perform: (elements, appState, value) => {
saveAsJSON(elements, appState);
saveAsJSON(elements, appState).catch(err => console.error(err));
return {};
},
PanelComponent: ({ updateData }) => (
@ -70,9 +70,11 @@ export const actionLoadScene: Action = {
title="Load"
aria-label="Load"
onClick={() => {
loadFromJSON().then(({ elements, appState }) => {
updateData({ elements: elements, appState: appState });
});
loadFromJSON()
.then(({ elements, appState }) => {
updateData({ elements: elements, appState: appState });
})
.catch(err => console.error(err));
}}
/>
)