@tldraw/editor 5.5.0-canary.eef775d9b2dd → 5.5.0-canary.f35842e3ba7e
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 +34 -20
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- 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 +34 -20
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- 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 +51 -25
- 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
package/dist-cjs/index.js
CHANGED
|
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
392
392
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
393
393
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
394
394
|
"@tldraw/editor",
|
|
395
|
-
"5.5.0-canary.
|
|
395
|
+
"5.5.0-canary.f35842e3ba7e",
|
|
396
396
|
"cjs"
|
|
397
397
|
);
|
|
398
398
|
//# sourceMappingURL=index.js.map
|
|
@@ -1610,12 +1610,15 @@ class Editor extends import_eventemitter3.default {
|
|
|
1610
1610
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
1611
1611
|
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
|
|
1612
1612
|
const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !(0, import_tlschema.isPageId)(firstParentId);
|
|
1613
|
-
const filteredShapes =
|
|
1614
|
-
|
|
1613
|
+
const filteredShapes = this.getCurrentPageShapes().filter(
|
|
1614
|
+
(shape2) => !this.isShapeOrAncestorLocked(shape2) && (isSelectedWithinContainer ? shape2.parentId === firstParentId : (0, import_tlschema.isPageId)(shape2.parentId))
|
|
1615
|
+
);
|
|
1616
|
+
const readingOrderShapes = this._getShapesInReadingOrder(filteredShapes);
|
|
1615
1617
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1616
1618
|
let adjacentShapeId;
|
|
1617
1619
|
if (direction === "next" || direction === "prev") {
|
|
1618
1620
|
const shapeIds = readingOrderShapes.map((shape2) => shape2.id);
|
|
1621
|
+
if (shapeIds.length === 0) return;
|
|
1619
1622
|
const currentIndex = currentShapeId ? shapeIds.indexOf(currentShapeId) : -1;
|
|
1620
1623
|
const startIndex = currentIndex === -1 && direction === "prev" ? 0 : currentIndex;
|
|
1621
1624
|
const adjacentIndex = (startIndex + (direction === "next" ? 1 : -1) + shapeIds.length) % shapeIds.length;
|
|
@@ -2498,7 +2501,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
2498
2501
|
setCamera(point, opts) {
|
|
2499
2502
|
const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
2500
2503
|
if (isLocked && !opts?.force) return this;
|
|
2501
|
-
const _point = import_Vec.Vec.
|
|
2504
|
+
const _point = new import_Vec.Vec(point.x, point.y, point.z ?? this.getZoomLevel());
|
|
2502
2505
|
if (!Number.isFinite(_point.x) || !Number.isFinite(_point.y) || !Number.isFinite(_point.z)) {
|
|
2503
2506
|
throw Error(
|
|
2504
2507
|
`Editor.setCamera: expected finite values, got (${_point.x}, ${_point.y}, ${_point.z}).`
|
|
@@ -2920,6 +2923,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
2920
2923
|
}
|
|
2921
2924
|
const isOnSamePage = presence.currentPageId === this.getCurrentPageId();
|
|
2922
2925
|
if (!isOnSamePage) {
|
|
2926
|
+
this.markHistoryStoppingPoint("change-page");
|
|
2923
2927
|
this.setCurrentPage(presence.currentPageId);
|
|
2924
2928
|
}
|
|
2925
2929
|
if (opts && opts.animation && !isOnSamePage) {
|
|
@@ -3751,7 +3755,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
3751
3755
|
if (ids.length <= 0) return this;
|
|
3752
3756
|
this.run(
|
|
3753
3757
|
() => {
|
|
3754
|
-
this.store.props.assets.remove?.(ids)
|
|
3758
|
+
Promise.resolve(this.store.props.assets.remove?.(ids)).catch(
|
|
3759
|
+
(err) => console.error("Error while removing assets from the asset store:", err)
|
|
3760
|
+
);
|
|
3755
3761
|
this.store.remove(ids);
|
|
3756
3762
|
},
|
|
3757
3763
|
{ history: "ignore" }
|
|
@@ -6935,21 +6941,29 @@ class Editor extends import_eventemitter3.default {
|
|
|
6935
6941
|
await Promise.allSettled(
|
|
6936
6942
|
content.assets.map(async (asset) => {
|
|
6937
6943
|
if ((asset.type === "image" || asset.type === "video") && !asset.props.src?.startsWith("data:image") && !asset.props.src?.startsWith("data:video") && !asset.props.src?.startsWith("http")) {
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6944
|
+
try {
|
|
6945
|
+
const objectUrl = await this.store.props.assets.resolve(asset, {
|
|
6946
|
+
screenScale: 1,
|
|
6947
|
+
steppedScreenScale: 1,
|
|
6948
|
+
dpr: 1,
|
|
6949
|
+
networkEffectiveType: null,
|
|
6950
|
+
shouldResolveToOriginal: true
|
|
6951
|
+
});
|
|
6952
|
+
if (objectUrl) {
|
|
6953
|
+
const response = await (0, import_utils.fetch)(objectUrl);
|
|
6954
|
+
if (response.ok) {
|
|
6955
|
+
const assetWithDataUrl = (0, import_utils.structuredClone)(asset);
|
|
6956
|
+
assetWithDataUrl.props.src = await import_utils.FileHelpers.blobToDataUrl(await response.blob());
|
|
6957
|
+
assets.push(assetWithDataUrl);
|
|
6958
|
+
return;
|
|
6959
|
+
}
|
|
6960
|
+
console.warn(`Could not inline asset ${asset.id}: fetch returned ${response.status}`);
|
|
6961
|
+
}
|
|
6962
|
+
} catch (err) {
|
|
6963
|
+
console.warn(`Could not inline asset ${asset.id}`, err);
|
|
6964
|
+
}
|
|
6952
6965
|
}
|
|
6966
|
+
assets.push(asset);
|
|
6953
6967
|
})
|
|
6954
6968
|
);
|
|
6955
6969
|
content.assets = assets;
|
|
@@ -8297,8 +8311,8 @@ class Editor extends import_eventemitter3.default {
|
|
|
8297
8311
|
break;
|
|
8298
8312
|
}
|
|
8299
8313
|
case "keyboard": {
|
|
8300
|
-
if (info.
|
|
8301
|
-
if (info.
|
|
8314
|
+
if (info.code === "ShiftRight") info.code = "ShiftLeft";
|
|
8315
|
+
if (info.code === "AltRight") info.code = "AltLeft";
|
|
8302
8316
|
if (info.code === "ControlRight") info.code = "ControlLeft";
|
|
8303
8317
|
if (info.code === "MetaRight") info.code = "MetaLeft";
|
|
8304
8318
|
switch (info.name) {
|