feat: various delta improvements (#9571)
This commit is contained in:
@@ -103,6 +103,7 @@ import {
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
getObservedAppState,
|
||||
getCommonBounds,
|
||||
getElementAbsoluteCoords,
|
||||
bindOrUnbindLinearElements,
|
||||
@@ -260,7 +261,6 @@ import type {
|
||||
ExcalidrawNonSelectionElement,
|
||||
ExcalidrawArrowElement,
|
||||
ExcalidrawElbowArrowElement,
|
||||
SceneElementsMap,
|
||||
} from "@excalidraw/element/types";
|
||||
|
||||
import type { Mutable, ValueOf } from "@excalidraw/common/utility-types";
|
||||
@@ -702,6 +702,8 @@ class App extends React.Component<AppProps, AppState> {
|
||||
addFiles: this.addFiles,
|
||||
resetScene: this.resetScene,
|
||||
getSceneElementsIncludingDeleted: this.getSceneElementsIncludingDeleted,
|
||||
getSceneElementsMapIncludingDeleted:
|
||||
this.getSceneElementsMapIncludingDeleted,
|
||||
history: {
|
||||
clear: this.resetHistory,
|
||||
},
|
||||
@@ -3909,22 +3911,18 @@ class App extends React.Component<AppProps, AppState> {
|
||||
}) => {
|
||||
const { elements, appState, collaborators, captureUpdate } = sceneData;
|
||||
|
||||
const nextElements = elements ? syncInvalidIndices(elements) : undefined;
|
||||
|
||||
if (captureUpdate) {
|
||||
const nextElementsMap = elements
|
||||
? (arrayToMap(nextElements ?? []) as SceneElementsMap)
|
||||
: undefined;
|
||||
|
||||
const nextAppState = appState
|
||||
? // new instance, with partial appstate applied to previously captured one, including hidden prop inside `prevCommittedAppState`
|
||||
Object.assign({}, this.store.snapshot.appState, appState)
|
||||
const observedAppState = appState
|
||||
? getObservedAppState({
|
||||
...this.store.snapshot.appState,
|
||||
...appState,
|
||||
})
|
||||
: undefined;
|
||||
|
||||
this.store.scheduleMicroAction({
|
||||
action: captureUpdate,
|
||||
elements: nextElementsMap,
|
||||
appState: nextAppState,
|
||||
elements: elements ?? [],
|
||||
appState: observedAppState,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3932,8 +3930,8 @@ class App extends React.Component<AppProps, AppState> {
|
||||
this.setState(appState);
|
||||
}
|
||||
|
||||
if (nextElements) {
|
||||
this.scene.replaceAllElements(nextElements);
|
||||
if (elements) {
|
||||
this.scene.replaceAllElements(elements);
|
||||
}
|
||||
|
||||
if (collaborators) {
|
||||
@@ -10550,7 +10548,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
// otherwise we would end up with duplicated fractional indices on undo
|
||||
this.store.scheduleMicroAction({
|
||||
action: CaptureUpdateAction.NEVER,
|
||||
elements: arrayToMap(elements) as SceneElementsMap,
|
||||
elements,
|
||||
appState: undefined,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user