@tldraw/editor 5.5.0-next.9665a55b2322 → 5.5.0-next.b6a9f7cd7be2

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.
Files changed (110) hide show
  1. package/dist-cjs/index.d.ts +2 -0
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/TldrawEditor.js +16 -12
  4. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  5. package/dist-cjs/lib/components/MenuClickCapture.js +42 -3
  6. package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
  7. package/dist-cjs/lib/editor/Editor.js +130 -147
  8. package/dist-cjs/lib/editor/Editor.js.map +3 -3
  9. package/dist-cjs/lib/editor/derivations/bindingsIndex.js +2 -0
  10. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
  11. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +4 -4
  12. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  13. package/dist-cjs/lib/exports/ExportDelay.js +10 -2
  14. package/dist-cjs/lib/exports/ExportDelay.js.map +2 -2
  15. package/dist-cjs/lib/exports/FontEmbedder.js +25 -11
  16. package/dist-cjs/lib/exports/FontEmbedder.js.map +2 -2
  17. package/dist-cjs/lib/exports/StyleEmbedder.js +9 -4
  18. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  19. package/dist-cjs/lib/exports/fetchCache.js +3 -0
  20. package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
  21. package/dist-cjs/lib/exports/getSvgAsImage.js +10 -4
  22. package/dist-cjs/lib/exports/getSvgAsImage.js.map +2 -2
  23. package/dist-cjs/lib/exports/getSvgJsx.js +18 -9
  24. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  25. package/dist-cjs/lib/exports/parseCss.js +1 -1
  26. package/dist-cjs/lib/exports/parseCss.js.map +1 -1
  27. package/dist-cjs/lib/hooks/useCanvasEvents.js +24 -0
  28. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  29. package/dist-cjs/lib/hooks/useIdentity.js +6 -2
  30. package/dist-cjs/lib/hooks/useIdentity.js.map +3 -3
  31. package/dist-cjs/lib/license/LicenseManager.js +9 -1
  32. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  33. package/dist-cjs/lib/license/LicenseProvider.js +12 -4
  34. package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
  35. package/dist-cjs/lib/utils/deepLinks.js +2 -1
  36. package/dist-cjs/lib/utils/deepLinks.js.map +2 -2
  37. package/dist-cjs/version.js +3 -3
  38. package/dist-cjs/version.js.map +1 -1
  39. package/dist-esm/index.d.mts +2 -0
  40. package/dist-esm/index.mjs +1 -1
  41. package/dist-esm/lib/TldrawEditor.mjs +17 -13
  42. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  43. package/dist-esm/lib/components/MenuClickCapture.mjs +42 -3
  44. package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
  45. package/dist-esm/lib/editor/Editor.mjs +130 -147
  46. package/dist-esm/lib/editor/Editor.mjs.map +3 -3
  47. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs +2 -0
  48. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
  49. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +4 -4
  50. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  51. package/dist-esm/lib/exports/ExportDelay.mjs +11 -3
  52. package/dist-esm/lib/exports/ExportDelay.mjs.map +2 -2
  53. package/dist-esm/lib/exports/FontEmbedder.mjs +25 -11
  54. package/dist-esm/lib/exports/FontEmbedder.mjs.map +2 -2
  55. package/dist-esm/lib/exports/StyleEmbedder.mjs +9 -4
  56. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  57. package/dist-esm/lib/exports/fetchCache.mjs +3 -0
  58. package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
  59. package/dist-esm/lib/exports/getSvgAsImage.mjs +10 -4
  60. package/dist-esm/lib/exports/getSvgAsImage.mjs.map +2 -2
  61. package/dist-esm/lib/exports/getSvgJsx.mjs +18 -9
  62. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  63. package/dist-esm/lib/exports/parseCss.mjs +1 -1
  64. package/dist-esm/lib/exports/parseCss.mjs.map +1 -1
  65. package/dist-esm/lib/hooks/useCanvasEvents.mjs +24 -0
  66. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  67. package/dist-esm/lib/hooks/useIdentity.mjs +7 -3
  68. package/dist-esm/lib/hooks/useIdentity.mjs.map +3 -3
  69. package/dist-esm/lib/license/LicenseManager.mjs +9 -1
  70. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  71. package/dist-esm/lib/license/LicenseProvider.mjs +13 -5
  72. package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
  73. package/dist-esm/lib/utils/deepLinks.mjs +2 -1
  74. package/dist-esm/lib/utils/deepLinks.mjs.map +2 -2
  75. package/dist-esm/version.mjs +3 -3
  76. package/dist-esm/version.mjs.map +1 -1
  77. package/editor.css +9 -1
  78. package/package.json +8 -11
  79. package/src/lib/TldrawEditor.tsx +27 -15
  80. package/src/lib/components/MenuClickCapture.tsx +55 -4
  81. package/src/lib/editor/Editor.test.ts +20 -0
  82. package/src/lib/editor/Editor.ts +190 -244
  83. package/src/lib/editor/derivations/bindingsIndex.ts +3 -0
  84. package/src/lib/editor/managers/TextManager/TextManager.test.ts +74 -0
  85. package/src/lib/editor/managers/TextManager/TextManager.ts +6 -5
  86. package/src/lib/exports/ExportDelay.tsx +16 -4
  87. package/src/lib/exports/FontEmbedder.test.ts +99 -0
  88. package/src/lib/exports/FontEmbedder.ts +32 -11
  89. package/src/lib/exports/StyleEmbedder.ts +13 -4
  90. package/src/lib/exports/fetchCache.test.ts +22 -0
  91. package/src/lib/exports/fetchCache.ts +4 -0
  92. package/src/lib/exports/getSvgAsImage.ts +13 -5
  93. package/src/lib/exports/getSvgJsx.test.ts +43 -1
  94. package/src/lib/exports/getSvgJsx.tsx +28 -16
  95. package/src/lib/exports/parseCss.test.ts +4 -0
  96. package/src/lib/exports/parseCss.ts +2 -2
  97. package/src/lib/hooks/useCanvasEvents.ts +42 -0
  98. package/src/lib/hooks/useIdentity.tsx +12 -1
  99. package/src/lib/license/LicenseManager.ts +13 -1
  100. package/src/lib/license/LicenseProvider.test.tsx +76 -0
  101. package/src/lib/license/LicenseProvider.tsx +19 -5
  102. package/src/lib/test/preserveFocus.test.tsx +81 -0
  103. package/src/lib/utils/deepLinks.test.ts +15 -0
  104. package/src/lib/utils/deepLinks.ts +8 -3
  105. package/src/version.ts +3 -3
  106. package/dist-cjs/lib/primitives/geometry/geometry.bench.js +0 -133
  107. package/dist-cjs/lib/primitives/geometry/geometry.bench.js.map +0 -7
  108. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs +0 -132
  109. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs.map +0 -7
  110. package/src/lib/primitives/geometry/geometry.bench.ts +0 -179
@@ -95,6 +95,10 @@ var import_UserPreferencesManager = require("./managers/UserPreferencesManager/U
95
95
  var import_OverlayManager = require("./overlays/OverlayManager");
96
96
  var import_RootState = require("./tools/RootState");
97
97
  const RENDERING_SHAPES_SORT_CACHE_THRESHOLD = 100;
98
+ const AXIS = {
99
+ horizontal: { val: "x", min: "minX", max: "maxX", dim: "width" },
100
+ vertical: { val: "y", min: "minY", max: "maxY", dim: "height" }
101
+ };
98
102
  class Editor extends import_eventemitter3.default {
99
103
  id = (0, import_utils.uniqueId)();
100
104
  constructor({
@@ -421,7 +425,7 @@ class Editor extends import_eventemitter3.default {
421
425
  }
422
426
  }
423
427
  if (deleteBindingIds.length) {
424
- this.deleteBindings(deleteBindingIds);
428
+ this.store.remove(deleteBindingIds);
425
429
  }
426
430
  }
427
431
  },
@@ -1381,6 +1385,7 @@ class Editor extends import_eventemitter3.default {
1381
1385
  * @public
1382
1386
  **/
1383
1387
  updateDocumentSettings(settings) {
1388
+ if (this.getIsReadonly()) return this;
1384
1389
  this.run(
1385
1390
  () => {
1386
1391
  this.store.put([{ ...this.getDocumentSettings(), ...settings }]);
@@ -1540,7 +1545,7 @@ class Editor extends import_eventemitter3.default {
1540
1545
  * @public
1541
1546
  */
1542
1547
  select(...shapes) {
1543
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id);
1548
+ const ids = toShapeIds(shapes);
1544
1549
  this.setSelectedShapes(ids);
1545
1550
  return this;
1546
1551
  }
@@ -1555,7 +1560,7 @@ class Editor extends import_eventemitter3.default {
1555
1560
  * @public
1556
1561
  */
1557
1562
  deselect(...shapes) {
1558
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id);
1563
+ const ids = toShapeIds(shapes);
1559
1564
  const selectedShapeIds = this.getSelectedShapeIds();
1560
1565
  if (selectedShapeIds.length > 0 && ids.length > 0) {
1561
1566
  this.setSelectedShapes(selectedShapeIds.filter((id) => !ids.includes(id)));
@@ -1593,7 +1598,7 @@ class Editor extends import_eventemitter3.default {
1593
1598
  }
1594
1599
  const ids = this.getSortedChildIdsForParent(parentToSelectWithinId);
1595
1600
  if (ids.length <= 0) return this;
1596
- this.setSelectedShapes(this._getUnlockedShapeIds(ids));
1601
+ this.setSelectedShapes(ids.filter((id) => !this.getShape(id)?.isLocked));
1597
1602
  return this;
1598
1603
  }
1599
1604
  /**
@@ -1720,13 +1725,14 @@ class Editor extends import_eventemitter3.default {
1720
1725
  });
1721
1726
  if (shapesInDirection.length === 0) return currentShapeId;
1722
1727
  const lowestScoringShape = (0, import_utils.minBy)(shapesInDirection, ({ center }) => {
1723
- const distance = import_Vec.Vec.Dist2(currentCenter, center);
1728
+ const distance = import_Vec.Vec.Dist(currentCenter, center);
1724
1729
  const dirProp = ["left", "right"].includes(direction) ? "x" : "y";
1725
1730
  const directionalDistance = Math.abs(center[dirProp] - currentCenter[dirProp]);
1726
1731
  const offProp = ["left", "right"].includes(direction) ? "y" : "x";
1727
1732
  const offAxisDeviation = Math.abs(center[offProp] - currentCenter[offProp]);
1728
- const angle = Math.abs(import_Vec.Vec.Angle(currentCenter, center) * (180 / Math.PI));
1729
- const angleDeviation = Math.abs(angle - directionToAngle[direction]);
1733
+ const angle = (import_Vec.Vec.Angle(currentCenter, center) * (180 / Math.PI) + 360) % 360;
1734
+ const rawAngleDeviation = Math.abs(angle - directionToAngle[direction]);
1735
+ const angleDeviation = Math.min(rawAngleDeviation, 360 - rawAngleDeviation);
1730
1736
  return distance * 1 + // Base distance
1731
1737
  offAxisDeviation * 2 + // Heavy penalty for off-axis deviation
1732
1738
  (distance - directionalDistance) * 1.5 + // Penalty for diagonal distance
@@ -2064,7 +2070,7 @@ class Editor extends import_eventemitter3.default {
2064
2070
  * @public
2065
2071
  */
2066
2072
  setHintingShapes(shapes) {
2067
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id);
2073
+ const ids = toShapeIds(shapes);
2068
2074
  this.run(
2069
2075
  () => {
2070
2076
  this._updateCurrentPageState({ hintingShapeIds: (0, import_utils.dedupe)(ids) });
@@ -2094,7 +2100,7 @@ class Editor extends import_eventemitter3.default {
2094
2100
  * @public
2095
2101
  */
2096
2102
  setErasingShapes(shapes) {
2097
- const ids = typeof shapes[0] === "string" ? shapes.slice() : shapes.map((shape) => shape.id);
2103
+ const ids = toShapeIds(shapes).slice();
2098
2104
  ids.sort();
2099
2105
  const erasingShapeIds = this.getErasingShapeIds();
2100
2106
  this.run(
@@ -2501,7 +2507,7 @@ class Editor extends import_eventemitter3.default {
2501
2507
  setCamera(point, opts) {
2502
2508
  const { isLocked } = this._cameraOptions.__unsafe__getWithoutCapture();
2503
2509
  if (isLocked && !opts?.force) return this;
2504
- const _point = import_Vec.Vec.Cast(point);
2510
+ const _point = new import_Vec.Vec(point.x, point.y, point.z ?? this.getZoomLevel());
2505
2511
  if (!Number.isFinite(_point.x) || !Number.isFinite(_point.y) || !Number.isFinite(_point.z)) {
2506
2512
  throw Error(
2507
2513
  `Editor.setCamera: expected finite values, got (${_point.x}, ${_point.y}, ${_point.z}).`
@@ -2795,11 +2801,14 @@ class Editor extends import_eventemitter3.default {
2795
2801
  _animateViewport(ms) {
2796
2802
  if (!this._viewportAnimation) return;
2797
2803
  this._viewportAnimation.elapsed += ms;
2798
- const { elapsed, easing, duration, start, end } = this._viewportAnimation;
2804
+ const { elapsed, easing, duration, start, end, opts } = this._viewportAnimation;
2799
2805
  if (elapsed > duration) {
2800
2806
  this.off("tick", this._animateViewport);
2801
2807
  this._viewportAnimation = null;
2802
- this._setCamera(new import_Vec.Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width));
2808
+ this._setCamera(
2809
+ new import_Vec.Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width),
2810
+ opts
2811
+ );
2803
2812
  return;
2804
2813
  }
2805
2814
  const remaining = duration - elapsed;
@@ -2837,7 +2846,8 @@ class Editor extends import_eventemitter3.default {
2837
2846
  duration: duration / animationSpeed,
2838
2847
  easing,
2839
2848
  start: viewportPageBounds.clone(),
2840
- end: targetViewportPage.clone()
2849
+ end: targetViewportPage.clone(),
2850
+ opts: rest
2841
2851
  };
2842
2852
  this.once("stop-camera-animation", () => {
2843
2853
  this.off("tick", this._animateViewport);
@@ -3755,7 +3765,9 @@ class Editor extends import_eventemitter3.default {
3755
3765
  if (ids.length <= 0) return this;
3756
3766
  this.run(
3757
3767
  () => {
3758
- this.store.props.assets.remove?.(ids);
3768
+ Promise.resolve(this.store.props.assets.remove?.(ids)).catch(
3769
+ (err) => console.error("Error while removing assets from the asset store:", err)
3770
+ );
3759
3771
  this.store.remove(ids);
3760
3772
  },
3761
3773
  { history: "ignore" }
@@ -4137,7 +4149,7 @@ class Editor extends import_eventemitter3.default {
4137
4149
  if (shapes.length === 0) {
4138
4150
  return;
4139
4151
  }
4140
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
4152
+ const ids = toShapeIds(shapes);
4141
4153
  const freshShapes = (0, import_utils.compact)(ids.map((id) => this.getShape(id)));
4142
4154
  if (freshShapes.length === 1) {
4143
4155
  const parentId = freshShapes[0].parentId;
@@ -4234,12 +4246,14 @@ class Editor extends import_eventemitter3.default {
4234
4246
  */
4235
4247
  getSelectedShapeAtPoint(point) {
4236
4248
  const selectedShapeIds = this.getSelectedShapeIds();
4237
- const margin = this.options.hitTestMargin / this.getZoomLevel();
4249
+ if (selectedShapeIds.length === 0) return void 0;
4250
+ const selectedShapeIdSet = new Set(selectedShapeIds);
4251
+ const margin = this.getHitTestMargin();
4238
4252
  const sortedShapes = this.getCurrentPageShapesSorted();
4239
4253
  for (let i = sortedShapes.length - 1; i >= 0; i--) {
4240
4254
  const shape = sortedShapes[i];
4241
4255
  if (shape.type === "group") continue;
4242
- if (!selectedShapeIds.includes(shape.id)) continue;
4256
+ if (!selectedShapeIdSet.has(shape.id)) continue;
4243
4257
  if (this.getShapeGeometry(shape).hitTestPoint(
4244
4258
  this.getPointInShapeSpace(shape, point),
4245
4259
  margin,
@@ -4337,7 +4351,6 @@ class Editor extends import_eventemitter3.default {
4337
4351
  }
4338
4352
  return inMarginClosestToEdgeHit || shape;
4339
4353
  } else {
4340
- if (this.getShapePageBounds(shape).contains(viewportPageBounds)) continue;
4341
4354
  if (hitInside ? (
4342
4355
  // On hitInside, the distance will be negative for hits inside
4343
4356
  // If the distance is positive, check against the outer margin
@@ -4354,6 +4367,7 @@ class Editor extends import_eventemitter3.default {
4354
4367
  inMarginClosestToEdgeHit = shape;
4355
4368
  }
4356
4369
  } else if (!inMarginClosestToEdgeHit) {
4370
+ if (this.getShapePageBounds(shape).contains(viewportPageBounds)) continue;
4357
4371
  const { area } = geometry;
4358
4372
  if (area < inHollowSmallestArea) {
4359
4373
  inHollowSmallestArea = area;
@@ -4364,6 +4378,9 @@ class Editor extends import_eventemitter3.default {
4364
4378
  }
4365
4379
  } else {
4366
4380
  if (distance < this.getHitTestMargin()) {
4381
+ if (inMarginClosestToEdgeHit && inMarginClosestToEdgeDistance <= distance) {
4382
+ return inMarginClosestToEdgeHit;
4383
+ }
4367
4384
  return shape;
4368
4385
  }
4369
4386
  }
@@ -4640,7 +4657,7 @@ class Editor extends import_eventemitter3.default {
4640
4657
  * @public
4641
4658
  */
4642
4659
  reparentShapes(shapes, parentId, insertIndex) {
4643
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
4660
+ const ids = toShapeIds(shapes);
4644
4661
  if (ids.length === 0) return this;
4645
4662
  const changes = [];
4646
4663
  const parentTransform = (0, import_tlschema.isPageId)(parentId) ? import_Mat.Mat.Identity() : this.getShapePageTransform(parentId);
@@ -4869,6 +4886,7 @@ class Editor extends import_eventemitter3.default {
4869
4886
  * binding, but the `type`, `toId`, and `fromId` must all be provided.
4870
4887
  */
4871
4888
  createBindings(partials) {
4889
+ if (this.getIsReadonly()) return this;
4872
4890
  const bindings = [];
4873
4891
  for (const partial of partials) {
4874
4892
  const fromShape = this.getShape(partial.fromId);
@@ -4903,6 +4921,7 @@ class Editor extends import_eventemitter3.default {
4903
4921
  * binding is skipped. The changes from the partial are merged into the existing record.
4904
4922
  */
4905
4923
  updateBindings(partials) {
4924
+ if (this.getIsReadonly()) return this;
4906
4925
  const updated = [];
4907
4926
  for (const partial of partials) {
4908
4927
  if (!partial) continue;
@@ -4931,6 +4950,16 @@ class Editor extends import_eventemitter3.default {
4931
4950
  * Delete several bindings by their IDs. If a binding ID doesn't exist, it's ignored.
4932
4951
  */
4933
4952
  deleteBindings(bindings, { isolateShapes = false } = {}) {
4953
+ if (this.getIsReadonly()) return this;
4954
+ return this._deleteBindings(bindings, { isolateShapes });
4955
+ }
4956
+ /**
4957
+ * Unguarded so that withIsolatedShapes can transiently isolate shapes for copy and export in
4958
+ * readonly mode; the public deleteBindings is what readonly blocks.
4959
+ *
4960
+ * @internal
4961
+ */
4962
+ _deleteBindings(bindings, { isolateShapes = false } = {}) {
4934
4963
  const ids = bindings.map((binding) => typeof binding === "string" ? binding : binding.id);
4935
4964
  if (isolateShapes) {
4936
4965
  this.store.atomic(() => {
@@ -4989,7 +5018,7 @@ class Editor extends import_eventemitter3.default {
4989
5018
  * @param opts - The options for the rotation.
4990
5019
  */
4991
5020
  rotateShapesBy(shapes, delta, opts) {
4992
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5021
+ const ids = toShapeIds(shapes);
4993
5022
  if (ids.length <= 0) return this;
4994
5023
  const snapshot = (0, import_rotation.getRotationSnapshot)({ editor: this, ids });
4995
5024
  if (!snapshot) return this;
@@ -5026,6 +5055,14 @@ class Editor extends import_eventemitter3.default {
5026
5055
  }
5027
5056
  return workingShape;
5028
5057
  }
5058
+ // Counter-rotates the page-space delta into the parent's space; without that a child of a rotated
5059
+ // frame or group would move along its parent's axes instead of the page's.
5060
+ // todo: a shape laid out together with its own parent moves twice, once with the parent and once
5061
+ // on its own; the layout commands should skip shapes whose ancestors are also being laid out
5062
+ getChangesToTranslateShapeByPageDelta(shape, pageDelta) {
5063
+ const localDelta = import_Vec.Vec.From(pageDelta).rot(-this.getShapeParentTransform(shape).rotation());
5064
+ return this.getChangesToTranslateShape(shape, localDelta.add(shape));
5065
+ }
5029
5066
  /**
5030
5067
  * Move shapes by a delta.
5031
5068
  *
@@ -5038,14 +5075,12 @@ class Editor extends import_eventemitter3.default {
5038
5075
  * @param offset - The offset to apply to the shapes.
5039
5076
  */
5040
5077
  nudgeShapes(shapes, offset) {
5041
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5078
+ const ids = toShapeIds(shapes);
5042
5079
  if (ids.length <= 0) return this;
5043
5080
  const changes = [];
5044
5081
  for (const id of ids) {
5045
5082
  const shape = this.getShape(id);
5046
- const localDelta = import_Vec.Vec.From(offset);
5047
- localDelta.rot(-this.getShapeParentTransform(shape).rotation());
5048
- changes.push(this.getChangesToTranslateShape(shape, localDelta.add(shape)));
5083
+ changes.push(this.getChangesToTranslateShapeByPageDelta(shape, offset));
5049
5084
  }
5050
5085
  this.updateShapes(changes);
5051
5086
  return this;
@@ -5066,7 +5101,7 @@ class Editor extends import_eventemitter3.default {
5066
5101
  */
5067
5102
  duplicateShapes(shapes, offset) {
5068
5103
  this.run(() => {
5069
- const _ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5104
+ const _ids = toShapeIds(shapes);
5070
5105
  const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
5071
5106
  if (ids.length <= 0) return this;
5072
5107
  const initialIds = new Set(ids);
@@ -5175,7 +5210,7 @@ class Editor extends import_eventemitter3.default {
5175
5210
  * @public
5176
5211
  */
5177
5212
  moveShapesToPage(shapes, pageId) {
5178
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5213
+ const ids = toShapeIds(shapes);
5179
5214
  if (ids.length === 0) return this;
5180
5215
  if (this.getIsReadonly()) return this;
5181
5216
  const currentPageId = this.getCurrentPageId();
@@ -5211,7 +5246,7 @@ class Editor extends import_eventemitter3.default {
5211
5246
  * @public
5212
5247
  */
5213
5248
  toggleLock(shapes) {
5214
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5249
+ const ids = toShapeIds(shapes);
5215
5250
  if (this.getIsReadonly() || ids.length === 0) return this;
5216
5251
  let allLocked = true;
5217
5252
  const shapesToToggle = [];
@@ -5250,7 +5285,7 @@ class Editor extends import_eventemitter3.default {
5250
5285
  * @public
5251
5286
  */
5252
5287
  sendToBack(shapes) {
5253
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5288
+ const ids = toShapeIds(shapes);
5254
5289
  const changes = (0, import_reorderShapes.getReorderingShapesChanges)(this, "toBack", ids, {
5255
5290
  considerAllShapes: true
5256
5291
  });
@@ -5280,7 +5315,7 @@ class Editor extends import_eventemitter3.default {
5280
5315
  * @public
5281
5316
  */
5282
5317
  sendBackward(shapes, opts = {}) {
5283
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5318
+ const ids = toShapeIds(shapes);
5284
5319
  const changes = (0, import_reorderShapes.getReorderingShapesChanges)(this, "backward", ids, opts);
5285
5320
  if (changes) this.updateShapes(changes);
5286
5321
  return this;
@@ -5308,7 +5343,7 @@ class Editor extends import_eventemitter3.default {
5308
5343
  * @public
5309
5344
  */
5310
5345
  bringForward(shapes, opts = {}) {
5311
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5346
+ const ids = toShapeIds(shapes);
5312
5347
  const changes = (0, import_reorderShapes.getReorderingShapesChanges)(this, "forward", ids, opts);
5313
5348
  if (changes) this.updateShapes(changes);
5314
5349
  return this;
@@ -5327,7 +5362,7 @@ class Editor extends import_eventemitter3.default {
5327
5362
  * @public
5328
5363
  */
5329
5364
  bringToFront(shapes) {
5330
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5365
+ const ids = toShapeIds(shapes);
5331
5366
  const changes = (0, import_reorderShapes.getReorderingShapesChanges)(this, "toFront", ids);
5332
5367
  if (changes) this.updateShapes(changes);
5333
5368
  return this;
@@ -5339,7 +5374,7 @@ class Editor extends import_eventemitter3.default {
5339
5374
  * @internal
5340
5375
  */
5341
5376
  getShapeClusters(shapes, type, opts) {
5342
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5377
+ const ids = toShapeIds(shapes);
5343
5378
  let freshShapes = (0, import_utils.compact)(ids.map((id) => this.getShape(id)));
5344
5379
  if (opts?.filterAxisAligned) {
5345
5380
  freshShapes = freshShapes.filter((s) => {
@@ -5420,7 +5455,7 @@ class Editor extends import_eventemitter3.default {
5420
5455
  */
5421
5456
  flipShapes(shapes, operation) {
5422
5457
  if (this.getIsReadonly()) return this;
5423
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5458
+ const ids = toShapeIds(shapes);
5424
5459
  const shapesToFlipFirstPass = (0, import_utils.compact)(ids.map((id) => this.getShape(id)));
5425
5460
  for (const shape of shapesToFlipFirstPass) {
5426
5461
  if (this.isShapeOfType(shape, "group")) {
@@ -5494,21 +5529,7 @@ class Editor extends import_eventemitter3.default {
5494
5529
  const { clusters: shapeClustersToStack } = this.getShapeClusters(shapes, "stack");
5495
5530
  const len = shapeClustersToStack.length;
5496
5531
  if (_gap === 0 && len < 3 || len < 2) return this;
5497
- let val;
5498
- let min;
5499
- let max;
5500
- let dim;
5501
- if (operation === "horizontal") {
5502
- val = "x";
5503
- min = "minX";
5504
- max = "maxX";
5505
- dim = "width";
5506
- } else {
5507
- val = "y";
5508
- min = "minY";
5509
- max = "maxY";
5510
- dim = "height";
5511
- }
5532
+ const { val, min, max, dim } = AXIS[operation];
5512
5533
  let shapeGap = 0;
5513
5534
  shapeClustersToStack.sort((a, b) => a.pageBounds[min] - b.pageBounds[min]);
5514
5535
  if (_gap === 0) {
@@ -5547,13 +5568,7 @@ class Editor extends import_eventemitter3.default {
5547
5568
  const delta = new import_Vec.Vec();
5548
5569
  delta[val] = v + shapeGap - pageBounds[val];
5549
5570
  for (const shape of shapes2) {
5550
- const shapeDelta = delta.clone();
5551
- const parent = this.getShapeParent(shape);
5552
- if (parent) {
5553
- shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
5554
- }
5555
- shapeDelta.add(shape);
5556
- changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
5571
+ changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
5557
5572
  }
5558
5573
  v += pageBounds[dim] + shapeGap;
5559
5574
  }
@@ -5633,13 +5648,7 @@ class Editor extends import_eventemitter3.default {
5633
5648
  for (const { shapes: shapes2, pageBounds, nextPageBounds } of shapeClustersToPack) {
5634
5649
  const delta = import_Vec.Vec.Sub(nextPageBounds.point, pageBounds.point).add(centerDelta);
5635
5650
  for (const shape of shapes2) {
5636
- const shapeDelta = delta.clone();
5637
- const parent = this.getShapeParent(shape);
5638
- if (parent) {
5639
- shapeDelta.rot(-this.getShapeParentTransform(shape).rotation());
5640
- }
5641
- shapeDelta.add(shape);
5642
- changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
5651
+ changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
5643
5652
  }
5644
5653
  }
5645
5654
  if (changes.length) {
@@ -5699,13 +5708,7 @@ class Editor extends import_eventemitter3.default {
5699
5708
  }
5700
5709
  }
5701
5710
  for (const shape of shapes2) {
5702
- const shapeDelta = delta.clone();
5703
- const parent = this.getShapeParent(shape);
5704
- if (parent) {
5705
- shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
5706
- }
5707
- shapeDelta.add(shape);
5708
- changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
5711
+ changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
5709
5712
  }
5710
5713
  });
5711
5714
  this.updateShapes(changes);
@@ -5729,27 +5732,13 @@ class Editor extends import_eventemitter3.default {
5729
5732
  if (this.getIsReadonly()) return this;
5730
5733
  const { clusters: shapeClustersToDistribute } = this.getShapeClusters(shapes, "distribute");
5731
5734
  if (shapeClustersToDistribute.length < 3) return this;
5732
- let val;
5733
- let min;
5734
- let max;
5735
- let dim;
5736
- if (operation === "horizontal") {
5737
- val = "x";
5738
- min = "minX";
5739
- max = "maxX";
5740
- dim = "width";
5741
- } else {
5742
- val = "y";
5743
- min = "minY";
5744
- max = "maxY";
5745
- dim = "height";
5746
- }
5735
+ const { val, min, max, dim } = AXIS[operation];
5747
5736
  const changes = [];
5748
5737
  const first = shapeClustersToDistribute.sort((a, b) => a.pageBounds[min] - b.pageBounds[min])[0];
5749
5738
  const last2 = shapeClustersToDistribute.sort((a, b) => b.pageBounds[max] - a.pageBounds[max])[0];
5750
5739
  if (first === last2) {
5751
5740
  const excludedShapeIds = new Set(first.shapes.map((s) => s.id));
5752
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5741
+ const ids = toShapeIds(shapes);
5753
5742
  return this.distributeShapes(
5754
5743
  ids.filter((id) => !excludedShapeIds.has(id)),
5755
5744
  operation
@@ -5773,13 +5762,7 @@ class Editor extends import_eventemitter3.default {
5773
5762
  delta[val] = last2.pageBounds[max] - pageBounds[max] - 1;
5774
5763
  }
5775
5764
  for (const shape of shapes2) {
5776
- const shapeDelta = delta.clone();
5777
- const parent = this.getShapeParent(shape);
5778
- if (parent) {
5779
- shapeDelta.rot(-this.getShapePageTransform(parent).rotation());
5780
- }
5781
- shapeDelta.add(shape);
5782
- changes.push(this.getChangesToTranslateShape(shape, shapeDelta));
5765
+ changes.push(this.getChangesToTranslateShapeByPageDelta(shape, delta));
5783
5766
  }
5784
5767
  v += pageBounds[dim] + gap;
5785
5768
  }
@@ -5809,32 +5792,17 @@ class Editor extends import_eventemitter3.default {
5809
5792
  );
5810
5793
  if (shapeClustersToStretch.length < 2) return this;
5811
5794
  const commonBounds = import_Box.Box.Common(allBounds);
5812
- let val;
5813
- let min;
5814
- let dim;
5815
- if (operation === "horizontal") {
5816
- val = "x";
5817
- min = "minX";
5818
- dim = "width";
5819
- } else {
5820
- val = "y";
5821
- min = "minY";
5822
- dim = "height";
5823
- }
5795
+ const { val, min, dim } = AXIS[operation];
5824
5796
  this.run(() => {
5825
5797
  shapeClustersToStretch.forEach(({ shapes: shapes2, pageBounds }) => {
5826
- const localOffset = new import_Vec.Vec();
5827
- localOffset[val] = commonBounds[min] - pageBounds[min];
5798
+ const pageOffset = new import_Vec.Vec();
5799
+ pageOffset[val] = commonBounds[min] - pageBounds[min];
5828
5800
  const scaleOrigin = pageBounds.center.clone();
5829
5801
  scaleOrigin[val] = commonBounds[min];
5830
5802
  const scale = new import_Vec.Vec(1, 1);
5831
5803
  scale[val] = commonBounds[dim] / pageBounds[dim];
5832
5804
  for (const shape of shapes2) {
5833
- const shapeLocalOffset = localOffset.clone();
5834
- shapeLocalOffset.rot(-this.getShapeParentTransform(shape).rotation());
5835
- shapeLocalOffset.add(shape);
5836
- const changes = this.getChangesToTranslateShape(shape, shapeLocalOffset);
5837
- this.updateShape(changes);
5805
+ this.updateShape(this.getChangesToTranslateShapeByPageDelta(shape, pageOffset));
5838
5806
  this.resizeShape(shape.id, scale, {
5839
5807
  initialBounds: this.getShapeGeometry(shape).bounds,
5840
5808
  scaleOrigin,
@@ -5877,7 +5845,7 @@ class Editor extends import_eventemitter3.default {
5877
5845
  const scaleY = targetBounds.height / commonBounds.height;
5878
5846
  const scale = new import_Vec.Vec(scaleX, scaleY);
5879
5847
  shapeClusters.forEach(({ shapes: shapes2, pageBounds }) => {
5880
- const localOffset = new import_Vec.Vec(
5848
+ const pageOffset = new import_Vec.Vec(
5881
5849
  targetBounds.minX - commonBounds.minX + (pageBounds.minX - commonBounds.minX) * (scaleX - 1),
5882
5850
  targetBounds.minY - commonBounds.minY + (pageBounds.minY - commonBounds.minY) * (scaleY - 1)
5883
5851
  );
@@ -5886,11 +5854,7 @@ class Editor extends import_eventemitter3.default {
5886
5854
  targetBounds.minY + (pageBounds.minY - commonBounds.minY) * scaleY
5887
5855
  );
5888
5856
  for (const shape of shapes2) {
5889
- const shapeLocalOffset = localOffset.clone();
5890
- shapeLocalOffset.rot(-this.getShapeParentTransform(shape).rotation());
5891
- shapeLocalOffset.add(shape);
5892
- const changes = this.getChangesToTranslateShape(shape, shapeLocalOffset);
5893
- this.updateShape(changes);
5857
+ this.updateShape(this.getChangesToTranslateShapeByPageDelta(shape, pageOffset));
5894
5858
  this.resizeShape(shape.id, scale, {
5895
5859
  initialBounds: this.getShapeGeometry(shape).bounds,
5896
5860
  scaleOrigin,
@@ -6309,12 +6273,17 @@ class Editor extends import_eventemitter3.default {
6309
6273
  let remaining = duration;
6310
6274
  let t;
6311
6275
  const animations = [];
6276
+ const ignoreShapeLock = this._shouldIgnoreShapeLock;
6312
6277
  let partial, result;
6313
6278
  for (let i = 0, n = partials.length; i < n; i++) {
6314
6279
  partial = partials[i];
6315
6280
  if (!partial) continue;
6316
6281
  const shape = this.getShape(partial.id);
6317
6282
  if (!shape) continue;
6283
+ const unlocks = shape.isLocked && Object.hasOwn(partial, "isLocked") && !partial.isLocked;
6284
+ if (!ignoreShapeLock && !unlocks && this.isShapeOrAncestorLocked(shape)) {
6285
+ continue;
6286
+ }
6318
6287
  result = {
6319
6288
  start: (0, import_utils.structuredClone)(shape),
6320
6289
  end: applyPartialToRecordWithProps((0, import_utils.structuredClone)(shape), partial)
@@ -6330,7 +6299,7 @@ class Editor extends import_eventemitter3.default {
6330
6299
  (p) => p && animatingShapes2.get(p.id) === animationId
6331
6300
  );
6332
6301
  if (partialsToUpdate.length) {
6333
- this.updateShapes(partialsToUpdate);
6302
+ this.run(() => this.updateShapes(partialsToUpdate), { ignoreShapeLock });
6334
6303
  }
6335
6304
  this.off("tick", handleTick);
6336
6305
  return;
@@ -6363,13 +6332,13 @@ class Editor extends import_eventemitter3.default {
6363
6332
  throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");
6364
6333
  }
6365
6334
  if (this.getIsReadonly()) return this;
6366
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
6367
- if (ids.length <= 1) return this;
6335
+ const ids = toShapeIds(shapes);
6368
6336
  const shapesToGroup = (0, import_utils.compact)(
6369
6337
  (this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map(
6370
6338
  (id) => this.getShape(id)
6371
6339
  )
6372
6340
  );
6341
+ if (shapesToGroup.length <= 1) return this;
6373
6342
  const sortedShapeIds = shapesToGroup.sort(import_utils.sortByIndex).map((s) => s.id);
6374
6343
  const childBounds = (0, import_utils.compact)(shapesToGroup.map((shape) => this.getShapePageBounds(shape)));
6375
6344
  const pageBounds = import_Box.Box.Common(childBounds);
@@ -6378,8 +6347,11 @@ class Editor extends import_eventemitter3.default {
6378
6347
  }
6379
6348
  const { x, y } = pageBounds.point;
6380
6349
  const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId();
6381
- if (this.getCurrentToolId() !== "select") return this;
6382
- if (!this.isIn("select.idle")) {
6350
+ if (!this.canCreateShapes([groupId])) {
6351
+ alertMaxShapes(this);
6352
+ return this;
6353
+ }
6354
+ if (this.isIn("select") && !this.isIn("select.idle")) {
6383
6355
  this.cancel();
6384
6356
  }
6385
6357
  const shapesWithRootParent = shapesToGroup.filter((shape) => shape.parentId === parentId).sort(import_utils.sortByIndex);
@@ -6407,15 +6379,14 @@ class Editor extends import_eventemitter3.default {
6407
6379
  ungroupShapes(shapes, opts = {}) {
6408
6380
  if (this.getIsReadonly()) return this;
6409
6381
  const { select = true } = opts;
6410
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
6382
+ const ids = toShapeIds(shapes);
6411
6383
  const shapesToUngroup = (0, import_utils.compact)(
6412
6384
  (this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map(
6413
6385
  (id) => this.getShape(id)
6414
6386
  )
6415
6387
  );
6416
6388
  if (shapesToUngroup.length === 0) return this;
6417
- if (this.getCurrentToolId() !== "select") return this;
6418
- if (!this.isIn("select.idle")) {
6389
+ if (this.isIn("select") && !this.isIn("select.idle")) {
6419
6390
  this.cancel();
6420
6391
  }
6421
6392
  const idsToSelect = /* @__PURE__ */ new Set();
@@ -6429,16 +6400,16 @@ class Editor extends import_eventemitter3.default {
6429
6400
  });
6430
6401
  if (groups.length === 0) return this;
6431
6402
  this.run(() => {
6432
- let group;
6433
6403
  for (let i = 0, n = groups.length; i < n; i++) {
6434
- group = groups[i];
6404
+ const group = this.getShape(groups[i].id);
6405
+ if (!group) continue;
6435
6406
  const childIds = this.getSortedChildIdsForParent(group.id);
6436
6407
  for (let j = 0, n2 = childIds.length; j < n2; j++) {
6437
6408
  idsToSelect.add(childIds[j]);
6438
6409
  }
6439
6410
  this.reparentShapes(childIds, group.parentId, group.index);
6440
6411
  }
6441
- this.deleteShapes(groups.map((group2) => group2.id));
6412
+ this.deleteShapes(groups.map((group) => group.id));
6442
6413
  if (select) {
6443
6414
  this.select(...idsToSelect);
6444
6415
  }
@@ -6519,14 +6490,14 @@ class Editor extends import_eventemitter3.default {
6519
6490
  }
6520
6491
  /** @internal */
6521
6492
  _getUnlockedShapeIds(ids) {
6522
- return ids.filter((id) => !this.getShape(id)?.isLocked);
6493
+ return ids.filter((id) => !this.isShapeOrAncestorLocked(id));
6523
6494
  }
6524
6495
  deleteShapes(_ids) {
6525
6496
  if (this.getIsReadonly()) return this;
6526
6497
  if (!Array.isArray(_ids)) {
6527
6498
  throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");
6528
6499
  }
6529
- const shapeIds = typeof _ids[0] === "string" ? _ids : _ids.map((s) => s.id);
6500
+ const shapeIds = toShapeIds(_ids);
6530
6501
  const shapeIdsToDelete = this._shouldIgnoreShapeLock ? shapeIds : this._getUnlockedShapeIds(shapeIds);
6531
6502
  if (shapeIdsToDelete.length === 0) return this;
6532
6503
  const allShapeIdsToDelete = new Set(shapeIdsToDelete);
@@ -6871,7 +6842,7 @@ class Editor extends import_eventemitter3.default {
6871
6842
  * @public
6872
6843
  */
6873
6844
  getContentFromCurrentPage(shapes) {
6874
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
6845
+ const ids = toShapeIds(shapes);
6875
6846
  if (!ids) return;
6876
6847
  if (ids.length === 0) return;
6877
6848
  const shapeIds = this.getShapeAndDescendantIds(ids);
@@ -6939,21 +6910,29 @@ class Editor extends import_eventemitter3.default {
6939
6910
  await Promise.allSettled(
6940
6911
  content.assets.map(async (asset) => {
6941
6912
  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);
6913
+ try {
6914
+ const objectUrl = await this.store.props.assets.resolve(asset, {
6915
+ screenScale: 1,
6916
+ steppedScreenScale: 1,
6917
+ dpr: 1,
6918
+ networkEffectiveType: null,
6919
+ shouldResolveToOriginal: true
6920
+ });
6921
+ if (objectUrl) {
6922
+ const response = await (0, import_utils.fetch)(objectUrl);
6923
+ if (response.ok) {
6924
+ const assetWithDataUrl = (0, import_utils.structuredClone)(asset);
6925
+ assetWithDataUrl.props.src = await import_utils.FileHelpers.blobToDataUrl(await response.blob());
6926
+ assets.push(assetWithDataUrl);
6927
+ return;
6928
+ }
6929
+ console.warn(`Could not inline asset ${asset.id}: fetch returned ${response.status}`);
6930
+ }
6931
+ } catch (err) {
6932
+ console.warn(`Could not inline asset ${asset.id}`, err);
6933
+ }
6956
6934
  }
6935
+ assets.push(asset);
6957
6936
  })
6958
6937
  );
6959
6938
  content.assets = assets;
@@ -7247,7 +7226,7 @@ class Editor extends import_eventemitter3.default {
7247
7226
  * @public
7248
7227
  */
7249
7228
  async getSvgElement(shapes, opts = {}) {
7250
- const ids = shapes.length === 0 ? this.getCurrentPageShapeIdsSorted() : typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
7229
+ const ids = shapes.length === 0 ? this.getCurrentPageShapeIdsSorted() : toShapeIds(shapes);
7251
7230
  if (ids.length === 0) return void 0;
7252
7231
  await this.fonts.loadRequiredFontsForCurrentPage(this.options.maxFontsToLoadBeforeRender);
7253
7232
  return (0, import_exportToSvg.exportToSvg)(this, ids, opts);
@@ -8165,6 +8144,7 @@ class Editor extends import_eventemitter3.default {
8165
8144
  inputs.buttons.add(info.button);
8166
8145
  inputs.setIsPointing(true);
8167
8146
  inputs.setIsDragging(false);
8147
+ this.stopCameraAnimation();
8168
8148
  if (!isPenMode && info.isPenDirect) {
8169
8149
  this.updateInstanceState({ isPenMode: true });
8170
8150
  this.interrupt();
@@ -8672,6 +8652,9 @@ function pushShapeWithDescendants(editor, id, result) {
8672
8652
  pushShapeWithDescendants(editor, childIds[i], result);
8673
8653
  }
8674
8654
  }
8655
+ function toShapeIds(shapes) {
8656
+ return typeof shapes[0] === "string" ? shapes : shapes.map((shape) => shape.id);
8657
+ }
8675
8658
  function withIsolatedShapes(editor, shapeIds, callback) {
8676
8659
  let result;
8677
8660
  editor.run(
@@ -8694,7 +8677,7 @@ function withIsolatedShapes(editor, shapeIds, callback) {
8694
8677
  }
8695
8678
  }
8696
8679
  }
8697
- editor.deleteBindings([...bindingsToRemove], { isolateShapes: true });
8680
+ editor._deleteBindings([...bindingsToRemove], { isolateShapes: true });
8698
8681
  try {
8699
8682
  result = import_utils.Result.ok(callback(bindingsWithBoth));
8700
8683
  } catch (error) {