tldraw 4.3.0-canary.e52fa5385f86 → 4.3.0-canary.ea88b223b83a

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 (548) hide show
  1. package/dist-cjs/index.d.ts +294 -237
  2. package/dist-cjs/index.js +12 -5
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
  5. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  6. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  7. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  8. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  9. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  10. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  11. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
  13. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  15. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  16. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  17. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  18. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  19. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  20. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  21. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  22. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  23. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  24. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  25. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  26. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  27. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
  28. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  29. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  30. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  31. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  32. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  33. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  34. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  35. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
  36. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  37. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
  38. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  39. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  40. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  41. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  42. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  43. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
  44. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  45. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  46. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  47. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
  48. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  49. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  50. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  51. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
  52. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  53. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  54. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  55. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
  56. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  57. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  58. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  59. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  60. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  61. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  62. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  63. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  64. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  65. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  66. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  67. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  68. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  69. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  70. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  71. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  72. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  73. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  74. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  75. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  76. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  77. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  78. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  79. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  80. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  81. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  82. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  83. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  84. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  85. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  86. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  87. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +9 -7
  88. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  89. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  90. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  91. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  92. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  93. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  94. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  95. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  96. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  97. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  98. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  99. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  103. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +7 -5
  104. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  105. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  106. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  107. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  109. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  110. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  111. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  112. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  113. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  114. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  115. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  116. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  117. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  118. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  119. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  123. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  124. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  125. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  126. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  127. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  128. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  129. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  130. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  131. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  132. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  133. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  134. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  135. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  136. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  137. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  138. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  139. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  140. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  141. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  142. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  143. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  144. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  145. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  146. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  147. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  148. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  149. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  150. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  151. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  152. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  153. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  154. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  155. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  156. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  157. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  159. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  160. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  161. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  163. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  164. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  165. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  166. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  167. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  168. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  169. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  170. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  172. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  173. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +6 -5
  174. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  175. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  176. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  177. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -2
  178. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  179. package/dist-cjs/lib/ui/context/actions.js +6 -6
  180. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  181. package/dist-cjs/lib/ui/context/components.js +1 -2
  182. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  183. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  184. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  185. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  186. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  187. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  188. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  189. package/dist-cjs/lib/ui/version.js +3 -3
  190. package/dist-cjs/lib/ui/version.js.map +1 -1
  191. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -6
  192. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  193. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  194. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  195. package/dist-cjs/lib/utils/text/richText.js +4 -2
  196. package/dist-cjs/lib/utils/text/richText.js.map +2 -2
  197. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  198. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  199. package/dist-esm/index.d.mts +294 -237
  200. package/dist-esm/index.mjs +12 -5
  201. package/dist-esm/index.mjs.map +2 -2
  202. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  203. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  204. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  205. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  206. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  207. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  208. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  209. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  210. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  211. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  212. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  213. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  214. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  215. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  216. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  217. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  218. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  219. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  220. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  221. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  222. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  223. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  224. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
  225. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  226. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  227. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  228. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  229. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  230. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  231. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  232. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
  233. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  234. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
  235. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  236. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  237. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  238. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  239. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  240. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
  241. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  242. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  243. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  244. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
  245. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  246. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  247. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  248. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
  249. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  250. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  251. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  252. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
  253. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  254. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  255. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  256. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  257. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  258. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  259. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  260. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  261. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  262. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  263. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  264. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  265. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  266. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  267. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  268. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  269. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  270. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  271. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  272. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  273. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  274. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
  275. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  276. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  277. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  278. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  279. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  280. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  281. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  282. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  283. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  284. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +9 -7
  285. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  286. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  287. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  288. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  289. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  290. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  291. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  292. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  293. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  294. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  295. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  296. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  297. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  298. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  299. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  300. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +7 -5
  301. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  302. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  303. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  304. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  305. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  306. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  307. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  308. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  309. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  310. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -15
  311. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  312. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  313. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  314. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  315. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  316. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  317. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  318. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  319. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  320. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  321. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  323. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  324. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  325. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  326. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  327. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  328. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  329. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  330. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  331. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  332. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  333. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  334. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  335. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  336. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  337. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  338. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  339. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  340. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  341. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  342. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  343. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  344. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  345. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  346. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  347. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  348. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  349. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  350. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  351. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  352. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  353. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  354. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  355. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  356. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  357. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  358. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  359. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  360. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  361. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  362. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  363. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  364. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  365. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  366. package/dist-esm/lib/ui/components/menu-items.mjs +3 -1
  367. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  368. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  369. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  370. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +6 -5
  371. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  372. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  373. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  374. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +1 -2
  375. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  376. package/dist-esm/lib/ui/context/actions.mjs +6 -6
  377. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  378. package/dist-esm/lib/ui/context/components.mjs +1 -2
  379. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  380. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  381. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  382. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  383. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  384. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  385. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  386. package/dist-esm/lib/ui/version.mjs +3 -3
  387. package/dist-esm/lib/ui/version.mjs.map +1 -1
  388. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +9 -6
  389. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  390. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  391. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  392. package/dist-esm/lib/utils/text/richText.mjs +5 -2
  393. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  394. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  395. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  396. package/package.json +18 -16
  397. package/src/index.ts +5 -2
  398. package/src/lib/Tldraw.test.tsx +46 -1
  399. package/src/lib/canvas/TldrawSelectionForeground.tsx +2 -2
  400. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  401. package/src/lib/defaultExternalContentHandlers.ts +10 -10
  402. package/src/lib/defaultSideEffects.ts +6 -1
  403. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  404. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  405. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +15 -15
  406. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  407. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  408. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  409. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  410. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  411. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  412. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
  413. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  414. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  415. package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
  416. package/src/lib/shapes/draw/getPath.ts +31 -10
  417. package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
  418. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
  419. package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
  420. package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
  421. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  422. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  423. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  424. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
  425. package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
  426. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
  427. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  428. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  429. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
  430. package/src/lib/shapes/shared/PlainTextLabel.tsx +10 -1
  431. package/src/lib/shapes/shared/RichTextLabel.tsx +12 -3
  432. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  433. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  434. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  435. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  436. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  437. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  438. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  439. package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
  440. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  441. package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
  442. package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
  443. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  444. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  445. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  446. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  447. package/src/lib/tools/SelectTool/DragAndDropManager.ts +12 -7
  448. package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
  449. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  450. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
  451. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  452. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  453. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  454. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  455. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -5
  456. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
  457. package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
  458. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
  459. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  460. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
  461. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  462. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  463. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  464. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  465. package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
  466. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  467. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
  468. package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
  469. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  470. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  471. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  472. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  473. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  474. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  475. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  476. package/src/lib/ui/TldrawUi.tsx +5 -2
  477. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  478. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  479. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  480. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  481. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  482. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  483. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  484. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  485. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  486. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  487. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  488. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  489. package/src/lib/ui/components/menu-items.tsx +3 -1
  490. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  491. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +12 -5
  492. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  493. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  494. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +0 -1
  495. package/src/lib/ui/context/actions.tsx +6 -6
  496. package/src/lib/ui/context/components.tsx +1 -2
  497. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  498. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  499. package/src/lib/ui/hooks/useTools.tsx +4 -5
  500. package/src/lib/ui/version.ts +3 -3
  501. package/src/lib/ui.css +27 -23
  502. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  503. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +11 -6
  504. package/src/lib/utils/test-helpers.ts +60 -0
  505. package/src/lib/utils/text/richText.ts +6 -5
  506. package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
  507. package/src/test/Editor.test.tsx +40 -29
  508. package/src/test/EraserTool.test.ts +10 -12
  509. package/src/test/TestEditor.ts +48 -47
  510. package/src/test/TldrawEditor.test.tsx +3 -2
  511. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  512. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  513. package/src/test/arrows-megabus.test.tsx +1 -1
  514. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  515. package/src/test/commands/cameraState.test.ts +299 -0
  516. package/src/test/commands/setCamera.test.ts +13 -11
  517. package/src/test/commands/stackShapes.test.ts +34 -8
  518. package/src/test/commands/zoomToBounds.test.ts +19 -3
  519. package/src/test/commands/zoomToSelection.test.ts +14 -3
  520. package/src/test/custom-clipping.test.ts +16 -9
  521. package/src/test/drawing.test.ts +17 -10
  522. package/src/test/flipShapes.test.ts +33 -0
  523. package/src/test/frames.test.ts +92 -0
  524. package/src/test/groups.test.tsx +1 -1
  525. package/src/test/modifiers.test.ts +6 -6
  526. package/src/test/resizing.test.ts +7 -9
  527. package/src/test/selection-omnibus.test.ts +2 -2
  528. package/src/test/spacebarPanning.test.ts +28 -10
  529. package/src/test/test-jsx.tsx +3 -0
  530. package/tldraw.css +41 -35
  531. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  532. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  533. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  534. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  535. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  536. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  537. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  538. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  539. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  540. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  541. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  542. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  543. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  544. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  545. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
  546. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  547. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  548. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -17,7 +17,7 @@ class Brushing extends StateNode {
17
17
  // cleanup function for the viewport reactor
18
18
  onEnter(info) {
19
19
  const { editor } = this;
20
- const { altKey } = editor.inputs;
20
+ const altKey = editor.inputs.getAltKey();
21
21
  this.isWrapMode = editor.user.getIsWrapMode();
22
22
  this.viewportDidChange = false;
23
23
  let isInitialCheck = true;
@@ -64,7 +64,7 @@ class Brushing extends StateNode {
64
64
  this.parent.transition("idle", info);
65
65
  }
66
66
  onKeyDown(info) {
67
- if (this.editor.inputs.altKey) {
67
+ if (this.editor.inputs.getAltKey()) {
68
68
  this.parent.transition("scribble_brushing", info);
69
69
  } else {
70
70
  this.hitTestShapes();
@@ -79,9 +79,10 @@ class Brushing extends StateNode {
79
79
  }
80
80
  hitTestShapes() {
81
81
  const { editor, excludedShapeIds, isWrapMode } = this;
82
- const {
83
- inputs: { originPagePoint, currentPagePoint, shiftKey, ctrlKey }
84
- } = editor;
82
+ const originPagePoint = editor.inputs.getOriginPagePoint();
83
+ const currentPagePoint = editor.inputs.getCurrentPagePoint();
84
+ const shiftKey = editor.inputs.getShiftKey();
85
+ const ctrlKey = editor.inputs.getCtrlKey();
85
86
  const results = new Set(shiftKey ? this.initialSelectedShapeIds : []);
86
87
  const isWrapping = isWrapMode ? !ctrlKey : ctrlKey;
87
88
  const brush = Box.FromPoints([originPagePoint, currentPagePoint]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Brushing.ts"],
4
- "sourcesContent": ["import {\n\tBox,\n\tMat,\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPageId,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLShapeId,\n\tTLTickEventInfo,\n\tVec,\n\tpointInPolygon,\n\tpolygonsIntersect,\n\treact,\n} from '@tldraw/editor'\n\nexport class Brushing extends StateNode {\n\tstatic override id = 'brushing'\n\n\tinfo = {} as TLPointerEventInfo & { target: 'canvas' }\n\n\tinitialSelectedShapeIds: TLShapeId[] = []\n\texcludedShapeIds = new Set<TLShapeId>()\n\tisWrapMode = false\n\n\tviewportDidChange = false\n\tcleanupViewportChangeReactor() {\n\t\tvoid null\n\t} // cleanup function for the viewport reactor\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst { editor } = this\n\t\tconst { altKey } = editor.inputs\n\n\t\tthis.isWrapMode = editor.user.getIsWrapMode()\n\n\t\tthis.viewportDidChange = false\n\n\t\tlet isInitialCheck = true\n\n\t\tthis.cleanupViewportChangeReactor = react('viewport change while brushing', () => {\n\t\t\teditor.getViewportPageBounds() // capture the viewport change\n\t\t\tif (!isInitialCheck && !this.viewportDidChange) {\n\t\t\t\tthis.viewportDidChange = true\n\t\t\t}\n\t\t})\n\n\t\tif (altKey) {\n\t\t\tthis.parent.transition('scribble_brushing', info)\n\t\t\treturn\n\t\t}\n\n\t\tthis.excludedShapeIds = new Set(\n\t\t\teditor\n\t\t\t\t.getCurrentPageShapes()\n\t\t\t\t.filter(\n\t\t\t\t\t(shape) => editor.isShapeOfType(shape, 'group') || editor.isShapeOrAncestorLocked(shape)\n\t\t\t\t)\n\t\t\t\t.map((shape) => shape.id)\n\t\t)\n\n\t\tthis.info = info\n\t\tthis.initialSelectedShapeIds = editor.getSelectedShapeIds().slice()\n\t\tthis.hitTestShapes()\n\t\tisInitialCheck = false\n\t}\n\n\toverride onExit() {\n\t\tthis.initialSelectedShapeIds = []\n\t\tthis.editor.updateInstanceState({ brush: null })\n\n\t\tthis.cleanupViewportChangeReactor()\n\t}\n\n\toverride onTick({ elapsed }: TLTickEventInfo) {\n\t\tconst { editor } = this\n\t\teditor.edgeScrollManager.updateEdgeScrolling(elapsed)\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.hitTestShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel(info: TLCancelEventInfo) {\n\t\tthis.editor.setSelectedShapes(this.initialSelectedShapeIds)\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (this.editor.inputs.altKey) {\n\t\t\tthis.parent.transition('scribble_brushing', info)\n\t\t} else {\n\t\t\tthis.hitTestShapes()\n\t\t}\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.hitTestShapes()\n\t}\n\n\tprivate complete() {\n\t\tthis.hitTestShapes()\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate hitTestShapes() {\n\t\tconst { editor, excludedShapeIds, isWrapMode } = this\n\t\tconst {\n\t\t\tinputs: { originPagePoint, currentPagePoint, shiftKey, ctrlKey },\n\t\t} = editor\n\n\t\t// We'll be collecting shape ids of selected shapes; if we're holding shift key, we start from our initial shapes\n\t\tconst results = new Set(shiftKey ? this.initialSelectedShapeIds : [])\n\n\t\t// In wrap mode, we need to completely enclose a shape to select it\n\t\tconst isWrapping = isWrapMode ? !ctrlKey : ctrlKey\n\n\t\t// Set the brush to contain the current and origin points\n\t\tconst brush = Box.FromPoints([originPagePoint, currentPagePoint])\n\n\t\t// We'll be testing the corners of the brush against the shapes\n\t\tconst { corners } = brush\n\n\t\tlet A: Vec,\n\t\t\tB: Vec,\n\t\t\tshape: TLShape,\n\t\t\tpageBounds: Box | undefined,\n\t\t\tpageTransform: Mat | undefined,\n\t\t\tlocalCorners: Vec[]\n\n\t\t// Some notes on optimization. We could easily cache all of the shape positions at\n\t\t// the start of the interaction and then do very fast checks against them, but that\n\t\t// would mean changes introduced by other collaborators wouldn't be reflected\u2014a user\n\t\t// could select a shape by selecting where it _used_ to be.\n\n\t\t// We still want to avoid hit tests as much as possible, however, so we test only the\n\t\t// shapes that are on screen UNLESS: the user has scrolled their viewpor; or the user\n\t\t// is dragging outside of the screen (e.g. in a window). In those cases, we need to\n\t\t// test all shapes.\n\n\t\t// On a page with ~5000 shapes, on-screen hit tests are about 2x faster than\n\t\t// testing all shapes.\n\n\t\tconst brushBoxIsInsideViewport = editor.getViewportPageBounds().contains(brush)\n\t\tconst shapesToHitTest =\n\t\t\tbrushBoxIsInsideViewport && !this.viewportDidChange\n\t\t\t\t? editor.getCurrentPageRenderingShapesSorted()\n\t\t\t\t: editor.getCurrentPageShapesSorted()\n\n\t\tconst currentPageId = editor.getCurrentPageId()\n\n\t\ttestAllShapes: for (let i = 0, n = shapesToHitTest.length; i < n; i++) {\n\t\t\tshape = shapesToHitTest[i]\n\t\t\tif (excludedShapeIds.has(shape.id) || results.has(shape.id)) continue testAllShapes\n\n\t\t\tpageBounds = editor.getShapePageBounds(shape)\n\t\t\tif (!pageBounds) continue testAllShapes\n\n\t\t\t// If the brush fully wraps a shape, it's almost certainly a hit\n\t\t\tif (brush.contains(pageBounds)) {\n\t\t\t\tthis.handleHit(shape, currentPagePoint, currentPageId, results, corners)\n\t\t\t\tcontinue testAllShapes\n\t\t\t}\n\n\t\t\t// If we're in wrap mode and the brush did not fully encloses the shape, it's a miss\n\t\t\t// We also skip frames unless we've completely selected the frame.\n\t\t\tif (isWrapping || editor.isShapeOfType(shape, 'frame')) {\n\t\t\t\tcontinue testAllShapes\n\t\t\t}\n\n\t\t\t// If the brush collides the page bounds, then do hit tests against\n\t\t\t// each of the brush's four sides.\n\t\t\tif (brush.collides(pageBounds)) {\n\t\t\t\t// Shapes expect to hit test line segments in their own coordinate system,\n\t\t\t\t// so we first need to get the brush corners in the shape's local space.\n\t\t\t\tpageTransform = editor.getShapePageTransform(shape)\n\t\t\t\tif (!pageTransform) continue testAllShapes\n\t\t\t\tlocalCorners = pageTransform.clone().invert().applyToPoints(corners)\n\t\t\t\t// See if any of the edges intersect the shape's geometry\n\t\t\t\tconst geometry = editor.getShapeGeometry(shape)\n\t\t\t\thitTestBrushEdges: for (let i = 0; i < 4; i++) {\n\t\t\t\t\tA = localCorners[i]\n\t\t\t\t\tB = localCorners[(i + 1) % 4]\n\t\t\t\t\tif (geometry.hitTestLineSegment(A, B, 0)) {\n\t\t\t\t\t\tthis.handleHit(shape, currentPagePoint, currentPageId, results, corners)\n\t\t\t\t\t\tbreak hitTestBrushEdges\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst currentBrush = editor.getInstanceState().brush\n\t\tif (!currentBrush || !brush.equals(currentBrush)) {\n\t\t\teditor.updateInstanceState({ brush: { ...brush.toJson() } })\n\t\t}\n\n\t\tconst current = editor.getSelectedShapeIds()\n\t\tif (current.length !== results.size || current.some((id) => !results.has(id))) {\n\t\t\teditor.setSelectedShapes(Array.from(results))\n\t\t}\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.editor.updateInstanceState({ brush: null })\n\t}\n\n\tprivate handleHit(\n\t\tshape: TLShape,\n\t\tcurrentPagePoint: Vec,\n\t\tcurrentPageId: TLPageId,\n\t\tresults: Set<TLShapeId>,\n\t\tcorners: Vec[]\n\t) {\n\t\tif (shape.parentId === currentPageId) {\n\t\t\tresults.add(shape.id)\n\t\t\treturn\n\t\t}\n\n\t\t// Find the outermost selectable shape, check to see if it has a\n\t\t// page mask; and if so, check to see if the brush intersects it\n\t\tconst selectedShape = this.editor.getOutermostSelectableShape(shape)\n\t\tconst pageMask = this.editor.getShapeMask(selectedShape.id)\n\t\tif (\n\t\t\tpageMask &&\n\t\t\t!polygonsIntersect(pageMask, corners) &&\n\t\t\t!pointInPolygon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,OAAO,CAAC;AAAA,IAC7C;AAAA,EACD;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,oBAAoB,EAAE,OAAO,KAAK,CAAC;AAAA,EAChD;AAAA,EAEQ,UACP,OACA,kBACA,eACA,SACA,SACC;AACD,QAAI,MAAM,aAAa,eAAe;AACrC,cAAQ,IAAI,MAAM,EAAE;AACpB;AAAA,IACD;AAIA,UAAM,gBAAgB,KAAK,OAAO,4BAA4B,KAAK;AACnE,UAAM,WAAW,KAAK,OAAO,aAAa,cAAc,EAAE;AAC1D,QACC,YACA,CAAC,kBAAkB,UAAU,OAAO,KACpC,CAAC,eAAe,kBAAkB,QAAQ,GACzC;AACD;AAAA,IACD;AACA,YAAQ,IAAI,cAAc,EAAE;AAAA,EAC7B;AACD;",
4
+ "sourcesContent": ["import {\n\tBox,\n\tMat,\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPageId,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLShapeId,\n\tTLTickEventInfo,\n\tVec,\n\tpointInPolygon,\n\tpolygonsIntersect,\n\treact,\n} from '@tldraw/editor'\n\nexport class Brushing extends StateNode {\n\tstatic override id = 'brushing'\n\n\tinfo = {} as TLPointerEventInfo & { target: 'canvas' }\n\n\tinitialSelectedShapeIds: TLShapeId[] = []\n\texcludedShapeIds = new Set<TLShapeId>()\n\tisWrapMode = false\n\n\tviewportDidChange = false\n\tcleanupViewportChangeReactor() {\n\t\tvoid null\n\t} // cleanup function for the viewport reactor\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst { editor } = this\n\t\tconst altKey = editor.inputs.getAltKey()\n\n\t\tthis.isWrapMode = editor.user.getIsWrapMode()\n\n\t\tthis.viewportDidChange = false\n\n\t\tlet isInitialCheck = true\n\n\t\tthis.cleanupViewportChangeReactor = react('viewport change while brushing', () => {\n\t\t\teditor.getViewportPageBounds() // capture the viewport change\n\t\t\tif (!isInitialCheck && !this.viewportDidChange) {\n\t\t\t\tthis.viewportDidChange = true\n\t\t\t}\n\t\t})\n\n\t\tif (altKey) {\n\t\t\tthis.parent.transition('scribble_brushing', info)\n\t\t\treturn\n\t\t}\n\n\t\tthis.excludedShapeIds = new Set(\n\t\t\teditor\n\t\t\t\t.getCurrentPageShapes()\n\t\t\t\t.filter(\n\t\t\t\t\t(shape) => editor.isShapeOfType(shape, 'group') || editor.isShapeOrAncestorLocked(shape)\n\t\t\t\t)\n\t\t\t\t.map((shape) => shape.id)\n\t\t)\n\n\t\tthis.info = info\n\t\tthis.initialSelectedShapeIds = editor.getSelectedShapeIds().slice()\n\t\tthis.hitTestShapes()\n\t\tisInitialCheck = false\n\t}\n\n\toverride onExit() {\n\t\tthis.initialSelectedShapeIds = []\n\t\tthis.editor.updateInstanceState({ brush: null })\n\n\t\tthis.cleanupViewportChangeReactor()\n\t}\n\n\toverride onTick({ elapsed }: TLTickEventInfo) {\n\t\tconst { editor } = this\n\t\teditor.edgeScrollManager.updateEdgeScrolling(elapsed)\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.hitTestShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel(info: TLCancelEventInfo) {\n\t\tthis.editor.setSelectedShapes(this.initialSelectedShapeIds)\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (this.editor.inputs.getAltKey()) {\n\t\t\tthis.parent.transition('scribble_brushing', info)\n\t\t} else {\n\t\t\tthis.hitTestShapes()\n\t\t}\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.hitTestShapes()\n\t}\n\n\tprivate complete() {\n\t\tthis.hitTestShapes()\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate hitTestShapes() {\n\t\tconst { editor, excludedShapeIds, isWrapMode } = this\n\t\tconst originPagePoint = editor.inputs.getOriginPagePoint()\n\t\tconst currentPagePoint = editor.inputs.getCurrentPagePoint()\n\t\tconst shiftKey = editor.inputs.getShiftKey()\n\t\tconst ctrlKey = editor.inputs.getCtrlKey()\n\n\t\t// We'll be collecting shape ids of selected shapes; if we're holding shift key, we start from our initial shapes\n\t\tconst results = new Set(shiftKey ? this.initialSelectedShapeIds : [])\n\n\t\t// In wrap mode, we need to completely enclose a shape to select it\n\t\tconst isWrapping = isWrapMode ? !ctrlKey : ctrlKey\n\n\t\t// Set the brush to contain the current and origin points\n\t\tconst brush = Box.FromPoints([originPagePoint, currentPagePoint])\n\n\t\t// We'll be testing the corners of the brush against the shapes\n\t\tconst { corners } = brush\n\n\t\tlet A: Vec,\n\t\t\tB: Vec,\n\t\t\tshape: TLShape,\n\t\t\tpageBounds: Box | undefined,\n\t\t\tpageTransform: Mat | undefined,\n\t\t\tlocalCorners: Vec[]\n\n\t\t// Some notes on optimization. We could easily cache all of the shape positions at\n\t\t// the start of the interaction and then do very fast checks against them, but that\n\t\t// would mean changes introduced by other collaborators wouldn't be reflected\u2014a user\n\t\t// could select a shape by selecting where it _used_ to be.\n\n\t\t// We still want to avoid hit tests as much as possible, however, so we test only the\n\t\t// shapes that are on screen UNLESS: the user has scrolled their viewpor; or the user\n\t\t// is dragging outside of the screen (e.g. in a window). In those cases, we need to\n\t\t// test all shapes.\n\n\t\t// On a page with ~5000 shapes, on-screen hit tests are about 2x faster than\n\t\t// testing all shapes.\n\n\t\tconst brushBoxIsInsideViewport = editor.getViewportPageBounds().contains(brush)\n\t\tconst shapesToHitTest =\n\t\t\tbrushBoxIsInsideViewport && !this.viewportDidChange\n\t\t\t\t? editor.getCurrentPageRenderingShapesSorted()\n\t\t\t\t: editor.getCurrentPageShapesSorted()\n\n\t\tconst currentPageId = editor.getCurrentPageId()\n\n\t\ttestAllShapes: for (let i = 0, n = shapesToHitTest.length; i < n; i++) {\n\t\t\tshape = shapesToHitTest[i]\n\t\t\tif (excludedShapeIds.has(shape.id) || results.has(shape.id)) continue testAllShapes\n\n\t\t\tpageBounds = editor.getShapePageBounds(shape)\n\t\t\tif (!pageBounds) continue testAllShapes\n\n\t\t\t// If the brush fully wraps a shape, it's almost certainly a hit\n\t\t\tif (brush.contains(pageBounds)) {\n\t\t\t\tthis.handleHit(shape, currentPagePoint, currentPageId, results, corners)\n\t\t\t\tcontinue testAllShapes\n\t\t\t}\n\n\t\t\t// If we're in wrap mode and the brush did not fully encloses the shape, it's a miss\n\t\t\t// We also skip frames unless we've completely selected the frame.\n\t\t\tif (isWrapping || editor.isShapeOfType(shape, 'frame')) {\n\t\t\t\tcontinue testAllShapes\n\t\t\t}\n\n\t\t\t// If the brush collides the page bounds, then do hit tests against\n\t\t\t// each of the brush's four sides.\n\t\t\tif (brush.collides(pageBounds)) {\n\t\t\t\t// Shapes expect to hit test line segments in their own coordinate system,\n\t\t\t\t// so we first need to get the brush corners in the shape's local space.\n\t\t\t\tpageTransform = editor.getShapePageTransform(shape)\n\t\t\t\tif (!pageTransform) continue testAllShapes\n\t\t\t\tlocalCorners = pageTransform.clone().invert().applyToPoints(corners)\n\t\t\t\t// See if any of the edges intersect the shape's geometry\n\t\t\t\tconst geometry = editor.getShapeGeometry(shape)\n\t\t\t\thitTestBrushEdges: for (let i = 0; i < 4; i++) {\n\t\t\t\t\tA = localCorners[i]\n\t\t\t\t\tB = localCorners[(i + 1) % 4]\n\t\t\t\t\tif (geometry.hitTestLineSegment(A, B, 0)) {\n\t\t\t\t\t\tthis.handleHit(shape, currentPagePoint, currentPageId, results, corners)\n\t\t\t\t\t\tbreak hitTestBrushEdges\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst currentBrush = editor.getInstanceState().brush\n\t\tif (!currentBrush || !brush.equals(currentBrush)) {\n\t\t\teditor.updateInstanceState({ brush: { ...brush.toJson() } })\n\t\t}\n\n\t\tconst current = editor.getSelectedShapeIds()\n\t\tif (current.length !== results.size || current.some((id) => !results.has(id))) {\n\t\t\teditor.setSelectedShapes(Array.from(results))\n\t\t}\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.editor.updateInstanceState({ brush: null })\n\t}\n\n\tprivate handleHit(\n\t\tshape: TLShape,\n\t\tcurrentPagePoint: Vec,\n\t\tcurrentPageId: TLPageId,\n\t\tresults: Set<TLShapeId>,\n\t\tcorners: Vec[]\n\t) {\n\t\tif (shape.parentId === currentPageId) {\n\t\t\tresults.add(shape.id)\n\t\t\treturn\n\t\t}\n\n\t\t// Find the outermost selectable shape, check to see if it has a\n\t\t// page mask; and if so, check to see if the brush intersects it\n\t\tconst selectedShape = this.editor.getOutermostSelectableShape(shape)\n\t\tconst pageMask = this.editor.getShapeMask(selectedShape.id)\n\t\tif (\n\t\t\tpageMask &&\n\t\t\t!polygonsIntersect(pageMask, corners) &&\n\t\t\t!pointInPolygon(currentPagePoint, pageMask)\n\t\t) {\n\t\t\treturn\n\t\t}\n\t\tresults.add(selectedShape.id)\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EASA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,iBAAiB,UAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAER,0BAAuC,CAAC;AAAA,EACxC,mBAAmB,oBAAI,IAAe;AAAA,EACtC,aAAa;AAAA,EAEb,oBAAoB;AAAA,EACpB,+BAA+B;AAAA,EAE/B;AAAA;AAAA,EAES,QAAQ,MAAiD;AACjE,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,SAAS,OAAO,OAAO,UAAU;AAEvC,SAAK,aAAa,OAAO,KAAK,cAAc;AAE5C,SAAK,oBAAoB;AAEzB,QAAI,iBAAiB;AAErB,SAAK,+BAA+B,MAAM,kCAAkC,MAAM;AACjF,aAAO,sBAAsB;AAC7B,UAAI,CAAC,kBAAkB,CAAC,KAAK,mBAAmB;AAC/C,aAAK,oBAAoB;AAAA,MAC1B;AAAA,IACD,CAAC;AAED,QAAI,QAAQ;AAC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9C,cAAI,aAAaA,EAAC;AAClB,cAAI,cAAcA,KAAI,KAAK,CAAC;AAC5B,cAAI,SAAS,mBAAmB,GAAG,GAAG,CAAC,GAAG;AACzC,iBAAK,UAAU,OAAO,kBAAkB,eAAe,SAAS,OAAO;AACvE,kBAAM;AAAA,UACP;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,eAAe,OAAO,iBAAiB,EAAE;AAC/C,QAAI,CAAC,gBAAgB,CAAC,MAAM,OAAO,YAAY,GAAG;AACjD,aAAO,oBAAoB,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,EAAE,EAAE,CAAC;AAAA,IAC5D;AAEA,UAAM,UAAU,OAAO,oBAAoB;AAC3C,QAAI,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,KAAK,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,GAAG;AAC9E,aAAO,kBAAkB,MAAM,KAAK,OAAO,CAAC;AAAA,IAC7C;AAAA,EACD;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,oBAAoB,EAAE,OAAO,KAAK,CAAC;AAAA,EAChD;AAAA,EAEQ,UACP,OACA,kBACA,eACA,SACA,SACC;AACD,QAAI,MAAM,aAAa,eAAe;AACrC,cAAQ,IAAI,MAAM,EAAE;AACpB;AAAA,IACD;AAIA,UAAM,gBAAgB,KAAK,OAAO,4BAA4B,KAAK;AACnE,UAAM,WAAW,KAAK,OAAO,aAAa,cAAc,EAAE;AAC1D,QACC,YACA,CAAC,kBAAkB,UAAU,OAAO,KACpC,CAAC,eAAe,kBAAkB,QAAQ,GACzC;AACD;AAAA,IACD;AACA,YAAQ,IAAI,cAAc,EAAE;AAAA,EAC7B;AACD;",
6
6
  "names": ["i"]
7
7
  }
@@ -51,9 +51,9 @@ class Cropping extends StateNode {
51
51
  if (!shape) return;
52
52
  const util = this.editor.getShapeUtil(shape.type);
53
53
  if (!util) return;
54
- const { shiftKey } = this.editor.inputs;
55
- const currentPagePoint = this.editor.inputs.currentPagePoint.clone().sub(cursorHandleOffset);
56
- const originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset);
54
+ const shiftKey = this.editor.inputs.getShiftKey();
55
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint().clone().sub(cursorHandleOffset);
56
+ const originPagePoint = this.editor.inputs.getOriginPagePoint().clone().sub(cursorHandleOffset);
57
57
  const change = currentPagePoint.clone().sub(originPagePoint).rot(-shape.rotation);
58
58
  const crop = shape.props.crop ?? getDefaultCrop();
59
59
  const uncroppedSize = getUncroppedSize(shape.props, crop);
@@ -107,9 +107,7 @@ class Cropping extends StateNode {
107
107
  }
108
108
  createSnapshot() {
109
109
  const selectionRotation = this.editor.getSelectionRotation();
110
- const {
111
- inputs: { originPagePoint }
112
- } = this.editor;
110
+ const originPagePoint = this.editor.inputs.getOriginPagePoint();
113
111
  const shape = this.editor.getOnlySelectedShape();
114
112
  const selectionBounds = this.editor.getSelectionRotatedPageBounds();
115
113
  const dragHandlePoint = Vec.RotWith(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts"],
4
- "sourcesContent": ["import {\n\tSelectionHandle,\n\tShapeWithCrop,\n\tStateNode,\n\tTLPointerEventInfo,\n\tVec,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\nimport { getCropBox, getDefaultCrop, getUncroppedSize } from '../../../../../shapes/shared/crop'\nimport { CursorTypeMap } from '../../PointingResizeHandle'\n\ntype Snapshot = ReturnType<Cropping['createSnapshot']>\n\nexport class Cropping extends StateNode {\n\tstatic override id = 'cropping'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'selection'\n\t\thandle: SelectionHandle\n\t\tonInteractionEnd?: string | (() => void)\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'selection'\n\t\t\thandle: SelectionHandle\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('cropping')\n\t\tthis.snapshot = this.createSnapshot()\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\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}\n\n\tprivate updateCursor() {\n\t\tconst selectedShape = this.editor.getSelectedShapes()[0]\n\t\tif (!selectedShape) return\n\n\t\tconst cursorType = CursorTypeMap[this.info.handle!]\n\t\tthis.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() })\n\t}\n\n\tprivate updateShapes() {\n\t\tconst { shape, cursorHandleOffset } = this.snapshot\n\n\t\tif (!shape) return\n\t\tconst util = this.editor.getShapeUtil<ShapeWithCrop>(shape.type)\n\t\tif (!util) return\n\n\t\tconst { shiftKey } = this.editor.inputs\n\t\tconst currentPagePoint = this.editor.inputs.currentPagePoint.clone().sub(cursorHandleOffset)\n\t\tconst originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset)\n\t\tconst change = currentPagePoint.clone().sub(originPagePoint).rot(-shape.rotation)\n\n\t\tconst crop = shape.props.crop ?? getDefaultCrop()\n\t\tconst uncroppedSize = getUncroppedSize(shape.props, crop)\n\n\t\tconst cropFn = util.onCrop?.bind(util) ?? getCropBox\n\t\tconst partial = cropFn(shape, {\n\t\t\thandle: this.info.handle,\n\t\t\tchange,\n\t\t\tcrop,\n\t\t\tuncroppedSize,\n\t\t\tinitialShape: this.snapshot.shape,\n\t\t\taspectRatioLocked: shiftKey,\n\t\t})\n\t\tif (!partial) return\n\n\t\tthis.editor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\t...partial,\n\t\t\t},\n\t\t])\n\t\tthis.updateCursor()\n\t}\n\n\tprivate complete() {\n\t\tthis.updateShapes()\n\t\tkickoutOccludedShapes(this.editor, [this.snapshot.shape.id])\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.setCroppingShape(null)\n\t\t\tthis.editor.setCurrentTool('select.idle')\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.setCroppingShape(null)\n\t\t\tthis.editor.setCurrentTool('select.idle')\n\t\t}\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst selectionRotation = this.editor.getSelectionRotation()\n\t\tconst {\n\t\t\tinputs: { originPagePoint },\n\t\t} = this.editor\n\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()!\n\n\t\tconst dragHandlePoint = Vec.RotWith(\n\t\t\tselectionBounds.getHandlePoint(this.info.handle!),\n\t\t\tselectionBounds.point,\n\t\t\tselectionRotation\n\t\t)\n\n\t\tconst curs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AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,KAAK,MAAM;AAClC,UAAM,EAAE,iBAAiB,IAAI,KAAK;AAClC,QAAI,kBAAkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,KAAK,IAAI;AAAA,MACvD,OAAO;AACN,yBAAiB;AAAA,MAClB;AAAA,IACD,OAAO;AACN,WAAK,OAAO,iBAAiB,IAAI;AACjC,WAAK,OAAO,eAAe,aAAa;AAAA,IACzC;AAAA,EACD;AAAA,EAEQ,iBAAiB;AACxB,UAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAC3D,UAAM;AAAA,MACL,QAAQ,EAAE,gBAAgB;AAAA,IAC3B,IAAI,KAAK;AAET,UAAM,QAAQ,KAAK,OAAO,qBAAqB;AAE/C,UAAM,kBAAkB,KAAK,OAAO,8BAA8B;AAElE,UAAM,kBAAkB,IAAI;AAAA,MAC3B,gBAAgB,eAAe,KAAK,KAAK,MAAO;AAAA,MAChD,gBAAgB;AAAA,MAChB;AAAA,IACD;AAEA,UAAM,qBAAqB,IAAI,IAAI,iBAAiB,eAAe;AAEnE,WAAO;AAAA,MACN;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import {\n\tSelectionHandle,\n\tShapeWithCrop,\n\tStateNode,\n\tTLPointerEventInfo,\n\tVec,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\nimport { getCropBox, getDefaultCrop, getUncroppedSize } from '../../../../../shapes/shared/crop'\nimport { CursorTypeMap } from '../../PointingResizeHandle'\n\ntype Snapshot = ReturnType<Cropping['createSnapshot']>\n\nexport class Cropping extends StateNode {\n\tstatic override id = 'cropping'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'selection'\n\t\thandle: SelectionHandle\n\t\tonInteractionEnd?: string | (() => void)\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'selection'\n\t\t\thandle: SelectionHandle\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('cropping')\n\t\tthis.snapshot = this.createSnapshot()\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\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}\n\n\tprivate updateCursor() {\n\t\tconst selectedShape = this.editor.getSelectedShapes()[0]\n\t\tif (!selectedShape) return\n\n\t\tconst cursorType = CursorTypeMap[this.info.handle!]\n\t\tthis.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() })\n\t}\n\n\tprivate updateShapes() {\n\t\tconst { shape, cursorHandleOffset } = this.snapshot\n\n\t\tif (!shape) return\n\t\tconst util = this.editor.getShapeUtil<ShapeWithCrop>(shape.type)\n\t\tif (!util) return\n\n\t\tconst shiftKey = this.editor.inputs.getShiftKey()\n\t\tconst currentPagePoint = this.editor.inputs\n\t\t\t.getCurrentPagePoint()\n\t\t\t.clone()\n\t\t\t.sub(cursorHandleOffset)\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint().clone().sub(cursorHandleOffset)\n\t\tconst change = currentPagePoint.clone().sub(originPagePoint).rot(-shape.rotation)\n\n\t\tconst crop = shape.props.crop ?? getDefaultCrop()\n\t\tconst uncroppedSize = getUncroppedSize(shape.props, crop)\n\n\t\tconst cropFn = util.onCrop?.bind(util) ?? getCropBox\n\t\tconst partial = cropFn(shape, {\n\t\t\thandle: this.info.handle,\n\t\t\tchange,\n\t\t\tcrop,\n\t\t\tuncroppedSize,\n\t\t\tinitialShape: this.snapshot.shape,\n\t\t\taspectRatioLocked: shiftKey,\n\t\t})\n\t\tif (!partial) return\n\n\t\tthis.editor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\t...partial,\n\t\t\t},\n\t\t])\n\t\tthis.updateCursor()\n\t}\n\n\tprivate complete() {\n\t\tthis.updateShapes()\n\t\tkickoutOccludedShapes(this.editor, [this.snapshot.shape.id])\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.setCroppingShape(null)\n\t\t\tthis.editor.setCurrentTool('select.idle')\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.setCroppingShape(null)\n\t\t\tthis.editor.setCurrentTool('select.idle')\n\t\t}\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst selectionRotation = this.editor.getSelectionRotation()\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()!\n\n\t\tconst dragHandlePoint = Vec.RotWith(\n\t\t\tselectionBounds.getHandlePoint(this.info.handle!),\n\t\t\tselectionBounds.point,\n\t\t\tselectionRotation\n\t\t)\n\n\t\tconst cursorHandleOffset = Vec.Sub(originPagePoint, dragHandlePoint)\n\n\t\treturn {\n\t\t\tshape,\n\t\t\tcursorHandleOffset,\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAGC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AACP,SAAS,YAAY,gBAAgB,wBAAwB;AAC7D,SAAS,qBAAqB;AAIvB,MAAM,iBAAiB,UAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAMR,SAAS;AAAA,EAED,WAAW,CAAC;AAAA,EAEX,QACR,MAKC;AACD,SAAK,OAAO;AACZ,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AACA,SAAK,SAAS,KAAK,OAAO,yBAAyB,UAAU;AAC7D,SAAK,WAAW,KAAK,eAAe;AACpC,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,gBAAgB;AACxB,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,YAAY;AACpB,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,UAAU;AAClB,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,qBAAqB,MAAS;AAAA,EAC3C;AAAA,EAEQ,eAAe;AACtB,UAAM,gBAAgB,KAAK,OAAO,kBAAkB,EAAE,CAAC;AACvD,QAAI,CAAC,cAAe;AAEpB,UAAM,aAAa,cAAc,KAAK,KAAK,MAAO;AAClD,SAAK,OAAO,UAAU,EAAE,MAAM,YAAY,UAAU,KAAK,OAAO,qBAAqB,EAAE,CAAC;AAAA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,OAAO;AACN,WAAK,OAAO,iBAAiB,IAAI;AACjC,WAAK,OAAO,eAAe,aAAa;AAAA,IACzC;AAAA,EACD;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,KAAK,MAAM;AAClC,UAAM,EAAE,iBAAiB,IAAI,KAAK;AAClC,QAAI,kBAAkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,KAAK,IAAI;AAAA,MACvD,OAAO;AACN,yBAAiB;AAAA,MAClB;AAAA,IACD,OAAO;AACN,WAAK,OAAO,iBAAiB,IAAI;AACjC,WAAK,OAAO,eAAe,aAAa;AAAA,IACzC;AAAA,EACD;AAAA,EAEQ,iBAAiB;AACxB,UAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAC3D,UAAM,kBAAkB,KAAK,OAAO,OAAO,mBAAmB;AAE9D,UAAM,QAAQ,KAAK,OAAO,qBAAqB;AAE/C,UAAM,kBAAkB,KAAK,OAAO,8BAA8B;AAElE,UAAM,kBAAkB,IAAI;AAAA,MAC3B,gBAAgB,eAAe,KAAK,KAAK,MAAO;AAAA,MAChD,gBAAgB;AAAA,MAChB;AAAA,IACD;AAEA,UAAM,qBAAqB,IAAI,IAAI,iBAAiB,eAAe;AAEnE,WAAO;AAAA,MACN;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -93,7 +93,7 @@ class Idle extends StateNode {
93
93
  }
94
94
  }
95
95
  onDoubleClick(info) {
96
- if (this.editor.inputs.shiftKey || info.phase !== "up") return;
96
+ if (this.editor.inputs.getShiftKey() || info.phase !== "up") return;
97
97
  const croppingShapeId = this.editor.getCroppingShapeId();
98
98
  if (!croppingShapeId) return;
99
99
  const shape = this.editor.getShape(croppingShapeId);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts"],
4
- "sourcesContent": ["import {\n\tShapeWithCrop,\n\tStateNode,\n\tTLClickEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tVec,\n} from '@tldraw/editor'\nimport { getHitShapeOnCanvasPointerDown } from '../../../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\toverride onEnter() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\n\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\tif (onlySelectedShape) {\n\t\t\tthis.editor.setCroppingShape(onlySelectedShape.id)\n\t\t}\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onCancel() {\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle', {})\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tif (info.accelKey) {\n\t\t\tthis.cancel()\n\t\t\t// feed the event back into the statechart\n\t\t\tthis.editor.root.handleEvent(info)\n\t\t\treturn\n\t\t}\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !this.editor.isShapeOfType(hitShape, 'group')) {\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\tthis.cancel()\n\t\t\t\t// feed the event back into the statechart\n\t\t\t\tthis.editor.root.handleEvent(info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tif (info.shape.id === this.editor.getCroppingShapeId()) {\n\t\t\t\t\tthis.editor.setCurrentTool('select.crop.pointing_crop', info)\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tif (this.editor.getShapeUtil(info.shape)?.canCrop(info.shape)) {\n\t\t\t\t\t\tthis.editor.setCroppingShape(info.shape.id)\n\t\t\t\t\t\tthis.editor.setSelectedShapes([info.shape.id])\n\t\t\t\t\t\tthis.editor.setCurrentTool('select.crop.pointing_crop', info)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.cancel()\n\t\t\t\t\t\t// feed the event back into the statechart\n\t\t\t\t\t\tthis.editor.root.handleEvent(info)\n\t\t\t\t\t}\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\tthis.editor.setCurrentTool('select.pointing_rotate_handle', {\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\tonInteractionEnd: 'select.crop.idle',\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\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\tthis.editor.setCurrentTool('select.crop.pointing_crop_handle', {\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\tonInteractionEnd: 'select.crop.idle',\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\tthis.cancel()\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\t// Without this, the double click's \"settle\" would trigger the reset\n\t\t// after the user double clicked the edge to begin cropping\n\t\tif (this.editor.inputs.shiftKey || info.phase !== 'up') return\n\n\t\tconst croppingShapeId = this.editor.getCroppingShapeId()\n\t\tif (!croppingShapeId) return\n\t\tconst shape = this.editor.getShape(croppingShapeId)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (!util) return\n\n\t\tif (info.target === 'selection') {\n\t\t\tutil.onDoubleClickEdge?.(shape, info)\n\t\t\treturn\n\t\t}\n\n\t\t// If the user double clicks the canvas, we want to cancel cropping,\n\t\t// especially if it's an animated image, we want the image to continue playing.\n\t\tthis.cancel()\n\t\tthis.editor.root.handleEvent(info)\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.nudgeCroppingImage(false)\n\t}\n\n\toverride onKeyRepeat() {\n\t\tthis.nudgeCroppingImage(true)\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.editor.setCroppingShape(null)\n\t\t\t\tthis.editor.setCurrentTool('select.idle', {})\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle', {})\n\t}\n\n\tprivate nudgeCroppingImage(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 (shiftKey) delta.mul(10)\n\n\t\tconst shape = this.editor.getShape(this.editor.getCroppingShapeId()!) as ShapeWithCrop\n\t\tif (!shape) return\n\t\tconst partial = getTranslateCroppedImageChange(this.editor, shape, delta)\n\n\t\tif (partial) {\n\t\t\tif (!ephemeral) {\n\t\t\t\t// We don't want to create new marks if the user\n\t\t\t\t// is just holding down the arrow keys\n\t\t\t\tthis.editor.markHistoryStoppingPoint('translate crop')\n\t\t\t}\n\n\t\t\tthis.editor.updateShapes([partial])\n\t\t}\n\t}\n}\n"],
5
- "mappings": "AAAA;AAAA,EAEC;AAAA,EAIA;AAAA,OACM;AACP,SAAS,sCAAsC;AAC/C,SAAS,sCAAsC;AAExC,MAAM,aAAa,UAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAEZ,UAAU;AAClB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAEtD,UAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAE3D,QAAI,mBAAmB;AACtB,WAAK,OAAO,iBAAiB,kBAAkB,EAAE;AAAA,IAClD;AAAA,EACD;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO,iBAAiB,IAAI;AACjC,SAAK,OAAO,eAAe,eAAe,CAAC,CAAC;AAAA,EAC7C;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,UAAU;AAClB,WAAK,OAAO;AAEZ,WAAK,OAAO,KAAK,YAAY,IAAI;AACjC;AAAA,IACD;AAEA,YAAQ,KAAK,QAAQ;AAAA,MACpB,KAAK,UAAU;AACd,cAAM,WAAW,+BAA+B,KAAK,MAAM;AAC3D,YAAI,YAAY,CAAC,KAAK,OAAO,cAAc,UAAU,OAAO,GAAG;AAC9D,eAAK,cAAc;AAAA,YAClB,GAAG;AAAA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IAAI,IAAI,GAAG,CAAC,CAAC,EAAG;AAEjC,QAAI,SAAU,OAAM,IAAI,EAAE;AAE1B,UAAM,QAAQ,KAAK,OAAO,SAAS,KAAK,OAAO,mBAAmB,CAAE;AACpE,QAAI,CAAC,MAAO;AACZ,UAAM,UAAU,+BAA+B,KAAK,QAAQ,OAAO,KAAK;AAExE,QAAI,SAAS;AACZ,UAAI,CAAC,WAAW;AAGf,aAAK,OAAO,yBAAyB,gBAAgB;AAAA,MACtD;AAEA,WAAK,OAAO,aAAa,CAAC,OAAO,CAAC;AAAA,IACnC;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import {\n\tShapeWithCrop,\n\tStateNode,\n\tTLClickEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tVec,\n} from '@tldraw/editor'\nimport { getHitShapeOnCanvasPointerDown } from '../../../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\toverride onEnter() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\n\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\tif (onlySelectedShape) {\n\t\t\tthis.editor.setCroppingShape(onlySelectedShape.id)\n\t\t}\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onCancel() {\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle', {})\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tif (info.accelKey) {\n\t\t\tthis.cancel()\n\t\t\t// feed the event back into the statechart\n\t\t\tthis.editor.root.handleEvent(info)\n\t\t\treturn\n\t\t}\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !this.editor.isShapeOfType(hitShape, 'group')) {\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\tthis.cancel()\n\t\t\t\t// feed the event back into the statechart\n\t\t\t\tthis.editor.root.handleEvent(info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tif (info.shape.id === this.editor.getCroppingShapeId()) {\n\t\t\t\t\tthis.editor.setCurrentTool('select.crop.pointing_crop', info)\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\tif (this.editor.getShapeUtil(info.shape)?.canCrop(info.shape)) {\n\t\t\t\t\t\tthis.editor.setCroppingShape(info.shape.id)\n\t\t\t\t\t\tthis.editor.setSelectedShapes([info.shape.id])\n\t\t\t\t\t\tthis.editor.setCurrentTool('select.crop.pointing_crop', info)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.cancel()\n\t\t\t\t\t\t// feed the event back into the statechart\n\t\t\t\t\t\tthis.editor.root.handleEvent(info)\n\t\t\t\t\t}\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\tthis.editor.setCurrentTool('select.pointing_rotate_handle', {\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\tonInteractionEnd: 'select.crop.idle',\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\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\tthis.editor.setCurrentTool('select.crop.pointing_crop_handle', {\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\tonInteractionEnd: 'select.crop.idle',\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\tthis.cancel()\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\t// Without this, the double click's \"settle\" would trigger the reset\n\t\t// after the user double clicked the edge to begin cropping\n\t\tif (this.editor.inputs.getShiftKey() || info.phase !== 'up') return\n\n\t\tconst croppingShapeId = this.editor.getCroppingShapeId()\n\t\tif (!croppingShapeId) return\n\t\tconst shape = this.editor.getShape(croppingShapeId)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (!util) return\n\n\t\tif (info.target === 'selection') {\n\t\t\tutil.onDoubleClickEdge?.(shape, info)\n\t\t\treturn\n\t\t}\n\n\t\t// If the user double clicks the canvas, we want to cancel cropping,\n\t\t// especially if it's an animated image, we want the image to continue playing.\n\t\tthis.cancel()\n\t\tthis.editor.root.handleEvent(info)\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.nudgeCroppingImage(false)\n\t}\n\n\toverride onKeyRepeat() {\n\t\tthis.nudgeCroppingImage(true)\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.editor.setCroppingShape(null)\n\t\t\t\tthis.editor.setCurrentTool('select.idle', {})\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle', {})\n\t}\n\n\tprivate nudgeCroppingImage(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 (shiftKey) delta.mul(10)\n\n\t\tconst shape = this.editor.getShape(this.editor.getCroppingShapeId()!) as ShapeWithCrop\n\t\tif (!shape) return\n\t\tconst partial = getTranslateCroppedImageChange(this.editor, shape, delta)\n\n\t\tif (partial) {\n\t\t\tif (!ephemeral) {\n\t\t\t\t// We don't want to create new marks if the user\n\t\t\t\t// is just holding down the arrow keys\n\t\t\t\tthis.editor.markHistoryStoppingPoint('translate crop')\n\t\t\t}\n\n\t\t\tthis.editor.updateShapes([partial])\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAIA;AAAA,OACM;AACP,SAAS,sCAAsC;AAC/C,SAAS,sCAAsC;AAExC,MAAM,aAAa,UAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAEZ,UAAU;AAClB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAEtD,UAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAE3D,QAAI,mBAAmB;AACtB,WAAK,OAAO,iBAAiB,kBAAkB,EAAE;AAAA,IAClD;AAAA,EACD;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,WAAW;A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mB,YAAY,OAAO;AAC7C,UAAM;AAAA,MACL,QAAQ;AAAA,QACP,QAAQ,EAAE,KAAK;AAAA,MAChB;AAAA,IACD,IAAI;AAKJ,UAAM,WAAW,KAAK,IAAI,WAAW;AAErC,UAAM,QAAQ,IAAI,IAAI,GAAG,CAAC;AAE1B,QAAI,KAAK,IAAI,WAAW,EAAG,OAAM,KAAK;AACtC,QAAI,KAAK,IAAI,YAAY,EAAG,OAAM,KAAK;AACvC,QAAI,KAAK,IAAI,SAAS,EAAG,OAAM,KAAK;AACpC,QAAI,KAAK,IAAI,WAAW,EAAG,OAAM,KAAK;AAEtC,QAAI,MAAM,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,EAAG;AAEjC,QAAI,SAAU,OAAM,IAAI,EAAE;AAE1B,UAAM,QAAQ,KAAK,OAAO,SAAS,KAAK,OAAO,mBAAmB,CAAE;AACpE,QAAI,CAAC,MAAO;AACZ,UAAM,UAAU,+BAA+B,KAAK,QAAQ,OAAO,KAAK;AAExE,QAAI,SAAS;AACZ,UAAI,CAAC,WAAW;AAGf,aAAK,OAAO,yBAAyB,gBAAgB;AAAA,MACtD;AAEA,WAAK,OAAO,aAAa,CAAC,OAAO,CAAC;AAAA,IACnC;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -5,7 +5,7 @@ class PointingCrop extends StateNode {
5
5
  this.editor.setCurrentTool("select.crop.idle", {});
6
6
  }
7
7
  onPointerMove(info) {
8
- if (this.editor.inputs.isDragging) {
8
+ if (this.editor.inputs.getIsDragging()) {
9
9
  this.startDragging(info);
10
10
  }
11
11
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\n\nexport class PointingCrop extends StateNode {\n\tstatic override id = 'pointing_crop'\n\n\toverride onCancel() {\n\t\tthis.editor.setCurrentTool('select.crop.idle', {})\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tthis.startDragging(info)\n\t\t}\n\t}\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startDragging(info)\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tthis.editor.setCurrentTool('select.crop.idle', info)\n\t}\n\n\tstartDragging(info: TLPointerEventInfo) {\n\t\tthis.editor.setCurrentTool('select.crop.translating_crop', info)\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAqC;AAEvC,MAAM,qBAAqB,UAAU;AAAA,EAC3C,OAAgB,KAAK;AAAA,EAEZ,WAAW;AACnB,SAAK,OAAO,eAAe,oBAAoB,CAAC,CAAC;AAAA,EAClD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,WAAK,cAAc,IAAI;AAAA,IACxB;AAAA,EACD;AAAA,EACS,YAAY,MAA0B;AAC9C,SAAK,cAAc,IAAI;AAAA,EACxB;AAAA,EAES,YAAY,MAA0B;AAC9C,SAAK,OAAO,eAAe,oBAAoB,IAAI;AAAA,EACpD;AAAA,EAEA,cAAc,MAA0B;AACvC,SAAK,OAAO,eAAe,gCAAgC,IAAI;AAAA,EAChE;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\n\nexport class PointingCrop extends StateNode {\n\tstatic override id = 'pointing_crop'\n\n\toverride onCancel() {\n\t\tthis.editor.setCurrentTool('select.crop.idle', {})\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tthis.startDragging(info)\n\t\t}\n\t}\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startDragging(info)\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tthis.editor.setCurrentTool('select.crop.idle', info)\n\t}\n\n\tstartDragging(info: TLPointerEventInfo) {\n\t\tthis.editor.setCurrentTool('select.crop.translating_crop', info)\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAqC;AAEvC,MAAM,qBAAqB,UAAU;AAAA,EAC3C,OAAgB,KAAK;AAAA,EAEZ,WAAW;AACnB,SAAK,OAAO,eAAe,oBAAoB,CAAC,CAAC;AAAA,EAClD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,WAAK,cAAc,IAAI;AAAA,IACxB;AAAA,EACD;AAAA,EACS,YAAY,MAA0B;AAC9C,SAAK,cAAc,IAAI;AAAA,EACxB;AAAA,EAES,YAAY,MAA0B;AAC9C,SAAK,OAAO,eAAe,oBAAoB,IAAI;AAAA,EACpD;AAAA,EAEA,cAAc,MAA0B;AACvC,SAAK,OAAO,eAAe,gCAAgC,IAAI;AAAA,EAChE;AACD;",
6
6
  "names": []
7
7
  }
@@ -19,7 +19,7 @@ class PointingCropHandle extends StateNode {
19
19
  this.parent.setCurrentToolIdMask(void 0);
20
20
  }
21
21
  onPointerMove() {
22
- if (this.editor.inputs.isDragging) {
22
+ if (this.editor.inputs.getIsDragging()) {
23
23
  this.startCropping();
24
24
  }
25
25
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { CursorTypeMap } from '../../PointingResizeHandle'\n\ntype TLPointingCropHandleInfo = TLPointerEventInfo & {\n\ttarget: 'selection'\n} & {\n\tonInteractionEnd?: string | (() => void)\n}\n\nexport class PointingCropHandle extends StateNode {\n\tstatic override id = 'pointing_crop_handle'\n\n\tprivate info = {} as TLPointingCropHandleInfo\n\n\toverride onEnter(info: TLPointingCropHandleInfo) {\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tconst selectedShape = this.editor.getSelectedShapes()[0]\n\t\tif (!selectedShape) return\n\n\t\tconst cursorType = CursorTypeMap[this.info.handle!]\n\t\tthis.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() })\n\t\tthis.editor.setCroppingShape(selectedShape.id)\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t}\n\n\toverride onPointerMove() {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tthis.startCropping()\n\t\t}\n\t}\n\n\toverride onLongPress() {\n\t\tthis.startCropping()\n\t}\n\n\tprivate startCropping() {\n\t\tif (this.editor.getIsReadonly()) return\n\t\tthis.parent.transition('cropping', {\n\t\t\t...this.info,\n\t\t\tonInteractionEnd: this.info.onInteractionEnd,\n\t\t})\n\t}\n\n\toverride onPointerUp() {\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle')\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\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\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor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;AACjC,SAAK,OAAO,eAAe,aAAa;AAAA,EACzC;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,cAAc;AACtB,SAAK,OAAO;AAAA,EACb;AAAA,EAEQ,SAAS;AAChB,UAAM,EAAE,iBAAiB,IAAI,KAAK;AAClC,QAAI,kBAAkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,KAAK,IAAI;AAAA,MACvD,OAAO;AACN,yBAAiB;AAAA,MAClB;AACA;AAAA,IACD;AACA,SAAK,OAAO,iBAAiB,IAAI;AACjC,SAAK,OAAO,eAAe,aAAa;AAAA,EACzC;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { CursorTypeMap } from '../../PointingResizeHandle'\n\ntype TLPointingCropHandleInfo = TLPointerEventInfo & {\n\ttarget: 'selection'\n} & {\n\tonInteractionEnd?: string | (() => void)\n}\n\nexport class PointingCropHandle extends StateNode {\n\tstatic override id = 'pointing_crop_handle'\n\n\tprivate info = {} as TLPointingCropHandleInfo\n\n\toverride onEnter(info: TLPointingCropHandleInfo) {\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tconst selectedShape = this.editor.getSelectedShapes()[0]\n\t\tif (!selectedShape) return\n\n\t\tconst cursorType = CursorTypeMap[this.info.handle!]\n\t\tthis.editor.setCursor({ type: cursorType, rotation: this.editor.getSelectionRotation() })\n\t\tthis.editor.setCroppingShape(selectedShape.id)\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t}\n\n\toverride onPointerMove() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tthis.startCropping()\n\t\t}\n\t}\n\n\toverride onLongPress() {\n\t\tthis.startCropping()\n\t}\n\n\tprivate startCropping() {\n\t\tif (this.editor.getIsReadonly()) return\n\t\tthis.parent.transition('cropping', {\n\t\t\t...this.info,\n\t\t\tonInteractionEnd: this.info.onInteractionEnd,\n\t\t})\n\t}\n\n\toverride onPointerUp() {\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle')\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\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\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, this.info)\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.editor.setCroppingShape(null)\n\t\tthis.editor.setCurrentTool('select.idle')\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAqC;AAC9C,SAAS,qBAAqB;AAQvB,MAAM,2BAA2B,UAAU;AAAA,EACjD,OAAgB,KAAK;AAAA,EAEb,OAAO,CAAC;AAAA,EAEP,QAAQ,MAAgC;AAChD,SAAK,OAAO;AACZ,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AACA,UAAM,gBAAgB,KAAK,OAAO,kBAAkB,EAAE,CAAC;AACvD,QAAI,CAAC,cAAe;AAEpB,UAAM,aAAa,cAAc,KAAK,K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AK,OAAO,iBAAiB,IAAI;AACjC,SAAK,OAAO,eAAe,aAAa;AAAA,EACzC;AACD;",
6
6
  "names": []
7
7
  }
@@ -63,7 +63,8 @@ class TranslatingCrop extends StateNode {
63
63
  updateShapes() {
64
64
  const shape = this.snapshot.shape;
65
65
  if (!shape) return;
66
- const { originPagePoint, currentPagePoint } = this.editor.inputs;
66
+ const originPagePoint = this.editor.inputs.getOriginPagePoint();
67
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
67
68
  const delta = currentPagePoint.clone().sub(originPagePoint);
68
69
  const partial = getTranslateCroppedImageChange(this.editor, shape, delta);
69
70
  if (partial) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts"],
4
- "sourcesContent": ["import { ShapeWithCrop, StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\ntype Snapshot = ReturnType<TranslatingCrop['createSnapshot']>\n\nexport class TranslatingCrop extends StateNode {\n\tstatic override id = 'translating_crop'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'shape'\n\t\tisCreating?: boolean\n\t\tonInteractionEnd?: string\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'shape'\n\t\t\tisCreating?: boolean\n\t\t\tonInteractionEnd?: string\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tthis.snapshot = this.createSnapshot()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('translating_crop')\n\t\tthis.editor.setCursor({ type: 'move', rotation: 0 })\n\t\tthis.updateShapes()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.complete()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected complete() {\n\t\tthis.updateShapes()\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\t\treturn { shape }\n\t}\n\n\tprotected updateShapes() {\n\t\tconst shape = this.snapshot.shape as ShapeWithCrop\n\n\t\tif (!shape) return\n\n\t\tconst { originPagePoint, currentPagePoint } = this.editor.inputs\n\t\tconst delta = currentPagePoint.clone().sub(originPagePoint)\n\t\tconst partial = getTranslateCroppedImageChange(this.editor, shape, delta)\n\n\t\tif (partial) {\n\t\t\tthis.editor.updateShapes([partial])\n\t\t}\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAwB,iBAA0D;AAClF,SAAS,sCAAsC;AAIxC,MAAM,wBAAwB,UAAU;AAAA,EAC9C,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAMR,SAAS;AAAA,EAED,WAAW,CAAC;AAAA,EAEX,QACR,MAKC;AACD,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK,eAA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AE,IAAI,eAAe;AAC1D,UAAM,UAAU,+BAA+B,KAAK,QAAQ,OAAO,KAAK;AAExE,QAAI,SAAS;AACZ,WAAK,OAAO,aAAa,CAAC,OAAO,CAAC;AAAA,IACnC;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import { ShapeWithCrop, StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\ntype Snapshot = ReturnType<TranslatingCrop['createSnapshot']>\n\nexport class TranslatingCrop extends StateNode {\n\tstatic override id = 'translating_crop'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'shape'\n\t\tisCreating?: boolean\n\t\tonInteractionEnd?: string\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'shape'\n\t\t\tisCreating?: boolean\n\t\t\tonInteractionEnd?: string\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tthis.snapshot = this.createSnapshot()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('translating_crop')\n\t\tthis.editor.setCursor({ type: 'move', rotation: 0 })\n\t\tthis.updateShapes()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.complete()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected complete() {\n\t\tthis.updateShapes()\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\t\treturn { shape }\n\t}\n\n\tprotected updateShapes() {\n\t\tconst shape = this.snapshot.shape as ShapeWithCrop\n\n\t\tif (!shape) return\n\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\tconst delta = currentPagePoint.clone().sub(originPagePoint)\n\t\tconst partial = getTranslateCroppedImageChange(this.editor, shape, delta)\n\n\t\tif (partial) {\n\t\t\tthis.editor.updateShapes([partial])\n\t\t}\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAwB,iBAA0D;AAClF,SAAS,sCAAsC;AAIxC,MAAM,wBAAwB,UAAU;AAAA,EAC9C,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAMR,SAAS;AAAA,EAED,WAAW,CAAC;AAAA,EAEX,QACR,MAKC;AACD,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK,eAAe;AAEpC,SAAK,SAAS,KAAK,OAAO,yBAAyB,kBAAkB;AACrE,SAAK,OAAO,UAAU,EAAE,MAAM,QAAQ,UAAU,EAAE,CAAC;AACnD,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,gBAAgB;AACxB,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,cAAc;AACtB,S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  }
11
- const flatten = editor.inputs.shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null;
11
+ const flatten = editor.inputs.getShiftKey() ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null;
12
12
  if (flatten === "x") {
13
13
  delta.x = 0;
14
14
  } else if (flatten === "y") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts"],
4
- "sourcesContent": ["import { Editor, ShapeWithCrop, TLShapePartial, Vec, clamp, structuredClone } from '@tldraw/editor'\nimport { getUncroppedSize } from '../../../../../shapes/shared/crop'\n\nexport function getTranslateCroppedImageChange(editor: Editor, shape: ShapeWithCrop, delta: Vec) {\n\tif (!shape) {\n\t\tthrow Error('Needs to translate a cropped shape!')\n\t}\n\n\tconst { crop: oldCrop } = shape.props\n\tif (!oldCrop) {\n\t\t// can't translate a shape that doesn't have an existing crop\n\t\treturn\n\t}\n\n\tconst flatten: 'x' | 'y' | null = editor.inputs.shiftKey\n\t\t? Math.abs(delta.x) < Math.abs(delta.y)\n\t\t\t? 'x'\n\t\t\t: 'y'\n\t\t: null\n\n\tif (flatten === 'x') {\n\t\tdelta.x = 0\n\t} else if (flatten === 'y') {\n\t\tdelta.y = 0\n\t}\n\n\tdelta.rot(-shape.rotation)\n\n\tconst { w, h } = getUncroppedSize(shape.props, oldCrop)\n\tconst xCropSize = oldCrop.bottomRight.x - oldCrop.topLeft.x\n\tconst yCropSize = oldCrop.bottomRight.y - oldCrop.topLeft.y\n\tconst newCrop = structuredClone(oldCrop)\n\n\tconst xMinWithCrop = 1 - xCropSize\n\tconst yMinWithCrop = 1 - yCropSize\n\tnewCrop.topLeft.x = clamp(newCrop.topLeft.x - delta.x / w, 0, xMinWithCrop)\n\tnewCrop.topLeft.y = clamp(newCrop.topLeft.y - delta.y / h, 0, yMinWithCrop)\n\n\tnewCrop.bottomRight.x = newCrop.topLeft.x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M;AAAA,IACV,MAAM,MAAM;AAAA,IACZ,OAAO;AAAA,MACN,MAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO;AACR;",
4
+ "sourcesContent": ["import { Editor, ShapeWithCrop, TLShapePartial, Vec, clamp, structuredClone } from '@tldraw/editor'\nimport { getUncroppedSize } from '../../../../../shapes/shared/crop'\n\nexport function getTranslateCroppedImageChange(editor: Editor, shape: ShapeWithCrop, delta: Vec) {\n\tif (!shape) {\n\t\tthrow Error('Needs to translate a cropped shape!')\n\t}\n\n\tconst { crop: oldCrop } = shape.props\n\tif (!oldCrop) {\n\t\t// can't translate a shape that doesn't have an existing crop\n\t\treturn\n\t}\n\n\tconst flatten: 'x' | 'y' | null = editor.inputs.getShiftKey()\n\t\t? Math.abs(delta.x) < Math.abs(delta.y)\n\t\t\t? 'x'\n\t\t\t: 'y'\n\t\t: null\n\n\tif (flatten === 'x') {\n\t\tdelta.x = 0\n\t} else if (flatten === 'y') {\n\t\tdelta.y = 0\n\t}\n\n\tdelta.rot(-shape.rotation)\n\n\tconst { w, h } = getUncroppedSize(shape.props, oldCrop)\n\tconst xCropSize = oldCrop.bottomRight.x - oldCrop.topLeft.x\n\tconst yCropSize = oldCrop.bottomRight.y - oldCrop.topLeft.y\n\tconst newCrop = structuredClone(oldCrop)\n\n\tconst xMinWithCrop = 1 - xCropSize\n\tconst yMinWithCrop = 1 - yCropSize\n\tnewCrop.topLeft.x = clamp(newCrop.topLeft.x - delta.x / w, 0, xMinWithCrop)\n\tnewCrop.topLeft.y = clamp(newCrop.topLeft.y - delta.y / h, 0, yMinWithCrop)\n\n\tnewCrop.bottomRight.x = newCrop.topLeft.x + xCropSize\n\tnewCrop.bottomRight.y = newCrop.topLeft.y + yCropSize\n\n\tconst partial: TLShapePartial<typeof shape> = {\n\t\tid: shape.id,\n\t\ttype: shape.type,\n\t\tprops: {\n\t\t\tcrop: newCrop,\n\t\t},\n\t}\n\n\treturn partial\n}\n"],
5
+ "mappings": "AAAA,SAAqD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Transform = this.editor.getShapePageTransform(shape);
49
49
  this.initialPageRotation = this.initialPageTransform.rotation();
50
- this.initialPagePoint = this.editor.inputs.originPagePoint.clone();
50
+ this.initialPagePoint = this.editor.inputs.getOriginPagePoint().clone();
51
51
  this.editor.setCursor({ type: isCreating ? "cross" : "grabbing", rotation: 0 });
52
52
  const handles = this.editor.getShapeHandles(shape).sort(sortByIndex);
53
53
  const index = handles.findIndex((h) => h.id === info.handle.id);
@@ -212,10 +212,12 @@ class DraggingHandle extends StateNode {
212
212
  const { editor, shapeId, initialPagePoint } = this;
213
213
  const { initialHandle, initialPageRotation, initialAdjacentHandle } = this;
214
214
  const isSnapMode = this.editor.user.getIsSnapMode();
215
- const {
216
- snaps,
217
- inputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity }
218
- } = editor;
215
+ const { snaps } = editor;
216
+ const currentPagePoint = editor.inputs.getCurrentPagePoint();
217
+ const shiftKey = editor.inputs.getShiftKey();
218
+ const ctrlKey = editor.inputs.getCtrlKey();
219
+ const altKey = editor.inputs.getAltKey();
220
+ const pointerVelocity = editor.inputs.getPointerVelocity();
219
221
  const initial = this.info.shape;
220
222
  const shape = editor.getShape(shapeId);
221
223
  if (!shape) return;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/DraggingHandle.tsx"],
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\twarnOnce,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\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 | (() => void)\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\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\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// First, check if the handle specifies a custom reference handle\n\t\tif (info.handle.snapReferenceHandleId) {\n\t\t\tconst customHandle = handles.find((h) => h.id === info.handle.snapReferenceHandleId)\n\t\t\tif (customHandle) {\n\t\t\t\tthis.initialAdjacentHandle = customHandle\n\t\t\t}\n\t\t}\n\n\t\t// If no custom reference handle, use default behavior\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\t// Start from the handle and work forward\n\t\t\tfor (let i = index + 1; i < handles.length; 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\n\t\t\t// If still no handle, start from the end and work backward\n\t\t\tif (!this.initialAdjacentHandle) {\n\t\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst handle = handles[i]\n\t\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\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(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\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\t\tconst timeoutValue = arrowUtil.options.pointingPreciseTimeout\n\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}, timeoutValue)\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 (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t\t\t// Return to the tool that was active before this one but only if tool lock is turned on!\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t\treturn\n\t\t\t}\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\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\t// Return to the tool that was active before this one, whether tool lock is turned on or not!\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t}\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(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\tlet canSnap = false\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tif (initialHandle.canSnap && initialHandle.snapType) {\n\t\t\twarnOnce(\n\t\t\t\t'canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.'\n\t\t\t)\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\tcanSnap = initialHandle.canSnap || initialHandle.snapType !== undefined\n\t\t}\n\n\t\tif (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 (initialHandle.type === 'vertex' && this.editor.isShapeOfType(shape, 'arrow')) {\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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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\twarnOnce,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\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 | (() => void)\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\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\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.getOriginPagePoint().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// First, check if the handle specifies a custom reference handle\n\t\tif (info.handle.snapReferenceHandleId) {\n\t\t\tconst customHandle = handles.find((h) => h.id === info.handle.snapReferenceHandleId)\n\t\t\tif (customHandle) {\n\t\t\t\tthis.initialAdjacentHandle = customHandle\n\t\t\t}\n\t\t}\n\n\t\t// If no custom reference handle, use default behavior\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\t// Start from the handle and work forward\n\t\t\tfor (let i = index + 1; i < handles.length; 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\n\t\t\t// If still no handle, start from the end and work backward\n\t\t\tif (!this.initialAdjacentHandle) {\n\t\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst handle = handles[i]\n\t\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\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(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\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\t\tconst timeoutValue = arrowUtil.options.pointingPreciseTimeout\n\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}, timeoutValue)\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 (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t\t\t// Return to the tool that was active before this one but only if tool lock is turned on!\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t\treturn\n\t\t\t}\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\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\t// Return to the tool that was active before this one, whether tool lock is turned on or not!\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t}\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 { snaps } = editor\n\t\tconst currentPagePoint = editor.inputs.getCurrentPagePoint()\n\t\tconst shiftKey = editor.inputs.getShiftKey()\n\t\tconst ctrlKey = editor.inputs.getCtrlKey()\n\t\tconst altKey = editor.inputs.getAltKey()\n\t\tconst pointerVelocity = editor.inputs.getPointerVelocity()\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(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\tlet canSnap = false\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tif (initialHandle.canSnap && initialHandle.snapType) {\n\t\t\twarnOnce(\n\t\t\t\t'canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.'\n\t\t\t)\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\tcanSnap = initialHandle.canSnap || initialHandle.snapType !== undefined\n\t\t}\n\n\t\tif (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 (initialHandle.type === 'vertex' && this.editor.isShapeOfType(shape, 'arrow')) {\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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAU1B,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAErB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,E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  }
@@ -8,12 +8,18 @@ import { getHitShapeOnCanvasPointerDown } from "../../selection-logic/getHitShap
8
8
  import { updateHoveredShapeId } from "../../selection-logic/updateHoveredShapeId.mjs";
9
9
  class EditingShape extends StateNode {
10
10
  static id = "editing_shape";
11
- hitShapeForPointerUp = null;
11
+ hitLabelOnShapeForPointerUp = null;
12
12
  info = {};
13
+ didPointerDownOnEditingShape = false;
14
+ isTextInputFocused() {
15
+ const container = this.editor.getContainer();
16
+ return container.contains(document.activeElement) && (document.activeElement?.nodeName === "INPUT" || document.activeElement?.nodeName === "TEXTAREA" || document.activeElement?.isContentEditable);
17
+ }
13
18
  onEnter(info) {
14
19
  const editingShape = this.editor.getEditingShape();
15
20
  if (!editingShape) throw Error("Entered editing state without an editing shape");
16
- this.hitShapeForPointerUp = null;
21
+ this.hitLabelOnShapeForPointerUp = null;
22
+ this.didPointerDownOnEditingShape = false;
17
23
  this.info = info;
18
24
  if (info.isCreatingTextWhileToolLocked) {
19
25
  this.parent.setCurrentToolIdMask("text");
@@ -32,14 +38,26 @@ class EditingShape extends StateNode {
32
38
  }
33
39
  }
34
40
  onPointerMove(info) {
35
- if (this.hitShapeForPointerUp && this.editor.inputs.isDragging) {
41
+ if (this.hitLabelOnShapeForPointerUp && this.editor.inputs.getIsDragging()) {
36
42
  if (this.editor.getIsReadonly()) return;
37
- if (this.hitShapeForPointerUp.isLocked) return;
38
- this.editor.select(this.hitShapeForPointerUp);
43
+ if (this.hitLabelOnShapeForPointerUp.isLocked) return;
44
+ this.editor.select(this.hitLabelOnShapeForPointerUp);
39
45
  this.parent.transition("translating", info);
40
- this.hitShapeForPointerUp = null;
46
+ this.hitLabelOnShapeForPointerUp = null;
41
47
  return;
42
48
  }
49
+ if (this.didPointerDownOnEditingShape && this.editor.inputs.isDragging) {
50
+ if (this.editor.getIsReadonly()) return;
51
+ const editingShape = this.editor.getEditingShape();
52
+ if (!editingShape || editingShape.isLocked) return;
53
+ if (!this.isTextInputFocused()) {
54
+ this.editor.select(editingShape);
55
+ this.parent.transition("translating", info);
56
+ this.didPointerDownOnEditingShape = false;
57
+ return;
58
+ }
59
+ this.didPointerDownOnEditingShape = false;
60
+ }
43
61
  switch (info.target) {
44
62
  case "shape":
45
63
  case "canvas": {
@@ -49,7 +67,8 @@ class EditingShape extends StateNode {
49
67
  }
50
68
  }
51
69
  onPointerDown(info) {
52
- this.hitShapeForPointerUp = null;
70
+ this.hitLabelOnShapeForPointerUp = null;
71
+ this.didPointerDownOnEditingShape = false;
53
72
  switch (info.target) {
54
73
  // N.B. This bit of logic has a bit of history to it.
55
74
  // There was a PR that got rid of this logic: https://github.com/tldraw/tldraw/pull/4237
@@ -85,13 +104,14 @@ class EditingShape extends StateNode {
85
104
  if (textLabel && !isEmptyTextShape) {
86
105
  const pointInShapeSpace = this.editor.getPointInShapeSpace(
87
106
  selectingShape,
88
- this.editor.inputs.currentPagePoint
107
+ this.editor.inputs.getCurrentPagePoint()
89
108
  );
90
109
  if (textLabel.bounds.containsPoint(pointInShapeSpace, 0) && textLabel.hitTestPoint(pointInShapeSpace)) {
91
110
  if (selectingShape.id === editingShape.id) {
111
+ this.didPointerDownOnEditingShape = true;
92
112
  return;
93
113
  } else {
94
- this.hitShapeForPointerUp = selectingShape;
114
+ this.hitLabelOnShapeForPointerUp = selectingShape;
95
115
  this.editor.markHistoryStoppingPoint("editing on pointer up");
96
116
  this.editor.select(selectingShape.id);
97
117
  return;
@@ -116,9 +136,16 @@ class EditingShape extends StateNode {
116
136
  this.editor.root.handleEvent(info);
117
137
  }
118
138
  onPointerUp(info) {
119
- const hitShape = this.hitShapeForPointerUp;
139
+ if (this.didPointerDownOnEditingShape) {
140
+ this.didPointerDownOnEditingShape = false;
141
+ if (!this.isTextInputFocused()) {
142
+ this.editor.getRichTextEditor()?.commands.focus("all");
143
+ return;
144
+ }
145
+ }
146
+ const hitShape = this.hitLabelOnShapeForPointerUp;
120
147
  if (!hitShape) return;
121
- this.hitShapeForPointerUp = null;
148
+ this.hitLabelOnShapeForPointerUp = null;
122
149
  const util = this.editor.getShapeUtil(hitShape);
123
150
  if (hitShape.isLocked) return;
124
151
  if (this.editor.getIsReadonly()) {