mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
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:
parent
f4d4b323e1
commit
7ddc206b8c
4 changed files with 143 additions and 39 deletions
|
@ -39,6 +39,10 @@ export const actionClearCanvas: Action = {
|
|||
aria-label="Clear the canvas & reset background color"
|
||||
onClick={() => {
|
||||
if (window.confirm("This will clear the whole canvas. Are you sure?")) {
|
||||
// TODO: Defined globally, since file handles aren't yet serializable.
|
||||
// Once `FileSystemFileHandle` can be serialized, make this
|
||||
// part of `AppState`.
|
||||
(window as any).handle = null;
|
||||
updateData(null);
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -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));
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue