@tldraw/editor 3.8.0-internal.af5331ba6061 → 3.8.0

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 (69) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/dist-cjs/index.d.ts +169 -52
  3. package/dist-cjs/index.js +4 -1
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
  6. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  7. package/dist-cjs/lib/editor/Editor.js +30 -17
  8. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  9. package/dist-cjs/lib/editor/managers/TextManager.js +1 -0
  10. package/dist-cjs/lib/editor/managers/TextManager.js.map +2 -2
  11. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +13 -0
  12. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  13. package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js +66 -0
  14. package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js.map +7 -0
  15. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  16. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  17. package/dist-cjs/lib/hooks/useCanvasEvents.js +19 -8
  18. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  19. package/dist-cjs/lib/hooks/useDocumentEvents.js +1 -3
  20. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  21. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -0
  22. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +3 -3
  23. package/dist-cjs/lib/options.js +2 -2
  24. package/dist-cjs/lib/options.js.map +2 -2
  25. package/dist-cjs/lib/utils/dom.js +6 -0
  26. package/dist-cjs/lib/utils/dom.js.map +2 -2
  27. package/dist-cjs/version.js +3 -3
  28. package/dist-cjs/version.js.map +1 -1
  29. package/dist-esm/index.d.mts +169 -52
  30. package/dist-esm/index.mjs +5 -1
  31. package/dist-esm/index.mjs.map +2 -2
  32. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
  33. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  34. package/dist-esm/lib/editor/Editor.mjs +30 -17
  35. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  36. package/dist-esm/lib/editor/managers/TextManager.mjs +1 -0
  37. package/dist-esm/lib/editor/managers/TextManager.mjs.map +2 -2
  38. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +13 -0
  39. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  40. package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs +46 -0
  41. package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs.map +7 -0
  42. package/dist-esm/lib/hooks/useCanvasEvents.mjs +19 -8
  43. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  44. package/dist-esm/lib/hooks/useDocumentEvents.mjs +2 -4
  45. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  46. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -0
  47. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +3 -3
  48. package/dist-esm/lib/options.mjs +2 -2
  49. package/dist-esm/lib/options.mjs.map +2 -2
  50. package/dist-esm/lib/utils/dom.mjs +6 -0
  51. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  52. package/dist-esm/version.mjs +3 -3
  53. package/dist-esm/version.mjs.map +1 -1
  54. package/editor.css +2 -1
  55. package/package.json +7 -7
  56. package/src/index.ts +18 -1
  57. package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
  58. package/src/lib/editor/Editor.ts +56 -27
  59. package/src/lib/editor/managers/TextManager.ts +1 -0
  60. package/src/lib/editor/shapes/ShapeUtil.ts +49 -1
  61. package/src/lib/editor/shapes/shared/resizeScaled.ts +61 -0
  62. package/src/lib/editor/types/emit-types.ts +1 -0
  63. package/src/lib/editor/types/external-content.ts +104 -50
  64. package/src/lib/hooks/useCanvasEvents.ts +20 -8
  65. package/src/lib/hooks/useDocumentEvents.ts +2 -11
  66. package/src/lib/hooks/usePassThroughWheelEvents.ts +7 -0
  67. package/src/lib/options.ts +5 -2
  68. package/src/lib/utils/dom.ts +12 -0
  69. package/src/version.ts +3 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,174 @@
1
+ # v3.8.0 (Wed Feb 12 2025)
2
+
3
+ ### Release Notes
4
+
5
+ #### support dragging urls onto the canvas ([#5411](https://github.com/tldraw/tldraw/pull/5411))
6
+
7
+ - Dragging and dropping URLs onto the canvas is now supported (and creates a bookmark by default)
8
+
9
+ #### Add tldraw and excalidraw to external content types ([#5402](https://github.com/tldraw/tldraw/pull/5402))
10
+
11
+ - You can now customize how pasted tldraw and excalidraw content is handled with `registerExternalContentHandler`.
12
+
13
+ #### ShapeUtil.configure for shape options ([#5399](https://github.com/tldraw/tldraw/pull/5399))
14
+
15
+ - introduces shape options & `ShapeUtil.configure`, a utility for passing options to a shape util
16
+ - moves (unreleased) noteShapeResizeMode to NoteShapeOptions.resizeMode
17
+ - If you pass tldraw a shape util with the same type as a default, it'll now replace the default rather than crash
18
+ - **BREAKING** `options.maxDrawShapePoints` should now be specified with `DrawShapeUtil.configure({maxPoints})` and `HighlightShapeUtil.configure({maxPoints})`
19
+
20
+ #### Shape options ([#5349](https://github.com/tldraw/tldraw/pull/5349))
21
+
22
+ - introduces shape options
23
+ - moves (unreleased) `noteShapeResizeMode` to `NoteShapeOptions.resizeMode`
24
+ - moves `maxDrawShapePoints` to `DrawShapeOptions.maxPoints`
25
+ - adds `maxPoints` to `HighlightShapeOptions.maxPoints`
26
+ - 💥 breaking change if someone was using `options.maxDrawShapePoints`.
27
+
28
+ #### Numeric shortcuts were still getting triggered when used inside some inputs (like the file rename input) ([#5378](https://github.com/tldraw/tldraw/pull/5378))
29
+
30
+ - Fix an issue with numeric shortcuts working inside of editable elements.
31
+
32
+ #### Don't pass through mousewheel events on scrollable elements ([#5356](https://github.com/tldraw/tldraw/pull/5356))
33
+
34
+ - Fixed a bug with scrollable UI elements not being scrollable.
35
+
36
+ #### Improve frame heading perf ([#5357](https://github.com/tldraw/tldraw/pull/5357))
37
+
38
+ - Fix bug effecting performance when many frames are on the screen.
39
+
40
+ #### Add option to disable numbered shortcuts on the toolbar ([#5340](https://github.com/tldraw/tldraw/pull/5340))
41
+
42
+ - SDK: Added editor option to disable 0-9 keyboard shortcuts for the toolbar
43
+ - Improved keyboard shortcuts for the toolbar
44
+
45
+ #### support react 19 ([#5293](https://github.com/tldraw/tldraw/pull/5293))
46
+
47
+ - tldraw now supports react 19
48
+
49
+ #### separately export default external content/asset handlers ([#5298](https://github.com/tldraw/tldraw/pull/5298))
50
+
51
+ - You can now import each of our external asset/content handlers, so you can augment them without having to copy-paste them into your app
52
+
53
+ #### BREAKING
54
+ - `TLExternalAssetContent` has been renamed to `TLExternalAsset`
55
+
56
+ #### Emit a before-event from Editor ([#5319](https://github.com/tldraw/tldraw/pull/5319))
57
+
58
+ - Emit a `before-event` from Editor for events before they are handled by tldraw.
59
+
60
+ #### fix: consider font style in text measuring ([#5313](https://github.com/tldraw/tldraw/pull/5313))
61
+
62
+ - Fixed a bug with…
63
+
64
+ #### Add editor option to allow sticky note resizing by scale ([#5273](https://github.com/tldraw/tldraw/pull/5273))
65
+
66
+ - Added `options.noteShapeResizeMode` editor option to control how note shapes resize.
67
+
68
+ #### Fix an error when embed util is not present. ([#5296](https://github.com/tldraw/tldraw/pull/5296))
69
+
70
+ - Fix an issue with embeds logic not gracefully handling cases when we don't have an embed util.
71
+
72
+ #### Add an onCrop handler to ShapeUtil ([#5137](https://github.com/tldraw/tldraw/pull/5137))
73
+
74
+ - Add support for an onCrop handler on shape utils that allows you to prevent or modify the crop.
75
+ - The `TLImageShapeCrop` type has been replaced by `TLShapeCrop`.
76
+
77
+ #### Style changing duration reduced from 2 to 1 second ([#5158](https://github.com/tldraw/tldraw/pull/5158))
78
+
79
+ - Style changing duration reduced from 2 to 1 second
80
+
81
+ #### Asset uploads ([#5218](https://github.com/tldraw/tldraw/pull/5218))
82
+
83
+ **Breaking change**
84
+
85
+ - `@tldraw/tlschema`: `TLAssetStore.upload` used to return just the `src` of the uploaded asset. It now returns `{src: string, meta?: JsonObject}`. The returned metadata will be added to the asset record and thus allows the users to add some additional data to them when uploading.
86
+ - `@tldraw/editor`: `Editor.uploadAsset` used to return `Promise<string>` and now returns `Promise<{ src: string; meta?: JsonObject }> `
87
+
88
+ #### Exports DX pass ([#5114](https://github.com/tldraw/tldraw/pull/5114))
89
+
90
+ #### Breaking changes / user facing changes
91
+ - The copy/export as JSON option has been removed. Data copied/exported from here could not be used anyway. If you need this in your app, look into `Editor.getContentFromCurrentPage`.
92
+ - `useImageOrVideoAssetUrl` now expects a `width` parameter representing the rendered width of the asset.
93
+ - `Editor.getSvgElement` and `Editor.getSvgString` will now export all shapes on the current page instead of returning undefined when passed an empty array of shape ids.
94
+
95
+ #### Product improvement
96
+ - When exporting to an image, image assets are now downloaded at a resolution appropriate for how they will appear in the export.
97
+
98
+ #### API changes
99
+ - There's a new `Editor.toImage` method that makes creating an image from your canvas easier. (`exportToBlob` is deprecated in favour of it)
100
+ - `SvgExportContext` now exposes the `scale` and `pixelRatio` options of the current export
101
+ - `SvgExportContext` now has a `resolveAssetUrl` method to resolve an asset at a resolution appropriate for the export.
102
+ - `copyAs(editor, ids, format, opts)` has been deprecated in favour of `copyAs(editor, ids, opts)`.
103
+ - `exportAs(editor, ids, format, name, opts)` has been deprecated in favour of `exportAs(editor, ids, opts)`
104
+
105
+ #### Always override session state on initial load ([#5233](https://github.com/tldraw/tldraw/pull/5233))
106
+
107
+ - Fixed a bug where grid mode and other settings would not persist across page reloads.
108
+
109
+ #### i18n: augment the list so that we hit the top 40 languages ([#5208](https://github.com/tldraw/tldraw/pull/5208))
110
+
111
+ - i18n: add top 40 languages into the list
112
+
113
+ #### pass custom migrations to useLocalStore ([#5135](https://github.com/tldraw/tldraw/pull/5135))
114
+
115
+ - Fixed a bug with locally synced stores where custom migrations were not being passed to the store constructor.
116
+
117
+ ---
118
+
119
+ #### 🐛 Bug Fix
120
+
121
+ - fix: consider font style in text measuring [#5313](https://github.com/tldraw/tldraw/pull/5313) ([@ricardo-crespo](https://github.com/ricardo-crespo))
122
+
123
+ #### 🐛 Bug Fixes
124
+
125
+ - Numeric shortcuts were still getting triggered when used inside some inputs (like the file rename input) [#5378](https://github.com/tldraw/tldraw/pull/5378) ([@MitjaBezensek](https://github.com/MitjaBezensek))
126
+ - Improve frame heading perf [#5357](https://github.com/tldraw/tldraw/pull/5357) ([@steveruizok](https://github.com/steveruizok))
127
+ - Fix an error when embed util is not present. [#5296](https://github.com/tldraw/tldraw/pull/5296) ([@MitjaBezensek](https://github.com/MitjaBezensek) [@mimecuvalo](https://github.com/mimecuvalo))
128
+ - Always override session state on initial load [#5233](https://github.com/tldraw/tldraw/pull/5233) ([@ds300](https://github.com/ds300))
129
+ - i18n: rename two locale codes [#5212](https://github.com/tldraw/tldraw/pull/5212) ([@mimecuvalo](https://github.com/mimecuvalo))
130
+ - pass custom migrations to useLocalStore [#5135](https://github.com/tldraw/tldraw/pull/5135) ([@ds300](https://github.com/ds300))
131
+
132
+ #### 💄 Product Improvements
133
+
134
+ - support dragging urls onto the canvas [#5411](https://github.com/tldraw/tldraw/pull/5411) ([@SomeHats](https://github.com/SomeHats))
135
+ - Don't pass through mousewheel events on scrollable elements [#5356](https://github.com/tldraw/tldraw/pull/5356) ([@steveruizok](https://github.com/steveruizok))
136
+ - support react 19 [#5293](https://github.com/tldraw/tldraw/pull/5293) ([@SomeHats](https://github.com/SomeHats) [@mimecuvalo](https://github.com/mimecuvalo) [@huppy-bot[bot]](https://github.com/huppy-bot[bot]))
137
+ - Style changing duration reduced from 2 to 1 second [#5158](https://github.com/tldraw/tldraw/pull/5158) (alexander.melnik@pandadoc.com [@melnikkk](https://github.com/melnikkk))
138
+ - Asset uploads [#5218](https://github.com/tldraw/tldraw/pull/5218) ([@MitjaBezensek](https://github.com/MitjaBezensek))
139
+ - error logging: add more context for errors [#5221](https://github.com/tldraw/tldraw/pull/5221) ([@mimecuvalo](https://github.com/mimecuvalo))
140
+
141
+ #### 🎉 New Features
142
+
143
+ - i18n: augment the list so that we hit the top 40 languages [#5208](https://github.com/tldraw/tldraw/pull/5208) ([@mimecuvalo](https://github.com/mimecuvalo))
144
+
145
+ #### 🛠️ API Changes
146
+
147
+ - Add tldraw and excalidraw to external content types [#5402](https://github.com/tldraw/tldraw/pull/5402) ([@SomeHats](https://github.com/SomeHats))
148
+ - ShapeUtil.configure for shape options [#5399](https://github.com/tldraw/tldraw/pull/5399) ([@SomeHats](https://github.com/SomeHats))
149
+ - Shape options [#5349](https://github.com/tldraw/tldraw/pull/5349) ([@steveruizok](https://github.com/steveruizok))
150
+ - Add option to disable numbered shortcuts on the toolbar [#5340](https://github.com/tldraw/tldraw/pull/5340) ([@steveruizok](https://github.com/steveruizok))
151
+ - separately export default external content/asset handlers [#5298](https://github.com/tldraw/tldraw/pull/5298) ([@SomeHats](https://github.com/SomeHats))
152
+ - Emit a before-event from Editor [#5319](https://github.com/tldraw/tldraw/pull/5319) ([@trygve-aaberge-adsk](https://github.com/trygve-aaberge-adsk))
153
+ - Add editor option to allow sticky note resizing by scale [#5273](https://github.com/tldraw/tldraw/pull/5273) ([@steveruizok](https://github.com/steveruizok))
154
+ - Add an onCrop handler to ShapeUtil [#5137](https://github.com/tldraw/tldraw/pull/5137) ([@trygve-aaberge-adsk](https://github.com/trygve-aaberge-adsk) [@mimecuvalo](https://github.com/mimecuvalo))
155
+ - Exports DX pass [#5114](https://github.com/tldraw/tldraw/pull/5114) ([@SomeHats](https://github.com/SomeHats))
156
+
157
+ #### Authors: 10
158
+
159
+ - [@huppy-bot[bot]](https://github.com/huppy-bot[bot])
160
+ - Aleksander Melnik (alexander.melnik@pandadoc.com)
161
+ - alex ([@SomeHats](https://github.com/SomeHats))
162
+ - Alexander Melnik ([@melnikkk](https://github.com/melnikkk))
163
+ - David Sheldrick ([@ds300](https://github.com/ds300))
164
+ - Mime Čuvalo ([@mimecuvalo](https://github.com/mimecuvalo))
165
+ - Mitja Bezenšek ([@MitjaBezensek](https://github.com/MitjaBezensek))
166
+ - Ricardo Crespo ([@ricardo-crespo](https://github.com/ricardo-crespo))
167
+ - Steve Ruiz ([@steveruizok](https://github.com/steveruizok))
168
+ - Trygve Aaberge ([@trygve-aaberge-adsk](https://github.com/trygve-aaberge-adsk))
169
+
170
+ ---
171
+
1
172
  # v3.7.0 (Tue Jan 07 2025)
2
173
 
3
174
  ### Release Notes
@@ -68,6 +68,7 @@ import { TLPropsMigrations } from '@tldraw/tlschema';
68
68
  import { TLRecord } from '@tldraw/tlschema';
69
69
  import { TLScribble } from '@tldraw/tlschema';
70
70
  import { TLShape } from '@tldraw/tlschema';
71
+ import { TLShapeCrop } from '@tldraw/tlschema';
71
72
  import { TLShapeId } from '@tldraw/tlschema';
72
73
  import { TLShapePartial } from '@tldraw/tlschema';
73
74
  import { TLStore } from '@tldraw/tlschema';
@@ -90,6 +91,8 @@ import { useValue } from '@tldraw/state-react';
90
91
  import { VecModel } from '@tldraw/tlschema';
91
92
  import { whyAmIRunning } from '@tldraw/state';
92
93
 
94
+ /* Excluded from this release type: activeElementShouldCaptureKeys */
95
+
93
96
  /**
94
97
  * Get the angle of a point on an arc.
95
98
  * @param fromAngle - The angle from center to arc's start point (A) on the circle
@@ -851,6 +854,7 @@ export declare const defaultTldrawOptions: {
851
854
  readonly edgeScrollDistance: 8;
852
855
  readonly edgeScrollEaseDuration: 200;
853
856
  readonly edgeScrollSpeed: 25;
857
+ readonly enableToolbarKeyboardShortcuts: true;
854
858
  readonly exportProvider: ExoticComponent< {
855
859
  children?: ReactNode;
856
860
  }>;
@@ -881,7 +885,6 @@ export declare const defaultTldrawOptions: {
881
885
  readonly maxExportDelayMs: 5000;
882
886
  readonly maxFilesAtOnce: 100;
883
887
  readonly maxPages: 40;
884
- readonly maxPointsPerDrawShape: 500;
885
888
  readonly maxShapesPerPage: 4000;
886
889
  readonly multiClickDurationMs: 200;
887
890
  readonly temporaryAssetPreviewLifetimeMs: 180000;
@@ -1117,6 +1120,14 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1117
1120
  getShapeUtil<S extends TLUnknownShape>(shape: S | TLShapePartial<S>): ShapeUtil<S>;
1118
1121
  getShapeUtil<S extends TLUnknownShape>(type: S['type']): ShapeUtil<S>;
1119
1122
  getShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): T;
1123
+ /**
1124
+ * Returns true if the editor has a shape util for the given shape / shape type.
1125
+ *
1126
+ * @param shape - A shape, shape partial, or shape type.
1127
+ */
1128
+ hasShapeUtil<S extends TLUnknownShape>(shape: S | TLShapePartial<S>): boolean;
1129
+ hasShapeUtil<S extends TLUnknownShape>(type: S['type']): boolean;
1130
+ hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
1120
1131
  /**
1121
1132
  * A map of shape utility classes (TLShapeUtils) by shape type.
1122
1133
  *
@@ -1369,8 +1380,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1369
1380
  *
1370
1381
  * @example
1371
1382
  * ```ts
1372
- * state.getStateDescendant('select')
1373
- * state.getStateDescendant('select.brushing')
1383
+ * editor.getStateDescendant('select')
1384
+ * editor.getStateDescendant('select.brushing')
1374
1385
  * ```
1375
1386
  *
1376
1387
  * @param path - The descendant's path of state ids, separated by periods.
@@ -3434,7 +3445,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3434
3445
  *
3435
3446
  * @public
3436
3447
  */
3437
- registerExternalAssetHandler<T extends TLExternalAssetContent['type']>(type: T, handler: ((info: TLExternalAssetContent & {
3448
+ registerExternalAssetHandler<T extends TLExternalAsset['type']>(type: T, handler: ((info: TLExternalAsset & {
3438
3449
  type: T;
3439
3450
  }) => Promise<TLAsset>) | null): this;
3440
3451
  /**
@@ -3480,8 +3491,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3480
3491
  * @param info - Info about the external content.
3481
3492
  * @returns The asset.
3482
3493
  */
3483
- getAssetForExternalContent(info: TLExternalAssetContent): Promise<TLAsset | undefined>;
3484
- hasExternalAssetHandler(type: TLExternalAssetContent['type']): boolean;
3494
+ getAssetForExternalContent(info: TLExternalAsset): Promise<TLAsset | undefined>;
3495
+ hasExternalAssetHandler(type: TLExternalAsset['type']): boolean;
3485
3496
  /* Excluded from this release type: externalContentHandlers */
3486
3497
  /**
3487
3498
  * Register an external content handler. This handler will be called when the editor receives
@@ -3502,9 +3513,9 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3502
3513
  *
3503
3514
  * @public
3504
3515
  */
3505
- registerExternalContentHandler<T extends TLExternalContent<E>['type'], E>(type: T, handler: ((info: T extends TLExternalContent<E>['type'] ? TLExternalContent<E> & {
3516
+ registerExternalContentHandler<T extends TLExternalContent<E>['type'], E>(type: T, handler: ((info: T extends TLExternalContent<E>['type'] ? Extract<TLExternalContent<E>, {
3506
3517
  type: T;
3507
- } : TLExternalContent<E>) => void) | null): this;
3518
+ }> : TLExternalContent<E>) => void) | null): this;
3508
3519
  /**
3509
3520
  * Handle external content, such as files, urls, embeds, or plain text which has been put into the app, for example by pasting external text or dropping external images onto canvas.
3510
3521
  *
@@ -4683,6 +4694,23 @@ export declare interface ResizeBoxOptions {
4683
4694
  maxHeight?: number;
4684
4695
  }
4685
4696
 
4697
+ /**
4698
+ * Resize a shape that has a scale prop.
4699
+ *
4700
+ * @param shape - The shape to resize
4701
+ * @param info - The resize info
4702
+ *
4703
+ * @public */
4704
+ export declare function resizeScaled(shape: TLBaseShape<any, {
4705
+ scale: number;
4706
+ }>, { initialBounds, scaleX, scaleY, newPoint, handle }: TLResizeInfo<any>): {
4707
+ props: {
4708
+ scale: number;
4709
+ };
4710
+ x: number;
4711
+ y: number;
4712
+ };
4713
+
4686
4714
  /** @public */
4687
4715
  export declare const ROTATE_CORNER_TO_SELECTION_CORNER: {
4688
4716
  readonly bottom_left_rotate: "bottom_left";
@@ -4786,7 +4814,17 @@ export declare function setUserPreferences(user: TLUserPreferences): void;
4786
4814
  /** @public */
4787
4815
  export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
4788
4816
  editor: Editor;
4817
+ /** Configure this shape utils {@link ShapeUtil.options | `options`}. */
4818
+ static configure<T extends TLShapeUtilConstructor<any, any>>(this: T, options: T extends new (...args: any[]) => {
4819
+ options: infer Options;
4820
+ } ? Partial<Options> : never): T;
4789
4821
  constructor(editor: Editor);
4822
+ /**
4823
+ * Options for this shape util. If you're implementing a custom shape util, you can override
4824
+ * this to provide customization options for your shape. If using an existing shape util, you
4825
+ * can customizing this by calling {@link ShapeUtil.configure}.
4826
+ */
4827
+ options: {};
4790
4828
  /**
4791
4829
  * Props allow you to define the shape's properties in a way that the editor can understand.
4792
4830
  * This has two main uses:
@@ -5054,6 +5092,15 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
5054
5092
  * @public
5055
5093
  */
5056
5094
  onBeforeUpdate?(prev: Shape, next: Shape): Shape | void;
5095
+ /**
5096
+ * A callback called when a shape changes from a crop.
5097
+ *
5098
+ * @param shape - The shape at the start of the crop.
5099
+ * @param info - Info about the crop.
5100
+ * @returns A change to apply to the shape, or void.
5101
+ * @public
5102
+ */
5103
+ onCrop?(shape: Shape, info: TLCropInfo<Shape>): Omit<TLShapePartial<Shape>, 'id' | 'type'> | undefined | void;
5057
5104
  /**
5058
5105
  * A callback called when some other shapes are dragged over this one.
5059
5106
  *
@@ -5546,6 +5593,12 @@ export declare interface TLBaseEventInfo {
5546
5593
  accelKey: boolean;
5547
5594
  }
5548
5595
 
5596
+ /** @public */
5597
+ export declare interface TLBaseExternalContent {
5598
+ sources?: TLExternalContentSource[];
5599
+ point?: VecLike;
5600
+ }
5601
+
5549
5602
  /** @public */
5550
5603
  export declare interface TLBindingUtilConstructor<T extends TLUnknownBinding, U extends BindingUtil<T> = BindingUtil<T>> {
5551
5604
  new (editor: Editor): U;
@@ -5711,6 +5764,24 @@ export declare interface TLContent {
5711
5764
  schema: SerializedSchema;
5712
5765
  }
5713
5766
 
5767
+ /**
5768
+ * Info about a crop.
5769
+ * @param handle - The handle being dragged.
5770
+ * @param change - The distance the handle is moved.
5771
+ * @param initialShape - The shape at the start of the resize.
5772
+ * @public
5773
+ */
5774
+ export declare interface TLCropInfo<T extends TLShape> {
5775
+ handle: SelectionHandle;
5776
+ change: Vec;
5777
+ crop: TLShapeCrop;
5778
+ uncroppedSize: {
5779
+ h: number;
5780
+ w: number;
5781
+ };
5782
+ initialShape: T;
5783
+ }
5784
+
5714
5785
  /** @public */
5715
5786
  export declare interface TLCursorProps {
5716
5787
  className?: string;
@@ -5924,7 +5995,6 @@ export declare interface TldrawOptions {
5924
5995
  readonly dragDistanceSquared: number;
5925
5996
  readonly defaultSvgPadding: number;
5926
5997
  readonly cameraSlideFriction: number;
5927
- readonly maxPointsPerDrawShape: number;
5928
5998
  readonly gridSteps: readonly {
5929
5999
  readonly mid: number;
5930
6000
  readonly min: number;
@@ -5963,6 +6033,10 @@ export declare interface TldrawOptions {
5963
6033
  readonly exportProvider: ComponentType<{
5964
6034
  children: React.ReactNode;
5965
6035
  }>;
6036
+ /**
6037
+ * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.
6038
+ */
6039
+ readonly enableToolbarKeyboardShortcuts: boolean;
5966
6040
  }
5967
6041
 
5968
6042
  /** @public */
@@ -6064,6 +6138,13 @@ export declare interface TLEditorSnapshot {
6064
6138
  session: TLSessionStateSnapshot;
6065
6139
  }
6066
6140
 
6141
+ /** @public */
6142
+ export declare interface TLEmbedExternalContent<EmbedDefinition> extends TLBaseExternalContent {
6143
+ type: 'embed';
6144
+ url: string;
6145
+ embed: EmbedDefinition;
6146
+ }
6147
+
6067
6148
  /** @public */
6068
6149
  export declare type TLEnterEventHandler = (info: any, from: string) => void;
6069
6150
 
@@ -6089,6 +6170,13 @@ export declare interface TLErrorBoundaryProps {
6089
6170
  fallback: TLErrorFallbackComponent;
6090
6171
  }
6091
6172
 
6173
+ /** @public */
6174
+ export declare interface TLErrorExternalContentSource {
6175
+ type: 'error';
6176
+ data: null | string;
6177
+ reason: string;
6178
+ }
6179
+
6092
6180
  /** @public */
6093
6181
  export declare type TLErrorFallbackComponent = ComponentType<{
6094
6182
  editor?: Editor;
@@ -6134,6 +6222,7 @@ export declare interface TLEventMap {
6134
6222
  }];
6135
6223
  'stop-camera-animation': [];
6136
6224
  'stop-following': [];
6225
+ 'before-event': [TLEventInfo];
6137
6226
  event: [TLEventInfo];
6138
6227
  tick: [number];
6139
6228
  frame: [number];
@@ -6148,6 +6237,18 @@ export declare type TLEventMapHandler<T extends keyof TLEventMap> = (...args: TL
6148
6237
  /** @public */
6149
6238
  export declare type TLEventName = 'cancel' | 'complete' | 'interrupt' | 'tick' | 'wheel' | TLCLickEventName | TLKeyboardEventName | TLPinchEventName | TLPointerEventName;
6150
6239
 
6240
+ /** @public */
6241
+ export declare interface TLExcalidrawExternalContent extends TLBaseExternalContent {
6242
+ type: 'excalidraw';
6243
+ content: any;
6244
+ }
6245
+
6246
+ /** @public */
6247
+ export declare interface TLExcalidrawExternalContentSource {
6248
+ type: 'excalidraw';
6249
+ data: any;
6250
+ }
6251
+
6151
6252
  /** @public */
6152
6253
  export declare type TLExitEventHandler = (info: any, to: string) => void;
6153
6254
 
@@ -6155,54 +6256,27 @@ export declare type TLExitEventHandler = (info: any, to: string) => void;
6155
6256
  export declare type TLExportType = 'jpeg' | 'png' | 'svg' | 'webp';
6156
6257
 
6157
6258
  /** @public */
6158
- export declare type TLExternalAssetContent = {
6159
- assetId?: TLAssetId;
6160
- file: File;
6259
+ export declare type TLExternalAsset = TLFileExternalAsset | TLUrlExternalAsset;
6260
+
6261
+ /** @public */
6262
+ export declare type TLExternalContent<EmbedDefinition> = TLEmbedExternalContent<EmbedDefinition> | TLExcalidrawExternalContent | TLFilesExternalContent | TLSvgTextExternalContent | TLTextExternalContent | TLTldrawExternalContent | TLUrlExternalContent;
6263
+
6264
+ /** @public */
6265
+ export declare type TLExternalContentSource = TLErrorExternalContentSource | TLExcalidrawExternalContentSource | TLTextExternalContentSource | TLTldrawExternalContentSource;
6266
+
6267
+ /** @public */
6268
+ export declare interface TLFileExternalAsset {
6161
6269
  type: 'file';
6162
- } | {
6163
- type: 'url';
6164
- url: string;
6165
- };
6270
+ file: File;
6271
+ assetId?: TLAssetId;
6272
+ }
6166
6273
 
6167
6274
  /** @public */
6168
- export declare type TLExternalContent<EmbedDefinition> = {
6169
- point?: VecLike;
6170
- sources?: TLExternalContentSource[];
6171
- } & ({
6172
- embed: EmbedDefinition;
6173
- type: 'embed';
6174
- url: string;
6175
- } | {
6275
+ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
6276
+ type: 'files';
6176
6277
  files: File[];
6177
6278
  ignoreParent: boolean;
6178
- type: 'files';
6179
- } | {
6180
- text: string;
6181
- type: 'svg-text';
6182
- } | {
6183
- text: string;
6184
- type: 'text';
6185
- } | {
6186
- type: 'url';
6187
- url: string;
6188
- });
6189
-
6190
- /** @public */
6191
- export declare type TLExternalContentSource = {
6192
- data: any;
6193
- type: 'excalidraw';
6194
- } | {
6195
- data: null | string;
6196
- reason: string;
6197
- type: 'error';
6198
- } | {
6199
- data: string;
6200
- subtype: 'html' | 'json' | 'text' | 'url';
6201
- type: 'text';
6202
- } | {
6203
- data: TLContent;
6204
- type: 'tldraw';
6205
- };
6279
+ }
6206
6280
 
6207
6281
  /** @public */
6208
6282
  export declare interface TLGridProps {
@@ -6823,6 +6897,25 @@ export declare interface TLSvgExportOptions {
6823
6897
  */
6824
6898
  export declare type TLSvgOptions = TLImageExportOptions;
6825
6899
 
6900
+ /** @public */
6901
+ export declare interface TLSvgTextExternalContent extends TLBaseExternalContent {
6902
+ type: 'svg-text';
6903
+ text: string;
6904
+ }
6905
+
6906
+ /** @public */
6907
+ export declare interface TLTextExternalContent extends TLBaseExternalContent {
6908
+ type: 'text';
6909
+ text: string;
6910
+ }
6911
+
6912
+ /** @public */
6913
+ export declare interface TLTextExternalContentSource {
6914
+ type: 'text';
6915
+ data: string;
6916
+ subtype: 'html' | 'json' | 'text' | 'url';
6917
+ }
6918
+
6826
6919
  /** @public */
6827
6920
  export declare type TLTickEvent = (info: TLTickEventInfo) => void;
6828
6921
 
@@ -6840,6 +6933,30 @@ export declare interface TLTickEventInfo {
6840
6933
  */
6841
6934
  export declare const tltime: Timers;
6842
6935
 
6936
+ /** @public */
6937
+ export declare interface TLTldrawExternalContent extends TLBaseExternalContent {
6938
+ type: 'tldraw';
6939
+ content: TLContent;
6940
+ }
6941
+
6942
+ /** @public */
6943
+ export declare interface TLTldrawExternalContentSource {
6944
+ type: 'tldraw';
6945
+ data: TLContent;
6946
+ }
6947
+
6948
+ /** @public */
6949
+ export declare interface TLUrlExternalAsset {
6950
+ type: 'url';
6951
+ url: string;
6952
+ }
6953
+
6954
+ /** @public */
6955
+ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
6956
+ type: 'url';
6957
+ url: string;
6958
+ }
6959
+
6843
6960
  /** @public */
6844
6961
  export declare interface TLUser {
6845
6962
  readonly userPreferences: Signal<TLUserPreferences>;
package/dist-cjs/index.js CHANGED
@@ -97,6 +97,7 @@ __export(index_exports, {
97
97
  USER_COLORS: () => import_TLUserPreferences.USER_COLORS,
98
98
  UserPreferencesManager: () => import_UserPreferencesManager.UserPreferencesManager,
99
99
  Vec: () => import_Vec.Vec,
100
+ activeElementShouldCaptureKeys: () => import_dom.activeElementShouldCaptureKeys,
100
101
  angleDistance: () => import_utils2.angleDistance,
101
102
  applyRotationToSnapshotShapes: () => import_rotation.applyRotationToSnapshotShapes,
102
103
  approximately: () => import_utils2.approximately,
@@ -175,6 +176,7 @@ __export(index_exports, {
175
176
  refreshPage: () => import_refreshPage.refreshPage,
176
177
  releasePointerCapture: () => import_dom.releasePointerCapture,
177
178
  resizeBox: () => import_resizeBox.resizeBox,
179
+ resizeScaled: () => import_resizeScaled.resizeScaled,
178
180
  rotateSelectionHandle: () => import_Box.rotateSelectionHandle,
179
181
  runtime: () => import_runtime.runtime,
180
182
  sanitizeId: () => import_useSafeId.sanitizeId,
@@ -241,6 +243,7 @@ var import_at2 = require("core-js/stable/string/at.js");
241
243
  var import_replace_all = require("core-js/stable/string/replace-all.js");
242
244
  var import_state = require("@tldraw/state");
243
245
  var import_state_react = require("@tldraw/state-react");
246
+ var import_resizeScaled = require("./lib/editor/shapes/shared/resizeScaled");
244
247
  var import_LocalIndexedDb = require("./lib/utils/sync/LocalIndexedDb");
245
248
  __reExport(index_exports, require("@tldraw/store"), module.exports);
246
249
  __reExport(index_exports, require("@tldraw/tlschema"), module.exports);
@@ -363,7 +366,7 @@ function debugEnableLicensing() {
363
366
  }
364
367
  (0, import_utils.registerTldrawLibraryVersion)(
365
368
  "@tldraw/editor",
366
- "3.8.0-internal.af5331ba6061",
369
+ "3.8.0",
367
370
  "cjs"
368
371
  );
369
372
  //# sourceMappingURL=index.js.map