mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
support embedding scene data to PNG/SVG (#2219)
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
parent
7618ca48d7
commit
5950fa9a40
20 changed files with 329 additions and 27 deletions
|
@ -6,6 +6,7 @@ import { fileOpen, fileSave } from "browser-nativefs";
|
|||
import { loadFromBlob } from "./blob";
|
||||
import { loadLibrary } from "./localStorage";
|
||||
import { Library } from "./library";
|
||||
import { MIME_TYPES } from "../constants";
|
||||
|
||||
export const serializeAsJSON = (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
|
@ -48,8 +49,8 @@ export const saveAsJSON = async (
|
|||
export const loadFromJSON = async (localAppState: AppState) => {
|
||||
const blob = await fileOpen({
|
||||
description: "Excalidraw files",
|
||||
extensions: [".json", ".excalidraw"],
|
||||
mimeTypes: ["application/json"],
|
||||
extensions: [".json", ".excalidraw", ".png", ".svg"],
|
||||
mimeTypes: ["application/json", "image/png", "image/svg+xml"],
|
||||
});
|
||||
return loadFromBlob(blob, localAppState);
|
||||
};
|
||||
|
@ -76,7 +77,7 @@ export const saveLibraryAsJSON = async () => {
|
|||
);
|
||||
const fileName = "library.excalidrawlib";
|
||||
const blob = new Blob([serialized], {
|
||||
type: "application/vnd.excalidrawlib+json",
|
||||
type: MIME_TYPES.excalidrawlib,
|
||||
});
|
||||
await fileSave(blob, {
|
||||
fileName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue