@tldraw/editor 3.9.0-canary.81717556ec3d → 3.9.0-canary.8339b14b4397

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 (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist-cjs/index.d.ts +37 -7
  4. package/dist-cjs/index.js +1 -1
  5. package/dist-cjs/index.js.map +2 -2
  6. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +1 -1
  7. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
  8. package/dist-cjs/lib/editor/Editor.js +431 -249
  9. package/dist-cjs/lib/editor/Editor.js.map +3 -3
  10. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +7 -2
  11. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/exports/getSvgJsx.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 +37 -7
  16. package/dist-esm/index.mjs +1 -1
  17. package/dist-esm/index.mjs.map +2 -2
  18. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +1 -1
  19. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
  20. package/dist-esm/lib/editor/Editor.mjs +427 -245
  21. package/dist-esm/lib/editor/Editor.mjs.map +3 -3
  22. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +7 -2
  23. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  24. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  25. package/dist-esm/version.mjs +3 -3
  26. package/dist-esm/version.mjs.map +1 -1
  27. package/package.json +7 -7
  28. package/src/index.ts +2 -0
  29. package/src/lib/components/default-components/DefaultErrorFallback.tsx +5 -3
  30. package/src/lib/editor/Editor.ts +556 -273
  31. package/src/lib/editor/shapes/ShapeUtil.ts +32 -5
  32. package/src/lib/exports/getSvgJsx.tsx +1 -0
  33. package/src/version.ts +3 -3
@@ -36,7 +36,7 @@ export interface TLShapeUtilConstructor<
36
36
  *
37
37
  * @public
38
38
  */
39
- export interface TLShapeUtilCanBindOpts<Shape extends TLUnknownShape = TLShape> {
39
+ export interface TLShapeUtilCanBindOpts<Shape extends TLUnknownShape = TLUnknownShape> {
40
40
  /** The type of shape referenced by the `fromId` of the binding. */
41
41
  fromShapeType: string
42
42
  /** The type of shape referenced by the `toId` of the binding. */
@@ -45,6 +45,27 @@ export interface TLShapeUtilCanBindOpts<Shape extends TLUnknownShape = TLShape>
45
45
  bindingType: string
46
46
  }
47
47
 
48
+ /**
49
+ * Options passed to {@link ShapeUtil.canBeLaidOut}.
50
+ *
51
+ * @public
52
+ */
53
+ export interface TLShapeUtilCanBeLaidOutOpts {
54
+ /** The type of action causing the layout. */
55
+ type?: 'align' | 'distribute' | 'pack' | 'stack' | 'flip' | 'stretch'
56
+ /** The other shapes being laid out */
57
+ shapes?: TLShape[]
58
+ }
59
+
60
+ /** Additional options for the {@link ShapeUtil.getGeometry} method.
61
+ *
62
+ * @public
63
+ */
64
+ export interface TLGeometryOpts {
65
+ /** The context in which the geometry is being requested. */
66
+ context?: string
67
+ }
68
+
48
69
  /** @public */
49
70
  export interface TLShapeUtilCanvasSvgDef {
50
71
  key: string
@@ -128,9 +149,10 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
128
149
  * Get the shape's geometry.
129
150
  *
130
151
  * @param shape - The shape.
152
+ * @param opts - Additional options for the request.
131
153
  * @public
132
154
  */
133
- abstract getGeometry(shape: Shape): Geometry2d
155
+ abstract getGeometry(shape: Shape, opts?: TLGeometryOpts): Geometry2d
134
156
 
135
157
  /**
136
158
  * Get a JSX element for the shape (as an HTML element).
@@ -151,6 +173,7 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
151
173
  /**
152
174
  * Whether the shape can be snapped to by another shape.
153
175
  *
176
+ * @param shape - The shape.
154
177
  * @public
155
178
  */
156
179
  canSnap(_shape: Shape): boolean {
@@ -171,7 +194,7 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
171
194
  *
172
195
  * @public
173
196
  */
174
- canBind(_opts: TLShapeUtilCanBindOpts<Shape>): boolean {
197
+ canBind(_opts: TLShapeUtilCanBindOpts): boolean {
175
198
  return true
176
199
  }
177
200
 
@@ -212,11 +235,15 @@ export abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
212
235
  }
213
236
 
214
237
  /**
215
- * Whether the shape participates in stacking, aligning, and distributing.
238
+ * Whether the shape can participate in layout functions such as alignment or distribution.
239
+ *
240
+ * @param shape - The shape.
241
+ * @param info - Additional context information: the type of action causing the layout and the
242
+ * @public
216
243
  *
217
244
  * @public
218
245
  */
219
- canBeLaidOut(_shape: Shape): boolean {
246
+ canBeLaidOut(_shape: Shape, _info: TLShapeUtilCanBeLaidOutOpts): boolean {
220
247
  return true
221
248
  }
222
249
 
@@ -205,6 +205,7 @@ function SvgExport({
205
205
  ;(async () => {
206
206
  const shapeDefs: Record<string, { pending: false; element: ReactElement }> = {}
207
207
 
208
+ // Then render everything. The shapes with assets should all hit the cache
208
209
  const unorderedShapeElementPromises = renderingShapes.map(
209
210
  async ({ id, opacity, index, backgroundIndex }) => {
210
211
  // Don't render the frame if we're only exporting a single frame and it's children
package/src/version.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '3.9.0-canary.81717556ec3d'
4
+ export const version = '3.9.0-canary.8339b14b4397'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-02-25T13:46:50.082Z',
8
- patch: '2025-02-25T13:46:50.082Z',
7
+ minor: '2025-02-28T15:05:55.134Z',
8
+ patch: '2025-02-28T15:05:55.134Z',
9
9
  }