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
@@ -10,14 +10,14 @@ import { clearArrowTargetState } from "../../../shapes/arrow/arrowTargetState.mj
10
10
  import { getArrowBindings } from "../../../shapes/arrow/shared.mjs";
11
11
  class DraggingHandle extends StateNode {
12
12
  static id = "dragging_handle";
13
- shapeId = "";
14
- initialHandle = {};
15
- initialAdjacentHandle = null;
16
- initialPagePoint = {};
17
- markId = "";
13
+ shapeId;
14
+ initialHandle;
15
+ initialAdjacentHandle;
16
+ initialPagePoint;
17
+ markId;
18
18
  initialPageTransform;
19
19
  initialPageRotation;
20
- info = {};
20
+ info;
21
21
  isPrecise = false;
22
22
  isPreciseId = null;
23
23
  pointingId = null;
@@ -42,22 +42,6 @@ class DraggingHandle extends StateNode {
42
42
  this.markId = this.editor.markHistoryStoppingPoint("dragging handle");
43
43
  }
44
44
  this.initialHandle = structuredClone(handle);
45
- if (this.editor.isShapeOfType(shape, "line")) {
46
- if (this.initialHandle.type === "create") {
47
- this.editor.updateShape({
48
- ...shape,
49
- props: {
50
- points: {
51
- ...shape.props.points,
52
- [handle.index]: { id: handle.index, index: handle.index, x: handle.x, y: handle.y }
53
- }
54
- }
55
- });
56
- const handlesAfter = this.editor.getShapeHandles(shape);
57
- const handleAfter = handlesAfter.find((h) => h.index === handle.index);
58
- this.initialHandle = structuredClone(handleAfter);
59
- }
60
- }
61
45
  this.initialPageTransform = this.editor.getShapePageTransform(shape);
62
46
  this.initialPageRotation = this.initialPageTransform.rotation();
63
47
  this.initialPagePoint = this.editor.inputs.originPagePoint.clone();
@@ -93,6 +77,17 @@ class DraggingHandle extends StateNode {
93
77
  }
94
78
  }
95
79
  }
80
+ const handleDragInfo = {
81
+ handle: this.initialHandle,
82
+ isPrecise: this.isPrecise,
83
+ isCreatingShape: !!this.info.isCreating,
84
+ initial: shape
85
+ };
86
+ const util = this.editor.getShapeUtil(shape);
87
+ const startChanges = util.onHandleDragStart?.(shape, handleDragInfo);
88
+ if (startChanges) {
89
+ this.editor.updateShapes([{ ...startChanges, id: shape.id, type: shape.type }]);
90
+ }
96
91
  this.update();
97
92
  this.editor.select(this.shapeId);
98
93
  }
@@ -147,6 +142,20 @@ class DraggingHandle extends StateNode {
147
142
  complete() {
148
143
  this.editor.snaps.clearIndicators();
149
144
  kickoutOccludedShapes(this.editor, [this.shapeId]);
145
+ const shape = this.editor.getShape(this.shapeId);
146
+ if (shape) {
147
+ const util = this.editor.getShapeUtil(shape);
148
+ const handleDragInfo = {
149
+ handle: this.initialHandle,
150
+ isPrecise: this.isPrecise,
151
+ isCreatingShape: !!this.info.isCreating,
152
+ initial: this.info.shape
153
+ };
154
+ const endChanges = util.onHandleDragEnd?.(shape, handleDragInfo);
155
+ if (endChanges) {
156
+ this.editor.updateShapes([{ ...endChanges, id: shape.id }]);
157
+ }
158
+ }
150
159
  const { onInteractionEnd } = this.info;
151
160
  if (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {
152
161
  this.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId });
@@ -155,6 +164,17 @@ class DraggingHandle extends StateNode {
155
164
  this.parent.transition("idle");
156
165
  }
157
166
  cancel() {
167
+ const shape = this.editor.getShape(this.shapeId);
168
+ if (shape) {
169
+ const util = this.editor.getShapeUtil(shape);
170
+ const handleDragInfo = {
171
+ handle: this.initialHandle,
172
+ isPrecise: this.isPrecise,
173
+ isCreatingShape: !!this.info.isCreating,
174
+ initial: this.info.shape
175
+ };
176
+ util.onHandleDragCancel?.(shape, handleDragInfo);
177
+ }
158
178
  this.editor.bailToMark(this.markId);
159
179
  this.editor.snaps.clearIndicators();
160
180
  const { onInteractionEnd } = this.info;
@@ -199,6 +219,7 @@ class DraggingHandle extends StateNode {
199
219
  const changes = util.onHandleDrag?.(shape, {
200
220
  handle: nextHandle,
201
221
  isPrecise: this.isPrecise || altKey,
222
+ isCreatingShape: !!this.info.isCreating,
202
223
  initial
203
224
  });
204
225
  const next = { id: shape.id, type: shape.type, ...changes };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/DraggingHandle.tsx"],
4
- "sourcesContent": ["import {\n\tStateNode,\n\tTLArrowShape,\n\tTLHandle,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tkickoutOccludedShapes,\n\tsnapAngle,\n\tsortByIndex,\n\tstructuredClone,\n} from '@tldraw/editor'\nimport { clearArrowTargetState } from '../../../shapes/arrow/arrowTargetState'\nimport { getArrowBindings } from '../../../shapes/arrow/shared'\n\nexport type DraggingHandleInfo = TLPointerEventInfo & {\n\tshape: TLArrowShape | TLLineShape\n\ttarget: 'handle'\n\tonInteractionEnd?: string\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n}\n\nexport class DraggingHandle extends StateNode {\n\tstatic override id = 'dragging_handle'\n\n\tshapeId = '' as TLShapeId\n\tinitialHandle = {} as TLHandle\n\tinitialAdjacentHandle = null as TLHandle | null\n\tinitialPagePoint = {} as Vec\n\n\tmarkId = ''\n\tinitialPageTransform: any\n\tinitialPageRotation: any\n\n\tinfo = {} as DraggingHandleInfo\n\n\tisPrecise = false\n\tisPreciseId = null as TLShapeId | null\n\tpointingId = null as TLShapeId | null\n\n\toverride onEnter(info: DraggingHandleInfo) {\n\t\tconst { shape, isCreating, creatingMarkId, handle } = info\n\t\tthis.info = info\n\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\tthis.shapeId = shape.id\n\t\tthis.markId = ''\n\n\t\tif (isCreating) {\n\t\t\tif (creatingMarkId) {\n\t\t\t\tthis.markId = creatingMarkId\n\t\t\t} else {\n\t\t\t\t// handle legacy implicit `creating:{shapeId}` marks\n\t\t\t\tconst markId = this.editor.getMarkIdMatching(\n\t\t\t\t\t`creating:${this.editor.getOnlySelectedShapeId()}`\n\t\t\t\t)\n\t\t\t\tif (markId) {\n\t\t\t\t\tthis.markId = markId\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint('dragging handle')\n\t\t}\n\n\t\tthis.initialHandle = structuredClone(handle)\n\n\t\tif (this.editor.isShapeOfType<TLLineShape>(shape, 'line')) {\n\t\t\t// For line shapes, if we're dragging a \"create\" handle, then\n\t\t\t// create a new vertex handle at that point; and make this handle\n\t\t\t// the handle that we're dragging.\n\t\t\tif (this.initialHandle.type === 'create') {\n\t\t\t\tthis.editor.updateShape({\n\t\t\t\t\t...shape,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t...shape.props.points,\n\t\t\t\t\t\t\t[handle.index]: { id: handle.index, index: handle.index, x: handle.x, y: handle.y },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tconst handlesAfter = this.editor.getShapeHandles(shape)!\n\t\t\t\tconst handleAfter = handlesAfter.find((h) => h.index === handle.index)!\n\t\t\t\tthis.initialHandle = structuredClone(handleAfter)\n\t\t\t}\n\t\t}\n\n\t\tthis.initialPageTransform = this.editor.getShapePageTransform(shape)!\n\t\tthis.initialPageRotation = this.initialPageTransform.rotation()\n\t\tthis.initialPagePoint = this.editor.inputs.originPagePoint.clone()\n\n\t\tthis.editor.setCursor({ type: isCreating ? 'cross' : 'grabbing', rotation: 0 })\n\n\t\tconst handles = this.editor.getShapeHandles(shape)!.sort(sortByIndex)\n\t\tconst index = handles.findIndex((h) => h.id === info.handle.id)\n\n\t\t// Find the adjacent handle\n\t\tthis.initialAdjacentHandle = null\n\n\t\t// Start from the handle and work forward\n\t\tfor (let i = index + 1; i < handles.length; i++) {\n\t\t\tconst handle = handles[i]\n\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// If still no handle, start from the end and work backward\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\tconst handle = handles[i]\n\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// <!-- Only relevant to arrows\n\t\tif (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {\n\t\t\tconst initialBinding = getArrowBindings(this.editor, shape)[info.handle.id as 'start' | 'end']\n\n\t\t\tthis.isPrecise = false\n\n\t\t\tif (initialBinding) {\n\t\t\t\tthis.isPrecise = initialBinding.props.isPrecise\n\t\t\t\tif (this.isPrecise) {\n\t\t\t\t\tthis.isPreciseId = initialBinding.toId\n\t\t\t\t} else {\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// -->\n\n\t\tthis.update()\n\n\t\tthis.editor.select(this.shapeId)\n\t}\n\n\t// Only relevant to arrows\n\tprivate exactTimeout = -1 as any\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tthis.clearExactTimeout()\n\t\t}\n\n\t\tthis.exactTimeout = this.editor.timers.setTimeout(() => {\n\t\t\tif (this.getIsActive() && !this.isPrecise) {\n\t\t\t\tthis.isPrecise = true\n\t\t\t\tthis.isPreciseId = this.pointingId\n\t\t\t\tthis.update()\n\t\t\t}\n\t\t\tthis.exactTimeout = -1\n\t\t}, 750)\n\t}\n\n\t// Only relevant to arrows\n\tprivate clearExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tclearTimeout(this.exactTimeout)\n\t\t\tthis.exactTimeout = -1\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.update()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.update()\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate complete() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tkickoutOccludedShapes(this.editor, [this.shapeId])\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t// Return to the tool that was active before this one,\n\t\t\t// but only if tool lock is turned on!\n\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\t// Return to the tool that was active before this one,\n\t\t\t// whether tool lock is turned on or not!\n\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate update() {\n\t\tconst { editor, shapeId, initialPagePoint } = this\n\t\tconst { initialHandle, initialPageRotation, initialAdjacentHandle } = this\n\t\tconst isSnapMode = this.editor.user.getIsSnapMode()\n\t\tconst {\n\t\t\tsnaps,\n\t\t\tinputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity },\n\t\t} = editor\n\n\t\tconst initial = this.info.shape\n\n\t\tconst shape = editor.getShape(shapeId)\n\t\tif (!shape) return\n\t\tconst util = editor.getShapeUtil(shape)\n\n\t\tconst initialBinding = editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t\t? getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\t\t\t: undefined\n\n\t\tlet point = currentPagePoint\n\t\t\t.clone()\n\t\t\t.sub(initialPagePoint)\n\t\t\t.rot(-initialPageRotation)\n\t\t\t.add(initialHandle)\n\n\t\tif (shiftKey && initialAdjacentHandle && initialHandle.id !== 'middle') {\n\t\t\tconst angle = Vec.Angle(initialAdjacentHandle, point)\n\t\t\tconst snappedAngle = snapAngle(angle, 24)\n\t\t\tconst angleDifference = snappedAngle - angle\n\t\t\tpoint = Vec.RotWith(point, initialAdjacentHandle, angleDifference)\n\t\t}\n\n\t\t// Clear any existing snaps\n\t\teditor.snaps.clearIndicators()\n\n\t\tlet nextHandle = { ...initialHandle, x: point.x, y: point.y }\n\n\t\tif (initialHandle.canSnap && (isSnapMode ? !ctrlKey : ctrlKey)) {\n\t\t\t// We're snapping\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape.id)\n\t\t\tif (!pageTransform) throw Error('Expected a page transform')\n\n\t\t\tconst snap = snaps.handles.snapHandle({ currentShapeId: shapeId, handle: nextHandle })\n\n\t\t\tif (snap) {\n\t\t\t\tsnap.nudge.rot(-editor.getShapeParentTransform(shape)!.rotation())\n\t\t\t\tpoint.add(snap.nudge)\n\t\t\t\tnextHandle = { ...initialHandle, x: point.x, y: point.y }\n\t\t\t}\n\t\t}\n\n\t\tconst changes = util.onHandleDrag?.(shape, {\n\t\t\thandle: nextHandle,\n\t\t\tisPrecise: this.isPrecise || altKey,\n\t\t\tinitial: initial,\n\t\t})\n\n\t\tconst next: TLShapePartial<any> = { id: shape.id, type: shape.type, ...changes }\n\n\t\t// Arrows\n\t\tif (\n\t\t\tinitialHandle.type === 'vertex' &&\n\t\t\tthis.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t) {\n\t\t\tconst bindingAfter = getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\n\t\t\tif (bindingAfter) {\n\t\t\t\tif (initialBinding?.toId !== bindingAfter.toId) {\n\t\t\t\t\tthis.pointingId = bindingAfter.toId\n\t\t\t\t\tthis.isPrecise = pointerVelocity.len() < 0.5 || altKey\n\t\t\t\t\tthis.isPreciseId = this.isPrecise ? bindingAfter.toId : null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (initialBinding) {\n\t\t\t\t\tthis.pointingId = null\n\t\t\t\t\tthis.isPrecise = false\n\t\t\t\t\tthis.isPreciseId = null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (changes) {\n\t\t\teditor.updateShapes([next])\n\t\t}\n\t}\n}\n"],
5
- "mappings": "AAAA;AAAA,EACC;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAU1B,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAErB,UAAU;AAAA,EACV,gBAAgB,CAAC;AAAA,EACjB,wBAAwB;AAAA,EACxB,mBAAmB,CAAC;AAAA,EAEpB,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EAEA,OAAO,CAAC;AAAA,EAER,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEJ,QAAQ,MAA0B;AAC1C,UAAM,EAAE,OAAO,YAAY,gBAAgB,OAAO,IAAI;AACtD,SAAK,OAAO;AACZ,SAAK,OAAO,qBAAqB,KAAK,gBAAgB;AACtD,SAAK,UAAU,MAAM;AACrB,SAAK,SAAS;AAEd,QAAI,YAAY;AACf,UAAI,gBAAgB;AACnB,aAAK,SAAS;AAAA,MACf,OAAO;AAEN,cAAM,SAAS,KAAK,OAAO;AAAA,UAC1B,YAAY,KAAK,OAAO,uBAAuB,CAAC;AAAA,QACjD;AACA,YAAI,QAAQ;AACX,eAAK,SAAS;AAAA,QACf;AAAA,MACD;AAAA,IACD,OAAO;AACN,WAAK,SAAS,KAAK,OAAO,yBAAyB,iBAAiB;AAAA,IACrE;AAEA,SAAK,gBAAgB,gBAAgB,MAAM;AAE3C,QAAI,KAAK,OAAO,cAA2B,OAAO,MAAM,GAAG;AAI1D,UAAI,KAAK,cAAc,SAAS,UAAU;AACzC,aA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eAAK,YAAY,gBAAgB,IAAI,IAAI,OAAO;AAChD,eAAK,cAAc,KAAK,YAAY,aAAa,OAAO;AACxD,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD,OAAO;AACN,YAAI,gBAAgB;AACnB,eAAK,aAAa;AAClB,eAAK,YAAY;AACjB,eAAK,cAAc;AACnB,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEA,QAAI,SAAS;AACZ,aAAO,aAAa,CAAC,IAAI,CAAC;AAAA,IAC3B;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLArrowShape,\n\tTLHandle,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tkickoutOccludedShapes,\n\tsnapAngle,\n\tsortByIndex,\n\tstructuredClone,\n} from '@tldraw/editor'\nimport { clearArrowTargetState } from '../../../shapes/arrow/arrowTargetState'\nimport { getArrowBindings } from '../../../shapes/arrow/shared'\n\nexport type DraggingHandleInfo = TLPointerEventInfo & {\n\tshape: TLArrowShape | TLLineShape\n\ttarget: 'handle'\n\tonInteractionEnd?: string\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n}\n\nexport class DraggingHandle extends StateNode {\n\tstatic override id = 'dragging_handle'\n\n\tshapeId!: TLShapeId\n\tinitialHandle!: TLHandle\n\tinitialAdjacentHandle!: TLHandle | null\n\tinitialPagePoint!: Vec\n\n\tmarkId!: string\n\tinitialPageTransform!: Mat\n\tinitialPageRotation!: number\n\n\tinfo!: DraggingHandleInfo\n\n\tisPrecise = false\n\tisPreciseId: TLShapeId | null = null\n\tpointingId: TLShapeId | null = null\n\n\toverride onEnter(info: DraggingHandleInfo) {\n\t\tconst { shape, isCreating, creatingMarkId, handle } = info\n\t\tthis.info = info\n\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\tthis.shapeId = shape.id\n\t\tthis.markId = ''\n\n\t\tif (isCreating) {\n\t\t\tif (creatingMarkId) {\n\t\t\t\tthis.markId = creatingMarkId\n\t\t\t} else {\n\t\t\t\t// handle legacy implicit `creating:{shapeId}` marks\n\t\t\t\tconst markId = this.editor.getMarkIdMatching(\n\t\t\t\t\t`creating:${this.editor.getOnlySelectedShapeId()}`\n\t\t\t\t)\n\t\t\t\tif (markId) {\n\t\t\t\t\tthis.markId = markId\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint('dragging handle')\n\t\t}\n\n\t\tthis.initialHandle = structuredClone(handle)\n\n\t\tthis.initialPageTransform = this.editor.getShapePageTransform(shape)!\n\t\tthis.initialPageRotation = this.initialPageTransform.rotation()\n\t\tthis.initialPagePoint = this.editor.inputs.originPagePoint.clone()\n\n\t\tthis.editor.setCursor({ type: isCreating ? 'cross' : 'grabbing', rotation: 0 })\n\n\t\tconst handles = this.editor.getShapeHandles(shape)!.sort(sortByIndex)\n\t\tconst index = handles.findIndex((h) => h.id === info.handle.id)\n\n\t\t// Find the adjacent handle\n\t\tthis.initialAdjacentHandle = null\n\n\t\t// Start from the handle and work forward\n\t\tfor (let i = index + 1; i < handles.length; i++) {\n\t\t\tconst handle = handles[i]\n\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// If still no handle, start from the end and work backward\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\tconst handle = handles[i]\n\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// <!-- Only relevant to arrows\n\t\tif (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {\n\t\t\tconst initialBinding = getArrowBindings(this.editor, shape)[info.handle.id as 'start' | 'end']\n\n\t\t\tthis.isPrecise = false\n\n\t\t\tif (initialBinding) {\n\t\t\t\tthis.isPrecise = initialBinding.props.isPrecise\n\t\t\t\tif (this.isPrecise) {\n\t\t\t\t\tthis.isPreciseId = initialBinding.toId\n\t\t\t\t} else {\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// -->\n\n\t\t// Call onHandleDragStart callback\n\t\tconst handleDragInfo = {\n\t\t\thandle: this.initialHandle,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: shape,\n\t\t}\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tconst startChanges = util.onHandleDragStart?.(shape, handleDragInfo)\n\t\tif (startChanges) {\n\t\t\tthis.editor.updateShapes([{ ...startChanges, id: shape.id, type: shape.type }])\n\t\t}\n\n\t\tthis.update()\n\n\t\tthis.editor.select(this.shapeId)\n\t}\n\n\t// Only relevant to arrows\n\tprivate exactTimeout = -1 as any\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tthis.clearExactTimeout()\n\t\t}\n\n\t\tthis.exactTimeout = this.editor.timers.setTimeout(() => {\n\t\t\tif (this.getIsActive() && !this.isPrecise) {\n\t\t\t\tthis.isPrecise = true\n\t\t\t\tthis.isPreciseId = this.pointingId\n\t\t\t\tthis.update()\n\t\t\t}\n\t\t\tthis.exactTimeout = -1\n\t\t}, 750)\n\t}\n\n\t// Only relevant to arrows\n\tprivate clearExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tclearTimeout(this.exactTimeout)\n\t\t\tthis.exactTimeout = -1\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.update()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.update()\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate complete() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tkickoutOccludedShapes(this.editor, [this.shapeId])\n\n\t\t// Call onHandleDragEnd callback before state transitions\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tconst endChanges = util.onHandleDragEnd?.(shape, handleDragInfo)\n\t\t\tif (endChanges) {\n\t\t\t\tthis.editor.updateShapes([{ ...endChanges, id: shape.id }])\n\t\t\t}\n\t\t}\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t// Return to the tool that was active before this one,\n\t\t\t// but only if tool lock is turned on!\n\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\t// Call onHandleDragCancel callback before bailing to mark\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tutil.onHandleDragCancel?.(shape, handleDragInfo)\n\t\t}\n\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\t// Return to the tool that was active before this one,\n\t\t\t// whether tool lock is turned on or not!\n\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate update() {\n\t\tconst { editor, shapeId, initialPagePoint } = this\n\t\tconst { initialHandle, initialPageRotation, initialAdjacentHandle } = this\n\t\tconst isSnapMode = this.editor.user.getIsSnapMode()\n\t\tconst {\n\t\t\tsnaps,\n\t\t\tinputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity },\n\t\t} = editor\n\n\t\tconst initial = this.info.shape\n\n\t\tconst shape = editor.getShape(shapeId)\n\t\tif (!shape) return\n\t\tconst util = editor.getShapeUtil(shape)\n\n\t\tconst initialBinding = editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t\t? getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\t\t\t: undefined\n\n\t\tlet point = currentPagePoint\n\t\t\t.clone()\n\t\t\t.sub(initialPagePoint)\n\t\t\t.rot(-initialPageRotation)\n\t\t\t.add(initialHandle)\n\n\t\tif (shiftKey && initialAdjacentHandle && initialHandle.id !== 'middle') {\n\t\t\tconst angle = Vec.Angle(initialAdjacentHandle, point)\n\t\t\tconst snappedAngle = snapAngle(angle, 24)\n\t\t\tconst angleDifference = snappedAngle - angle\n\t\t\tpoint = Vec.RotWith(point, initialAdjacentHandle, angleDifference)\n\t\t}\n\n\t\t// Clear any existing snaps\n\t\teditor.snaps.clearIndicators()\n\n\t\tlet nextHandle = { ...initialHandle, x: point.x, y: point.y }\n\n\t\tif (initialHandle.canSnap && (isSnapMode ? !ctrlKey : ctrlKey)) {\n\t\t\t// We're snapping\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape.id)\n\t\t\tif (!pageTransform) throw Error('Expected a page transform')\n\n\t\t\tconst snap = snaps.handles.snapHandle({ currentShapeId: shapeId, handle: nextHandle })\n\n\t\t\tif (snap) {\n\t\t\t\tsnap.nudge.rot(-editor.getShapeParentTransform(shape)!.rotation())\n\t\t\t\tpoint.add(snap.nudge)\n\t\t\t\tnextHandle = { ...initialHandle, x: point.x, y: point.y }\n\t\t\t}\n\t\t}\n\n\t\tconst changes = util.onHandleDrag?.(shape, {\n\t\t\thandle: nextHandle,\n\t\t\tisPrecise: this.isPrecise || altKey,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: initial,\n\t\t})\n\n\t\tconst next: TLShapePartial<any> = { id: shape.id, type: shape.type, ...changes }\n\n\t\t// Arrows\n\t\tif (\n\t\t\tinitialHandle.type === 'vertex' &&\n\t\t\tthis.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t) {\n\t\t\tconst bindingAfter = getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\n\t\t\tif (bindingAfter) {\n\t\t\t\tif (initialBinding?.toId !== bindingAfter.toId) {\n\t\t\t\t\tthis.pointingId = bindingAfter.toId\n\t\t\t\t\tthis.isPrecise = pointerVelocity.len() < 0.5 || altKey\n\t\t\t\t\tthis.isPreciseId = this.isPrecise ? bindingAfter.toId : null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (initialBinding) {\n\t\t\t\t\tthis.pointingId = null\n\t\t\t\t\tthis.isPrecise = false\n\t\t\t\t\tthis.isPreciseId = null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (changes) {\n\t\t\teditor.updateShapes([next])\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAOA;AAAA,EACA;AA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ED,UAAM,OAA4B,EAAE,IAAI,MAAM,IAAI,MAAM,MAAM,MAAM,GAAG,QAAQ;AAG/E,QACC,cAAc,SAAS,YACvB,KAAK,OAAO,cAA4B,OAAO,OAAO,GACrD;AACD,YAAM,eAAe,iBAAiB,QAAQ,KAAK,EAAE,cAAc,EAAqB;AAExF,UAAI,cAAc;AACjB,YAAI,gBAAgB,SAAS,aAAa,MAAM;AAC/C,eAAK,aAAa,aAAa;AAC/B,eAAK,YAAY,gBAAgB,IAAI,IAAI,OAAO;AAChD,eAAK,cAAc,KAAK,YAAY,aAAa,OAAO;AACxD,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD,OAAO;AACN,YAAI,gBAAgB;AACnB,eAAK,aAAa;AAClB,eAAK,YAAY;AACjB,eAAK,cAAc;AACnB,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEA,QAAI,SAAS;AACZ,aAAO,aAAa,CAAC,IAAI,CAAC;AAAA,IAC3B;AAAA,EACD;AACD;",
6
6
  "names": ["handle"]
7
7
  }
@@ -7,6 +7,7 @@ import {
7
7
  pointInPolygon,
8
8
  toRichText
9
9
  } from "@tldraw/editor";
10
+ import { isOverArrowLabel } from "../../../shapes/arrow/arrowLabel.mjs";
10
11
  import { getHitShapeOnCanvasPointerDown } from "../../selection-logic/getHitShapeOnCanvasPointerDown.mjs";
11
12
  import { getShouldEnterCropMode } from "../../selection-logic/getShouldEnterCropModeOnPointerDown.mjs";
12
13
  import { selectOnCanvasPointerUp } from "../../selection-logic/selectOnCanvasPointerUp.mjs";
@@ -69,10 +70,6 @@ class Idle extends StateNode {
69
70
  }
70
71
  case "shape": {
71
72
  const { shape } = info;
72
- if (this.isOverArrowLabelTest(shape)) {
73
- this.parent.transition("pointing_arrow_label", info);
74
- break;
75
- }
76
73
  if (this.editor.isShapeOrAncestorLocked(shape)) {
77
74
  this.parent.transition("pointing_canvas", info);
78
75
  break;
@@ -452,17 +449,7 @@ class Idle extends StateNode {
452
449
  }
453
450
  isOverArrowLabelTest(shape) {
454
451
  if (!shape) return false;
455
- if (this.editor.isShapeOfType(shape, "arrow")) {
456
- const pointInShapeSpace = this.editor.getPointInShapeSpace(
457
- shape,
458
- this.editor.inputs.currentPagePoint
459
- );
460
- const labelGeometry = this.editor.getShapeGeometry(shape).children[1];
461
- if (labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)) {
462
- return true;
463
- }
464
- }
465
- return false;
452
+ return isOverArrowLabel(this.editor, shape);
466
453
  }
467
454
  handleDoubleClickOnCanvas(info) {
468
455
  if (this.editor.getIsReadonly()) return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Idle.ts"],
4
- "sourcesContent": ["import {\n\tEditor,\n\tGroup2d,\n\tStateNode,\n\tTLAdjacentDirection,\n\tTLArrowShape,\n\tTLClickEventInfo,\n\tTLGroupShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLTextShape,\n\tVec,\n\tVecLike,\n\tcreateShapeId,\n\tdebugFlags,\n\tkickoutOccludedShapes,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\nimport { startEditingShapeWithLabel } from '../selectHelpers'\n\nconst SKIPPED_KEYS_FOR_AUTO_EDITING = [\n\t'Delete',\n\t'Backspace',\n\t'[',\n\t']',\n\t'Enter',\n\t' ',\n\t'Shift',\n\t'Tab',\n]\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\tselectedShapesOnKeyDown: TLShape[] = []\n\n\toverride onEnter() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.selectedShapesOnKeyDown = []\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onExit() {\n\t\tupdateHoveredShapeId.cancel()\n\t}\n\n\toverride onPointerMove() {\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tconst shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor)\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\t// Check to see if we hit any shape under the pointer; if so,\n\t\t\t\t// handle this as a pointer down on the shape instead of the canvas\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !hitShape.isLocked) {\n\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tif (this.isOverArrowLabelTest(shape)) {\n\t\t\t\t\t// We're moving the label on a shape.\n\t\t\t\t\tthis.parent.transition('pointing_arrow_label', info)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif (this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tif (this.editor.inputs.altKey) {\n\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t} else {\n\t\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\t\tthis.parent.transition('pointing_handle', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tswitch (info.handle) {\n\t\t\t\t\tcase 'mobile_rotate':\n\t\t\t\t\tcase 'top_left_rotate':\n\t\t\t\t\tcase 'top_right_rotate':\n\t\t\t\t\tcase 'bottom_left_rotate':\n\t\t\t\t\tcase 'bottom_right_rotate': {\n\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.parent.transition('pointing_rotate_handle', info)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'top':\n\t\t\t\t\tcase 'right':\n\t\t\t\t\tcase 'bottom':\n\t\t\t\t\tcase 'left':\n\t\t\t\t\tcase 'top_left':\n\t\t\t\t\tcase 'top_right':\n\t\t\t\t\tcase 'bottom_left':\n\t\t\t\t\tcase 'bottom_right': {\n\t\t\t\t\t\tif (shouldEnterCropMode) {\n\t\t\t\t\t\t\tthis.parent.transition('crop.pointing_crop_handle', info)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.parent.transition('pointing_resize_handle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thoveredShape &&\n\t\t\t\t\t\t\t!this.editor.getSelectedShapeIds().includes(hoveredShape.id) &&\n\t\t\t\t\t\t\t!hoveredShape.isLocked\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\t\tshape: hoveredShape,\n\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.parent.transition('pointing_selection', info)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onDoubleClick(info: TLClickEventInfo) {\n\t\tif (this.editor.inputs.shiftKey || info.phase !== 'up') return\n\n\t\t// We don't want to double click while toggling shapes\n\t\tif (info.ctrlKey || info.shiftKey) return\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\n\t\t\t\t// todo\n\t\t\t\t// double clicking on the middle of a hollow geo shape without a label, or\n\t\t\t\t// over the label of a hollwo shape that has a label, should start editing\n\t\t\t\t// that shape's label. We can't support \"double click anywhere inside\"\n\t\t\t\t// of the shape yet because that also creates text shapes, and can produce\n\t\t\t\t// unexpected results when working \"inside of\" a hollow shape.\n\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: (this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ??\n\t\t\t\t\t\t\tthis.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t}))\n\n\t\t\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tif (this.editor.isShapeOfType<TLGroupShape>(hitShape, 'group')) {\n\t\t\t\t\t\t// Probably select the shape\n\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst parent = this.editor.getShape(hitShape.parentId)\n\t\t\t\t\t\tif (parent && this.editor.isShapeOfType<TLGroupShape>(parent, 'group')) {\n\t\t\t\t\t\t\t// The shape is the direct child of a group. If the group is\n\t\t\t\t\t\t\t// selected, then we can select the shape. If the group is the\n\t\t\t\t\t\t\t// focus layer id, then we can double click into it as usual.\n\t\t\t\t\t\t\tif (focusedGroupId && parent.id === focusedGroupId) {\n\t\t\t\t\t\t\t\t// noop, double click on the shape as normal below\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// The shape is the child of some group other than our current\n\t\t\t\t\t\t\t\t// focus layer. We should probably select the group instead.\n\t\t\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// double click on the shape. We'll start editing the\n\t\t\t\t\t// shape if it's editable or else do a double click on\n\t\t\t\t\t// the canvas.\n\t\t\t\t\tthis.onDoubleClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif (!this.editor.inputs.shiftKey) {\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\t\t\tif (onlySelectedShape) {\n\t\t\t\t\tconst util = this.editor.getShapeUtil(onlySelectedShape)\n\n\t\t\t\t\tif (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// Test edges for an onDoubleClickEdge handler\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'right' ||\n\t\t\t\t\t\tinfo.handle === 'left' ||\n\t\t\t\t\t\tinfo.handle === 'top' ||\n\t\t\t\t\t\tinfo.handle === 'bottom'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickEdge?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click edge')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'top_left' ||\n\t\t\t\t\t\tinfo.handle === 'top_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_left'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickCorner?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click corner')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// For corners OR edges but NOT rotation corners\n\t\t\t\t\tif (\n\t\t\t\t\t\tutil.canCrop(onlySelectedShape) &&\n\t\t\t\t\t\t!this.editor.isShapeOrAncestorLocked(onlySelectedShape)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\t\tthis.startEditingShape(onlySelectedShape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\n\t\t\t\t// Allow playing videos and embeds\n\t\t\t\tif (shape.type !== 'video' && shape.type !== 'embed' && this.editor.getIsReadonly()) break\n\n\t\t\t\tif (util.onDoubleClick) {\n\t\t\t\t\t// Call the shape's double click handler\n\t\t\t\t\tconst change = util.onDoubleClick?.(shape)\n\t\t\t\t\tif (change) {\n\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (util.canCrop(shape) && !this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\t// crop image etc on double click\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('select and crop')\n\t\t\t\t\tthis.editor.select(info.shape?.id)\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the shape can edit, then begin editing\n\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape cannot edit, then create a text shape and\n\t\t\t\t\t// begin editing the text shape\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tconst { shape, handle } = info\n\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tconst changes = util.onDoubleClickHandle?.(shape, handle)\n\n\t\t\t\tif (changes) {\n\t\t\t\t\tthis.editor.updateShapes([changes])\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape can edit, then begin editing the shape.\n\t\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onRightClick(info: TLPointerEventInfo) {\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t\thitLabels: true,\n\t\t\t\t\t\t\t\thitLocked: true,\n\t\t\t\t\t\t\t\thitFrameInside: true,\n\t\t\t\t\t\t\t\trenderingOnly: true,\n\t\t\t\t\t\t\t})\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.editor.selectNone()\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { selectedShapeIds } = this.editor.getCurrentPageState()\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tconst targetShape = this.editor.getOutermostSelectableShape(\n\t\t\t\t\tshape,\n\t\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t\t)\n\n\t\t\t\tif (\n\t\t\t\t\t!selectedShapeIds.includes(targetShape.id) &&\n\t\t\t\t\t!this.editor.findShapeAncestor(targetShape, (shape) =>\n\t\t\t\t\t\tselectedShapeIds.includes(shape.id)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\t\t\tthis.editor.setSelectedShapes([targetShape.id])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tif (\n\t\t\tthis.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() &&\n\t\t\tthis.editor.getSelectedShapeIds().length > 0\n\t\t) {\n\t\t\tthis.editor.popFocusedGroupId()\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('clearing selection')\n\t\t\tthis.editor.selectNone()\n\t\t}\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tthis.selectedShapesOnKeyDown = this.editor.getSelectedShapes()\n\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tif (info.shiftKey) {\n\t\t\t\t\t\tif (info.code === 'ArrowDown') {\n\t\t\t\t\t\t\tthis.editor.selectFirstChildShape()\n\t\t\t\t\t\t} else if (info.code === 'ArrowUp') {\n\t\t\t\t\t\t\tthis.editor.selectParentShape()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(false)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (debugFlags['editOnType'].get()) {\n\t\t\t// This feature flag lets us start editing a note shape's label when a key is pressed.\n\t\t\t// We exclude certain keys to avoid conflicting with modifiers, but there are conflicts\n\t\t\t// with other action kbds, hence why this is kept behind a feature flag.\n\t\t\tif (!SKIPPED_KEYS_FOR_AUTO_EDITING.includes(info.key) && !info.altKey && !info.ctrlKey) {\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (\n\t\t\t\t\tonlySelectedShape &&\n\t\t\t\t\t// If it's a note shape, then edit on type\n\t\t\t\t\tthis.editor.isShapeOfType(onlySelectedShape, 'note') &&\n\t\t\t\t\t// If it's not locked or anything\n\t\t\t\t\tthis.shouldStartEditingShape(onlySelectedShape)\n\t\t\t\t) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyRepeat(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(true)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'Enter': {\n\t\t\t\t// Because Enter onKeyDown can happen outside the canvas (but then focus the canvas potentially),\n\t\t\t\t// we need to check if the canvas was initially selecting something before continuing.\n\t\t\t\tif (!this.selectedShapesOnKeyDown.length) return\n\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\n\t\t\t\t// On enter, if every selected shape is a group, then select all of the children of the groups\n\t\t\t\tif (\n\t\t\t\t\tselectedShapes.every((shape) => this.editor.isShapeOfType<TLGroupShape>(shape, 'group'))\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.setSelectedShapes(\n\t\t\t\t\t\tselectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is croppable, then begin cropping it\n\t\t\t\tif (getShouldEnterCropMode(this.editor)) {\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate shouldStartEditingShape(\n\t\tshape: TLShape | null = this.editor.getOnlySelectedShape()\n\t): boolean {\n\t\tif (!shape) return false\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return false\n\t\tif (!this.canInteractWithShapeInReadOnly(shape)) return false\n\t\treturn this.editor.getShapeUtil(shape).canEdit(shape)\n\t}\n\n\tprivate startEditingShape(\n\t\tshape: TLShape,\n\t\tinfo: TLClickEventInfo | TLKeyboardEventInfo,\n\t\tshouldSelectAll?: boolean\n\t) {\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return\n\t\tthis.editor.markHistoryStoppingPoint('editing shape')\n\t\tstartEditingShapeWithLabel(this.editor, shape, shouldSelectAll)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tisOverArrowLabelTest(shape: TLShape | undefined) {\n\t\tif (!shape) return false\n\n\t\t// todo: Extract into general hit test for arrows\n\t\tif (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {\n\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\tshape,\n\t\t\t\tthis.editor.inputs.currentPagePoint\n\t\t\t)\n\t\t\t// How should we handle multiple labels? Do shapes ever have multiple labels?\n\t\t\tconst labelGeometry = this.editor.getShapeGeometry<Group2d>(shape).children[1]\n\t\t\t// Knowing what we know about arrows... if the shape has no text in its label,\n\t\t\t// then the label geometry should not be there.\n\t\t\tif (labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\treturn false\n\t}\n\n\thandleDoubleClickOnCanvas(info: TLClickEventInfo) {\n\t\t// Create text shape and transition to editing_shape\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\tif (!this.editor.options.createTextOnCanvasDoubleClick) return\n\n\t\tthis.editor.markHistoryStoppingPoint('creating text shape')\n\n\t\tconst id = createShapeId()\n\n\t\tconst { x, y } = this.editor.inputs.currentPagePoint\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShapes<TLTextShape>([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'text',\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tprops: {\n\t\t\t\t\trichText: toRichText(''),\n\t\t\t\t\tautoSize: true,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape(id)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(shape)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.setEditingShape(id)\n\t\tthis.editor.select(id)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tprivate nudgeSelectedShapes(ephemeral = false) {\n\t\tconst {\n\t\t\teditor: {\n\t\t\t\tinputs: { keys },\n\t\t\t},\n\t\t} = this\n\n\t\t// We want to use the \"actual\" shift key state,\n\t\t// not the one that's in the editor.inputs.shiftKey,\n\t\t// because that one uses a short timeout on release\n\t\tconst shiftKey = keys.has('ShiftLeft')\n\n\t\tconst delta = new Vec(0, 0)\n\n\t\tif (keys.has('ArrowLeft')) delta.x -= 1\n\t\tif (keys.has('ArrowRight')) delta.x += 1\n\t\tif (keys.has('ArrowUp')) delta.y -= 1\n\t\tif (keys.has('ArrowDown')) delta.y += 1\n\n\t\tif (delta.equals(new Vec(0, 0))) return\n\n\t\tif (!ephemeral) this.editor.markHistoryStoppingPoint('nudge shapes')\n\n\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\n\t\tconst step = this.editor.getInstanceState().isGridMode\n\t\t\t? shiftKey\n\t\t\t\t? gridSize * GRID_INCREMENT\n\t\t\t\t: gridSize\n\t\t\t: shiftKey\n\t\t\t\t? MAJOR_NUDGE_FACTOR\n\t\t\t\t: MINOR_NUDGE_FACTOR\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tthis.editor.nudgeShapes(selectedShapeIds, delta.mul(step))\n\t\tkickoutOccludedShapes(this.editor, selectedShapeIds)\n\t}\n\n\tprivate canInteractWithShapeInReadOnly(shape: TLShape) {\n\t\tif (!this.editor.getIsReadonly()) return true\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (util.canEditInReadonly(shape)) return true\n\t\treturn false\n\t}\n}\n\nexport const MAJOR_NUDGE_FACTOR = 10\nexport const MINOR_NUDGE_FACTOR = 1\nexport const GRID_INCREMENT = 5\n\nfunction isPointInRotatedSelectionBounds(editor: Editor, point: VecLike) {\n\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\tif (!selectionBounds) return false\n\n\tconst selectionRotation = editor.getSelectionRotation()\n\tif (!selectionRotation) return selectionBounds.containsPoint(point)\n\n\treturn pointInPolygon(\n\t\tpoint,\n\t\tselectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))\n\t)\n}\n"],
5
- "mappings": "AAAA;AAAA,EAGC;AAAA,EASA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sCAAsC;AAC/C,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAE3C,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,aAAa,UAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,0BAAqC,CAAC;AAAA,EAE7B,UAAU;AAClB,SAAK,OAAO,qBAAqB,MAAS;AAC1C,yBAAqB,KAAK,MAAM;AAChC,SAAK,0BAA0B,CAAC;AAChC,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,SAAS;AACjB,yBAAqB,OAAO;AAAA,EAC7B;AAAA,EAES,gBAAgB;AACxB,yBAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,cAAc,MAA0B;AAChD,UAAM,sBAAsB,KAAK,WAAW,uBAAuB,KAAK,MAAM;AAE9E,YAAQ,KAAK,QAAQ;AAAA,MACpB,KAAK,UAAU;AAGd,cAAM,WA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,gBAAiB,QAAO;AAE7B,QAAM,oBAAoB,OAAO,qBAAqB;AACtD,MAAI,CAAC,kBAAmB,QAAO,gBAAgB,cAAc,KAAK;AAElE,SAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
4
+ "sourcesContent": ["import {\n\tEditor,\n\tStateNode,\n\tTLAdjacentDirection,\n\tTLClickEventInfo,\n\tTLGroupShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLTextShape,\n\tVec,\n\tVecLike,\n\tcreateShapeId,\n\tdebugFlags,\n\tkickoutOccludedShapes,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\nimport { startEditingShapeWithLabel } from '../selectHelpers'\n\nconst SKIPPED_KEYS_FOR_AUTO_EDITING = [\n\t'Delete',\n\t'Backspace',\n\t'[',\n\t']',\n\t'Enter',\n\t' ',\n\t'Shift',\n\t'Tab',\n]\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\tselectedShapesOnKeyDown: TLShape[] = []\n\n\toverride onEnter() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.selectedShapesOnKeyDown = []\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onExit() {\n\t\tupdateHoveredShapeId.cancel()\n\t}\n\n\toverride onPointerMove() {\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tconst shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor)\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\t// Check to see if we hit any shape under the pointer; if so,\n\t\t\t\t// handle this as a pointer down on the shape instead of the canvas\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !hitShape.isLocked) {\n\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tif (this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tif (this.editor.inputs.altKey) {\n\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t} else {\n\t\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\t\tthis.parent.transition('pointing_handle', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tswitch (info.handle) {\n\t\t\t\t\tcase 'mobile_rotate':\n\t\t\t\t\tcase 'top_left_rotate':\n\t\t\t\t\tcase 'top_right_rotate':\n\t\t\t\t\tcase 'bottom_left_rotate':\n\t\t\t\t\tcase 'bottom_right_rotate': {\n\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.parent.transition('pointing_rotate_handle', info)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'top':\n\t\t\t\t\tcase 'right':\n\t\t\t\t\tcase 'bottom':\n\t\t\t\t\tcase 'left':\n\t\t\t\t\tcase 'top_left':\n\t\t\t\t\tcase 'top_right':\n\t\t\t\t\tcase 'bottom_left':\n\t\t\t\t\tcase 'bottom_right': {\n\t\t\t\t\t\tif (shouldEnterCropMode) {\n\t\t\t\t\t\t\tthis.parent.transition('crop.pointing_crop_handle', info)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.parent.transition('pointing_resize_handle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thoveredShape &&\n\t\t\t\t\t\t\t!this.editor.getSelectedShapeIds().includes(hoveredShape.id) &&\n\t\t\t\t\t\t\t!hoveredShape.isLocked\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\t\tshape: hoveredShape,\n\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.parent.transition('pointing_selection', info)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onDoubleClick(info: TLClickEventInfo) {\n\t\tif (this.editor.inputs.shiftKey || info.phase !== 'up') return\n\n\t\t// We don't want to double click while toggling shapes\n\t\tif (info.ctrlKey || info.shiftKey) return\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\n\t\t\t\t// todo\n\t\t\t\t// double clicking on the middle of a hollow geo shape without a label, or\n\t\t\t\t// over the label of a hollwo shape that has a label, should start editing\n\t\t\t\t// that shape's label. We can't support \"double click anywhere inside\"\n\t\t\t\t// of the shape yet because that also creates text shapes, and can produce\n\t\t\t\t// unexpected results when working \"inside of\" a hollow shape.\n\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: (this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ??\n\t\t\t\t\t\t\tthis.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t}))\n\n\t\t\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tif (this.editor.isShapeOfType<TLGroupShape>(hitShape, 'group')) {\n\t\t\t\t\t\t// Probably select the shape\n\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst parent = this.editor.getShape(hitShape.parentId)\n\t\t\t\t\t\tif (parent && this.editor.isShapeOfType<TLGroupShape>(parent, 'group')) {\n\t\t\t\t\t\t\t// The shape is the direct child of a group. If the group is\n\t\t\t\t\t\t\t// selected, then we can select the shape. If the group is the\n\t\t\t\t\t\t\t// focus layer id, then we can double click into it as usual.\n\t\t\t\t\t\t\tif (focusedGroupId && parent.id === focusedGroupId) {\n\t\t\t\t\t\t\t\t// noop, double click on the shape as normal below\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// The shape is the child of some group other than our current\n\t\t\t\t\t\t\t\t// focus layer. We should probably select the group instead.\n\t\t\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// double click on the shape. We'll start editing the\n\t\t\t\t\t// shape if it's editable or else do a double click on\n\t\t\t\t\t// the canvas.\n\t\t\t\t\tthis.onDoubleClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif (!this.editor.inputs.shiftKey) {\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\t\t\tif (onlySelectedShape) {\n\t\t\t\t\tconst util = this.editor.getShapeUtil(onlySelectedShape)\n\n\t\t\t\t\tif (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// Test edges for an onDoubleClickEdge handler\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'right' ||\n\t\t\t\t\t\tinfo.handle === 'left' ||\n\t\t\t\t\t\tinfo.handle === 'top' ||\n\t\t\t\t\t\tinfo.handle === 'bottom'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickEdge?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click edge')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'top_left' ||\n\t\t\t\t\t\tinfo.handle === 'top_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_left'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickCorner?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click corner')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// For corners OR edges but NOT rotation corners\n\t\t\t\t\tif (\n\t\t\t\t\t\tutil.canCrop(onlySelectedShape) &&\n\t\t\t\t\t\t!this.editor.isShapeOrAncestorLocked(onlySelectedShape)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\t\tthis.startEditingShape(onlySelectedShape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\n\t\t\t\t// Allow playing videos and embeds\n\t\t\t\tif (shape.type !== 'video' && shape.type !== 'embed' && this.editor.getIsReadonly()) break\n\n\t\t\t\tif (util.onDoubleClick) {\n\t\t\t\t\t// Call the shape's double click handler\n\t\t\t\t\tconst change = util.onDoubleClick?.(shape)\n\t\t\t\t\tif (change) {\n\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (util.canCrop(shape) && !this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\t// crop image etc on double click\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('select and crop')\n\t\t\t\t\tthis.editor.select(info.shape?.id)\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the shape can edit, then begin editing\n\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape cannot edit, then create a text shape and\n\t\t\t\t\t// begin editing the text shape\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tconst { shape, handle } = info\n\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tconst changes = util.onDoubleClickHandle?.(shape, handle)\n\n\t\t\t\tif (changes) {\n\t\t\t\t\tthis.editor.updateShapes([changes])\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape can edit, then begin editing the shape.\n\t\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onRightClick(info: TLPointerEventInfo) {\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t\thitLabels: true,\n\t\t\t\t\t\t\t\thitLocked: true,\n\t\t\t\t\t\t\t\thitFrameInside: true,\n\t\t\t\t\t\t\t\trenderingOnly: true,\n\t\t\t\t\t\t\t})\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.editor.selectNone()\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { selectedShapeIds } = this.editor.getCurrentPageState()\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tconst targetShape = this.editor.getOutermostSelectableShape(\n\t\t\t\t\tshape,\n\t\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t\t)\n\n\t\t\t\tif (\n\t\t\t\t\t!selectedShapeIds.includes(targetShape.id) &&\n\t\t\t\t\t!this.editor.findShapeAncestor(targetShape, (shape) =>\n\t\t\t\t\t\tselectedShapeIds.includes(shape.id)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\t\t\tthis.editor.setSelectedShapes([targetShape.id])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tif (\n\t\t\tthis.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() &&\n\t\t\tthis.editor.getSelectedShapeIds().length > 0\n\t\t) {\n\t\t\tthis.editor.popFocusedGroupId()\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('clearing selection')\n\t\t\tthis.editor.selectNone()\n\t\t}\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tthis.selectedShapesOnKeyDown = this.editor.getSelectedShapes()\n\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tif (info.shiftKey) {\n\t\t\t\t\t\tif (info.code === 'ArrowDown') {\n\t\t\t\t\t\t\tthis.editor.selectFirstChildShape()\n\t\t\t\t\t\t} else if (info.code === 'ArrowUp') {\n\t\t\t\t\t\t\tthis.editor.selectParentShape()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(false)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (debugFlags['editOnType'].get()) {\n\t\t\t// This feature flag lets us start editing a note shape's label when a key is pressed.\n\t\t\t// We exclude certain keys to avoid conflicting with modifiers, but there are conflicts\n\t\t\t// with other action kbds, hence why this is kept behind a feature flag.\n\t\t\tif (!SKIPPED_KEYS_FOR_AUTO_EDITING.includes(info.key) && !info.altKey && !info.ctrlKey) {\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (\n\t\t\t\t\tonlySelectedShape &&\n\t\t\t\t\t// If it's a note shape, then edit on type\n\t\t\t\t\tthis.editor.isShapeOfType(onlySelectedShape, 'note') &&\n\t\t\t\t\t// If it's not locked or anything\n\t\t\t\t\tthis.shouldStartEditingShape(onlySelectedShape)\n\t\t\t\t) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyRepeat(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(true)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'Enter': {\n\t\t\t\t// Because Enter onKeyDown can happen outside the canvas (but then focus the canvas potentially),\n\t\t\t\t// we need to check if the canvas was initially selecting something before continuing.\n\t\t\t\tif (!this.selectedShapesOnKeyDown.length) return\n\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\n\t\t\t\t// On enter, if every selected shape is a group, then select all of the children of the groups\n\t\t\t\tif (\n\t\t\t\t\tselectedShapes.every((shape) => this.editor.isShapeOfType<TLGroupShape>(shape, 'group'))\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.setSelectedShapes(\n\t\t\t\t\t\tselectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is croppable, then begin cropping it\n\t\t\t\tif (getShouldEnterCropMode(this.editor)) {\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate shouldStartEditingShape(\n\t\tshape: TLShape | null = this.editor.getOnlySelectedShape()\n\t): boolean {\n\t\tif (!shape) return false\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return false\n\t\tif (!this.canInteractWithShapeInReadOnly(shape)) return false\n\t\treturn this.editor.getShapeUtil(shape).canEdit(shape)\n\t}\n\n\tprivate startEditingShape(\n\t\tshape: TLShape,\n\t\tinfo: TLClickEventInfo | TLKeyboardEventInfo,\n\t\tshouldSelectAll?: boolean\n\t) {\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return\n\t\tthis.editor.markHistoryStoppingPoint('editing shape')\n\t\tstartEditingShapeWithLabel(this.editor, shape, shouldSelectAll)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tisOverArrowLabelTest(shape: TLShape | undefined) {\n\t\tif (!shape) return false\n\n\t\treturn isOverArrowLabel(this.editor, shape)\n\t}\n\n\thandleDoubleClickOnCanvas(info: TLClickEventInfo) {\n\t\t// Create text shape and transition to editing_shape\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\tif (!this.editor.options.createTextOnCanvasDoubleClick) return\n\n\t\tthis.editor.markHistoryStoppingPoint('creating text shape')\n\n\t\tconst id = createShapeId()\n\n\t\tconst { x, y } = this.editor.inputs.currentPagePoint\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShapes<TLTextShape>([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'text',\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tprops: {\n\t\t\t\t\trichText: toRichText(''),\n\t\t\t\t\tautoSize: true,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape(id)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(shape)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.setEditingShape(id)\n\t\tthis.editor.select(id)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tprivate nudgeSelectedShapes(ephemeral = false) {\n\t\tconst {\n\t\t\teditor: {\n\t\t\t\tinputs: { keys },\n\t\t\t},\n\t\t} = this\n\n\t\t// We want to use the \"actual\" shift key state,\n\t\t// not the one that's in the editor.inputs.shiftKey,\n\t\t// because that one uses a short timeout on release\n\t\tconst shiftKey = keys.has('ShiftLeft')\n\n\t\tconst delta = new Vec(0, 0)\n\n\t\tif (keys.has('ArrowLeft')) delta.x -= 1\n\t\tif (keys.has('ArrowRight')) delta.x += 1\n\t\tif (keys.has('ArrowUp')) delta.y -= 1\n\t\tif (keys.has('ArrowDown')) delta.y += 1\n\n\t\tif (delta.equals(new Vec(0, 0))) return\n\n\t\tif (!ephemeral) this.editor.markHistoryStoppingPoint('nudge shapes')\n\n\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\n\t\tconst step = this.editor.getInstanceState().isGridMode\n\t\t\t? shiftKey\n\t\t\t\t? gridSize * GRID_INCREMENT\n\t\t\t\t: gridSize\n\t\t\t: shiftKey\n\t\t\t\t? MAJOR_NUDGE_FACTOR\n\t\t\t\t: MINOR_NUDGE_FACTOR\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tthis.editor.nudgeShapes(selectedShapeIds, delta.mul(step))\n\t\tkickoutOccludedShapes(this.editor, selectedShapeIds)\n\t}\n\n\tprivate canInteractWithShapeInReadOnly(shape: TLShape) {\n\t\tif (!this.editor.getIsReadonly()) return true\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (util.canEditInReadonly(shape)) return true\n\t\treturn false\n\t}\n}\n\nexport const MAJOR_NUDGE_FACTOR = 10\nexport const MINOR_NUDGE_FACTOR = 1\nexport const GRID_INCREMENT = 5\n\nfunction isPointInRotatedSelectionBounds(editor: Editor, point: VecLike) {\n\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\tif (!selectionBounds) return false\n\n\tconst selectionRotation = editor.getSelectionRotation()\n\tif (!selectionRotation) return selectionBounds.containsPoint(point)\n\n\treturn pointInPolygon(\n\t\tpoint,\n\t\tselectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))\n\t)\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAQA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AACjC,SAAS,sCAAsC;AAC/C,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,kCAAkC;AAE3C,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM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BAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB;AAE9B,SAAS,gCAAgC,QAAgB,OAAgB;AACxE,QAAM,kBAAkB,OAAO,8BAA8B;AAC7D,MAAI,CAAC,gBAAiB,QAAO;AAE7B,QAAM,oBAAoB,OAAO,qBAAqB;AACtD,MAAI,CAAC,kBAAmB,QAAO,gBAAgB,cAAc,KAAK;AAElE,SAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
6
6
  "names": ["shape"]
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { StateNode } from "@tldraw/editor";
2
+ import { isOverArrowLabel } from "../../../shapes/arrow/arrowLabel.mjs";
2
3
  import { getTextLabels } from "../../../utils/shapes/shapes.mjs";
3
4
  class PointingShape extends StateNode {
4
5
  static id = "pointing_shape";
@@ -154,6 +155,10 @@ class PointingShape extends StateNode {
154
155
  }
155
156
  onPointerMove(info) {
156
157
  if (this.editor.inputs.isDragging) {
158
+ if (isOverArrowLabel(this.editor, this.hitShape)) {
159
+ this.parent.transition("pointing_arrow_label", { ...info, shape: this.hitShape });
160
+ return;
161
+ }
157
162
  if (this.didCtrlOnEnter) {
158
163
  this.parent.transition("brushing", info);
159
164
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingShape.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\n\nexport class PointingShape extends StateNode {\n\tstatic override id = 'pointing_shape'\n\n\thitShape = {} as TLShape\n\thitShapeForPointerUp = {} as TLShape\n\tisDoubleClick = false\n\n\tdidCtrlOnEnter = false\n\tdidSelectOnEnter = false\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'shape' }) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\t\tconst { shiftKey, altKey, accelKey } = info\n\n\t\tthis.hitShape = info.shape\n\t\tthis.isDoubleClick = false\n\t\tthis.didCtrlOnEnter = accelKey\n\t\tconst outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape)\n\t\tconst selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) =>\n\t\t\tselectedShapeIds.includes(parent.id)\n\t\t)\n\n\t\tif (\n\t\t\tthis.didCtrlOnEnter ||\n\t\t\t// If the shape has an onClick handler\n\t\t\tthis.editor.getShapeUtil(info.shape).onClick ||\n\t\t\t// ...or if the shape is the focused layer (e.g. group)\n\t\t\toutermostSelectingShape.id === focusedGroupId ||\n\t\t\t// ...or if the shape is within the selection\n\t\t\tselectedShapeIds.includes(outermostSelectingShape.id) ||\n\t\t\t// ...or if an ancestor of the shape is selected\n\t\t\tselectedAncestor ||\n\t\t\t// ...or if the current point is NOT within the selection bounds\n\t\t\t(selectedShapeIds.length > 1 && selectionBounds?.containsPoint(currentPagePoint))\n\t\t) {\n\t\t\t// We won't select the shape on enter, though we might select it on pointer up!\n\t\t\tthis.didSelectOnEnter = false\n\t\t\tthis.hitShapeForPointerUp = outermostSelectingShape\n\t\t\treturn\n\t\t}\n\n\t\tthis.didSelectOnEnter = true\n\n\t\tif (shiftKey && !altKey) {\n\t\t\tthis.editor.cancelDoubleClick()\n\t\t\tif (!selectedShapeIds.includes(outermostSelectingShape.id)) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift selecting shape')\n\t\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, outermostSelectingShape.id])\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\tthis.editor.setSelectedShapes([outermostSelectingShape.id])\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst zoomLevel = this.editor.getZoomLevel()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tconst hitShape =\n\t\t\tthis.editor.getShapeAtPoint(currentPagePoint, {\n\t\t\t\tmargin: this.editor.options.hitTestMargin / zoomLevel,\n\t\t\t\thitInside: true,\n\t\t\t\trenderingOnly: true,\n\t\t\t}) ?? this.hitShape\n\n\t\tconst selectingShape = hitShape\n\t\t\t? this.editor.getOutermostSelectableShape(hitShape)\n\t\t\t: this.hitShapeForPointerUp\n\n\t\tif (selectingShape) {\n\t\t\t// If the selecting shape has a click handler, call it instead of selecting the shape\n\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\tif (util.onClick) {\n\t\t\t\tconst change = util.onClick?.(selectingShape)\n\t\t\t\tif (change) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('shape on click')\n\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (selectingShape.id === focusedGroupId) {\n\t\t\t\tif (selectedShapeIds.length > 0) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('clearing shape ids')\n\t\t\t\t\tthis.editor.setSelectedShapes([])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t\t}\n\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!this.didSelectOnEnter) {\n\t\t\t// if the shape has an ancestor which is a focusable layer and it is not focused but it is selected\n\t\t\t// then we should focus the layer and select the shape\n\n\t\t\tconst outermostSelectableShape = this.editor.getOutermostSelectableShape(\n\t\t\t\thitShape,\n\t\t\t\t// if a group is selected, we want to stop before reaching that group\n\t\t\t\t// so we can drill down into the group\n\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t)\n\n\t\t\t// If the outermost shape is selected, then either select or deselect the SELECTING shape\n\t\t\tif (selectedShapeIds.includes(outermostSelectableShape.id)) {\n\t\t\t\t// same shape, so deselect it if shift is pressed, otherwise deselect all others\n\t\t\t\tif (additiveSelectionKey) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('deselecting on pointer up')\n\t\t\t\t\tthis.editor.deselect(selectingShape)\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedShapeIds.includes(selectingShape.id)) {\n\t\t\t\t\t\t// todo\n\t\t\t\t\t\t// if the shape is editable and we're inside of an editable part of that shape, e.g. the label of a geo shape,\n\t\t\t\t\t\t// then we would want to begin editing the shape. At the moment we're relying on the shape label's onPointerUp\n\t\t\t\t\t\t// handler to do this logic, and prevent the regular pointer up event, so we won't be here in that case.\n\n\t\t\t\t\t\t// if the shape has a text label, and we're inside of the label, then we want to begin editing the label.\n\t\t\t\t\t\tif (selectedShapeIds.length === 1) {\n\t\t\t\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t\t\t\t// N.B. we're only interested if there is exactly one text label. We don't handle the\n\t\t\t\t\t\t\t// case if there's potentially more than one text label at the moment.\n\t\t\t\t\t\t\tif (textLabel) {\n\t\t\t\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\t\t\t\tcurrentPagePoint\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tthis.editor.run(() => {\n\t\t\t\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\n\t\t\t\t\t\t\t\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\t\t\t\t\t\t\t\tif (this.editor.getIsReadonly()) {\n\t\t\t\t\t\t\t\t\t\t\tif (!util.canEditInReadonly(selectingShape)) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tthis.editor.setEditingShape(selectingShape.id)\n\t\t\t\t\t\t\t\t\t\tthis.editor.setCurrentTool('select.editing_shape')\n\n\t\t\t\t\t\t\t\t\t\tif (this.isDoubleClick) {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('select-all-text', { shapeId: selectingShape.id })\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('place-caret', {\n\t\t\t\t\t\t\t\t\t\t\t\tshapeId: selectingShape.id,\n\t\t\t\t\t\t\t\t\t\t\t\tpoint: info.point,\n\t\t\t\t\t\t\t\t\t\t\t})\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\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// We just want to select the single shape from the selection\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (additiveSelectionKey) {\n\t\t\t\t// Different shape, so we are drilling down into a group with shift key held.\n\t\t\t\t// Deselect any ancestors and add the target shape to the selection\n\t\t\t\tconst ancestors = this.editor.getShapeAncestors(outermostSelectableShape)\n\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift deselecting on pointer up')\n\t\t\t\tthis.editor.setSelectedShapes([\n\t\t\t\t\t...this.editor.getSelectedShapeIds().filter((id) => !ancestors.find((a) => a.id === id)),\n\t\t\t\t\toutermostSelectableShape.id,\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t// different shape and we are drilling down, but no shift held so just select it straight up\n\t\t\t\tthis.editor.setSelectedShapes([outermostSelectableShape.id])\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onDoubleClick() {\n\t\tthis.isDoubleClick = true\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tif (this.didCtrlOnEnter) {\n\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t} else {\n\t\t\t\tthis.startTranslating(info)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startTranslating(info)\n\t}\n\n\tprivate startTranslating(info: TLPointerEventInfo) {\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\t// Re-focus the editor, just in case the text label of the shape has stolen focus\n\t\tthis.editor.focus()\n\t\tthis.parent.transition('translating', info)\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate cancel() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": "AAAA,S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AAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\n\nexport class PointingShape extends StateNode {\n\tstatic override id = 'pointing_shape'\n\n\thitShape = {} as TLShape\n\thitShapeForPointerUp = {} as TLShape\n\tisDoubleClick = false\n\n\tdidCtrlOnEnter = false\n\tdidSelectOnEnter = false\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'shape' }) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\t\tconst { shiftKey, altKey, accelKey } = info\n\n\t\tthis.hitShape = info.shape\n\t\tthis.isDoubleClick = false\n\t\tthis.didCtrlOnEnter = accelKey\n\t\tconst outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape)\n\t\tconst selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) =>\n\t\t\tselectedShapeIds.includes(parent.id)\n\t\t)\n\n\t\tif (\n\t\t\tthis.didCtrlOnEnter ||\n\t\t\t// If the shape has an onClick handler\n\t\t\tthis.editor.getShapeUtil(info.shape).onClick ||\n\t\t\t// ...or if the shape is the focused layer (e.g. group)\n\t\t\toutermostSelectingShape.id === focusedGroupId ||\n\t\t\t// ...or if the shape is within the selection\n\t\t\tselectedShapeIds.includes(outermostSelectingShape.id) ||\n\t\t\t// ...or if an ancestor of the shape is selected\n\t\t\tselectedAncestor ||\n\t\t\t// ...or if the current point is NOT within the selection bounds\n\t\t\t(selectedShapeIds.length > 1 && selectionBounds?.containsPoint(currentPagePoint))\n\t\t) {\n\t\t\t// We won't select the shape on enter, though we might select it on pointer up!\n\t\t\tthis.didSelectOnEnter = false\n\t\t\tthis.hitShapeForPointerUp = outermostSelectingShape\n\t\t\treturn\n\t\t}\n\n\t\tthis.didSelectOnEnter = true\n\n\t\tif (shiftKey && !altKey) {\n\t\t\tthis.editor.cancelDoubleClick()\n\t\t\tif (!selectedShapeIds.includes(outermostSelectingShape.id)) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift selecting shape')\n\t\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, outermostSelectingShape.id])\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\tthis.editor.setSelectedShapes([outermostSelectingShape.id])\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst zoomLevel = this.editor.getZoomLevel()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tconst hitShape =\n\t\t\tthis.editor.getShapeAtPoint(currentPagePoint, {\n\t\t\t\tmargin: this.editor.options.hitTestMargin / zoomLevel,\n\t\t\t\thitInside: true,\n\t\t\t\trenderingOnly: true,\n\t\t\t}) ?? this.hitShape\n\n\t\tconst selectingShape = hitShape\n\t\t\t? this.editor.getOutermostSelectableShape(hitShape)\n\t\t\t: this.hitShapeForPointerUp\n\n\t\tif (selectingShape) {\n\t\t\t// If the selecting shape has a click handler, call it instead of selecting the shape\n\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\tif (util.onClick) {\n\t\t\t\tconst change = util.onClick?.(selectingShape)\n\t\t\t\tif (change) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('shape on click')\n\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (selectingShape.id === focusedGroupId) {\n\t\t\t\tif (selectedShapeIds.length > 0) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('clearing shape ids')\n\t\t\t\t\tthis.editor.setSelectedShapes([])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t\t}\n\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!this.didSelectOnEnter) {\n\t\t\t// if the shape has an ancestor which is a focusable layer and it is not focused but it is selected\n\t\t\t// then we should focus the layer and select the shape\n\n\t\t\tconst outermostSelectableShape = this.editor.getOutermostSelectableShape(\n\t\t\t\thitShape,\n\t\t\t\t// if a group is selected, we want to stop before reaching that group\n\t\t\t\t// so we can drill down into the group\n\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t)\n\n\t\t\t// If the outermost shape is selected, then either select or deselect the SELECTING shape\n\t\t\tif (selectedShapeIds.includes(outermostSelectableShape.id)) {\n\t\t\t\t// same shape, so deselect it if shift is pressed, otherwise deselect all others\n\t\t\t\tif (additiveSelectionKey) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('deselecting on pointer up')\n\t\t\t\t\tthis.editor.deselect(selectingShape)\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedShapeIds.includes(selectingShape.id)) {\n\t\t\t\t\t\t// todo\n\t\t\t\t\t\t// if the shape is editable and we're inside of an editable part of that shape, e.g. the label of a geo shape,\n\t\t\t\t\t\t// then we would want to begin editing the shape. At the moment we're relying on the shape label's onPointerUp\n\t\t\t\t\t\t// handler to do this logic, and prevent the regular pointer up event, so we won't be here in that case.\n\n\t\t\t\t\t\t// if the shape has a text label, and we're inside of the label, then we want to begin editing the label.\n\t\t\t\t\t\tif (selectedShapeIds.length === 1) {\n\t\t\t\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t\t\t\t// N.B. we're only interested if there is exactly one text label. We don't handle the\n\t\t\t\t\t\t\t// case if there's potentially more than one text label at the moment.\n\t\t\t\t\t\t\tif (textLabel) {\n\t\t\t\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\t\t\t\tcurrentPagePoint\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tthis.editor.run(() => {\n\t\t\t\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\n\t\t\t\t\t\t\t\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\t\t\t\t\t\t\t\tif (this.editor.getIsReadonly()) {\n\t\t\t\t\t\t\t\t\t\t\tif (!util.canEditInReadonly(selectingShape)) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tthis.editor.setEditingShape(selectingShape.id)\n\t\t\t\t\t\t\t\t\t\tthis.editor.setCurrentTool('select.editing_shape')\n\n\t\t\t\t\t\t\t\t\t\tif (this.isDoubleClick) {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('select-all-text', { shapeId: selectingShape.id })\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('place-caret', {\n\t\t\t\t\t\t\t\t\t\t\t\tshapeId: selectingShape.id,\n\t\t\t\t\t\t\t\t\t\t\t\tpoint: info.point,\n\t\t\t\t\t\t\t\t\t\t\t})\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\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// We just want to select the single shape from the selection\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (additiveSelectionKey) {\n\t\t\t\t// Different shape, so we are drilling down into a group with shift key held.\n\t\t\t\t// Deselect any ancestors and add the target shape to the selection\n\t\t\t\tconst ancestors = this.editor.getShapeAncestors(outermostSelectableShape)\n\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift deselecting on pointer up')\n\t\t\t\tthis.editor.setSelectedShapes([\n\t\t\t\t\t...this.editor.getSelectedShapeIds().filter((id) => !ancestors.find((a) => a.id === id)),\n\t\t\t\t\toutermostSelectableShape.id,\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t// different shape and we are drilling down, but no shift held so just select it straight up\n\t\t\t\tthis.editor.setSelectedShapes([outermostSelectableShape.id])\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onDoubleClick() {\n\t\tthis.isDoubleClick = true\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tif (isOverArrowLabel(this.editor, this.hitShape)) {\n\t\t\t\t// We're moving the label on a shape.\n\t\t\t\tthis.parent.transition('pointing_arrow_label', { ...info, shape: this.hitShape })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (this.didCtrlOnEnter) {\n\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t} else {\n\t\t\t\tthis.startTranslating(info)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startTranslating(info)\n\t}\n\n\tprivate startTranslating(info: TLPointerEventInfo) {\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\t// Re-focus the editor, just in case the text label of the shape has stolen focus\n\t\tthis.editor.focus()\n\t\tthis.parent.transition('translating', info)\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate cancel() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAA8C;AACvD,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAEvB,MAAM,sBAAsB,UAAU;AAAA,EAC5C,OAAgB,KAAK;AAAA,EAErB,WAAW,CAAC;AAAA,EACZ,uBAAuB,CAAC;AAAA,EACxB,gBAAgB;AAAA,EAEhB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EAEV,QAAQ,MAAgD;AAChE,UAAM,mBAAmB,KAAK,OAAO,oBAAoB;AACzD,UAAM,kBAAkB,KAAK,OAAO,8BAA8B;AAClE,UAAM,iBAAiB,KAAK,OAAO,kBAAkB;AACrD,UAAM;AAAA,MACL,QAAQ,EAAE,iBAAiB;AAAA,IAC5B,IAAI,KAAK;AACT,UAAM,EAAE,UAAU,QAAQ,SAAS,IAAI;AAEvC,SAAK,WAAW,KAAK;AACrB,SAAK,gBAAgB;AACrB,SAAK,iBAAiB;AACtB,UAAM,0BAA0B,KAAK,OAAO,4BAA4B,KAAK,KAAK;AAClF,UAAM,mBAAmB,KAAK,OAAO;AAAA,MAAkB;AAAA,MAAyB,CAAC,WAChF,iBA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AACxB,SAAK,gBAAgB;AAAA,EACtB;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,UAAI,iBAAiB,KAAK,QAAQ,KAAK,QAAQ,GAAG;AAEjD,aAAK,OAAO,WAAW,wBAAwB,EAAE,GAAG,MAAM,OAAO,KAAK,SAAS,CAAC;AAChF;AAAA,MACD;AAEA,UAAI,KAAK,gBAAgB;AACxB,aAAK,OAAO,WAAW,YAAY,IAAI;AAAA,MACxC,OAAO;AACN,aAAK,iBAAiB,IAAI;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAC9C,SAAK,iBAAiB,IAAI;AAAA,EAC3B;AAAA,EAEQ,iBAAiB,MAA0B;AAClD,QAAI,KAAK,OAAO,cAAc,EAAG;AAGjC,SAAK,OAAO,MAAM;AAClB,SAAK,OAAO,WAAW,eAAe,IAAI;AAAA,EAC3C;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EACS,aAAa;AACrB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,cAAc;AACtB,SAAK,OAAO;AAAA,EACb;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -78,6 +78,14 @@ class Resizing extends StateNode {
78
78
  this.cancel();
79
79
  }
80
80
  cancel() {
81
+ const { shapeSnapshots } = this.snapshot;
82
+ shapeSnapshots.forEach(({ shape }) => {
83
+ const current = this.editor.getShape(shape.id);
84
+ if (current) {
85
+ const util = this.editor.getShapeUtil(shape);
86
+ util.onResizeCancel?.(shape, current);
87
+ }
88
+ });
81
89
  this.editor.bailToMark(this.markId);
82
90
  if (this.info.onInteractionEnd) {
83
91
  this.editor.setCurrentTool(this.info.onInteractionEnd, {});