tldraw 3.16.0-next.34fddf633325 → 3.16.0-next.b88d494af370

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 (229) hide show
  1. package/dist-cjs/index.d.ts +102 -5
  2. package/dist-cjs/index.js +8 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
  5. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  6. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
  7. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  9. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  10. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
  11. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  13. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  14. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
  15. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  17. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  18. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
  19. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
  21. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
  22. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
  23. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  24. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
  25. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
  26. package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
  27. package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
  29. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
  31. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  32. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
  33. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  35. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  36. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  37. package/dist-cjs/lib/ui/TldrawUi.js +14 -0
  38. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  39. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +12 -3
  40. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  41. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
  42. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
  43. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  44. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  45. package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
  46. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  47. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +1 -1
  48. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
  49. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +2 -1
  50. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  51. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
  52. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
  53. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
  54. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
  55. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +14 -14
  56. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  57. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
  58. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
  59. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +26 -25
  60. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
  61. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
  62. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  63. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -21
  64. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  65. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +189 -80
  66. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  67. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -2
  68. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  69. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +5 -16
  70. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
  71. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
  72. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  73. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
  74. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
  75. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +19 -4
  76. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  77. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +153 -152
  78. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  79. package/dist-cjs/lib/ui/components/primitives/layout.js +76 -0
  80. package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
  81. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  82. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
  83. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  84. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +153 -20
  85. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  86. package/dist-cjs/lib/ui/context/events.js.map +2 -2
  87. package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
  88. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  89. package/dist-cjs/lib/ui/version.js +3 -3
  90. package/dist-cjs/lib/ui/version.js.map +1 -1
  91. package/dist-esm/index.d.mts +102 -5
  92. package/dist-esm/index.mjs +15 -1
  93. package/dist-esm/index.mjs.map +2 -2
  94. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  95. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  96. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
  97. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  98. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  99. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  100. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
  101. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  102. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  103. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  104. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +13 -12
  105. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  106. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  107. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  108. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
  109. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  110. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
  111. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
  112. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
  113. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  114. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
  115. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
  116. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
  117. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
  118. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
  119. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  120. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +5 -4
  121. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  122. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
  123. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  124. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  125. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  126. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  127. package/dist-esm/lib/ui/TldrawUi.mjs +16 -2
  128. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  129. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +12 -3
  130. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  131. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
  132. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
  133. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  134. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  135. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
  136. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  137. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +1 -1
  138. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
  139. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
  140. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  141. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
  142. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
  143. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
  144. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
  145. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +14 -14
  146. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  147. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
  148. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
  149. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +26 -25
  150. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
  151. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
  152. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  153. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -21
  154. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  155. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -81
  156. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  157. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -2
  158. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  159. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -6
  160. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
  161. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
  162. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  163. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
  164. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
  165. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +19 -4
  166. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  167. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +162 -154
  168. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  169. package/dist-esm/lib/ui/components/primitives/layout.mjs +46 -0
  170. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
  171. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  172. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
  173. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  174. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +161 -22
  175. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  176. package/dist-esm/lib/ui/context/events.mjs.map +2 -2
  177. package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
  178. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  179. package/dist-esm/lib/ui/version.mjs +3 -3
  180. package/dist-esm/lib/ui/version.mjs.map +1 -1
  181. package/package.json +3 -3
  182. package/src/index.ts +12 -0
  183. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  184. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
  185. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  186. package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
  187. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  188. package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -14
  189. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  190. package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
  191. package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
  192. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
  193. package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
  194. package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
  195. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
  196. package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
  197. package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
  198. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  199. package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -1
  200. package/src/lib/ui/TldrawUi.tsx +17 -2
  201. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
  202. package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
  203. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  204. package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
  205. package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +1 -1
  206. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +3 -2
  207. package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
  208. package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
  209. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +39 -43
  210. package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
  211. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +7 -6
  212. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
  213. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
  214. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +212 -61
  215. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +2 -2
  216. package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +40 -37
  217. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
  218. package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
  219. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +32 -9
  220. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +186 -172
  221. package/src/lib/ui/components/primitives/layout.tsx +107 -0
  222. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
  223. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
  224. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +220 -19
  225. package/src/lib/ui/context/events.tsx +1 -0
  226. package/src/lib/ui/hooks/useTools.tsx +140 -10
  227. package/src/lib/ui/version.ts +3 -3
  228. package/src/lib/ui.css +363 -305
  229. package/tldraw.css +656 -595
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/ui/context/events.tsx"],
4
- "sourcesContent": ["import * as React from 'react'\n\n/** @public */\nexport type TLUiEventSource =\n\t| 'menu'\n\t| 'main-menu'\n\t| 'context-menu'\n\t| 'zoom-menu'\n\t| 'document-name'\n\t| 'navigation-zone'\n\t| 'quick-actions'\n\t| 'actions-menu'\n\t| 'kbd'\n\t| 'debug-panel'\n\t| 'page-menu'\n\t| 'share-menu'\n\t| 'export-menu'\n\t| 'toolbar'\n\t| 'people-menu'\n\t| 'dialog'\n\t| 'help-menu'\n\t| 'helper-buttons'\n\t| 'style-panel'\n\t| 'rich-text-menu'\n\t| 'image-toolbar'\n\t| 'video-toolbar'\n\t| 'unknown'\n\n/** @public */\nexport interface TLUiEventMap {\n\t// Actions\n\tundo: null\n\tredo: null\n\t'change-language': { locale: string }\n\t'change-page': { direction?: 'prev' | 'next' }\n\t'select-adjacent-shape': { direction: 'prev' | 'next' | 'left' | 'right' | 'up' | 'down' }\n\t'delete-page': null\n\t'duplicate-page': null\n\t'move-page': null\n\t'new-page': null\n\t'rename-page': null\n\t'move-to-page': null\n\t'move-to-new-page': null\n\t'rename-document': null\n\t'group-shapes': null\n\t'ungroup-shapes': null\n\t'remove-frame': null\n\t'fit-frame-to-content': null\n\t'convert-to-embed': null\n\t'convert-to-bookmark': null\n\t'open-embed-link': null\n\t'toggle-auto-size': null\n\t'copy-as': { format: 'svg' | 'png' | 'json' }\n\t'export-as': { format: 'svg' | 'png' | 'json' }\n\t'export-all-as': { format: 'svg' | 'png' | 'json' }\n\t'download-original': null\n\t'edit-link': null\n\t'insert-embed': null\n\t'insert-media': null\n\t'replace-media': null\n\t'image-manipulate': null\n\t'alt-text-start': null\n\t'set-alt-text': null\n\t'align-shapes': {\n\t\toperation: 'left' | 'center-horizontal' | 'right' | 'top' | 'center-vertical' | 'bottom'\n\t}\n\t'duplicate-shapes': null\n\t'pack-shapes': null\n\t'stack-shapes': { operation: 'horizontal' | 'vertical' }\n\t'flip-shapes': { operation: 'horizontal' | 'vertical' }\n\t'distribute-shapes': { operation: 'horizontal' | 'vertical' }\n\t'stretch-shapes': { operation: 'horizontal' | 'vertical' }\n\t'reorder-shapes': {\n\t\toperation: 'toBack' | 'toFront' | 'forward' | 'backward'\n\t}\n\t'delete-shapes': null\n\t'select-all-shapes': null\n\t'select-none-shapes': null\n\t'rotate-ccw': { fine: boolean }\n\t'rotate-cw': { fine: boolean }\n\t'zoom-in': { towardsCursor: boolean }\n\t'zoom-out': { towardsCursor: boolean }\n\t'zoom-to-fit': null\n\t'zoom-to-selection': null\n\t'reset-zoom': null\n\t'zoom-into-view': null\n\t'zoom-to-content': null\n\t'open-menu': { id: string }\n\t'close-menu': { id: string }\n\t'create-new-project': null\n\t'save-project-to-file': null\n\t'open-file': null\n\t'select-tool': { id: string }\n\tprint: null\n\tcopy: null\n\tpaste: null\n\tcut: null\n\t'set-style': { id: string; value: string | number }\n\t'toggle-transparent': null\n\t'toggle-snap-mode': null\n\t'toggle-tool-lock': null\n\t'toggle-grid-mode': null\n\t'toggle-wrap-mode': null\n\t'toggle-focus-mode': null\n\t'toggle-debug-mode': null\n\t'toggle-dynamic-size-mode': null\n\t'toggle-paste-at-cursor': null\n\t'toggle-lock': null\n\t'toggle-reduce-motion': null\n\t'toggle-keyboard-shortcuts': null\n\t'toggle-ui-labels': null\n\t'toggle-edge-scrolling': null\n\t'color-scheme': { value: string }\n\t'exit-pen-mode': null\n\t'start-following': null\n\t'stop-following': null\n\t'set-color': null\n\t'change-user-name': null\n\t'open-cursor-chat': null\n\t'zoom-tool': null\n\t'unlock-all': null\n\t'enlarge-shapes': null\n\t'shrink-shapes': null\n\t'flatten-to-image': null\n\t'a11y-repeat-shape-announce': null\n\t'open-url': { url: string }\n\t'open-context-menu': null\n\t'adjust-shape-styles': null\n\t'copy-link': null\n\t'image-replace': null\n\t'video-replace': null\n\t'open-kbd-shortcuts': null\n\t'rich-text': {\n\t\toperation:\n\t\t\t| 'bold'\n\t\t\t| 'strike'\n\t\t\t| 'link'\n\t\t\t| 'link-edit'\n\t\t\t| 'link-visit'\n\t\t\t| 'link-remove'\n\t\t\t| 'heading'\n\t\t\t| 'bulletList'\n\t}\n\tedit: null\n}\n\n/** @public */\nexport type TLUiEventData<K> = K extends null\n\t? { source: TLUiEventSource }\n\t: { source: TLUiEventSource } & K\n\n/** @public */\nexport type TLUiEventHandler = <T extends keyof TLUiEventMap>(\n\tname: T,\n\tdata: TLUiEventData<TLUiEventMap[T]>\n) => void\n\n/** @public */\nexport type TLUiEventContextType = TLUiEventHandler\n\n/** @internal */\nconst defaultEventHandler: TLUiEventContextType = () => void null\n\n/** @internal */\nexport const EventsContext = React.createContext<TLUiEventContextType | null>(null)\n\n/** @public */\nexport interface EventsProviderProps {\n\tonEvent?: TLUiEventHandler\n\tchildren: React.ReactNode\n}\n\n/** @public @react */\nexport function TldrawUiEventsProvider({ onEvent, children }: EventsProviderProps) {\n\treturn (\n\t\t<EventsContext.Provider value={onEvent ?? defaultEventHandler}>\n\t\t\t{children}\n\t\t</EventsContext.Provider>\n\t)\n}\n\n/** @public */\nexport function useUiEvents(): TLUiEventContextType {\n\tconst eventHandler = React.useContext(EventsContext)\n\treturn eventHandler ?? defaultEventHandler\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+KE;AA/KF,YAAuB;AAiKvB,MAAM,sBAA4C,MAAM;AAGjD,MAAM,gBAAgB,MAAM,cAA2C,IAAI;AAS3E,SAAS,uBAAuB,EAAE,SAAS,SAAS,GAAwB;AAClF,SACC,4CAAC,cAAc,UAAd,EAAuB,OAAO,WAAW,qBACxC,UACF;AAEF;AAGO,SAAS,cAAoC;AACnD,QAAM,eAAe,MAAM,WAAW,aAAa;AACnD,SAAO,gBAAgB;AACxB;",
4
+ "sourcesContent": ["import * as React from 'react'\n\n/** @public */\nexport type TLUiEventSource =\n\t| 'menu'\n\t| 'main-menu'\n\t| 'context-menu'\n\t| 'zoom-menu'\n\t| 'document-name'\n\t| 'navigation-zone'\n\t| 'quick-actions'\n\t| 'actions-menu'\n\t| 'kbd'\n\t| 'debug-panel'\n\t| 'page-menu'\n\t| 'share-menu'\n\t| 'export-menu'\n\t| 'toolbar'\n\t| 'people-menu'\n\t| 'dialog'\n\t| 'help-menu'\n\t| 'helper-buttons'\n\t| 'style-panel'\n\t| 'rich-text-menu'\n\t| 'image-toolbar'\n\t| 'video-toolbar'\n\t| 'unknown'\n\n/** @public */\nexport interface TLUiEventMap {\n\t// Actions\n\tundo: null\n\tredo: null\n\t'change-language': { locale: string }\n\t'change-page': { direction?: 'prev' | 'next' }\n\t'select-adjacent-shape': { direction: 'prev' | 'next' | 'left' | 'right' | 'up' | 'down' }\n\t'delete-page': null\n\t'duplicate-page': null\n\t'move-page': null\n\t'new-page': null\n\t'rename-page': null\n\t'move-to-page': null\n\t'move-to-new-page': null\n\t'rename-document': null\n\t'group-shapes': null\n\t'ungroup-shapes': null\n\t'remove-frame': null\n\t'fit-frame-to-content': null\n\t'convert-to-embed': null\n\t'convert-to-bookmark': null\n\t'open-embed-link': null\n\t'toggle-auto-size': null\n\t'copy-as': { format: 'svg' | 'png' | 'json' }\n\t'export-as': { format: 'svg' | 'png' | 'json' }\n\t'export-all-as': { format: 'svg' | 'png' | 'json' }\n\t'download-original': null\n\t'edit-link': null\n\t'insert-embed': null\n\t'insert-media': null\n\t'replace-media': null\n\t'image-manipulate': null\n\t'alt-text-start': null\n\t'set-alt-text': null\n\t'align-shapes': {\n\t\toperation: 'left' | 'center-horizontal' | 'right' | 'top' | 'center-vertical' | 'bottom'\n\t}\n\t'duplicate-shapes': null\n\t'pack-shapes': null\n\t'stack-shapes': { operation: 'horizontal' | 'vertical' }\n\t'flip-shapes': { operation: 'horizontal' | 'vertical' }\n\t'distribute-shapes': { operation: 'horizontal' | 'vertical' }\n\t'stretch-shapes': { operation: 'horizontal' | 'vertical' }\n\t'reorder-shapes': {\n\t\toperation: 'toBack' | 'toFront' | 'forward' | 'backward'\n\t}\n\t'delete-shapes': null\n\t'select-all-shapes': null\n\t'select-none-shapes': null\n\t'rotate-ccw': { fine: boolean }\n\t'rotate-cw': { fine: boolean }\n\t'zoom-in': { towardsCursor: boolean }\n\t'zoom-out': { towardsCursor: boolean }\n\t'zoom-to-fit': null\n\t'zoom-to-selection': null\n\t'reset-zoom': null\n\t'zoom-into-view': null\n\t'zoom-to-content': null\n\t'open-menu': { id: string }\n\t'close-menu': { id: string }\n\t'create-new-project': null\n\t'save-project-to-file': null\n\t'open-file': null\n\t'select-tool': { id: string }\n\tprint: null\n\tcopy: null\n\tpaste: null\n\tcut: null\n\t'set-style': { id: string; value: string | number }\n\t'toggle-transparent': null\n\t'toggle-snap-mode': null\n\t'toggle-tool-lock': null\n\t'toggle-grid-mode': null\n\t'toggle-wrap-mode': null\n\t'toggle-focus-mode': null\n\t'toggle-debug-mode': null\n\t'toggle-dynamic-size-mode': null\n\t'toggle-paste-at-cursor': null\n\t'toggle-lock': null\n\t'toggle-reduce-motion': null\n\t'toggle-keyboard-shortcuts': null\n\t'toggle-ui-labels': null\n\t'toggle-edge-scrolling': null\n\t'color-scheme': { value: string }\n\t'exit-pen-mode': null\n\t'start-following': null\n\t'stop-following': null\n\t'set-color': null\n\t'change-user-name': null\n\t'open-cursor-chat': null\n\t'zoom-tool': null\n\t'unlock-all': null\n\t'enlarge-shapes': null\n\t'shrink-shapes': null\n\t'flatten-to-image': null\n\t'a11y-repeat-shape-announce': null\n\t'open-url': { url: string }\n\t'open-context-menu': null\n\t'adjust-shape-styles': null\n\t'copy-link': null\n\t'drag-tool': { id: string }\n\t'image-replace': null\n\t'video-replace': null\n\t'open-kbd-shortcuts': null\n\t'rich-text': {\n\t\toperation:\n\t\t\t| 'bold'\n\t\t\t| 'strike'\n\t\t\t| 'link'\n\t\t\t| 'link-edit'\n\t\t\t| 'link-visit'\n\t\t\t| 'link-remove'\n\t\t\t| 'heading'\n\t\t\t| 'bulletList'\n\t}\n\tedit: null\n}\n\n/** @public */\nexport type TLUiEventData<K> = K extends null\n\t? { source: TLUiEventSource }\n\t: { source: TLUiEventSource } & K\n\n/** @public */\nexport type TLUiEventHandler = <T extends keyof TLUiEventMap>(\n\tname: T,\n\tdata: TLUiEventData<TLUiEventMap[T]>\n) => void\n\n/** @public */\nexport type TLUiEventContextType = TLUiEventHandler\n\n/** @internal */\nconst defaultEventHandler: TLUiEventContextType = () => void null\n\n/** @internal */\nexport const EventsContext = React.createContext<TLUiEventContextType | null>(null)\n\n/** @public */\nexport interface EventsProviderProps {\n\tonEvent?: TLUiEventHandler\n\tchildren: React.ReactNode\n}\n\n/** @public @react */\nexport function TldrawUiEventsProvider({ onEvent, children }: EventsProviderProps) {\n\treturn (\n\t\t<EventsContext.Provider value={onEvent ?? defaultEventHandler}>\n\t\t\t{children}\n\t\t</EventsContext.Provider>\n\t)\n}\n\n/** @public */\nexport function useUiEvents(): TLUiEventContextType {\n\tconst eventHandler = React.useContext(EventsContext)\n\treturn eventHandler ?? defaultEventHandler\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgLE;AAhLF,YAAuB;AAkKvB,MAAM,sBAA4C,MAAM;AAGjD,MAAM,gBAAgB,MAAM,cAA2C,IAAI;AAS3E,SAAS,uBAAuB,EAAE,SAAS,SAAS,GAAwB;AAClF,SACC,4CAAC,cAAc,UAAd,EAAuB,OAAO,WAAW,qBACxC,UACF;AAEF;AAGO,SAAS,cAAoC;AACnD,QAAM,eAAe,MAAM,WAAW,aAAa;AACnD,SAAO,gBAAgB;AACxB;",
6
6
  "names": []
7
7
  }
@@ -30,6 +30,7 @@ var useTools_exports = {};
30
30
  __export(useTools_exports, {
31
31
  ToolsContext: () => ToolsContext,
32
32
  ToolsProvider: () => ToolsProvider,
33
+ onDragFromToolbarToCreateShape: () => onDragFromToolbarToCreateShape,
33
34
  useTools: () => useTools
34
35
  });
35
36
  module.exports = __toCommonJS(useTools_exports);
@@ -105,20 +106,26 @@ function ToolsProvider({ overrides, children }) {
105
106
  onToolSelect(source, this);
106
107
  }
107
108
  },
108
- ...[...import_editor.GeoShapeGeoStyle.values].map((id) => ({
109
- id,
110
- label: `tool.${id}`,
109
+ ...[...import_editor.GeoShapeGeoStyle.values].map((geo) => ({
110
+ id: geo,
111
+ label: `tool.${geo}`,
111
112
  meta: {
112
- geo: id
113
+ geo
113
114
  },
114
- kbd: id === "rectangle" ? "r" : id === "ellipse" ? "o" : void 0,
115
- icon: "geo-" + id,
115
+ kbd: geo === "rectangle" ? "r" : geo === "ellipse" ? "o" : void 0,
116
+ icon: "geo-" + geo,
116
117
  onSelect(source) {
117
118
  editor.run(() => {
118
- editor.setStyleForNextShapes(import_editor.GeoShapeGeoStyle, id);
119
+ editor.setStyleForNextShapes(import_editor.GeoShapeGeoStyle, geo);
119
120
  editor.setCurrentTool("geo");
120
- onToolSelect(source, this, `geo-${id}`);
121
+ onToolSelect(source, this, `geo-${geo}`);
121
122
  });
123
+ },
124
+ onDragStart(source, info) {
125
+ onDragFromToolbarToCreateShape(editor, info, {
126
+ createShape: (id) => editor.createShape({ id, type: "geo", props: { w: 200, h: 200, geo } })
127
+ });
128
+ trackEvent("drag-tool", { source, id: "geo" });
122
129
  }
123
130
  })),
124
131
  {
@@ -129,6 +136,16 @@ function ToolsProvider({ overrides, children }) {
129
136
  onSelect(source) {
130
137
  editor.setCurrentTool("arrow");
131
138
  onToolSelect(source, this);
139
+ },
140
+ onDragStart(source, info) {
141
+ onDragFromToolbarToCreateShape(editor, info, {
142
+ createShape: (id) => editor.createShape({
143
+ id,
144
+ type: "arrow",
145
+ props: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } }
146
+ })
147
+ });
148
+ trackEvent("drag-tool", { source, id: "arrow" });
132
149
  }
133
150
  },
134
151
  {
@@ -139,6 +156,24 @@ function ToolsProvider({ overrides, children }) {
139
156
  onSelect(source) {
140
157
  editor.setCurrentTool("line");
141
158
  onToolSelect(source, this);
159
+ },
160
+ onDragStart(source, info) {
161
+ onDragFromToolbarToCreateShape(editor, info, {
162
+ createShape: (id) => {
163
+ const [start, end] = (0, import_editor.getIndicesBetween)(null, null, 2);
164
+ editor.createShape({
165
+ id,
166
+ type: "line",
167
+ props: {
168
+ points: {
169
+ [start]: { id: start, index: start, x: 0, y: 200 },
170
+ [end]: { id: end, index: end, x: 200, y: 0 }
171
+ }
172
+ }
173
+ });
174
+ }
175
+ });
176
+ trackEvent("drag-tool", { source, id: "line" });
142
177
  }
143
178
  },
144
179
  {
@@ -149,6 +184,12 @@ function ToolsProvider({ overrides, children }) {
149
184
  onSelect(source) {
150
185
  editor.setCurrentTool("frame");
151
186
  onToolSelect(source, this);
187
+ },
188
+ onDragStart(source, info) {
189
+ onDragFromToolbarToCreateShape(editor, info, {
190
+ createShape: (id) => editor.createShape({ id, type: "frame" })
191
+ });
192
+ trackEvent("drag-tool", { source, id: "frame" });
152
193
  }
153
194
  },
154
195
  {
@@ -159,6 +200,16 @@ function ToolsProvider({ overrides, children }) {
159
200
  onSelect(source) {
160
201
  editor.setCurrentTool("text");
161
202
  onToolSelect(source, this);
203
+ },
204
+ onDragStart(source, info) {
205
+ onDragFromToolbarToCreateShape(editor, info, {
206
+ createShape: (id) => editor.createShape({ id, type: "text", props: { richText: (0, import_editor.toRichText)("Text") } }),
207
+ onDragEnd: (id) => {
208
+ editor.setEditingShape(id);
209
+ editor.emit("select-all-text", { shapeId: id });
210
+ }
211
+ });
212
+ trackEvent("drag-tool", { source, id: "text" });
162
213
  }
163
214
  },
164
215
  {
@@ -179,6 +230,16 @@ function ToolsProvider({ overrides, children }) {
179
230
  onSelect(source) {
180
231
  editor.setCurrentTool("note");
181
232
  onToolSelect(source, this);
233
+ },
234
+ onDragStart(source, info) {
235
+ onDragFromToolbarToCreateShape(editor, info, {
236
+ createShape: (id) => editor.createShape({ id, type: "note" }),
237
+ onDragEnd: (id) => {
238
+ editor.setEditingShape(id);
239
+ editor.emit("select-all-text", { shapeId: id });
240
+ }
241
+ });
242
+ trackEvent("drag-tool", { source, id: "note" });
182
243
  }
183
244
  },
184
245
  {
@@ -219,7 +280,7 @@ function ToolsProvider({ overrides, children }) {
219
280
  return overrides(editor, tools2, helpers);
220
281
  }
221
282
  return tools2;
222
- }, [overrides, editor, helpers, onToolSelect]);
283
+ }, [overrides, editor, helpers, onToolSelect, trackEvent]);
223
284
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToolsContext.Provider, { value: tools, children });
224
285
  }
225
286
  function useTools() {
@@ -229,4 +290,28 @@ function useTools() {
229
290
  }
230
291
  return ctx;
231
292
  }
293
+ function onDragFromToolbarToCreateShape(editor, info, opts) {
294
+ const { x, y } = editor.inputs.currentPagePoint;
295
+ const stoppingPoint = editor.markHistoryStoppingPoint("drag shape tool");
296
+ editor.setCurrentTool("select.translating");
297
+ const id = (0, import_editor.createShapeId)();
298
+ opts.createShape(id);
299
+ const shape = (0, import_editor.assertExists)(editor.getShape(id), "Shape not found");
300
+ const { w, h } = editor.getShapePageBounds(id);
301
+ editor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 });
302
+ editor.select(id);
303
+ editor.setCurrentTool("select.translating", {
304
+ ...info,
305
+ target: "shape",
306
+ shape: editor.getShape(id),
307
+ isCreating: true,
308
+ creatingMarkId: stoppingPoint,
309
+ onCreate() {
310
+ editor.setCurrentTool("select.idle");
311
+ editor.select(id);
312
+ opts.onDragEnd?.(id);
313
+ }
314
+ });
315
+ editor.getCurrentTool().setCurrentToolIdMask(shape.type);
316
+ }
232
317
  //# sourceMappingURL=useTools.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/ui/hooks/useTools.tsx"],
4
- "sourcesContent": ["import { Editor, GeoShapeGeoStyle, useMaybeEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((id) => ({\n\t\t\t\tid,\n\t\t\t\tlabel: `tool.${id}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo: id,\n\t\t\t\t},\n\t\t\t\tkbd: id === 'rectangle' ? 'r' : id === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + id) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, id)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${id}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwPQ;AAxPR,oBAAyD;AACzD,YAAuB;AACvB,yBAA4B;AAE5B,kBAAwB;AACxB,oBAA6C;AAE7C,uBAAuD;AAEvD,4BAA+B;AA8BxB,MAAM,eAAe,MAAM,cAA2C,IAAI;AAa1E,SAAS,cAAc,EAAE,WAAW,SAAS,GAA2B;AAC9E,QAAM,aAAS,8BAAe;AAC9B,QAAM,iBAAa,2BAAY;AAE/B,QAAM,WAAO,qBAAQ;AACrB,QAAM,UAAM,sCAAe;AAC3B,QAAM,cAAU,oCAAkB;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B,CACC,QACA,MACA,OACI;AACJ,WAAK,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,EAAE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AAC,KAAK;AACT,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AAEA,SAAO;AACR;",
4
+ "sourcesContent": ["import {\n\tassertExists,\n\tcreateShapeId,\n\tEditor,\n\tGeoShapeGeoStyle,\n\tgetIndicesBetween,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\ttoRichText,\n\tuseMaybeEditor,\n} from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\tonDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((geo) => ({\n\t\t\t\tid: geo,\n\t\t\t\tlabel: `tool.${geo}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo,\n\t\t\t\t},\n\t\t\t\tkbd: geo === 'rectangle' ? 'r' : geo === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + geo) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, geo)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${geo}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'geo', props: { w: 200, h: 200, geo } }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'geo' })\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\tprops: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'arrow' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => {\n\t\t\t\t\t\t\tconst [start, end] = getIndicesBetween(null, null, 2)\n\t\t\t\t\t\t\teditor.createShape<TLLineShape>({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'line',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t\t\t\t[start]: { id: start, index: start, x: 0, y: 200 },\n\t\t\t\t\t\t\t\t\t\t[end]: { id: end, index: end, x: 200, y: 0 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'line' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'frame' }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'frame' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'text', props: { richText: toRichText('Text') } }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'text' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'note' }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'note' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect, trackEvent])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n\n/**\n * Options for {@link onDragFromToolbarToCreateShape}.\n * @public\n */\nexport interface OnDragFromToolbarToCreateShapesOpts {\n\t/**\n\t * Create the shape being dragged. You don't need to worry about positioning it, as it'll be\n\t * immediately updated with the correct position.\n\t */\n\tcreateShape(id: TLShapeId): void\n\t/**\n\t * Called once the drag interaction has finished.\n\t */\n\tonDragEnd?(id: TLShapeId): void\n}\n\n/**\n * A helper method to use in {@link TLUiToolItem#onDragStart} to create a shape by dragging it from\n * the toolbar.\n * @public\n */\nexport function onDragFromToolbarToCreateShape(\n\teditor: Editor,\n\tinfo: TLPointerEventInfo,\n\topts: OnDragFromToolbarToCreateShapesOpts\n) {\n\tconst { x, y } = editor.inputs.currentPagePoint\n\n\tconst stoppingPoint = editor.markHistoryStoppingPoint('drag shape tool')\n\teditor.setCurrentTool('select.translating')\n\n\tconst id = createShapeId()\n\topts.createShape(id)\n\tconst shape = assertExists(editor.getShape(id), 'Shape not found')\n\n\tconst { w, h } = editor.getShapePageBounds(id)!\n\teditor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 })\n\teditor.select(id)\n\n\teditor.setCurrentTool('select.translating', {\n\t\t...info,\n\t\ttarget: 'shape',\n\t\tshape: editor.getShape(id),\n\t\tisCreating: true,\n\t\tcreatingMarkId: stoppingPoint,\n\t\tonCreate() {\n\t\t\teditor.setCurrentTool('select.idle')\n\t\t\teditor.select(id)\n\t\t\topts.onDragEnd?.(id)\n\t\t},\n\t})\n\n\teditor.getCurrentTool().setCurrentToolIdMask(shape.type)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmUQ;AAnUR,oBAWO;AACP,YAAuB;AACvB,yBAA4B;AAE5B,kBAAwB;AACxB,oBAA6C;AAE7C,uBAAuD;AAEvD,4BAA+B;AA+BxB,MAAM,eAAe,MAAM,cAA2C,IAAI;AAa1E,SAAS,cAAc,EAAE,WAAW,SAAS,GAA2B;AAC9E,QAAM,aAAS,8BAAe;AAC9B,QAAM,iBAAa,2BAAY;AAE/B,QAAM,WAAO,qBAAQ;AACrB,QAAM,UAAM,sCAAe;AAC3B,QAAM,cAAU,oCAAkB;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B,CACC,QACA,MACA,OACI;AACJ,WAAK,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC;AACtC,iBAAW,eAAe,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC;AAAA,IACxD;AAAA,IACA,CAAC,MAAM,KAAK,UAAU;AAAA,EACvB;AAEA,QAAM,QAAQ,MAAM,QAA8B,MAAM;AACvD,QAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,UAAM,aAA+D;AAAA,MACpE;AAAA,QACC,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,MAAM;AAAA,QACN,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,SAAS,QAAQ;AAChB,cAAI,OAAO,KAAK,QAAQ,GAAG;AAO1B,kBAAM,cAAc,OAAO,KAAK,WAAW;AAC3C,wBAAY,KAAK,CAAC,GAAG,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"]
7
7
  }
@@ -22,10 +22,10 @@ __export(version_exports, {
22
22
  version: () => version
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const version = "3.16.0-next.34fddf633325";
25
+ const version = "3.16.0-next.b88d494af370";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-08-06T14:20:08.115Z",
29
- patch: "2025-08-06T14:20:08.115Z"
28
+ minor: "2025-08-15T10:33:20.761Z",
29
+ patch: "2025-08-15T10:33:20.761Z"
30
30
  };
31
31
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/ui/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.34fddf633325'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-06T14:20:08.115Z',\n\tpatch: '2025-08-06T14:20:08.115Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.b88d494af370'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-15T10:33:20.761Z',\n\tpatch: '2025-08-15T10:33:20.761Z',\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -13,11 +13,13 @@ import { CSSProperties } from 'react';
13
13
  import { Editor } from '@tldraw/editor';
14
14
  import { Extension } from '@tiptap/core';
15
15
  import { Extensions } from '@tiptap/core';
16
+ import { ForwardRefExoticComponent } from 'react';
16
17
  import { Geometry2d } from '@tldraw/editor';
17
18
  import { Geometry2dFilters } from '@tldraw/editor';
18
19
  import { Geometry2dOptions } from '@tldraw/editor';
19
20
  import { Group2d } from '@tldraw/editor';
20
21
  import { HandleSnapGeometry } from '@tldraw/editor';
22
+ import { HTMLAttributes } from 'react';
21
23
  import { IndexKey } from '@tldraw/editor';
22
24
  import { JsonObject } from '@tldraw/editor';
23
25
  import { JSX as JSX_2 } from 'react/jsx-runtime';
@@ -37,6 +39,7 @@ import { ReadonlySharedStyleMap } from '@tldraw/editor';
37
39
  import { RecordProps } from '@tldraw/editor';
38
40
  import { Rectangle2d } from '@tldraw/editor';
39
41
  import { RecursivePartial } from '@tldraw/editor';
42
+ import { RefAttributes } from 'react';
40
43
  import { RefObject } from 'react';
41
44
  import { Result } from '@tldraw/editor';
42
45
  import { RichTextFontVisitorState } from '@tldraw/editor';
@@ -1014,6 +1017,11 @@ export declare function DefaultToolbarContent(): JSX_2.Element;
1014
1017
  /** @public */
1015
1018
  export declare interface DefaultToolbarProps {
1016
1019
  children?: ReactNode;
1020
+ orientation?: 'horizontal' | 'vertical';
1021
+ minItems?: number;
1022
+ minSizePx?: number;
1023
+ maxItems?: number;
1024
+ maxSizePx?: number;
1017
1025
  }
1018
1026
 
1019
1027
  /** @public */
@@ -2120,6 +2128,29 @@ export declare function NoteToolbarItem(): JSX_2.Element;
2120
2128
  /** @public @react */
2121
2129
  export declare function OfflineIndicator(): JSX_2.Element;
2122
2130
 
2131
+ /**
2132
+ * A helper method to use in {@link TLUiToolItem#onDragStart} to create a shape by dragging it from
2133
+ * the toolbar.
2134
+ * @public
2135
+ */
2136
+ export declare function onDragFromToolbarToCreateShape(editor: Editor, info: TLPointerEventInfo, opts: OnDragFromToolbarToCreateShapesOpts): void;
2137
+
2138
+ /**
2139
+ * Options for {@link onDragFromToolbarToCreateShape}.
2140
+ * @public
2141
+ */
2142
+ export declare interface OnDragFromToolbarToCreateShapesOpts {
2143
+ /**
2144
+ * Create the shape being dragged. You don't need to worry about positioning it, as it'll be
2145
+ * immediately updated with the correct position.
2146
+ */
2147
+ createShape(id: TLShapeId): void;
2148
+ /**
2149
+ * Called once the drag interaction has finished.
2150
+ */
2151
+ onDragEnd?(id: TLShapeId): void;
2152
+ }
2153
+
2123
2154
  /** @public @react */
2124
2155
  export declare function OpacitySlider(): JSX_2.Element | null;
2125
2156
 
@@ -2127,11 +2158,17 @@ export declare function OpacitySlider(): JSX_2.Element | null;
2127
2158
  export declare function OvalToolbarItem(): JSX_2.Element;
2128
2159
 
2129
2160
  /** @public @react */
2130
- export declare function OverflowingToolbar({ children }: OverflowingToolbarProps): JSX_2.Element;
2161
+ export declare function OverflowingToolbar({ children, orientation, sizingParentClassName, minItems, minSizePx, maxItems, maxSizePx, }: OverflowingToolbarProps): JSX_2.Element;
2131
2162
 
2132
2163
  /** @public */
2133
2164
  export declare interface OverflowingToolbarProps {
2134
2165
  children: React.ReactNode;
2166
+ orientation: 'horizontal' | 'vertical';
2167
+ sizingParentClassName: string;
2168
+ minItems: number;
2169
+ minSizePx: number;
2170
+ maxItems: number;
2171
+ maxSizePx: number;
2135
2172
  }
2136
2173
 
2137
2174
  /** @public @react */
@@ -2918,6 +2955,13 @@ export declare function TldrawUiButtonLabel({ children }: TLUiButtonLabelProps):
2918
2955
  /** @public */
2919
2956
  export declare const TldrawUiButtonPicker: <T extends string>(props: TLUiButtonPickerProps<T>) => ReactElement;
2920
2957
 
2958
+ /**
2959
+ * A column, usually of UI controls like buttons, select dropdown, checkboxes, etc.
2960
+ *
2961
+ * @public @react
2962
+ */
2963
+ export declare const TldrawUiColumn: ForwardRefExoticComponent<TLUiLayoutProps & RefAttributes<HTMLDivElement>>;
2964
+
2921
2965
  /** @public @react */
2922
2966
  export declare function TldrawUiComponentsProvider({ overrides, children, }: TLUiComponentsProviderProps): JSX_2.Element;
2923
2967
 
@@ -2980,6 +3024,13 @@ export declare function TldrawUiDropdownMenuTrigger({ children, ...rest }: TLUiD
2980
3024
  /** @public @react */
2981
3025
  export declare function TldrawUiEventsProvider({ onEvent, children }: EventsProviderProps): JSX_2.Element;
2982
3026
 
3027
+ /**
3028
+ * A tight grid 4 elements wide, usually of UI controls like buttons, select dropdown, checkboxes,
3029
+ * etc.
3030
+ *
3031
+ * @public @react */
3032
+ export declare const TldrawUiGrid: ForwardRefExoticComponent<TLUiLayoutProps & RefAttributes<HTMLDivElement>>;
3033
+
2983
3034
  /** @public @react */
2984
3035
  export declare const TldrawUiIcon: NamedExoticComponent<TLUiIconProps>;
2985
3036
 
@@ -3005,7 +3056,7 @@ export declare function TldrawUiMenuContextProvider({ type, sourceId, children,
3005
3056
  export declare function TldrawUiMenuGroup({ id, label, className, children }: TLUiMenuGroupProps): boolean | JSX_2.Element | Iterable<ReactNode> | null | number | string | undefined;
3006
3057
 
3007
3058
  /** @public @react */
3008
- export declare function TldrawUiMenuItem<TranslationKey extends string = string, IconType extends string = string>({ disabled, spinner, readonlyOk, id, kbd, label, icon, iconLeft, onSelect, noClose, isSelected, }: TLUiMenuItemProps<TranslationKey, IconType>): JSX_2.Element | null;
3059
+ export declare function TldrawUiMenuItem<TranslationKey extends string = string, IconType extends string = string>({ disabled, spinner, readonlyOk, id, kbd, label, icon, iconLeft, onSelect, noClose, isSelected, onDragStart, }: TLUiMenuItemProps<TranslationKey, IconType>): JSX_2.Element | null;
3009
3060
 
3010
3061
  /** @public @react */
3011
3062
  export declare function TldrawUiMenuSubmenu<Translation extends string = string>({ id, disabled, label, size, children, }: TLUiMenuSubmenuProps<Translation>): boolean | JSX_2.Element | Iterable<ReactNode> | null | number | string | undefined;
@@ -3013,8 +3064,24 @@ export declare function TldrawUiMenuSubmenu<Translation extends string = string>
3013
3064
  /** @public @react */
3014
3065
  export declare function TldrawUiMenuToolItem({ toolId, ...rest }: TLUiMenuToolItemProps): JSX_2.Element | null;
3015
3066
 
3067
+ /** @public */
3068
+ export declare interface TldrawUiOrientationContext {
3069
+ orientation: 'horizontal' | 'vertical';
3070
+ tooltipSide: 'bottom' | 'left' | 'right' | 'top';
3071
+ }
3072
+
3016
3073
  /** @public @react */
3017
- export declare function TldrawUiPopover({ id, children, onOpenChange, open }: TLUiPopoverProps): JSX_2.Element;
3074
+ export declare function TldrawUiOrientationProvider({ children, orientation, tooltipSide, }: TldrawUiOrientationProviderProps): JSX_2.Element;
3075
+
3076
+ /** @public */
3077
+ export declare interface TldrawUiOrientationProviderProps {
3078
+ children: ReactNode;
3079
+ orientation: 'horizontal' | 'vertical';
3080
+ tooltipSide?: 'bottom' | 'left' | 'right' | 'top';
3081
+ }
3082
+
3083
+ /** @public @react */
3084
+ export declare function TldrawUiPopover({ id, children, onOpenChange, open, className }: TLUiPopoverProps): JSX_2.Element;
3018
3085
 
3019
3086
  /** @public @react */
3020
3087
  export declare function TldrawUiPopoverContent({ side, children, align, sideOffset, alignOffset, disableEscapeKeyDown, autoFocusFirstButton, }: TLUiPopoverContentProps): JSX_2.Element;
@@ -3044,6 +3111,13 @@ export declare interface TldrawUiProps extends TLUiContextProviderProps {
3044
3111
  assetUrls?: TLUiAssetUrlOverrides;
3045
3112
  }
3046
3113
 
3114
+ /**
3115
+ * A row, usually of UI controls like buttons, select dropdown, checkboxes, etc.
3116
+ *
3117
+ * @public @react
3118
+ */
3119
+ export declare const TldrawUiRow: ForwardRefExoticComponent<TLUiLayoutProps & RefAttributes<HTMLDivElement>>;
3120
+
3047
3121
  /** @public @react */
3048
3122
  export declare const TldrawUiSlider: React_3.ForwardRefExoticComponent<TLUiSliderProps & React_3.RefAttributes<HTMLDivElement>>;
3049
3123
 
@@ -3063,7 +3137,7 @@ export declare const TldrawUiToolbarToggleGroup: ({ children, className, type, .
3063
3137
  export declare const TldrawUiToolbarToggleItem: ({ children, className, type, value, tooltip, ...props }: TLUiToolbarToggleItemProps) => JSX_2.Element;
3064
3138
 
3065
3139
  /** @public @react */
3066
- export declare function TldrawUiTooltip({ children, content, side, sideOffset, disabled, }: TldrawUiTooltipProps): JSX_2.Element;
3140
+ export declare const TldrawUiTooltip: React_3.ForwardRefExoticComponent<TldrawUiTooltipProps & React_3.RefAttributes<HTMLButtonElement>>;
3067
3141
 
3068
3142
  /** @public */
3069
3143
  export declare interface TldrawUiTooltipProps {
@@ -3072,6 +3146,8 @@ export declare interface TldrawUiTooltipProps {
3072
3146
  side?: 'bottom' | 'left' | 'right' | 'top';
3073
3147
  sideOffset?: number;
3074
3148
  disabled?: boolean;
3149
+ showOnMobile?: boolean;
3150
+ delayDuration?: number;
3075
3151
  }
3076
3152
 
3077
3153
  /** @public @react */
@@ -3618,6 +3694,9 @@ export declare interface TLUiEventMap {
3618
3694
  'open-context-menu': null;
3619
3695
  'adjust-shape-styles': null;
3620
3696
  'copy-link': null;
3697
+ 'drag-tool': {
3698
+ id: string;
3699
+ };
3621
3700
  'image-replace': null;
3622
3701
  'video-replace': null;
3623
3702
  'open-kbd-shortcuts': null;
@@ -3704,6 +3783,13 @@ export declare type TLUiKeyboardShortcutsDialogProps = TLUiDialogProps & {
3704
3783
  children?: ReactNode;
3705
3784
  };
3706
3785
 
3786
+ /** @public */
3787
+ export declare interface TLUiLayoutProps extends HTMLAttributes<HTMLDivElement> {
3788
+ children: ReactNode;
3789
+ tooltipSide?: 'bottom' | 'left' | 'right' | 'top';
3790
+ asChild?: boolean;
3791
+ }
3792
+
3707
3793
  /** @public */
3708
3794
  export declare interface TLUiMainMenuProps {
3709
3795
  children?: ReactNode;
@@ -3743,7 +3829,7 @@ export declare interface TLUiMenuContextProviderProps {
3743
3829
  }
3744
3830
 
3745
3831
  /** @public */
3746
- export declare type TLUiMenuContextType = 'context-menu' | 'helper-buttons' | 'icons' | 'keyboard-shortcuts' | 'menu' | 'panel' | 'small-icons' | 'toolbar-overflow' | 'toolbar';
3832
+ export declare type TLUiMenuContextType = 'context-menu' | 'helper-buttons' | 'icons' | 'keyboard-shortcuts' | 'menu' | 'small-icons' | 'toolbar-overflow' | 'toolbar';
3747
3833
 
3748
3834
  /** @public */
3749
3835
  export declare interface TLUiMenuGroupProps<TranslationKey extends string = string> {
@@ -3803,6 +3889,10 @@ export declare interface TLUiMenuItemProps<TranslationKey extends string = strin
3803
3889
  * Whether the item is selected.
3804
3890
  */
3805
3891
  isSelected?: boolean;
3892
+ /**
3893
+ * The function to call when the item is dragged. If this is provided, the item will be draggable.
3894
+ */
3895
+ onDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void;
3806
3896
  }
3807
3897
 
3808
3898
  /** @public */
@@ -3848,6 +3938,7 @@ export declare interface TLUiPopoverProps {
3848
3938
  open?: boolean;
3849
3939
  children: React_3.ReactNode;
3850
3940
  onOpenChange?(isOpen: boolean): void;
3941
+ className?: string;
3851
3942
  }
3852
3943
 
3853
3944
  /** @public */
@@ -3942,6 +4033,8 @@ export declare interface TLUiToolbarProps extends React_3.HTMLAttributes<HTMLDiv
3942
4033
  className?: string;
3943
4034
  dir?: 'ltr' | 'rtl';
3944
4035
  label: string;
4036
+ orientation?: 'grid' | 'horizontal' | 'vertical';
4037
+ tooltipSide?: 'bottom' | 'left' | 'right' | 'top';
3945
4038
  }
3946
4039
 
3947
4040
  /** @public */
@@ -3970,6 +4063,7 @@ export declare interface TLUiToolItem<TranslationKey extends string = string, Ic
3970
4063
  shortcutsLabel?: TranslationKey;
3971
4064
  icon: IconType | TLUiIconJsx;
3972
4065
  onSelect(source: TLUiEventSource): void;
4066
+ onDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void;
3973
4067
  /**
3974
4068
  * The keyboard shortcut for this tool. This is a string that can be a single key,
3975
4069
  * or a combination of keys.
@@ -4382,6 +4476,9 @@ export declare function useShowCollaborationUi(): boolean;
4382
4476
  /** @public */
4383
4477
  export declare function useTldrawUiComponents(): TLUiComponents;
4384
4478
 
4479
+ /** @public */
4480
+ export declare function useTldrawUiOrientation(): TldrawUiOrientationContext;
4481
+
4385
4482
  /** @public */
4386
4483
  export declare function useToasts(): TLUiToastsContextType;
4387
4484
 
@@ -8,6 +8,13 @@ import { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from "./lib/ui/compo
8
8
  import { AccessibilityMenu } from "./lib/ui/components/AccessibilityMenu.mjs";
9
9
  import { ColorSchemeMenu } from "./lib/ui/components/ColorSchemeMenu.mjs";
10
10
  import { DefaultDialogs } from "./lib/ui/components/Dialogs.mjs";
11
+ import {
12
+ TldrawUiColumn,
13
+ TldrawUiGrid,
14
+ TldrawUiOrientationProvider,
15
+ TldrawUiRow,
16
+ useTldrawUiOrientation
17
+ } from "./lib/ui/components/primitives/layout.mjs";
11
18
  import {
12
19
  TldrawUiMenuActionCheckboxItem
13
20
  } from "./lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs";
@@ -446,6 +453,7 @@ import { useMenuIsOpen } from "./lib/ui/hooks/useMenuIsOpen.mjs";
446
453
  import { useReadonly } from "./lib/ui/hooks/useReadonly.mjs";
447
454
  import { useRelevantStyles } from "./lib/ui/hooks/useRelevantStyles.mjs";
448
455
  import {
456
+ onDragFromToolbarToCreateShape,
449
457
  useTools
450
458
  } from "./lib/ui/hooks/useTools.mjs";
451
459
  import {
@@ -497,7 +505,7 @@ import {
497
505
  } from "./lib/utils/tldr/file.mjs";
498
506
  registerTldrawLibraryVersion(
499
507
  "tldraw",
500
- "3.16.0-next.34fddf633325",
508
+ "3.16.0-next.b88d494af370",
501
509
  "esm"
502
510
  );
503
511
  export {
@@ -693,6 +701,7 @@ export {
693
701
  TldrawUiButtonIcon,
694
702
  TldrawUiButtonLabel,
695
703
  TldrawUiButtonPicker,
704
+ TldrawUiColumn,
696
705
  TldrawUiComponentsProvider,
697
706
  TldrawUiContextProvider,
698
707
  TldrawUiContextualToolbar,
@@ -712,6 +721,7 @@ export {
712
721
  TldrawUiDropdownMenuSubTrigger,
713
722
  TldrawUiDropdownMenuTrigger,
714
723
  TldrawUiEventsProvider,
724
+ TldrawUiGrid,
715
725
  TldrawUiIcon,
716
726
  TldrawUiInput,
717
727
  TldrawUiKbd,
@@ -723,9 +733,11 @@ export {
723
733
  TldrawUiMenuItem,
724
734
  TldrawUiMenuSubmenu,
725
735
  TldrawUiMenuToolItem,
736
+ TldrawUiOrientationProvider,
726
737
  TldrawUiPopover,
727
738
  TldrawUiPopoverContent,
728
739
  TldrawUiPopoverTrigger,
740
+ TldrawUiRow,
729
741
  TldrawUiSlider,
730
742
  TldrawUiToastsProvider,
731
743
  TldrawUiToolbar,
@@ -803,6 +815,7 @@ export {
803
815
  getHitShapeOnCanvasPointerDown,
804
816
  getMediaAssetInfoPartial,
805
817
  getUncroppedSize,
818
+ onDragFromToolbarToCreateShape,
806
819
  parseAndLoadDocument,
807
820
  parseTldrawJsonFile,
808
821
  preloadFont,
@@ -851,6 +864,7 @@ export {
851
864
  useSelectedShapesAnnouncer,
852
865
  useShowCollaborationUi,
853
866
  useTldrawUiComponents,
867
+ useTldrawUiOrientation,
854
868
  useToasts,
855
869
  useTools,
856
870
  useTranslation,