@tldraw/editor 5.5.0-next.a2698a88ecfb → 5.5.0-next.c25ed1f4cf7f
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.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +15 -9
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +14 -6
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +3 -3
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +13 -17
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +78 -40
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +15 -9
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +14 -6
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +3 -3
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +13 -17
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +78 -40
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.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 +32 -16
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +23 -8
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +28 -0
- package/src/lib/utils/sync/LocalIndexedDb.ts +18 -20
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +236 -0
- package/src/lib/utils/sync/TLLocalSyncClient.ts +106 -54
- package/src/version.ts +3 -3
|
@@ -1651,12 +1651,15 @@ class Editor extends EventEmitter {
|
|
|
1651
1651
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1652
1652
|
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
|
|
1653
1653
|
const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !isPageId(firstParentId);
|
|
1654
|
-
const filteredShapes =
|
|
1655
|
-
|
|
1654
|
+
const filteredShapes = this.getCurrentPageShapes().filter(
|
|
1655
|
+
(shape2) => !this.isShapeOrAncestorLocked(shape2) && (isSelectedWithinContainer ? shape2.parentId === firstParentId : isPageId(shape2.parentId))
|
|
1656
|
+
);
|
|
1657
|
+
const readingOrderShapes = this._getShapesInReadingOrder(filteredShapes);
|
|
1656
1658
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1657
1659
|
let adjacentShapeId;
|
|
1658
1660
|
if (direction === "next" || direction === "prev") {
|
|
1659
1661
|
const shapeIds = readingOrderShapes.map((shape2) => shape2.id);
|
|
1662
|
+
if (shapeIds.length === 0) return;
|
|
1660
1663
|
const currentIndex = currentShapeId ? shapeIds.indexOf(currentShapeId) : -1;
|
|
1661
1664
|
const startIndex = currentIndex === -1 && direction === "prev" ? 0 : currentIndex;
|
|
1662
1665
|
const adjacentIndex = (startIndex + (direction === "next" ? 1 : -1) + shapeIds.length) % shapeIds.length;
|
|
@@ -2539,14 +2542,16 @@ class Editor extends EventEmitter {
|
|
|
2539
2542
|
setCamera(point, opts) {
|
|
2540
2543
|
const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
2541
2544
|
if (isLocked && !opts?.force) return this;
|
|
2545
|
+
const _point = Vec.Cast(point);
|
|
2546
|
+
if (!Number.isFinite(_point.x) || !Number.isFinite(_point.y) || !Number.isFinite(_point.z)) {
|
|
2547
|
+
throw Error(
|
|
2548
|
+
`Editor.setCamera: expected finite values, got (${_point.x}, ${_point.y}, ${_point.z}).`
|
|
2549
|
+
);
|
|
2550
|
+
}
|
|
2542
2551
|
this.stopCameraAnimation();
|
|
2543
2552
|
if (this.getInstanceState().followingUserId) {
|
|
2544
2553
|
this.stopFollowingUser();
|
|
2545
2554
|
}
|
|
2546
|
-
const _point = Vec.Cast(point);
|
|
2547
|
-
if (!Number.isFinite(_point.x)) _point.x = 0;
|
|
2548
|
-
if (!Number.isFinite(_point.y)) _point.y = 0;
|
|
2549
|
-
if (_point.z === void 0 || !Number.isFinite(_point.z)) point.z = this.getZoomLevel();
|
|
2550
2555
|
const camera = this.getConstrainedCamera(_point, opts);
|
|
2551
2556
|
if (opts?.animation) {
|
|
2552
2557
|
const { width, height } = this.getViewportScreenBounds();
|
|
@@ -2959,6 +2964,7 @@ class Editor extends EventEmitter {
|
|
|
2959
2964
|
}
|
|
2960
2965
|
const isOnSamePage = presence.currentPageId === this.getCurrentPageId();
|
|
2961
2966
|
if (!isOnSamePage) {
|
|
2967
|
+
this.markHistoryStoppingPoint("change-page");
|
|
2962
2968
|
this.setCurrentPage(presence.currentPageId);
|
|
2963
2969
|
}
|
|
2964
2970
|
if (opts && opts.animation && !isOnSamePage) {
|
|
@@ -5399,7 +5405,7 @@ class Editor extends EventEmitter {
|
|
|
5399
5405
|
const shapesMovingTogether = [shape];
|
|
5400
5406
|
const boundsOfShapesMovingTogether = [shapePageBounds];
|
|
5401
5407
|
this.collectShapesViaArrowBindings({
|
|
5402
|
-
bindings: this.
|
|
5408
|
+
bindings: this.getBindingsInvolvingShape(shape.id, "arrow"),
|
|
5403
5409
|
initialShapes: freshShapes,
|
|
5404
5410
|
resultShapes: shapesMovingTogether,
|
|
5405
5411
|
resultBounds: boundsOfShapesMovingTogether,
|
|
@@ -8336,8 +8342,8 @@ class Editor extends EventEmitter {
|
|
|
8336
8342
|
break;
|
|
8337
8343
|
}
|
|
8338
8344
|
case "keyboard": {
|
|
8339
|
-
if (info.
|
|
8340
|
-
if (info.
|
|
8345
|
+
if (info.code === "ShiftRight") info.code = "ShiftLeft";
|
|
8346
|
+
if (info.code === "AltRight") info.code = "AltLeft";
|
|
8341
8347
|
if (info.code === "ControlRight") info.code = "ControlLeft";
|
|
8342
8348
|
if (info.code === "MetaRight") info.code = "MetaLeft";
|
|
8343
8349
|
switch (info.name) {
|