@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 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.eef775d9b2dd",
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 = isSelectedWithinContainer ? this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId) : this.getCurrentPageShapes().filter((shape2) => (0, import_tlschema.isPageId)(shape2.parentId));
1614
- const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(filteredShapes) : this.getCurrentPageShapesInReadingOrder();
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.Cast(point);
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
- const assetWithDataUrl = (0, import_utils.structuredClone)(asset);
6939
- const objectUrl = await this.store.props.assets.resolve(asset, {
6940
- screenScale: 1,
6941
- steppedScreenScale: 1,
6942
- dpr: 1,
6943
- networkEffectiveType: null,
6944
- shouldResolveToOriginal: true
6945
- });
6946
- assetWithDataUrl.props.src = await import_utils.FileHelpers.blobToDataUrl(
6947
- await (0, import_utils.fetch)(objectUrl).then((r) => r.blob())
6948
- );
6949
- assets.push(assetWithDataUrl);
6950
- } else {
6951
- assets.push(asset);
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.key === "ShiftRight") info.key = "ShiftLeft";
8301
- if (info.key === "AltRight") info.key = "AltLeft";
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) {