@tldraw/editor 3.13.0-canary.6307ec7baefb → 3.13.0-canary.66687519f459
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 +14 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +45 -9
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +0 -3
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.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 +14 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +45 -9
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +0 -3
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.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 +56 -9
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +0 -4
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -1560,6 +1560,16 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1560
1560
|
* @public
|
|
1561
1561
|
*/
|
|
1562
1562
|
selectAll(): this;
|
|
1563
|
+
/**
|
|
1564
|
+
* Select the next shape in the reading order or in cardinal order.
|
|
1565
|
+
*
|
|
1566
|
+
* @example
|
|
1567
|
+
* ```ts
|
|
1568
|
+
* editor.selectAdjacentShape('next')
|
|
1569
|
+
* ```
|
|
1570
|
+
*
|
|
1571
|
+
* @public
|
|
1572
|
+
*/
|
|
1563
1573
|
selectAdjacentShape(direction: TLAdjacentDirection): void;
|
|
1564
1574
|
/**
|
|
1565
1575
|
* Generates a reading order for shapes based on rows grouping.
|
|
@@ -1568,12 +1578,16 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1568
1578
|
* @public
|
|
1569
1579
|
*/
|
|
1570
1580
|
getCurrentPageShapesInReadingOrder(): TLShape[];
|
|
1581
|
+
private _getShapesInReadingOrder;
|
|
1571
1582
|
/**
|
|
1572
1583
|
* Find the nearest adjacent shape in a specific direction.
|
|
1573
1584
|
*
|
|
1574
1585
|
* @public
|
|
1575
1586
|
*/
|
|
1576
1587
|
getNearestAdjacentShape(currentShapeId: TLShapeId, direction: 'down' | 'left' | 'right' | 'up'): TLShapeId;
|
|
1588
|
+
selectParentShape(): void;
|
|
1589
|
+
selectFirstChildShape(): void;
|
|
1590
|
+
private _selectShapesAndZoom;
|
|
1577
1591
|
/**
|
|
1578
1592
|
* Clear the selection.
|
|
1579
1593
|
*
|
|
@@ -4285,7 +4299,6 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
4285
4299
|
static type: "group";
|
|
4286
4300
|
static props: RecordProps<TLGroupShape>;
|
|
4287
4301
|
static migrations: TLPropsMigrations;
|
|
4288
|
-
canTabTo(): boolean;
|
|
4289
4302
|
hideSelectionBoundsFg(): boolean;
|
|
4290
4303
|
canBind(): boolean;
|
|
4291
4304
|
getDefaultProps(): TLGroupShape['props'];
|
package/dist-cjs/index.js
CHANGED
|
@@ -1441,9 +1441,23 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1441
1441
|
this.setSelectedShapes(this._getUnlockedShapeIds(ids));
|
|
1442
1442
|
return this;
|
|
1443
1443
|
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Select the next shape in the reading order or in cardinal order.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* editor.selectAdjacentShape('next')
|
|
1450
|
+
* ```
|
|
1451
|
+
*
|
|
1452
|
+
* @public
|
|
1453
|
+
*/
|
|
1444
1454
|
selectAdjacentShape(direction) {
|
|
1445
|
-
const readingOrderShapes = this.getCurrentPageShapesInReadingOrder();
|
|
1446
1455
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1456
|
+
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
|
|
1457
|
+
const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !(0, import_tlschema.isPageId)(firstParentId);
|
|
1458
|
+
const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(
|
|
1459
|
+
this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId)
|
|
1460
|
+
) : this.getCurrentPageShapesInReadingOrder();
|
|
1447
1461
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1448
1462
|
let adjacentShapeId;
|
|
1449
1463
|
if (direction === "next" || direction === "prev") {
|
|
@@ -1457,18 +1471,15 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1457
1471
|
}
|
|
1458
1472
|
const shape = this.getShape(adjacentShapeId);
|
|
1459
1473
|
if (!shape) return;
|
|
1460
|
-
this.
|
|
1461
|
-
this.zoomToSelectionIfOffscreen(256, {
|
|
1462
|
-
animation: {
|
|
1463
|
-
duration: this.options.animationMediumMs
|
|
1464
|
-
},
|
|
1465
|
-
inset: 0
|
|
1466
|
-
});
|
|
1474
|
+
this._selectShapesAndZoom([shape.id]);
|
|
1467
1475
|
}
|
|
1468
1476
|
getCurrentPageShapesInReadingOrder() {
|
|
1477
|
+
const shapes = this.getCurrentPageShapes().filter((shape) => (0, import_tlschema.isPageId)(shape.parentId));
|
|
1478
|
+
return this._getShapesInReadingOrder(shapes);
|
|
1479
|
+
}
|
|
1480
|
+
_getShapesInReadingOrder(shapes) {
|
|
1469
1481
|
const SHALLOW_ANGLE = 20;
|
|
1470
1482
|
const ROW_THRESHOLD = 100;
|
|
1471
|
-
const shapes = this.getCurrentPageShapes();
|
|
1472
1483
|
const tabbableShapes = shapes.filter((shape) => this.getShapeUtil(shape).canTabTo(shape));
|
|
1473
1484
|
if (tabbableShapes.length <= 1) return tabbableShapes;
|
|
1474
1485
|
const shapesWithCenters = tabbableShapes.map((shape) => ({
|
|
@@ -1566,6 +1577,31 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1566
1577
|
});
|
|
1567
1578
|
return lowestScoringShape.shape.id;
|
|
1568
1579
|
}
|
|
1580
|
+
selectParentShape() {
|
|
1581
|
+
const selectedShape = this.getOnlySelectedShape();
|
|
1582
|
+
if (!selectedShape) return;
|
|
1583
|
+
const parentShape = this.getShape(selectedShape.parentId);
|
|
1584
|
+
if (!parentShape) return;
|
|
1585
|
+
this._selectShapesAndZoom([parentShape.id]);
|
|
1586
|
+
}
|
|
1587
|
+
selectFirstChildShape() {
|
|
1588
|
+
const selectedShapes = this.getSelectedShapes();
|
|
1589
|
+
if (!selectedShapes.length) return;
|
|
1590
|
+
const selectedShape = selectedShapes[0];
|
|
1591
|
+
const children = this.getSortedChildIdsForParent(selectedShape.id).map((id) => this.getShape(id)).filter((i) => i);
|
|
1592
|
+
const sortedChildren = this._getShapesInReadingOrder(children);
|
|
1593
|
+
if (sortedChildren.length === 0) return;
|
|
1594
|
+
this._selectShapesAndZoom([sortedChildren[0].id]);
|
|
1595
|
+
}
|
|
1596
|
+
_selectShapesAndZoom(ids) {
|
|
1597
|
+
this.setSelectedShapes(ids);
|
|
1598
|
+
this.zoomToSelectionIfOffscreen(256, {
|
|
1599
|
+
animation: {
|
|
1600
|
+
duration: this.options.animationMediumMs
|
|
1601
|
+
},
|
|
1602
|
+
inset: 0
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1569
1605
|
/**
|
|
1570
1606
|
* Clear the selection.
|
|
1571
1607
|
*
|