tldraw 3.15.0-canary.c5c8f9bb0ec2 → 3.15.0-canary.d251cd98b4e1

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 (61) hide show
  1. package/dist-cjs/index.d.ts +77 -84
  2. package/dist-cjs/index.js +31 -30
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -11
  5. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  6. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +11 -1
  7. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
  8. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +1 -0
  9. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
  10. package/dist-cjs/lib/ui/components/menu-items.js +16 -0
  11. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  12. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +0 -2
  13. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  14. package/dist-cjs/lib/ui/context/actions.js +28 -1
  15. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  16. package/dist-cjs/lib/ui/context/events.js.map +2 -2
  17. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  18. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  19. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  20. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +4 -0
  21. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  22. package/dist-cjs/lib/ui/version.js +3 -3
  23. package/dist-cjs/lib/ui/version.js.map +1 -1
  24. package/dist-esm/index.d.mts +77 -84
  25. package/dist-esm/index.mjs +134 -132
  26. package/dist-esm/index.mjs.map +2 -2
  27. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -11
  28. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  29. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +11 -1
  30. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
  31. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +2 -0
  32. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
  33. package/dist-esm/lib/ui/components/menu-items.mjs +16 -0
  34. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  35. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +0 -2
  36. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  37. package/dist-esm/lib/ui/context/actions.mjs +28 -1
  38. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  39. package/dist-esm/lib/ui/context/events.mjs.map +2 -2
  40. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  41. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  42. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +4 -0
  43. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  44. package/dist-esm/lib/ui/version.mjs +3 -3
  45. package/dist-esm/lib/ui/version.mjs.map +1 -1
  46. package/package.json +3 -3
  47. package/src/index.ts +159 -158
  48. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -12
  49. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +8 -0
  50. package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -0
  51. package/src/lib/ui/components/menu-items.tsx +17 -0
  52. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +0 -2
  53. package/src/lib/ui/context/actions.tsx +29 -1
  54. package/src/lib/ui/context/events.tsx +2 -0
  55. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
  56. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +4 -0
  57. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +4 -0
  58. package/src/lib/ui/version.ts +3 -3
  59. package/src/test/Editor.test.tsx +68 -1
  60. package/src/test/commands/clipboard.test.ts +1 -1
  61. package/src/test/editor.test.ts +0 -77
package/src/index.ts CHANGED
@@ -24,7 +24,6 @@ export { usePrefersReducedMotion } from './lib/shapes/shared/usePrefersReducedMo
24
24
  export { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from './lib/ui/components/A11y'
25
25
  export { ColorSchemeMenu } from './lib/ui/components/ColorSchemeMenu'
26
26
  export { DefaultDialogs } from './lib/ui/components/Dialogs'
27
- export { DefaultToasts } from './lib/ui/components/Toasts'
28
27
  export {
29
28
  TldrawUiMenuActionCheckboxItem,
30
29
  type TLUiMenuActionCheckboxItemProps,
@@ -37,11 +36,10 @@ export {
37
36
  TldrawUiMenuToolItem,
38
37
  type TLUiMenuToolItemProps,
39
38
  } from './lib/ui/components/primitives/menus/TldrawUiMenuToolItem'
39
+ export { DefaultToasts } from './lib/ui/components/Toasts'
40
40
  export { TldrawUiTranslationProvider } from './lib/ui/hooks/useTranslation/useTranslation'
41
41
  // eslint-disable-next-line local/no-export-star
42
42
  export * from '@tldraw/editor'
43
- export { Tldraw, type TLComponents, type TldrawBaseProps, type TldrawProps } from './lib/Tldraw'
44
- export { TldrawImage, type TldrawImageProps } from './lib/TldrawImage'
45
43
  export { ArrowBindingUtil } from './lib/bindings/arrow/ArrowBindingUtil'
46
44
  export { TldrawHandles } from './lib/canvas/TldrawHandles'
47
45
  export { TldrawArrowHints, TldrawOverlays } from './lib/canvas/TldrawOverlays'
@@ -59,11 +57,11 @@ export {
59
57
  type TLEmbedShapePermissions,
60
58
  } from './lib/defaultEmbedDefinitions'
61
59
  export {
62
- DEFAULT_MAX_ASSET_SIZE,
63
- DEFAULT_MAX_IMAGE_DIMENSION,
64
60
  centerSelectionAroundPoint,
65
61
  createEmptyBookmarkShape,
66
62
  createShapesForAssets,
63
+ DEFAULT_MAX_ASSET_SIZE,
64
+ DEFAULT_MAX_IMAGE_DIMENSION,
67
65
  defaultHandleExternalEmbedContent,
68
66
  defaultHandleExternalExcalidrawContent,
69
67
  defaultHandleExternalFileAsset,
@@ -82,8 +80,6 @@ export { defaultShapeTools } from './lib/defaultShapeTools'
82
80
  export { defaultShapeUtils } from './lib/defaultShapeUtils'
83
81
  export { registerDefaultSideEffects } from './lib/defaultSideEffects'
84
82
  export { defaultTools } from './lib/defaultTools'
85
- export { ArrowShapeTool } from './lib/shapes/arrow/ArrowShapeTool'
86
- export { ArrowShapeUtil } from './lib/shapes/arrow/ArrowShapeUtil'
87
83
  export {
88
84
  type ArrowShapeOptions,
89
85
  type TLArcArrowInfo,
@@ -93,6 +89,8 @@ export {
93
89
  type TLElbowArrowInfo,
94
90
  type TLStraightArrowInfo,
95
91
  } from './lib/shapes/arrow/arrow-types'
92
+ export { ArrowShapeTool } from './lib/shapes/arrow/ArrowShapeTool'
93
+ export { ArrowShapeUtil } from './lib/shapes/arrow/ArrowShapeUtil'
96
94
  export {
97
95
  type ElbowArrowBox,
98
96
  type ElbowArrowBoxEdges,
@@ -132,17 +130,6 @@ export { LineShapeTool } from './lib/shapes/line/LineShapeTool'
132
130
  export { LineShapeUtil } from './lib/shapes/line/LineShapeUtil'
133
131
  export { NoteShapeTool } from './lib/shapes/note/NoteShapeTool'
134
132
  export { NoteShapeUtil, type NoteShapeOptions } from './lib/shapes/note/NoteShapeUtil'
135
- export {
136
- PlainTextLabel,
137
- TextLabel,
138
- type PlainTextLabelProps,
139
- } from './lib/shapes/shared/PlainTextLabel'
140
- export {
141
- RichTextLabel,
142
- RichTextSVG,
143
- type RichTextLabelProps,
144
- type RichTextSVGProps,
145
- } from './lib/shapes/shared/RichTextLabel'
146
133
  export {
147
134
  ASPECT_RATIO_OPTIONS,
148
135
  ASPECT_RATIO_TO_VALUE,
@@ -161,11 +148,22 @@ export {
161
148
  TEXT_PROPS,
162
149
  } from './lib/shapes/shared/default-shape-constants'
163
150
  export {
164
- DefaultFontFaces,
165
151
  allDefaultFontFaces,
152
+ DefaultFontFaces,
166
153
  type TLDefaultFont,
167
154
  type TLDefaultFonts,
168
155
  } from './lib/shapes/shared/defaultFonts'
156
+ export {
157
+ PlainTextLabel,
158
+ TextLabel,
159
+ type PlainTextLabelProps,
160
+ } from './lib/shapes/shared/PlainTextLabel'
161
+ export {
162
+ RichTextLabel,
163
+ RichTextSVG,
164
+ type RichTextLabelProps,
165
+ type RichTextSVGProps,
166
+ } from './lib/shapes/shared/RichTextLabel'
169
167
  export { useDefaultColorTheme } from './lib/shapes/shared/useDefaultColorTheme'
170
168
  export { useEditablePlainText, useEditableText } from './lib/shapes/shared/useEditablePlainText'
171
169
  export { useEditableRichText } from './lib/shapes/shared/useEditableRichText'
@@ -180,12 +178,13 @@ export { TextShapeTool } from './lib/shapes/text/TextShapeTool'
180
178
  export { TextShapeUtil, type TextShapeOptions } from './lib/shapes/text/TextShapeUtil'
181
179
  export { VideoShapeUtil, type VideoShapeOptions } from './lib/shapes/video/VideoShapeUtil'
182
180
  export { type StyleValuesForUi } from './lib/styles'
181
+ export { Tldraw, type TLComponents, type TldrawBaseProps, type TldrawProps } from './lib/Tldraw'
182
+ export { TldrawImage, type TldrawImageProps } from './lib/TldrawImage'
183
183
  export { EraserTool } from './lib/tools/EraserTool/EraserTool'
184
184
  export { HandTool } from './lib/tools/HandTool/HandTool'
185
185
  export { LaserTool } from './lib/tools/LaserTool/LaserTool'
186
186
  export { SelectTool } from './lib/tools/SelectTool/SelectTool'
187
187
  export { ZoomTool } from './lib/tools/ZoomTool/ZoomTool'
188
- export { TldrawUi, type TldrawUiProps } from './lib/ui/TldrawUi'
189
188
  export {
190
189
  setDefaultUiAssetUrls,
191
190
  type TLUiAssetUrlOverrides,
@@ -223,6 +222,11 @@ export {
223
222
  type ExampleDialogProps,
224
223
  } from './lib/ui/components/DebugMenu/DefaultDebugMenuContent'
225
224
  export { DefaultMenuPanel } from './lib/ui/components/DefaultMenuPanel'
225
+ export {
226
+ DefaultHelperButtons,
227
+ type TLUiHelperButtonsProps,
228
+ } from './lib/ui/components/HelperButtons/DefaultHelperButtons'
229
+ export { DefaultHelperButtonsContent } from './lib/ui/components/HelperButtons/DefaultHelperButtonsContent'
226
230
  export {
227
231
  DefaultHelpMenu,
228
232
  type TLUiHelpMenuProps,
@@ -231,11 +235,6 @@ export {
231
235
  DefaultHelpMenuContent,
232
236
  KeyboardShortcutsMenuItem,
233
237
  } from './lib/ui/components/HelpMenu/DefaultHelpMenuContent'
234
- export {
235
- DefaultHelperButtons,
236
- type TLUiHelperButtonsProps,
237
- } from './lib/ui/components/HelperButtons/DefaultHelperButtons'
238
- export { DefaultHelperButtonsContent } from './lib/ui/components/HelperButtons/DefaultHelperButtonsContent'
239
238
  export {
240
239
  DefaultKeyboardShortcutsDialog,
241
240
  type TLUiKeyboardShortcutsDialogProps,
@@ -256,116 +255,6 @@ export {
256
255
  UndoRedoGroup,
257
256
  ViewSubmenu,
258
257
  } from './lib/ui/components/MainMenu/DefaultMainMenuContent'
259
- export { DefaultMinimap } from './lib/ui/components/Minimap/DefaultMinimap'
260
- export { MobileStylePanel } from './lib/ui/components/MobileStylePanel'
261
- export { DefaultNavigationPanel } from './lib/ui/components/NavigationPanel/DefaultNavigationPanel'
262
- export { OfflineIndicator } from './lib/ui/components/OfflineIndicator/OfflineIndicator'
263
- export { DefaultPageMenu } from './lib/ui/components/PageMenu/DefaultPageMenu'
264
- export { PageItemInput, type PageItemInputProps } from './lib/ui/components/PageMenu/PageItemInput'
265
- export {
266
- PageItemSubmenu,
267
- type PageItemSubmenuProps,
268
- } from './lib/ui/components/PageMenu/PageItemSubmenu'
269
- export {
270
- DefaultQuickActions,
271
- type TLUiQuickActionsProps,
272
- } from './lib/ui/components/QuickActions/DefaultQuickActions'
273
- export { DefaultQuickActionsContent } from './lib/ui/components/QuickActions/DefaultQuickActionsContent'
274
- export { DefaultSharePanel } from './lib/ui/components/SharePanel/DefaultSharePanel'
275
- export { PeopleMenu, type PeopleMenuProps } from './lib/ui/components/SharePanel/PeopleMenu'
276
- export { Spinner } from './lib/ui/components/Spinner'
277
- export {
278
- DefaultStylePanel,
279
- type TLUiStylePanelProps,
280
- } from './lib/ui/components/StylePanel/DefaultStylePanel'
281
- export {
282
- ArrowheadStylePickerSet,
283
- CommonStylePickerSet,
284
- DefaultStylePanelContent,
285
- GeoStylePickerSet,
286
- OpacitySlider,
287
- SplineStylePickerSet,
288
- TextStylePickerSet,
289
- type StylePickerSetProps,
290
- type TLUiStylePanelContentProps,
291
- type ThemeStylePickerSetProps,
292
- } from './lib/ui/components/StylePanel/DefaultStylePanelContent'
293
- export {
294
- DefaultImageToolbar,
295
- type TLUiImageToolbarProps,
296
- } from './lib/ui/components/Toolbar/DefaultImageToolbar'
297
- export {
298
- DefaultImageToolbarContent,
299
- type DefaultImageToolbarContentProps,
300
- } from './lib/ui/components/Toolbar/DefaultImageToolbarContent'
301
- export {
302
- DefaultRichTextToolbar,
303
- type TLUiRichTextToolbarProps,
304
- } from './lib/ui/components/Toolbar/DefaultRichTextToolbar'
305
- export {
306
- DefaultRichTextToolbarContent,
307
- type DefaultRichTextToolbarContentProps,
308
- } from './lib/ui/components/Toolbar/DefaultRichTextToolbarContent'
309
- export {
310
- DefaultToolbar,
311
- type DefaultToolbarProps,
312
- } from './lib/ui/components/Toolbar/DefaultToolbar'
313
- export {
314
- ArrowDownToolbarItem,
315
- ArrowLeftToolbarItem,
316
- ArrowRightToolbarItem,
317
- ArrowToolbarItem,
318
- ArrowUpToolbarItem,
319
- AssetToolbarItem,
320
- CheckBoxToolbarItem,
321
- CloudToolbarItem,
322
- DefaultToolbarContent,
323
- DiamondToolbarItem,
324
- DrawToolbarItem,
325
- EllipseToolbarItem,
326
- EraserToolbarItem,
327
- FrameToolbarItem,
328
- HandToolbarItem,
329
- HexagonToolbarItem,
330
- HighlightToolbarItem,
331
- LaserToolbarItem,
332
- LineToolbarItem,
333
- NoteToolbarItem,
334
- OvalToolbarItem,
335
- RectangleToolbarItem,
336
- RhombusToolbarItem,
337
- SelectToolbarItem,
338
- StarToolbarItem,
339
- TextToolbarItem,
340
- ToolbarItem,
341
- TrapezoidToolbarItem,
342
- TriangleToolbarItem,
343
- XBoxToolbarItem,
344
- useIsToolSelected,
345
- type ToolbarItemProps,
346
- } from './lib/ui/components/Toolbar/DefaultToolbarContent'
347
- export {
348
- DefaultVideoToolbar,
349
- type TLUiVideoToolbarProps,
350
- } from './lib/ui/components/Toolbar/DefaultVideoToolbar'
351
- export {
352
- DefaultVideoToolbarContent,
353
- type DefaultVideoToolbarContentProps,
354
- } from './lib/ui/components/Toolbar/DefaultVideoToolbarContent'
355
- export {
356
- OverflowingToolbar,
357
- type OverflowingToolbarProps,
358
- } from './lib/ui/components/Toolbar/OverflowingToolbar'
359
- export {
360
- CenteredTopPanelContainer,
361
- type CenteredTopPanelContainerProps,
362
- } from './lib/ui/components/TopPanel/CenteredTopPanelContainer'
363
- export { DefaultTopPanel } from './lib/ui/components/TopPanel/DefaultTopPanel'
364
- export {
365
- DefaultZoomMenu,
366
- type TLUiZoomMenuProps,
367
- } from './lib/ui/components/ZoomMenu/DefaultZoomMenu'
368
- export { DefaultZoomMenuContent } from './lib/ui/components/ZoomMenu/DefaultZoomMenuContent'
369
258
  export {
370
259
  ArrangeMenuSubmenu,
371
260
  ClipboardMenuGroup,
@@ -394,6 +283,7 @@ export {
394
283
  ToggleEdgeScrollingItem,
395
284
  ToggleFocusModeItem,
396
285
  ToggleGridItem,
286
+ ToggleKeyboardShortcutsItem,
397
287
  ToggleLockMenuItem,
398
288
  TogglePasteAtCursorItem,
399
289
  ToggleReduceMotionItem,
@@ -407,6 +297,16 @@ export {
407
297
  ZoomToFitMenuItem,
408
298
  ZoomToSelectionMenuItem,
409
299
  } from './lib/ui/components/menu-items'
300
+ export { DefaultMinimap } from './lib/ui/components/Minimap/DefaultMinimap'
301
+ export { MobileStylePanel } from './lib/ui/components/MobileStylePanel'
302
+ export { DefaultNavigationPanel } from './lib/ui/components/NavigationPanel/DefaultNavigationPanel'
303
+ export { OfflineIndicator } from './lib/ui/components/OfflineIndicator/OfflineIndicator'
304
+ export { DefaultPageMenu } from './lib/ui/components/PageMenu/DefaultPageMenu'
305
+ export { PageItemInput, type PageItemInputProps } from './lib/ui/components/PageMenu/PageItemInput'
306
+ export {
307
+ PageItemSubmenu,
308
+ type PageItemSubmenuProps,
309
+ } from './lib/ui/components/PageMenu/PageItemSubmenu'
410
310
  export {
411
311
  TldrawUiButton,
412
312
  type TLUiButtonProps,
@@ -423,6 +323,27 @@ export {
423
323
  TldrawUiButtonLabel,
424
324
  type TLUiButtonLabelProps,
425
325
  } from './lib/ui/components/primitives/Button/TldrawUiButtonLabel'
326
+ export {
327
+ TldrawUiMenuCheckboxItem,
328
+ type TLUiMenuCheckboxItemProps,
329
+ } from './lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem'
330
+ export {
331
+ TldrawUiMenuContextProvider,
332
+ type TLUiMenuContextProviderProps,
333
+ type TLUiMenuContextType,
334
+ } from './lib/ui/components/primitives/menus/TldrawUiMenuContext'
335
+ export {
336
+ TldrawUiMenuGroup,
337
+ type TLUiMenuGroupProps,
338
+ } from './lib/ui/components/primitives/menus/TldrawUiMenuGroup'
339
+ export {
340
+ TldrawUiMenuItem,
341
+ type TLUiMenuItemProps,
342
+ } from './lib/ui/components/primitives/menus/TldrawUiMenuItem'
343
+ export {
344
+ TldrawUiMenuSubmenu,
345
+ type TLUiMenuSubmenuProps,
346
+ } from './lib/ui/components/primitives/menus/TldrawUiMenuSubmenu'
426
347
  export {
427
348
  TldrawUiButtonPicker,
428
349
  type TLUiButtonPickerProps,
@@ -484,31 +405,106 @@ export {
484
405
  type TLUiToolbarToggleItemProps,
485
406
  } from './lib/ui/components/primitives/TldrawUiToolbar'
486
407
  export {
487
- TldrawUiMenuCheckboxItem,
488
- type TLUiMenuCheckboxItemProps,
489
- } from './lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem'
408
+ DefaultQuickActions,
409
+ type TLUiQuickActionsProps,
410
+ } from './lib/ui/components/QuickActions/DefaultQuickActions'
411
+ export { DefaultQuickActionsContent } from './lib/ui/components/QuickActions/DefaultQuickActionsContent'
412
+ export { DefaultSharePanel } from './lib/ui/components/SharePanel/DefaultSharePanel'
413
+ export { PeopleMenu, type PeopleMenuProps } from './lib/ui/components/SharePanel/PeopleMenu'
414
+ export { Spinner } from './lib/ui/components/Spinner'
490
415
  export {
491
- TldrawUiMenuContextProvider,
492
- type TLUiMenuContextProviderProps,
493
- type TLUiMenuContextType,
494
- } from './lib/ui/components/primitives/menus/TldrawUiMenuContext'
416
+ DefaultStylePanel,
417
+ type TLUiStylePanelProps,
418
+ } from './lib/ui/components/StylePanel/DefaultStylePanel'
495
419
  export {
496
- TldrawUiMenuGroup,
497
- type TLUiMenuGroupProps,
498
- } from './lib/ui/components/primitives/menus/TldrawUiMenuGroup'
420
+ ArrowheadStylePickerSet,
421
+ CommonStylePickerSet,
422
+ DefaultStylePanelContent,
423
+ GeoStylePickerSet,
424
+ OpacitySlider,
425
+ SplineStylePickerSet,
426
+ TextStylePickerSet,
427
+ type StylePickerSetProps,
428
+ type ThemeStylePickerSetProps,
429
+ type TLUiStylePanelContentProps,
430
+ } from './lib/ui/components/StylePanel/DefaultStylePanelContent'
499
431
  export {
500
- TldrawUiMenuItem,
501
- type TLUiMenuItemProps,
502
- } from './lib/ui/components/primitives/menus/TldrawUiMenuItem'
432
+ DefaultImageToolbar,
433
+ type TLUiImageToolbarProps,
434
+ } from './lib/ui/components/Toolbar/DefaultImageToolbar'
503
435
  export {
504
- TldrawUiMenuSubmenu,
505
- type TLUiMenuSubmenuProps,
506
- } from './lib/ui/components/primitives/menus/TldrawUiMenuSubmenu'
507
- export { PORTRAIT_BREAKPOINT } from './lib/ui/constants'
436
+ DefaultImageToolbarContent,
437
+ type DefaultImageToolbarContentProps,
438
+ } from './lib/ui/components/Toolbar/DefaultImageToolbarContent'
508
439
  export {
509
- TldrawUiContextProvider,
510
- type TLUiContextProviderProps,
511
- } from './lib/ui/context/TldrawUiContextProvider'
440
+ DefaultRichTextToolbar,
441
+ type TLUiRichTextToolbarProps,
442
+ } from './lib/ui/components/Toolbar/DefaultRichTextToolbar'
443
+ export {
444
+ DefaultRichTextToolbarContent,
445
+ type DefaultRichTextToolbarContentProps,
446
+ } from './lib/ui/components/Toolbar/DefaultRichTextToolbarContent'
447
+ export {
448
+ DefaultToolbar,
449
+ type DefaultToolbarProps,
450
+ } from './lib/ui/components/Toolbar/DefaultToolbar'
451
+ export {
452
+ ArrowDownToolbarItem,
453
+ ArrowLeftToolbarItem,
454
+ ArrowRightToolbarItem,
455
+ ArrowToolbarItem,
456
+ ArrowUpToolbarItem,
457
+ AssetToolbarItem,
458
+ CheckBoxToolbarItem,
459
+ CloudToolbarItem,
460
+ DefaultToolbarContent,
461
+ DiamondToolbarItem,
462
+ DrawToolbarItem,
463
+ EllipseToolbarItem,
464
+ EraserToolbarItem,
465
+ FrameToolbarItem,
466
+ HandToolbarItem,
467
+ HexagonToolbarItem,
468
+ HighlightToolbarItem,
469
+ LaserToolbarItem,
470
+ LineToolbarItem,
471
+ NoteToolbarItem,
472
+ OvalToolbarItem,
473
+ RectangleToolbarItem,
474
+ RhombusToolbarItem,
475
+ SelectToolbarItem,
476
+ StarToolbarItem,
477
+ TextToolbarItem,
478
+ ToolbarItem,
479
+ TrapezoidToolbarItem,
480
+ TriangleToolbarItem,
481
+ useIsToolSelected,
482
+ XBoxToolbarItem,
483
+ type ToolbarItemProps,
484
+ } from './lib/ui/components/Toolbar/DefaultToolbarContent'
485
+ export {
486
+ DefaultVideoToolbar,
487
+ type TLUiVideoToolbarProps,
488
+ } from './lib/ui/components/Toolbar/DefaultVideoToolbar'
489
+ export {
490
+ DefaultVideoToolbarContent,
491
+ type DefaultVideoToolbarContentProps,
492
+ } from './lib/ui/components/Toolbar/DefaultVideoToolbarContent'
493
+ export {
494
+ OverflowingToolbar,
495
+ type OverflowingToolbarProps,
496
+ } from './lib/ui/components/Toolbar/OverflowingToolbar'
497
+ export {
498
+ CenteredTopPanelContainer,
499
+ type CenteredTopPanelContainerProps,
500
+ } from './lib/ui/components/TopPanel/CenteredTopPanelContainer'
501
+ export { DefaultTopPanel } from './lib/ui/components/TopPanel/DefaultTopPanel'
502
+ export {
503
+ DefaultZoomMenu,
504
+ type TLUiZoomMenuProps,
505
+ } from './lib/ui/components/ZoomMenu/DefaultZoomMenu'
506
+ export { DefaultZoomMenuContent } from './lib/ui/components/ZoomMenu/DefaultZoomMenuContent'
507
+ export { PORTRAIT_BREAKPOINT } from './lib/ui/constants'
512
508
  export {
513
509
  TldrawUiA11yProvider,
514
510
  useA11y,
@@ -554,6 +550,10 @@ export {
554
550
  type TLUiEventMap,
555
551
  type TLUiEventSource,
556
552
  } from './lib/ui/context/events'
553
+ export {
554
+ TldrawUiContextProvider,
555
+ type TLUiContextProviderProps,
556
+ } from './lib/ui/context/TldrawUiContextProvider'
557
557
  export {
558
558
  TldrawUiToastsProvider,
559
559
  useToasts,
@@ -592,6 +592,7 @@ export {
592
592
  } from './lib/ui/hooks/useTranslation/useTranslation'
593
593
  export { type TLUiIconType } from './lib/ui/icon-types'
594
594
  export { useDefaultHelpers, type TLUiOverrideHelpers, type TLUiOverrides } from './lib/ui/overrides'
595
+ export { TldrawUi, type TldrawUiProps } from './lib/ui/TldrawUi'
595
596
  export { containBoxSize, downsizeImage, type BoxWidthHeight } from './lib/utils/assets/assets'
596
597
  export { preloadFont, type TLTypeFace } from './lib/utils/assets/preload-font'
597
598
  export { getEmbedInfo, type TLEmbedResult } from './lib/utils/embeds/embeds'
@@ -606,8 +607,8 @@ export {
606
607
  type TLEditorAssetUrls,
607
608
  } from './lib/utils/static-assets/assetUrls'
608
609
  export {
609
- KeyboardShiftEnterTweakExtension,
610
610
  defaultAddFontsFromNode,
611
+ KeyboardShiftEnterTweakExtension,
611
612
  renderHtmlFromRichText,
612
613
  renderHtmlFromRichTextForMeasurement,
613
614
  renderPlaintextFromRichText,
@@ -617,6 +618,7 @@ export {
617
618
  export { truncateStringWithEllipsis } from './lib/utils/text/text'
618
619
  export { TextDirection } from './lib/utils/text/textDirection'
619
620
  export {
621
+ buildFromV1Document,
620
622
  TLV1AlignStyle,
621
623
  TLV1AssetType,
622
624
  TLV1ColorStyle,
@@ -625,7 +627,6 @@ export {
625
627
  TLV1FontStyle,
626
628
  TLV1ShapeType,
627
629
  TLV1SizeStyle,
628
- buildFromV1Document,
629
630
  type TLV1ArrowBinding,
630
631
  type TLV1ArrowShape,
631
632
  type TLV1Asset,
@@ -653,11 +654,11 @@ export {
653
654
  type TLV1VideoShape,
654
655
  } from './lib/utils/tldr/buildFromV1Document'
655
656
  export {
656
- TLDRAW_FILE_EXTENSION,
657
657
  parseAndLoadDocument,
658
658
  parseTldrawJsonFile,
659
659
  serializeTldrawJson,
660
660
  serializeTldrawJsonBlob,
661
+ TLDRAW_FILE_EXTENSION,
661
662
  type TldrawFile,
662
663
  type TldrawFileParseError,
663
664
  } from './lib/utils/tldr/file'
@@ -303,33 +303,26 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
303
303
  }
304
304
 
305
305
  function getTextSize(editor: Editor, props: TLTextShape['props']) {
306
- const { font, richText, autoSize, size, w } = props
306
+ const { font, richText, size, w } = props
307
307
 
308
- const minWidth = autoSize ? 16 : Math.max(16, w)
308
+ const minWidth = 16
309
309
  const fontSize = FONT_SIZES[size]
310
310
 
311
- const cw = autoSize
312
- ? null
313
- : // `measureText` floors the number so we need to do the same here to avoid issues.
314
- Math.floor(Math.max(minWidth, w))
311
+ const maybeFixedWidth = props.autoSize ? null : Math.max(minWidth, Math.floor(w))
315
312
 
316
313
  const html = renderHtmlFromRichTextForMeasurement(editor, richText)
317
314
  const result = editor.textMeasure.measureHtml(html, {
318
315
  ...TEXT_PROPS,
319
316
  fontFamily: FONT_FAMILIES[font],
320
317
  fontSize: fontSize,
321
- maxWidth: cw,
318
+ maxWidth: maybeFixedWidth,
322
319
  })
323
320
 
324
321
  // If we're autosizing the measureText will essentially `Math.floor`
325
322
  // the numbers so `19` rather than `19.3`, this means we must +1 to
326
323
  // whatever we get to avoid wrapping.
327
- if (autoSize) {
328
- result.w += 1
329
- }
330
-
331
324
  return {
332
- width: Math.max(minWidth, result.w),
325
+ width: maybeFixedWidth ?? Math.max(minWidth, result.w + 1),
333
326
  height: Math.max(fontSize, result.h),
334
327
  }
335
328
  }
@@ -213,6 +213,14 @@ export function DefaultKeyboardShortcutsDialogContent() {
213
213
  <TldrawUiMenuActionItem actionId="enlarge-shapes" />
214
214
  <TldrawUiMenuActionItem actionId="shrink-shapes" />
215
215
  <TldrawUiMenuActionItem actionId="a11y-repeat-shape-announce" />
216
+ <TldrawUiMenuItem
217
+ id="a11y-open-keyboard-shortcuts"
218
+ label="a11y.open-keyboard-shortcuts"
219
+ kbd="cmd+alt+/"
220
+ onSelect={() => {
221
+ /* do nothing */
222
+ }}
223
+ />
216
224
  </TldrawUiMenuGroup>
217
225
  {showCollaborationUi && (
218
226
  <TldrawUiMenuGroup label="shortcuts-dialog.collaboration" id="collaboration">
@@ -19,6 +19,7 @@ import {
19
19
  ToggleEdgeScrollingItem,
20
20
  ToggleFocusModeItem,
21
21
  ToggleGridItem,
22
+ ToggleKeyboardShortcutsItem,
22
23
  ToggleLockMenuItem,
23
24
  TogglePasteAtCursorItem,
24
25
  ToggleReduceMotionItem,
@@ -161,6 +162,7 @@ export function PreferencesGroup() {
161
162
  <ToggleFocusModeItem />
162
163
  <ToggleEdgeScrollingItem />
163
164
  <ToggleReduceMotionItem />
165
+ <ToggleKeyboardShortcutsItem />
164
166
  <ToggleDynamicSizeModeItem />
165
167
  <TogglePasteAtCursorItem />
166
168
  <ToggleDebugModeItem />
@@ -634,6 +634,23 @@ export function ToggleReduceMotionItem() {
634
634
  )
635
635
  }
636
636
 
637
+ /** @public @react */
638
+ export function ToggleKeyboardShortcutsItem() {
639
+ const editor = useEditor()
640
+ const keyboardShortcuts = useValue(
641
+ 'keyboardShortcuts',
642
+ () => editor.user.getAreKeyboardShortcutsEnabled(),
643
+ [editor]
644
+ )
645
+
646
+ return (
647
+ <TldrawUiMenuActionCheckboxItem
648
+ actionId="toggle-keyboard-shortcuts"
649
+ checked={keyboardShortcuts}
650
+ />
651
+ )
652
+ }
653
+
637
654
  /** @public @react */
638
655
  export function ToggleDebugModeItem() {
639
656
  const editor = useEditor()
@@ -218,7 +218,6 @@ export function TldrawUiMenuItem<
218
218
  preventDefault(e)
219
219
  onSelect('toolbar')
220
220
  }}
221
- role="option"
222
221
  title={titleStr}
223
222
  type="tool"
224
223
  >
@@ -237,7 +236,6 @@ export function TldrawUiMenuItem<
237
236
  data-value={id}
238
237
  disabled={disabled}
239
238
  onClick={() => onSelect('toolbar')}
240
- role="option"
241
239
  title={titleStr}
242
240
  type="icon"
243
241
  >
@@ -28,6 +28,7 @@ import { fitFrameToContent, removeFrame } from '../../utils/frames/frames'
28
28
  import { generateShapeAnnouncementMessage } from '../components/A11y'
29
29
  import { EditLinkDialog } from '../components/EditLinkDialog'
30
30
  import { EmbedDialog } from '../components/EmbedDialog'
31
+ import { DefaultKeyboardShortcutsDialog } from '../components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog'
31
32
  import { useShowCollaborationUi } from '../hooks/useCollaborationStatus'
32
33
  import { flattenShapesToImages } from '../hooks/useFlatten'
33
34
  import { TLUiTranslationKey } from '../hooks/useTranslation/TLUiTranslationKey'
@@ -48,6 +49,7 @@ export interface TLUiActionItem<
48
49
  label?: TransationKey | { [key: string]: TransationKey }
49
50
  readonlyOk?: boolean
50
51
  checkbox?: boolean
52
+ isRequiredA11yAction?: boolean
51
53
  onSelect(source: TLUiEventSource): Promise<void> | void
52
54
  }
53
55
 
@@ -168,6 +170,15 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
168
170
  helpers.addDialog({ component: EmbedDialog })
169
171
  },
170
172
  },
173
+ {
174
+ id: 'open-kbd-shortcuts',
175
+ label: 'action.open-kbd-shortcuts',
176
+ kbd: 'cmd+alt+/,ctrl+alt+/',
177
+ onSelect(source) {
178
+ trackEvent('open-kbd-shortcuts', { source })
179
+ helpers.addDialog({ component: DefaultKeyboardShortcutsDialog })
180
+ },
181
+ },
171
182
  {
172
183
  id: 'insert-media',
173
184
  label: 'action.insert-media',
@@ -502,7 +513,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
502
513
  }
503
514
  }
504
515
 
505
- if (!editor.canCreateShapes(ids)) return
506
516
  editor.markHistoryStoppingPoint('duplicate shapes')
507
517
  editor.duplicateShapes(ids, offset)
508
518
 
@@ -1234,6 +1244,21 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1234
1244
  },
1235
1245
  checkbox: true,
1236
1246
  },
1247
+ {
1248
+ id: 'toggle-keyboard-shortcuts',
1249
+ label: {
1250
+ default: 'action.toggle-keyboard-shortcuts',
1251
+ menu: 'action.toggle-keyboard-shortcuts.menu',
1252
+ },
1253
+ readonlyOk: true,
1254
+ onSelect(source) {
1255
+ trackEvent('toggle-keyboard-shortcuts', { source })
1256
+ editor.user.updateUserPreferences({
1257
+ areKeyboardShortcutsEnabled: !editor.user.getAreKeyboardShortcutsEnabled(),
1258
+ })
1259
+ },
1260
+ checkbox: true,
1261
+ },
1237
1262
  {
1238
1263
  id: 'toggle-edge-scrolling',
1239
1264
  label: {
@@ -1530,6 +1555,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1530
1555
  id: 'adjust-shape-styles',
1531
1556
  label: 'a11y.adjust-shape-styles',
1532
1557
  kbd: 'cmd+Enter,ctrl+Enter',
1558
+ isRequiredA11yAction: true,
1533
1559
  onSelect: async (source) => {
1534
1560
  if (!canApplySelectionAction()) return
1535
1561
 
@@ -1543,6 +1569,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1543
1569
  {
1544
1570
  id: 'a11y-open-context-menu',
1545
1571
  kbd: 'cmd+shift+Enter,ctrl+shift+Enter',
1572
+ isRequiredA11yAction: true,
1546
1573
  readonlyOk: true,
1547
1574
  onSelect: async (source) => {
1548
1575
  if (!canApplySelectionAction()) return
@@ -1595,6 +1622,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
1595
1622
  id: 'a11y-repeat-shape-announce',
1596
1623
  kbd: 'alt+r',
1597
1624
  label: 'a11y.repeat-shape',
1625
+ isRequiredA11yAction: true,
1598
1626
  readonlyOk: true,
1599
1627
  onSelect: async (source) => {
1600
1628
  const selectedShapeIds = editor.getSelectedShapeIds()