mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
add excalidraw_embed into base repo (#2040)
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
parent
80cbe13167
commit
ab7073abdb
16 changed files with 6710 additions and 77 deletions
|
@ -19,6 +19,7 @@ import { serializeAsJSON } from "./json";
|
|||
import { ExportType } from "../scene/types";
|
||||
import { restore } from "./restore";
|
||||
import { restoreFromLocalStorage } from "./localStorage";
|
||||
import { DataState } from "./types";
|
||||
|
||||
export { loadFromBlob } from "./blob";
|
||||
export { saveAsJSON, loadFromJSON } from "./json";
|
||||
|
@ -234,7 +235,7 @@ export const exportToBackend = async (
|
|||
|
||||
export const importFromBackend = async (
|
||||
id: string | null,
|
||||
privateKey: string | undefined,
|
||||
privateKey?: string | null,
|
||||
) => {
|
||||
let elements: readonly ExcalidrawElement[] = [];
|
||||
let appState = getDefaultAppState();
|
||||
|
@ -364,14 +365,18 @@ export const exportCanvas = async (
|
|||
}
|
||||
};
|
||||
|
||||
export const loadScene = async (id: string | null, privateKey?: string) => {
|
||||
export const loadScene = async (
|
||||
id: string | null,
|
||||
privateKey?: string | null,
|
||||
initialData?: DataState,
|
||||
) => {
|
||||
let data;
|
||||
if (id != null) {
|
||||
// the private key is used to decrypt the content from the server, take
|
||||
// extra care not to leak it
|
||||
data = await importFromBackend(id, privateKey);
|
||||
} else {
|
||||
data = restoreFromLocalStorage();
|
||||
data = initialData || restoreFromLocalStorage();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue