tldraw 4.2.2 → 4.2.3

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 (621) hide show
  1. package/dist-cjs/index.d.ts +242 -311
  2. package/dist-cjs/index.js +5 -13
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
  5. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +4 -7
  6. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  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 +1 -6
  11. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +13 -14
  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/elbowArrowSnapLines.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
  21. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +10 -4
  22. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  23. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +4 -7
  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/bookmark/bookmarks.js.map +2 -2
  28. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +22 -24
  29. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/draw/getPath.js +11 -20
  31. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  32. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +86 -82
  33. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  34. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +0 -6
  35. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  36. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  37. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -6
  38. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  39. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +142 -146
  40. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  41. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +10 -5
  42. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  43. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  44. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  45. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +21 -23
  46. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  47. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  48. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  49. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +11 -6
  50. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  51. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  52. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +10 -5
  53. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  54. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -3
  55. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  56. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -14
  57. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  58. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +4 -12
  59. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  60. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  61. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  62. package/dist-cjs/lib/shapes/shared/crop.js +0 -1
  63. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  64. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  65. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  66. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  67. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  68. package/dist-cjs/lib/shapes/shared/{useEfficientZoomThreshold.js → useForceSolid.js} +7 -10
  69. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +7 -0
  70. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  71. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  72. package/dist-cjs/lib/shapes/text/RichTextArea.js +0 -5
  73. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  74. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -5
  75. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  76. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +10 -4
  77. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  78. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +5 -7
  79. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  80. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  81. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  82. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +5 -4
  83. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  84. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +4 -2
  85. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  86. package/dist-cjs/lib/tools/HandTool/HandTool.js +5 -3
  87. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  88. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +2 -3
  89. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  90. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  91. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  92. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  93. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  94. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +11 -10
  95. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  96. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +5 -6
  97. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +6 -4
  99. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  105. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +1 -2
  107. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +6 -8
  111. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +11 -38
  113. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +50 -42
  115. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  117. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  118. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  119. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +14 -4
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  123. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  124. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  125. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  126. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  127. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  128. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +13 -4
  129. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  130. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +6 -5
  131. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  132. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +3 -2
  133. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  134. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +6 -7
  135. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  136. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +11 -13
  137. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  138. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +4 -15
  139. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  140. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  141. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  142. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  143. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  144. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +6 -5
  145. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  146. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +3 -1
  147. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  148. package/dist-cjs/lib/{utils/test-helpers.js → tools/selection-logic/getShouldEnterCropModeOnPointerDown.js} +8 -21
  149. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +7 -0
  150. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  151. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  152. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  153. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  154. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  155. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  156. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +9 -3
  157. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +3 -1
  159. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  160. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  161. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +21 -1
  163. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  164. package/dist-cjs/lib/ui/components/EditLinkDialog.js +1 -11
  165. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  166. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  167. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  168. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  169. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +15 -2
  170. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  171. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +1 -3
  172. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  173. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +0 -6
  174. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  175. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  176. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  177. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  178. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  179. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  180. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  181. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +32 -0
  182. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +7 -0
  183. package/dist-cjs/lib/ui/components/menu-items.js +1 -3
  184. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  185. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -3
  186. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  187. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  188. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  189. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +93 -149
  190. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  191. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  192. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  193. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
  194. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  195. package/dist-cjs/lib/ui/context/actions.js +8 -7
  196. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  197. package/dist-cjs/lib/ui/context/components.js +2 -1
  198. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  199. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  200. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  201. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  202. package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
  203. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  204. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  205. package/dist-cjs/lib/ui/hooks/useTools.js +5 -4
  206. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  207. package/dist-cjs/lib/ui/version.js +3 -3
  208. package/dist-cjs/lib/ui/version.js.map +1 -1
  209. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +6 -16
  210. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  211. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  212. package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
  213. package/dist-cjs/lib/utils/text/richText.js +2 -4
  214. package/dist-cjs/lib/utils/text/richText.js.map +2 -2
  215. package/dist-cjs/lib/utils/text/textDirection.js +51 -0
  216. package/dist-cjs/lib/utils/text/textDirection.js.map +7 -0
  217. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -7
  218. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  219. package/dist-esm/index.d.mts +242 -311
  220. package/dist-esm/index.mjs +5 -14
  221. package/dist-esm/index.mjs.map +2 -2
  222. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  223. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +4 -8
  224. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  225. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  226. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  227. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  228. package/dist-esm/lib/defaultSideEffects.mjs +1 -6
  229. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  230. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  231. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  232. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  233. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  234. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  235. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  236. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
  238. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +10 -4
  239. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  240. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +4 -7
  241. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  242. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  243. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  244. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  245. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +24 -29
  246. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/draw/getPath.mjs +11 -21
  248. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +86 -83
  250. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  251. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +0 -6
  252. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  253. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  254. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -6
  255. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  256. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +142 -147
  257. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  258. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +10 -5
  259. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  260. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  261. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  262. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +22 -24
  263. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  264. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  265. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  266. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +12 -7
  267. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  268. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +10 -5
  270. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -4
  272. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -14
  274. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  275. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +4 -12
  276. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  277. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  278. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  279. package/dist-esm/lib/shapes/shared/crop.mjs +0 -1
  280. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  281. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  282. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  283. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  284. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  285. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +9 -0
  286. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +7 -0
  287. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  288. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  289. package/dist-esm/lib/shapes/text/RichTextArea.mjs +0 -5
  290. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  291. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +2 -5
  292. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  293. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +10 -4
  294. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  295. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +5 -7
  296. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  297. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  298. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  299. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +5 -4
  300. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  301. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +8 -3
  302. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  303. package/dist-esm/lib/tools/HandTool/HandTool.mjs +5 -3
  304. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  305. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +2 -3
  306. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  307. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  308. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  309. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  310. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  311. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +11 -10
  312. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  313. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +5 -6
  314. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  315. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +6 -4
  316. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  317. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  318. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  319. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  320. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  321. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  322. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  323. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +1 -2
  324. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  325. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  326. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  327. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +6 -8
  328. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  329. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +11 -38
  330. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  331. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +51 -43
  332. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  333. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  334. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  335. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  336. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  337. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +19 -6
  338. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  339. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  340. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  341. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  342. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  343. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  344. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  345. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +13 -4
  346. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  347. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +6 -5
  348. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  349. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +3 -2
  350. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  351. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +6 -7
  352. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  353. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +11 -13
  354. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  355. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +4 -17
  356. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  357. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  358. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  359. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  360. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  361. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +6 -5
  362. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  363. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +3 -1
  364. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  365. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +8 -0
  366. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +7 -0
  367. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  368. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  369. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  370. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  371. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  372. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  373. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +8 -2
  374. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  375. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +3 -1
  376. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  377. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  378. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  379. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +30 -3
  380. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  381. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +1 -11
  382. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  383. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  384. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  385. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  386. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +6 -3
  387. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  388. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +1 -3
  389. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  390. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +0 -6
  391. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  392. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  393. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  394. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  395. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  396. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  397. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  398. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +12 -0
  399. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +7 -0
  400. package/dist-esm/lib/ui/components/menu-items.mjs +5 -4
  401. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  402. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -3
  403. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  404. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  405. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  406. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +95 -157
  407. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  408. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  409. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  410. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
  411. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  412. package/dist-esm/lib/ui/context/actions.mjs +8 -7
  413. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  414. package/dist-esm/lib/ui/context/components.mjs +2 -1
  415. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  416. package/dist-esm/lib/ui/hooks/menu-hooks.mjs +4 -1
  417. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  418. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  419. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  420. package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
  421. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  422. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  423. package/dist-esm/lib/ui/hooks/useTools.mjs +5 -4
  424. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  425. package/dist-esm/lib/ui/version.mjs +3 -3
  426. package/dist-esm/lib/ui/version.mjs.map +1 -1
  427. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +6 -17
  428. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  429. package/dist-esm/lib/utils/export/exportAs.mjs +3 -1
  430. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  431. package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
  432. package/dist-esm/lib/utils/text/richText.mjs +2 -5
  433. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  434. package/dist-esm/lib/utils/text/textDirection.mjs +31 -0
  435. package/dist-esm/lib/utils/text/textDirection.mjs.map +7 -0
  436. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -8
  437. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  438. package/package.json +16 -18
  439. package/src/index.ts +2 -6
  440. package/src/lib/Tldraw.test.tsx +1 -46
  441. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
  442. package/src/lib/canvas/TldrawSelectionForeground.tsx +9 -20
  443. package/src/lib/defaultEmbedDefinitions.ts +0 -1
  444. package/src/lib/defaultExternalContentHandlers.ts +14 -13
  445. package/src/lib/defaultSideEffects.ts +1 -6
  446. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +133 -40
  447. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  448. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
  449. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
  450. package/src/lib/shapes/arrow/arrow-types.ts +0 -2
  451. package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
  452. package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
  453. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
  454. package/src/lib/shapes/arrow/shared.ts +4 -4
  455. package/src/lib/shapes/arrow/toolStates/Idle.tsx +14 -4
  456. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +5 -8
  457. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  458. package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
  459. package/src/lib/shapes/draw/DrawShapeUtil.tsx +26 -30
  460. package/src/lib/shapes/draw/getPath.ts +10 -31
  461. package/src/lib/shapes/draw/toolStates/Drawing.ts +90 -100
  462. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -8
  463. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  464. package/src/lib/shapes/frame/FrameShapeUtil.tsx +4 -10
  465. package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +2 -10
  466. package/src/lib/shapes/geo/GeoShapeUtil.tsx +176 -228
  467. package/src/lib/shapes/geo/toolStates/Idle.ts +15 -5
  468. package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
  469. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -25
  470. package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
  471. package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
  472. package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
  473. package/src/lib/shapes/note/NoteShapeTool.test.ts +1 -2
  474. package/src/lib/shapes/note/NoteShapeUtil.tsx +10 -9
  475. package/src/lib/shapes/note/noteCloning.test.ts +1 -3
  476. package/src/lib/shapes/note/noteHelpers.ts +2 -2
  477. package/src/lib/shapes/note/toolStates/Pointing.ts +10 -5
  478. package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -4
  479. package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -12
  480. package/src/lib/shapes/shared/RichTextLabel.tsx +4 -14
  481. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  482. package/src/lib/shapes/shared/crop.ts +0 -1
  483. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  484. package/src/lib/shapes/shared/useEditablePlainText.ts +3 -7
  485. package/src/lib/shapes/shared/useEditableRichText.ts +3 -7
  486. package/src/lib/shapes/shared/useForceSolid.ts +6 -0
  487. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  488. package/src/lib/shapes/text/RichTextArea.tsx +0 -5
  489. package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
  490. package/src/lib/shapes/text/TextShapeUtil.tsx +0 -5
  491. package/src/lib/shapes/text/toolStates/Idle.ts +14 -4
  492. package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
  493. package/src/lib/shapes/video/VideoShapeUtil.tsx +1 -2
  494. package/src/lib/tools/EraserTool/childStates/Erasing.ts +10 -7
  495. package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -5
  496. package/src/lib/tools/HandTool/HandTool.ts +5 -3
  497. package/src/lib/tools/HandTool/childStates/Dragging.ts +2 -3
  498. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  499. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  500. package/src/lib/tools/SelectTool/DragAndDropManager.ts +11 -14
  501. package/src/lib/tools/SelectTool/childStates/Brushing.ts +11 -8
  502. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +6 -7
  503. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +4 -3
  504. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  505. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  506. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +1 -2
  507. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  508. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +12 -11
  509. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +16 -57
  510. package/src/lib/tools/SelectTool/childStates/Idle.ts +81 -64
  511. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +8 -7
  512. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  513. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +17 -9
  514. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  515. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  516. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
  517. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +14 -4
  518. package/src/lib/tools/SelectTool/childStates/Resizing.ts +10 -8
  519. package/src/lib/tools/SelectTool/childStates/Rotating.ts +3 -2
  520. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +10 -9
  521. package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -16
  522. package/src/lib/tools/SelectTool/selectHelpers.ts +4 -39
  523. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  524. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  525. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +6 -5
  526. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +3 -1
  527. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +10 -0
  528. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  529. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  530. package/src/lib/ui/TldrawUi.tsx +2 -5
  531. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +9 -1
  532. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +3 -1
  533. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  534. package/src/lib/ui/components/DefaultDebugPanel.tsx +42 -3
  535. package/src/lib/ui/components/EditLinkDialog.tsx +6 -16
  536. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  537. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  538. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +5 -6
  539. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +1 -3
  540. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +0 -8
  541. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
  542. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  543. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  544. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  545. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +10 -0
  546. package/src/lib/ui/components/menu-items.tsx +15 -9
  547. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +3 -5
  548. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  549. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +113 -208
  550. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  551. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  552. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
  553. package/src/lib/ui/context/actions.tsx +19 -15
  554. package/src/lib/ui/context/components.tsx +2 -1
  555. package/src/lib/ui/hooks/menu-hooks.ts +19 -9
  556. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  557. package/src/lib/ui/hooks/useFlatten.ts +2 -1
  558. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  559. package/src/lib/ui/hooks/useTools.tsx +7 -5
  560. package/src/lib/ui/version.ts +3 -3
  561. package/src/lib/ui.css +29 -31
  562. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +48 -12
  563. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +6 -19
  564. package/src/lib/utils/export/exportAs.ts +9 -2
  565. package/src/lib/utils/frames/frames.ts +1 -1
  566. package/src/lib/utils/text/richText.ts +5 -6
  567. package/src/lib/utils/text/textDirection.ts +32 -0
  568. package/src/lib/utils/tldr/buildFromV1Document.ts +19 -21
  569. package/src/test/Editor.test.tsx +41 -78
  570. package/src/test/EraserTool.test.ts +12 -10
  571. package/src/test/SelectTool.test.ts +19 -11
  572. package/src/test/TestEditor.ts +51 -49
  573. package/src/test/TldrawEditor.test.tsx +20 -24
  574. package/src/test/__snapshots__/drawing.test.ts.snap +1257 -3
  575. package/src/test/__snapshots__/resizing.test.ts.snap +12 -3
  576. package/src/test/arrows-megabus.test.tsx +1 -1
  577. package/src/test/bindings.test.tsx +25 -29
  578. package/src/test/bindingsIndex.test.tsx +4 -4
  579. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  580. package/src/test/commands/createShapes.test.ts +1 -15
  581. package/src/test/commands/getSvgString.test.ts +2 -2
  582. package/src/test/commands/putContent.test.ts +1 -80
  583. package/src/test/commands/setCamera.test.ts +11 -13
  584. package/src/test/commands/stackShapes.test.ts +8 -34
  585. package/src/test/commands/updateShapes.test.ts +5 -21
  586. package/src/test/commands/zoomToBounds.test.ts +3 -19
  587. package/src/test/commands/zoomToSelection.test.ts +3 -14
  588. package/src/test/custom-clipping.test.ts +44 -52
  589. package/src/test/customSnapping.test.tsx +62 -77
  590. package/src/test/drawing.test.ts +10 -17
  591. package/src/test/duplicate.test.ts +1 -1
  592. package/src/test/flipShapes.test.ts +0 -33
  593. package/src/test/frames.test.ts +2 -94
  594. package/src/test/getCulledShapes.test.tsx +3 -11
  595. package/src/test/getShapeAtPoint.test.ts +2 -2
  596. package/src/test/groups.test.tsx +4 -7
  597. package/src/test/modifiers.test.ts +6 -6
  598. package/src/test/resizing.test.ts +22 -16
  599. package/src/test/selection-omnibus.test.ts +13 -13
  600. package/src/test/shapeutils.test.ts +1 -1
  601. package/src/test/spacebarPanning.test.ts +10 -28
  602. package/src/test/styles2.test.tsx +1 -1
  603. package/src/test/styles3.test.ts +5 -5
  604. package/src/test/test-jsx.tsx +57 -72
  605. package/src/test/text.test.ts +17 -15
  606. package/src/test/translating.test.ts +8 -6
  607. package/tldraw.css +41 -45
  608. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +0 -7
  609. package/dist-cjs/lib/utils/test-helpers.js.map +0 -7
  610. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +0 -12
  611. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +0 -7
  612. package/dist-esm/lib/utils/test-helpers.mjs +0 -21
  613. package/dist-esm/lib/utils/test-helpers.mjs.map +0 -7
  614. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +0 -146
  615. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +0 -146
  616. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +0 -10
  617. package/src/lib/utils/test-helpers.ts +0 -60
  618. package/src/test/commands/cameraState.test.ts +0 -299
  619. package/src/test/commands/createShape.test.ts +0 -64
  620. package/src/test/commands/isShapeOfType.test.ts +0 -44
  621. package/src/test/commands/updateShape.test.ts +0 -67
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingShape.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\n\nexport class PointingShape extends StateNode {\n\tstatic override id = 'pointing_shape'\n\n\thitShape = {} as TLShape\n\thitShapeForPointerUp = {} as TLShape\n\tisDoubleClick = false\n\n\tdidCtrlOnEnter = false\n\tdidSelectOnEnter = false\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'shape' }) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\tconst { shiftKey, altKey, accelKey } = info\n\n\t\tthis.hitShape = info.shape\n\t\tthis.isDoubleClick = false\n\t\tthis.didCtrlOnEnter = accelKey\n\t\tconst outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape)\n\t\tconst selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) =>\n\t\t\tselectedShapeIds.includes(parent.id)\n\t\t)\n\n\t\tif (\n\t\t\tthis.didCtrlOnEnter ||\n\t\t\t// If the shape has an onClick handler\n\t\t\tthis.editor.getShapeUtil(info.shape).onClick ||\n\t\t\t// ...or if the shape is the focused layer (e.g. group)\n\t\t\toutermostSelectingShape.id === focusedGroupId ||\n\t\t\t// ...or if the shape is within the selection\n\t\t\tselectedShapeIds.includes(outermostSelectingShape.id) ||\n\t\t\t// ...or if an ancestor of the shape is selected\n\t\t\tselectedAncestor ||\n\t\t\t// ...or if the current point is NOT within the selection bounds\n\t\t\t(selectedShapeIds.length > 1 && selectionBounds?.containsPoint(currentPagePoint))\n\t\t) {\n\t\t\t// We won't select the shape on enter, though we might select it on pointer up!\n\t\t\tthis.didSelectOnEnter = false\n\t\t\tthis.hitShapeForPointerUp = outermostSelectingShape\n\t\t\treturn\n\t\t}\n\n\t\tthis.didSelectOnEnter = true\n\n\t\tif (shiftKey && !altKey) {\n\t\t\tthis.editor.cancelDoubleClick()\n\t\t\tif (!selectedShapeIds.includes(outermostSelectingShape.id)) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift selecting shape')\n\t\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, outermostSelectingShape.id])\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\tthis.editor.setSelectedShapes([outermostSelectingShape.id])\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst zoomLevel = this.editor.getZoomLevel()\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tconst hitShape =\n\t\t\tthis.editor.getShapeAtPoint(currentPagePoint, {\n\t\t\t\tmargin: this.editor.options.hitTestMargin / zoomLevel,\n\t\t\t\thitInside: true,\n\t\t\t\trenderingOnly: true,\n\t\t\t}) ?? this.hitShape\n\n\t\tconst selectingShape = hitShape\n\t\t\t? this.editor.getOutermostSelectableShape(hitShape)\n\t\t\t: this.hitShapeForPointerUp\n\n\t\tif (selectingShape) {\n\t\t\t// If the selecting shape has a click handler, call it instead of selecting the shape\n\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\tif (util.onClick) {\n\t\t\t\tconst change = util.onClick?.(selectingShape)\n\t\t\t\tif (change) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('shape on click')\n\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (selectingShape.id === focusedGroupId) {\n\t\t\t\tif (selectedShapeIds.length > 0) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('clearing shape ids')\n\t\t\t\t\tthis.editor.setSelectedShapes([])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t\t}\n\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!this.didSelectOnEnter) {\n\t\t\t// if the shape has an ancestor which is a focusable layer and it is not focused but it is selected\n\t\t\t// then we should focus the layer and select the shape\n\n\t\t\tconst outermostSelectableShape = this.editor.getOutermostSelectableShape(\n\t\t\t\thitShape,\n\t\t\t\t// if a group is selected, we want to stop before reaching that group\n\t\t\t\t// so we can drill down into the group\n\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t)\n\n\t\t\t// If the outermost shape is selected, then either select or deselect the SELECTING shape\n\t\t\tif (selectedShapeIds.includes(outermostSelectableShape.id)) {\n\t\t\t\t// same shape, so deselect it if shift is pressed, otherwise deselect all others\n\t\t\t\tif (additiveSelectionKey) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('deselecting on pointer up')\n\t\t\t\t\tthis.editor.deselect(selectingShape)\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedShapeIds.includes(selectingShape.id)) {\n\t\t\t\t\t\t// todo\n\t\t\t\t\t\t// if the shape is editable and we're inside of an editable part of that shape, e.g. the label of a geo shape,\n\t\t\t\t\t\t// then we would want to begin editing the shape. At the moment we're relying on the shape label's onPointerUp\n\t\t\t\t\t\t// handler to do this logic, and prevent the regular pointer up event, so we won't be here in that case.\n\n\t\t\t\t\t\t// if the shape has a text label, and we're inside of the label, then we want to begin editing the label.\n\t\t\t\t\t\tif (selectedShapeIds.length === 1) {\n\t\t\t\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t\t\t\t// N.B. we're only interested if there is exactly one text label. We don't handle the\n\t\t\t\t\t\t\t// case if there's potentially more than one text label at the moment.\n\t\t\t\t\t\t\tif (textLabel) {\n\t\t\t\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\t\t\t\tcurrentPagePoint\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tthis.editor.run(() => {\n\t\t\t\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\n\t\t\t\t\t\t\t\t\t\tif (!this.editor.canEditShape(selectingShape)) return\n\t\t\t\t\t\t\t\t\t\tthis.editor.setEditingShape(selectingShape.id)\n\t\t\t\t\t\t\t\t\t\tthis.editor.setCurrentTool('select.editing_shape')\n\n\t\t\t\t\t\t\t\t\t\tif (this.isDoubleClick) {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('select-all-text', { shapeId: selectingShape.id })\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('place-caret', {\n\t\t\t\t\t\t\t\t\t\t\t\tshapeId: selectingShape.id,\n\t\t\t\t\t\t\t\t\t\t\t\tpoint: info.point,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// We just want to select the single shape from the selection\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (additiveSelectionKey) {\n\t\t\t\t// Different shape, so we are drilling down into a group with shift key held.\n\t\t\t\t// Deselect any ancestors and add the target shape to the selection\n\t\t\t\tconst ancestors = this.editor.getShapeAncestors(outermostSelectableShape)\n\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift deselecting on pointer up')\n\t\t\t\tthis.editor.setSelectedShapes([\n\t\t\t\t\t...this.editor.getSelectedShapeIds().filter((id) => !ancestors.find((a) => a.id === id)),\n\t\t\t\t\toutermostSelectableShape.id,\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t// different shape and we are drilling down, but no shift held so just select it straight up\n\t\t\t\tthis.editor.setSelectedShapes([outermostSelectableShape.id])\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onDoubleClick() {\n\t\tthis.isDoubleClick = true\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tif (isOverArrowLabel(this.editor, this.hitShape)) {\n\t\t\t\t// We're moving the label on a shape.\n\t\t\t\tthis.parent.transition('pointing_arrow_label', { ...info, shape: this.hitShape })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (this.didCtrlOnEnter) {\n\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t} else {\n\t\t\t\tthis.startTranslating(info)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startTranslating(info)\n\t}\n\n\tprivate startTranslating(info: TLPointerEventInfo) {\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\t// Re-focus the editor, just in case the text label of the shape has stolen focus\n\t\tthis.editor.focus()\n\t\tthis.parent.transition('translating', info)\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate cancel() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAA8C;AACvD,SAAS,wBAAwB;AACjC,SAAS,q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SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\n\nexport class PointingShape extends StateNode {\n\tstatic override id = 'pointing_shape'\n\n\thitShape = {} as TLShape\n\thitShapeForPointerUp = {} as TLShape\n\tisDoubleClick = false\n\n\tdidCtrlOnEnter = false\n\tdidSelectOnEnter = false\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'shape' }) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst selectionBounds = this.editor.getSelectionRotatedPageBounds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\t\tconst { shiftKey, altKey, accelKey } = info\n\n\t\tthis.hitShape = info.shape\n\t\tthis.isDoubleClick = false\n\t\tthis.didCtrlOnEnter = accelKey\n\t\tconst outermostSelectingShape = this.editor.getOutermostSelectableShape(info.shape)\n\t\tconst selectedAncestor = this.editor.findShapeAncestor(outermostSelectingShape, (parent) =>\n\t\t\tselectedShapeIds.includes(parent.id)\n\t\t)\n\n\t\tif (\n\t\t\tthis.didCtrlOnEnter ||\n\t\t\t// If the shape has an onClick handler\n\t\t\tthis.editor.getShapeUtil(info.shape).onClick ||\n\t\t\t// ...or if the shape is the focused layer (e.g. group)\n\t\t\toutermostSelectingShape.id === focusedGroupId ||\n\t\t\t// ...or if the shape is within the selection\n\t\t\tselectedShapeIds.includes(outermostSelectingShape.id) ||\n\t\t\t// ...or if an ancestor of the shape is selected\n\t\t\tselectedAncestor ||\n\t\t\t// ...or if the current point is NOT within the selection bounds\n\t\t\t(selectedShapeIds.length > 1 && selectionBounds?.containsPoint(currentPagePoint))\n\t\t) {\n\t\t\t// We won't select the shape on enter, though we might select it on pointer up!\n\t\t\tthis.didSelectOnEnter = false\n\t\t\tthis.hitShapeForPointerUp = outermostSelectingShape\n\t\t\treturn\n\t\t}\n\n\t\tthis.didSelectOnEnter = true\n\n\t\tif (shiftKey && !altKey) {\n\t\t\tthis.editor.cancelDoubleClick()\n\t\t\tif (!selectedShapeIds.includes(outermostSelectingShape.id)) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift selecting shape')\n\t\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, outermostSelectingShape.id])\n\t\t\t}\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\tthis.editor.setSelectedShapes([outermostSelectingShape.id])\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\t\tconst zoomLevel = this.editor.getZoomLevel()\n\t\tconst {\n\t\t\tinputs: { currentPagePoint },\n\t\t} = this.editor\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tconst hitShape =\n\t\t\tthis.editor.getShapeAtPoint(currentPagePoint, {\n\t\t\t\tmargin: this.editor.options.hitTestMargin / zoomLevel,\n\t\t\t\thitInside: true,\n\t\t\t\trenderingOnly: true,\n\t\t\t}) ?? this.hitShape\n\n\t\tconst selectingShape = hitShape\n\t\t\t? this.editor.getOutermostSelectableShape(hitShape)\n\t\t\t: this.hitShapeForPointerUp\n\n\t\tif (selectingShape) {\n\t\t\t// If the selecting shape has a click handler, call it instead of selecting the shape\n\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\tif (util.onClick) {\n\t\t\t\tconst change = util.onClick?.(selectingShape)\n\t\t\t\tif (change) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('shape on click')\n\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (selectingShape.id === focusedGroupId) {\n\t\t\t\tif (selectedShapeIds.length > 0) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('clearing shape ids')\n\t\t\t\t\tthis.editor.setSelectedShapes([])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t\t}\n\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (!this.didSelectOnEnter) {\n\t\t\t// if the shape has an ancestor which is a focusable layer and it is not focused but it is selected\n\t\t\t// then we should focus the layer and select the shape\n\n\t\t\tconst outermostSelectableShape = this.editor.getOutermostSelectableShape(\n\t\t\t\thitShape,\n\t\t\t\t// if a group is selected, we want to stop before reaching that group\n\t\t\t\t// so we can drill down into the group\n\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t)\n\n\t\t\t// If the outermost shape is selected, then either select or deselect the SELECTING shape\n\t\t\tif (selectedShapeIds.includes(outermostSelectableShape.id)) {\n\t\t\t\t// same shape, so deselect it if shift is pressed, otherwise deselect all others\n\t\t\t\tif (additiveSelectionKey) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('deselecting on pointer up')\n\t\t\t\t\tthis.editor.deselect(selectingShape)\n\t\t\t\t} else {\n\t\t\t\t\tif (selectedShapeIds.includes(selectingShape.id)) {\n\t\t\t\t\t\t// todo\n\t\t\t\t\t\t// if the shape is editable and we're inside of an editable part of that shape, e.g. the label of a geo shape,\n\t\t\t\t\t\t// then we would want to begin editing the shape. At the moment we're relying on the shape label's onPointerUp\n\t\t\t\t\t\t// handler to do this logic, and prevent the regular pointer up event, so we won't be here in that case.\n\n\t\t\t\t\t\t// if the shape has a text label, and we're inside of the label, then we want to begin editing the label.\n\t\t\t\t\t\tif (selectedShapeIds.length === 1) {\n\t\t\t\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t\t\t\t// N.B. we're only interested if there is exactly one text label. We don't handle the\n\t\t\t\t\t\t\t// case if there's potentially more than one text label at the moment.\n\t\t\t\t\t\t\tif (textLabel) {\n\t\t\t\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\t\t\t\tcurrentPagePoint\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tthis.editor.run(() => {\n\t\t\t\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\n\t\t\t\t\t\t\t\t\t\tconst util = this.editor.getShapeUtil(selectingShape)\n\t\t\t\t\t\t\t\t\t\tif (this.editor.getIsReadonly()) {\n\t\t\t\t\t\t\t\t\t\t\tif (!util.canEditInReadonly(selectingShape)) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tthis.editor.setEditingShape(selectingShape.id)\n\t\t\t\t\t\t\t\t\t\tthis.editor.setCurrentTool('select.editing_shape')\n\n\t\t\t\t\t\t\t\t\t\tif (this.isDoubleClick) {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('select-all-text', { shapeId: selectingShape.id })\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tthis.editor.emit('place-caret', {\n\t\t\t\t\t\t\t\t\t\t\t\tshapeId: selectingShape.id,\n\t\t\t\t\t\t\t\t\t\t\t\tpoint: info.point,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// We just want to select the single shape from the selection\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t\t\tthis.editor.select(selectingShape)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (additiveSelectionKey) {\n\t\t\t\t// Different shape, so we are drilling down into a group with shift key held.\n\t\t\t\t// Deselect any ancestors and add the target shape to the selection\n\t\t\t\tconst ancestors = this.editor.getShapeAncestors(outermostSelectableShape)\n\n\t\t\t\tthis.editor.markHistoryStoppingPoint('shift deselecting on pointer up')\n\t\t\t\tthis.editor.setSelectedShapes([\n\t\t\t\t\t...this.editor.getSelectedShapeIds().filter((id) => !ancestors.find((a) => a.id === id)),\n\t\t\t\t\toutermostSelectableShape.id,\n\t\t\t\t])\n\t\t\t} else {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting on pointer up')\n\t\t\t\t// different shape and we are drilling down, but no shift held so just select it straight up\n\t\t\t\tthis.editor.setSelectedShapes([outermostSelectableShape.id])\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onDoubleClick() {\n\t\tthis.isDoubleClick = true\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tif (isOverArrowLabel(this.editor, this.hitShape)) {\n\t\t\t\t// We're moving the label on a shape.\n\t\t\t\tthis.parent.transition('pointing_arrow_label', { ...info, shape: this.hitShape })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (this.didCtrlOnEnter) {\n\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t} else {\n\t\t\t\tthis.startTranslating(info)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onLongPress(info: TLPointerEventInfo) {\n\t\tthis.startTranslating(info)\n\t}\n\n\tprivate startTranslating(info: TLPointerEventInfo) {\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\t// Re-focus the editor, just in case the text label of the shape has stolen focus\n\t\tthis.editor.focus()\n\t\tthis.parent.transition('translating', info)\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate cancel() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAA8C;AACvD,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAEvB,MAAM,sBAAsB,UAAU;AAAA,EAC5C,OAAgB,KAAK;AAAA,EAErB,WAAW,CAAC;AAAA,EACZ,uBAAuB,CAAC;AAAA,EACxB,gBAAgB;AAAA,EAEhB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EAEV,QAAQ,MAAgD;AAChE,UAAM,mBAAmB,KAAK,OAAO,oBAAoB;AACzD,UAAM,kBAAkB,KAAK,OAAO,8BAA8B;AAClE,UAAM,iBAAiB,KAAK,OAAO,kBAAkB;AACrD,UAAM;AAAA,MACL,QAAQ,EAAE,iBAAiB;AAAA,IAC5B,IAAI,KAAK;AACT,UAAM,EAAE,UAAU,QAAQ,SAAS,IAAI;AAEvC,SAAK,WAAW,KAAK;AACrB,SAAK,gBAAgB;AACrB,SAAK,iBAAiB;AACtB,UAAM,0BAA0B,KAAK,OAAO,4BAA4B,KAAK,KAAK;AAClF,UAAM,mBAAmB,KAAK,OAAO;AAAA,MAAkB;AAAA,MAAyB,CAAC,WAChF,iBAAiB,SAAS,OAAO,EAAE;A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A,EACtB;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,UAAI,iBAAiB,KAAK,QAAQ,KAAK,QAAQ,GAAG;AAEjD,aAAK,OAAO,WAAW,wBAAwB,EAAE,GAAG,MAAM,OAAO,KAAK,SAAS,CAAC;AAChF;AAAA,MACD;AAEA,UAAI,KAAK,gBAAgB;AACxB,aAAK,OAAO,WAAW,YAAY,IAAI;AAAA,MACxC,OAAO;AACN,aAAK,iBAAiB,IAAI;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAC9C,SAAK,iBAAiB,IAAI;AAAA,EAC3B;AAAA,EAEQ,iBAAiB,MAA0B;AAClD,QAAI,KAAK,OAAO,cAAc,EAAG;AAGjC,SAAK,OAAO,MAAM;AAClB,SAAK,OAAO,WAAW,eAAe,IAAI;AAAA,EAC3C;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EACS,aAAa;AACrB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,cAAc;AACtB,SAAK,OAAO;AAAA,EACb;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -151,8 +151,7 @@ class Resizing extends StateNode {
151
151
  }
152
152
  }
153
153
  updateShapes() {
154
- const altKey = this.editor.inputs.getAltKey();
155
- const shiftKey = this.editor.inputs.getShiftKey();
154
+ const { altKey, shiftKey } = this.editor.inputs;
156
155
  const {
157
156
  frames,
158
157
  shapeSnapshots,
@@ -170,8 +169,8 @@ class Resizing extends StateNode {
170
169
  }
171
170
  }
172
171
  const isHoldingAccel = isAccelKey(this.editor.inputs);
173
- const currentPagePoint = this.editor.inputs.getCurrentPagePoint().clone().sub(cursorHandleOffset).sub(this.creationCursorOffset);
174
- const originPagePoint = this.editor.inputs.getOriginPagePoint().clone().sub(cursorHandleOffset);
172
+ const currentPagePoint = this.editor.inputs.currentPagePoint.clone().sub(cursorHandleOffset).sub(this.creationCursorOffset);
173
+ const originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset);
175
174
  if (this.editor.getInstanceState().isGridMode && !isHoldingAccel) {
176
175
  const { gridSize } = this.editor.getDocumentSettings();
177
176
  currentPagePoint.snapToGrid(gridSize);
@@ -320,7 +319,9 @@ class Resizing extends StateNode {
320
319
  const { editor } = this;
321
320
  const selectedShapeIds = editor.getSelectedShapeIds();
322
321
  const selectionRotation = editor.getSelectionRotation();
323
- const originPagePoint = editor.inputs.getOriginPagePoint();
322
+ const {
323
+ inputs: { originPagePoint }
324
+ } = editor;
324
325
  const selectionBounds = editor.getSelectionRotatedPageBounds();
325
326
  if (!selectionBounds) throw Error("Resizing but nothing is selected");
326
327
  const dragHandlePoint = Vec.RotWith(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Resizing.ts"],
4
- "sourcesContent": ["import {\n\tBox,\n\tHALF_PI,\n\tMat,\n\tPI,\n\tPI2,\n\tSelectionCorner,\n\tSelectionEdge,\n\tStateNode,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTickEventInfo,\n\tVec,\n\tVecLike,\n\tareAnglesCompatible,\n\tcompact,\n\tisAccelKey,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\n\nexport type ResizingInfo = TLPointerEventInfo & {\n\ttarget: 'selection'\n\thandle: SelectionEdge | SelectionCorner\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n\tonCreate?(shape: TLShape | null): void\n\tcreationCursorOffset?: VecLike\n\tonInteractionEnd?: string | (() => void)\n}\n\nexport class Resizing extends StateNode {\n\tstatic override id = 'resizing'\n\n\tinfo = {} as ResizingInfo\n\n\tmarkId = ''\n\n\t// A switch to detect when the user is holding ctrl\n\tprivate didHoldCommand = false\n\n\t// we transition into the resizing state from the geo pointing state, which starts with a shape of size w: 1, h: 1,\n\t// so if the user drags x: +50, y: +50 after mouseDown, the shape will be w: 51, h: 51, which is too many pixels, alas\n\t// so we allow passing a further offset into this state to negate such issues\n\tcreationCursorOffset = { x: 0, y: 0 } as VecLike\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(info: ResizingInfo) {\n\t\tconst { isCreating = false, creatingMarkId, creationCursorOffset = { x: 0, y: 0 } } = info\n\n\t\tthis.info = info\n\t\tthis.didHoldCommand = false\n\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.creationCursorOffset = creationCursorOffset\n\n\t\ttry {\n\t\t\t// On rare and mysterious occasions, the user can enter the resizing state with no shapes selected\n\t\t\tthis.snapshot = this._createSnapshot()\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\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('starting resizing')\n\t\t}\n\n\t\tif (isCreating) {\n\t\t\tthis.editor.setCursor({ type: 'cross', rotation: 0 })\n\t\t}\n\n\t\tthis.handleResizeStart()\n\t\tthis.updateShapes()\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.updateShapes()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateShapes()\n\t}\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\tprivate cancel() {\n\t\t// Call onResizeCancel callback before resetting\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)\n\t\t\tif (current) {\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tutil.onResizeCancel?.(shape, current)\n\t\t\t}\n\t\t})\n\n\t\tthis.editor.bailToMark(this.markId)\n\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, {})\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tkickoutOccludedShapes(this.editor, this.snapshot.selectedShapeIds)\n\n\t\tthis.handleResizeEnd()\n\n\t\tif (this.info.isCreating && this.info.onCreate) {\n\t\t\tthis.info.onCreate?.(this.editor.getOnlySelectedShape())\n\t\t\treturn\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) {\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, {})\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 handleResizeStart() {\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tconst changes: TLShapePartial[] = []\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst change = util.onResizeStart?.(shape)\n\t\t\tif (change) {\n\t\t\t\tchanges.push(change)\n\t\t\t}\n\t\t})\n\n\t\tif (changes.length > 0) {\n\t\t\tthis.editor.updateShapes(changes)\n\t\t}\n\t}\n\n\tprivate handleResizeEnd() {\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tconst changes: TLShapePartial[] = []\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)!\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst change = util.onResizeEnd?.(shape, current)\n\t\t\tif (change) {\n\t\t\t\tchanges.push(change)\n\t\t\t}\n\t\t})\n\n\t\tif (changes.length > 0) {\n\t\t\tthis.editor.updateShapes(changes)\n\t\t}\n\t}\n\n\tprivate updateShapes() {\n\t\tconst altKey = this.editor.inputs.getAltKey()\n\t\tconst shiftKey = this.editor.inputs.getShiftKey()\n\t\tconst {\n\t\t\tframes,\n\t\t\tshapeSnapshots,\n\t\t\tselectionBounds,\n\t\t\tcursorHandleOffset,\n\t\t\tselectedShapeIds,\n\t\t\tselectionRotation,\n\t\t\tcanShapesDeform,\n\t\t} = this.snapshot\n\n\t\tlet isAspectRatioLocked = shiftKey || !canShapesDeform\n\n\t\tif (shapeSnapshots.size === 1) {\n\t\t\tconst onlySnapshot = [...shapeSnapshots.values()][0]!\n\t\t\tif (this.editor.isShapeOfType(onlySnapshot.shape, 'text')) {\n\t\t\t\tisAspectRatioLocked = !(this.info.handle === 'left' || this.info.handle === 'right')\n\t\t\t}\n\t\t}\n\n\t\t// first negate the 'cursor handle offset'\n\t\t// we need to do this because we do grid snapping based on the page point of the handle\n\t\t// rather than the page point of the cursor, so it's easier to pretend that the cursor\n\t\t// is really where the handle actually is\n\t\t//\n\t\t// *** Massively zoomed-in diagram of the initial mouseDown ***\n\t\t//\n\t\t//\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502corner handle\n\t\t// \u250C\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2510\n\t\t// selection \u2502 \u2502\n\t\t// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524 x\u25C4\u2500\u2500\u253C\u2500\u2500\u2500\u2500 drag handle point \u25B2\n\t\t// \u2502 \u2502 \u2502\n\t\t// \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u251C\u2500 cursorHandleOffset.y\n\t\t// \u2502\n\t\t// originPagePoint\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25BAx\u2500\u2510 \u25BC\n\t\t// \u2502 \u2514\u2500\u2510\n\t\t// \u2502 \u2514\u2500\u2510\n\t\t// \u2502 \u2502 mouse (sorry)\n\t\t// \u2514\u2500\u2500\u2510 \u250C\u2518\n\t\t// \u2502 \u2502\n\t\t// \u2514\u2500\u2518\n\t\t// \u25C4\u2500\u2500\u252C\u2500\u2500\u25BA\n\t\t// \u2502\n\t\t// cursorHandleOffset.x\n\n\t\tconst isHoldingAccel = isAccelKey(this.editor.inputs)\n\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\t\t.sub(this.creationCursorOffset)\n\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint().clone().sub(cursorHandleOffset)\n\n\t\tif (this.editor.getInstanceState().isGridMode && !isHoldingAccel) {\n\t\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\t\t\tcurrentPagePoint.snapToGrid(gridSize)\n\t\t}\n\n\t\tconst dragHandle = this.info.handle as SelectionCorner | SelectionEdge\n\t\tconst scaleOriginHandle = rotateSelectionHandle(dragHandle, Math.PI)\n\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !isHoldingAccel : isHoldingAccel\n\n\t\tif (shouldSnap && selectionRotation % HALF_PI === 0) {\n\t\t\tconst { nudge } = this.editor.snaps.shapeBounds.snapResizeShapes({\n\t\t\t\tdragDelta: Vec.Sub(currentPagePoint, originPagePoint),\n\t\t\t\tinitialSelectionPageBounds: this.snapshot.initialSelectionPageBounds,\n\t\t\t\thandle: rotateSelectionHandle(dragHandle, selectionRotation),\n\t\t\t\tisAspectRatioLocked,\n\t\t\t\tisResizingFromCenter: altKey,\n\t\t\t})\n\n\t\t\tcurrentPagePoint.add(nudge)\n\t\t}\n\n\t\t// get the page point of the selection handle opposite to the drag handle\n\t\t// or the center of the selection box if altKey is pressed\n\t\tconst scaleOriginPage = Vec.RotWith(\n\t\t\taltKey ? selectionBounds.center : selectionBounds.getHandlePoint(scaleOriginHandle),\n\t\t\tselectionBounds.point,\n\t\t\tselectionRotation\n\t\t)\n\n\t\t// calculate the scale by measuring the current distance between the drag handle and the scale origin\n\t\t// and dividing by the original distance between the drag handle and the scale origin\n\n\t\t// bug: for edges, the page point doesn't matter, the\n\n\t\tconst distanceFromScaleOriginNow = Vec.Sub(currentPagePoint, scaleOriginPage).rot(\n\t\t\t-selectionRotation\n\t\t)\n\n\t\tconst distanceFromScaleOriginAtStart = Vec.Sub(originPagePoint, scaleOriginPage).rot(\n\t\t\t-selectionRotation\n\t\t)\n\n\t\tconst scale = Vec.DivV(distanceFromScaleOriginNow, distanceFromScaleOriginAtStart)\n\n\t\tif (!Number.isFinite(scale.x)) scale.x = 1\n\t\tif (!Number.isFinite(scale.y)) scale.y = 1\n\n\t\tconst isXLocked = dragHandle === 'top' || dragHandle === 'bottom'\n\t\tconst isYLocked = dragHandle === 'left' || dragHandle === 'right'\n\n\t\t// lock an axis if required\n\t\tif (isAspectRatioLocked) {\n\t\t\tif (isYLocked) {\n\t\t\t\t// holding shift and dragging either the left or the right edge\n\t\t\t\tscale.y = Math.abs(scale.x)\n\t\t\t} else if (isXLocked) {\n\t\t\t\t// holding shift and dragging either the top or the bottom edge\n\t\t\t\tscale.x = Math.abs(scale.y)\n\t\t\t} else if (Math.abs(scale.x) > Math.abs(scale.y)) {\n\t\t\t\t// holding shift and the drag has moved further in the x dimension\n\t\t\t\tscale.y = Math.abs(scale.x) * (scale.y < 0 ? -1 : 1)\n\t\t\t} else {\n\t\t\t\t// holding shift and the drag has moved further in the y dimension\n\t\t\t\tscale.x = Math.abs(scale.y) * (scale.x < 0 ? -1 : 1)\n\t\t\t}\n\t\t} else {\n\t\t\t// not holding shift, but still need to lock axes if dragging an edge\n\t\t\tif (isXLocked) {\n\t\t\t\tscale.x = 1\n\t\t\t}\n\t\t\tif (isYLocked) {\n\t\t\t\tscale.y = 1\n\t\t\t}\n\t\t}\n\n\t\tif (!this.info.isCreating) {\n\t\t\tthis.updateCursor({\n\t\t\t\tdragHandle,\n\t\t\t\tisFlippedX: scale.x < 0,\n\t\t\t\tisFlippedY: scale.y < 0,\n\t\t\t\trotation: selectionRotation,\n\t\t\t})\n\t\t}\n\n\t\tfor (const id of shapeSnapshots.keys()) {\n\t\t\tconst snapshot = shapeSnapshots.get(id)!\n\n\t\t\tthis.editor.resizeShape(id, scale, {\n\t\t\t\tinitialShape: snapshot.shape,\n\t\t\t\tinitialBounds: snapshot.bounds,\n\t\t\t\tinitialPageTransform: snapshot.pageTransform,\n\t\t\t\tdragHandle,\n\t\t\t\tmode:\n\t\t\t\t\tselectedShapeIds.length === 1 && id === selectedShapeIds[0]\n\t\t\t\t\t\t? 'resize_bounds'\n\t\t\t\t\t\t: 'scale_shape',\n\t\t\t\tscaleOrigin: scaleOriginPage,\n\t\t\t\tisAspectRatioLocked,\n\t\t\t\tscaleAxisRotation: selectionRotation,\n\t\t\t\tskipStartAndEndCallbacks: true,\n\t\t\t})\n\t\t}\n\n\t\t// If there's only one shape snapshot and it's a frame and the user is holding ctrl,\n\t\t// then we preserve the position of the frame's children, almost like the user is cropping\n\t\t// the frame rather than resizing it.\n\t\tif (isHoldingAccel) {\n\t\t\tthis.didHoldCommand = true\n\n\t\t\tfor (const { id, children } of frames) {\n\t\t\t\tif (!children.length) continue\n\t\t\t\tconst initial = shapeSnapshots.get(id)!.shape\n\t\t\t\tconst current = this.editor.getShape(id)!\n\t\t\t\tif (!(initial && current)) continue\n\n\t\t\t\tconst dx = current.x - initial.x\n\t\t\t\tconst dy = current.y - initial.y\n\n\t\t\t\tconst delta = new Vec(dx, dy).rot(-initial.rotation)\n\n\t\t\t\tif (delta.x !== 0 || delta.y !== 0) {\n\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\tthis.editor.updateShape({\n\t\t\t\t\t\t\tid: child.id,\n\t\t\t\t\t\t\ttype: child.type,\n\t\t\t\t\t\t\tx: child.x - delta.x,\n\t\t\t\t\t\t\ty: child.y - delta.y,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.didHoldCommand) {\n\t\t\t// If we're no longer holding the command key...\n\t\t\tthis.didHoldCommand = false\n\n\t\t\tfor (const { children } of frames) {\n\t\t\t\tif (!children.length) continue\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tthis.editor.updateShape({\n\t\t\t\t\t\tid: child.id,\n\t\t\t\t\t\ttype: child.type,\n\t\t\t\t\t\tx: child.x,\n\t\t\t\t\t\ty: child.y,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// ---\n\n\tprivate updateCursor({\n\t\tdragHandle,\n\t\tisFlippedX,\n\t\tisFlippedY,\n\t\trotation,\n\t}: {\n\t\tdragHandle: SelectionCorner | SelectionEdge\n\t\tisFlippedX: boolean\n\t\tisFlippedY: boolean\n\t\trotation: number\n\t}) {\n\t\tconst nextCursor = { ...this.editor.getInstanceState().cursor }\n\n\t\tswitch (dragHandle) {\n\t\t\tcase 'top_left':\n\t\t\tcase 'bottom_right': {\n\t\t\t\tnextCursor.type = 'nwse-resize'\n\t\t\t\tif (isFlippedX !== isFlippedY) {\n\t\t\t\t\tnextCursor.type = 'nesw-resize'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'top_right':\n\t\t\tcase 'bottom_left': {\n\t\t\t\tnextCursor.type = 'nesw-resize'\n\t\t\t\tif (isFlippedX !== isFlippedY) {\n\t\t\t\t\tnextCursor.type = 'nwse-resize'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tnextCursor.rotation = rotation\n\n\t\tthis.editor.setCursor(nextCursor)\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tprivate _createSnapshot() {\n\t\tconst { editor } = this\n\t\tconst selectedShapeIds = editor.getSelectedShapeIds()\n\t\tconst selectionRotation = editor.getSelectionRotation()\n\t\tconst originPagePoint = editor.inputs.getOriginPagePoint()\n\n\t\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\t\tif (!selectionBounds) throw Error('Resizing but nothing is selected')\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\tconst shapeSnapshots = new Map<\n\t\t\tTLShapeId,\n\t\t\t{\n\t\t\t\tshape: TLShape\n\t\t\t\tbounds: Box\n\t\t\t\tpageTransform: Mat\n\t\t\t\tpageRotation: number\n\t\t\t\tisAspectRatioLocked: boolean\n\t\t\t}\n\t\t>()\n\n\t\tconst frames: { id: TLShapeId; children: TLShape[] }[] = []\n\n\t\tconst populateResizingShapes = (shapeId: TLShapeId): false | undefined => {\n\t\t\tconst shape = editor.getShape(shapeId)\n\t\t\tif (!shape) return false\n\n\t\t\tconst util = editor.getShapeUtil(shape)\n\n\t\t\t// If the shape can resize, add it to the resizing shapes snapshots\n\t\t\tif (util.canResize(shape)) {\n\t\t\t\tconst pageTransform = editor.getShapePageTransform(shape)!\n\t\t\t\tshapeSnapshots.set(shape.id, {\n\t\t\t\t\tshape,\n\t\t\t\t\tbounds: editor.getShapeGeometry(shape).bounds,\n\t\t\t\t\tpageTransform,\n\t\t\t\t\tpageRotation: Mat.Decompose(pageTransform).rotation,\n\t\t\t\t\tisAspectRatioLocked: util.isAspectRatioLocked(shape),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Special case:\n\t\t\t// For frames, we don't want to resize children but we DO want to get a snapshot of their children so that we can restore their\n\t\t\t// positions with the accel key behavior. We could break this further into APIs, for example by collecting snapshots of all\n\t\t\t// descendants (easy) but also flagging with behavior like \"resize\" or \"keep absolute position\" or \"reposition only with accel key\",\n\t\t\t// though I'm not sure where that would be defined; perhaps better handled with onResizeStart / onResize callbacks on the util, and\n\t\t\t// pass `accelKeyIsPressed` as well as `accelKeyWasPressed`?\n\t\t\tif (editor.isShapeOfType(shape, 'frame')) {\n\t\t\t\tframes.push({\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\tchildren: compact(\n\t\t\t\t\t\teditor.getSortedChildIdsForParent(shape).map((id) => editor.getShape(id))\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// This will stop the traversal of descendants\n\t\t\tif (!util.canResizeChildren(shape)) return false\n\t\t}\n\n\t\tselectedShapeIds.forEach((shapeId) => {\n\t\t\tconst keepDescending = populateResizingShapes(shapeId)\n\t\t\tif (keepDescending === false) return\n\t\t\teditor.visitDescendants(shapeId, populateResizingShapes)\n\t\t})\n\n\t\tconst canShapesDeform = ![...shapeSnapshots.values()].some(\n\t\t\t(shape) =>\n\t\t\t\t!areAnglesCompatible(shape.pageRotation, selectionRotation) || shape.isAspectRatioLocked\n\t\t)\n\n\t\treturn {\n\t\t\tshapeSnapshots,\n\t\t\tselectionBounds,\n\t\t\tcursorHandleOffset,\n\t\t\tselectionRotation,\n\t\t\tselectedShapeIds,\n\t\t\tcanShapesDeform,\n\t\t\tinitialSelectionPageBounds: this.editor.getSelectionPageBounds()!,\n\t\t\tframes,\n\t\t}\n\t}\n}\n\ntype Snapshot = ReturnType<Resizing['_createSnapshot']>\n\nconst ORDERED_SELECTION_HANDLES: (SelectionEdge | SelectionCorner)[] = [\n\t'top',\n\t'top_right',\n\t'right',\n\t'bottom_right',\n\t'bottom',\n\t'bottom_left',\n\t'left',\n\t'top_left',\n]\n\nexport function rotateSelectionHandle(handle: SelectionEdge | SelectionCorner, rotation: number) {\n\t// first find out how many tau we need to rotate by\n\trotation = rotation % PI2\n\tconst numSteps = Math.round(rotation / (PI / 4))\n\n\tconst currentIndex = ORDERED_SELECTION_HANDLES.indexOf(handle)\n\treturn ORDERED_SELECTION_HANDLES[(currentIndex + numSteps) % ORDERED_SELECTION_HANDLES.length]\n}\n"],
5
- "mappings": "AAAA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EAMA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAYA,MAAM,iBAAiB,UAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAER,SAAS;AAAA;AAAA,EAGD,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAKzB,uBAAuB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EAE5B,WAAW,CAAC;AAAA,EAEX,QAAQ,MAAoB;AACpC,UAAM,EAAE,aAAa,OAAO,gBAAgB,uBAAuB,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,IAAI;AAEtF,SAAK,OAAO;AACZ,SAAK,iBAAiB;AAEtB,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AAC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AQ,CAAC,YAAY;AACrC,YAAM,iBAAiB,uBAAuB,OAAO;AACrD,UAAI,mBAAmB,MAAO;AAC9B,aAAO,iBAAiB,SAAS,sBAAsB;AAAA,IACxD,CAAC;AAED,UAAM,kBAAkB,CAAC,CAAC,GAAG,eAAe,OAAO,CAAC,EAAE;AAAA,MACrD,CAAC,UACA,CAAC,oBAAoB,MAAM,cAAc,iBAAiB,KAAK,MAAM;AAAA,IACvE;AAEA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,4BAA4B,KAAK,OAAO,uBAAuB;AAAA,MAC/D;AAAA,IACD;AAAA,EACD;AACD;AAIA,MAAM,4BAAiE;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,sBAAsB,QAAyC,UAAkB;AAEhG,aAAW,WAAW;AACtB,QAAM,WAAW,KAAK,MAAM,YAAY,KAAK,EAAE;AAE/C,QAAM,eAAe,0BAA0B,QAAQ,MAAM;AAC7D,SAAO,2BAA2B,eAAe,YAAY,0BAA0B,MAAM;AAC9F;",
4
+ "sourcesContent": ["import {\n\tBox,\n\tHALF_PI,\n\tMat,\n\tPI,\n\tPI2,\n\tSelectionCorner,\n\tSelectionEdge,\n\tStateNode,\n\tTLFrameShape,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTickEventInfo,\n\tVec,\n\tVecLike,\n\tareAnglesCompatible,\n\tcompact,\n\tisAccelKey,\n\tkickoutOccludedShapes,\n} from '@tldraw/editor'\n\nexport type ResizingInfo = TLPointerEventInfo & {\n\ttarget: 'selection'\n\thandle: SelectionEdge | SelectionCorner\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n\tonCreate?(shape: TLShape | null): void\n\tcreationCursorOffset?: VecLike\n\tonInteractionEnd?: string | (() => void)\n}\n\nexport class Resizing extends StateNode {\n\tstatic override id = 'resizing'\n\n\tinfo = {} as ResizingInfo\n\n\tmarkId = ''\n\n\t// A switch to detect when the user is holding ctrl\n\tprivate didHoldCommand = false\n\n\t// we transition into the resizing state from the geo pointing state, which starts with a shape of size w: 1, h: 1,\n\t// so if the user drags x: +50, y: +50 after mouseDown, the shape will be w: 51, h: 51, which is too many pixels, alas\n\t// so we allow passing a further offset into this state to negate such issues\n\tcreationCursorOffset = { x: 0, y: 0 } as VecLike\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(info: ResizingInfo) {\n\t\tconst { isCreating = false, creatingMarkId, creationCursorOffset = { x: 0, y: 0 } } = info\n\n\t\tthis.info = info\n\t\tthis.didHoldCommand = false\n\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.creationCursorOffset = creationCursorOffset\n\n\t\ttry {\n\t\t\t// On rare and mysterious occasions, the user can enter the resizing state with no shapes selected\n\t\t\tthis.snapshot = this._createSnapshot()\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\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('starting resizing')\n\t\t}\n\n\t\tif (isCreating) {\n\t\t\tthis.editor.setCursor({ type: 'cross', rotation: 0 })\n\t\t}\n\n\t\tthis.handleResizeStart()\n\t\tthis.updateShapes()\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.updateShapes()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateShapes()\n\t}\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\tprivate cancel() {\n\t\t// Call onResizeCancel callback before resetting\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)\n\t\t\tif (current) {\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tutil.onResizeCancel?.(shape, current)\n\t\t\t}\n\t\t})\n\n\t\tthis.editor.bailToMark(this.markId)\n\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, {})\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tkickoutOccludedShapes(this.editor, this.snapshot.selectedShapeIds)\n\n\t\tthis.handleResizeEnd()\n\n\t\tif (this.info.isCreating && this.info.onCreate) {\n\t\t\tthis.info.onCreate?.(this.editor.getOnlySelectedShape())\n\t\t\treturn\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) {\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, {})\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 handleResizeStart() {\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tconst changes: TLShapePartial[] = []\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst change = util.onResizeStart?.(shape)\n\t\t\tif (change) {\n\t\t\t\tchanges.push(change)\n\t\t\t}\n\t\t})\n\n\t\tif (changes.length > 0) {\n\t\t\tthis.editor.updateShapes(changes)\n\t\t}\n\t}\n\n\tprivate handleResizeEnd() {\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tconst changes: TLShapePartial[] = []\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)!\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst change = util.onResizeEnd?.(shape, current)\n\t\t\tif (change) {\n\t\t\t\tchanges.push(change)\n\t\t\t}\n\t\t})\n\n\t\tif (changes.length > 0) {\n\t\t\tthis.editor.updateShapes(changes)\n\t\t}\n\t}\n\n\tprivate updateShapes() {\n\t\tconst { altKey, shiftKey } = this.editor.inputs\n\t\tconst {\n\t\t\tframes,\n\t\t\tshapeSnapshots,\n\t\t\tselectionBounds,\n\t\t\tcursorHandleOffset,\n\t\t\tselectedShapeIds,\n\t\t\tselectionRotation,\n\t\t\tcanShapesDeform,\n\t\t} = this.snapshot\n\n\t\tlet isAspectRatioLocked = shiftKey || !canShapesDeform\n\n\t\tif (shapeSnapshots.size === 1) {\n\t\t\tconst onlySnapshot = [...shapeSnapshots.values()][0]!\n\t\t\tif (this.editor.isShapeOfType<TLTextShape>(onlySnapshot.shape, 'text')) {\n\t\t\t\tisAspectRatioLocked = !(this.info.handle === 'left' || this.info.handle === 'right')\n\t\t\t}\n\t\t}\n\n\t\t// first negate the 'cursor handle offset'\n\t\t// we need to do this because we do grid snapping based on the page point of the handle\n\t\t// rather than the page point of the cursor, so it's easier to pretend that the cursor\n\t\t// is really where the handle actually is\n\t\t//\n\t\t// *** Massively zoomed-in diagram of the initial mouseDown ***\n\t\t//\n\t\t//\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502\n\t\t// \u2502corner handle\n\t\t// \u250C\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2510\n\t\t// selection \u2502 \u2502\n\t\t// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524 x\u25C4\u2500\u2500\u253C\u2500\u2500\u2500\u2500 drag handle point \u25B2\n\t\t// \u2502 \u2502 \u2502\n\t\t// \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u251C\u2500 cursorHandleOffset.y\n\t\t// \u2502\n\t\t// originPagePoint\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25BAx\u2500\u2510 \u25BC\n\t\t// \u2502 \u2514\u2500\u2510\n\t\t// \u2502 \u2514\u2500\u2510\n\t\t// \u2502 \u2502 mouse (sorry)\n\t\t// \u2514\u2500\u2500\u2510 \u250C\u2518\n\t\t// \u2502 \u2502\n\t\t// \u2514\u2500\u2518\n\t\t// \u25C4\u2500\u2500\u252C\u2500\u2500\u25BA\n\t\t// \u2502\n\t\t// cursorHandleOffset.x\n\n\t\tconst isHoldingAccel = isAccelKey(this.editor.inputs)\n\n\t\tconst currentPagePoint = this.editor.inputs.currentPagePoint\n\t\t\t.clone()\n\t\t\t.sub(cursorHandleOffset)\n\t\t\t.sub(this.creationCursorOffset)\n\n\t\tconst originPagePoint = this.editor.inputs.originPagePoint.clone().sub(cursorHandleOffset)\n\n\t\tif (this.editor.getInstanceState().isGridMode && !isHoldingAccel) {\n\t\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\t\t\tcurrentPagePoint.snapToGrid(gridSize)\n\t\t}\n\n\t\tconst dragHandle = this.info.handle as SelectionCorner | SelectionEdge\n\t\tconst scaleOriginHandle = rotateSelectionHandle(dragHandle, Math.PI)\n\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !isHoldingAccel : isHoldingAccel\n\n\t\tif (shouldSnap && selectionRotation % HALF_PI === 0) {\n\t\t\tconst { nudge } = this.editor.snaps.shapeBounds.snapResizeShapes({\n\t\t\t\tdragDelta: Vec.Sub(currentPagePoint, originPagePoint),\n\t\t\t\tinitialSelectionPageBounds: this.snapshot.initialSelectionPageBounds,\n\t\t\t\thandle: rotateSelectionHandle(dragHandle, selectionRotation),\n\t\t\t\tisAspectRatioLocked,\n\t\t\t\tisResizingFromCenter: altKey,\n\t\t\t})\n\n\t\t\tcurrentPagePoint.add(nudge)\n\t\t}\n\n\t\t// get the page point of the selection handle opposite to the drag handle\n\t\t// or the center of the selection box if altKey is pressed\n\t\tconst scaleOriginPage = Vec.RotWith(\n\t\t\taltKey ? selectionBounds.center : selectionBounds.getHandlePoint(scaleOriginHandle),\n\t\t\tselectionBounds.point,\n\t\t\tselectionRotation\n\t\t)\n\n\t\t// calculate the scale by measuring the current distance between the drag handle and the scale origin\n\t\t// and dividing by the original distance between the drag handle and the scale origin\n\n\t\t// bug: for edges, the page point doesn't matter, the\n\n\t\tconst distanceFromScaleOriginNow = Vec.Sub(currentPagePoint, scaleOriginPage).rot(\n\t\t\t-selectionRotation\n\t\t)\n\n\t\tconst distanceFromScaleOriginAtStart = Vec.Sub(originPagePoint, scaleOriginPage).rot(\n\t\t\t-selectionRotation\n\t\t)\n\n\t\tconst scale = Vec.DivV(distanceFromScaleOriginNow, distanceFromScaleOriginAtStart)\n\n\t\tif (!Number.isFinite(scale.x)) scale.x = 1\n\t\tif (!Number.isFinite(scale.y)) scale.y = 1\n\n\t\tconst isXLocked = dragHandle === 'top' || dragHandle === 'bottom'\n\t\tconst isYLocked = dragHandle === 'left' || dragHandle === 'right'\n\n\t\t// lock an axis if required\n\t\tif (isAspectRatioLocked) {\n\t\t\tif (isYLocked) {\n\t\t\t\t// holding shift and dragging either the left or the right edge\n\t\t\t\tscale.y = Math.abs(scale.x)\n\t\t\t} else if (isXLocked) {\n\t\t\t\t// holding shift and dragging either the top or the bottom edge\n\t\t\t\tscale.x = Math.abs(scale.y)\n\t\t\t} else if (Math.abs(scale.x) > Math.abs(scale.y)) {\n\t\t\t\t// holding shift and the drag has moved further in the x dimension\n\t\t\t\tscale.y = Math.abs(scale.x) * (scale.y < 0 ? -1 : 1)\n\t\t\t} else {\n\t\t\t\t// holding shift and the drag has moved further in the y dimension\n\t\t\t\tscale.x = Math.abs(scale.y) * (scale.x < 0 ? -1 : 1)\n\t\t\t}\n\t\t} else {\n\t\t\t// not holding shift, but still need to lock axes if dragging an edge\n\t\t\tif (isXLocked) {\n\t\t\t\tscale.x = 1\n\t\t\t}\n\t\t\tif (isYLocked) {\n\t\t\t\tscale.y = 1\n\t\t\t}\n\t\t}\n\n\t\tif (!this.info.isCreating) {\n\t\t\tthis.updateCursor({\n\t\t\t\tdragHandle,\n\t\t\t\tisFlippedX: scale.x < 0,\n\t\t\t\tisFlippedY: scale.y < 0,\n\t\t\t\trotation: selectionRotation,\n\t\t\t})\n\t\t}\n\n\t\tfor (const id of shapeSnapshots.keys()) {\n\t\t\tconst snapshot = shapeSnapshots.get(id)!\n\n\t\t\tthis.editor.resizeShape(id, scale, {\n\t\t\t\tinitialShape: snapshot.shape,\n\t\t\t\tinitialBounds: snapshot.bounds,\n\t\t\t\tinitialPageTransform: snapshot.pageTransform,\n\t\t\t\tdragHandle,\n\t\t\t\tmode:\n\t\t\t\t\tselectedShapeIds.length === 1 && id === selectedShapeIds[0]\n\t\t\t\t\t\t? 'resize_bounds'\n\t\t\t\t\t\t: 'scale_shape',\n\t\t\t\tscaleOrigin: scaleOriginPage,\n\t\t\t\tisAspectRatioLocked,\n\t\t\t\tscaleAxisRotation: selectionRotation,\n\t\t\t\tskipStartAndEndCallbacks: true,\n\t\t\t})\n\t\t}\n\n\t\t// If there's only one shape snapshot and it's a frame and the user is holding ctrl,\n\t\t// then we preserve the position of the frame's children, almost like the user is cropping\n\t\t// the frame rather than resizing it.\n\t\tif (isHoldingAccel) {\n\t\t\tthis.didHoldCommand = true\n\n\t\t\tfor (const { id, children } of frames) {\n\t\t\t\tif (!children.length) continue\n\t\t\t\tconst initial = shapeSnapshots.get(id)!.shape\n\t\t\t\tconst current = this.editor.getShape(id)!\n\t\t\t\tif (!(initial && current)) continue\n\n\t\t\t\tconst dx = current.x - initial.x\n\t\t\t\tconst dy = current.y - initial.y\n\n\t\t\t\tconst delta = new Vec(dx, dy).rot(-initial.rotation)\n\n\t\t\t\tif (delta.x !== 0 || delta.y !== 0) {\n\t\t\t\t\tfor (const child of children) {\n\t\t\t\t\t\tthis.editor.updateShape({\n\t\t\t\t\t\t\tid: child.id,\n\t\t\t\t\t\t\ttype: child.type,\n\t\t\t\t\t\t\tx: child.x - delta.x,\n\t\t\t\t\t\t\ty: child.y - delta.y,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.didHoldCommand) {\n\t\t\t// If we're no longer holding the command key...\n\t\t\tthis.didHoldCommand = false\n\n\t\t\tfor (const { children } of frames) {\n\t\t\t\tif (!children.length) continue\n\t\t\t\tfor (const child of children) {\n\t\t\t\t\tthis.editor.updateShape({\n\t\t\t\t\t\tid: child.id,\n\t\t\t\t\t\ttype: child.type,\n\t\t\t\t\t\tx: child.x,\n\t\t\t\t\t\ty: child.y,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// ---\n\n\tprivate updateCursor({\n\t\tdragHandle,\n\t\tisFlippedX,\n\t\tisFlippedY,\n\t\trotation,\n\t}: {\n\t\tdragHandle: SelectionCorner | SelectionEdge\n\t\tisFlippedX: boolean\n\t\tisFlippedY: boolean\n\t\trotation: number\n\t}) {\n\t\tconst nextCursor = { ...this.editor.getInstanceState().cursor }\n\n\t\tswitch (dragHandle) {\n\t\t\tcase 'top_left':\n\t\t\tcase 'bottom_right': {\n\t\t\t\tnextCursor.type = 'nwse-resize'\n\t\t\t\tif (isFlippedX !== isFlippedY) {\n\t\t\t\t\tnextCursor.type = 'nesw-resize'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'top_right':\n\t\t\tcase 'bottom_left': {\n\t\t\t\tnextCursor.type = 'nesw-resize'\n\t\t\t\tif (isFlippedX !== isFlippedY) {\n\t\t\t\t\tnextCursor.type = 'nwse-resize'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tnextCursor.rotation = rotation\n\n\t\tthis.editor.setCursor(nextCursor)\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tprivate _createSnapshot() {\n\t\tconst { editor } = this\n\t\tconst selectedShapeIds = editor.getSelectedShapeIds()\n\t\tconst selectionRotation = editor.getSelectionRotation()\n\t\tconst {\n\t\t\tinputs: { originPagePoint },\n\t\t} = editor\n\n\t\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\t\tif (!selectionBounds) throw Error('Resizing but nothing is selected')\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\tconst shapeSnapshots = new Map<\n\t\t\tTLShapeId,\n\t\t\t{\n\t\t\t\tshape: TLShape\n\t\t\t\tbounds: Box\n\t\t\t\tpageTransform: Mat\n\t\t\t\tpageRotation: number\n\t\t\t\tisAspectRatioLocked: boolean\n\t\t\t}\n\t\t>()\n\n\t\tconst frames: { id: TLShapeId; children: TLShape[] }[] = []\n\n\t\tconst populateResizingShapes = (shapeId: TLShapeId): false | undefined => {\n\t\t\tconst shape = editor.getShape(shapeId)\n\t\t\tif (!shape) return false\n\n\t\t\tconst util = editor.getShapeUtil(shape)\n\n\t\t\t// If the shape can resize, add it to the resizing shapes snapshots\n\t\t\tif (util.canResize(shape)) {\n\t\t\t\tconst pageTransform = editor.getShapePageTransform(shape)!\n\t\t\t\tshapeSnapshots.set(shape.id, {\n\t\t\t\t\tshape,\n\t\t\t\t\tbounds: editor.getShapeGeometry(shape).bounds,\n\t\t\t\t\tpageTransform,\n\t\t\t\t\tpageRotation: Mat.Decompose(pageTransform).rotation,\n\t\t\t\t\tisAspectRatioLocked: util.isAspectRatioLocked(shape),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Special case:\n\t\t\t// For frames, we don't want to resize children but we DO want to get a snapshot of their children so that we can restore their\n\t\t\t// positions with the accel key behavior. We could break this further into APIs, for example by collecting snapshots of all\n\t\t\t// descendants (easy) but also flagging with behavior like \"resize\" or \"keep absolute position\" or \"reposition only with accel key\",\n\t\t\t// though I'm not sure where that would be defined; perhaps better handled with onResizeStart / onResize callbacks on the util, and\n\t\t\t// pass `accelKeyIsPressed` as well as `accelKeyWasPressed`?\n\t\t\tif (editor.isShapeOfType<TLFrameShape>(shape, 'frame')) {\n\t\t\t\tframes.push({\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\tchildren: compact(\n\t\t\t\t\t\teditor.getSortedChildIdsForParent(shape).map((id) => editor.getShape(id))\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// This will stop the traversal of descendants\n\t\t\tif (!util.canResizeChildren(shape)) return false\n\t\t}\n\n\t\tselectedShapeIds.forEach((shapeId) => {\n\t\t\tconst keepDescending = populateResizingShapes(shapeId)\n\t\t\tif (keepDescending === false) return\n\t\t\teditor.visitDescendants(shapeId, populateResizingShapes)\n\t\t})\n\n\t\tconst canShapesDeform = ![...shapeSnapshots.values()].some(\n\t\t\t(shape) =>\n\t\t\t\t!areAnglesCompatible(shape.pageRotation, selectionRotation) || shape.isAspectRatioLocked\n\t\t)\n\n\t\treturn {\n\t\t\tshapeSnapshots,\n\t\t\tselectionBounds,\n\t\t\tcursorHandleOffset,\n\t\t\tselectionRotation,\n\t\t\tselectedShapeIds,\n\t\t\tcanShapesDeform,\n\t\t\tinitialSelectionPageBounds: this.editor.getSelectionPageBounds()!,\n\t\t\tframes,\n\t\t}\n\t}\n}\n\ntype Snapshot = ReturnType<Resizing['_createSnapshot']>\n\nconst ORDERED_SELECTION_HANDLES: (SelectionEdge | SelectionCorner)[] = [\n\t'top',\n\t'top_right',\n\t'right',\n\t'bottom_right',\n\t'bottom',\n\t'bottom_left',\n\t'left',\n\t'top_left',\n]\n\nexport function rotateSelectionHandle(handle: SelectionEdge | SelectionCorner, rotation: number) {\n\t// first find out how many tau we need to rotate by\n\trotation = rotation % PI2\n\tconst numSteps = Math.round(rotation / (PI / 4))\n\n\tconst currentIndex = ORDERED_SELECTION_HANDLES.indexOf(handle)\n\treturn ORDERED_SELECTION_HANDLES[(currentIndex + numSteps) % ORDERED_SELECTION_HANDLES.length]\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EAQA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAYA,MAAM,iBAAiB,UAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAER,SAAS;AAAA;AAAA,EAGD,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAKzB,uBAAuB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EAE5B,WAAW,CAAC;AAAA,EAEX,QAAQ,MAAoB;AACpC,UAAM,EAAE,aAAa,OAAO,gBAAgB,uBAAuB,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,IA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,UACzE;AAAA,QACD,CAAC;AAAA,MACF;AAGA,UAAI,CAAC,KAAK,kBAAkB,KAAK,EAAG,QAAO;AAAA,IAC5C;AAEA,qBAAiB,QAAQ,CAAC,YAAY;AACrC,YAAM,iBAAiB,uBAAuB,OAAO;AACrD,UAAI,mBAAmB,MAAO;AAC9B,aAAO,iBAAiB,SAAS,sBAAsB;AAAA,IACxD,CAAC;AAED,UAAM,kBAAkB,CAAC,CAAC,GAAG,eAAe,OAAO,CAAC,EAAE;AAAA,MACrD,CAAC,UACA,CAAC,oBAAoB,MAAM,cAAc,iBAAiB,KAAK,MAAM;AAAA,IACvE;AAEA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,4BAA4B,KAAK,OAAO,uBAAuB;AAAA,MAC/D;AAAA,IACD;AAAA,EACD;AACD;AAIA,MAAM,4BAAiE;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,sBAAsB,QAAyC,UAAkB;AAEhG,aAAW,WAAW;AACtB,QAAM,WAAW,KAAK,MAAM,YAAY,KAAK,EAAE;AAE/C,QAAM,eAAe,0BAA0B,QAAQ,MAAM;AAC7D,SAAO,2BAA2B,eAAe,YAAY,0BAA0B,MAAM;AAC9F;",
6
6
  "names": []
7
7
  }
@@ -123,8 +123,9 @@ class Rotating extends StateNode {
123
123
  this.parent.transition("idle", this.info);
124
124
  }
125
125
  _getRotationFromPointerPosition({ snapToNearestDegree }) {
126
- const shiftKey = this.editor.inputs.getShiftKey();
127
- const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
126
+ const {
127
+ inputs: { shiftKey, currentPagePoint }
128
+ } = this.editor;
128
129
  const { initialCursorAngle, initialShapesRotation, initialPageCenter } = this.snapshot;
129
130
  const preSnapRotationDelta = initialPageCenter.angle(currentPagePoint) - initialCursorAngle;
130
131
  let newSelectionRotation = initialShapesRotation + preSnapRotationDelta;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Rotating.ts"],
4
- "sourcesContent": ["import {\n\tRotateCorner,\n\tStateNode,\n\tTLPointerEventInfo,\n\tTLRotationSnapshot,\n\tapplyRotationToSnapshotShapes,\n\tdegreesToRadians,\n\tgetRotationSnapshot,\n\tkickoutOccludedShapes,\n\tshortAngleDist,\n\tsnapAngle,\n} from '@tldraw/editor'\nimport { CursorTypeMap } from './PointingResizeHandle'\n\nconst ONE_DEGREE = Math.PI / 180\n\nexport class Rotating extends StateNode {\n\tstatic override id = 'rotating'\n\n\tsnapshot = {} as TLRotationSnapshot\n\n\tinfo = {} as Extract<TLPointerEventInfo, { target: 'selection' }> & {\n\t\tonInteractionEnd?: string | (() => void)\n\t}\n\n\tmarkId = ''\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & { target: 'selection'; onInteractionEnd?: string | (() => void) }\n\t) {\n\t\t// Store the event information\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('rotate start')\n\n\t\tconst snapshot = getRotationSnapshot({\n\t\t\teditor: this.editor,\n\t\t\tids: this.editor.getSelectedShapeIds(),\n\t\t})\n\t\tif (!snapshot) return this.parent.transition('idle', this.info)\n\t\tthis.snapshot = snapshot\n\n\t\t// Trigger a pointer move\n\t\tconst newSelectionRotation = this._getRotationFromPointerPosition({\n\t\t\tsnapToNearestDegree: false,\n\t\t})\n\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: this._getRotationFromPointerPosition({ snapToNearestDegree: false }),\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'start',\n\t\t})\n\n\t\t// Update cursor\n\t\tthis.editor.setCursor({\n\t\t\ttype: CursorTypeMap[this.info.handle as RotateCorner],\n\t\t\trotation: newSelectionRotation + this.snapshot.initialShapesRotation,\n\t\t})\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.snapshot = {} as TLRotationSnapshot\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.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\t// ---\n\n\tprivate update() {\n\t\tconst newSelectionRotation = this._getRotationFromPointerPosition({\n\t\t\tsnapToNearestDegree: false,\n\t\t})\n\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: newSelectionRotation,\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'update',\n\t\t})\n\n\t\t// Update cursor\n\t\tthis.editor.setCursor({\n\t\t\ttype: CursorTypeMap[this.info.handle as RotateCorner],\n\t\t\trotation: newSelectionRotation + this.snapshot.initialShapesRotation,\n\t\t})\n\t}\n\n\tprivate cancel() {\n\t\t// Call onRotateCancel callback before bailing to mark\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)\n\t\t\tif (current) {\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tutil.onRotateCancel?.(shape, current)\n\t\t\t}\n\t\t})\n\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\treturn\n\t\t}\n\t\tthis.parent.transition('idle', this.info)\n\t}\n\n\tprivate complete() {\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: this._getRotationFromPointerPosition({ snapToNearestDegree: true }),\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'end',\n\t\t})\n\t\tkickoutOccludedShapes(\n\t\t\tthis.editor,\n\t\t\tthis.snapshot.shapeSnapshots.map((s) => s.shape.id)\n\t\t)\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.parent.transition('idle', this.info)\n\t}\n\n\t_getRotationFromPointerPosition({ snapToNearestDegree }: { snapToNearestDegree: boolean }) {\n\t\tconst shiftKey = this.editor.inputs.getShiftKey()\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\tconst { initialCursorAngle, initialShapesRotation, initialPageCenter } = this.snapshot\n\n\t\t// The delta is the difference between the current angle and the initial angle\n\t\tconst preSnapRotationDelta = initialPageCenter.angle(currentPagePoint) - initialCursorAngle\n\t\tlet newSelectionRotation = initialShapesRotation + preSnapRotationDelta\n\n\t\tif (shiftKey) {\n\t\t\tnewSelectionRotation = snapAngle(newSelectionRotation, 24)\n\t\t} else if (snapToNearestDegree) {\n\t\t\tnewSelectionRotation = Math.round(newSelectionRotation / ONE_DEGREE) * ONE_DEGREE\n\n\t\t\tif (this.editor.getInstanceState().isCoarsePointer) {\n\t\t\t\tconst snappedToRightAngle = snapAngle(newSelectionRotation, 4)\n\t\t\t\tconst angleToRightAngle = shortAngleDist(newSelectionRotation, snappedToRightAngle)\n\t\t\t\tif (Math.abs(angleToRightAngle) < degreesToRadians(5)) {\n\t\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n\tTLPointerEventInfo,\n\tTLRotationSnapshot,\n\tapplyRotationToSnapshotShapes,\n\tdegreesToRadians,\n\tgetRotationSnapshot,\n\tkickoutOccludedShapes,\n\tshortAngleDist,\n\tsnapAngle,\n} from '@tldraw/editor'\nimport { CursorTypeMap } from './PointingResizeHandle'\n\nconst ONE_DEGREE = Math.PI / 180\n\nexport class Rotating extends StateNode {\n\tstatic override id = 'rotating'\n\n\tsnapshot = {} as TLRotationSnapshot\n\n\tinfo = {} as Extract<TLPointerEventInfo, { target: 'selection' }> & {\n\t\tonInteractionEnd?: string | (() => void)\n\t}\n\n\tmarkId = ''\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & { target: 'selection'; onInteractionEnd?: string | (() => void) }\n\t) {\n\t\t// Store the event information\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('rotate start')\n\n\t\tconst snapshot = getRotationSnapshot({\n\t\t\teditor: this.editor,\n\t\t\tids: this.editor.getSelectedShapeIds(),\n\t\t})\n\t\tif (!snapshot) return this.parent.transition('idle', this.info)\n\t\tthis.snapshot = snapshot\n\n\t\t// Trigger a pointer move\n\t\tconst newSelectionRotation = this._getRotationFromPointerPosition({\n\t\t\tsnapToNearestDegree: false,\n\t\t})\n\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: this._getRotationFromPointerPosition({ snapToNearestDegree: false }),\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'start',\n\t\t})\n\n\t\t// Update cursor\n\t\tthis.editor.setCursor({\n\t\t\ttype: CursorTypeMap[this.info.handle as RotateCorner],\n\t\t\trotation: newSelectionRotation + this.snapshot.initialShapesRotation,\n\t\t})\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.snapshot = {} as TLRotationSnapshot\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.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\t// ---\n\n\tprivate update() {\n\t\tconst newSelectionRotation = this._getRotationFromPointerPosition({\n\t\t\tsnapToNearestDegree: false,\n\t\t})\n\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: newSelectionRotation,\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'update',\n\t\t})\n\n\t\t// Update cursor\n\t\tthis.editor.setCursor({\n\t\t\ttype: CursorTypeMap[this.info.handle as RotateCorner],\n\t\t\trotation: newSelectionRotation + this.snapshot.initialShapesRotation,\n\t\t})\n\t}\n\n\tprivate cancel() {\n\t\t// Call onRotateCancel callback before bailing to mark\n\t\tconst { shapeSnapshots } = this.snapshot\n\n\t\tshapeSnapshots.forEach(({ shape }) => {\n\t\t\tconst current = this.editor.getShape(shape.id)\n\t\t\tif (current) {\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tutil.onRotateCancel?.(shape, current)\n\t\t\t}\n\t\t})\n\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\treturn\n\t\t}\n\t\tthis.parent.transition('idle', this.info)\n\t}\n\n\tprivate complete() {\n\t\tapplyRotationToSnapshotShapes({\n\t\t\teditor: this.editor,\n\t\t\tdelta: this._getRotationFromPointerPosition({ snapToNearestDegree: true }),\n\t\t\tsnapshot: this.snapshot,\n\t\t\tstage: 'end',\n\t\t})\n\t\tkickoutOccludedShapes(\n\t\t\tthis.editor,\n\t\t\tthis.snapshot.shapeSnapshots.map((s) => s.shape.id)\n\t\t)\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.parent.transition('idle', this.info)\n\t}\n\n\t_getRotationFromPointerPosition({ snapToNearestDegree }: { snapToNearestDegree: boolean }) {\n\t\tconst {\n\t\t\tinputs: { shiftKey, currentPagePoint },\n\t\t} = this.editor\n\t\tconst { initialCursorAngle, initialShapesRotation, initialPageCenter } = this.snapshot\n\n\t\t// The delta is the difference between the current angle and the initial angle\n\t\tconst preSnapRotationDelta = initialPageCenter.angle(currentPagePoint) - initialCursorAngle\n\t\tlet newSelectionRotation = initialShapesRotation + preSnapRotationDelta\n\n\t\tif (shiftKey) {\n\t\t\tnewSelectionRotation = snapAngle(newSelectionRotation, 24)\n\t\t} else if (snapToNearestDegree) {\n\t\t\tnewSelectionRotation = Math.round(newSelectionRotation / ONE_DEGREE) * ONE_DEGREE\n\n\t\t\tif (this.editor.getInstanceState().isCoarsePointer) {\n\t\t\t\tconst snappedToRightAngle = snapAngle(newSelectionRotation, 4)\n\t\t\t\tconst angleToRightAngle = shortAngleDist(newSelectionRotation, snappedToRightAngle)\n\t\t\t\tif (Math.abs(angleToRightAngle) < degreesToRadians(5)) {\n\t\t\t\t\tnewSelectionRotation = snappedToRightAngle\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn newSelectionRotation - initialShapesRotation\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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MACL,KAAK,SAAS,eAAe,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;AAAA,IACnD;AACA,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,WAAW,QAAQ,KAAK,IAAI;AAAA,EACzC;AAAA,EAEA,gCAAgC,EAAE,oBAAoB,GAAqC;AAC1F,UAAM;AAAA,MACL,QAAQ,EAAE,UAAU,iBAAiB;AAAA,IACtC,IAAI,KAAK;AACT,UAAM,EAAE,oBAAoB,uBAAuB,kBAAkB,IAAI,KAAK;AAG9E,UAAM,uBAAuB,kBAAkB,MAAM,gBAAgB,IAAI;AACzE,QAAI,uBAAuB,wBAAwB;AAEnD,QAAI,UAAU;AACb,6BAAuB,UAAU,sBAAsB,EAAE;AAAA,IAC1D,WAAW,qBAAqB;AAC/B,6BAAuB,KAAK,MAAM,uBAAuB,UAAU,IAAI;AAEvE,UAAI,KAAK,OAAO,iBAAiB,EAAE,iBAAiB;AACnD,cAAM,sBAAsB,UAAU,sBAAsB,CAAC;AAC7D,cAAM,oBAAoB,eAAe,sBAAsB,mBAAmB;AAClF,YAAI,KAAK,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,GAAG;AACtD,iCAAuB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEA,WAAO,uBAAuB;AAAA,EAC/B;AACD;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,7 @@ class ScribbleBrushing extends StateNode {
12
12
  newlySelectedShapeIds = /* @__PURE__ */ new Set();
13
13
  onEnter() {
14
14
  this.initialSelectedShapeIds = new Set(
15
- this.editor.inputs.getShiftKey() ? this.editor.getSelectedShapeIds() : []
15
+ this.editor.inputs.shiftKey ? this.editor.getSelectedShapeIds() : []
16
16
  );
17
17
  this.newlySelectedShapeIds = /* @__PURE__ */ new Set();
18
18
  this.size = 0;
@@ -39,7 +39,7 @@ class ScribbleBrushing extends StateNode {
39
39
  this.updateScribbleSelection(false);
40
40
  }
41
41
  onKeyUp() {
42
- if (!this.editor.inputs.getAltKey()) {
42
+ if (!this.editor.inputs.altKey) {
43
43
  this.parent.transition("brushing");
44
44
  } else {
45
45
  this.updateScribbleSelection(false);
@@ -52,16 +52,15 @@ class ScribbleBrushing extends StateNode {
52
52
  this.complete();
53
53
  }
54
54
  pushPointToScribble() {
55
- const { x, y } = this.editor.inputs.getCurrentPagePoint();
55
+ const { x, y } = this.editor.inputs.currentPagePoint;
56
56
  this.editor.scribbles.addPoint(this.scribbleId, x, y);
57
57
  }
58
58
  updateScribbleSelection(addPoint) {
59
59
  const { editor } = this;
60
60
  const currentPageShapes = this.editor.getCurrentPageRenderingShapesSorted();
61
- const shiftKey = this.editor.inputs.getShiftKey();
62
- const originPagePoint = this.editor.inputs.getOriginPagePoint();
63
- const previousPagePoint = this.editor.inputs.getPreviousPagePoint();
64
- const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
61
+ const {
62
+ inputs: { shiftKey, originPagePoint, previousPagePoint, currentPagePoint }
63
+ } = this.editor;
65
64
  const { newlySelectedShapeIds, initialSelectedShapeIds } = this;
66
65
  if (addPoint) {
67
66
  this.pushPointToScribble();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts"],
4
- "sourcesContent": ["import {\n\tGeometry2d,\n\tStateNode,\n\tTLShape,\n\tTLShapeId,\n\tVec,\n\tintersectLineSegmentPolygon,\n\tpointInPolygon,\n} from '@tldraw/editor'\n\nexport class ScribbleBrushing extends StateNode {\n\tstatic override id = 'scribble_brushing'\n\n\thits = new Set<TLShapeId>()\n\n\tsize = 0\n\n\tscribbleId = 'id'\n\n\tinitialSelectedShapeIds = new Set<TLShapeId>()\n\tnewlySelectedShapeIds = new Set<TLShapeId>()\n\n\toverride onEnter() {\n\t\tthis.initialSelectedShapeIds = new Set<TLShapeId>(\n\t\t\tthis.editor.inputs.getShiftKey() ? this.editor.getSelectedShapeIds() : []\n\t\t)\n\t\tthis.newlySelectedShapeIds = new Set<TLShapeId>()\n\t\tthis.size = 0\n\t\tthis.hits.clear()\n\n\t\tconst scribbleItem = this.editor.scribbles.addScribble({\n\t\t\tcolor: 'selection-stroke',\n\t\t\topacity: 0.32,\n\t\t\tsize: 12,\n\t\t})\n\n\t\tthis.scribbleId = scribbleItem.id\n\n\t\tthis.updateScribbleSelection(true)\n\n\t\tthis.editor.updateInstanceState({ brush: null })\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.scribbles.stop(this.scribbleId)\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateScribbleSelection(true)\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateScribbleSelection(false)\n\t}\n\n\toverride onKeyUp() {\n\t\tif (!this.editor.inputs.getAltKey()) {\n\t\t\tthis.parent.transition('brushing')\n\t\t} else {\n\t\t\tthis.updateScribbleSelection(false)\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\tprivate pushPointToScribble() {\n\t\tconst { x, y } = this.editor.inputs.getCurrentPagePoint()\n\t\tthis.editor.scribbles.addPoint(this.scribbleId, x, y)\n\t}\n\n\tprivate updateScribbleSelection(addPoint: boolean) {\n\t\tconst { editor } = this\n\t\t// const zoomLevel = this.editor.getZoomLevel()\n\t\tconst currentPageShapes = this.editor.getCurrentPageRenderingShapesSorted()\n\t\tconst shiftKey = this.editor.inputs.getShiftKey()\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\t\tconst previousPagePoint = this.editor.inputs.getPreviousPagePoint()\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\n\t\tconst { newlySelectedShapeIds, initialSelectedShapeIds } = this\n\n\t\tif (addPoint) {\n\t\t\tthis.pushPointToScribble()\n\t\t}\n\n\t\tconst shapes = currentPageShapes\n\t\tlet shape: TLShape, geometry: Geometry2d, A: Vec, B: Vec\n\n\t\tconst minDist = 0 // this.editor.options.hitTestMargin / zoomLevel\n\n\t\tfor (let i = 0, n = shapes.length; i < n; i++) {\n\t\t\tshape = shapes[i]\n\n\t\t\t// If the shape is a group or is already selected or locked, don't select it\n\t\t\tif (\n\t\t\t\teditor.isShapeOfType(shape, 'group') ||\n\t\t\t\tnewlySelectedShapeIds.has(shape.id) ||\n\t\t\t\teditor.isShapeOrAncestorLocked(shape)\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tgeometry = editor.getShapeGeometry(shape)\n\n\t\t\t// If the scribble started inside of the frame, don't select it\n\t\t\tif (\n\t\t\t\teditor.isShapeOfType(shape, 'frame') &&\n\t\t\t\tgeometry.bounds.containsPoint(editor.getPointInShapeSpace(shape, originPagePoint))\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Hit test the shape using a line segment\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape)\n\t\t\tif (!geometry || !pageTransform) continue\n\t\t\tconst pt = pageTransform.clone().invert()\n\t\t\tA = pt.applyToPoint(previousPagePoint)\n\t\t\tB = pt.applyToPoint(currentPagePoint)\n\n\t\t\t// If the line segment is entirely above / below / left / right of the shape's bounding box, skip the hit test\n\t\t\tconst { bounds } = geometry\n\t\t\tif (\n\t\t\t\tbounds.minX - minDist > Math.max(A.x, B.x) ||\n\t\t\t\tbounds.minY - minDist > Math.max(A.y, B.y) ||\n\t\t\t\tbounds.maxX + minDist < Math.min(A.x, B.x) ||\n\t\t\t\tbounds.maxY + minDist < Math.min(A.y, B.y)\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (geometry.hitTestLineSegment(A, B, minDist)) {\n\t\t\t\tconst outermostShape = this.editor.getOutermostSelectableShape(shape)\n\t\t\t\tconst pageMask = this.editor.getShapeMask(outermostShape.id)\n\t\t\t\tif (pageMask) {\n\t\t\t\t\tconst intersection = intersectLineSegmentPolygon(\n\t\t\t\t\t\tpreviousPagePoint,\n\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\tpageMask\n\t\t\t\t\t)\n\t\t\t\t\tif (intersection !== null) {\n\t\t\t\t\t\tconst isInMask = pointInPolygon(currentPagePoint, pageMask)\n\t\t\t\t\t\tif (!isInMask) continue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnewlySelectedShapeIds.add(outermostShape.id)\n\t\t\t}\n\t\t}\n\n\t\tconst current = editor.getSelectedShapeIds()\n\t\tconst next = new Set<TLShapeId>(\n\t\t\tshiftKey ? [...newlySelectedShapeIds, ...initialSelectedShapeIds] : [...newlySelectedShapeIds]\n\t\t)\n\t\tif (current.length !== next.size || current.some((id) => !next.has(id))) {\n\t\t\tthis.editor.setSelectedShapes(Array.from(next))\n\t\t}\n\t}\n\n\tprivate complete() {\n\t\tthis.updateScribbleSelection(true)\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.setSelectedShapes([...this.initialSelectedShapeIds])\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": "AAAA;AAAA,EAEC;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,yBAAyB,UAAU;AAAA,EAC/C,OAAgB,KAAK;AAAA,EAErB,OAAO,oBAAI,IAAe;AAAA,EAE1B,OAAO;AAAA,EAEP,aAAa;AAAA,EAEb,0BAA0B,oBAAI,IAAe;AAAA,EAC7C,wBAAwB,oBAAI,IAAe;AAAA,EAElC,UAAU;AAClB,SAAK,0BAA0B,IAAI;AAAA,MAClC,KAAK,OAAO,OAAO,YAAY,IAAI,KAAK,OAAO,oBAAoB,IAAI,CAAC;AAAA,IACzE;AACA,SAAK,wBAAwB,oBAA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,WAAW,eAAe,kBAAkB,QAAQ;AAC1D,gBAAI,CAAC,SAAU;AAAA,UAChB;AAAA,QACD;AAEA,8BAAsB,IAAI,eAAe,EAAE;AAAA,MAC5C;AAAA,IACD;AAEA,UAAM,UAAU,OAAO,oBAAoB;AAC3C,UAAM,OAAO,IAAI;AAAA,MAChB,WAAW,CAAC,GAAG,uBAAuB,GAAG,uBAAuB,IAAI,CAAC,GAAG,qBAAqB;AAAA,IAC9F;AACA,QAAI,QAAQ,WAAW,KAAK,QAAQ,QAAQ,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG;AACxE,WAAK,OAAO,kBAAkB,MAAM,KAAK,IAAI,CAAC;AAAA,IAC/C;AAAA,EACD;AAAA,EAEQ,WAAW;AAClB,SAAK,wBAAwB,IAAI;AACjC,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,kBAAkB,CAAC,GAAG,KAAK,uBAAuB,CAAC;AAC/D,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import {\n\tGeometry2d,\n\tStateNode,\n\tTLFrameShape,\n\tTLGroupShape,\n\tTLShape,\n\tTLShapeId,\n\tVec,\n\tintersectLineSegmentPolygon,\n\tpointInPolygon,\n} from '@tldraw/editor'\n\nexport class ScribbleBrushing extends StateNode {\n\tstatic override id = 'scribble_brushing'\n\n\thits = new Set<TLShapeId>()\n\n\tsize = 0\n\n\tscribbleId = 'id'\n\n\tinitialSelectedShapeIds = new Set<TLShapeId>()\n\tnewlySelectedShapeIds = new Set<TLShapeId>()\n\n\toverride onEnter() {\n\t\tthis.initialSelectedShapeIds = new Set<TLShapeId>(\n\t\t\tthis.editor.inputs.shiftKey ? this.editor.getSelectedShapeIds() : []\n\t\t)\n\t\tthis.newlySelectedShapeIds = new Set<TLShapeId>()\n\t\tthis.size = 0\n\t\tthis.hits.clear()\n\n\t\tconst scribbleItem = this.editor.scribbles.addScribble({\n\t\t\tcolor: 'selection-stroke',\n\t\t\topacity: 0.32,\n\t\t\tsize: 12,\n\t\t})\n\n\t\tthis.scribbleId = scribbleItem.id\n\n\t\tthis.updateScribbleSelection(true)\n\n\t\tthis.editor.updateInstanceState({ brush: null })\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.scribbles.stop(this.scribbleId)\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateScribbleSelection(true)\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.updateScribbleSelection(false)\n\t}\n\n\toverride onKeyUp() {\n\t\tif (!this.editor.inputs.altKey) {\n\t\t\tthis.parent.transition('brushing')\n\t\t} else {\n\t\t\tthis.updateScribbleSelection(false)\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\tprivate pushPointToScribble() {\n\t\tconst { x, y } = this.editor.inputs.currentPagePoint\n\t\tthis.editor.scribbles.addPoint(this.scribbleId, x, y)\n\t}\n\n\tprivate updateScribbleSelection(addPoint: boolean) {\n\t\tconst { editor } = this\n\t\t// const zoomLevel = this.editor.getZoomLevel()\n\t\tconst currentPageShapes = this.editor.getCurrentPageRenderingShapesSorted()\n\t\tconst {\n\t\t\tinputs: { shiftKey, originPagePoint, previousPagePoint, currentPagePoint },\n\t\t} = this.editor\n\n\t\tconst { newlySelectedShapeIds, initialSelectedShapeIds } = this\n\n\t\tif (addPoint) {\n\t\t\tthis.pushPointToScribble()\n\t\t}\n\n\t\tconst shapes = currentPageShapes\n\t\tlet shape: TLShape, geometry: Geometry2d, A: Vec, B: Vec\n\n\t\tconst minDist = 0 // this.editor.options.hitTestMargin / zoomLevel\n\n\t\tfor (let i = 0, n = shapes.length; i < n; i++) {\n\t\t\tshape = shapes[i]\n\n\t\t\t// If the shape is a group or is already selected or locked, don't select it\n\t\t\tif (\n\t\t\t\teditor.isShapeOfType<TLGroupShape>(shape, 'group') ||\n\t\t\t\tnewlySelectedShapeIds.has(shape.id) ||\n\t\t\t\teditor.isShapeOrAncestorLocked(shape)\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tgeometry = editor.getShapeGeometry(shape)\n\n\t\t\t// If the scribble started inside of the frame, don't select it\n\t\t\tif (\n\t\t\t\teditor.isShapeOfType<TLFrameShape>(shape, 'frame') &&\n\t\t\t\tgeometry.bounds.containsPoint(editor.getPointInShapeSpace(shape, originPagePoint))\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Hit test the shape using a line segment\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape)\n\t\t\tif (!geometry || !pageTransform) continue\n\t\t\tconst pt = pageTransform.clone().invert()\n\t\t\tA = pt.applyToPoint(previousPagePoint)\n\t\t\tB = pt.applyToPoint(currentPagePoint)\n\n\t\t\t// If the line segment is entirely above / below / left / right of the shape's bounding box, skip the hit test\n\t\t\tconst { bounds } = geometry\n\t\t\tif (\n\t\t\t\tbounds.minX - minDist > Math.max(A.x, B.x) ||\n\t\t\t\tbounds.minY - minDist > Math.max(A.y, B.y) ||\n\t\t\t\tbounds.maxX + minDist < Math.min(A.x, B.x) ||\n\t\t\t\tbounds.maxY + minDist < Math.min(A.y, B.y)\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif (geometry.hitTestLineSegment(A, B, minDist)) {\n\t\t\t\tconst outermostShape = this.editor.getOutermostSelectableShape(shape)\n\t\t\t\tconst pageMask = this.editor.getShapeMask(outermostShape.id)\n\t\t\t\tif (pageMask) {\n\t\t\t\t\tconst intersection = intersectLineSegmentPolygon(\n\t\t\t\t\t\tpreviousPagePoint,\n\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\tpageMask\n\t\t\t\t\t)\n\t\t\t\t\tif (intersection !== null) {\n\t\t\t\t\t\tconst isInMask = pointInPolygon(currentPagePoint, pageMask)\n\t\t\t\t\t\tif (!isInMask) continue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnewlySelectedShapeIds.add(outermostShape.id)\n\t\t\t}\n\t\t}\n\n\t\tconst current = editor.getSelectedShapeIds()\n\t\tconst next = new Set<TLShapeId>(\n\t\t\tshiftKey ? [...newlySelectedShapeIds, ...initialSelectedShapeIds] : [...newlySelectedShapeIds]\n\t\t)\n\t\tif (current.length !== next.size || current.some((id) => !next.has(id))) {\n\t\t\tthis.editor.setSelectedShapes(Array.from(next))\n\t\t}\n\t}\n\n\tprivate complete() {\n\t\tthis.updateScribbleSelection(true)\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.setSelectedShapes([...this.initialSelectedShapeIds])\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAMA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,yBAAyB,UAAU;AAAA,EAC/C,OAAgB,KAAK;AAAA,EAErB,OAAO,oBAAI,IAAe;AAAA,EAE1B,OAAO;AAAA,EAEP,aAAa;AAAA,EAEb,0BAA0B,oBAAI,IAAe;AAAA,EAC7C,wBAAwB,oBAAI,IAAe;AAAA,EAElC,UAAU;AAClB,SAAK,0BAA0B,IAAI;AAAA,MAClC,KAAK,OAAO,OAAO,WAAW,KAAK,OAAO,oBAAoB,IAAI,CAAC;AAAA,IACpE;AACA,SAAK,wBAAwB,oBAAI,IAAe;AAChD,SAAK,OAAO;AACZ,SAAK,KAAK,MAAM;AAEhB,UAAM,eAAe,KAAK,OAAO,UAAU,YAAY;AAAA,MACtD,OAAO;AAAA,MACP,SAAS;AAAA,MACT,MAAM;AAAA,IACP,CAAC;AAED,SAAK,aAAa,aAAa;AAE/B,SAAK,wBAAwB,IAAI;AAEjC,SAAK,OAAO,oBAAoB,EAAE,OAAO,KAAK,CAAC;AAAA,EAChD;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,UAAU,KAA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AI,CAAC;AAAA,IAC/C;AAAA,EACD;AAAA,EAEQ,WAAW;AAClB,SAAK,wBAAwB,IAAI;AACjC,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,kBAAkB,CAAC,GAAG,KAAK,uBAAuB,CAAC;AAC/D,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -110,7 +110,7 @@ class Translating extends (_a = StateNode, _updateParentTransforms_dec = [bind],
110
110
  this.editor.setCursor({ type: "move", rotation: 0 });
111
111
  this.selectionSnapshot = getTranslatingSnapshot(this.editor);
112
112
  if (!this.isCreating) {
113
- if (this.editor.inputs.getAltKey()) {
113
+ if (this.editor.inputs.altKey) {
114
114
  this.startCloning();
115
115
  if (this.isCloning) return;
116
116
  }
@@ -135,14 +135,14 @@ class Translating extends (_a = StateNode, _updateParentTransforms_dec = [bind],
135
135
  this.updateShapes();
136
136
  }
137
137
  onKeyDown() {
138
- if (this.editor.inputs.getAltKey() && !this.isCloning) {
138
+ if (this.editor.inputs.altKey && !this.isCloning) {
139
139
  this.startCloning();
140
140
  if (this.isCloning) return;
141
141
  }
142
142
  this.updateShapes();
143
143
  }
144
144
  onKeyUp() {
145
- if (!this.editor.inputs.getAltKey() && this.isCloning) {
145
+ if (!this.editor.inputs.altKey && this.isCloning) {
146
146
  this.stopCloning();
147
147
  return;
148
148
  }
@@ -243,7 +243,7 @@ class Translating extends (_a = StateNode, _updateParentTransforms_dec = [bind],
243
243
  // Get fresh shapes from the snapshot, in case onTranslateStart mutates the shape
244
244
  compact(this.snapshot.movingShapes.map((s) => this.editor.getShape(s.id))),
245
245
  // Start from the place where the user started dragging
246
- this.editor.inputs.getOriginPagePoint(),
246
+ this.editor.inputs.originPagePoint,
247
247
  this.updateParentTransforms
248
248
  );
249
249
  this.editor.setHoveredShape(null);
@@ -281,7 +281,7 @@ class Translating extends (_a = StateNode, _updateParentTransforms_dec = [bind],
281
281
  const { snapshot } = this;
282
282
  this.dragAndDropManager.startDraggingShapes(
283
283
  snapshot.movingShapes,
284
- this.editor.inputs.getOriginPagePoint(),
284
+ this.editor.inputs.originPagePoint,
285
285
  this.updateParentTransforms
286
286
  );
287
287
  moveShapesToPoint({
@@ -359,7 +359,7 @@ function getTranslatingSnapshot(editor) {
359
359
  }
360
360
  let noteAdjacentPositions;
361
361
  let noteSnapshot;
362
- const originPagePoint = editor.inputs.getOriginPagePoint();
362
+ const { originPagePoint } = editor.inputs;
363
363
  const allHoveredNotes = shapeSnapshots.filter(
364
364
  (s) => editor.isShapeOfType(s.shape, "note") && editor.isPointInShape(s.shape, originPagePoint)
365
365
  );
@@ -404,21 +404,19 @@ function moveShapesToPoint({
404
404
  shapeSnapshots,
405
405
  averagePagePoint
406
406
  } = snapshot;
407
- const shiftKey = editor.inputs.getShiftKey();
408
- const accelKey = editor.inputs.getAccelKey();
409
407
  const isGridMode = editor.getInstanceState().isGridMode;
410
408
  const gridSize = editor.getDocumentSettings().gridSize;
411
- const delta = Vec.Sub(inputs.getCurrentPagePoint(), inputs.getOriginPagePoint());
412
- const flatten = shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null;
409
+ const delta = Vec.Sub(inputs.currentPagePoint, inputs.originPagePoint);
410
+ const flatten = editor.inputs.shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null;
413
411
  if (flatten === "x") {
414
412
  delta.x = 0;
415
413
  } else if (flatten === "y") {
416
414
  delta.y = 0;
417
415
  }
418
416
  editor.snaps.clearIndicators();
419
- const isSnapping = editor.user.getIsSnapMode() ? !accelKey : accelKey;
417
+ const isSnapping = editor.user.getIsSnapMode() ? !inputs.ctrlKey : inputs.ctrlKey;
420
418
  let snappedToPit = false;
421
- if (isSnapping && editor.inputs.getPointerVelocity().len() < 0.5) {
419
+ if (isSnapping && editor.inputs.pointerVelocity.len() < 0.5) {
422
420
  const { nudge } = editor.snaps.shapeBounds.snapTranslateShapes({
423
421
  dragDelta: delta,
424
422
  initialSelectionPageBounds: initialPageBounds,
@@ -446,7 +444,7 @@ function moveShapesToPoint({
446
444
  }
447
445
  const averageSnappedPoint = Vec.Add(averagePagePoint, delta);
448
446
  const snapIndicators = editor.snaps.getIndicators();
449
- if (isGridMode && !accelKey && !snappedToPit && snapIndicators.length === 0) {
447
+ if (isGridMode && !inputs.ctrlKey && !snappedToPit && snapIndicators.length === 0) {
450
448
  averageSnappedPoint.snapToGrid(gridSize);
451
449
  }
452
450
  const averageSnap = Vec.Sub(averageSnappedPoint, averagePagePoint);