mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: make file handling more robust (#5057)
This commit is contained in:
parent
0d70690ec8
commit
d2e687ed0a
11 changed files with 328 additions and 152 deletions
|
@ -9,7 +9,7 @@ import {
|
|||
import { clearElementsForDatabase, clearElementsForExport } from "../element";
|
||||
import { ExcalidrawElement } from "../element/types";
|
||||
import { AppState, BinaryFiles, LibraryItems } from "../types";
|
||||
import { isImageFileHandle, loadFromBlob } from "./blob";
|
||||
import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob";
|
||||
|
||||
import {
|
||||
ExportedDataState,
|
||||
|
@ -93,13 +93,13 @@ export const loadFromJSON = async (
|
|||
localAppState: AppState,
|
||||
localElements: readonly ExcalidrawElement[] | null,
|
||||
) => {
|
||||
const blob = await fileOpen({
|
||||
const file = 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"],
|
||||
});
|
||||
return loadFromBlob(blob, localAppState, localElements);
|
||||
return loadFromBlob(await normalizeFile(file), localAppState, localElements);
|
||||
};
|
||||
|
||||
export const isValidExcalidrawData = (data?: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue