@tldraw/editor 4.3.0-canary.da35795ba8e2 → 4.3.0-canary.eb3bbfa1daab

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 +56 -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 +4 -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 +56 -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 +4 -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 +85 -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 +2 -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
@@ -2804,14 +2804,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2804
2804
  }
2805
2805
  if (_willSetInitialBounds) {
2806
2806
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2807
+ this.emit("resize", screenBounds.toJson());
2807
2808
  this.setCamera(this.getCamera());
2808
2809
  } else {
2809
2810
  if (center && !this.getInstanceState().followingUserId) {
2810
2811
  const before = this.getViewportPageBounds().center;
2811
2812
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2813
+ this.emit("resize", screenBounds.toJson());
2812
2814
  this.centerOnPoint(before);
2813
2815
  } else {
2814
2816
  this.updateInstanceState({ screenBounds: screenBounds.toJson(), insets });
2817
+ this.emit("resize", screenBounds.toJson());
2815
2818
  this._setCamera(Vec.From({ ...this.getCamera() }));
2816
2819
  }
2817
2820
  }
@@ -4435,30 +4438,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
4435
4438
  getBinding(id) {
4436
4439
  return this.store.get(id);
4437
4440
  }
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
4441
  getBindingsFromShape(shape, type) {
4443
4442
  const id = typeof shape === "string" ? shape : shape.id;
4444
4443
  return this.getBindingsInvolvingShape(id).filter(
4445
4444
  (b) => b.fromId === id && b.type === type
4446
4445
  );
4447
4446
  }
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
4447
  getBindingsToShape(shape, type) {
4453
4448
  const id = typeof shape === "string" ? shape : shape.id;
4454
4449
  return this.getBindingsInvolvingShape(id).filter(
4455
4450
  (b) => b.toId === id && b.type === type
4456
4451
  );
4457
4452
  }
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
4453
  getBindingsInvolvingShape(shape, type) {
4463
4454
  const id = typeof shape === "string" ? shape : shape.id;
4464
4455
  const result = this._getBindingsIndexCache().get(id) ?? EMPTY_ARRAY;
@@ -7516,6 +7507,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7516
7507
  this.setCursor({ type: this._prevCursor, rotation: 0 });
7517
7508
  }
7518
7509
  }
7510
+ this.emit("event", info);
7519
7511
  this.root.handleEvent(info);
7520
7512
  return;
7521
7513
  }