@tldraw/editor 3.14.0-canary.ae1762886f91 → 3.14.0-canary.b8c5ab05b06a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +0 -17
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +9 -43
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/utils/reorderShapes.js +11 -10
- package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +0 -17
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +9 -43
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/utils/reorderShapes.mjs +11 -10
- package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +10 -44
- package/src/lib/utils/reorderShapes.ts +10 -13
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -2460,23 +2460,6 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2460
2460
|
* @public
|
|
2461
2461
|
*/
|
|
2462
2462
|
getShapeGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T;
|
|
2463
|
-
private _shapePageGeometryCaches;
|
|
2464
|
-
/**
|
|
2465
|
-
* Get the geometry of a shape in page-space.
|
|
2466
|
-
*
|
|
2467
|
-
* @example
|
|
2468
|
-
* ```ts
|
|
2469
|
-
* editor.getShapePageGeometry(myShape)
|
|
2470
|
-
* editor.getShapePageGeometry(myShapeId)
|
|
2471
|
-
* editor.getShapePageGeometry(myShapeId, { context: "arrow" })
|
|
2472
|
-
* ```
|
|
2473
|
-
*
|
|
2474
|
-
* @param shape - The shape (or shape id) to get the geometry for.
|
|
2475
|
-
* @param opts - Additional options about the request for geometry. Passed to {@link ShapeUtil.getGeometry}.
|
|
2476
|
-
*
|
|
2477
|
-
* @public
|
|
2478
|
-
*/
|
|
2479
|
-
getShapePageGeometry<T extends Geometry2d>(shape: TLShape | TLShapeId, opts?: TLGeometryOpts): T;
|
|
2480
2463
|
/* Excluded from this release type: _getShapeHandlesCache */
|
|
2481
2464
|
/**
|
|
2482
2465
|
* Get the handles (if any) for a shape.
|
package/dist-cjs/index.js
CHANGED
|
@@ -302,7 +302,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
302
302
|
__publicField(this, "_currentPageShapeIds");
|
|
303
303
|
/* --------------------- Shapes --------------------- */
|
|
304
304
|
__publicField(this, "_shapeGeometryCaches", {});
|
|
305
|
-
__publicField(this, "_shapePageGeometryCaches", {});
|
|
306
305
|
// Parents and children
|
|
307
306
|
/**
|
|
308
307
|
* A cache of parents to children.
|
|
@@ -3495,41 +3494,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3495
3494
|
typeof shape === "string" ? shape : shape.id
|
|
3496
3495
|
);
|
|
3497
3496
|
}
|
|
3498
|
-
/**
|
|
3499
|
-
* Get the geometry of a shape in page-space.
|
|
3500
|
-
*
|
|
3501
|
-
* @example
|
|
3502
|
-
* ```ts
|
|
3503
|
-
* editor.getShapePageGeometry(myShape)
|
|
3504
|
-
* editor.getShapePageGeometry(myShapeId)
|
|
3505
|
-
* editor.getShapePageGeometry(myShapeId, { context: "arrow" })
|
|
3506
|
-
* ```
|
|
3507
|
-
*
|
|
3508
|
-
* @param shape - The shape (or shape id) to get the geometry for.
|
|
3509
|
-
* @param opts - Additional options about the request for geometry. Passed to {@link ShapeUtil.getGeometry}.
|
|
3510
|
-
*
|
|
3511
|
-
* @public
|
|
3512
|
-
*/
|
|
3513
|
-
getShapePageGeometry(shape, opts) {
|
|
3514
|
-
const context = opts?.context ?? "none";
|
|
3515
|
-
if (!this._shapePageGeometryCaches[context]) {
|
|
3516
|
-
this._shapePageGeometryCaches[context] = this.store.createComputedCache(
|
|
3517
|
-
"bounds",
|
|
3518
|
-
(shape2) => {
|
|
3519
|
-
const geometry = this.getShapeGeometry(shape2.id, opts);
|
|
3520
|
-
const pageTransform = this.getShapePageTransform(shape2.id);
|
|
3521
|
-
return geometry.transform(pageTransform);
|
|
3522
|
-
},
|
|
3523
|
-
{
|
|
3524
|
-
// we only depend directly on the shape id, and changing geometry/transform will update us anyway
|
|
3525
|
-
areRecordsEqual: () => true
|
|
3526
|
-
}
|
|
3527
|
-
);
|
|
3528
|
-
}
|
|
3529
|
-
return this._shapePageGeometryCaches[context].get(
|
|
3530
|
-
typeof shape === "string" ? shape : shape.id
|
|
3531
|
-
);
|
|
3532
|
-
}
|
|
3533
3497
|
_getShapeHandlesCache() {
|
|
3534
3498
|
return this.store.createComputedCache(
|
|
3535
3499
|
"handles",
|
|
@@ -3623,7 +3587,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3623
3587
|
}
|
|
3624
3588
|
_getShapePageBoundsCache() {
|
|
3625
3589
|
return this.store.createComputedCache("pageBoundsCache", (shape) => {
|
|
3626
|
-
|
|
3590
|
+
const pageTransform = this.getShapePageTransform(shape);
|
|
3591
|
+
if (!pageTransform) return void 0;
|
|
3592
|
+
const geometry = this.getShapeGeometry(shape);
|
|
3593
|
+
return import_Box.Box.FromPoints(pageTransform.applyToPoints(geometry.vertices));
|
|
3627
3594
|
});
|
|
3628
3595
|
}
|
|
3629
3596
|
/**
|
|
@@ -3680,12 +3647,11 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3680
3647
|
(shape2) => this.isShapeOfType(shape2, "frame")
|
|
3681
3648
|
);
|
|
3682
3649
|
if (frameAncestors.length === 0) return void 0;
|
|
3683
|
-
const pageMask = frameAncestors.map(
|
|
3684
|
-
(s)
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
).reduce((acc, b) => {
|
|
3650
|
+
const pageMask = frameAncestors.map((s) => {
|
|
3651
|
+
const geometry = this.getShapeGeometry(s.id);
|
|
3652
|
+
const pageTransform = this.getShapePageTransform(s.id);
|
|
3653
|
+
return pageTransform.applyToPoints(geometry.vertices);
|
|
3654
|
+
}).reduce((acc, b) => {
|
|
3689
3655
|
if (!(b && acc)) return void 0;
|
|
3690
3656
|
const intersection = (0, import_intersect.intersectPolygonPolygon)(acc, b);
|
|
3691
3657
|
if (intersection) {
|