@tldraw/editor 3.8.0-internal.a0a0d9e5162c → 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 (116) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/dist-cjs/index.d.ts +277 -64
  3. package/dist-cjs/index.js +15 -8
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +2 -5
  6. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  7. package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +2 -2
  8. package/dist-cjs/lib/config/createTLStore.js +4 -2
  9. package/dist-cjs/lib/config/createTLStore.js.map +2 -2
  10. package/dist-cjs/lib/editor/Editor.js +101 -24
  11. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  12. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
  13. package/dist-cjs/lib/editor/managers/TextManager.js +1 -0
  14. package/dist-cjs/lib/editor/managers/TextManager.js.map +2 -2
  15. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +13 -0
  16. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  17. package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js +66 -0
  18. package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js.map +7 -0
  19. package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
  20. package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
  21. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  22. package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
  23. package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
  24. package/dist-cjs/lib/exports/exportToSvg.js.map +2 -2
  25. package/dist-cjs/lib/exports/getSvgAsImage.js +83 -0
  26. package/dist-cjs/lib/exports/getSvgAsImage.js.map +7 -0
  27. package/dist-cjs/lib/exports/getSvgJsx.js +16 -3
  28. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  29. package/dist-cjs/lib/hooks/useCanvasEvents.js +19 -8
  30. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  31. package/dist-cjs/lib/hooks/useDocumentEvents.js +1 -3
  32. package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
  33. package/dist-cjs/lib/hooks/useLocalStore.js +1 -1
  34. package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
  35. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -0
  36. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +3 -3
  37. package/dist-cjs/lib/options.js +2 -2
  38. package/dist-cjs/lib/options.js.map +2 -2
  39. package/dist-cjs/lib/utils/browserCanvasMaxSize.js +75 -0
  40. package/dist-cjs/lib/utils/browserCanvasMaxSize.js.map +7 -0
  41. package/dist-cjs/lib/utils/dom.js +6 -0
  42. package/dist-cjs/lib/utils/dom.js.map +2 -2
  43. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -1
  44. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
  45. package/dist-cjs/version.js +3 -3
  46. package/dist-cjs/version.js.map +1 -1
  47. package/dist-esm/index.d.mts +277 -64
  48. package/dist-esm/index.mjs +9 -1
  49. package/dist-esm/index.mjs.map +2 -2
  50. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +2 -5
  51. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  52. package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
  53. package/dist-esm/lib/config/createTLStore.mjs +4 -2
  54. package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
  55. package/dist-esm/lib/editor/Editor.mjs +101 -24
  56. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  57. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
  58. package/dist-esm/lib/editor/managers/TextManager.mjs +1 -0
  59. package/dist-esm/lib/editor/managers/TextManager.mjs.map +2 -2
  60. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +13 -0
  61. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  62. package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs +46 -0
  63. package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs.map +7 -0
  64. package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
  65. package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
  66. package/dist-esm/lib/exports/exportToSvg.mjs.map +2 -2
  67. package/dist-esm/lib/exports/getSvgAsImage.mjs +63 -0
  68. package/dist-esm/lib/exports/getSvgAsImage.mjs.map +7 -0
  69. package/dist-esm/lib/exports/getSvgJsx.mjs +16 -3
  70. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  71. package/dist-esm/lib/hooks/useCanvasEvents.mjs +19 -8
  72. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  73. package/dist-esm/lib/hooks/useDocumentEvents.mjs +2 -4
  74. package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
  75. package/dist-esm/lib/hooks/useLocalStore.mjs +1 -1
  76. package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
  77. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -0
  78. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +3 -3
  79. package/dist-esm/lib/options.mjs +2 -2
  80. package/dist-esm/lib/options.mjs.map +2 -2
  81. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs +45 -0
  82. package/dist-esm/lib/utils/browserCanvasMaxSize.mjs.map +7 -0
  83. package/dist-esm/lib/utils/dom.mjs +6 -0
  84. package/dist-esm/lib/utils/dom.mjs.map +2 -2
  85. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -1
  86. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
  87. package/dist-esm/version.mjs +3 -3
  88. package/dist-esm/version.mjs.map +1 -1
  89. package/editor.css +2 -1
  90. package/package.json +22 -20
  91. package/src/index.ts +22 -1
  92. package/src/lib/components/default-components/DefaultCanvas.tsx +2 -5
  93. package/src/lib/config/TLSessionStateSnapshot.ts +3 -1
  94. package/src/lib/config/createTLStore.ts +4 -2
  95. package/src/lib/editor/Editor.ts +151 -59
  96. package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +4 -4
  97. package/src/lib/editor/managers/TextManager.ts +1 -0
  98. package/src/lib/editor/shapes/ShapeUtil.ts +49 -1
  99. package/src/lib/editor/shapes/shared/resizeScaled.ts +61 -0
  100. package/src/lib/editor/types/SvgExportContext.tsx +21 -0
  101. package/src/lib/editor/types/emit-types.ts +1 -0
  102. package/src/lib/editor/types/external-content.ts +104 -50
  103. package/src/lib/editor/types/misc-types.ts +55 -2
  104. package/src/lib/exports/StyleEmbedder.ts +1 -1
  105. package/src/lib/exports/exportToSvg.tsx +2 -2
  106. package/src/lib/exports/getSvgAsImage.ts +92 -0
  107. package/src/lib/exports/getSvgJsx.tsx +17 -2
  108. package/src/lib/hooks/useCanvasEvents.ts +20 -8
  109. package/src/lib/hooks/useDocumentEvents.ts +2 -11
  110. package/src/lib/hooks/useLocalStore.ts +1 -1
  111. package/src/lib/hooks/usePassThroughWheelEvents.ts +7 -0
  112. package/src/lib/options.ts +5 -2
  113. package/src/lib/utils/browserCanvasMaxSize.ts +65 -0
  114. package/src/lib/utils/dom.ts +12 -0
  115. package/src/lib/utils/sync/TLLocalSyncClient.ts +3 -1
  116. 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