@tldraw/editor 3.14.0-canary.faba3f64c07f → 3.14.0-canary.fb0390b30559

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 (37) hide show
  1. package/dist-cjs/index.d.ts +16 -0
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/editor/Editor.js +22 -3
  4. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  5. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +3 -1
  6. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
  7. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +13 -6
  8. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +3 -3
  9. package/dist-cjs/lib/primitives/geometry/Group2d.js +11 -6
  10. package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
  11. package/dist-cjs/lib/utils/dom.js +1 -1
  12. package/dist-cjs/lib/utils/dom.js.map +2 -2
  13. package/dist-cjs/version.js +3 -3
  14. package/dist-cjs/version.js.map +1 -1
  15. package/dist-esm/index.d.mts +16 -0
  16. package/dist-esm/index.mjs +1 -1
  17. package/dist-esm/lib/editor/Editor.mjs +22 -3
  18. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  19. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +3 -1
  20. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
  21. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +13 -6
  22. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +3 -3
  23. package/dist-esm/lib/primitives/geometry/Group2d.mjs +11 -6
  24. package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
  25. package/dist-esm/lib/utils/dom.mjs +1 -1
  26. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  27. package/dist-esm/version.mjs +3 -3
  28. package/dist-esm/version.mjs.map +1 -1
  29. package/editor.css +7 -0
  30. package/package.json +7 -7
  31. package/src/lib/editor/Editor.ts +30 -6
  32. package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +3 -1
  33. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +25 -17
  34. package/src/lib/primitives/geometry/Group2d.ts +11 -5
  35. package/src/lib/utils/dom.ts +1 -1
  36. package/src/version.ts +3 -3
  37. package/CHANGELOG.md +0 -4327
@@ -3264,6 +3264,22 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3264
3264
  * @public
3265
3265
  */
3266
3266
  getInitialMetaForShape(_shape: TLShape): JsonObject;
3267
+ /**
3268
+ * Get whether the provided shape can be created.
3269
+ *
3270
+ * @param shape - The shape or shape IDs to check.
3271
+ *
3272
+ * @public
3273
+ */
3274
+ canCreateShape<T extends TLUnknownShape>(shape: OptionalKeys<TLShapePartial<T>, 'id'> | T['id']): boolean;
3275
+ /**
3276
+ * Get whether the provided shapes can be created.
3277
+ *
3278
+ * @param shapes - The shapes or shape IDs to create.
3279
+ *
3280
+ * @public
3281
+ */
3282
+ canCreateShapes<T extends TLUnknownShape>(shapes: (OptionalKeys<TLShapePartial<T>, 'id'> | T['id'])[]): boolean;
3267
3283
  /**
3268
3284
  * Create a single shape.
3269
3285
  *
package/dist-cjs/index.js CHANGED
@@ -364,7 +364,7 @@ function debugEnableLicensing() {
364
364
  }
365
365
  (0, import_utils.registerTldrawLibraryVersion)(
366
366
  "@tldraw/editor",
367
- "3.14.0-canary.faba3f64c07f",
367
+ "3.14.0-canary.fb0390b30559",
368
368
  "cjs"
369
369
  );
370
370
  //# sourceMappingURL=index.js.map
@@ -2788,7 +2788,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
2788
2788
  * @public
2789
2789
  */
2790
2790
  updateViewportScreenBounds(screenBounds, center = false) {
2791
- if (screenBounds instanceof HTMLElement) {
2791
+ if (!(screenBounds instanceof import_Box.Box)) {
2792
2792
  const rect = screenBounds.getBoundingClientRect();
2793
2793
  screenBounds = new import_Box.Box(
2794
2794
  rect.left || rect.x,
@@ -4727,8 +4727,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
4727
4727
  shape.index = index;
4728
4728
  });
4729
4729
  const shapesToCreate = shapesToCreateWithOriginals.map(({ shape }) => shape);
4730
- const maxShapesReached = shapesToCreate.length + this.getCurrentPageShapeIds().size > this.options.maxShapesPerPage;
4731
- if (maxShapesReached) {
4730
+ if (!this.canCreateShapes(shapesToCreate)) {
4732
4731
  alertMaxShapes(this);
4733
4732
  return;
4734
4733
  }
@@ -5743,6 +5742,26 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
5743
5742
  getInitialMetaForShape(_shape) {
5744
5743
  return {};
5745
5744
  }
5745
+ /**
5746
+ * Get whether the provided shape can be created.
5747
+ *
5748
+ * @param shape - The shape or shape IDs to check.
5749
+ *
5750
+ * @public
5751
+ */
5752
+ canCreateShape(shape) {
5753
+ return this.canCreateShapes([shape]);
5754
+ }
5755
+ /**
5756
+ * Get whether the provided shapes can be created.
5757
+ *
5758
+ * @param shapes - The shapes or shape IDs to create.
5759
+ *
5760
+ * @public
5761
+ */
5762
+ canCreateShapes(shapes) {
5763
+ return shapes.length + this.getCurrentPageShapeIds().size <= this.options.maxShapesPerPage;
5764
+ }
5746
5765
  /**
5747
5766
  * Create a single shape.
5748
5767
  *