mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: pass localElements to restore and restoreElement API's and bump versions of duplicate elements on import (#3797)
This commit is contained in:
parent
038e9c13dd
commit
097362662d
14 changed files with 164 additions and 61 deletions
|
@ -654,7 +654,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
const fileHandle = launchParams.files[0];
|
||||
const blob: Blob = await fileHandle.getFile();
|
||||
blob.handle = fileHandle;
|
||||
loadFromBlob(blob, this.state)
|
||||
loadFromBlob(blob, this.state, this.scene.getElements())
|
||||
.then(({ elements, appState }) =>
|
||||
this.syncActionResult({
|
||||
elements,
|
||||
|
@ -692,7 +692,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
};
|
||||
}
|
||||
|
||||
const scene = restore(initialData, null);
|
||||
const scene = restore(initialData, null, null);
|
||||
scene.appState = {
|
||||
...scene.appState,
|
||||
isLoading: false,
|
||||
|
@ -1201,7 +1201,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
});
|
||||
} else if (data.elements) {
|
||||
this.addElementsFromPasteOrLibrary({
|
||||
elements: restoreElements(data.elements),
|
||||
elements: data.elements,
|
||||
position: "cursor",
|
||||
});
|
||||
} else if (data.text) {
|
||||
|
@ -1216,7 +1216,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
elements: readonly ExcalidrawElement[];
|
||||
position: { clientX: number; clientY: number } | "cursor" | "center";
|
||||
}) => {
|
||||
const elements = restoreElements(opts.elements);
|
||||
const elements = restoreElements(opts.elements, null);
|
||||
const [minX, minY, maxX, maxY] = getCommonBounds(elements);
|
||||
|
||||
const elementsCenterX = distance(minX, maxX) / 2;
|
||||
|
@ -3805,7 +3805,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||
try {
|
||||
const file = event.dataTransfer.files[0];
|
||||
if (file?.type === "image/png" || file?.type === "image/svg+xml") {
|
||||
const { elements, appState } = await loadFromBlob(file, this.state);
|
||||
const { elements, appState } = await loadFromBlob(
|
||||
file,
|
||||
this.state,
|
||||
this.scene.getElements(),
|
||||
);
|
||||
this.syncActionResult({
|
||||
elements,
|
||||
appState: {
|
||||
|
@ -3865,7 +3869,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
};
|
||||
|
||||
loadFileToCanvas = (file: Blob) => {
|
||||
loadFromBlob(file, this.state)
|
||||
loadFromBlob(file, this.state, this.scene.getElements())
|
||||
.then(({ elements, appState }) =>
|
||||
this.syncActionResult({
|
||||
elements,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue