Fix many syncing issues (#952)

This commit is contained in:
Pete Hunt 2020-03-14 20:46:57 -07:00 committed by GitHub
parent b20d4539c0
commit 3f8144ef85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 176 additions and 100 deletions

View file

@ -1,6 +1,7 @@
import { ExcalidrawElement } from "../element/types";
import { getElementAbsoluteCoords } from "../element";
import { AppState } from "../types";
import { newElementWith } from "../element/mutateElement";
export function getElementsWithinSelection(
elements: readonly ExcalidrawElement[],
@ -34,24 +35,16 @@ export function deleteSelectedElements(
elements: readonly ExcalidrawElement[],
appState: AppState,
) {
const deletedIds: AppState["deletedIds"] = {};
return {
elements: elements.filter(el => {
elements: elements.map(el => {
if (appState.selectedElementIds[el.id]) {
deletedIds[el.id] = {
version: el.version,
};
return false;
return newElementWith(el, { isDeleted: true });
}
return true;
return el;
}),
appState: {
...appState,
selectedElementIds: {},
deletedIds: {
...appState.deletedIds,
...deletedIds,
},
},
};
}