mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fileHandle refactor & fixes (#2252)
This commit is contained in:
parent
4a26845395
commit
1484c5a63b
17 changed files with 163 additions and 41 deletions
|
@ -27,23 +27,23 @@ export const serializeAsJSON = (
|
|||
export const saveAsJSON = async (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
fileHandle: any,
|
||||
) => {
|
||||
const serialized = serializeAsJSON(elements, appState);
|
||||
const blob = new Blob([serialized], {
|
||||
type: "application/json",
|
||||
});
|
||||
const name = `${appState.name}.excalidraw`;
|
||||
// TODO: Make this part of `AppState`.
|
||||
(window as any).handle = await fileSave(
|
||||
|
||||
const fileHandle = await fileSave(
|
||||
blob,
|
||||
{
|
||||
fileName: name,
|
||||
fileName: appState.name,
|
||||
description: "Excalidraw file",
|
||||
extensions: [".excalidraw"],
|
||||
},
|
||||
fileHandle || null,
|
||||
appState.fileHandle,
|
||||
);
|
||||
|
||||
return { fileHandle };
|
||||
};
|
||||
|
||||
export const loadFromJSON = async (localAppState: AppState) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue