tldraw 3.16.0-internal.a478398270c6 → 3.16.0-internal.f8b97f0c414f

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 (656) hide show
  1. package/dist-cjs/index.d.ts +471 -130
  2. package/dist-cjs/index.js +58 -15
  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/TldrawImage.js +5 -2
  7. package/dist-cjs/lib/TldrawImage.js.map +3 -3
  8. package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
  9. package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
  10. package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
  11. package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
  12. package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
  13. package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
  14. package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
  15. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  16. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +279 -271
  17. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  18. package/dist-cjs/lib/defaultExternalContentHandlers.js +6 -4
  19. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +27 -44
  21. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +22 -4
  23. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  24. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  25. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  26. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  27. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  28. package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +1 -1
  29. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +3 -0
  30. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  31. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +4 -4
  32. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  33. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -6
  34. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  35. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  36. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  37. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  38. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +25 -18
  39. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  40. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  41. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  42. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +2 -2
  43. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +2 -2
  44. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +3 -2
  45. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  46. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
  47. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
  48. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -4
  49. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  50. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +6 -3
  51. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +2 -2
  52. package/dist-cjs/lib/shapes/line/LineShapeUtil.js +20 -5
  53. package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
  54. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +8 -6
  55. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  56. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +4 -4
  57. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  58. package/dist-cjs/lib/shapes/shared/PathBuilder.js +21 -3
  59. package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
  60. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -3
  61. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  62. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +5 -2
  63. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  64. package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
  65. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  66. package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +4 -3
  67. package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
  68. package/dist-cjs/lib/shapes/shared/crop.js +1 -0
  69. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  70. package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
  71. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +3 -4
  72. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  73. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  74. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  75. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  76. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +10 -1
  77. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
  78. package/dist-cjs/lib/shapes/text/PlainTextArea.js +2 -2
  79. package/dist-cjs/lib/shapes/text/PlainTextArea.js.map +2 -2
  80. package/dist-cjs/lib/shapes/text/RichTextArea.js +3 -3
  81. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  82. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +7 -13
  83. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  84. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  85. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  86. package/dist-cjs/lib/styles.js.map +2 -2
  87. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
  88. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  89. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
  90. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  91. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +7 -1
  92. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  93. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +43 -22
  94. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  95. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +2 -15
  96. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  97. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +5 -0
  98. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  99. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +8 -0
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +8 -0
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +8 -0
  104. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  105. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  106. package/dist-cjs/lib/ui/TldrawUi.js +27 -12
  107. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  108. package/dist-cjs/lib/ui/components/A11y.js +15 -13
  109. package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
  110. package/dist-cjs/lib/ui/components/AccessibilityMenu.js +35 -0
  111. package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +7 -0
  112. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +12 -3
  113. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  114. package/dist-cjs/lib/ui/components/{FollowingIndicator.js → DefaultFollowingIndicator.js} +6 -6
  115. package/dist-cjs/lib/ui/components/DefaultFollowingIndicator.js.map +7 -0
  116. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
  117. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
  118. package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
  119. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  120. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +57 -7
  121. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
  122. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +3 -2
  123. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
  124. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  125. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  126. package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
  127. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  128. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +4 -5
  129. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
  130. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +3 -2
  131. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  132. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
  133. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
  134. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
  135. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
  136. package/dist-cjs/lib/ui/components/Spinner.js +2 -25
  137. package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
  138. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +11 -4
  139. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  140. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +249 -278
  141. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  142. package/dist-cjs/lib/ui/components/{primitives/TldrawUiButtonPicker.js → StylePanel/StylePanelButtonPicker.js} +52 -54
  143. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  144. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  145. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  146. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +26 -25
  147. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  148. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +47 -43
  149. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  150. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  151. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  152. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +3 -2
  153. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  154. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +21 -7
  155. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
  156. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +39 -10
  157. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -21
  159. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  160. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js +15 -3
  161. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +3 -3
  163. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +2 -2
  164. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +189 -80
  165. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  166. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +5 -4
  167. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  168. package/dist-cjs/lib/ui/components/menu-items.js +22 -0
  169. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  170. package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +11 -2
  172. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  173. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
  174. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
  175. package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +35 -1
  176. package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
  177. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js +2 -2
  178. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js.map +2 -2
  179. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
  180. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
  181. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +23 -6
  182. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  183. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +33 -7
  184. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  185. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +294 -0
  186. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +7 -0
  187. package/dist-cjs/lib/ui/components/primitives/layout.js +76 -0
  188. package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
  189. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
  190. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  191. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
  192. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  193. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +154 -22
  194. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  195. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +3 -2
  196. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
  197. package/dist-cjs/lib/ui/context/actions.js +79 -17
  198. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  199. package/dist-cjs/lib/ui/context/components.js +2 -0
  200. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  201. package/dist-cjs/lib/ui/context/events.js.map +2 -2
  202. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  203. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +1 -1
  204. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  205. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  206. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  207. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  208. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  209. package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
  210. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  211. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  212. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +13 -0
  213. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  214. package/dist-cjs/lib/ui/kbd-utils.js +11 -4
  215. package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
  216. package/dist-cjs/lib/ui/version.js +3 -3
  217. package/dist-cjs/lib/ui/version.js.map +1 -1
  218. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
  219. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  220. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  221. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  222. package/dist-cjs/lib/utils/export/export.js +0 -20
  223. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  224. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  225. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  226. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +3 -2
  227. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  228. package/dist-esm/index.d.mts +471 -130
  229. package/dist-esm/index.mjs +107 -32
  230. package/dist-esm/index.mjs.map +2 -2
  231. package/dist-esm/lib/Tldraw.mjs +14 -4
  232. package/dist-esm/lib/Tldraw.mjs.map +2 -2
  233. package/dist-esm/lib/TldrawImage.mjs +5 -2
  234. package/dist-esm/lib/TldrawImage.mjs.map +2 -2
  235. package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
  236. package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
  237. package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
  238. package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
  239. package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
  240. package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
  241. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  242. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  243. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +279 -271
  244. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  245. package/dist-esm/lib/defaultExternalContentHandlers.mjs +6 -4
  246. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +30 -44
  248. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +25 -5
  250. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  251. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  252. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  253. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  254. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  255. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +1 -1
  256. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +3 -0
  257. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  258. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +5 -5
  259. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  260. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -6
  261. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  262. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  263. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  264. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  265. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +26 -18
  266. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  267. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  268. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +3 -3
  270. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +4 -2
  272. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
  274. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
  275. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -4
  276. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  277. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +6 -3
  278. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +2 -2
  279. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +21 -5
  280. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
  281. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +9 -6
  282. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  283. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +5 -5
  284. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  285. package/dist-esm/lib/shapes/shared/PathBuilder.mjs +22 -3
  286. package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
  287. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -3
  288. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  289. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +5 -2
  290. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  291. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +5 -4
  292. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  293. package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +4 -3
  294. package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
  295. package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
  296. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  297. package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
  298. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +4 -5
  299. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  300. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  301. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  302. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  303. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +10 -1
  304. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
  305. package/dist-esm/lib/shapes/text/PlainTextArea.mjs +3 -3
  306. package/dist-esm/lib/shapes/text/PlainTextArea.mjs.map +2 -2
  307. package/dist-esm/lib/shapes/text/RichTextArea.mjs +3 -4
  308. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  309. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +8 -13
  310. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  311. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  312. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  313. package/dist-esm/lib/styles.mjs.map +2 -2
  314. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
  315. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  316. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
  317. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  318. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +7 -1
  319. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  320. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +43 -22
  321. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +2 -15
  323. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  324. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +5 -0
  325. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  326. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +8 -0
  327. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  328. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +8 -0
  329. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  330. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +8 -0
  331. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  332. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  333. package/dist-esm/lib/ui/TldrawUi.mjs +29 -14
  334. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  335. package/dist-esm/lib/ui/components/A11y.mjs +16 -14
  336. package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
  337. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +19 -0
  338. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +7 -0
  339. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +12 -3
  340. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  341. package/dist-esm/lib/ui/components/{FollowingIndicator.mjs → DefaultFollowingIndicator.mjs} +3 -3
  342. package/dist-esm/lib/ui/components/DefaultFollowingIndicator.mjs.map +7 -0
  343. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
  344. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
  345. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
  346. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  347. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +57 -7
  348. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
  349. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
  350. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
  351. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  352. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  353. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
  354. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  355. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +4 -5
  356. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
  357. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +4 -3
  358. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  359. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
  360. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
  361. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
  362. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
  363. package/dist-esm/lib/ui/components/Spinner.mjs +3 -26
  364. package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
  365. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +16 -5
  366. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  367. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +251 -282
  368. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  369. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +126 -0
  370. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  371. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  372. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  373. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +23 -22
  374. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  375. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +44 -40
  376. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  377. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  378. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  379. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +3 -2
  380. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  381. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +23 -9
  382. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
  383. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +39 -10
  384. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  385. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -21
  386. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  387. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs +15 -3
  388. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs.map +2 -2
  389. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +3 -3
  390. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  391. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -81
  392. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  393. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +5 -4
  394. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  395. package/dist-esm/lib/ui/components/menu-items.mjs +22 -0
  396. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  397. package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
  398. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +12 -3
  399. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  400. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
  401. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
  402. package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +36 -2
  403. package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
  404. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs +3 -3
  405. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs.map +2 -2
  406. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
  407. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
  408. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +23 -6
  409. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  410. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +33 -7
  411. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  412. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +272 -0
  413. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +7 -0
  414. package/dist-esm/lib/ui/components/primitives/layout.mjs +46 -0
  415. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
  416. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
  417. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  418. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
  419. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  420. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +162 -24
  421. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  422. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +3 -2
  423. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
  424. package/dist-esm/lib/ui/context/actions.mjs +79 -17
  425. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  426. package/dist-esm/lib/ui/context/components.mjs +2 -0
  427. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  428. package/dist-esm/lib/ui/context/events.mjs.map +2 -2
  429. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  430. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  431. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  432. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  433. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  434. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  435. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  436. package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
  437. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  438. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +13 -0
  439. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  440. package/dist-esm/lib/ui/kbd-utils.mjs +11 -4
  441. package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
  442. package/dist-esm/lib/ui/version.mjs +3 -3
  443. package/dist-esm/lib/ui/version.mjs.map +1 -1
  444. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
  445. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  446. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  447. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  448. package/dist-esm/lib/utils/export/export.mjs +0 -20
  449. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  450. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  451. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  452. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +3 -2
  453. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  454. package/package.json +12 -34
  455. package/src/index.ts +80 -24
  456. package/src/lib/Tldraw.tsx +15 -2
  457. package/src/lib/TldrawImage.tsx +6 -2
  458. package/src/lib/canvas/TldrawCropHandles.tsx +3 -1
  459. package/src/lib/canvas/TldrawHandles.tsx +5 -1
  460. package/src/lib/canvas/TldrawOverlays.tsx +1 -1
  461. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  462. package/src/lib/canvas/TldrawSelectionForeground.tsx +5 -1
  463. package/src/lib/defaultExternalContentHandlers.ts +14 -5
  464. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
  465. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +6 -5
  466. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +53 -11
  467. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +30 -46
  468. package/src/lib/shapes/arrow/arrowLabel.ts +31 -3
  469. package/src/lib/shapes/arrow/arrowTargetState.ts +3 -2
  470. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  471. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +2 -2
  472. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +3 -0
  473. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +5 -5
  474. package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
  475. package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -7
  476. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  477. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  478. package/src/lib/shapes/frame/FrameShapeUtil.tsx +35 -21
  479. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  480. package/src/lib/shapes/frame/components/FrameLabelInput.tsx +3 -3
  481. package/src/lib/shapes/geo/GeoShapeUtil.tsx +4 -2
  482. package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
  483. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -4
  484. package/src/lib/shapes/image/ImageShapeUtil.tsx +6 -3
  485. package/src/lib/shapes/line/LineShapeUtil.test.tsx +8 -7
  486. package/src/lib/shapes/line/LineShapeUtil.tsx +25 -6
  487. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
  488. package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
  489. package/src/lib/shapes/note/NoteShapeUtil.tsx +11 -4
  490. package/src/lib/shapes/shared/HyperlinkButton.tsx +5 -5
  491. package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
  492. package/src/lib/shapes/shared/PathBuilder.tsx +35 -1
  493. package/src/lib/shapes/shared/PlainTextLabel.tsx +3 -7
  494. package/src/lib/shapes/shared/RichTextLabel.tsx +6 -1
  495. package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
  496. package/src/lib/shapes/shared/SvgTextLabel.tsx +4 -2
  497. package/src/lib/shapes/shared/crop.ts +1 -0
  498. package/src/lib/shapes/shared/freehand/svg.ts +2 -0
  499. package/src/lib/shapes/shared/useEditablePlainText.ts +12 -12
  500. package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
  501. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  502. package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
  503. package/src/lib/shapes/text/PlainTextArea.tsx +3 -3
  504. package/src/lib/shapes/text/RichTextArea.tsx +3 -4
  505. package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
  506. package/src/lib/shapes/text/TextShapeUtil.tsx +8 -14
  507. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  508. package/src/lib/styles.tsx +3 -1
  509. package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
  510. package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
  511. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +8 -1
  512. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +54 -30
  513. package/src/lib/tools/SelectTool/childStates/Idle.ts +2 -24
  514. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +7 -0
  515. package/src/lib/tools/SelectTool/childStates/Resizing.ts +12 -1
  516. package/src/lib/tools/SelectTool/childStates/Rotating.ts +11 -0
  517. package/src/lib/tools/SelectTool/childStates/Translating.ts +11 -1
  518. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -0
  519. package/src/lib/ui/TldrawUi.tsx +33 -12
  520. package/src/lib/ui/components/A11y.tsx +17 -15
  521. package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
  522. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
  523. package/src/lib/ui/components/{FollowingIndicator.tsx → DefaultFollowingIndicator.tsx} +2 -1
  524. package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
  525. package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
  526. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +46 -6
  527. package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -2
  528. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  529. package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
  530. package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +4 -5
  531. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +5 -4
  532. package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
  533. package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
  534. package/src/lib/ui/components/Spinner.tsx +2 -24
  535. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +28 -12
  536. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +261 -342
  537. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +66 -48
  538. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  539. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +31 -22
  540. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  541. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  542. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +5 -4
  543. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +25 -9
  544. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +33 -16
  545. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
  546. package/src/lib/ui/components/Toolbar/DefaultVideoToolbarContent.tsx +12 -4
  547. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +5 -5
  548. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +212 -61
  549. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +17 -12
  550. package/src/lib/ui/components/menu-items.tsx +25 -0
  551. package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
  552. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +8 -3
  553. package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
  554. package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +41 -3
  555. package/src/lib/ui/components/primitives/TldrawUiInput.tsx +3 -3
  556. package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
  557. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +54 -29
  558. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +59 -12
  559. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +365 -0
  560. package/src/lib/ui/components/primitives/layout.tsx +107 -0
  561. package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
  562. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
  563. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
  564. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +224 -23
  565. package/src/lib/ui/context/TldrawUiContextProvider.tsx +23 -20
  566. package/src/lib/ui/context/actions.tsx +81 -18
  567. package/src/lib/ui/context/components.tsx +3 -0
  568. package/src/lib/ui/context/events.tsx +7 -3
  569. package/src/lib/ui/hooks/menu-hooks.ts +1 -0
  570. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  571. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  572. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
  573. package/src/lib/ui/hooks/useTools.tsx +142 -11
  574. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +13 -0
  575. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +13 -0
  576. package/src/lib/ui/kbd-utils.ts +12 -4
  577. package/src/lib/ui/version.ts +3 -3
  578. package/src/lib/ui.css +432 -315
  579. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +21 -7
  580. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +7 -7
  581. package/src/lib/utils/export/copyAs.ts +1 -24
  582. package/src/lib/utils/export/export.ts +0 -36
  583. package/src/lib/utils/export/exportAs.ts +1 -32
  584. package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +28 -7
  585. package/src/lib/utils/tldr/buildFromV1Document.ts +2 -1
  586. package/src/test/A11y.test.tsx +3 -2
  587. package/src/test/ClickManager.test.ts +7 -6
  588. package/src/test/Editor.test.tsx +56 -28
  589. package/src/test/EraserTool.test.ts +184 -13
  590. package/src/test/HandTool.test.ts +10 -9
  591. package/src/test/HighlightShape.test.ts +2 -1
  592. package/src/test/SelectTool.test.ts +40 -13
  593. package/src/test/TLUserPreferences.test.ts +4 -3
  594. package/src/test/TestEditor.ts +13 -15
  595. package/src/test/TldrawEditor.test.tsx +26 -19
  596. package/src/test/ZoomTool.test.ts +7 -6
  597. package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
  598. package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
  599. package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
  600. package/src/test/arrows-megabus.test.tsx +17 -10
  601. package/src/test/bindings.test.tsx +24 -37
  602. package/src/test/bookmark-shapes.test.ts +1 -8
  603. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +23 -7
  604. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
  605. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  606. package/src/test/commands/alignShapes.test.tsx +25 -24
  607. package/src/test/commands/animationSpeed.test.ts +2 -1
  608. package/src/test/commands/centerOnPoint.test.ts +3 -2
  609. package/src/test/commands/clipboard.test.ts +3 -2
  610. package/src/test/commands/createShapes.test.ts +2 -1
  611. package/src/test/commands/deletePage.test.ts +84 -1
  612. package/src/test/commands/deleteShapes.test.ts +2 -1
  613. package/src/test/commands/distributeShapes.test.tsx +11 -10
  614. package/src/test/commands/getSvgString.test.ts +2 -1
  615. package/src/test/commands/packShapes.test.ts +5 -4
  616. package/src/test/commands/putContent.test.ts +1 -0
  617. package/src/test/commands/resizeShape.test.ts +2 -1
  618. package/src/test/commands/rotateShapes.test.ts +7 -6
  619. package/src/test/commands/setCamera.test.ts +4 -3
  620. package/src/test/commands/setCurrentPage.test.ts +3 -2
  621. package/src/test/commands/stackShapes.test.ts +11 -10
  622. package/src/test/commands/stretch.test.tsx +13 -12
  623. package/src/test/commands/updateShapes.test.ts +9 -5
  624. package/src/test/createDeepLink.test.tsx +2 -1
  625. package/src/test/cropping.test.ts +3 -2
  626. package/src/test/custom-clipping.test.ts +442 -0
  627. package/src/test/customSnapping.test.tsx +55 -41
  628. package/src/test/drawing.test.ts +2 -1
  629. package/src/test/flipShapes.test.ts +4 -3
  630. package/src/test/frames.test.ts +25 -24
  631. package/src/test/getCulledShapes.test.tsx +80 -4
  632. package/src/test/groups.test.tsx +6 -4
  633. package/src/test/handleDeepLink.test.tsx +2 -1
  634. package/src/test/inner-outer-margin.test.ts +315 -0
  635. package/src/test/maxShapes.test.ts +3 -2
  636. package/src/test/modifiers.test.ts +5 -4
  637. package/src/test/navigation.test.ts +264 -9
  638. package/src/test/panning.test.ts +2 -1
  639. package/src/test/perf/perf.test.ts +2 -1
  640. package/src/test/registerDeepLinkListener.test.tsx +10 -9
  641. package/src/test/resizing.test.ts +39 -38
  642. package/src/test/select.test.tsx +4 -3
  643. package/src/test/selection-omnibus.test.ts +11 -10
  644. package/src/test/shapeutils.test.ts +398 -48
  645. package/src/test/translating.test.ts +12 -11
  646. package/tldraw.css +759 -630
  647. package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +0 -7
  648. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  649. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  650. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  651. package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +0 -7
  652. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  653. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  654. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -113
  655. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  656. 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,SA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AI,CAAC,SAAS;AACpB,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA,MAAK;AAAA,cACL,eAAa,SAAS,MAAM,IAAI,KAAK,KAAK;AAAA,cAC1C,OACC,iBACA,aACA,IAAI,GAAG,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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UAAU;AAAA,QACV,UAAU;AAAA;AAAA,IACX;AAAA,IACC,CAAC,cACD;AAAA,MAAC;AAAA;AAAA,QACA,OAAO,IAAI,6BAA6B;AAAA,QACxC,MAAK;AAAA,QACL,eAAe;AAAA,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<Extract<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,SAA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,QACV,eAAY;AAAA,QACZ,OAAO;AAAA,QACP,aAAa,IAAI,0BAA0B;AAAA,QAC3C,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,UAAU;AAAA;AAAA,IACX;AAAA,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,9 +28,7 @@ var import_useTranslation = require("../../hooks/useTranslation/useTranslation")
28
28
  var import_TldrawUiContextualToolbar = require("../primitives/TldrawUiContextualToolbar");
29
29
  var import_AltTextEditor = require("./AltTextEditor");
30
30
  var import_DefaultImageToolbarContent = require("./DefaultImageToolbarContent");
31
- const DefaultImageToolbar = (0, import_editor.track)(function DefaultImageToolbar2({
32
- children
33
- }) {
31
+ function DefaultImageToolbar({ children }) {
34
32
  const editor = (0, import_editor.useEditor)();
35
33
  const imageShapeId = (0, import_editor.useValue)(
36
34
  "imageShape",
@@ -41,7 +39,11 @@ const DefaultImageToolbar = (0, import_editor.track)(function DefaultImageToolba
41
39
  },
42
40
  [editor]
43
41
  );
44
- const showToolbar = editor.isInAny("select.idle", "select.pointing_shape", "select.crop");
42
+ const showToolbar = (0, import_editor.useValue)(
43
+ "showToolbar",
44
+ () => editor.isInAny("select.idle", "select.pointing_shape", "select.crop"),
45
+ [editor]
46
+ );
45
47
  const isLocked = (0, import_editor.useValue)(
46
48
  "locked",
47
49
  () => imageShapeId ? editor.getShape(imageShapeId)?.isLocked : false,
@@ -49,15 +51,24 @@ const DefaultImageToolbar = (0, import_editor.track)(function DefaultImageToolba
49
51
  );
50
52
  if (!imageShapeId || !showToolbar || isLocked) return null;
51
53
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContextualToolbarInner, { imageShapeId, children }, imageShapeId);
52
- });
54
+ }
53
55
  function ContextualToolbarInner({
54
56
  children,
55
57
  imageShapeId
56
58
  }) {
57
59
  const editor = (0, import_editor.useEditor)();
58
60
  const msg = (0, import_useTranslation.useTranslation)();
61
+ const isChangingCrop = (0, import_editor.useValue)(
62
+ "editor path",
63
+ () => editor.isInAny(
64
+ "select.crop.cropping",
65
+ "select.crop.pointing_crop_handle",
66
+ "select.crop.translating_crop"
67
+ ),
68
+ [editor]
69
+ );
70
+ const camera = (0, import_editor.useValue)("camera", () => editor.getCamera(), [editor]);
59
71
  const isInCropTool = (0, import_editor.useValue)("editor path", () => editor.isIn("select.crop."), [editor]);
60
- const isCropping = (0, import_editor.useValue)("editor path", () => editor.isIn("select.crop.cropping"), [editor]);
61
72
  const previousSelectionBounds = (0, import_react.useRef)();
62
73
  const handleManipulatingEnd = (0, import_react.useCallback)(() => {
63
74
  editor.setCroppingShape(null);
@@ -70,6 +81,9 @@ function ContextualToolbarInner({
70
81
  [editor]
71
82
  );
72
83
  const onEditAltTextClose = (0, import_react.useCallback)(() => setIsEditingAltText(false), []);
84
+ (0, import_react.useEffect)(() => {
85
+ previousSelectionBounds.current = void 0;
86
+ }, [camera]);
73
87
  const getSelectionBounds = (0, import_react.useCallback)(() => {
74
88
  if (isInCropTool && previousSelectionBounds.current) {
75
89
  return previousSelectionBounds.current;
@@ -80,7 +94,7 @@ function ContextualToolbarInner({
80
94
  previousSelectionBounds.current = bounds;
81
95
  return bounds;
82
96
  }, [editor, isInCropTool]);
83
- if (isCropping) {
97
+ if (isChangingCrop) {
84
98
  previousSelectionBounds.current = void 0;
85
99
  return null;
86
100
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx"],
4
- "sourcesContent": ["import { Box, TLImageShape, track, useEditor, useValue } from '@tldraw/editor'\nimport { useCallback, useRef, useState } from 'react'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiContextualToolbar } from '../primitives/TldrawUiContextualToolbar'\nimport { AltTextEditor } from './AltTextEditor'\nimport { DefaultImageToolbarContent } from './DefaultImageToolbarContent'\n\n/** @public */\nexport interface TLUiImageToolbarProps {\n\tchildren?: React.ReactNode\n}\n\n/** @public @react */\nexport const DefaultImageToolbar = track(function DefaultImageToolbar({\n\tchildren,\n}: TLUiImageToolbarProps) {\n\tconst editor = useEditor()\n\tconst imageShapeId = useValue(\n\t\t'imageShape',\n\t\t() => {\n\t\t\tconst onlySelectedShape = editor.getOnlySelectedShape()\n\t\t\tif (!onlySelectedShape || onlySelectedShape.type !== 'image') return null\n\t\t\treturn onlySelectedShape.id\n\t\t},\n\t\t[editor]\n\t)\n\tconst showToolbar = editor.isInAny('select.idle', 'select.pointing_shape', 'select.crop')\n\tconst isLocked = useValue(\n\t\t'locked',\n\t\t() => (imageShapeId ? editor.getShape<TLImageShape>(imageShapeId)?.isLocked : false),\n\t\t[editor, imageShapeId]\n\t)\n\tif (!imageShapeId || !showToolbar || isLocked) return null\n\n\treturn (\n\t\t<ContextualToolbarInner key={imageShapeId} imageShapeId={imageShapeId}>\n\t\t\t{children}\n\t\t</ContextualToolbarInner>\n\t)\n})\n\nfunction ContextualToolbarInner({\n\tchildren,\n\timageShapeId,\n}: {\n\tchildren?: React.ReactNode\n\timageShapeId: TLImageShape['id']\n}) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\n\tconst isInCropTool = useValue('editor path', () => editor.isIn('select.crop.'), [editor])\n\tconst isCropping = useValue('editor path', () => editor.isIn('select.crop.cropping'), [editor])\n\tconst previousSelectionBounds = useRef<Box | undefined>()\n\tconst handleManipulatingEnd = useCallback(() => {\n\t\teditor.setCroppingShape(null)\n\t\teditor.setCurrentTool('select.idle')\n\t}, [editor])\n\n\tconst [isEditingAltText, setIsEditingAltText] = useState(false)\n\tconst handleEditAltTextStart = useCallback(() => setIsEditingAltText(true), [])\n\tconst handleManipulatingStart = useCallback(\n\t\t() => editor.setCurrentTool('select.crop.idle'),\n\t\t[editor]\n\t)\n\tconst onEditAltTextClose = useCallback(() => setIsEditingAltText(false), [])\n\n\tconst getSelectionBounds = useCallback(() => {\n\t\tif (isInCropTool && previousSelectionBounds.current) {\n\t\t\t// If we're cropping we want to be able to keep the toolbar in the same position.\n\t\t\treturn previousSelectionBounds.current\n\t\t}\n\t\tconst fullBounds = editor.getSelectionScreenBounds()\n\t\tif (!fullBounds) return undefined\n\t\tconst bounds = new Box(fullBounds.x, fullBounds.y, fullBounds.width, 0)\n\t\tpreviousSelectionBounds.current = bounds\n\t\treturn bounds\n\t}, [editor, isInCropTool])\n\n\tif (isCropping) {\n\t\tpreviousSelectionBounds.current = undefined\n\t\treturn null\n\t}\n\n\treturn (\n\t\t<TldrawUiContextualToolbar\n\t\t\tclassName=\"tlui-image__toolbar\"\n\t\t\tgetSelectionBounds={getSelectionBounds}\n\t\t\tlabel={msg('tool.image-toolbar-title')}\n\t\t>\n\t\t\t{children ? (\n\t\t\t\tchildren\n\t\t\t) : isEditingAltText ? (\n\t\t\t\t<AltTextEditor shapeId={imageShapeId} onClose={onEditAltTextClose} source=\"image-toolbar\" />\n\t\t\t) : (\n\t\t\t\t<DefaultImageToolbarContent\n\t\t\t\t\timageShapeId={imageShapeId}\n\t\t\t\t\tisManipulating={isInCropTool}\n\t\t\t\t\tonEditAltTextStart={handleEditAltTextStart}\n\t\t\t\t\tonManipulatingStart={handleManipulatingStart}\n\t\t\t\t\tonManipulatingEnd={handleManipulatingEnd}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</TldrawUiContextualToolbar>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCE;AAnCF,oBAA8D;AAC9D,mBAA8C;AAC9C,4BAA+B;AAC/B,uCAA0C;AAC1C,2BAA8B;AAC9B,wCAA2C;AAQpC,MAAM,0BAAsB,qBAA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AAoB,KAAK,GAAG,CAAC,CAAC;AAE3E,QAAM,yBAAqB,0BAAY,MAAM;AAC5C,QAAI,gBAAgB,wBAAwB,SAAS;AAEpD,aAAO,wBAAwB;AAAA,IAChC;AACA,UAAM,aAAa,OAAO,yBAAyB;AACnD,QAAI,CAAC,WAAY,QAAO;AACxB,UAAM,SAAS,IAAI,kBAAI,WAAW,GAAG,WAAW,GAAG,WAAW,OAAO,CAAC;AACtE,4BAAwB,UAAU;AAClC,WAAO;AAAA,EACR,GAAG,CAAC,QAAQ,YAAY,CAAC;AAEzB,MAAI,YAAY;AACf,4BAAwB,UAAU;AAClC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,OAAO,IAAI,0BAA0B;AAAA,MAEpC,qBACA,WACG,mBACH,4CAAC,sCAAc,SAAS,cAAc,SAAS,oBAAoB,QAAO,iBAAgB,IAE1F;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA,gBAAgB;AAAA,UAChB,oBAAoB;AAAA,UACpB,qBAAqB;AAAA,UACrB,mBAAmB;AAAA;AAAA,MACpB;AAAA;AAAA,EAEF;AAEF;",
6
- "names": ["DefaultImageToolbar"]
4
+ "sourcesContent": ["import { Box, TLImageShape, useEditor, useValue } from '@tldraw/editor'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiContextualToolbar } from '../primitives/TldrawUiContextualToolbar'\nimport { AltTextEditor } from './AltTextEditor'\nimport { DefaultImageToolbarContent } from './DefaultImageToolbarContent'\n\n/** @public */\nexport interface TLUiImageToolbarProps {\n\tchildren?: React.ReactNode\n}\n\n/** @public @react */\nexport function DefaultImageToolbar({ children }: TLUiImageToolbarProps) {\n\tconst editor = useEditor()\n\tconst imageShapeId = useValue(\n\t\t'imageShape',\n\t\t() => {\n\t\t\tconst onlySelectedShape = editor.getOnlySelectedShape()\n\t\t\tif (!onlySelectedShape || onlySelectedShape.type !== 'image') return null\n\t\t\treturn onlySelectedShape.id\n\t\t},\n\t\t[editor]\n\t)\n\tconst showToolbar = useValue(\n\t\t'showToolbar',\n\t\t() => editor.isInAny('select.idle', 'select.pointing_shape', 'select.crop'),\n\t\t[editor]\n\t)\n\tconst isLocked = useValue(\n\t\t'locked',\n\t\t() => (imageShapeId ? editor.getShape<TLImageShape>(imageShapeId)?.isLocked : false),\n\t\t[editor, imageShapeId]\n\t)\n\tif (!imageShapeId || !showToolbar || isLocked) return null\n\n\treturn (\n\t\t<ContextualToolbarInner key={imageShapeId} imageShapeId={imageShapeId}>\n\t\t\t{children}\n\t\t</ContextualToolbarInner>\n\t)\n}\n\nfunction ContextualToolbarInner({\n\tchildren,\n\timageShapeId,\n}: {\n\tchildren?: React.ReactNode\n\timageShapeId: TLImageShape['id']\n}) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\n\tconst isChangingCrop = useValue(\n\t\t'editor path',\n\t\t() =>\n\t\t\teditor.isInAny(\n\t\t\t\t'select.crop.cropping',\n\t\t\t\t'select.crop.pointing_crop_handle',\n\t\t\t\t'select.crop.translating_crop'\n\t\t\t),\n\t\t[editor]\n\t)\n\tconst camera = useValue('camera', () => editor.getCamera(), [editor])\n\tconst isInCropTool = useValue('editor path', () => editor.isIn('select.crop.'), [editor])\n\tconst previousSelectionBounds = useRef<Box | undefined>()\n\tconst handleManipulatingEnd = useCallback(() => {\n\t\teditor.setCroppingShape(null)\n\t\teditor.setCurrentTool('select.idle')\n\t}, [editor])\n\n\tconst [isEditingAltText, setIsEditingAltText] = useState(false)\n\tconst handleEditAltTextStart = useCallback(() => setIsEditingAltText(true), [])\n\tconst handleManipulatingStart = useCallback(\n\t\t() => editor.setCurrentTool('select.crop.idle'),\n\t\t[editor]\n\t)\n\tconst onEditAltTextClose = useCallback(() => setIsEditingAltText(false), [])\n\n\tuseEffect(() => {\n\t\tpreviousSelectionBounds.current = undefined\n\t}, [camera])\n\n\tconst getSelectionBounds = useCallback(() => {\n\t\tif (isInCropTool && previousSelectionBounds.current) {\n\t\t\t// If we're cropping we want to be able to keep the toolbar in the same position.\n\t\t\treturn previousSelectionBounds.current\n\t\t}\n\t\tconst fullBounds = editor.getSelectionScreenBounds()\n\t\tif (!fullBounds) return undefined\n\t\tconst bounds = new Box(fullBounds.x, fullBounds.y, fullBounds.width, 0)\n\t\tpreviousSelectionBounds.current = bounds\n\t\treturn bounds\n\t}, [editor, isInCropTool])\n\n\tif (isChangingCrop) {\n\t\tpreviousSelectionBounds.current = undefined\n\t\treturn null\n\t}\n\n\treturn (\n\t\t<TldrawUiContextualToolbar\n\t\t\tclassName=\"tlui-image__toolbar\"\n\t\t\tgetSelectionBounds={getSelectionBounds}\n\t\t\tlabel={msg('tool.image-toolbar-title')}\n\t\t>\n\t\t\t{children ? (\n\t\t\t\tchildren\n\t\t\t) : isEditingAltText ? (\n\t\t\t\t<AltTextEditor shapeId={imageShapeId} onClose={onEditAltTextClose} source=\"image-toolbar\" />\n\t\t\t) : (\n\t\t\t\t<DefaultImageToolbarContent\n\t\t\t\t\timageShapeId={imageShapeId}\n\t\t\t\t\tisManipulating={isInCropTool}\n\t\t\t\t\tonEditAltTextStart={handleEditAltTextStart}\n\t\t\t\t\tonManipulatingStart={handleManipulatingStart}\n\t\t\t\t\tonManipulatingEnd={handleManipulatingEnd}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</TldrawUiContextualToolbar>\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCE;AArCF,oBAAuD;AACvD,mBAAyD;AACzD,4BAA+B;AAC/B,uCAA0C;AAC1C,2BAA8B;AAC9B,wCAA2C;AAQpC,SAAS,oBAAoB,EAAE,SAAS,GAA0B;AACxE,QAAM,aAAS,yBAAU;AACzB,QAAM,mBAAe;AAAA,IACpB;AAAA,IACA,MAAM;AACL,YAAM,oBAAoB,OAAO,qBAAqB;AACtD,UA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BAAqB,0BAAY,MAAM,oBAAoB,KAAK,GAAG,CAAC,CAAC;AAE3E,8BAAU,MAAM;AACf,4BAAwB,UAAU;AAAA,EACnC,GAAG,CAAC,MAAM,CAAC;AAEX,QAAM,yBAAqB,0BAAY,MAAM;AAC5C,QAAI,gBAAgB,wBAAwB,SAAS;AAEpD,aAAO,wBAAwB;AAAA,IAChC;AACA,UAAM,aAAa,OAAO,yBAAyB;AACnD,QAAI,CAAC,WAAY,QAAO;AACxB,UAAM,SAAS,IAAI,kBAAI,WAAW,GAAG,WAAW,GAAG,WAAW,OAAO,CAAC;AACtE,4BAAwB,UAAU;AAClC,WAAO;AAAA,EACR,GAAG,CAAC,QAAQ,YAAY,CAAC;AAEzB,MAAI,gBAAgB;AACnB,4BAAwB,UAAU;AAClC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,OAAO,IAAI,0BAA0B;AAAA,MAEpC,qBACA,WACG,mBACH,4CAAC,sCAAc,SAAS,cAAc,SAAS,oBAAoB,QAAO,iBAAgB,IAE1F;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA,gBAAgB;AAAA,UAChB,oBAAoB;AAAA,UACpB,qBAAqB;AAAA,UACrB,mBAAmB;AAAA;AAAA,MACpB;AAAA;AAAA,EAEF;AAEF;",
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;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,QAAM,WAAO,wBAAS,QAAQ,MAAM,OAAO,SAAuB,YAAY,EAAG,MAAM,MAAM;AAAA,IAC5F;AAAA,IACA;AAAA,EACD,CAAC;AACD,QAAM,OAAO,OACV,KAAK,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,QAAQ,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,QAAQ,EAAE,IAC7F;AACH,QAAM,CAAC,SAAS,UAAU,QAAI;AAAA,IAC7B,OAAO,KAAK,IAAI,MAAM,IAAI,IAAI,oBAAQ,IAAI;AAAA,EAC3C;AACA,QAAM,cAAU,2BAAW;AAO3B,8BAAU,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,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\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