@tldraw/editor 3.14.0-canary.33ea232f2305 → 3.14.0-canary.3b2250d26732

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 (68) hide show
  1. package/dist-cjs/index.d.ts +114 -15
  2. package/dist-cjs/index.js +4 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/editor/Editor.js +76 -28
  5. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  6. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +3 -1
  7. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
  8. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +3 -2
  9. package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
  10. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +0 -10
  11. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +13 -6
  13. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +3 -3
  14. package/dist-cjs/lib/editor/tools/StateNode.js +3 -3
  15. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  16. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  17. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  18. package/dist-cjs/lib/primitives/geometry/Geometry2d.js +6 -2
  19. package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
  20. package/dist-cjs/lib/primitives/geometry/Group2d.js +11 -6
  21. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  22. package/dist-cjs/lib/utils/dom.js +1 -1
  23. package/dist-cjs/lib/utils/dom.js.map +2 -2
  24. package/dist-cjs/lib/utils/reparenting.js +232 -0
  25. package/dist-cjs/lib/utils/reparenting.js.map +7 -0
  26. package/dist-cjs/version.js +3 -3
  27. package/dist-cjs/version.js.map +1 -1
  28. package/dist-esm/index.d.mts +114 -15
  29. package/dist-esm/index.mjs +4 -1
  30. package/dist-esm/index.mjs.map +2 -2
  31. package/dist-esm/lib/editor/Editor.mjs +76 -28
  32. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  33. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +3 -1
  34. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
  35. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +3 -2
  36. package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
  37. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +0 -10
  38. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  39. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +13 -6
  40. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +3 -3
  41. package/dist-esm/lib/editor/tools/StateNode.mjs +3 -3
  42. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  43. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +6 -2
  44. package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
  45. package/dist-esm/lib/primitives/geometry/Group2d.mjs +11 -6
  46. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  47. package/dist-esm/lib/utils/dom.mjs +1 -1
  48. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  49. package/dist-esm/lib/utils/reparenting.mjs +216 -0
  50. package/dist-esm/lib/utils/reparenting.mjs.map +7 -0
  51. package/dist-esm/version.mjs +3 -3
  52. package/dist-esm/version.mjs.map +1 -1
  53. package/editor.css +17 -11
  54. package/package.json +7 -7
  55. package/src/index.ts +6 -0
  56. package/src/lib/editor/Editor.ts +88 -37
  57. package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +3 -1
  58. package/src/lib/editor/managers/TextManager/TextManager.ts +4 -2
  59. package/src/lib/editor/shapes/ShapeUtil.ts +47 -15
  60. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +25 -17
  61. package/src/lib/editor/tools/StateNode.ts +3 -3
  62. package/src/lib/editor/types/emit-types.ts +4 -0
  63. package/src/lib/editor/types/external-content.ts +10 -1
  64. package/src/lib/primitives/geometry/Geometry2d.ts +7 -2
  65. package/src/lib/primitives/geometry/Group2d.ts +11 -5
  66. package/src/lib/utils/dom.ts +1 -1
  67. package/src/lib/utils/reparenting.ts +383 -0
  68. package/src/version.ts +3 -3
@@ -46,7 +46,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
46
46
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
47
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
48
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
49
- var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionScreenBounds_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
49
+ var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, _getNotVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getCurrentPageShapesInReadingOrder_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
50
50
  import {
51
51
  EMPTY_ARRAY,
52
52
  atom,
@@ -158,7 +158,7 @@ import { TextManager } from "./managers/TextManager/TextManager.mjs";
158
158
  import { TickManager } from "./managers/TickManager/TickManager.mjs";
159
159
  import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
160
160
  import { RootState } from "./tools/RootState.mjs";
161
- class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionScreenBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
161
+ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getCurrentPageShapesInReadingOrder_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], _getNotVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
162
162
  constructor({
163
163
  store,
164
164
  user,
@@ -357,6 +357,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
357
357
  __publicField(this, "externalContentHandlers", {
358
358
  text: null,
359
359
  files: null,
360
+ "file-replace": null,
360
361
  embed: null,
361
362
  "svg-text": null,
362
363
  url: null,
@@ -1675,6 +1676,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1675
1676
  getSelectionPageBounds() {
1676
1677
  return this.getShapesPageBounds(this.getSelectedShapeIds());
1677
1678
  }
1679
+ /**
1680
+ * The bounds of the selection bounding box in the current page space.
1681
+ *
1682
+ * @readonly
1683
+ * @public
1684
+ */
1678
1685
  getSelectionScreenBounds() {
1679
1686
  const bounds = this.getSelectionPageBounds();
1680
1687
  if (!bounds) return void 0;
@@ -2815,7 +2822,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2815
2822
  * @public
2816
2823
  */
2817
2824
  updateViewportScreenBounds(screenBounds, center = false) {
2818
- if (screenBounds instanceof HTMLElement) {
2825
+ if (!(screenBounds instanceof Box)) {
2819
2826
  const rect = screenBounds.getBoundingClientRect();
2820
2827
  screenBounds = new Box(
2821
2828
  rect.left || rect.x,
@@ -4158,7 +4165,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4158
4165
  if (!id) return void 0;
4159
4166
  const freshShape = this.getShape(id);
4160
4167
  if (freshShape === void 0 || !isShapeId(freshShape.parentId)) return void 0;
4161
- return this.store.get(freshShape.parentId);
4168
+ return this.getShape(freshShape.parentId);
4162
4169
  }
4163
4170
  /**
4164
4171
  * If siblingShape and targetShape are siblings, this returns targetShape. If targetShape has an
@@ -4290,6 +4297,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4290
4297
  if (!pagePoint) continue;
4291
4298
  const newPoint = invertedParentTransform.applyToPoint(pagePoint);
4292
4299
  const newRotation = pageTransform.rotation() - parentPageRotation;
4300
+ if (shape.id === parentId) {
4301
+ throw Error("Attempted to reparent a shape to itself!");
4302
+ }
4293
4303
  changes.push({
4294
4304
  id: shape.id,
4295
4305
  type: shape.type,
@@ -4382,6 +4392,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4382
4392
  }
4383
4393
  return shapeIds;
4384
4394
  }
4395
+ /** @deprecated Use {@link Editor.getDraggingOverShape} instead */
4396
+ getDroppingOverShape(point, droppingShapes) {
4397
+ return this.getDraggingOverShape(point, droppingShapes);
4398
+ }
4385
4399
  /**
4386
4400
  * Get the shape that some shapes should be dropped on at a given point.
4387
4401
  *
@@ -4392,22 +4406,20 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4392
4406
  *
4393
4407
  * @public
4394
4408
  */
4395
- getDroppingOverShape(point, droppingShapes = []) {
4396
- const currentPageShapesSorted = this.getCurrentPageShapesSorted();
4397
- for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
4398
- const shape = currentPageShapesSorted[i];
4399
- if (
4400
- // ignore hidden shapes
4401
- this.isShapeHidden(shape) || // don't allow dropping on selected shapes
4402
- this.getSelectedShapeIds().includes(shape.id) || // only allow shapes that can receive children
4403
- !this.getShapeUtil(shape).canDropShapes(shape, droppingShapes) || // don't allow dropping a shape on itself or one of it's children
4404
- droppingShapes.find((s) => s.id === shape.id || this.hasAncestor(shape, s.id))
4405
- ) {
4406
- continue;
4407
- }
4408
- const maskedPageBounds = this.getShapeMaskedPageBounds(shape.id);
4409
- if (maskedPageBounds && maskedPageBounds.containsPoint(point) && this.getShapeGeometry(shape).hitTestPoint(this.getPointInShapeSpace(shape, point), 0, true)) {
4410
- return shape;
4409
+ getDraggingOverShape(point, droppingShapes) {
4410
+ const draggingShapes = compact(droppingShapes.map((s) => this.getShape(s))).filter(
4411
+ (s) => !s.isLocked && !this.isShapeHidden(s)
4412
+ );
4413
+ const maybeDraggingOverShapes = this.getShapesAtPoint(point, {
4414
+ hitInside: true,
4415
+ margin: 0
4416
+ }).filter(
4417
+ (s) => !droppingShapes.includes(s) && !s.isLocked && !this.isShapeHidden(s) && !draggingShapes.includes(s)
4418
+ );
4419
+ for (const maybeDraggingOverShape of maybeDraggingOverShapes) {
4420
+ const shapeUtil = this.getShapeUtil(maybeDraggingOverShape);
4421
+ if (shapeUtil.onDragShapesOver || shapeUtil.onDragShapesIn || shapeUtil.onDragShapesOut || shapeUtil.onDropShapesOver) {
4422
+ return maybeDraggingOverShape;
4411
4423
  }
4412
4424
  }
4413
4425
  }
@@ -4684,7 +4696,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4684
4696
  */
4685
4697
  duplicateShapes(shapes, offset) {
4686
4698
  this.run(() => {
4687
- const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
4699
+ const _ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
4700
+ const ids = this._shouldIgnoreShapeLock ? _ids : this._getUnlockedShapeIds(_ids);
4688
4701
  if (ids.length <= 0) return this;
4689
4702
  const initialIds = new Set(ids);
4690
4703
  const shapeIdSet = this.getShapeAndDescendantIds(ids);
@@ -4748,8 +4761,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4748
4761
  shape.index = index;
4749
4762
  });
4750
4763
  const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) => shape);
4751
- const maxShapesReached = shapesToCreate.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage;
4752
- if (maxShapesReached) {
4764
+ if (!this.canCreateShapes(shapesToCreate)) {
4753
4765
  alertMaxShapes(this);
4754
4766
  return;
4755
4767
  }
@@ -5764,6 +5776,26 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
5764
5776
  getInitialMetaForShape(_shape) {
5765
5777
  return {};
5766
5778
  }
5779
+ /**
5780
+ * Get whether the provided shape can be created.
5781
+ *
5782
+ * @param shape - The shape or shape IDs to check.
5783
+ *
5784
+ * @public
5785
+ */
5786
+ canCreateShape(shape) {
5787
+ return this.canCreateShapes([shape]);
5788
+ }
5789
+ /**
5790
+ * Get whether the provided shapes can be created.
5791
+ *
5792
+ * @param shapes - The shapes or shape IDs to create.
5793
+ *
5794
+ * @public
5795
+ */
5796
+ canCreateShapes(shapes) {
5797
+ return shapes.length + this.getCurrentPageShapeIds().size <= this.options.maxShapesPerPage;
5798
+ }
5767
5799
  /**
5768
5800
  * Create a single shape.
5769
5801
  *
@@ -5817,7 +5849,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
5817
5849
  let parentId = this.getFocusedGroupId();
5818
5850
  for (let i = currentPageShapesSorted.length - 1; i >= 0; i--) {
5819
5851
  const parent = currentPageShapesSorted[i];
5820
- if (!this.isShapeHidden(parent) && this.getShapeUtil(parent).canReceiveNewChildrenOfType(parent, partial.type) && this.isPointInShape(
5852
+ const util = this.getShapeUtil(parent);
5853
+ if (util.canReceiveNewChildrenOfType(parent, partial.type) && !this.isShapeHidden(parent) && this.isPointInShape(
5821
5854
  parent,
5822
5855
  // If no parent is provided, then we can treat the
5823
5856
  // shape's provided x/y as being in the page's space.
@@ -5892,6 +5925,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
5892
5925
  ...shape.meta
5893
5926
  };
5894
5927
  });
5928
+ this.emit("created-shapes", shapeRecordsToCreate);
5929
+ this.emit("edit");
5895
5930
  this.store.put(shapeRecordsToCreate);
5896
5931
  });
5897
5932
  return this;
@@ -6133,6 +6168,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6133
6168
  updated = this.getShapeUtil(shape).onBeforeUpdate?.(shape, updated) ?? updated;
6134
6169
  updates.push(updated);
6135
6170
  }
6171
+ this.emit("edited-shapes", updates);
6172
+ this.emit("edit");
6136
6173
  this.store.put(updates);
6137
6174
  });
6138
6175
  }
@@ -6154,6 +6191,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6154
6191
  allShapeIdsToDelete.add(childId);
6155
6192
  });
6156
6193
  }
6194
+ this.emit("deleted-shapes", [...allShapeIdsToDelete]);
6195
+ this.emit("edit");
6157
6196
  return this.run(() => this.store.remove([...allShapeIdsToDelete]));
6158
6197
  }
6159
6198
  deleteShape(_id) {
@@ -6497,6 +6536,14 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6497
6536
  async putExternalContent(info) {
6498
6537
  return this.externalContentHandlers[info.type]?.(info);
6499
6538
  }
6539
+ /**
6540
+ * Handle replacing external content.
6541
+ *
6542
+ * @param info - Info about the external content.
6543
+ */
6544
+ async replaceExternalContent(info) {
6545
+ return this.externalContentHandlers[info.type]?.(info);
6546
+ }
6500
6547
  /**
6501
6548
  * Get content that can be exported for the given shape ids.
6502
6549
  *
@@ -6914,7 +6961,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6914
6961
  previousScreenPoint,
6915
6962
  previousPagePoint,
6916
6963
  currentScreenPoint,
6917
- currentPagePoint
6964
+ currentPagePoint,
6965
+ originScreenPoint,
6966
+ originPagePoint
6918
6967
  } = this.inputs;
6919
6968
  const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID);
6920
6969
  const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera());
@@ -6932,8 +6981,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
6932
6981
  this.inputs.isPen = info.type === "pointer" && info.isPen;
6933
6982
  if (info.name === "pointer_down" || this.inputs.isPinching) {
6934
6983
  pointerVelocity.set(0, 0);
6935
- this.inputs.originScreenPoint.setTo(currentScreenPoint);
6936
- this.inputs.originPagePoint.setTo(currentPagePoint);
6984
+ originScreenPoint.setTo(currentScreenPoint);
6985
+ originPagePoint.setTo(currentPagePoint);
6937
6986
  }
6938
6987
  this.run(
6939
6988
  () => {
@@ -7786,7 +7835,6 @@ __decorateElement(_init, 1, "getCurrentPageShapesInReadingOrder", _getCurrentPag
7786
7835
  __decorateElement(_init, 1, "getOnlySelectedShapeId", _getOnlySelectedShapeId_dec, Editor);
7787
7836
  __decorateElement(_init, 1, "getOnlySelectedShape", _getOnlySelectedShape_dec, Editor);
7788
7837
  __decorateElement(_init, 1, "getSelectionPageBounds", _getSelectionPageBounds_dec, Editor);
7789
- __decorateElement(_init, 1, "getSelectionScreenBounds", _getSelectionScreenBounds_dec, Editor);
7790
7838
  __decorateElement(_init, 1, "getSelectionRotation", _getSelectionRotation_dec, Editor);
7791
7839
  __decorateElement(_init, 1, "getSelectionRotatedPageBounds", _getSelectionRotatedPageBounds_dec, Editor);
7792
7840
  __decorateElement(_init, 1, "getSelectionRotatedScreenBounds", _getSelectionRotatedScreenBounds_dec, Editor);