mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Implement the Web Share Target API (#3230)
* Use the web share target API * Make requested changes * Remove line * Add application/json back * Add application/vnd.excalidraw+json * Add 'POST' check back * Make requested changes * Update src/appState.ts Co-authored-by: Thomas Steiner <tomac@google.com> * Update test * Override initializeScene * Use Excalidraw MIME type * Minor fixes * More MIME type tweaks * More permissive file open * Be overpermissive in file open Co-authored-by: Thomas Steiner <tomac@google.com> Co-authored-by: tomayac <steiner.thomas@gmail.com>
This commit is contained in:
parent
f1daff2437
commit
b9e70ec666
6 changed files with 11846 additions and 11397 deletions
|
@ -30,13 +30,13 @@ export const saveAsJSON = async (
|
|||
) => {
|
||||
const serialized = serializeAsJSON(elements, appState);
|
||||
const blob = new Blob([serialized], {
|
||||
type: "application/json",
|
||||
type: MIME_TYPES.excalidraw,
|
||||
});
|
||||
|
||||
const fileHandle = await fileSave(
|
||||
blob,
|
||||
{
|
||||
fileName: appState.name,
|
||||
fileName: `${appState.name}.excalidraw`,
|
||||
description: "Excalidraw file",
|
||||
extensions: [".excalidraw"],
|
||||
},
|
||||
|
@ -48,8 +48,17 @@ export const saveAsJSON = async (
|
|||
export const loadFromJSON = async (localAppState: AppState) => {
|
||||
const blob = await fileOpen({
|
||||
description: "Excalidraw files",
|
||||
// ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442
|
||||
// gets resolved. Else, iOS users cannot open `.excalidraw` files.
|
||||
/*
|
||||
extensions: [".json", ".excalidraw", ".png", ".svg"],
|
||||
mimeTypes: ["application/json", "image/png", "image/svg+xml"],
|
||||
mimeTypes: [
|
||||
MIME_TYPES.excalidraw,
|
||||
"application/json",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
],
|
||||
*/
|
||||
});
|
||||
return loadFromBlob(blob, localAppState);
|
||||
};
|
||||
|
@ -101,8 +110,11 @@ export const saveLibraryAsJSON = async () => {
|
|||
export const importLibraryFromJSON = async () => {
|
||||
const blob = await fileOpen({
|
||||
description: "Excalidraw library files",
|
||||
// ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442
|
||||
// gets resolved. Else, iOS users cannot open `.excalidraw` files.
|
||||
/*
|
||||
extensions: [".json", ".excalidrawlib"],
|
||||
mimeTypes: ["application/json"],
|
||||
*/
|
||||
});
|
||||
Library.importLibrary(blob);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue