From 229f4d6b4141d6db72a2b451f337101127d4be22 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 10 Nov 2025 23:04:52 -0800 Subject: [PATCH] fix coordinates --- src/automerge/useAutomergeStoreV2.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/automerge/useAutomergeStoreV2.ts b/src/automerge/useAutomergeStoreV2.ts index eebdc17..6f6cf10 100644 --- a/src/automerge/useAutomergeStoreV2.ts +++ b/src/automerge/useAutomergeStoreV2.ts @@ -376,8 +376,11 @@ export function useAutomergeStoreV2({ const shapeFromStore = store.get(s.id) if (shapeFromStore && shapeFromStore.typeName === 'shape') { // Preserve original x and y from the store shape data - const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x - const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y + // Type assertion needed because s is TLRecord but we know it's a shape + const sAny = s as any + const shapeFromStoreAny = shapeFromStore as any + const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x + const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y // Ensure x and y are preserved if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) { @@ -440,8 +443,11 @@ export function useAutomergeStoreV2({ const shapeFromStore = store.get(s.id) if (shapeFromStore && shapeFromStore.typeName === 'shape') { // Preserve original x and y from the store shape data - const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x - const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y + // Type assertion needed because s is TLRecord but we know it's a shape + const sAny = s as any + const shapeFromStoreAny = shapeFromStore as any + const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x + const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y // Ensure x and y are preserved if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) { @@ -537,8 +543,11 @@ export function useAutomergeStoreV2({ const shapeFromStore = store.get(s.id) if (shapeFromStore && shapeFromStore.typeName === 'shape') { // Preserve original x and y from the store shape data - const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x - const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y + // Type assertion needed because s is TLRecord but we know it's a shape + const sAny = s as any + const shapeFromStoreAny = shapeFromStore as any + const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x + const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y // Ensure x and y are preserved if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) {