@tldraw/editor 3.13.0-canary.ad6c4f5526a8 → 3.13.0-canary.ae38fb277ff7
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 +2 -15
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +6 -10
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +9 -45
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +3 -0
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +2 -1
- package/dist-cjs/lib/hooks/useEditorComponents.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 +2 -15
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +6 -10
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +9 -45
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +3 -0
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +4 -1
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +0 -7
- package/package.json +7 -7
- package/src/lib/components/default-components/DefaultCanvas.tsx +6 -11
- package/src/lib/editor/Editor.ts +9 -56
- package/src/lib/editor/shapes/ShapeUtil.ts +1 -1
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +4 -0
- package/src/lib/hooks/useEditorComponents.tsx +5 -2
- package/src/version.ts +3 -3
|
@@ -1475,23 +1475,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1475
1475
|
this.setSelectedShapes(this._getUnlockedShapeIds(ids));
|
|
1476
1476
|
return this;
|
|
1477
1477
|
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Select the next shape in the reading order or in cardinal order.
|
|
1480
|
-
*
|
|
1481
|
-
* @example
|
|
1482
|
-
* ```ts
|
|
1483
|
-
* editor.selectAdjacentShape('next')
|
|
1484
|
-
* ```
|
|
1485
|
-
*
|
|
1486
|
-
* @public
|
|
1487
|
-
*/
|
|
1488
1478
|
selectAdjacentShape(direction) {
|
|
1479
|
+
const readingOrderShapes = this.getCurrentPageShapesInReadingOrder();
|
|
1489
1480
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1490
|
-
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
|
|
1491
|
-
const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !isPageId(firstParentId);
|
|
1492
|
-
const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(
|
|
1493
|
-
this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId)
|
|
1494
|
-
) : this.getCurrentPageShapesInReadingOrder();
|
|
1495
1481
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1496
1482
|
let adjacentShapeId;
|
|
1497
1483
|
if (direction === "next" || direction === "prev") {
|
|
@@ -1505,15 +1491,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1505
1491
|
}
|
|
1506
1492
|
const shape = this.getShape(adjacentShapeId);
|
|
1507
1493
|
if (!shape) return;
|
|
1508
|
-
this.
|
|
1494
|
+
this.setSelectedShapes([shape.id]);
|
|
1495
|
+
this.zoomToSelectionIfOffscreen(256, {
|
|
1496
|
+
animation: {
|
|
1497
|
+
duration: this.options.animationMediumMs
|
|
1498
|
+
},
|
|
1499
|
+
inset: 0
|
|
1500
|
+
});
|
|
1509
1501
|
}
|
|
1510
1502
|
getCurrentPageShapesInReadingOrder() {
|
|
1511
|
-
const shapes = this.getCurrentPageShapes().filter((shape) => isPageId(shape.parentId));
|
|
1512
|
-
return this._getShapesInReadingOrder(shapes);
|
|
1513
|
-
}
|
|
1514
|
-
_getShapesInReadingOrder(shapes) {
|
|
1515
1503
|
const SHALLOW_ANGLE = 20;
|
|
1516
1504
|
const ROW_THRESHOLD = 100;
|
|
1505
|
+
const shapes = this.getCurrentPageShapes();
|
|
1517
1506
|
const tabbableShapes = shapes.filter((shape) => this.getShapeUtil(shape).canTabTo(shape));
|
|
1518
1507
|
if (tabbableShapes.length <= 1) return tabbableShapes;
|
|
1519
1508
|
const shapesWithCenters = tabbableShapes.map((shape) => ({
|
|
@@ -1611,31 +1600,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1611
1600
|
});
|
|
1612
1601
|
return lowestScoringShape.shape.id;
|
|
1613
1602
|
}
|
|
1614
|
-
selectParentShape() {
|
|
1615
|
-
const selectedShape = this.getOnlySelectedShape();
|
|
1616
|
-
if (!selectedShape) return;
|
|
1617
|
-
const parentShape = this.getShape(selectedShape.parentId);
|
|
1618
|
-
if (!parentShape) return;
|
|
1619
|
-
this._selectShapesAndZoom([parentShape.id]);
|
|
1620
|
-
}
|
|
1621
|
-
selectFirstChildShape() {
|
|
1622
|
-
const selectedShapes = this.getSelectedShapes();
|
|
1623
|
-
if (!selectedShapes.length) return;
|
|
1624
|
-
const selectedShape = selectedShapes[0];
|
|
1625
|
-
const children = this.getSortedChildIdsForParent(selectedShape.id).map((id) => this.getShape(id)).filter((i) => i);
|
|
1626
|
-
const sortedChildren = this._getShapesInReadingOrder(children);
|
|
1627
|
-
if (sortedChildren.length === 0) return;
|
|
1628
|
-
this._selectShapesAndZoom([sortedChildren[0].id]);
|
|
1629
|
-
}
|
|
1630
|
-
_selectShapesAndZoom(ids) {
|
|
1631
|
-
this.setSelectedShapes(ids);
|
|
1632
|
-
this.zoomToSelectionIfOffscreen(256, {
|
|
1633
|
-
animation: {
|
|
1634
|
-
duration: this.options.animationMediumMs
|
|
1635
|
-
},
|
|
1636
|
-
inset: 0
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
1603
|
/**
|
|
1640
1604
|
* Clear the selection.
|
|
1641
1605
|
*
|