From fc914043468d2b4dd13e2c8244aa177d3d8e2425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mime=20=C4=8Cuvalo?= Date: Fri, 22 Mar 2024 21:10:20 +0000 Subject: [PATCH] rename --- packages/editor/api-report.md | 2 +- packages/editor/api/api.json | 70 +++++++++---------- packages/editor/src/lib/editor/Editor.ts | 2 +- .../editor/src/lib/editor/shapes/ShapeUtil.ts | 7 +- packages/tldraw/api-report.md | 4 +- packages/tldraw/api/api.json | 60 ++++++++-------- .../src/lib/shapes/frame/FrameShapeUtil.tsx | 2 +- 7 files changed, 73 insertions(+), 74 deletions(-) diff --git a/packages/editor/api-report.md b/packages/editor/api-report.md index a35a1921a..af4bb8bda 100644 --- a/packages/editor/api-report.md +++ b/packages/editor/api-report.md @@ -1599,7 +1599,6 @@ export abstract class ShapeUtil { canBind: (_shape: Shape, _otherShape?: K | undefined) => boolean; canCrop: TLShapeUtilFlag; canDropShapes(shape: Shape, shapes: TLShape[]): boolean; - canDropShapesOnlyWithinMaskedBounds: TLShapeUtilFlag; canEdit: TLShapeUtilFlag; canEditInReadOnly: TLShapeUtilFlag; canReceiveNewChildrenOfType(shape: Shape, type: TLShape['type']): boolean; @@ -1624,6 +1623,7 @@ export abstract class ShapeUtil { hideSelectionBoundsFg: TLShapeUtilFlag; abstract indicator(shape: Shape): any; isAspectRatioLocked: TLShapeUtilFlag; + isFrame: TLShapeUtilFlag; isSticky: TLShapeUtilFlag; // (undocumented) static migrations?: Migrations; diff --git a/packages/editor/api/api.json b/packages/editor/api/api.json index 8e3c88aa5..e77b11285 100644 --- a/packages/editor/api/api.json +++ b/packages/editor/api/api.json @@ -30401,41 +30401,6 @@ "isAbstract": false, "name": "canDropShapes" }, - { - "kind": "Property", - "canonicalReference": "@tldraw/editor!ShapeUtil#canDropShapesOnlyWithinMaskedBounds:member", - "docComment": "/**\n * Whether the dropping a shape onto another behaves like a frame (true) where one has to drop the shape within the bounds of the frame, or like a stickies (false) where the shape is considered dropped when the bounding boxes collide.\n *\n * @public\n */\n", - "excerptTokens": [ - { - "kind": "Content", - "text": "canDropShapesOnlyWithinMaskedBounds: " - }, - { - "kind": "Reference", - "text": "TLShapeUtilFlag", - "canonicalReference": "@tldraw/editor!TLShapeUtilFlag:type" - }, - { - "kind": "Content", - "text": "" - }, - { - "kind": "Content", - "text": ";" - } - ], - "isReadonly": false, - "isOptional": false, - "releaseTag": "Public", - "name": "canDropShapesOnlyWithinMaskedBounds", - "propertyTypeTokenRange": { - "startIndex": 1, - "endIndex": 3 - }, - "isStatic": false, - "isProtected": false, - "isAbstract": false - }, { "kind": "Property", "canonicalReference": "@tldraw/editor!ShapeUtil#canEdit:member", @@ -31284,6 +31249,41 @@ "isProtected": false, "isAbstract": false }, + { + "kind": "Property", + "canonicalReference": "@tldraw/editor!ShapeUtil#isFrame:member", + "docComment": "/**\n * Whether the shape is a frame and carries the behaviors that go along with frames. Frames are shapes that can contain other shapes, in a portal-like fashion.\n *\n * @public\n */\n", + "excerptTokens": [ + { + "kind": "Content", + "text": "isFrame: " + }, + { + "kind": "Reference", + "text": "TLShapeUtilFlag", + "canonicalReference": "@tldraw/editor!TLShapeUtilFlag:type" + }, + { + "kind": "Content", + "text": "" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "isFrame", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 3 + }, + "isStatic": false, + "isProtected": false, + "isAbstract": false + }, { "kind": "Property", "canonicalReference": "@tldraw/editor!ShapeUtil#isSticky:member", diff --git a/packages/editor/src/lib/editor/Editor.ts b/packages/editor/src/lib/editor/Editor.ts index 426122e99..4c9571f5d 100644 --- a/packages/editor/src/lib/editor/Editor.ts +++ b/packages/editor/src/lib/editor/Editor.ts @@ -5026,7 +5026,7 @@ export class Editor extends EventEmitter { // partially clipped by its own parent frame. const maskedPageBounds = this.getShapeMaskedPageBounds(shape.id) if ( - this.getShapeUtil(shape).canDropShapesOnlyWithinMaskedBounds(shape) && + this.getShapeUtil(shape).isFrame(shape) && maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true) diff --git a/packages/editor/src/lib/editor/shapes/ShapeUtil.ts b/packages/editor/src/lib/editor/shapes/ShapeUtil.ts index 9d04a61d2..b18c674ae 100644 --- a/packages/editor/src/lib/editor/shapes/ShapeUtil.ts +++ b/packages/editor/src/lib/editor/shapes/ShapeUtil.ts @@ -225,13 +225,12 @@ export abstract class ShapeUtil { } /** - * Whether the dropping a shape onto another behaves like a frame (true) where one - * has to drop the shape within the bounds of the frame, or like a stickies (false) where - * the shape is considered dropped when the bounding boxes collide. + * Whether the shape is a frame and carries the behaviors that go along with frames. + * Frames are shapes that can contain other shapes, in a portal-like fashion. * * @public */ - canDropShapesOnlyWithinMaskedBounds: TLShapeUtilFlag = () => true + isFrame: TLShapeUtilFlag = () => true /** * Whether the shape should adhere to other shapes: diff --git a/packages/tldraw/api-report.md b/packages/tldraw/api-report.md index 051a33129..8b4207a29 100644 --- a/packages/tldraw/api-report.md +++ b/packages/tldraw/api-report.md @@ -632,8 +632,6 @@ export class FrameShapeUtil extends BaseBoxShapeUtil { // (undocumented) canDropShapes: (shape: TLFrameShape, _shapes: TLShape[]) => boolean; // (undocumented) - canDropShapesOnlyWithinMaskedBounds: () => boolean; - // (undocumented) canEdit: () => boolean; // (undocumented) canReceiveNewChildrenOfType: (shape: TLShape, _type: TLShape['type']) => boolean; @@ -646,6 +644,8 @@ export class FrameShapeUtil extends BaseBoxShapeUtil { // (undocumented) indicator(shape: TLFrameShape): JSX_2.Element; // (undocumented) + isFrame: () => boolean; + // (undocumented) static migrations: Migrations; // (undocumented) onDragShapesOut: (_shape: TLFrameShape, shapes: TLShape[]) => void; diff --git a/packages/tldraw/api/api.json b/packages/tldraw/api/api.json index 9c0085043..07bd2f20d 100644 --- a/packages/tldraw/api/api.json +++ b/packages/tldraw/api/api.json @@ -7156,36 +7156,6 @@ "isProtected": false, "isAbstract": false }, - { - "kind": "Property", - "canonicalReference": "tldraw!FrameShapeUtil#canDropShapesOnlyWithinMaskedBounds:member", - "docComment": "", - "excerptTokens": [ - { - "kind": "Content", - "text": "canDropShapesOnlyWithinMaskedBounds: " - }, - { - "kind": "Content", - "text": "() => boolean" - }, - { - "kind": "Content", - "text": ";" - } - ], - "isReadonly": false, - "isOptional": false, - "releaseTag": "Public", - "name": "canDropShapesOnlyWithinMaskedBounds", - "propertyTypeTokenRange": { - "startIndex": 1, - "endIndex": 2 - }, - "isStatic": false, - "isProtected": false, - "isAbstract": false - }, { "kind": "Property", "canonicalReference": "tldraw!FrameShapeUtil#canEdit:member", @@ -7458,6 +7428,36 @@ "isAbstract": false, "name": "indicator" }, + { + "kind": "Property", + "canonicalReference": "tldraw!FrameShapeUtil#isFrame:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "isFrame: " + }, + { + "kind": "Content", + "text": "() => boolean" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": false, + "isOptional": false, + "releaseTag": "Public", + "name": "isFrame", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isStatic": false, + "isProtected": false, + "isAbstract": false + }, { "kind": "Property", "canonicalReference": "tldraw!FrameShapeUtil.migrations:member", diff --git a/packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx b/packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx index 2da4c2db5..f67ce43ce 100644 --- a/packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx +++ b/packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx @@ -42,7 +42,7 @@ export class FrameShapeUtil extends BaseBoxShapeUtil { override canEdit = () => true - override canDropShapesOnlyWithinMaskedBounds = () => true + override isFrame = () => true override getDefaultProps(): TLFrameShape['props'] { return { w: 160 * 2, h: 90 * 2, name: '' }