mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
retain local appState props on restore (#2224)
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
parent
b91f929503
commit
7618ca48d7
9 changed files with 153 additions and 69 deletions
|
@ -7,6 +7,8 @@ import {
|
|||
import { newElement, newTextElement, newLinearElement } from "../../element";
|
||||
import { DEFAULT_VERTICAL_ALIGN } from "../../constants";
|
||||
import { getDefaultAppState } from "../../appState";
|
||||
import { GlobalTestState, createEvent, fireEvent } from "../test-utils";
|
||||
import { ImportedDataState } from "../../data/types";
|
||||
|
||||
const { h } = window;
|
||||
|
||||
|
@ -135,4 +137,28 @@ export class API {
|
|||
}
|
||||
return element as any;
|
||||
};
|
||||
|
||||
static dropFile(sceneData: ImportedDataState) {
|
||||
const fileDropEvent = createEvent.drop(GlobalTestState.canvas);
|
||||
const file = new Blob(
|
||||
[
|
||||
JSON.stringify({
|
||||
type: "excalidraw",
|
||||
...sceneData,
|
||||
}),
|
||||
],
|
||||
{
|
||||
type: "application/json",
|
||||
},
|
||||
);
|
||||
Object.defineProperty(fileDropEvent, "dataTransfer", {
|
||||
value: {
|
||||
files: [file],
|
||||
getData: (_type: string) => {
|
||||
return "";
|
||||
},
|
||||
},
|
||||
});
|
||||
fireEvent(GlobalTestState.canvas, fileDropEvent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue