@tldraw/editor 5.5.0-canary.18fedebfa67a → 5.5.0-canary.1ad7975d82e3

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.18fedebfa67a",
395
+ "5.5.0-canary.1ad7975d82e3",
396
396
  "cjs"
397
397
  );
398
398
  //# sourceMappingURL=index.js.map
@@ -1593,7 +1593,7 @@ class Editor extends import_eventemitter3.default {
1593
1593
  }
1594
1594
  const ids = this.getSortedChildIdsForParent(parentToSelectWithinId);
1595
1595
  if (ids.length <= 0) return this;
1596
- this.setSelectedShapes(this._getUnlockedShapeIds(ids));
1596
+ this.setSelectedShapes(ids.filter((id) => !this.getShape(id)?.isLocked));
1597
1597
  return this;
1598
1598
  }
1599
1599
  /**
@@ -2501,7 +2501,7 @@ class Editor extends import_eventemitter3.default {
2501
2501
  setCamera(point, opts) {
2502
2502
  const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture();
2503
2503
  if (isLocked && !opts?.force) return this;
2504
- const _point = import_Vec.Vec.Cast(point);
2504
+ const _point = new import_Vec.Vec(point.x, point.y, point.z ?? this.getZoomLevel());
2505
2505
  if (!Number.isFinite(_point.x) || !Number.isFinite(_point.y) || !Number.isFinite(_point.z)) {
2506
2506
  throw Error(
2507
2507
  `Editor.setCamera: expected finite values, got (${_point.x}, ${_point.y}, ${_point.z}).`
@@ -3755,7 +3755,9 @@ class Editor extends import_eventemitter3.default {
3755
3755
  if (ids.length <= 0) return this;
3756
3756
  this.run(
3757
3757
  () => {
3758
- 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
+ );
3759
3761
  this.store.remove(ids);
3760
3762
  },
3761
3763
  { history: "ignore" }
@@ -6309,12 +6311,17 @@ class Editor extends import_eventemitter3.default {
6309
6311
  let remaining = duration;
6310
6312
  let t;
6311
6313
  const animations = [];
6314
+ const ignoreShapeLock = this._shouldIgnoreShapeLock;
6312
6315
  let partial, result;
6313
6316
  for (let i = 0, n = partials.length; i < n; i++) {
6314
6317
  partial = partials[i];
6315
6318
  if (!partial) continue;
6316
6319
  const shape = this.getShape(partial.id);
6317
6320
  if (!shape) continue;
6321
+ const unlocks = shape.isLocked && Object.hasOwn(partial, "isLocked") && !partial.isLocked;
6322
+ if (!ignoreShapeLock && !unlocks && this.isShapeOrAncestorLocked(shape)) {
6323
+ continue;
6324
+ }
6318
6325
  result = {
6319
6326
  start: (0, import_utils.structuredClone)(shape),
6320
6327
  end: applyPartialToRecordWithProps((0, import_utils.structuredClone)(shape), partial)
@@ -6330,7 +6337,7 @@ class Editor extends import_eventemitter3.default {
6330
6337
  (p) => p && animatingShapes2.get(p.id) === animationId
6331
6338
  );
6332
6339
  if (partialsToUpdate.length) {
6333
- this.updateShapes(partialsToUpdate);
6340
+ this.run(() => this.updateShapes(partialsToUpdate), { ignoreShapeLock });
6334
6341
  }
6335
6342
  this.off("tick", handleTick);
6336
6343
  return;
@@ -6370,6 +6377,7 @@ class Editor extends import_eventemitter3.default {
6370
6377
  (id) => this.getShape(id)
6371
6378
  )
6372
6379
  );
6380
+ if (shapesToGroup.length <= 1) return this;
6373
6381
  const sortedShapeIds = shapesToGroup.sort(import_utils.sortByIndex).map((s) => s.id);
6374
6382
  const childBounds = (0, import_utils.compact)(shapesToGroup.map((shape) => this.getShapePageBounds(shape)));
6375
6383
  const pageBounds = import_Box.Box.Common(childBounds);
@@ -6519,7 +6527,7 @@ class Editor extends import_eventemitter3.default {
6519
6527
  }
6520
6528
  /** @internal */
6521
6529
  _getUnlockedShapeIds(ids) {
6522
- return ids.filter((id) => !this.getShape(id)?.isLocked);
6530
+ return ids.filter((id) => !this.isShapeOrAncestorLocked(id));
6523
6531
  }
6524
6532
  deleteShapes(_ids) {
6525
6533
  if (this.getIsReadonly()) return this;
@@ -6939,21 +6947,29 @@ class Editor extends import_eventemitter3.default {
6939
6947
  await Promise.allSettled(
6940
6948
  content.assets.map(async (asset) => {
6941
6949
  if ((asset.type === "image" || asset.type === "video") && !asset.props.src?.startsWith("data:image") && !asset.props.src?.startsWith("data:video") && !asset.props.src?.startsWith("http")) {
6942
- const assetWithDataUrl = (0, import_utils.structuredClone)(asset);
6943
- const objectUrl = await this.store.props.assets.resolve(asset, {
6944
- screenScale: 1,
6945
- steppedScreenScale: 1,
6946
- dpr: 1,
6947
- networkEffectiveType: null,
6948
- shouldResolveToOriginal: true
6949
- });
6950
- assetWithDataUrl.props.src = await import_utils.FileHelpers.blobToDataUrl(
6951
- await (0, import_utils.fetch)(objectUrl).then((r) => r.blob())
6952
- );
6953
- assets.push(assetWithDataUrl);
6954
- } else {
6955
- assets.push(asset);
6950
+ try {
6951
+ const objectUrl = await this.store.props.assets.resolve(asset, {
6952
+ screenScale: 1,
6953
+ steppedScreenScale: 1,
6954
+ dpr: 1,
6955
+ networkEffectiveType: null,
6956
+ shouldResolveToOriginal: true
6957
+ });
6958
+ if (objectUrl) {
6959
+ const response = await (0, import_utils.fetch)(objectUrl);
6960
+ if (response.ok) {
6961
+ const assetWithDataUrl = (0, import_utils.structuredClone)(asset);
6962
+ assetWithDataUrl.props.src = await import_utils.FileHelpers.blobToDataUrl(await response.blob());
6963
+ assets.push(assetWithDataUrl);
6964
+ return;
6965
+ }
6966
+ console.warn(`Could not inline asset ${asset.id}: fetch returned ${response.status}`);
6967
+ }
6968
+ } catch (err) {
6969
+ console.warn(`Could not inline asset ${asset.id}`, err);
6970
+ }
6956
6971
  }
6972
+ assets.push(asset);
6957
6973
  })
6958
6974
  );
6959
6975
  content.assets = assets;