@tldraw/editor 4.3.0-next.921f0bb64804 → 4.3.0-next.a109a0fbe064

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 (58) hide show
  1. package/dist-cjs/index.d.ts +57 -35
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  4. package/dist-cjs/lib/editor/Editor.js +5 -12
  5. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  6. package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +2 -2
  7. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
  8. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
  9. package/dist-cjs/lib/editor/shapes/BaseBoxShapeUtil.js.map +1 -1
  10. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  11. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.js.map +2 -2
  13. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
  14. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  15. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  16. package/dist-cjs/lib/globals/menus.js +1 -1
  17. package/dist-cjs/lib/globals/menus.js.map +2 -2
  18. package/dist-cjs/lib/utils/reparenting.js.map +2 -2
  19. package/dist-cjs/version.js +3 -3
  20. package/dist-cjs/version.js.map +1 -1
  21. package/dist-esm/index.d.mts +57 -35
  22. package/dist-esm/index.mjs +1 -1
  23. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  24. package/dist-esm/lib/editor/Editor.mjs +5 -12
  25. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  26. package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +2 -2
  27. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
  28. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
  29. package/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs.map +1 -1
  30. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  31. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  32. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs.map +2 -2
  33. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
  34. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  35. package/dist-esm/lib/globals/menus.mjs +1 -1
  36. package/dist-esm/lib/globals/menus.mjs.map +2 -2
  37. package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
  38. package/dist-esm/version.mjs +3 -3
  39. package/dist-esm/version.mjs.map +1 -1
  40. package/package.json +10 -10
  41. package/src/lib/components/default-components/DefaultCanvas.tsx +1 -0
  42. package/src/lib/editor/Editor.test.ts +10 -10
  43. package/src/lib/editor/Editor.ts +86 -59
  44. package/src/lib/editor/bindings/BindingUtil.ts +15 -9
  45. package/src/lib/editor/derivations/bindingsIndex.ts +2 -2
  46. package/src/lib/editor/managers/FontManager/FontManager.test.ts +14 -4
  47. package/src/lib/editor/managers/SnapManager/SnapManager.ts +3 -3
  48. package/src/lib/editor/shapes/BaseBoxShapeUtil.tsx +2 -2
  49. package/src/lib/editor/shapes/ShapeUtil.ts +5 -8
  50. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -3
  51. package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +2 -1
  52. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
  53. package/src/lib/editor/types/emit-types.ts +3 -1
  54. package/src/lib/exports/getSvgJsx.test.ts +10 -19
  55. package/src/lib/exports/getSvgJsx.tsx +2 -5
  56. package/src/lib/globals/menus.ts +1 -1
  57. package/src/lib/utils/reparenting.ts +5 -5
  58. package/src/version.ts +3 -3
@@ -895,6 +895,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
895
895
  this.disposables.clear();
896
896
  this.store.dispose();
897
897
  this.isDisposed = true;
898
+ this.emit("dispose");
898
899
  }
899
900
  getShapeUtil(arg) {
900
901
  const type = typeof arg === "string" ? arg : arg.type;
@@ -2804,14 +2805,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2804
2805
  }
2805
2806
  if (_willSetInitialBounds) {
2806
2807
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2808
+ this.emit("resize", screenBounds.toJson());
2807
2809
  this.setCamera(this.getCamera());
2808
2810
  } else {
2809
2811
  if (center && !this.getInstanceState().followingUserId) {
2810
2812
  const before = this.getViewportPageBounds().center;
2811
2813
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2814
+ this.emit("resize", screenBounds.toJson());
2812
2815
  this.centerOnPoint(before);
2813
2816
  } else {
2814
2817
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2818
+ this.emit("resize", screenBounds.toJson());
2815
2819
  this._setCamera(Vec.From({ ...this.getCamera() }));
2816
2820
  }
2817
2821
  }
@@ -4435,30 +4439,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4435
4439
  getBinding(id) {
4436
4440
  return this.store.get(id);
4437
4441
  }
4438
- /**
4439
- * Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
4440
- * `fromId` matched the shape's ID.
4441
- */
4442
4442
  getBindingsFromShape(shape, type) {
4443
4443
  const id = typeof shape === "string" ? shape : shape.id;
4444
4444
  return this.getBindingsInvolvingShape(id).filter(
4445
4445
  (b) => b.fromId === id && b.type === type
4446
4446
  );
4447
4447
  }
4448
- /**
4449
- * Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
4450
- * `toId` matches the shape's ID.
4451
- */
4452
4448
  getBindingsToShape(shape, type) {
4453
4449
  const id = typeof shape === "string" ? shape : shape.id;
4454
4450
  return this.getBindingsInvolvingShape(id).filter(
4455
4451
  (b) => b.toId === id && b.type === type
4456
4452
  );
4457
4453
  }
4458
- /**
4459
- * Get all bindings involving a particular shape. This includes bindings where the shape is the
4460
- * `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
4461
- */
4462
4454
  getBindingsInvolvingShape(shape, type) {
4463
4455
  const id = typeof shape === "string" ? shape : shape.id;
4464
4456
  const result = this._getBindingsIndexCache().get(id) ?? EMPTY_ARRAY;
@@ -7516,6 +7508,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7516
7508
  this.setCursor({ type: this._prevCursor, rotation: 0 });
7517
7509
  }
7518
7510
  }
7511
+ this.emit("event", info);
7519
7512
  this.root.handleEvent(info);
7520
7513
  return;
7521
7514
  }