From acbd9ce0cd235c20c5d804943d3816c77fc7415a Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Thu, 27 Jul 2023 17:27:35 +0100 Subject: [PATCH] [fix] transform errors (#1772) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes some over-cautious transform errors introduced in #1751. ### Change Type - [x] `patch` — Bug fix ### Test Plan - [ ] Unit Tests --- packages/editor/src/lib/editor/Editor.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/lib/editor/Editor.ts b/packages/editor/src/lib/editor/Editor.ts index 37de0e529..a4e54d4dd 100644 --- a/packages/editor/src/lib/editor/Editor.ts +++ b/packages/editor/src/lib/editor/Editor.ts @@ -3879,8 +3879,7 @@ export class Editor extends EventEmitter { getParentTransform(id: TLShapeId): Matrix2d getParentTransform(arg: TLShape | TLShapeId): Matrix2d { const shape = typeof arg === 'string' ? this.getShape(arg) : arg - if (!shape) throw Error('Editor.getParentTransform: shape not found') - if (isPageId(shape.parentId)) return Matrix2d.Identity() + if (!shape || isPageId(shape.parentId)) return Matrix2d.Identity() return this._pageTransformCache.get(shape.parentId) ?? Matrix2d.Identity() } @@ -3900,9 +3899,8 @@ export class Editor extends EventEmitter { getPageTransform(id: TLShapeId): Matrix2d getPageTransform(shape: TLShape): Matrix2d getPageTransform(arg: TLShape | TLShapeId): Matrix2d { - const shape = typeof arg === 'string' ? this.getShape(arg) : arg - if (!shape) throw Error('Editor.getParentTransform: shape not found') - return this._pageTransformCache.get(shape.id) ?? Matrix2d.Identity() + const id = typeof arg === 'string' ? arg : this.getShape(arg)!.id + return this._pageTransformCache.get(id) ?? Matrix2d.Identity() } /**