This commit is contained in:
Gowtham Selvaraj 2025-05-03 00:07:41 +09:00 committed by GitHub
commit 154cd5f7cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 12 deletions

View file

@ -105,10 +105,13 @@ export const actionFinalize = register({
}
}
if (isInvisiblySmallElement(multiPointElement)) {
if (
multiPointElement.points.length < 2 ||
isInvisiblySmallElement(multiPointElement)
) {
// TODO: #7348 in theory this gets recorded by the store, so the invisible elements could be restored by the undo/redo, which might be not what we would want
newElements = newElements.filter(
(el) => el.id !== multiPointElement.id,
newElements = newElements.map((el) =>
el.id === multiPointElement.id ? { ...el, isDeleted: true } : el,
);
}

View file

@ -29,17 +29,27 @@ const shouldDiscardRemoteElement = (
local &&
// local element is being edited
(local.id === localAppState.editingTextElement?.id ||
local.id === localAppState.resizingElement?.id ||
local.id === localAppState.newElement?.id || // TODO: Is this still valid? As newElement is selection element, which is never part of the elements array
// local element is newer
local.version > remote.version ||
// resolve conflicting edits deterministically by taking the one with
// the lowest versionNonce
(local.version === remote.version &&
local.versionNonce < remote.versionNonce))
local.id === localAppState.resizingElement?.id)
) {
return true;
}
if (local?.version !== undefined && remote.version !== undefined) {
if (remote.isDeleted && remote.version > local.version) {
return false;
}
if (local.isDeleted && !remote.isDeleted) {
return true;
}
if (local.version > remote.version) {
return true;
}
if (local.version === remote.version) {
return local.versionNonce < remote.versionNonce;
}
}
return false;
};

View file

@ -522,7 +522,10 @@ export const restoreElements = (
(elements || []).reduce((elements, element) => {
// filtering out selection, which is legacy, no longer kept in elements,
// and causing issues if retained
if (element.type !== "selection" && !isInvisiblySmallElement(element)) {
if (
element.type !== "selection" &&
(!isInvisiblySmallElement(element) || element.isDeleted)
) {
let migratedElement: ExcalidrawElement | null = restoreElement(element);
if (migratedElement) {
const localElement = localElementsMap?.get(element.id);