tldraw 3.16.0-next.df90ce0ff566 → 3.16.0-next.e57e478c23e0

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 (469) hide show
  1. package/dist-cjs/index.d.ts +353 -105
  2. package/dist-cjs/index.js +46 -14
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/Tldraw.js +12 -2
  5. package/dist-cjs/lib/Tldraw.js.map +2 -2
  6. package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
  7. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  8. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -4
  9. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
  11. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +6 -0
  13. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  14. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  15. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  16. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  17. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  18. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
  19. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  21. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  22. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +18 -12
  23. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  24. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  25. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  26. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
  27. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
  29. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
  30. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
  31. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  32. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +6 -3
  33. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
  35. package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
  36. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
  37. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  38. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -3
  39. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  40. package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
  41. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  42. package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
  43. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +0 -2
  44. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  45. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  46. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  47. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +10 -1
  48. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
  49. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
  50. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  51. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  52. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  53. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
  54. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  55. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
  56. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  57. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  58. package/dist-cjs/lib/ui/TldrawUi.js +27 -12
  59. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  60. package/dist-cjs/lib/ui/assetUrls.js +13 -10
  61. package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
  62. package/dist-cjs/lib/ui/components/AccessibilityMenu.js +35 -0
  63. package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +7 -0
  64. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +12 -3
  65. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  66. package/dist-cjs/lib/ui/components/{FollowingIndicator.js → DefaultFollowingIndicator.js} +6 -6
  67. package/dist-cjs/lib/ui/components/DefaultFollowingIndicator.js.map +7 -0
  68. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
  69. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
  70. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +6 -6
  71. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +1 -1
  72. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +3 -3
  73. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
  74. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  75. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  76. package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
  77. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  78. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +1 -1
  79. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
  80. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +2 -1
  81. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  82. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
  83. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
  84. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
  85. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
  86. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +11 -4
  87. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  88. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +249 -279
  89. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  90. package/dist-cjs/lib/ui/components/{primitives/TldrawUiButtonPicker.js → StylePanel/StylePanelButtonPicker.js} +52 -56
  91. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  92. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  93. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  94. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +26 -25
  95. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  96. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +47 -43
  97. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  98. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  99. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  100. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +3 -2
  101. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  102. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +39 -10
  103. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  104. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -21
  105. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  106. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js +15 -3
  107. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js.map +2 -2
  108. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +3 -3
  109. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +2 -2
  110. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +189 -80
  111. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  112. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +5 -4
  113. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  114. package/dist-cjs/lib/ui/components/menu-items.js +6 -0
  115. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  116. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +10 -1
  117. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  118. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
  119. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
  120. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +17 -4
  121. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  122. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +32 -7
  123. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  124. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +269 -0
  125. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +7 -0
  126. package/dist-cjs/lib/ui/components/primitives/layout.js +76 -0
  127. package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
  128. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  129. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
  130. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  131. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +154 -20
  132. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  133. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +3 -2
  134. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
  135. package/dist-cjs/lib/ui/context/actions.js +38 -10
  136. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  137. package/dist-cjs/lib/ui/context/components.js +2 -0
  138. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  139. package/dist-cjs/lib/ui/context/events.js.map +2 -2
  140. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  141. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  142. package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
  143. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  144. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  145. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +5 -0
  146. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  147. package/dist-cjs/lib/ui/kbd-utils.js +9 -3
  148. package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
  149. package/dist-cjs/lib/ui/version.js +3 -3
  150. package/dist-cjs/lib/ui/version.js.map +1 -1
  151. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  152. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  153. package/dist-cjs/lib/utils/export/export.js +0 -20
  154. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  155. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  156. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  157. package/dist-esm/index.d.mts +353 -105
  158. package/dist-esm/index.mjs +85 -29
  159. package/dist-esm/index.mjs.map +2 -2
  160. package/dist-esm/lib/Tldraw.mjs +14 -4
  161. package/dist-esm/lib/Tldraw.mjs.map +2 -2
  162. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  163. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  164. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -4
  165. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  166. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
  167. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  168. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +6 -0
  169. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  170. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  171. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  172. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  173. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  174. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
  175. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  176. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  177. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  178. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +19 -12
  179. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  180. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  181. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  182. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
  183. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  184. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
  185. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
  186. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
  187. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  188. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +6 -3
  189. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +2 -2
  190. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
  191. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
  192. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
  193. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  194. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -3
  195. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  196. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +5 -4
  197. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  198. package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
  199. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +0 -2
  200. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  201. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  202. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  203. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +10 -1
  204. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
  205. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
  206. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  207. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  208. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  209. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
  210. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  211. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
  212. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  213. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  214. package/dist-esm/lib/ui/TldrawUi.mjs +29 -14
  215. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  216. package/dist-esm/lib/ui/assetUrls.mjs +13 -10
  217. package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
  218. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +19 -0
  219. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +7 -0
  220. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +12 -3
  221. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  222. package/dist-esm/lib/ui/components/{FollowingIndicator.mjs → DefaultFollowingIndicator.mjs} +3 -3
  223. package/dist-esm/lib/ui/components/DefaultFollowingIndicator.mjs.map +7 -0
  224. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
  225. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
  226. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +6 -6
  227. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +1 -1
  228. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -5
  229. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
  230. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  231. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  232. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
  233. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  234. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +1 -1
  235. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
  236. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
  237. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  238. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
  239. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
  240. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
  241. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
  242. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +16 -5
  243. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  244. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +251 -283
  245. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  246. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +126 -0
  247. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  248. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  249. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  250. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +23 -22
  251. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  252. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +44 -40
  253. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  254. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  255. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  256. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +3 -2
  257. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  258. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +39 -10
  259. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  260. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -21
  261. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  262. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs +15 -3
  263. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs.map +2 -2
  264. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +3 -3
  265. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  266. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -81
  267. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  268. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +5 -4
  269. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  270. package/dist-esm/lib/ui/components/menu-items.mjs +6 -0
  271. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  272. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +10 -1
  273. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  274. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
  275. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
  276. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +17 -4
  277. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  278. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +32 -7
  279. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  280. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +246 -0
  281. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +7 -0
  282. package/dist-esm/lib/ui/components/primitives/layout.mjs +46 -0
  283. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
  284. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  285. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
  286. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  287. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +162 -22
  288. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  289. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +3 -2
  290. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
  291. package/dist-esm/lib/ui/context/actions.mjs +38 -10
  292. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  293. package/dist-esm/lib/ui/context/components.mjs +2 -0
  294. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  295. package/dist-esm/lib/ui/context/events.mjs.map +2 -2
  296. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  297. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  298. package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
  299. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  300. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +5 -0
  301. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  302. package/dist-esm/lib/ui/kbd-utils.mjs +9 -3
  303. package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
  304. package/dist-esm/lib/ui/version.mjs +3 -3
  305. package/dist-esm/lib/ui/version.mjs.map +1 -1
  306. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  307. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  308. package/dist-esm/lib/utils/export/export.mjs +0 -20
  309. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  310. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  311. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  312. package/package.json +11 -34
  313. package/src/index.ts +64 -22
  314. package/src/lib/Tldraw.tsx +15 -2
  315. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  316. package/src/lib/defaultExternalContentHandlers.ts +12 -4
  317. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
  318. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +4 -3
  319. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +7 -6
  320. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
  321. package/src/lib/shapes/arrow/arrowLabel.ts +8 -0
  322. package/src/lib/shapes/arrow/arrowTargetState.ts +2 -1
  323. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  324. package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
  325. package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
  326. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  327. package/src/lib/shapes/frame/FrameShapeUtil.tsx +29 -14
  328. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  329. package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
  330. package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
  331. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
  332. package/src/lib/shapes/image/ImageShapeUtil.tsx +6 -3
  333. package/src/lib/shapes/line/LineShapeUtil.test.tsx +4 -3
  334. package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
  335. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
  336. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
  337. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -6
  338. package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
  339. package/src/lib/shapes/shared/freehand/svg.ts +2 -0
  340. package/src/lib/shapes/shared/useEditablePlainText.ts +0 -6
  341. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  342. package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
  343. package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
  344. package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
  345. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  346. package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
  347. package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
  348. package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -1
  349. package/src/lib/ui/TldrawUi.tsx +33 -12
  350. package/src/lib/ui/assetUrls.ts +13 -10
  351. package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
  352. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
  353. package/src/lib/ui/components/{FollowingIndicator.tsx → DefaultFollowingIndicator.tsx} +2 -1
  354. package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
  355. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +6 -6
  356. package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -4
  357. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  358. package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
  359. package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +1 -1
  360. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +3 -2
  361. package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
  362. package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
  363. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +28 -12
  364. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +261 -343
  365. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +66 -50
  366. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  367. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +31 -22
  368. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  369. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  370. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +4 -3
  371. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +33 -16
  372. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
  373. package/src/lib/ui/components/Toolbar/DefaultVideoToolbarContent.tsx +12 -4
  374. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +5 -5
  375. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +212 -61
  376. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +14 -11
  377. package/src/lib/ui/components/menu-items.tsx +8 -0
  378. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +6 -1
  379. package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
  380. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +50 -30
  381. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +54 -12
  382. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +335 -0
  383. package/src/lib/ui/components/primitives/layout.tsx +107 -0
  384. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
  385. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
  386. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +221 -19
  387. package/src/lib/ui/context/TldrawUiContextProvider.tsx +23 -20
  388. package/src/lib/ui/context/actions.tsx +38 -10
  389. package/src/lib/ui/context/components.tsx +3 -0
  390. package/src/lib/ui/context/events.tsx +3 -1
  391. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  392. package/src/lib/ui/hooks/useTools.tsx +140 -10
  393. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +5 -0
  394. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +5 -0
  395. package/src/lib/ui/kbd-utils.ts +10 -3
  396. package/src/lib/ui/version.ts +3 -3
  397. package/src/lib/ui.css +424 -293
  398. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +5 -5
  399. package/src/lib/utils/export/copyAs.ts +1 -24
  400. package/src/lib/utils/export/export.ts +0 -36
  401. package/src/lib/utils/export/exportAs.ts +1 -32
  402. package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +4 -4
  403. package/src/test/A11y.test.tsx +3 -2
  404. package/src/test/ClickManager.test.ts +7 -6
  405. package/src/test/Editor.test.tsx +20 -19
  406. package/src/test/EraserTool.test.ts +184 -13
  407. package/src/test/HandTool.test.ts +10 -9
  408. package/src/test/HighlightShape.test.ts +2 -1
  409. package/src/test/SelectTool.test.ts +3 -2
  410. package/src/test/TLUserPreferences.test.ts +4 -3
  411. package/src/test/TestEditor.ts +13 -15
  412. package/src/test/TldrawEditor.test.tsx +11 -10
  413. package/src/test/ZoomTool.test.ts +7 -6
  414. package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
  415. package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
  416. package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
  417. package/src/test/arrows-megabus.test.tsx +17 -10
  418. package/src/test/bindings.test.tsx +24 -37
  419. package/src/test/bookmark-shapes.test.ts +1 -8
  420. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +23 -7
  421. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
  422. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  423. package/src/test/commands/alignShapes.test.tsx +25 -24
  424. package/src/test/commands/animationSpeed.test.ts +2 -1
  425. package/src/test/commands/centerOnPoint.test.ts +3 -2
  426. package/src/test/commands/clipboard.test.ts +3 -2
  427. package/src/test/commands/createShapes.test.ts +2 -1
  428. package/src/test/commands/deleteShapes.test.ts +2 -1
  429. package/src/test/commands/distributeShapes.test.tsx +11 -10
  430. package/src/test/commands/getSvgString.test.ts +2 -1
  431. package/src/test/commands/packShapes.test.ts +5 -4
  432. package/src/test/commands/resizeShape.test.ts +2 -1
  433. package/src/test/commands/rotateShapes.test.ts +7 -6
  434. package/src/test/commands/setCamera.test.ts +4 -3
  435. package/src/test/commands/setCurrentPage.test.ts +3 -2
  436. package/src/test/commands/stackShapes.test.ts +11 -10
  437. package/src/test/commands/stretch.test.tsx +13 -12
  438. package/src/test/createDeepLink.test.tsx +2 -1
  439. package/src/test/cropping.test.ts +3 -2
  440. package/src/test/custom-clipping.test.ts +436 -0
  441. package/src/test/drawing.test.ts +2 -1
  442. package/src/test/flipShapes.test.ts +4 -3
  443. package/src/test/frames.test.ts +25 -24
  444. package/src/test/getCulledShapes.test.tsx +3 -2
  445. package/src/test/groups.test.tsx +1 -1
  446. package/src/test/handleDeepLink.test.tsx +2 -1
  447. package/src/test/inner-outer-margin.test.ts +315 -0
  448. package/src/test/maxShapes.test.ts +3 -2
  449. package/src/test/modifiers.test.ts +5 -4
  450. package/src/test/navigation.test.ts +12 -11
  451. package/src/test/panning.test.ts +2 -1
  452. package/src/test/perf/perf.test.ts +2 -1
  453. package/src/test/registerDeepLinkListener.test.tsx +10 -9
  454. package/src/test/resizing.test.ts +39 -38
  455. package/src/test/select.test.tsx +4 -3
  456. package/src/test/selection-omnibus.test.ts +11 -10
  457. package/src/test/shapeutils.test.ts +4 -3
  458. package/src/test/translating.test.ts +9 -8
  459. package/tldraw.css +725 -581
  460. package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +0 -7
  461. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  462. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  463. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  464. package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +0 -7
  465. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  466. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  467. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -115
  468. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  469. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -109
@@ -26,14 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var DropdownPicker_exports = {};
30
- __export(DropdownPicker_exports, {
31
- DropdownPicker: () => DropdownPicker
29
+ var StylePanelDropdownPicker_exports = {};
30
+ __export(StylePanelDropdownPicker_exports, {
31
+ StylePanelDropdownPicker: () => StylePanelDropdownPicker
32
32
  });
33
- module.exports = __toCommonJS(DropdownPicker_exports);
33
+ module.exports = __toCommonJS(StylePanelDropdownPicker_exports);
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_editor = require("@tldraw/editor");
36
- var import_classnames = __toESM(require("classnames"));
37
36
  var React = __toESM(require("react"));
38
37
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
39
38
  var import_TldrawUiButtonIcon = require("../primitives/Button/TldrawUiButtonIcon");
@@ -41,17 +40,20 @@ var import_TldrawUiButtonLabel = require("../primitives/Button/TldrawUiButtonLab
41
40
  var import_TldrawUiPopover = require("../primitives/TldrawUiPopover");
42
41
  var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
43
42
  var import_TldrawUiMenuContext = require("../primitives/menus/TldrawUiMenuContext");
44
- function DropdownPickerInner({
45
- id,
46
- label,
47
- uiType,
48
- stylePanelType,
49
- style,
50
- items,
51
- type,
52
- value,
53
- onValueChange
54
- }) {
43
+ var import_StylePanelContext = require("./StylePanelContext");
44
+ function DropdownPickerInner(props) {
45
+ const ctx = (0, import_StylePanelContext.useStylePanelContext)();
46
+ const {
47
+ id,
48
+ label,
49
+ uiType,
50
+ stylePanelType,
51
+ style,
52
+ items,
53
+ type,
54
+ value,
55
+ onValueChange = ctx.onValueChange
56
+ } = props;
55
57
  const msg = (0, import_useTranslation.useTranslation)();
56
58
  const editor = (0, import_editor.useEditor)();
57
59
  const [isOpen, setIsOpen] = React.useState(false);
@@ -63,26 +65,28 @@ function DropdownPickerInner({
63
65
  const titleStr = value.type === "mixed" ? msg("style-panel.mixed") : stylePanelName + " \u2014 " + msg(`${uiType}-style.${value.value}`);
64
66
  const labelStr = label ? msg(label) : "";
65
67
  const popoverId = `style panel ${id}`;
66
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiPopover.TldrawUiPopover, { id: popoverId, open: isOpen, onOpenChange: setIsOpen, children: [
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
68
- import_TldrawUiToolbar.TldrawUiToolbarButton,
69
- {
70
- type,
71
- "data-testid": `style.${uiType}`,
72
- "data-direction": "left",
73
- title: titleStr,
74
- children: [
75
- labelStr && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonLabel.TldrawUiButtonLabel, { children: labelStr }),
76
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: icon ?? "mixed" })
77
- ]
78
- }
79
- ) }),
80
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverContent, { side: "left", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
- import_TldrawUiToolbar.TldrawUiToolbar,
82
- {
83
- label: labelStr,
84
- className: (0, import_classnames.default)("tlui-buttons__grid", `tlui-buttons__${stylePanelType}`),
85
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "icons", sourceId: "style-panel", children: items.map((item) => {
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { label: stylePanelName, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
69
+ import_TldrawUiPopover.TldrawUiPopover,
70
+ {
71
+ id: popoverId,
72
+ open: isOpen,
73
+ onOpenChange: setIsOpen,
74
+ className: "tlui-style-panel__dropdown-picker",
75
+ children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
77
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
78
+ {
79
+ type,
80
+ "data-testid": `style.${uiType}`,
81
+ "data-direction": "left",
82
+ title: titleStr,
83
+ children: [
84
+ labelStr && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonLabel.TldrawUiButtonLabel, { children: labelStr }),
85
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: icon ?? "mixed" })
86
+ ]
87
+ }
88
+ ) }),
89
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverContent, { side: "left", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: items.length > 4 ? "grid" : "horizontal", label: labelStr, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "icons", sourceId: "style-panel", children: items.map((item) => {
86
90
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
87
91
  import_TldrawUiToolbar.TldrawUiToolbarButton,
88
92
  {
@@ -91,7 +95,7 @@ function DropdownPickerInner({
91
95
  title: stylePanelName + " \u2014 " + msg(`${uiType}-style.${item.value}`),
92
96
  isActive: icon === item.icon,
93
97
  onClick: () => {
94
- editor.markHistoryStoppingPoint("select style dropdown item");
98
+ ctx.onHistoryMark("select style dropdown item");
95
99
  onValueChange(style, item.value);
96
100
  import_editor.tlmenus.deleteOpenMenu(popoverId, editor.contextId);
97
101
  setIsOpen(false);
@@ -100,10 +104,10 @@ function DropdownPickerInner({
100
104
  },
101
105
  item.value
102
106
  );
103
- }) })
104
- }
105
- ) })
106
- ] });
107
+ }) }) }) })
108
+ ]
109
+ }
110
+ ) });
107
111
  }
108
- const DropdownPicker = React.memo(DropdownPickerInner);
109
- //# sourceMappingURL=DropdownPicker.js.map
112
+ const StylePanelDropdownPicker = React.memo(DropdownPickerInner);
113
+ //# sourceMappingURL=StylePanelDropdownPicker.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx"],
4
+ "sourcesContent": ["import { SharedStyle, StyleProp, tlmenus, useEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { StyleValuesForUi } from '../../../styles'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TLUiIconType } from '../../icon-types'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../primitives/Button/TldrawUiButtonLabel'\nimport {\n\tTldrawUiPopover,\n\tTldrawUiPopoverContent,\n\tTldrawUiPopoverTrigger,\n} from '../primitives/TldrawUiPopover'\nimport { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\nimport { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'\nimport { useStylePanelContext } from './StylePanelContext'\n\n/** @public */\nexport interface StylePanelDropdownPickerProps<T extends string> {\n\tid: string\n\tlabel?: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>\n\tuiType: string\n\tstylePanelType: string\n\tstyle: StyleProp<T>\n\tvalue: SharedStyle<T>\n\titems: StyleValuesForUi<T>\n\ttype: 'icon' | 'tool' | 'menu'\n\tonValueChange?(style: StyleProp<T>, value: T): void\n}\n\nfunction DropdownPickerInner<T extends string>(props: StylePanelDropdownPickerProps<T>) {\n\tconst ctx = useStylePanelContext()\n\tconst {\n\t\tid,\n\t\tlabel,\n\t\tuiType,\n\t\tstylePanelType,\n\t\tstyle,\n\t\titems,\n\t\ttype,\n\t\tvalue,\n\t\tonValueChange = ctx.onValueChange,\n\t} = props\n\tconst msg = useTranslation()\n\tconst editor = useEditor()\n\tconst [isOpen, setIsOpen] = React.useState(false)\n\n\tconst icon = React.useMemo(\n\t\t() => items.find((item) => value.type === 'shared' && item.value === value.value)?.icon,\n\t\t[items, value]\n\t)\n\n\tconst stylePanelName = msg(`style-panel.${stylePanelType}` as TLUiTranslationKey)\n\n\tconst titleStr =\n\t\tvalue.type === 'mixed'\n\t\t\t? msg('style-panel.mixed')\n\t\t\t: stylePanelName + ' \u2014 ' + msg(`${uiType}-style.${value.value}` as TLUiTranslationKey)\n\tconst labelStr = label ? msg(label) : ''\n\n\tconst popoverId = `style panel ${id}`\n\treturn (\n\t\t<TldrawUiToolbar label={stylePanelName}>\n\t\t\t<TldrawUiPopover\n\t\t\t\tid={popoverId}\n\t\t\t\topen={isOpen}\n\t\t\t\tonOpenChange={setIsOpen}\n\t\t\t\tclassName=\"tlui-style-panel__dropdown-picker\"\n\t\t\t>\n\t\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\tdata-testid={`style.${uiType}`}\n\t\t\t\t\t\tdata-direction=\"left\"\n\t\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\t>\n\t\t\t\t\t\t{labelStr && <TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>}\n\t\t\t\t\t\t<TldrawUiButtonIcon icon={(icon as TLUiIconType) ?? 'mixed'} />\n\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t\t<TldrawUiPopoverContent side=\"left\" align=\"center\">\n\t\t\t\t\t<TldrawUiToolbar orientation={items.length > 4 ? 'grid' : 'horizontal'} label={labelStr}>\n\t\t\t\t\t\t<TldrawUiMenuContextProvider type=\"icons\" sourceId=\"style-panel\">\n\t\t\t\t\t\t\t{items.map((item) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\t\t\t\tdata-testid={`style.${uiType}.${item.value}`}\n\t\t\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\t\t\tstylePanelName +\n\t\t\t\t\t\t\t\t\t\t\t' \u2014 ' +\n\t\t\t\t\t\t\t\t\t\t\tmsg(`${uiType}-style.${item.value}` as TLUiTranslationKey)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisActive={icon === item.icon}\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\tctx.onHistoryMark('select style dropdown item')\n\t\t\t\t\t\t\t\t\t\t\tonValueChange(style, item.value)\n\t\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(popoverId, editor.contextId)\n\t\t\t\t\t\t\t\t\t\t\tsetIsOpen(false)\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={item.icon} />\n\t\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t</TldrawUiPopoverContent>\n\t\t\t</TldrawUiPopover>\n\t\t</TldrawUiToolbar>\n\t)\n}\n\n// need to export like this to get generics\n/** @public @react */\nexport const StylePanelDropdownPicker = React.memo(DropdownPickerInner) as <T extends string>(\n\tprops: StylePanelDropdownPickerProps<T>\n) => React.JSX.Element\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsEK;AAtEL,oBAA2D;AAC3D,YAAuB;AAGvB,4BAA+B;AAE/B,gCAAmC;AACnC,iCAAoC;AACpC,6BAIO;AACP,6BAAuD;AACvD,iCAA4C;AAC5C,+BAAqC;AAerC,SAAS,oBAAsC,OAAyC;AACvF,QAAM,UAAM,+CAAqB;AACjC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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AAG,MAAM,UAAU,KAAK,KAAK,EAAwB;AAAA,cAE1D,UAAU,SAAS,KAAK;AAAA,cACxB,SAAS,MAAM;AACd,oBAAI,cAAc,4BAA4B;AAC9C,8BAAc,OAAO,KAAK,KAAK;AAC/B,sCAAQ,eAAe,WAAW,OAAO,SAAS;AAClD,0BAAU,KAAK;AAAA,cAChB;AAAA,cAEA,sDAAC,gDAAmB,MAAM,KAAK,MAAM;AAAA;AAAA,YAhBhC,KAAK;AAAA,UAiBX;AAAA,QAEF,CAAC,GACF,GACD,GACD;AAAA;AAAA;AAAA,EACD,GACD;AAEF;AAIO,MAAM,2BAA2B,MAAM,KAAK,mBAAmB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var StylePanelSubheading_exports = {};
20
+ __export(StylePanelSubheading_exports, {
21
+ StylePanelSubheading: () => StylePanelSubheading
22
+ });
23
+ module.exports = __toCommonJS(StylePanelSubheading_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ function StylePanelSubheading({ children }) {
26
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "tlui-style-panel__subheading", children });
27
+ }
28
+ //# sourceMappingURL=StylePanelSubheading.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/lib/ui/components/StylePanel/StylePanelSubheading.tsx"],
4
+ "sourcesContent": ["/** @public */\nexport interface StylePanelSubheadingProps {\n\tchildren: React.ReactNode\n}\n\n/** @public @react */\nexport function StylePanelSubheading({ children }: StylePanelSubheadingProps) {\n\treturn <h3 className=\"tlui-style-panel__subheading\">{children}</h3>\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOQ;AADD,SAAS,qBAAqB,EAAE,SAAS,GAA8B;AAC7E,SAAO,4CAAC,QAAG,WAAU,gCAAgC,UAAS;AAC/D;",
6
+ "names": []
7
+ }
@@ -26,9 +26,9 @@ var import_editor = require("@tldraw/editor");
26
26
  var import_react = require("react");
27
27
  var import_events = require("../../context/events");
28
28
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
29
- var import_TldrawUiButton = require("../primitives/Button/TldrawUiButton");
30
29
  var import_TldrawUiButtonIcon = require("../primitives/Button/TldrawUiButtonIcon");
31
30
  var import_TldrawUiInput = require("../primitives/TldrawUiInput");
31
+ var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
32
32
  function AltTextEditor({ shapeId, onClose, source }) {
33
33
  const editor = (0, import_editor.useEditor)();
34
34
  const [altText, setAltText] = (0, import_react.useState)(() => {
@@ -86,9 +86,10 @@ function AltTextEditor({ shapeId, onClose, source }) {
86
86
  }
87
87
  ),
88
88
  !isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
- import_TldrawUiButton.TldrawUiButton,
89
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
90
90
  {
91
91
  title: msg("tool.media-alt-text-confirm"),
92
+ "data-testid": "tool.media-alt-text-confirm",
92
93
  type: "icon",
93
94
  onPointerDown: import_editor.preventDefault,
94
95
  onClick: handleConfirm,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/AltTextEditor.tsx"],
4
- "sourcesContent": ["import { preventDefault, TLShape, TLShapeId, useEditor } from '@tldraw/editor'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { useUiEvents } from '../../context/events'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButton } from '../primitives/Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiInput } from '../primitives/TldrawUiInput'\n\n/** @public */\nexport interface AltTextEditorProps {\n\tshapeId: TLShapeId\n\tonClose(): void\n\tsource: 'image-toolbar' | 'video-toolbar'\n}\n\n/** @public @react */\nexport function AltTextEditor({ shapeId, onClose, source }: AltTextEditorProps) {\n\tconst editor = useEditor()\n\tconst [altText, setAltText] = useState(() => {\n\t\tconst shape = editor.getShape<TLShape>(shapeId)\n\t\tif (!shape) return ''\n\t\tif (!('altText' in shape.props)) throw Error('Shape does not have altText property')\n\t\treturn shape.props.altText || ''\n\t})\n\tconst msg = useTranslation()\n\tconst ref = useRef<HTMLInputElement>(null)\n\tconst trackEvent = useUiEvents()\n\tconst isReadonly = editor.getIsReadonly()\n\n\tconst handleValueChange = (value: string) => setAltText(value)\n\n\tconst handleComplete = () => {\n\t\ttrackEvent('set-alt-text', { source })\n\t\tconst shape = editor.getShape<TLShape & { props: { altText: string } }>(shapeId)\n\t\tif (!shape) return\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: { altText },\n\t\t\t},\n\t\t])\n\t\tonClose()\n\t}\n\n\tconst handleConfirm = () => handleComplete()\n\tconst handleAltTextCancel = useCallback(() => onClose(), [onClose])\n\n\tuseEffect(() => {\n\t\tref.current?.select()\n\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (event.key === 'Escape') {\n\t\t\t\tevent.stopPropagation()\n\t\t\t\thandleAltTextCancel()\n\t\t\t}\n\t\t}\n\n\t\tdocument.addEventListener('keydown', handleKeyDown, { capture: true })\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('keydown', handleKeyDown, { capture: true })\n\t\t}\n\t}, [handleAltTextCancel])\n\n\treturn (\n\t\t<>\n\t\t\t<TldrawUiInput\n\t\t\t\tref={ref}\n\t\t\t\tclassName=\"tlui-media__toolbar-alt-text-input\"\n\t\t\t\tdata-testid=\"media-toolbar.alt-text-input\"\n\t\t\t\tvalue={altText}\n\t\t\t\tplaceholder={msg('tool.media-alt-text-desc')}\n\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\tonComplete={handleComplete}\n\t\t\t\tonCancel={handleAltTextCancel}\n\t\t\t\tdisabled={isReadonly}\n\t\t\t/>\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\ttitle={msg('tool.media-alt-text-confirm')}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\tonPointerDown={preventDefault}\n\t\t\t\t\tonClick={handleConfirm}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"check\" />\n\t\t\t\t</TldrawUiButton>\n\t\t\t)}\n\t\t</>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEE;AAjEF,oBAA8D;AAC9D,mBAAyD;AACzD,oBAA4B;AAC5B,4BAA+B;AAC/B,4BAA+B;AAC/B,gCAAmC;AACnC,2BAA8B;AAUvB,SAAS,cAAc,EAAE,SAAS,SAAS,OAAO,GAAuB;AAC/E,QAAM,aAAS,yBAAU;AACzB,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,MAAM;AAC5C,UAAM,QAAQ,OAAO,SAAkB,OAAO;AAC9C,QAAI,CAAC,MAAO,QAAO;AACnB,QAAI,EAAE,aAAa,MAAM,OAAQ,OAAM,MAAM,sCAAsC;AACnF,WAAO,MAAM,MAAM,WAAW;AAAA,E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AAA,QACf,SAAS;AAAA,QAET,sDAAC,gDAAmB,OAAK,MAAC,MAAK,SAAQ;AAAA;AAAA,IACxC;AAAA,KAEF;AAEF;",
4
+ "sourcesContent": ["import { preventDefault, TLShape, TLShapeId, useEditor } from '@tldraw/editor'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { useUiEvents } from '../../context/events'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiInput } from '../primitives/TldrawUiInput'\nimport { TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\n\n/** @public */\nexport interface AltTextEditorProps {\n\tshapeId: TLShapeId\n\tonClose(): void\n\tsource: 'image-toolbar' | 'video-toolbar'\n}\n\n/** @public @react */\nexport function AltTextEditor({ shapeId, onClose, source }: AltTextEditorProps) {\n\tconst editor = useEditor()\n\tconst [altText, setAltText] = useState(() => {\n\t\tconst shape = editor.getShape<TLShape>(shapeId)\n\t\tif (!shape) return ''\n\t\tif (!('altText' in shape.props)) throw Error('Shape does not have altText property')\n\t\treturn shape.props.altText || ''\n\t})\n\tconst msg = useTranslation()\n\tconst ref = useRef<HTMLInputElement>(null)\n\tconst trackEvent = useUiEvents()\n\tconst isReadonly = editor.getIsReadonly()\n\n\tconst handleValueChange = (value: string) => setAltText(value)\n\n\tconst handleComplete = () => {\n\t\ttrackEvent('set-alt-text', { source })\n\t\tconst shape = editor.getShape<TLShape & { props: { altText: string } }>(shapeId)\n\t\tif (!shape) return\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: { altText },\n\t\t\t},\n\t\t])\n\t\tonClose()\n\t}\n\n\tconst handleConfirm = () => handleComplete()\n\tconst handleAltTextCancel = useCallback(() => onClose(), [onClose])\n\n\tuseEffect(() => {\n\t\tref.current?.select()\n\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (event.key === 'Escape') {\n\t\t\t\tevent.stopPropagation()\n\t\t\t\thandleAltTextCancel()\n\t\t\t}\n\t\t}\n\n\t\tdocument.addEventListener('keydown', handleKeyDown, { capture: true })\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('keydown', handleKeyDown, { capture: true })\n\t\t}\n\t}, [handleAltTextCancel])\n\n\treturn (\n\t\t<>\n\t\t\t<TldrawUiInput\n\t\t\t\tref={ref}\n\t\t\t\tclassName=\"tlui-media__toolbar-alt-text-input\"\n\t\t\t\tdata-testid=\"media-toolbar.alt-text-input\"\n\t\t\t\tvalue={altText}\n\t\t\t\tplaceholder={msg('tool.media-alt-text-desc')}\n\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\tonComplete={handleComplete}\n\t\t\t\tonCancel={handleAltTextCancel}\n\t\t\t\tdisabled={isReadonly}\n\t\t\t/>\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttitle={msg('tool.media-alt-text-confirm')}\n\t\t\t\t\tdata-testid=\"tool.media-alt-text-confirm\"\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\tonPointerDown={preventDefault}\n\t\t\t\t\tonClick={handleConfirm}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"check\" />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)}\n\t\t</>\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEE;AAjEF,oBAA8D;AAC9D,mBAAyD;AACzD,oBAA4B;AAC5B,4BAA+B;AAC/B,gCAAmC;AACnC,2BAA8B;AAC9B,6BAAsC;AAU/B,SAAS,cAAc,EAAE,SAAS,SAAS,OAAO,GAAuB;AAC/E,QAAM,aAAS,yBAAU;AACzB,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,MAAM;AAC5C,UAAM,QAAQ,OAAO,SAAkB,OAAO;AAC9C,QAAI,CAAC,MA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AA,IACC,CAAC,cACD;AAAA,MAAC;AAAA;AAAA,QACA,OAAO,IAAI,6BAA6B;AAAA,QACxC,eAAY;AAAA,QACZ,MAAK;AAAA,QACL,eAAe;AAAA,QACf,SAAS;AAAA,QAET,sDAAC,gDAAmB,OAAK,MAAC,MAAK,SAAQ;AAAA;AAAA,IACxC;AAAA,KAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -28,11 +28,11 @@ var import_crop = require("../../../shapes/shared/crop");
28
28
  var import_actions = require("../../context/actions");
29
29
  var import_events = require("../../context/events");
30
30
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
31
- var import_TldrawUiButton = require("../primitives/Button/TldrawUiButton");
32
31
  var import_TldrawUiButtonIcon = require("../primitives/Button/TldrawUiButtonIcon");
33
32
  var import_TldrawUiButtonLabel = require("../primitives/Button/TldrawUiButtonLabel");
34
33
  var import_TldrawUiDropdownMenu = require("../primitives/TldrawUiDropdownMenu");
35
34
  var import_TldrawUiSlider = require("../primitives/TldrawUiSlider");
35
+ var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
36
36
  const DefaultImageToolbarContent = (0, import_editor.track)(function DefaultImageToolbarContent2({
37
37
  imageShapeId,
38
38
  isManipulating,
@@ -184,7 +184,15 @@ const DefaultImageToolbarContent = (0, import_editor.track)(function DefaultImag
184
184
  }
185
185
  ),
186
186
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiDropdownMenu.TldrawUiDropdownMenuRoot, { id: "image-toolbar-aspect-ratio", children: [
187
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiDropdownMenu.TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButton.TldrawUiButton, { title: msg("tool.aspect-ratio"), type: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "corners" }) }) }),
187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiDropdownMenu.TldrawUiDropdownMenuTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
189
+ {
190
+ title: msg("tool.aspect-ratio"),
191
+ type: "icon",
192
+ "data-testid": "tool.image-aspect-ratio",
193
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "corners" })
194
+ }
195
+ ) }),
188
196
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiDropdownMenu.TldrawUiDropdownMenuContent, { side: "top", align: "center", children: import_crop.ASPECT_RATIO_OPTIONS.map((aspectRatio) => {
189
197
  let checked = false;
190
198
  if (isOriginalCrop) {
@@ -215,34 +223,55 @@ const DefaultImageToolbarContent = (0, import_editor.track)(function DefaultImag
215
223
  }) })
216
224
  ] }),
217
225
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
218
- import_TldrawUiButton.TldrawUiButton,
226
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
219
227
  {
220
228
  type: "icon",
221
229
  onClick: onManipulatingEnd,
222
- "data-testid": "tool.image-confirm",
223
- style: { borderLeft: "1px solid var(--color-divider)", marginLeft: "2px" },
230
+ "data-testid": "tool.image-crop-confirm",
231
+ style: { borderLeft: "1px solid var(--tl-color-divider)", marginLeft: "2px" },
232
+ title: msg("tool.image-crop-confirm"),
224
233
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "check" })
225
234
  }
226
235
  )
227
236
  ] });
228
237
  }
229
238
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
230
- !isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButton.TldrawUiButton, { type: "icon", title: msg("tool.replace-media"), onClick: handleImageReplace, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "tool-media" }) }),
231
- !isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButton.TldrawUiButton, { type: "icon", title: msg("tool.image-crop"), onClick: onManipulatingStart, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "crop" }) }),
239
+ !isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
240
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
241
+ {
242
+ type: "icon",
243
+ "data-testid": "tool.image-replace",
244
+ onClick: handleImageReplace,
245
+ title: msg("tool.replace-media"),
246
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "tool-media" })
247
+ }
248
+ ),
249
+ !isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
250
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
251
+ {
252
+ type: "icon",
253
+ title: msg("tool.image-crop"),
254
+ onClick: onManipulatingStart,
255
+ "data-testid": "tool.image-crop",
256
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "crop" })
257
+ }
258
+ ),
232
259
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
233
- import_TldrawUiButton.TldrawUiButton,
260
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
234
261
  {
235
262
  type: "icon",
236
263
  title: msg("action.download-original"),
237
264
  onClick: handleImageDownload,
265
+ "data-testid": "tool.image-download",
238
266
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "download" })
239
267
  }
240
268
  ),
241
269
  (altText || !isReadonly) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
242
- import_TldrawUiButton.TldrawUiButton,
270
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
243
271
  {
244
- type: "normal",
272
+ type: "icon",
245
273
  title: msg("tool.media-alt-text"),
274
+ "data-testid": "tool.image-alt-text",
246
275
  onClick: () => {
247
276
  trackEvent("alt-text-start", { source });
248
277
  onEditAltTextStart();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx"],
4
- "sourcesContent": ["import {\n\tapproximately,\n\tisEqual,\n\tkickoutOccludedShapes,\n\tmodulate,\n\tTLImageShape,\n\tTLShapePartial,\n\ttrack,\n\tuseEditor,\n\tuseValue,\n} from '@tldraw/editor'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n\tASPECT_RATIO_OPTION,\n\tASPECT_RATIO_OPTIONS,\n\tASPECT_RATIO_TO_VALUE,\n\tgetCroppedImageDataForAspectRatio,\n\tgetCroppedImageDataWhenZooming,\n\tgetDefaultCrop,\n\tMAX_ZOOM,\n} from '../../../shapes/shared/crop'\nimport { useActions } from '../../context/actions'\nimport { useUiEvents } from '../../context/events'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButton } from '../primitives/Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../primitives/Button/TldrawUiButtonLabel'\nimport {\n\tTldrawUiDropdownMenuCheckboxItem,\n\tTldrawUiDropdownMenuContent,\n\tTldrawUiDropdownMenuRoot,\n\tTldrawUiDropdownMenuTrigger,\n} from '../primitives/TldrawUiDropdownMenu'\nimport { TldrawUiSlider } from '../primitives/TldrawUiSlider'\n\n/** @public */\nexport interface DefaultImageToolbarContentProps {\n\timageShapeId: TLImageShape['id']\n\tisManipulating: boolean\n\tonEditAltTextStart(): void\n\tonManipulatingStart(): void\n\tonManipulatingEnd(): void\n}\n\n/** @public @react */\nexport const DefaultImageToolbarContent = track(function DefaultImageToolbarContent({\n\timageShapeId,\n\tisManipulating,\n\tonEditAltTextStart,\n\tonManipulatingStart,\n\tonManipulatingEnd,\n}: DefaultImageToolbarContentProps) {\n\tconst editor = useEditor()\n\tconst trackEvent = useUiEvents()\n\tconst msg = useTranslation()\n\tconst source = 'image-toolbar'\n\tconst sliderRef = useRef<HTMLDivElement>(null)\n\tconst isReadonly = editor.getIsReadonly()\n\n\tconst crop = useValue('crop', () => editor.getShape<TLImageShape>(imageShapeId)!.props.crop, [\n\t\teditor,\n\t\timageShapeId,\n\t])\n\tconst zoom = crop\n\t\t? Math.min(1 - (crop.bottomRight.x - crop.topLeft.x), 1 - (crop.bottomRight.y - crop.topLeft.y))\n\t\t: 0\n\tconst [maxZoom, setMaxZoom] = useState<number | undefined>(\n\t\tcrop ? Math.max(zoom, 1 - 1 / MAX_ZOOM) : MAX_ZOOM\n\t)\n\tconst actions = useActions()\n\n\t// So, we set a maxZoom here in case there's been a manual crop applied.\n\t// Typically, you can zoom 3x into the image size (MAX_ZOOM's value).\n\t// If you go deeper than that zoom level, we need to set that as the new 100%\n\t// value on the zoom slider (otherwise you could zoom into infinity).\n\t// This balances usage of the zoom slider with manual cropping.\n\tuseEffect(() => {\n\t\tsetMaxZoom(crop ? Math.max(zoom, 1 - 1 / MAX_ZOOM) : MAX_ZOOM)\n\t}, [crop, zoom, maxZoom])\n\n\tconst onHistoryMark = useCallback((id: string) => editor.markHistoryStoppingPoint(id), [editor])\n\n\t// Apply an easing function to smooth out the zoom curve,\n\t// otherwise the zoom slider has a cubic drag feel to it which feels off.\n\tconst easeZoom = useCallback((value: number, maxValue: number): number => {\n\t\tconst maxRatioConversion = MAX_ZOOM / (MAX_ZOOM - 1)\n\t\t// Use an easing function for a more natural zoom feel\n\t\treturn Math.pow(value / maxValue, maxRatioConversion) * maxValue\n\t}, [])\n\n\tconst displayValue =\n\t\tcrop && maxZoom\n\t\t\t? modulate(easeZoom(zoom, maxZoom), [0, maxZoom], [0, 100], true /* clamp */)\n\t\t\t: 0\n\n\tconst handleZoomChange = useCallback(\n\t\t(value: number) => {\n\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t// Convert the eased slider value back to the actual zoom value\n\t\t\tconst sliderPercent = value / 100\n\n\t\t\t// Convert the slider position back into the \"zoom\" value expected by\n\t\t\t// getCroppedImageDataWhenZooming.\n\t\t\t// 1. Undo the easing: z_out = sliderPercent^(1/maxRatioConversion) * maxZoom\n\t\t\t// 2. Translate z_out into the function's input domain. The helper computes\n\t\t\t// the *resulting* zoom (z_out) using:\n\t\t\t// z_out = 2 * z_in / (1 + 2 * z_in)\n\t\t\t// Solving for z_in gives:\n\t\t\t// z_in = z_out / (2 * (1 - z_out))\n\t\t\tconst maxDimension = 1 - 1 / MAX_ZOOM\n\t\t\tconst clampedMaxZoom = Math.min(maxDimension, maxZoom ?? maxDimension)\n\t\t\tconst maxRatioConversion = MAX_ZOOM / (MAX_ZOOM - 1)\n\t\t\tconst zOut = Math.pow(sliderPercent, 1 / maxRatioConversion) * clampedMaxZoom\n\t\t\tconst zoom = zOut >= 1 ? 1 : zOut / (2 * (1 - zOut))\n\t\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)\n\t\t\tif (!imageShape) return\n\n\t\t\tconst change = getCroppedImageDataWhenZooming(zoom, imageShape, maxZoom)\n\n\t\t\teditor.updateShape({\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tx: change.x,\n\t\t\t\ty: change.y,\n\t\t\t\tprops: {\n\t\t\t\t\tw: change.w,\n\t\t\t\t\th: change.h,\n\t\t\t\t\tcrop: change.crop,\n\t\t\t\t},\n\t\t\t} as TLShapePartial)\n\n\t\t\ttrackEvent('set-style', { source: 'image-toolbar', id: 'zoom', value })\n\t\t},\n\t\t[editor, trackEvent, imageShapeId, maxZoom]\n\t)\n\n\tconst handleImageReplace = useCallback(\n\t\t() => actions['image-replace'].onSelect('image-toolbar'),\n\t\t[actions]\n\t)\n\n\tconst handleImageDownload = useCallback(\n\t\t() => actions['download-original'].onSelect('image-toolbar'),\n\t\t[actions]\n\t)\n\n\tconst handleAspectRatioChange = (aspectRatio: ASPECT_RATIO_OPTION) => {\n\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)\n\t\tif (!imageShape) return\n\t\teditor.run(() => {\n\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\tconst change = getCroppedImageDataForAspectRatio(aspectRatio, imageShape)\n\t\t\teditor.markHistoryStoppingPoint('aspect ratio')\n\t\t\teditor.updateShape({\n\t\t\t\tid: imageShapeId,\n\t\t\t\ttype: 'image',\n\t\t\t\tx: change.x,\n\t\t\t\ty: change.y,\n\t\t\t\tprops: {\n\t\t\t\t\tcrop: change.crop,\n\t\t\t\t\tw: change.w,\n\t\t\t\t\th: change.h,\n\t\t\t\t},\n\t\t\t} as TLShapePartial)\n\t\t\tkickoutOccludedShapes(editor, [imageShapeId])\n\t\t})\n\t}\n\n\tconst altText = useValue(\n\t\t'altText',\n\t\t() => editor.getShape<TLImageShape>(imageShapeId)!.props.altText,\n\t\t[editor, imageShapeId]\n\t)\n\tconst shapeAspectRatio = useValue(\n\t\t'shapeAspectRatio',\n\t\t() => {\n\t\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)!\n\t\t\treturn imageShape.props.w / imageShape.props.h\n\t\t},\n\t\t[editor, imageShapeId]\n\t)\n\tconst isOriginalCrop = !crop || isEqual(crop, getDefaultCrop())\n\n\tuseEffect(() => {\n\t\tif (isManipulating) {\n\t\t\teditor.timers.setTimeout(() => sliderRef.current?.focus(), 0)\n\t\t}\n\t}, [editor, isManipulating])\n\n\tuseEffect(() => {\n\t\tfunction handleKeyDown(e: KeyboardEvent) {\n\t\t\tif (isManipulating) {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\teditor.cancel()\n\t\t\t\t\tonManipulatingEnd()\n\t\t\t\t} else if (e.key === 'Enter') {\n\t\t\t\t\teditor.complete()\n\t\t\t\t\tonManipulatingEnd()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst elm = sliderRef.current\n\t\tif (elm) {\n\t\t\telm.addEventListener('keydown', handleKeyDown)\n\t\t}\n\t\treturn () => {\n\t\t\tif (elm) {\n\t\t\t\telm.removeEventListener('keydown', handleKeyDown)\n\t\t\t}\n\t\t}\n\t}, [editor, isManipulating, onManipulatingEnd])\n\n\tif (isManipulating) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<TldrawUiSlider\n\t\t\t\t\tref={sliderRef}\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tlabel=\"tool.image-zoom\"\n\t\t\t\t\tonValueChange={handleZoomChange}\n\t\t\t\t\tonHistoryMark={onHistoryMark}\n\t\t\t\t\tmin={0}\n\t\t\t\t\tsteps={100}\n\t\t\t\t\tdata-testid=\"tool.image-zoom\"\n\t\t\t\t\ttitle={msg('tool.image-zoom')}\n\t\t\t\t/>\n\t\t\t\t<TldrawUiDropdownMenuRoot id=\"image-toolbar-aspect-ratio\">\n\t\t\t\t\t<TldrawUiDropdownMenuTrigger>\n\t\t\t\t\t\t<TldrawUiButton title={msg('tool.aspect-ratio')} type=\"icon\">\n\t\t\t\t\t\t\t<TldrawUiButtonIcon icon=\"corners\" />\n\t\t\t\t\t\t</TldrawUiButton>\n\t\t\t\t\t</TldrawUiDropdownMenuTrigger>\n\t\t\t\t\t<TldrawUiDropdownMenuContent side=\"top\" align=\"center\">\n\t\t\t\t\t\t{ASPECT_RATIO_OPTIONS.map((aspectRatio) => {\n\t\t\t\t\t\t\tlet checked = false\n\t\t\t\t\t\t\tif (isOriginalCrop) {\n\t\t\t\t\t\t\t\tif (aspectRatio === 'original') {\n\t\t\t\t\t\t\t\t\tchecked = true\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (aspectRatio === 'circle') {\n\t\t\t\t\t\t\t\t\tchecked = !!crop.isCircle\n\t\t\t\t\t\t\t\t} else if (aspectRatio === 'square') {\n\t\t\t\t\t\t\t\t\tchecked =\n\t\t\t\t\t\t\t\t\t\t!crop?.isCircle &&\n\t\t\t\t\t\t\t\t\t\tapproximately(shapeAspectRatio, ASPECT_RATIO_TO_VALUE[aspectRatio], 0.1)\n\t\t\t\t\t\t\t\t} else if (aspectRatio === 'original') {\n\t\t\t\t\t\t\t\t\tchecked = false\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchecked =\n\t\t\t\t\t\t\t\t\t\t!isOriginalCrop &&\n\t\t\t\t\t\t\t\t\t\tapproximately(shapeAspectRatio, ASPECT_RATIO_TO_VALUE[aspectRatio], 0.01)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<TldrawUiDropdownMenuCheckboxItem\n\t\t\t\t\t\t\t\t\tkey={aspectRatio}\n\t\t\t\t\t\t\t\t\tonSelect={() => handleAspectRatioChange(aspectRatio as ASPECT_RATIO_OPTION)}\n\t\t\t\t\t\t\t\t\tchecked={checked}\n\t\t\t\t\t\t\t\t\ttitle={msg(`tool.aspect-ratio.${aspectRatio}`)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiButtonLabel>\n\t\t\t\t\t\t\t\t\t\t{msg(`tool.aspect-ratio.${aspectRatio}`)}\n\t\t\t\t\t\t\t\t\t</TldrawUiButtonLabel>\n\t\t\t\t\t\t\t\t</TldrawUiDropdownMenuCheckboxItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</TldrawUiDropdownMenuContent>\n\t\t\t\t</TldrawUiDropdownMenuRoot>\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\tonClick={onManipulatingEnd}\n\t\t\t\t\tdata-testid=\"tool.image-confirm\"\n\t\t\t\t\tstyle={{ borderLeft: '1px solid var(--color-divider)', marginLeft: '2px' }}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"check\" />\n\t\t\t\t</TldrawUiButton>\n\t\t\t</>\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiButton type=\"icon\" title={msg('tool.replace-media')} onClick={handleImageReplace}>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"tool-media\" />\n\t\t\t\t</TldrawUiButton>\n\t\t\t)}\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiButton type=\"icon\" title={msg('tool.image-crop')} onClick={onManipulatingStart}>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"crop\" />\n\t\t\t\t</TldrawUiButton>\n\t\t\t)}\n\t\t\t<TldrawUiButton\n\t\t\t\ttype=\"icon\"\n\t\t\t\ttitle={msg('action.download-original')}\n\t\t\t\tonClick={handleImageDownload}\n\t\t\t>\n\t\t\t\t<TldrawUiButtonIcon small icon=\"download\" />\n\t\t\t</TldrawUiButton>\n\t\t\t{(altText || !isReadonly) && (\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\ttype=\"normal\"\n\t\t\t\t\ttitle={msg('tool.media-alt-text')}\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\ttrackEvent('alt-text-start', { source })\n\t\t\t\t\t\tonEditAltTextStart()\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"alt\" />\n\t\t\t\t</TldrawUiButton>\n\t\t\t)}\n\t\t</>\n\t)\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsNG;AAtNH,oBAUO;AACP,mBAAyD;AACzD,kBAQO;AACP,qBAA2B;AAC3B,oBAA4B;AAC5B,4BAA+B;AAC/B,4BAA+B;AAC/B,gCAAmC;AACnC,iCAAoC;AACpC,kCAKO;AACP,4BAA+B;AAYxB,MAAM,iCAA6B,qBAAM,SAASA,4BAA2B;AA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;AAAA,UAEzE,sDAAC,gDAAmB,OAAK,MAAC,MAAK,SAAQ;AAAA;AAAA,MACxC;AAAA,OACD;AAAA,EAEF;AAEA,SACC,4EACE;AAAA,KAAC,cACD,4CAAC,wCAAe,MAAK,QAAO,OAAO,IAAI,oBAAoB,GAAG,SAAS,oBACtE,sDAAC,gDAAmB,OAAK,MAAC,MAAK,cAAa,GAC7C;AAAA,IAEA,CAAC,cACD,4CAAC,wCAAe,MAAK,QAAO,OAAO,IAAI,iBAAiB,GAAG,SAAS,qBACnE,sDAAC,gDAAmB,OAAK,MAAC,MAAK,QAAO,GACvC;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,OAAO,IAAI,0BAA0B;AAAA,QACrC,SAAS;AAAA,QAET,sDAAC,gDAAmB,OAAK,MAAC,MAAK,YAAW;AAAA;AAAA,IAC3C;AAAA,KACE,WAAW,CAAC,eACb;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,OAAO,IAAI,qBAAqB;AAAA,QAChC,SAAS,MAAM;AACd,qBAAW,kBAAkB,EAAE,OAAO,CAAC;AACvC,6BAAmB;AAAA,QACpB;AAAA,QAEA,sDAAC,gDAAmB,OAAK,MAAC,MAAK,OAAM;AAAA;AAAA,IACtC;AAAA,KAEF;AAEF,CAAC;",
4
+ "sourcesContent": ["import {\n\tapproximately,\n\tisEqual,\n\tkickoutOccludedShapes,\n\tmodulate,\n\tTLImageShape,\n\tTLShapePartial,\n\ttrack,\n\tuseEditor,\n\tuseValue,\n} from '@tldraw/editor'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n\tASPECT_RATIO_OPTION,\n\tASPECT_RATIO_OPTIONS,\n\tASPECT_RATIO_TO_VALUE,\n\tgetCroppedImageDataForAspectRatio,\n\tgetCroppedImageDataWhenZooming,\n\tgetDefaultCrop,\n\tMAX_ZOOM,\n} from '../../../shapes/shared/crop'\nimport { useActions } from '../../context/actions'\nimport { useUiEvents } from '../../context/events'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../primitives/Button/TldrawUiButtonLabel'\nimport {\n\tTldrawUiDropdownMenuCheckboxItem,\n\tTldrawUiDropdownMenuContent,\n\tTldrawUiDropdownMenuRoot,\n\tTldrawUiDropdownMenuTrigger,\n} from '../primitives/TldrawUiDropdownMenu'\nimport { TldrawUiSlider } from '../primitives/TldrawUiSlider'\nimport { TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\n\n/** @public */\nexport interface DefaultImageToolbarContentProps {\n\timageShapeId: TLImageShape['id']\n\tisManipulating: boolean\n\tonEditAltTextStart(): void\n\tonManipulatingStart(): void\n\tonManipulatingEnd(): void\n}\n\n/** @public @react */\nexport const DefaultImageToolbarContent = track(function DefaultImageToolbarContent({\n\timageShapeId,\n\tisManipulating,\n\tonEditAltTextStart,\n\tonManipulatingStart,\n\tonManipulatingEnd,\n}: DefaultImageToolbarContentProps) {\n\tconst editor = useEditor()\n\tconst trackEvent = useUiEvents()\n\tconst msg = useTranslation()\n\tconst source = 'image-toolbar'\n\tconst sliderRef = useRef<HTMLDivElement>(null)\n\tconst isReadonly = editor.getIsReadonly()\n\n\tconst crop = useValue('crop', () => editor.getShape<TLImageShape>(imageShapeId)!.props.crop, [\n\t\teditor,\n\t\timageShapeId,\n\t])\n\tconst zoom = crop\n\t\t? Math.min(1 - (crop.bottomRight.x - crop.topLeft.x), 1 - (crop.bottomRight.y - crop.topLeft.y))\n\t\t: 0\n\tconst [maxZoom, setMaxZoom] = useState<number | undefined>(\n\t\tcrop ? Math.max(zoom, 1 - 1 / MAX_ZOOM) : MAX_ZOOM\n\t)\n\tconst actions = useActions()\n\n\t// So, we set a maxZoom here in case there's been a manual crop applied.\n\t// Typically, you can zoom 3x into the image size (MAX_ZOOM's value).\n\t// If you go deeper than that zoom level, we need to set that as the new 100%\n\t// value on the zoom slider (otherwise you could zoom into infinity).\n\t// This balances usage of the zoom slider with manual cropping.\n\tuseEffect(() => {\n\t\tsetMaxZoom(crop ? Math.max(zoom, 1 - 1 / MAX_ZOOM) : MAX_ZOOM)\n\t}, [crop, zoom, maxZoom])\n\n\tconst onHistoryMark = useCallback((id: string) => editor.markHistoryStoppingPoint(id), [editor])\n\n\t// Apply an easing function to smooth out the zoom curve,\n\t// otherwise the zoom slider has a cubic drag feel to it which feels off.\n\tconst easeZoom = useCallback((value: number, maxValue: number): number => {\n\t\tconst maxRatioConversion = MAX_ZOOM / (MAX_ZOOM - 1)\n\t\t// Use an easing function for a more natural zoom feel\n\t\treturn Math.pow(value / maxValue, maxRatioConversion) * maxValue\n\t}, [])\n\n\tconst displayValue =\n\t\tcrop && maxZoom\n\t\t\t? modulate(easeZoom(zoom, maxZoom), [0, maxZoom], [0, 100], true /* clamp */)\n\t\t\t: 0\n\n\tconst handleZoomChange = useCallback(\n\t\t(value: number) => {\n\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t// Convert the eased slider value back to the actual zoom value\n\t\t\tconst sliderPercent = value / 100\n\n\t\t\t// Convert the slider position back into the \"zoom\" value expected by\n\t\t\t// getCroppedImageDataWhenZooming.\n\t\t\t// 1. Undo the easing: z_out = sliderPercent^(1/maxRatioConversion) * maxZoom\n\t\t\t// 2. Translate z_out into the function's input domain. The helper computes\n\t\t\t// the *resulting* zoom (z_out) using:\n\t\t\t// z_out = 2 * z_in / (1 + 2 * z_in)\n\t\t\t// Solving for z_in gives:\n\t\t\t// z_in = z_out / (2 * (1 - z_out))\n\t\t\tconst maxDimension = 1 - 1 / MAX_ZOOM\n\t\t\tconst clampedMaxZoom = Math.min(maxDimension, maxZoom ?? maxDimension)\n\t\t\tconst maxRatioConversion = MAX_ZOOM / (MAX_ZOOM - 1)\n\t\t\tconst zOut = Math.pow(sliderPercent, 1 / maxRatioConversion) * clampedMaxZoom\n\t\t\tconst zoom = zOut >= 1 ? 1 : zOut / (2 * (1 - zOut))\n\t\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)\n\t\t\tif (!imageShape) return\n\n\t\t\tconst change = getCroppedImageDataWhenZooming(zoom, imageShape, maxZoom)\n\n\t\t\teditor.updateShape({\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tx: change.x,\n\t\t\t\ty: change.y,\n\t\t\t\tprops: {\n\t\t\t\t\tw: change.w,\n\t\t\t\t\th: change.h,\n\t\t\t\t\tcrop: change.crop,\n\t\t\t\t},\n\t\t\t} as TLShapePartial)\n\n\t\t\ttrackEvent('set-style', { source: 'image-toolbar', id: 'zoom', value })\n\t\t},\n\t\t[editor, trackEvent, imageShapeId, maxZoom]\n\t)\n\n\tconst handleImageReplace = useCallback(\n\t\t() => actions['image-replace'].onSelect('image-toolbar'),\n\t\t[actions]\n\t)\n\n\tconst handleImageDownload = useCallback(\n\t\t() => actions['download-original'].onSelect('image-toolbar'),\n\t\t[actions]\n\t)\n\n\tconst handleAspectRatioChange = (aspectRatio: ASPECT_RATIO_OPTION) => {\n\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)\n\t\tif (!imageShape) return\n\t\teditor.run(() => {\n\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\tconst change = getCroppedImageDataForAspectRatio(aspectRatio, imageShape)\n\t\t\teditor.markHistoryStoppingPoint('aspect ratio')\n\t\t\teditor.updateShape({\n\t\t\t\tid: imageShapeId,\n\t\t\t\ttype: 'image',\n\t\t\t\tx: change.x,\n\t\t\t\ty: change.y,\n\t\t\t\tprops: {\n\t\t\t\t\tcrop: change.crop,\n\t\t\t\t\tw: change.w,\n\t\t\t\t\th: change.h,\n\t\t\t\t},\n\t\t\t} as TLShapePartial)\n\t\t\tkickoutOccludedShapes(editor, [imageShapeId])\n\t\t})\n\t}\n\n\tconst altText = useValue(\n\t\t'altText',\n\t\t() => editor.getShape<TLImageShape>(imageShapeId)!.props.altText,\n\t\t[editor, imageShapeId]\n\t)\n\tconst shapeAspectRatio = useValue(\n\t\t'shapeAspectRatio',\n\t\t() => {\n\t\t\tconst imageShape = editor.getShape<TLImageShape>(imageShapeId)!\n\t\t\treturn imageShape.props.w / imageShape.props.h\n\t\t},\n\t\t[editor, imageShapeId]\n\t)\n\tconst isOriginalCrop = !crop || isEqual(crop, getDefaultCrop())\n\n\tuseEffect(() => {\n\t\tif (isManipulating) {\n\t\t\teditor.timers.setTimeout(() => sliderRef.current?.focus(), 0)\n\t\t}\n\t}, [editor, isManipulating])\n\n\tuseEffect(() => {\n\t\tfunction handleKeyDown(e: KeyboardEvent) {\n\t\t\tif (isManipulating) {\n\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\teditor.cancel()\n\t\t\t\t\tonManipulatingEnd()\n\t\t\t\t} else if (e.key === 'Enter') {\n\t\t\t\t\teditor.complete()\n\t\t\t\t\tonManipulatingEnd()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst elm = sliderRef.current\n\t\tif (elm) {\n\t\t\telm.addEventListener('keydown', handleKeyDown)\n\t\t}\n\t\treturn () => {\n\t\t\tif (elm) {\n\t\t\t\telm.removeEventListener('keydown', handleKeyDown)\n\t\t\t}\n\t\t}\n\t}, [editor, isManipulating, onManipulatingEnd])\n\n\tif (isManipulating) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<TldrawUiSlider\n\t\t\t\t\tref={sliderRef}\n\t\t\t\t\tvalue={displayValue}\n\t\t\t\t\tlabel=\"tool.image-zoom\"\n\t\t\t\t\tonValueChange={handleZoomChange}\n\t\t\t\t\tonHistoryMark={onHistoryMark}\n\t\t\t\t\tmin={0}\n\t\t\t\t\tsteps={100}\n\t\t\t\t\tdata-testid=\"tool.image-zoom\"\n\t\t\t\t\ttitle={msg('tool.image-zoom')}\n\t\t\t\t/>\n\t\t\t\t<TldrawUiDropdownMenuRoot id=\"image-toolbar-aspect-ratio\">\n\t\t\t\t\t<TldrawUiDropdownMenuTrigger>\n\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\ttitle={msg('tool.aspect-ratio')}\n\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\tdata-testid=\"tool.image-aspect-ratio\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TldrawUiButtonIcon icon=\"corners\" />\n\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t</TldrawUiDropdownMenuTrigger>\n\t\t\t\t\t<TldrawUiDropdownMenuContent side=\"top\" align=\"center\">\n\t\t\t\t\t\t{ASPECT_RATIO_OPTIONS.map((aspectRatio) => {\n\t\t\t\t\t\t\tlet checked = false\n\t\t\t\t\t\t\tif (isOriginalCrop) {\n\t\t\t\t\t\t\t\tif (aspectRatio === 'original') {\n\t\t\t\t\t\t\t\t\tchecked = true\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (aspectRatio === 'circle') {\n\t\t\t\t\t\t\t\t\tchecked = !!crop.isCircle\n\t\t\t\t\t\t\t\t} else if (aspectRatio === 'square') {\n\t\t\t\t\t\t\t\t\tchecked =\n\t\t\t\t\t\t\t\t\t\t!crop?.isCircle &&\n\t\t\t\t\t\t\t\t\t\tapproximately(shapeAspectRatio, ASPECT_RATIO_TO_VALUE[aspectRatio], 0.1)\n\t\t\t\t\t\t\t\t} else if (aspectRatio === 'original') {\n\t\t\t\t\t\t\t\t\tchecked = false\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tchecked =\n\t\t\t\t\t\t\t\t\t\t!isOriginalCrop &&\n\t\t\t\t\t\t\t\t\t\tapproximately(shapeAspectRatio, ASPECT_RATIO_TO_VALUE[aspectRatio], 0.01)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<TldrawUiDropdownMenuCheckboxItem\n\t\t\t\t\t\t\t\t\tkey={aspectRatio}\n\t\t\t\t\t\t\t\t\tonSelect={() => handleAspectRatioChange(aspectRatio as ASPECT_RATIO_OPTION)}\n\t\t\t\t\t\t\t\t\tchecked={checked}\n\t\t\t\t\t\t\t\t\ttitle={msg(`tool.aspect-ratio.${aspectRatio}`)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiButtonLabel>\n\t\t\t\t\t\t\t\t\t\t{msg(`tool.aspect-ratio.${aspectRatio}`)}\n\t\t\t\t\t\t\t\t\t</TldrawUiButtonLabel>\n\t\t\t\t\t\t\t\t</TldrawUiDropdownMenuCheckboxItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</TldrawUiDropdownMenuContent>\n\t\t\t\t</TldrawUiDropdownMenuRoot>\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\tonClick={onManipulatingEnd}\n\t\t\t\t\tdata-testid=\"tool.image-crop-confirm\"\n\t\t\t\t\tstyle={{ borderLeft: '1px solid var(--tl-color-divider)', marginLeft: '2px' }}\n\t\t\t\t\ttitle={msg('tool.image-crop-confirm')}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"check\" />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t</>\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\tdata-testid=\"tool.image-replace\"\n\t\t\t\t\tonClick={handleImageReplace}\n\t\t\t\t\ttitle={msg('tool.replace-media')}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"tool-media\" />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)}\n\t\t\t{!isReadonly && (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttitle={msg('tool.image-crop')}\n\t\t\t\t\tonClick={onManipulatingStart}\n\t\t\t\t\tdata-testid=\"tool.image-crop\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"crop\" />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)}\n\t\t\t<TldrawUiToolbarButton\n\t\t\t\ttype=\"icon\"\n\t\t\t\ttitle={msg('action.download-original')}\n\t\t\t\tonClick={handleImageDownload}\n\t\t\t\tdata-testid=\"tool.image-download\"\n\t\t\t>\n\t\t\t\t<TldrawUiButtonIcon small icon=\"download\" />\n\t\t\t</TldrawUiToolbarButton>\n\t\t\t{(altText || !isReadonly) && (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttitle={msg('tool.media-alt-text')}\n\t\t\t\t\tdata-testid=\"tool.image-alt-text\"\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\ttrackEvent('alt-text-start', { source })\n\t\t\t\t\t\tonEditAltTextStart()\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon small icon=\"alt\" />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)}\n\t\t</>\n\t)\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsNG;AAtNH,oBAUO;AACP,mBAAyD;AACzD,kBAQO;AACP,qBAA2B;AAC3B,oBAA4B;AAC5B,4BAA+B;AAC/B,gCAAmC;AACnC,iCAAoC;AACpC,kCAKO;AACP,4BAA+B;AAC/B,6BAAsC;AAY/B,MAAM,iCAA6B,qBAAM,SAASA,4BAA2B;AAAA,EACnF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAoC;AACnC,QAAM,aAAS,yBAAU;AACzB,QAAM,iBAAa,2BAAY;AAC/B,QAAM,UAAM,sCAAe;AAC3B,QAAM,SAAS;AACf,QAAM,gBAAY,qBAAuB,IAAI;AAC7C,QAAM,aAAa,OAAO,cAAc;AAExC,Q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AAAA;AAAA,QACA,MAAK;AAAA,QACL,eAAY;AAAA,QACZ,SAAS;AAAA,QACT,OAAO,IAAI,oBAAoB;AAAA,QAE/B,sDAAC,gDAAmB,OAAK,MAAC,MAAK,cAAa;AAAA;AAAA,IAC7C;AAAA,IAEA,CAAC,cACD;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,OAAO,IAAI,iBAAiB;AAAA,QAC5B,SAAS;AAAA,QACT,eAAY;AAAA,QAEZ,sDAAC,gDAAmB,OAAK,MAAC,MAAK,QAAO;AAAA;AAAA,IACvC;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,OAAO,IAAI,0BAA0B;AAAA,QACrC,SAAS;AAAA,QACT,eAAY;AAAA,QAEZ,sDAAC,gDAAmB,OAAK,MAAC,MAAK,YAAW;AAAA;AAAA,IAC3C;AAAA,KACE,WAAW,CAAC,eACb;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,OAAO,IAAI,qBAAqB;AAAA,QAChC,eAAY;AAAA,QACZ,SAAS,MAAM;AACd,qBAAW,kBAAkB,EAAE,OAAO,CAAC;AACvC,6BAAmB;AAAA,QACpB;AAAA,QAEA,sDAAC,gDAAmB,OAAK,MAAC,MAAK,OAAM;AAAA;AAAA,IACtC;AAAA,KAEF;AAEF,CAAC;",
6
6
  "names": ["DefaultImageToolbarContent", "zoom"]
7
7
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var DefaultToolbar_exports = {};
20
30
  __export(DefaultToolbar_exports, {
@@ -23,6 +33,7 @@ __export(DefaultToolbar_exports, {
23
33
  module.exports = __toCommonJS(DefaultToolbar_exports);
24
34
  var import_jsx_runtime = require("react/jsx-runtime");
25
35
  var import_editor = require("@tldraw/editor");
36
+ var import_classnames = __toESM(require("classnames"));
26
37
  var import_react = require("react");
27
38
  var import_constants = require("../../constants");
28
39
  var import_breakpoints = require("../../context/breakpoints");
@@ -30,11 +41,19 @@ var import_components = require("../../context/components");
30
41
  var import_useReadonly = require("../../hooks/useReadonly");
31
42
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
32
43
  var import_MobileStylePanel = require("../MobileStylePanel");
44
+ var import_layout = require("../primitives/layout");
33
45
  var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
34
46
  var import_DefaultToolbarContent = require("./DefaultToolbarContent");
35
47
  var import_OverflowingToolbar = require("./OverflowingToolbar");
36
48
  var import_ToggleToolLockedButton = require("./ToggleToolLockedButton");
37
- const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({ children }) {
49
+ const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({
50
+ children,
51
+ orientation = "horizontal",
52
+ minItems = 4,
53
+ minSizePx = 310,
54
+ maxItems = 8,
55
+ maxSizePx = 470
56
+ }) {
38
57
  const editor = (0, import_editor.useEditor)();
39
58
  const msg = (0, import_useTranslation.useTranslation)();
40
59
  const breakpoint = (0, import_breakpoints.useBreakpoint)();
@@ -44,25 +63,51 @@ const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({ childre
44
63
  (0, import_editor.usePassThroughWheelEvents)(ref);
45
64
  const { ActionsMenu, QuickActions } = (0, import_components.useTldrawUiComponents)();
46
65
  const showQuickActions = editor.options.actionShortcutsLocation === "menu" ? false : editor.options.actionShortcutsLocation === "toolbar" ? true : breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET;
47
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, className: "tlui-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-toolbar__inner", children: [
48
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-toolbar__left", children: [
49
- !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-toolbar__extras", children: [
50
- showQuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
51
- import_TldrawUiToolbar.TldrawUiToolbar,
52
- {
53
- className: "tlui-toolbar__extras__controls tlui-buttons__horizontal",
54
- label: msg("actions-menu.title"),
55
- children: [
56
- QuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QuickActions, {}),
57
- ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionsMenu, {})
58
- ]
59
- }
60
- ),
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToggleToolLockedButton.ToggleToolLockedButton, { activeToolId })
62
- ] }),
63
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OverflowingToolbar.OverflowingToolbar, { children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultToolbarContent.DefaultToolbarContent, {}) })
64
- ] }),
65
- breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-toolbar__tools", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MobileStylePanel.MobileStylePanel, {}) })
66
- ] }) });
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
+ import_layout.TldrawUiOrientationProvider,
68
+ {
69
+ orientation,
70
+ tooltipSide: orientation === "horizontal" ? "top" : "right",
71
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
72
+ "div",
73
+ {
74
+ ref,
75
+ className: (0, import_classnames.default)("tlui-main-toolbar", `tlui-main-toolbar--${orientation}`),
76
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__inner", children: [
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__left", children: [
78
+ !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__extras", children: [
79
+ showQuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
80
+ import_TldrawUiToolbar.TldrawUiToolbar,
81
+ {
82
+ orientation,
83
+ className: "tlui-main-toolbar__extras__controls",
84
+ label: msg("actions-menu.title"),
85
+ children: [
86
+ QuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QuickActions, {}),
87
+ ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionsMenu, {})
88
+ ]
89
+ }
90
+ ),
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToggleToolLockedButton.ToggleToolLockedButton, { activeToolId })
92
+ ] }),
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ import_OverflowingToolbar.OverflowingToolbar,
95
+ {
96
+ orientation,
97
+ sizingParentClassName: "tlui-main-toolbar",
98
+ minItems,
99
+ maxItems,
100
+ minSizePx,
101
+ maxSizePx,
102
+ children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultToolbarContent.DefaultToolbarContent, {})
103
+ }
104
+ )
105
+ ] }),
106
+ breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-main-toolbar__tools tlui-main-toolbar__mobile-style-panel", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MobileStylePanel.MobileStylePanel, {}) })
107
+ ] })
108
+ }
109
+ )
110
+ }
111
+ );
67
112
  });
68
113
  //# sourceMappingURL=DefaultToolbar.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/DefaultToolbar.tsx"],
4
- "sourcesContent": ["import { useEditor, usePassThroughWheelEvents, useValue } from '@tldraw/editor'\nimport { ReactNode, memo, useRef } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { useTldrawUiComponents } from '../../context/components'\nimport { useReadonly } from '../../hooks/useReadonly'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { MobileStylePanel } from '../MobileStylePanel'\nimport { TldrawUiToolbar } from '../primitives/TldrawUiToolbar'\nimport { DefaultToolbarContent } from './DefaultToolbarContent'\nimport { OverflowingToolbar } from './OverflowingToolbar'\nimport { ToggleToolLockedButton } from './ToggleToolLockedButton'\n\n/** @public */\nexport interface DefaultToolbarProps {\n\tchildren?: ReactNode\n}\n\n/**\n * The default toolbar for the editor. `children` defaults to the `DefaultToolbarContent` component.\n * Depending on the screen size, the children will overflow into a drop-down menu, with the most\n * recently active item from the overflow being shown in the main toolbar.\n *\n * @public\n * @react\n */\nexport const DefaultToolbar = memo(function DefaultToolbar({ children }: DefaultToolbarProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\tconst isReadonlyMode = useReadonly()\n\tconst activeToolId = useValue('current tool id', () => editor.getCurrentToolId(), [editor])\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst { ActionsMenu, QuickActions } = useTldrawUiComponents()\n\n\tconst showQuickActions =\n\t\teditor.options.actionShortcutsLocation === 'menu'\n\t\t\t? false\n\t\t\t: editor.options.actionShortcutsLocation === 'toolbar'\n\t\t\t\t? true\n\t\t\t\t: breakpoint < PORTRAIT_BREAKPOINT.TABLET\n\n\treturn (\n\t\t<div ref={ref} className=\"tlui-toolbar\">\n\t\t\t<div className=\"tlui-toolbar__inner\">\n\t\t\t\t<div className=\"tlui-toolbar__left\">\n\t\t\t\t\t{!isReadonlyMode && (\n\t\t\t\t\t\t<div className=\"tlui-toolbar__extras\">\n\t\t\t\t\t\t\t{showQuickActions && (\n\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-toolbar__extras__controls tlui-buttons__horizontal\"\n\t\t\t\t\t\t\t\t\tlabel={msg('actions-menu.title')}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{QuickActions && <QuickActions />}\n\t\t\t\t\t\t\t\t\t{ActionsMenu && <ActionsMenu />}\n\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<ToggleToolLockedButton activeToolId={activeToolId} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t<OverflowingToolbar>{children ?? <DefaultToolbarContent />}</OverflowingToolbar>\n\t\t\t\t</div>\n\t\t\t\t{breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && (\n\t\t\t\t\t<div className=\"tlui-toolbar__tools\">\n\t\t\t\t\t\t<MobileStylePanel />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDQ;AApDR,oBAA+D;AAC/D,mBAAwC;AACxC,uBAAoC;AACpC,yBAA8B;AAC9B,wBAAsC;AACtC,yBAA4B;AAC5B,4BAA+B;AAC/B,8BAAiC;AACjC,6BAAgC;AAChC,mCAAsC;AACtC,gCAAmC;AACnC,oCAAuC;AAehC,MAAM,qBAAiB,mBAAK,SAASA,gBAAe,EAAE,SAAS,GAAwB;AAC7F,QAAM,aAAS,yBAAU;AACzB,QAAM,UAAM,sCAAe;AAC3B,QAAM,iBAAa,kCAAc;AACjC,QAAM,qBAAiB,gCAAY;AACnC,QAAM,mBAAe,wBAAS,mBAAmB,MAAM,OAAO,iBAAiB,GAAG,CAAC,MAAM,CAAC;AAE1F,QAAM,UAAM,qBAAuB,IAAI;AACvC,+CAA0B,GAAG;AAE7B,QAAM,EAAE,aAAa,aAAa,QAAI,yCAAsB;AAE5D,QAAM,mBACL,OAAO,QAAQ,4BAA4B,SACxC,QACA,OAAO,QAAQ,4BAA4B,YAC1C,OACA,aAAa,qCAAoB;AAEtC,SACC,4CAAC,SAAI,KAAU,WAAU,gBACxB,uDAAC,SAAI,WAAU,uBACd;AAAA,iDAAC,SAAI,WAAU,sBACb;AAAA,OAAC,kBACD,6CAAC,SAAI,WAAU,wBACb;AAAA,4BACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAO,IAAI,oBAAoB;AAAA,YAE9B;AAAA,8BAAgB,4CAAC,gBAAa;AAAA,cAC9B,eAAe,4CAAC,eAAY;AAAA;AAAA;AAAA,QAC9B;AAAA,QAED,4CAAC,wDAAuB,cAA4B;AAAA,SACrD;AAAA,MAED,4CAAC,gDAAoB,sBAAY,4CAAC,sDAAsB,GAAG;AAAA,OAC5D;AAAA,IACC,aAAa,qCAAoB,aAAa,CAAC,kBAC/C,4CAAC,SAAI,WAAU,uBACd,sDAAC,4CAAiB,GACnB;AAAA,KAEF,GACD;AAEF,CAAC;",
6
- "names": ["DefaultToolbar"]
4
+ "sourcesContent": ["import { useEditor, usePassThroughWheelEvents, useValue } from '@tldraw/editor'\nimport classNames from 'classnames'\nimport { ReactNode, memo, useRef } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { useTldrawUiComponents } from '../../context/components'\nimport { useReadonly } from '../../hooks/useReadonly'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { MobileStylePanel } from '../MobileStylePanel'\nimport { TldrawUiOrientationProvider } from '../primitives/layout'\nimport { TldrawUiToolbar } from '../primitives/TldrawUiToolbar'\nimport { DefaultToolbarContent } from './DefaultToolbarContent'\nimport { OverflowingToolbar } from './OverflowingToolbar'\nimport { ToggleToolLockedButton } from './ToggleToolLockedButton'\n\n/** @public */\nexport interface DefaultToolbarProps {\n\tchildren?: ReactNode\n\torientation?: 'horizontal' | 'vertical'\n\tminItems?: number\n\tminSizePx?: number\n\tmaxItems?: number\n\tmaxSizePx?: number\n}\n\n/**\n * The default toolbar for the editor. `children` defaults to the `DefaultToolbarContent` component.\n * Depending on the screen size, the children will overflow into a drop-down menu, with the most\n * recently active item from the overflow being shown in the main toolbar.\n *\n * @public\n * @react\n */\nexport const DefaultToolbar = memo(function DefaultToolbar({\n\tchildren,\n\torientation = 'horizontal',\n\tminItems = 4,\n\tminSizePx = 310,\n\tmaxItems = 8,\n\tmaxSizePx = 470,\n}: DefaultToolbarProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\tconst isReadonlyMode = useReadonly()\n\tconst activeToolId = useValue('current tool id', () => editor.getCurrentToolId(), [editor])\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst { ActionsMenu, QuickActions } = useTldrawUiComponents()\n\n\tconst showQuickActions =\n\t\teditor.options.actionShortcutsLocation === 'menu'\n\t\t\t? false\n\t\t\t: editor.options.actionShortcutsLocation === 'toolbar'\n\t\t\t\t? true\n\t\t\t\t: breakpoint < PORTRAIT_BREAKPOINT.TABLET\n\n\treturn (\n\t\t<TldrawUiOrientationProvider\n\t\t\torientation={orientation}\n\t\t\ttooltipSide={orientation === 'horizontal' ? 'top' : 'right'}\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={classNames('tlui-main-toolbar', `tlui-main-toolbar--${orientation}`)}\n\t\t\t>\n\t\t\t\t<div className=\"tlui-main-toolbar__inner\">\n\t\t\t\t\t<div className=\"tlui-main-toolbar__left\">\n\t\t\t\t\t\t{!isReadonlyMode && (\n\t\t\t\t\t\t\t<div className=\"tlui-main-toolbar__extras\">\n\t\t\t\t\t\t\t\t{showQuickActions && (\n\t\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\t\torientation={orientation}\n\t\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__extras__controls\"\n\t\t\t\t\t\t\t\t\t\tlabel={msg('actions-menu.title')}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{QuickActions && <QuickActions />}\n\t\t\t\t\t\t\t\t\t\t{ActionsMenu && <ActionsMenu />}\n\t\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t<ToggleToolLockedButton activeToolId={activeToolId} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<OverflowingToolbar\n\t\t\t\t\t\t\torientation={orientation}\n\t\t\t\t\t\t\tsizingParentClassName=\"tlui-main-toolbar\"\n\t\t\t\t\t\t\tminItems={minItems}\n\t\t\t\t\t\t\tmaxItems={maxItems}\n\t\t\t\t\t\t\tminSizePx={minSizePx}\n\t\t\t\t\t\t\tmaxSizePx={maxSizePx}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children ?? <DefaultToolbarContent />}\n\t\t\t\t\t\t</OverflowingToolbar>\n\t\t\t\t\t</div>\n\t\t\t\t\t{breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && (\n\t\t\t\t\t\t<div className=\"tlui-main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