@tldraw/editor 3.15.0-canary.9cfe72490c8f → 3.15.0-canary.9d3e452295cd
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 +60 -3
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +27 -15
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +22 -19
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +20 -1
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +1 -1
- package/dist-cjs/lib/license/Watermark.js +2 -2
- package/dist-cjs/lib/license/Watermark.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 +60 -3
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +17 -15
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +22 -19
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +20 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +1 -1
- package/dist-esm/lib/license/Watermark.mjs +2 -2
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +17 -4
- package/package.json +9 -8
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/editor/Editor.ts +26 -18
- package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
- package/src/lib/editor/tools/StateNode.test.ts +285 -0
- package/src/lib/editor/tools/StateNode.ts +27 -1
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/license/Watermark.tsx +2 -2
- package/src/version.ts +3 -3
- package/src/lib/test/currentToolIdMask.test.ts +0 -49
|
@@ -1513,9 +1513,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1513
1513
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1514
1514
|
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
|
|
1515
1515
|
const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !isPageId(firstParentId);
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1518
|
-
) : this.getCurrentPageShapesInReadingOrder();
|
|
1516
|
+
const filteredShapes = isSelectedWithinContainer ? this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId) : this.getCurrentPageShapes().filter((shape2) => isPageId(shape2.parentId));
|
|
1517
|
+
const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(filteredShapes) : this.getCurrentPageShapesInReadingOrder();
|
|
1519
1518
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1520
1519
|
let adjacentShapeId;
|
|
1521
1520
|
if (direction === "next" || direction === "prev") {
|
|
@@ -1525,7 +1524,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1525
1524
|
adjacentShapeId = shapeIds[adjacentIndex];
|
|
1526
1525
|
} else {
|
|
1527
1526
|
if (!currentShapeId) return;
|
|
1528
|
-
adjacentShapeId = this.getNearestAdjacentShape(currentShapeId, direction);
|
|
1527
|
+
adjacentShapeId = this.getNearestAdjacentShape(filteredShapes, currentShapeId, direction);
|
|
1529
1528
|
}
|
|
1530
1529
|
const shape = this.getShape(adjacentShapeId);
|
|
1531
1530
|
if (!shape) return;
|
|
@@ -1591,11 +1590,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1591
1590
|
*
|
|
1592
1591
|
* @public
|
|
1593
1592
|
*/
|
|
1594
|
-
getNearestAdjacentShape(currentShapeId, direction) {
|
|
1593
|
+
getNearestAdjacentShape(shapes, currentShapeId, direction) {
|
|
1595
1594
|
const directionToAngle = { right: 0, left: 180, down: 90, up: 270 };
|
|
1596
1595
|
const currentShape = this.getShape(currentShapeId);
|
|
1597
1596
|
if (!currentShape) return currentShapeId;
|
|
1598
|
-
const shapes = this.getCurrentPageShapes();
|
|
1599
1597
|
const tabbableShapes = shapes.filter(
|
|
1600
1598
|
(shape) => this.getShapeUtil(shape).canTabTo(shape) && shape.id !== currentShapeId
|
|
1601
1599
|
);
|
|
@@ -3349,19 +3347,24 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3349
3347
|
*/
|
|
3350
3348
|
deletePage(page) {
|
|
3351
3349
|
const id = typeof page === "string" ? page : page.id;
|
|
3352
|
-
this.run(
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3350
|
+
this.run(
|
|
3351
|
+
() => {
|
|
3352
|
+
if (this.getIsReadonly()) return;
|
|
3353
|
+
const pages = this.getPages();
|
|
3354
|
+
if (pages.length === 1) return;
|
|
3355
|
+
const deletedPage = this.getPage(id);
|
|
3356
|
+
if (!deletedPage) return;
|
|
3357
|
+
if (id === this.getCurrentPageId()) {
|
|
3358
|
+
const index = pages.findIndex((page2) => page2.id === id);
|
|
3359
|
+
const next = pages[index - 1] ?? pages[index + 1];
|
|
3360
|
+
this.setCurrentPage(next.id);
|
|
3361
|
+
}
|
|
3362
|
+
const shapes = this.getSortedChildIdsForParent(deletedPage.id);
|
|
3363
|
+
this.deleteShapes(shapes);
|
|
3364
|
+
this.store.remove([deletedPage.id]);
|
|
3365
|
+
},
|
|
3366
|
+
{ ignoreShapeLock: true }
|
|
3367
|
+
);
|
|
3365
3368
|
return this;
|
|
3366
3369
|
}
|
|
3367
3370
|
/**
|