tldraw 4.3.0-canary.9c474ef3fad5 → 4.3.0-canary.a2419250444e

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 (507) hide show
  1. package/dist-cjs/index.d.ts +285 -237
  2. package/dist-cjs/index.js +12 -5
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  5. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  6. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  7. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  8. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  9. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +6 -2
  11. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  13. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  15. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  16. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  17. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  18. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  19. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  21. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  22. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  23. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  24. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +22 -20
  25. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  26. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  27. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  28. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  29. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  30. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  31. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  32. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -4
  33. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +136 -136
  35. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  36. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  37. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  38. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  39. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  40. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +22 -20
  41. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  42. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  43. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  44. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +1 -6
  45. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  46. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  47. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  48. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +1 -1
  49. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  50. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +1 -1
  51. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  52. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  53. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  54. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  55. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  56. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  57. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  58. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  59. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  60. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  61. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  62. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  63. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  64. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  65. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  66. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  67. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  68. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  69. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  70. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  71. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  72. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +9 -7
  73. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  74. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  75. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  76. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  77. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  78. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  79. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  80. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  81. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  82. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  83. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  84. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  85. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  86. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  87. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  88. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +7 -5
  89. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  90. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  91. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  92. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  93. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  94. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  95. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  96. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  97. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  99. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  101. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  103. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  105. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  107. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  111. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  113. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  115. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  117. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  118. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  119. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  120. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  121. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  122. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  123. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  124. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  125. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  126. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  127. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  128. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  129. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  130. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  131. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  132. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  133. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  134. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  135. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  136. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  137. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  138. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
  139. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
  140. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  141. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  142. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  143. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  144. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  145. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  146. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  147. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  148. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  149. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  150. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  151. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  152. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  153. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  154. package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js +1 -1
  155. package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js.map +2 -2
  156. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  157. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +6 -5
  159. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  160. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  161. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +13 -6
  163. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  164. package/dist-cjs/lib/ui/context/actions.js +6 -6
  165. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  166. package/dist-cjs/lib/ui/context/components.js +1 -2
  167. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  168. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  169. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  170. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  171. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  172. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  173. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  174. package/dist-cjs/lib/ui/version.js +3 -3
  175. package/dist-cjs/lib/ui/version.js.map +1 -1
  176. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -6
  177. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  178. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  179. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  180. package/dist-cjs/lib/utils/text/richText.js +4 -2
  181. package/dist-cjs/lib/utils/text/richText.js.map +2 -2
  182. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  183. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  184. package/dist-esm/index.d.mts +285 -237
  185. package/dist-esm/index.mjs +12 -5
  186. package/dist-esm/index.mjs.map +2 -2
  187. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  188. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  189. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  190. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  191. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  192. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  193. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +6 -2
  194. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  195. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  196. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  197. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  198. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  199. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  200. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  201. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  202. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  203. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  204. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  205. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  206. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  207. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +27 -22
  208. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  209. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  210. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  211. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  212. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  213. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  214. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  215. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -4
  216. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  217. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +137 -136
  218. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  219. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  220. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  221. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  222. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  223. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +23 -21
  224. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  225. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  226. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  227. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +2 -7
  228. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  229. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  230. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  231. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +1 -1
  232. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +1 -1
  234. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  235. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  236. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  238. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  239. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  240. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  241. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  242. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  243. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  244. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  245. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
  246. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  247. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  248. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  249. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  250. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  251. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  252. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  253. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  254. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  255. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +9 -7
  256. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  257. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  258. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  259. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  260. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  261. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  262. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  263. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  264. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  265. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  266. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  267. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  268. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  269. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  270. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  271. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +7 -5
  272. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  273. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  274. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  275. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  276. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  277. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  278. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  279. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  280. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  281. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -15
  282. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  283. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  284. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  285. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  286. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  287. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  288. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  289. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  290. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  291. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  292. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  293. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  294. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  295. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  296. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  297. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  298. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  299. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  300. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  301. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  302. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  303. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  304. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  305. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  306. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  307. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  308. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  309. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  310. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  311. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  312. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  313. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  314. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  315. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  316. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  317. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  318. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  319. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  320. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  321. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
  322. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
  323. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  324. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  325. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  326. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  327. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  328. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  329. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  330. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  331. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  332. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  333. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  334. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  335. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  336. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  337. package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs +1 -1
  338. package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs.map +2 -2
  339. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  340. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  341. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +6 -5
  342. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  343. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  344. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  345. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +13 -6
  346. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  347. package/dist-esm/lib/ui/context/actions.mjs +6 -6
  348. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  349. package/dist-esm/lib/ui/context/components.mjs +1 -2
  350. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  351. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  352. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  353. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  354. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  355. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  356. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  357. package/dist-esm/lib/ui/version.mjs +3 -3
  358. package/dist-esm/lib/ui/version.mjs.map +1 -1
  359. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +9 -6
  360. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  361. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  362. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  363. package/dist-esm/lib/utils/text/richText.mjs +5 -2
  364. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  365. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  366. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  367. package/package.json +18 -16
  368. package/src/index.ts +5 -2
  369. package/src/lib/Tldraw.test.tsx +46 -1
  370. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  371. package/src/lib/defaultExternalContentHandlers.ts +10 -10
  372. package/src/lib/defaultSideEffects.ts +6 -1
  373. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  374. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  375. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +6 -4
  376. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  377. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  378. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  379. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  380. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  381. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
  382. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  383. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  384. package/src/lib/shapes/draw/DrawShapeUtil.tsx +28 -24
  385. package/src/lib/shapes/draw/getPath.ts +31 -10
  386. package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
  387. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
  388. package/src/lib/shapes/frame/FrameShapeUtil.tsx +9 -3
  389. package/src/lib/shapes/geo/GeoShapeUtil.tsx +219 -172
  390. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  391. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  392. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  393. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -23
  394. package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
  395. package/src/lib/shapes/note/NoteShapeUtil.tsx +2 -2
  396. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  397. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  398. package/src/lib/shapes/shared/HyperlinkButton.tsx +1 -1
  399. package/src/lib/shapes/shared/RichTextLabel.tsx +1 -1
  400. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  401. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  402. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  403. package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
  404. package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
  405. package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
  406. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  407. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  408. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  409. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  410. package/src/lib/tools/SelectTool/DragAndDropManager.ts +12 -7
  411. package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
  412. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  413. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
  414. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  415. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  416. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  417. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  418. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -5
  419. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
  420. package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
  421. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
  422. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  423. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
  424. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  425. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  426. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  427. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  428. package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
  429. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  430. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
  431. package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
  432. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  433. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  434. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  435. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  436. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  437. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  438. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  439. package/src/lib/ui/TldrawUi.tsx +5 -2
  440. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  441. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  442. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  443. package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
  444. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  445. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  446. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  447. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  448. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  449. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  450. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  451. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  452. package/src/lib/ui/components/ZoomMenu/DefaultZoomMenu.tsx +1 -1
  453. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  454. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +12 -5
  455. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  456. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  457. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +5 -2
  458. package/src/lib/ui/context/actions.tsx +6 -6
  459. package/src/lib/ui/context/components.tsx +1 -2
  460. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  461. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  462. package/src/lib/ui/hooks/useTools.tsx +4 -5
  463. package/src/lib/ui/version.ts +3 -3
  464. package/src/lib/ui.css +27 -23
  465. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  466. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +11 -6
  467. package/src/lib/utils/test-helpers.ts +60 -0
  468. package/src/lib/utils/text/richText.ts +6 -5
  469. package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
  470. package/src/test/Editor.test.tsx +40 -29
  471. package/src/test/EraserTool.test.ts +10 -12
  472. package/src/test/TestEditor.ts +48 -47
  473. package/src/test/TldrawEditor.test.tsx +3 -2
  474. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  475. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  476. package/src/test/arrows-megabus.test.tsx +1 -1
  477. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +8 -8
  478. package/src/test/commands/setCamera.test.ts +13 -11
  479. package/src/test/commands/stackShapes.test.ts +34 -8
  480. package/src/test/commands/zoomToBounds.test.ts +19 -3
  481. package/src/test/commands/zoomToSelection.test.ts +14 -3
  482. package/src/test/custom-clipping.test.ts +16 -9
  483. package/src/test/drawing.test.ts +17 -10
  484. package/src/test/flipShapes.test.ts +33 -0
  485. package/src/test/frames.test.ts +92 -0
  486. package/src/test/groups.test.tsx +1 -1
  487. package/src/test/modifiers.test.ts +6 -6
  488. package/src/test/resizing.test.ts +7 -9
  489. package/src/test/selection-omnibus.test.ts +2 -2
  490. package/src/test/spacebarPanning.test.ts +28 -10
  491. package/src/test/test-jsx.tsx +3 -0
  492. package/src/test/ui/BackToContent.test.tsx +111 -0
  493. package/tldraw.css +33 -31
  494. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  495. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  496. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  497. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  498. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  499. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  500. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  501. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  502. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  503. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  504. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  505. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  506. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  507. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -9,10 +9,9 @@ import {
9
9
  } from "@tldraw/editor";
10
10
  import { isOverArrowLabel } from "../../../shapes/arrow/arrowLabel.mjs";
11
11
  import { getHitShapeOnCanvasPointerDown } from "../../selection-logic/getHitShapeOnCanvasPointerDown.mjs";
12
- import { getShouldEnterCropMode } from "../../selection-logic/getShouldEnterCropModeOnPointerDown.mjs";
13
12
  import { selectOnCanvasPointerUp } from "../../selection-logic/selectOnCanvasPointerUp.mjs";
14
13
  import { updateHoveredShapeId } from "../../selection-logic/updateHoveredShapeId.mjs";
15
- import { startEditingShapeWithLabel } from "../selectHelpers.mjs";
14
+ import { hasRichText, startEditingShapeWithRichText } from "../selectHelpers.mjs";
16
15
  const SKIPPED_KEYS_FOR_AUTO_EDITING = [
17
16
  "Delete",
18
17
  "Backspace",
@@ -39,7 +38,6 @@ class Idle extends StateNode {
39
38
  updateHoveredShapeId(this.editor);
40
39
  }
41
40
  onPointerDown(info) {
42
- const shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor);
43
41
  switch (info.target) {
44
42
  case "canvas": {
45
43
  const hitShape = getHitShapeOnCanvasPointerDown(this.editor);
@@ -53,9 +51,7 @@ class Idle extends StateNode {
53
51
  }
54
52
  const selectedShapeIds = this.editor.getSelectedShapeIds();
55
53
  const onlySelectedShape = this.editor.getOnlySelectedShape();
56
- const {
57
- inputs: { currentPagePoint }
58
- } = this.editor;
54
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
59
55
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
60
56
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
61
57
  this.onPointerDown({
@@ -79,7 +75,7 @@ class Idle extends StateNode {
79
75
  }
80
76
  case "handle": {
81
77
  if (this.editor.getIsReadonly()) break;
82
- if (this.editor.inputs.altKey) {
78
+ if (this.editor.inputs.getAltKey()) {
83
79
  this.parent.transition("pointing_shape", info);
84
80
  } else {
85
81
  this.parent.transition("pointing_handle", info);
@@ -108,7 +104,8 @@ class Idle extends StateNode {
108
104
  case "top_right":
109
105
  case "bottom_left":
110
106
  case "bottom_right": {
111
- if (shouldEnterCropMode) {
107
+ const onlySelectedShape = this.editor.getOnlySelectedShape();
108
+ if (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {
112
109
  this.parent.transition("crop.pointing_crop_handle", info);
113
110
  } else {
114
111
  if (info.accelKey) {
@@ -137,12 +134,13 @@ class Idle extends StateNode {
137
134
  }
138
135
  }
139
136
  onDoubleClick(info) {
140
- if (this.editor.inputs.shiftKey || info.phase !== "up") return;
137
+ if (this.editor.inputs.getShiftKey() || info.phase !== "up") return;
141
138
  if (info.ctrlKey || info.shiftKey) return;
142
139
  switch (info.target) {
143
140
  case "canvas": {
144
141
  const hoveredShape = this.editor.getHoveredShape();
145
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
142
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
143
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(currentPagePoint) ?? this.editor.getShapeAtPoint(currentPagePoint, {
146
144
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
147
145
  hitInside: false
148
146
  });
@@ -168,20 +166,31 @@ class Idle extends StateNode {
168
166
  });
169
167
  return;
170
168
  }
171
- if (!this.editor.inputs.shiftKey) {
169
+ if (!this.editor.inputs.getShiftKey()) {
172
170
  this.handleDoubleClickOnCanvas(info);
173
171
  }
174
172
  break;
175
173
  }
176
174
  case "selection": {
177
- if (this.editor.getIsReadonly()) break;
178
175
  const onlySelectedShape = this.editor.getOnlySelectedShape();
179
176
  if (onlySelectedShape) {
180
177
  const util = this.editor.getShapeUtil(onlySelectedShape);
181
- if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {
182
- return;
178
+ const isEdge = info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom";
179
+ const isCorner = info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left";
180
+ if (this.editor.getIsReadonly()) {
181
+ if (this.editor.canEditShape(onlySelectedShape, {
182
+ type: isCorner ? "double-click-corner" : isEdge ? "double-click-edge" : "double-click"
183
+ })) {
184
+ this.startEditingShape(
185
+ onlySelectedShape,
186
+ info,
187
+ true
188
+ /* select all */
189
+ );
190
+ }
191
+ break;
183
192
  }
184
- if (info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom") {
193
+ if (isEdge) {
185
194
  const change = util.onDoubleClickEdge?.(onlySelectedShape, info);
186
195
  if (change) {
187
196
  this.editor.markHistoryStoppingPoint("double click edge");
@@ -190,7 +199,7 @@ class Idle extends StateNode {
190
199
  return;
191
200
  }
192
201
  }
193
- if (info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left") {
202
+ if (isCorner) {
194
203
  const change = util.onDoubleClickCorner?.(onlySelectedShape, info);
195
204
  if (change) {
196
205
  this.editor.markHistoryStoppingPoint("double click corner");
@@ -199,11 +208,11 @@ class Idle extends StateNode {
199
208
  return;
200
209
  }
201
210
  }
202
- if (util.canCrop(onlySelectedShape) && !this.editor.isShapeOrAncestorLocked(onlySelectedShape)) {
211
+ if (this.editor.canCropShape(onlySelectedShape)) {
203
212
  this.parent.transition("crop", info);
204
213
  return;
205
214
  }
206
- if (this.shouldStartEditingShape(onlySelectedShape)) {
215
+ if (this.editor.canEditShape(onlySelectedShape)) {
207
216
  this.startEditingShape(
208
217
  onlySelectedShape,
209
218
  info,
@@ -231,7 +240,7 @@ class Idle extends StateNode {
231
240
  this.parent.transition("crop", info);
232
241
  return;
233
242
  }
234
- if (this.shouldStartEditingShape(shape)) {
243
+ if (this.editor.canEditShape(shape)) {
235
244
  this.startEditingShape(
236
245
  shape,
237
246
  info,
@@ -251,7 +260,7 @@ class Idle extends StateNode {
251
260
  if (changes) {
252
261
  this.editor.updateShapes([changes]);
253
262
  } else {
254
- if (this.shouldStartEditingShape(shape)) {
263
+ if (this.editor.canEditShape(shape)) {
255
264
  this.startEditingShape(
256
265
  shape,
257
266
  info,
@@ -267,7 +276,7 @@ class Idle extends StateNode {
267
276
  switch (info.target) {
268
277
  case "canvas": {
269
278
  const hoveredShape = this.editor.getHoveredShape();
270
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
279
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(), {
271
280
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
272
281
  hitInside: false,
273
282
  hitLabels: true,
@@ -285,9 +294,7 @@ class Idle extends StateNode {
285
294
  }
286
295
  const selectedShapeIds = this.editor.getSelectedShapeIds();
287
296
  const onlySelectedShape = this.editor.getOnlySelectedShape();
288
- const {
289
- inputs: { currentPagePoint }
290
- } = this.editor;
297
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
291
298
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
292
299
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
293
300
  this.onRightClick({
@@ -356,7 +363,7 @@ class Idle extends StateNode {
356
363
  const onlySelectedShape = this.editor.getOnlySelectedShape();
357
364
  if (onlySelectedShape && // If it's a note shape, then edit on type
358
365
  this.editor.isShapeOfType(onlySelectedShape, "note") && // If it's not locked or anything
359
- this.shouldStartEditingShape(onlySelectedShape)) {
366
+ this.editor.canEditShape(onlySelectedShape)) {
360
367
  this.startEditingShape(
361
368
  onlySelectedShape,
362
369
  {
@@ -408,7 +415,7 @@ class Idle extends StateNode {
408
415
  return;
409
416
  }
410
417
  const onlySelectedShape = this.editor.getOnlySelectedShape();
411
- if (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {
418
+ if (onlySelectedShape && this.editor.canEditShape(onlySelectedShape, { type: "press_enter" })) {
412
419
  this.startEditingShape(
413
420
  onlySelectedShape,
414
421
  {
@@ -421,7 +428,7 @@ class Idle extends StateNode {
421
428
  );
422
429
  return;
423
430
  }
424
- if (getShouldEnterCropMode(this.editor)) {
431
+ if (this.editor.canCropShape(onlySelectedShape)) {
425
432
  this.parent.transition("crop", info);
426
433
  }
427
434
  break;
@@ -435,16 +442,14 @@ class Idle extends StateNode {
435
442
  }
436
443
  }
437
444
  }
438
- shouldStartEditingShape(shape = this.editor.getOnlySelectedShape()) {
439
- if (!shape) return false;
440
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return false;
441
- if (!this.canInteractWithShapeInReadOnly(shape)) return false;
442
- return this.editor.getShapeUtil(shape).canEdit(shape);
443
- }
444
445
  startEditingShape(shape, info, shouldSelectAll) {
445
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return;
446
+ const { editor } = this;
446
447
  this.editor.markHistoryStoppingPoint("editing shape");
447
- startEditingShapeWithLabel(this.editor, shape, shouldSelectAll);
448
+ if (hasRichText(shape)) {
449
+ startEditingShapeWithRichText(editor, shape, { selectAll: shouldSelectAll });
450
+ } else {
451
+ editor.setEditingShape(shape);
452
+ }
448
453
  this.parent.transition("editing_shape", info);
449
454
  }
450
455
  isOverArrowLabelTest(shape) {
@@ -456,7 +461,7 @@ class Idle extends StateNode {
456
461
  if (!this.editor.options.createTextOnCanvasDoubleClick) return;
457
462
  this.editor.markHistoryStoppingPoint("creating text shape");
458
463
  const id = createShapeId();
459
- const { x, y } = this.editor.inputs.currentPagePoint;
464
+ const { x, y } = this.editor.inputs.getCurrentPagePoint();
460
465
  this.editor.createShapes([
461
466
  {
462
467
  id,
@@ -471,15 +476,8 @@ class Idle extends StateNode {
471
476
  ]);
472
477
  const shape = this.editor.getShape(id);
473
478
  if (!shape) return;
474
- const util = this.editor.getShapeUtil(shape);
475
- if (this.editor.getIsReadonly()) {
476
- if (!util.canEditInReadonly(shape)) {
477
- return;
478
- }
479
- }
480
- this.editor.setEditingShape(id);
481
- this.editor.select(id);
482
- this.parent.transition("editing_shape", info);
479
+ if (!this.editor.canEditShape(shape)) return;
480
+ startEditingShapeWithRichText(this.editor, id, { info });
483
481
  }
484
482
  nudgeSelectedShapes(ephemeral = false) {
485
483
  const {
@@ -501,12 +499,6 @@ class Idle extends StateNode {
501
499
  this.editor.nudgeShapes(selectedShapeIds, delta.mul(step));
502
500
  kickoutOccludedShapes(this.editor, selectedShapeIds);
503
501
  }
504
- canInteractWithShapeInReadOnly(shape) {
505
- if (!this.editor.getIsReadonly()) return true;
506
- const util = this.editor.getShapeUtil(shape);
507
- if (util.canEditInReadonly(shape)) return true;
508
- return false;
509
- }
510
502
  }
511
503
  const MAJOR_NUDGE_FACTOR = 10;
512
504
  const MINOR_NUDGE_FACTOR = 1;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Idle.ts"],
4
- "sourcesContent": ["import {\n\tEditor,\n\tStateNode,\n\tTLAdjacentDirection,\n\tTLClickEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tcreateShapeId,\n\tdebugFlags,\n\tkickoutOccludedShapes,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\nimport { startEditingShapeWithLabel } from '../selectHelpers'\n\nconst SKIPPED_KEYS_FOR_AUTO_EDITING = [\n\t'Delete',\n\t'Backspace',\n\t'[',\n\t']',\n\t'Enter',\n\t' ',\n\t'Shift',\n\t'Tab',\n]\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\tselectedShapesOnKeyDown: TLShape[] = []\n\n\toverride onEnter() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.selectedShapesOnKeyDown = []\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onExit() {\n\t\tupdateHoveredShapeId.cancel()\n\t}\n\n\toverride onPointerMove() {\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tconst shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor)\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\t// Check to see if we hit any shape under the pointer; if so,\n\t\t\t\t// handle this as a pointer down on the shape instead of the canvas\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !hitShape.isLocked) {\n\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tif (this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tif (this.editor.inputs.altKey) {\n\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t} else {\n\t\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\t\tthis.parent.transition('pointing_handle', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tswitch (info.handle) {\n\t\t\t\t\tcase 'mobile_rotate':\n\t\t\t\t\tcase 'top_left_rotate':\n\t\t\t\t\tcase 'top_right_rotate':\n\t\t\t\t\tcase 'bottom_left_rotate':\n\t\t\t\t\tcase 'bottom_right_rotate': {\n\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.parent.transition('pointing_rotate_handle', info)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'top':\n\t\t\t\t\tcase 'right':\n\t\t\t\t\tcase 'bottom':\n\t\t\t\t\tcase 'left':\n\t\t\t\t\tcase 'top_left':\n\t\t\t\t\tcase 'top_right':\n\t\t\t\t\tcase 'bottom_left':\n\t\t\t\t\tcase 'bottom_right': {\n\t\t\t\t\t\tif (shouldEnterCropMode) {\n\t\t\t\t\t\t\tthis.parent.transition('crop.pointing_crop_handle', info)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.parent.transition('pointing_resize_handle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thoveredShape &&\n\t\t\t\t\t\t\t!this.editor.getSelectedShapeIds().includes(hoveredShape.id) &&\n\t\t\t\t\t\t\t!hoveredShape.isLocked\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\t\tshape: hoveredShape,\n\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.parent.transition('pointing_selection', info)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onDoubleClick(info: TLClickEventInfo) {\n\t\tif (this.editor.inputs.shiftKey || info.phase !== 'up') return\n\n\t\t// We don't want to double click while toggling shapes\n\t\tif (info.ctrlKey || info.shiftKey) return\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\n\t\t\t\t// todo\n\t\t\t\t// double clicking on the middle of a hollow geo shape without a label, or\n\t\t\t\t// over the label of a hollwo shape that has a label, should start editing\n\t\t\t\t// that shape's label. We can't support \"double click anywhere inside\"\n\t\t\t\t// of the shape yet because that also creates text shapes, and can produce\n\t\t\t\t// unexpected results when working \"inside of\" a hollow shape.\n\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: (this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ??\n\t\t\t\t\t\t\tthis.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t}))\n\n\t\t\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tif (this.editor.isShapeOfType(hitShape, 'group')) {\n\t\t\t\t\t\t// Probably select the shape\n\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst parent = this.editor.getShape(hitShape.parentId)\n\t\t\t\t\t\tif (parent && this.editor.isShapeOfType(parent, 'group')) {\n\t\t\t\t\t\t\t// The shape is the direct child of a group. If the group is\n\t\t\t\t\t\t\t// selected, then we can select the shape. If the group is the\n\t\t\t\t\t\t\t// focus layer id, then we can double click into it as usual.\n\t\t\t\t\t\t\tif (focusedGroupId && parent.id === focusedGroupId) {\n\t\t\t\t\t\t\t\t// noop, double click on the shape as normal below\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// The shape is the child of some group other than our current\n\t\t\t\t\t\t\t\t// focus layer. We should probably select the group instead.\n\t\t\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// double click on the shape. We'll start editing the\n\t\t\t\t\t// shape if it's editable or else do a double click on\n\t\t\t\t\t// the canvas.\n\t\t\t\t\tthis.onDoubleClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif (!this.editor.inputs.shiftKey) {\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\t\t\tif (onlySelectedShape) {\n\t\t\t\t\tconst util = this.editor.getShapeUtil(onlySelectedShape)\n\n\t\t\t\t\tif (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// Test edges for an onDoubleClickEdge handler\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'right' ||\n\t\t\t\t\t\tinfo.handle === 'left' ||\n\t\t\t\t\t\tinfo.handle === 'top' ||\n\t\t\t\t\t\tinfo.handle === 'bottom'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickEdge?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click edge')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tinfo.handle === 'top_left' ||\n\t\t\t\t\t\tinfo.handle === 'top_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_left'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst change = util.onDoubleClickCorner?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click corner')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// For corners OR edges but NOT rotation corners\n\t\t\t\t\tif (\n\t\t\t\t\t\tutil.canCrop(onlySelectedShape) &&\n\t\t\t\t\t\t!this.editor.isShapeOrAncestorLocked(onlySelectedShape)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\t\tthis.startEditingShape(onlySelectedShape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\n\t\t\t\t// Allow playing videos and embeds\n\t\t\t\tif (shape.type !== 'video' && shape.type !== 'embed' && this.editor.getIsReadonly()) break\n\n\t\t\t\tif (util.onDoubleClick) {\n\t\t\t\t\t// Call the shape's double click handler\n\t\t\t\t\tconst change = util.onDoubleClick?.(shape)\n\t\t\t\t\tif (change) {\n\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (util.canCrop(shape) && !this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\t// crop image etc on double click\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('select and crop')\n\t\t\t\t\tthis.editor.select(info.shape?.id)\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the shape can edit, then begin editing\n\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape cannot edit, then create a text shape and\n\t\t\t\t\t// begin editing the text shape\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tconst { shape, handle } = info\n\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tconst changes = util.onDoubleClickHandle?.(shape, handle)\n\n\t\t\t\tif (changes) {\n\t\t\t\t\tthis.editor.updateShapes([changes])\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape can edit, then begin editing the shape.\n\t\t\t\t\tif (this.shouldStartEditingShape(shape)) {\n\t\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onRightClick(info: TLPointerEventInfo) {\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t\thitLabels: true,\n\t\t\t\t\t\t\t\thitLocked: true,\n\t\t\t\t\t\t\t\thitFrameInside: true,\n\t\t\t\t\t\t\t\trenderingOnly: true,\n\t\t\t\t\t\t\t})\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst {\n\t\t\t\t\tinputs: { currentPagePoint },\n\t\t\t\t} = this.editor\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.editor.selectNone()\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { selectedShapeIds } = this.editor.getCurrentPageState()\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tconst targetShape = this.editor.getOutermostSelectableShape(\n\t\t\t\t\tshape,\n\t\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t\t)\n\n\t\t\t\tif (\n\t\t\t\t\t!selectedShapeIds.includes(targetShape.id) &&\n\t\t\t\t\t!this.editor.findShapeAncestor(targetShape, (shape) =>\n\t\t\t\t\t\tselectedShapeIds.includes(shape.id)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\t\t\tthis.editor.setSelectedShapes([targetShape.id])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tif (\n\t\t\tthis.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() &&\n\t\t\tthis.editor.getSelectedShapeIds().length > 0\n\t\t) {\n\t\t\tthis.editor.popFocusedGroupId()\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('clearing selection')\n\t\t\tthis.editor.selectNone()\n\t\t}\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tthis.selectedShapesOnKeyDown = this.editor.getSelectedShapes()\n\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tif (info.shiftKey) {\n\t\t\t\t\t\tif (info.code === 'ArrowDown') {\n\t\t\t\t\t\t\tthis.editor.selectFirstChildShape()\n\t\t\t\t\t\t} else if (info.code === 'ArrowUp') {\n\t\t\t\t\t\t\tthis.editor.selectParentShape()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(false)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (debugFlags['editOnType'].get()) {\n\t\t\t// This feature flag lets us start editing a note shape's label when a key is pressed.\n\t\t\t// We exclude certain keys to avoid conflicting with modifiers, but there are conflicts\n\t\t\t// with other action kbds, hence why this is kept behind a feature flag.\n\t\t\tif (!SKIPPED_KEYS_FOR_AUTO_EDITING.includes(info.key) && !info.altKey && !info.ctrlKey) {\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (\n\t\t\t\t\tonlySelectedShape &&\n\t\t\t\t\t// If it's a note shape, then edit on type\n\t\t\t\t\tthis.editor.isShapeOfType(onlySelectedShape, 'note') &&\n\t\t\t\t\t// If it's not locked or anything\n\t\t\t\t\tthis.shouldStartEditingShape(onlySelectedShape)\n\t\t\t\t) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyRepeat(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(true)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length && !info.altKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\t// Because Enter onKeyDown can happen outside the canvas (but then focus the canvas potentially),\n\t\t\t\t// we need to check if the canvas was initially selecting something before continuing.\n\t\t\t\tif (!this.selectedShapesOnKeyDown.length) return\n\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\n\t\t\t\t// On enter, if every selected shape is a group, then select all of the children of the groups\n\t\t\t\tif (selectedShapes.every((shape) => this.editor.isShapeOfType(shape, 'group'))) {\n\t\t\t\t\tthis.editor.setSelectedShapes(\n\t\t\t\t\t\tselectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is croppable, then begin cropping it\n\t\t\t\tif (getShouldEnterCropMode(this.editor)) {\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length && !info.altKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate shouldStartEditingShape(\n\t\tshape: TLShape | null = this.editor.getOnlySelectedShape()\n\t): boolean {\n\t\tif (!shape) return false\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return false\n\t\tif (!this.canInteractWithShapeInReadOnly(shape)) return false\n\t\treturn this.editor.getShapeUtil(shape).canEdit(shape)\n\t}\n\n\tprivate startEditingShape(\n\t\tshape: TLShape,\n\t\tinfo: TLClickEventInfo | TLKeyboardEventInfo,\n\t\tshouldSelectAll?: boolean\n\t) {\n\t\tif (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return\n\t\tthis.editor.markHistoryStoppingPoint('editing shape')\n\t\tstartEditingShapeWithLabel(this.editor, shape, shouldSelectAll)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tisOverArrowLabelTest(shape: TLShape | undefined) {\n\t\tif (!shape) return false\n\n\t\treturn isOverArrowLabel(this.editor, shape)\n\t}\n\n\thandleDoubleClickOnCanvas(info: TLClickEventInfo) {\n\t\t// Create text shape and transition to editing_shape\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\tif (!this.editor.options.createTextOnCanvasDoubleClick) return\n\n\t\tthis.editor.markHistoryStoppingPoint('creating text shape')\n\n\t\tconst id = createShapeId()\n\n\t\tconst { x, y } = this.editor.inputs.currentPagePoint\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShapes([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'text',\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tprops: {\n\t\t\t\t\trichText: toRichText(''),\n\t\t\t\t\tautoSize: true,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape(id)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(shape)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.setEditingShape(id)\n\t\tthis.editor.select(id)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tprivate nudgeSelectedShapes(ephemeral = false) {\n\t\tconst {\n\t\t\teditor: {\n\t\t\t\tinputs: { keys },\n\t\t\t},\n\t\t} = this\n\n\t\t// We want to use the \"actual\" shift key state,\n\t\t// not the one that's in the editor.inputs.shiftKey,\n\t\t// because that one uses a short timeout on release\n\t\tconst shiftKey = keys.has('ShiftLeft')\n\n\t\tconst delta = new Vec(0, 0)\n\n\t\tif (keys.has('ArrowLeft')) delta.x -= 1\n\t\tif (keys.has('ArrowRight')) delta.x += 1\n\t\tif (keys.has('ArrowUp')) delta.y -= 1\n\t\tif (keys.has('ArrowDown')) delta.y += 1\n\n\t\tif (delta.equals(new Vec(0, 0))) return\n\n\t\tif (!ephemeral) this.editor.markHistoryStoppingPoint('nudge shapes')\n\n\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\n\t\tconst step = this.editor.getInstanceState().isGridMode\n\t\t\t? shiftKey\n\t\t\t\t? gridSize * GRID_INCREMENT\n\t\t\t\t: gridSize\n\t\t\t: shiftKey\n\t\t\t\t? MAJOR_NUDGE_FACTOR\n\t\t\t\t: MINOR_NUDGE_FACTOR\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tthis.editor.nudgeShapes(selectedShapeIds, delta.mul(step))\n\t\tkickoutOccludedShapes(this.editor, selectedShapeIds)\n\t}\n\n\tprivate canInteractWithShapeInReadOnly(shape: TLShape) {\n\t\tif (!this.editor.getIsReadonly()) return true\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (util.canEditInReadonly(shape)) return true\n\t\treturn false\n\t}\n}\n\nexport const MAJOR_NUDGE_FACTOR = 10\nexport const MINOR_NUDGE_FACTOR = 1\nexport const GRID_INCREMENT = 5\n\nfunction isPointInRotatedSelectionBounds(editor: Editor, point: VecLike) {\n\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\tif (!selectionBounds) return false\n\n\tconst selectionRotation = editor.getSelectionRotation()\n\tif (!selectionRotation) return selectionBounds.containsPoint(point)\n\n\treturn pointInPolygon(\n\t\tpoint,\n\t\tselectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))\n\t)\n}\n"],
5
- "mappings": "AAAA;AAAA,EAEC;AAAA,EAMA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AACjC,SAAS,sCAAsC;AAC/C,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC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+BAA+B,OAAgB;AACtD,QAAI,CAAC,KAAK,OAAO,cAAc,EAAG,QAAO;AACzC,UAAM,OAAO,KAAK,OAAO,aAAa,KAAK;AAC3C,QAAI,KAAK,kBAAkB,KAAK,EAAG,QAAO;AAC1C,WAAO;AAAA,EACR;AACD;AAEO,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB;AAE9B,SAAS,gCAAgC,QAAgB,OAAgB;AACxE,QAAM,kBAAkB,OAAO,8BAA8B;AAC7D,MAAI,CAAC,gBAAiB,QAAO;AAE7B,QAAM,oBAAoB,OAAO,qBAAqB;AACtD,MAAI,CAAC,kBAAmB,QAAO,gBAAgB,cAAc,KAAK;AAElE,SAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
4
+ "sourcesContent": ["import {\n\tEditor,\n\tStateNode,\n\tTLAdjacentDirection,\n\tTLClickEventInfo,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tcreateShapeId,\n\tdebugFlags,\n\tkickoutOccludedShapes,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\nimport { hasRichText, startEditingShapeWithRichText } from '../selectHelpers'\n\nconst SKIPPED_KEYS_FOR_AUTO_EDITING = [\n\t'Delete',\n\t'Backspace',\n\t'[',\n\t']',\n\t'Enter',\n\t' ',\n\t'Shift',\n\t'Tab',\n]\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\tselectedShapesOnKeyDown: TLShape[] = []\n\n\toverride onEnter() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.selectedShapesOnKeyDown = []\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onExit() {\n\t\tupdateHoveredShapeId.cancel()\n\t}\n\n\toverride onPointerMove() {\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\t// Check to see if we hit any shape under the pointer; if so,\n\t\t\t\t// handle this as a pointer down on the shape instead of the canvas\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor)\n\t\t\t\tif (hitShape && !hitShape.isLocked) {\n\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tif (this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\tthis.parent.transition('pointing_canvas', info)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tif (this.editor.inputs.getAltKey()) {\n\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t} else {\n\t\t\t\t\t// If we're holding ctrl key, we might select it, or start brushing...\n\t\t\t\t\tthis.parent.transition('pointing_handle', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tswitch (info.handle) {\n\t\t\t\t\tcase 'mobile_rotate':\n\t\t\t\t\tcase 'top_left_rotate':\n\t\t\t\t\tcase 'top_right_rotate':\n\t\t\t\t\tcase 'bottom_left_rotate':\n\t\t\t\t\tcase 'bottom_right_rotate': {\n\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.parent.transition('pointing_rotate_handle', info)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'top':\n\t\t\t\t\tcase 'right':\n\t\t\t\t\tcase 'bottom':\n\t\t\t\t\tcase 'left':\n\t\t\t\t\tcase 'top_left':\n\t\t\t\t\tcase 'top_right':\n\t\t\t\t\tcase 'bottom_left':\n\t\t\t\t\tcase 'bottom_right': {\n\t\t\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\t\t\tif (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {\n\t\t\t\t\t\t\tthis.parent.transition('crop.pointing_crop_handle', info)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (info.accelKey) {\n\t\t\t\t\t\t\t\tthis.parent.transition('brushing', info)\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.parent.transition('pointing_resize_handle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thoveredShape &&\n\t\t\t\t\t\t\t!this.editor.getSelectedShapeIds().includes(hoveredShape.id) &&\n\t\t\t\t\t\t\t!hoveredShape.isLocked\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\t\tshape: hoveredShape,\n\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.parent.transition('pointing_selection', info)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onDoubleClick(info: TLClickEventInfo) {\n\t\tif (this.editor.inputs.getShiftKey() || info.phase !== 'up') return\n\n\t\t// We don't want to double click while toggling shapes\n\t\tif (info.ctrlKey || info.shiftKey) return\n\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\n\t\t\t\t// todo\n\t\t\t\t// double clicking on the middle of a hollow geo shape without a label, or\n\t\t\t\t// over the label of a hollwo shape that has a label, should start editing\n\t\t\t\t// that shape's label. We can't support \"double click anywhere inside\"\n\t\t\t\t// of the shape yet because that also creates text shapes, and can produce\n\t\t\t\t// unexpected results when working \"inside of\" a hollow shape.\n\n\t\t\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: (this.editor.getSelectedShapeAtPoint(currentPagePoint) ??\n\t\t\t\t\t\t\tthis.editor.getShapeAtPoint(currentPagePoint, {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t}))\n\n\t\t\t\tconst focusedGroupId = this.editor.getFocusedGroupId()\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tif (this.editor.isShapeOfType(hitShape, 'group')) {\n\t\t\t\t\t\t// Probably select the shape\n\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst parent = this.editor.getShape(hitShape.parentId)\n\t\t\t\t\t\tif (parent && this.editor.isShapeOfType(parent, 'group')) {\n\t\t\t\t\t\t\t// The shape is the direct child of a group. If the group is\n\t\t\t\t\t\t\t// selected, then we can select the shape. If the group is the\n\t\t\t\t\t\t\t// focus layer id, then we can double click into it as usual.\n\t\t\t\t\t\t\tif (focusedGroupId && parent.id === focusedGroupId) {\n\t\t\t\t\t\t\t\t// noop, double click on the shape as normal below\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// The shape is the child of some group other than our current\n\t\t\t\t\t\t\t\t// focus layer. We should probably select the group instead.\n\t\t\t\t\t\t\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// double click on the shape. We'll start editing the\n\t\t\t\t\t// shape if it's editable or else do a double click on\n\t\t\t\t\t// the canvas.\n\t\t\t\t\tthis.onDoubleClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif (!this.editor.inputs.getShiftKey()) {\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'selection': {\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\n\t\t\t\tif (onlySelectedShape) {\n\t\t\t\t\tconst util = this.editor.getShapeUtil(onlySelectedShape)\n\t\t\t\t\tconst isEdge =\n\t\t\t\t\t\tinfo.handle === 'right' ||\n\t\t\t\t\t\tinfo.handle === 'left' ||\n\t\t\t\t\t\tinfo.handle === 'top' ||\n\t\t\t\t\t\tinfo.handle === 'bottom'\n\t\t\t\t\tconst isCorner =\n\t\t\t\t\t\tinfo.handle === 'top_left' ||\n\t\t\t\t\t\tinfo.handle === 'top_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_right' ||\n\t\t\t\t\t\tinfo.handle === 'bottom_left'\n\n\t\t\t\t\tif (this.editor.getIsReadonly()) {\n\t\t\t\t\t\t// includes readonly check\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tthis.editor.canEditShape(onlySelectedShape, {\n\t\t\t\t\t\t\t\ttype: isCorner\n\t\t\t\t\t\t\t\t\t? 'double-click-corner'\n\t\t\t\t\t\t\t\t\t: isEdge\n\t\t\t\t\t\t\t\t\t\t? 'double-click-edge'\n\t\t\t\t\t\t\t\t\t\t: 'double-click',\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthis.startEditingShape(onlySelectedShape, info, true /* select all */)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\t// Test edges for an onDoubleClickEdge handler\n\t\t\t\t\tif (isEdge) {\n\t\t\t\t\t\tconst change = util.onDoubleClickEdge?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click edge')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isCorner) {\n\t\t\t\t\t\tconst change = util.onDoubleClickCorner?.(onlySelectedShape, info)\n\t\t\t\t\t\tif (change) {\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('double click corner')\n\t\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\t\tkickoutOccludedShapes(this.editor, [onlySelectedShape.id])\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// For corners OR edges but NOT rotation corners\n\t\t\t\t\tif (this.editor.canCropShape(onlySelectedShape)) {\n\t\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.editor.canEditShape(onlySelectedShape)) {\n\t\t\t\t\t\tthis.startEditingShape(onlySelectedShape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape } = info\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\n\t\t\t\t// Allow playing videos and embeds\n\t\t\t\tif (shape.type !== 'video' && shape.type !== 'embed' && this.editor.getIsReadonly()) break\n\n\t\t\t\tif (util.onDoubleClick) {\n\t\t\t\t\t// Call the shape's double click handler\n\t\t\t\t\tconst change = util.onDoubleClick?.(shape)\n\t\t\t\t\tif (change) {\n\t\t\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (util.canCrop(shape) && !this.editor.isShapeOrAncestorLocked(shape)) {\n\t\t\t\t\t// crop image etc on double click\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('select and crop')\n\t\t\t\t\tthis.editor.select(info.shape?.id)\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the shape can edit, then begin editing\n\t\t\t\tif (this.editor.canEditShape(shape)) {\n\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape cannot edit, then create a text shape and\n\t\t\t\t\t// begin editing the text shape\n\t\t\t\t\tthis.handleDoubleClickOnCanvas(info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'handle': {\n\t\t\t\tif (this.editor.getIsReadonly()) break\n\t\t\t\tconst { shape, handle } = info\n\n\t\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\t\tconst changes = util.onDoubleClickHandle?.(shape, handle)\n\n\t\t\t\tif (changes) {\n\t\t\t\t\tthis.editor.updateShapes([changes])\n\t\t\t\t} else {\n\t\t\t\t\t// If the shape's double click handler has not created a change,\n\t\t\t\t\t// and if the shape can edit, then begin editing the shape.\n\t\t\t\t\tif (this.editor.canEditShape(shape)) {\n\t\t\t\t\t\tthis.startEditingShape(shape, info, true /* select all */)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onRightClick(info: TLPointerEventInfo) {\n\t\tswitch (info.target) {\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hoveredShape = this.editor.getHoveredShape()\n\t\t\t\tconst hitShape =\n\t\t\t\t\thoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')\n\t\t\t\t\t\t? hoveredShape\n\t\t\t\t\t\t: this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(), {\n\t\t\t\t\t\t\t\tmargin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),\n\t\t\t\t\t\t\t\thitInside: false,\n\t\t\t\t\t\t\t\thitLabels: true,\n\t\t\t\t\t\t\t\thitLocked: true,\n\t\t\t\t\t\t\t\thitFrameInside: true,\n\t\t\t\t\t\t\t\trenderingOnly: true,\n\t\t\t\t\t\t\t})\n\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\n\t\t\t\tif (\n\t\t\t\t\tselectedShapeIds.length > 1 ||\n\t\t\t\t\t(onlySelectedShape &&\n\t\t\t\t\t\t!this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape))\n\t\t\t\t) {\n\t\t\t\t\tif (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {\n\t\t\t\t\t\tthis.onRightClick({\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.editor.selectNone()\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { selectedShapeIds } = this.editor.getCurrentPageState()\n\t\t\t\tconst { shape } = info\n\n\t\t\t\tconst targetShape = this.editor.getOutermostSelectableShape(\n\t\t\t\t\tshape,\n\t\t\t\t\t(parent) => !selectedShapeIds.includes(parent.id)\n\t\t\t\t)\n\n\t\t\t\tif (\n\t\t\t\t\t!selectedShapeIds.includes(targetShape.id) &&\n\t\t\t\t\t!this.editor.findShapeAncestor(targetShape, (shape) =>\n\t\t\t\t\t\tselectedShapeIds.includes(shape.id)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting shape')\n\t\t\t\t\tthis.editor.setSelectedShapes([targetShape.id])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tif (\n\t\t\tthis.editor.getFocusedGroupId() !== this.editor.getCurrentPageId() &&\n\t\t\tthis.editor.getSelectedShapeIds().length > 0\n\t\t) {\n\t\t\tthis.editor.popFocusedGroupId()\n\t\t} else {\n\t\t\tthis.editor.markHistoryStoppingPoint('clearing selection')\n\t\t\tthis.editor.selectNone()\n\t\t}\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tthis.selectedShapesOnKeyDown = this.editor.getSelectedShapes()\n\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tif (info.shiftKey) {\n\t\t\t\t\t\tif (info.code === 'ArrowDown') {\n\t\t\t\t\t\t\tthis.editor.selectFirstChildShape()\n\t\t\t\t\t\t} else if (info.code === 'ArrowUp') {\n\t\t\t\t\t\t\tthis.editor.selectParentShape()\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(false)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (debugFlags['editOnType'].get()) {\n\t\t\t// This feature flag lets us start editing a note shape's label when a key is pressed.\n\t\t\t// We exclude certain keys to avoid conflicting with modifiers, but there are conflicts\n\t\t\t// with other action kbds, hence why this is kept behind a feature flag.\n\t\t\tif (!SKIPPED_KEYS_FOR_AUTO_EDITING.includes(info.key) && !info.altKey && !info.ctrlKey) {\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (\n\t\t\t\t\tonlySelectedShape &&\n\t\t\t\t\t// If it's a note shape, then edit on type\n\t\t\t\t\tthis.editor.isShapeOfType(onlySelectedShape, 'note') &&\n\t\t\t\t\t// If it's not locked or anything\n\t\t\t\t\tthis.editor.canEditShape(onlySelectedShape)\n\t\t\t\t) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyRepeat(info: TLKeyboardEventInfo) {\n\t\tswitch (info.code) {\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\tcase 'ArrowUp':\n\t\t\tcase 'ArrowDown': {\n\t\t\t\tif (info.accelKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(\n\t\t\t\t\t\tinfo.code.replace('Arrow', '').toLowerCase() as TLAdjacentDirection\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.nudgeSelectedShapes(true)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length && !info.altKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\t// Because Enter onKeyDown can happen outside the canvas (but then focus the canvas potentially),\n\t\t\t\t// we need to check if the canvas was initially selecting something before continuing.\n\t\t\t\tif (!this.selectedShapesOnKeyDown.length) return\n\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\n\t\t\t\t// On enter, if every selected shape is a group, then select all of the children of the groups\n\t\t\t\tif (selectedShapes.every((shape) => this.editor.isShapeOfType(shape, 'group'))) {\n\t\t\t\t\tthis.editor.setSelectedShapes(\n\t\t\t\t\t\tselectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is editable, then begin editing it\n\t\t\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\t\t\tif (\n\t\t\t\t\tonlySelectedShape &&\n\t\t\t\t\tthis.editor.canEditShape(onlySelectedShape, { type: 'press_enter' })\n\t\t\t\t) {\n\t\t\t\t\tthis.startEditingShape(\n\t\t\t\t\t\tonlySelectedShape,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...info,\n\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\tshape: onlySelectedShape,\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttrue /* select all */\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// If the only selected shape is croppable, then begin cropping it\n\t\t\t\tif (this.editor.canCropShape(onlySelectedShape)) {\n\t\t\t\t\tthis.parent.transition('crop', info)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Tab': {\n\t\t\t\tconst selectedShapes = this.editor.getSelectedShapes()\n\t\t\t\tif (selectedShapes.length && !info.altKey) {\n\t\t\t\t\tthis.editor.selectAdjacentShape(info.shiftKey ? 'prev' : 'next')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate startEditingShape(\n\t\tshape: TLShape,\n\t\tinfo: TLClickEventInfo | TLKeyboardEventInfo,\n\t\tshouldSelectAll?: boolean\n\t) {\n\t\tconst { editor } = this\n\t\tthis.editor.markHistoryStoppingPoint('editing shape')\n\t\tif (hasRichText(shape)) {\n\t\t\tstartEditingShapeWithRichText(editor, shape, { selectAll: shouldSelectAll })\n\t\t} else {\n\t\t\teditor.setEditingShape(shape)\n\t\t}\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tisOverArrowLabelTest(shape: TLShape | undefined) {\n\t\tif (!shape) return false\n\n\t\treturn isOverArrowLabel(this.editor, shape)\n\t}\n\n\thandleDoubleClickOnCanvas(info: TLClickEventInfo) {\n\t\t// Create text shape and transition to editing_shape\n\t\tif (this.editor.getIsReadonly()) return\n\n\t\tif (!this.editor.options.createTextOnCanvasDoubleClick) return\n\n\t\tthis.editor.markHistoryStoppingPoint('creating text shape')\n\n\t\tconst id = createShapeId()\n\n\t\tconst { x, y } = this.editor.inputs.getCurrentPagePoint()\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShapes([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'text',\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tprops: {\n\t\t\t\t\trichText: toRichText(''),\n\t\t\t\t\tautoSize: true,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape(id)\n\t\tif (!shape) return\n\n\t\tif (!this.editor.canEditShape(shape)) return\n\n\t\tstartEditingShapeWithRichText(this.editor, id, { info })\n\t}\n\n\tprivate nudgeSelectedShapes(ephemeral = false) {\n\t\tconst {\n\t\t\teditor: {\n\t\t\t\tinputs: { keys },\n\t\t\t},\n\t\t} = this\n\n\t\t// We want to use the \"actual\" shift key state,\n\t\t// not the one that's in the editor.inputs.shiftKey,\n\t\t// because that one uses a short timeout on release\n\t\tconst shiftKey = keys.has('ShiftLeft')\n\n\t\tconst delta = new Vec(0, 0)\n\n\t\tif (keys.has('ArrowLeft')) delta.x -= 1\n\t\tif (keys.has('ArrowRight')) delta.x += 1\n\t\tif (keys.has('ArrowUp')) delta.y -= 1\n\t\tif (keys.has('ArrowDown')) delta.y += 1\n\n\t\tif (delta.equals(new Vec(0, 0))) return\n\n\t\tif (!ephemeral) this.editor.markHistoryStoppingPoint('nudge shapes')\n\n\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\n\t\tconst step = this.editor.getInstanceState().isGridMode\n\t\t\t? shiftKey\n\t\t\t\t? gridSize * GRID_INCREMENT\n\t\t\t\t: gridSize\n\t\t\t: shiftKey\n\t\t\t\t? MAJOR_NUDGE_FACTOR\n\t\t\t\t: MINOR_NUDGE_FACTOR\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tthis.editor.nudgeShapes(selectedShapeIds, delta.mul(step))\n\t\tkickoutOccludedShapes(this.editor, selectedShapeIds)\n\t}\n}\n\nexport const MAJOR_NUDGE_FACTOR = 10\nexport const MINOR_NUDGE_FACTOR = 1\nexport const GRID_INCREMENT = 5\n\nfunction isPointInRotatedSelectionBounds(editor: Editor, point: VecLike) {\n\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\tif (!selectionBounds) return false\n\n\tconst selectionRotation = editor.getSelectionRotation()\n\tif (!selectionRotation) return selectionBounds.containsPoint(point)\n\n\treturn pointInPolygon(\n\t\tpoint,\n\t\tselectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))\n\t)\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EAMA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AACjC,SAAS,sCAAsC;AAC/C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,aAAa,qCAAqC;AAE3D,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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AA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
6
6
  "names": ["shape"]
7
7
  }
@@ -6,6 +6,7 @@ import {
6
6
  getArrowBodyGeometry,
7
7
  getArrowLabelDefaultPosition
8
8
  } from "../../../shapes/arrow/arrowLabel.mjs";
9
+ import { startEditingShapeWithRichText } from "../selectHelpers.mjs";
9
10
  class PointingArrowLabel extends StateNode {
10
11
  static id = "pointing_arrow_label";
11
12
  shapeId = "";
@@ -33,7 +34,7 @@ class PointingArrowLabel extends StateNode {
33
34
  if (!labelGeometry) {
34
35
  throw Error(`Expected to find an arrow label geometry for shape: ${shape.id}`);
35
36
  }
36
- const { currentPagePoint } = this.editor.inputs;
37
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
37
38
  const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint);
38
39
  this._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace);
39
40
  this.markId = this.editor.markHistoryStoppingPoint("label-drag start");
@@ -51,7 +52,7 @@ class PointingArrowLabel extends StateNode {
51
52
  }
52
53
  _labelDragOffset = new Vec(0, 0);
53
54
  onPointerMove() {
54
- const { isDragging } = this.editor.inputs;
55
+ const isDragging = this.editor.inputs.getIsDragging();
55
56
  if (!isDragging) return;
56
57
  if (this.didCtrlOnEnter) {
57
58
  this.parent.transition("brushing", this.info);
@@ -62,7 +63,7 @@ class PointingArrowLabel extends StateNode {
62
63
  const options = this.editor.getShapeUtil("arrow").options;
63
64
  const geometry = getArrowBodyGeometry(this.editor, shape);
64
65
  const transform = this.editor.getShapePageTransform(shape.id);
65
- const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint).add(this._labelDragOffset);
66
+ const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset);
66
67
  const defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape);
67
68
  let nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace);
68
69
  if (isNaN(nextLabelPosition)) {
@@ -91,9 +92,8 @@ class PointingArrowLabel extends StateNode {
91
92
  if (!shape) return;
92
93
  if (this.didDrag || !this.wasAlreadySelected) {
93
94
  this.complete();
94
- } else if (!this.editor.getIsReadonly()) {
95
- this.editor.setEditingShape(shape.id);
96
- this.editor.setCurrentTool("select.editing_shape");
95
+ } else if (this.editor.canEditShape(shape)) {
96
+ startEditingShapeWithRichText(this.editor, shape.id);
97
97
  }
98
98
  }
99
99
  onCancel() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts"],
4
- "sourcesContent": ["import {\n\tGroup2d,\n\tStateNode,\n\tTLArrowShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tVec,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport {\n\tgetArrowBodyGeometry,\n\tgetArrowLabelDefaultPosition,\n} from '../../../shapes/arrow/arrowLabel'\n\nexport class PointingArrowLabel extends StateNode {\n\tstatic override id = 'pointing_arrow_label'\n\n\tshapeId = '' as TLShapeId\n\tmarkId = ''\n\twasAlreadySelected = false\n\tdidDrag = false\n\tdidCtrlOnEnter = false\n\n\tprivate info = {} as TLPointerEventInfo & {\n\t\tshape: TLArrowShape\n\t\tonInteractionEnd?: string | (() => void)\n\t\tisCreating: boolean\n\t}\n\n\tprivate updateCursor() {\n\t\tthis.editor.setCursor({ type: 'grabbing', rotation: 0 })\n\t}\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\tshape: TLArrowShape\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t\tisCreating: boolean\n\t\t}\n\t) {\n\t\tconst { shape } = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.info = info\n\t\tthis.shapeId = shape.id\n\t\tthis.didDrag = false\n\t\tthis.didCtrlOnEnter = info.accelKey\n\t\tthis.wasAlreadySelected = this.editor.getOnlySelectedShapeId() === shape.id\n\t\tthis.updateCursor()\n\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst labelGeometry = geometry.children[1]\n\t\tif (!labelGeometry) {\n\t\t\tthrow Error(`Expected to find an arrow label geometry for shape: ${shape.id}`)\n\t\t}\n\t\tconst { currentPagePoint } = this.editor.inputs\n\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint)\n\n\t\tthis._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace)\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('label-drag start')\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\t\tif (additiveSelectionKey) {\n\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, this.shapeId])\n\n\t\t\treturn\n\t\t}\n\n\t\tthis.editor.setSelectedShapes([this.shapeId])\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate _labelDragOffset = new Vec(0, 0)\n\n\toverride onPointerMove() {\n\t\tconst { isDragging } = this.editor.inputs\n\t\tif (!isDragging) return\n\n\t\tif (this.didCtrlOnEnter) {\n\t\t\tthis.parent.transition('brushing', this.info)\n\t\t\treturn\n\t\t}\n\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tconst options = this.editor.getShapeUtil<ArrowShapeUtil>('arrow').options\n\t\tconst geometry = getArrowBodyGeometry(this.editor, shape)\n\t\tconst transform = this.editor.getShapePageTransform(shape.id)\n\n\t\tconst pointInShapeSpace = this.editor\n\t\t\t.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint)\n\t\t\t.add(this._labelDragOffset)\n\n\t\tconst defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\n\t\tlet nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace)\n\n\t\tif (isNaN(nextLabelPosition)) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tconst nextLabelPoint = transform.applyToPoint(geometry.interpolateAlongEdge(nextLabelPosition))\n\t\tconst labelDefaultPoint = transform.applyToPoint(\n\t\t\tgeometry.interpolateAlongEdge(defaultLabelPosition)\n\t\t)\n\n\t\tif (\n\t\t\tVec.DistMin(\n\t\t\t\tnextLabelPoint,\n\t\t\t\tlabelDefaultPoint,\n\t\t\t\toptions.labelCenterSnapDistance / this.editor.getZoomLevel()\n\t\t\t)\n\t\t) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tthis.didDrag = true\n\t\tthis.editor.updateShape({\n\t\t\tid: shape.id,\n\t\t\ttype: shape.type,\n\t\t\tprops: { labelPosition: nextLabelPosition },\n\t\t})\n\t}\n\n\toverride onPointerUp() {\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tif (this.didDrag || !this.wasAlreadySelected) {\n\t\t\tthis.complete()\n\t\t} else if (!this.editor.getIsReadonly()) {\n\t\t\t// Go into edit mode.\n\t\t\tthis.editor.setEditingShape(shape.id)\n\t\t\tthis.editor.setCurrentTool('select.editing_shape')\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\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 cancel() {\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"],
5
- "mappings": "AAAA;AAAA,EAEC;AAAA,EAIA;AAAA,OACM;AAEP;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAEA,MAAM,2BAA2B,UAAU;AAAA,EACjD,OAAgB,KAAK;AAAA,EAErB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,UAAU;AAAA,EACV,iBAAiB;AAAA,EAET,OAAO,CAAC;AAAA,EAMR,eAAe;AACtB,SAAK,OAAO,UAAU,EAAE,MAAM,YAAY,UAAU,EAAE,CAAC;AAAA,EACxD;AAAA,EAES,QACR,MAKC;AACD,UAAM,EAAE,MAAM,IAAI;AAClB,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AACA,SAAK,OAAO;AACZ,SAAK,UAAU,MAAM;AACrB,SAAK,UAAU;AACf,SAAK,iBAAiB,KAAK;AAC3B,SAAK,qBAAqB,KAAK,OAAO,uBAAuB,MAAM,MAAM;AACzE,SAAK,aAAa;AAElB,UAAM,WAAW,KAAK,OAAO,iBAA0B,KAAK;AAC5D,UAAM,gBAAgB,SAAS,SAAS,CAAC;AACzC,QAAI,CAAC,eAAe;AACnB,YAAM,MAAM,uDAAuD,MAAM,EAAE,EAAE;AAAA,IAC9E;AACA,UAAM,EAAE,iBAAiB,IAA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AkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,CAAC,CAAC;AAAA,MAChD,OAAO;AACN,yBAAiB;AAAA,MAClB;AACA;AAAA,IACD;AACA,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import {\n\tGroup2d,\n\tStateNode,\n\tTLArrowShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tVec,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport {\n\tgetArrowBodyGeometry,\n\tgetArrowLabelDefaultPosition,\n} from '../../../shapes/arrow/arrowLabel'\nimport { startEditingShapeWithRichText } from '../selectHelpers'\n\nexport class PointingArrowLabel extends StateNode {\n\tstatic override id = 'pointing_arrow_label'\n\n\tshapeId = '' as TLShapeId\n\tmarkId = ''\n\twasAlreadySelected = false\n\tdidDrag = false\n\tdidCtrlOnEnter = false\n\n\tprivate info = {} as TLPointerEventInfo & {\n\t\tshape: TLArrowShape\n\t\tonInteractionEnd?: string | (() => void)\n\t\tisCreating: boolean\n\t}\n\n\tprivate updateCursor() {\n\t\tthis.editor.setCursor({ type: 'grabbing', rotation: 0 })\n\t}\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\tshape: TLArrowShape\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t\tisCreating: boolean\n\t\t}\n\t) {\n\t\tconst { shape } = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.info = info\n\t\tthis.shapeId = shape.id\n\t\tthis.didDrag = false\n\t\tthis.didCtrlOnEnter = info.accelKey\n\t\tthis.wasAlreadySelected = this.editor.getOnlySelectedShapeId() === shape.id\n\t\tthis.updateCursor()\n\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst labelGeometry = geometry.children[1]\n\t\tif (!labelGeometry) {\n\t\t\tthrow Error(`Expected to find an arrow label geometry for shape: ${shape.id}`)\n\t\t}\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint)\n\n\t\tthis._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace)\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('label-drag start')\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\t\tif (additiveSelectionKey) {\n\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, this.shapeId])\n\n\t\t\treturn\n\t\t}\n\n\t\tthis.editor.setSelectedShapes([this.shapeId])\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate _labelDragOffset = new Vec(0, 0)\n\n\toverride onPointerMove() {\n\t\tconst isDragging = this.editor.inputs.getIsDragging()\n\t\tif (!isDragging) return\n\n\t\tif (this.didCtrlOnEnter) {\n\t\t\tthis.parent.transition('brushing', this.info)\n\t\t\treturn\n\t\t}\n\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tconst options = this.editor.getShapeUtil<ArrowShapeUtil>('arrow').options\n\t\tconst geometry = getArrowBodyGeometry(this.editor, shape)\n\t\tconst transform = this.editor.getShapePageTransform(shape.id)\n\n\t\tconst pointInShapeSpace = this.editor\n\t\t\t.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint())\n\t\t\t.add(this._labelDragOffset)\n\n\t\tconst defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\n\t\tlet nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace)\n\n\t\tif (isNaN(nextLabelPosition)) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tconst nextLabelPoint = transform.applyToPoint(geometry.interpolateAlongEdge(nextLabelPosition))\n\t\tconst labelDefaultPoint = transform.applyToPoint(\n\t\t\tgeometry.interpolateAlongEdge(defaultLabelPosition)\n\t\t)\n\n\t\tif (\n\t\t\tVec.DistMin(\n\t\t\t\tnextLabelPoint,\n\t\t\t\tlabelDefaultPoint,\n\t\t\t\toptions.labelCenterSnapDistance / this.editor.getZoomLevel()\n\t\t\t)\n\t\t) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tthis.didDrag = true\n\t\tthis.editor.updateShape({\n\t\t\tid: shape.id,\n\t\t\ttype: shape.type,\n\t\t\tprops: { labelPosition: nextLabelPosition },\n\t\t})\n\t}\n\n\toverride onPointerUp() {\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tif (this.didDrag || !this.wasAlreadySelected) {\n\t\t\tthis.complete()\n\t\t} else if (this.editor.canEditShape(shape)) {\n\t\t\tstartEditingShapeWithRichText(this.editor, shape.id)\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\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 cancel() {\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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SAAK,UAAU;AACf,SAAK,OAAO,YAAY;AAAA,MACvB,IAAI,MAAM;AAAA,MACV,MAAM,MAAM;AAAA,MACZ,OAAO,EAAE,eAAe,kBAAkB;AAAA,IAC3C,CAAC;AAAA,EACF;AAAA,EAES,cAAc;AACtB,UAAM,QAAQ,KAAK,OAAO,SAAuB,KAAK,OAAO;AAC7D,QAAI,CAAC,MAAO;AAEZ,QAAI,KAAK,WAAW,CAAC,KAAK,oBAAoB;AAC7C,WAAK,SAAS;AAAA,IACf,WAAW,KAAK,OAAO,aAAa,KAAK,GAAG;AAC3C,oCAA8B,KAAK,QAAQ,MAAM,EAAE;AAAA,IACpD;AAAA,EACD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,cAAc;AACtB,SAAK,OAAO;AAAA,EACb;AAAA,EAEQ,WAAW;AAClB,UAAM,EAAE,iBAAiB,IAAI,KAAK;AAClC,QAAI,kBAAkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,CAAC,CAAC;AAAA,MAChD,OAAO;AACN,yBAAiB;AAAA,MAClB;AACA;AAAA,IACD;AACA,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,KAAK,MAAM;AAElC,UAAM,EAAE,iBAAiB,IAAI,KAAK;AAClC,QAAI,kBAAkB;AACrB,UAAI,OAAO,qBAAqB,UAAU;AACzC,aAAK,OAAO,eAAe,kBAAkB,CAAC,CAAC;AAAA,MAChD,OAAO;AACN,yBAAiB;AAAA,MAClB;AACA;AAAA,IACD;AACA,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,7 @@ class PointingCanvas extends StateNode {
12
12
  }
13
13
  }
14
14
  onPointerMove(info) {
15
- if (this.editor.inputs.isDragging) {
15
+ if (this.editor.inputs.getIsDragging()) {
16
16
  this.parent.transition("brushing", info);
17
17
  }
18
18
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingCanvas.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\n\nexport class PointingCanvas extends StateNode {\n\tstatic override id = 'pointing_canvas'\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tif (!additiveSelectionKey) {\n\t\t\tif (this.editor.getSelectedShapeIds().length > 0) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting none')\n\t\t\t\tthis.editor.selectNone()\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tthis.parent.transition('brushing', info)\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// todo: also make this deselect\n\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": "AAAA,SAAS,iBAAqC;AAC9C,SAAS,+BAA+B;AAEjC,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAEZ,QAAQ,MAAiD;AACjE,UAAM,uBAAuB,KAAK,YAAY,KAAK;AAEnD,QAAI,CAAC,sBAAsB;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,SAAS,GAAG;AACjD,aAAK,OAAO,yBAAyB,gBAAgB;AACrD,aAAK,OAAO,WAAW;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,WAAK,OAAO,WAAW,YAAY,IAAI;AAAA,IACxC;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAE9C,4BAAwB,KAAK,QAAQ,IAAI;AACzC,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,WAAW;AAClB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\n\nexport class PointingCanvas extends StateNode {\n\tstatic override id = 'pointing_canvas'\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tif (!additiveSelectionKey) {\n\t\t\tif (this.editor.getSelectedShapeIds().length > 0) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting none')\n\t\t\t\tthis.editor.selectNone()\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tthis.parent.transition('brushing', info)\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// todo: also make this deselect\n\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": "AAAA,SAAS,iBAAqC;AAC9C,SAAS,+BAA+B;AAEjC,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAEZ,QAAQ,MAAiD;AACjE,UAAM,uBAAuB,KAAK,YAAY,KAAK;AAEnD,QAAI,CAAC,sBAAsB;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,SAAS,GAAG;AACjD,aAAK,OAAO,yBAAyB,gBAAgB;AACrD,aAAK,OAAO,WAAW;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,WAAK,OAAO,WAAW,YAAY,IAAI;AAAA,IACxC;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAE9C,4BAAwB,KAAK,QAAQ,IAAI;AACzC,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,WAAW;AAClB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -6,7 +6,7 @@ import {
6
6
  getNoteAdjacentPositions,
7
7
  getNoteShapeForAdjacentPosition
8
8
  } from "../../../shapes/note/noteHelpers.mjs";
9
- import { startEditingShapeWithLabel } from "../selectHelpers.mjs";
9
+ import { startEditingShapeWithRichText } from "../selectHelpers.mjs";
10
10
  class PointingHandle extends StateNode {
11
11
  static id = "pointing_handle";
12
12
  didCtrlOnEnter = false;
@@ -43,12 +43,7 @@ class PointingHandle extends StateNode {
43
43
  const { editor } = this;
44
44
  const nextNote = getNoteForAdjacentPosition(editor, shape, handle, false);
45
45
  if (nextNote) {
46
- startEditingShapeWithLabel(
47
- editor,
48
- nextNote,
49
- true
50
- /* selectAll */
51
- );
46
+ startEditingShapeWithRichText(editor, nextNote, { selectAll: true });
52
47
  return;
53
48
  }
54
49
  }
@@ -56,7 +51,7 @@ class PointingHandle extends StateNode {
56
51
  }
57
52
  onPointerMove(info) {
58
53
  const { editor } = this;
59
- if (editor.inputs.isDragging) {
54
+ if (editor.inputs.getIsDragging()) {
60
55
  if (this.didCtrlOnEnter) {
61
56
  this.parent.transition("brushing", info);
62
57
  } else {
@@ -74,7 +69,7 @@ class PointingHandle extends StateNode {
74
69
  if (editor.isShapeOfType(shape, "note")) {
75
70
  const nextNote = getNoteForAdjacentPosition(editor, shape, handle, true);
76
71
  if (nextNote) {
77
- const centeredOnPointer = editor.getPointInParentSpace(nextNote, editor.inputs.originPagePoint).sub(Vec.Rot(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale), nextNote.rotation));
72
+ const centeredOnPointer = editor.getPointInParentSpace(nextNote, editor.inputs.getOriginPagePoint()).sub(Vec.Rot(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale), nextNote.rotation));
78
73
  editor.updateShape({ ...nextNote, x: centeredOnPointer.x, y: centeredOnPointer.y });
79
74
  editor.setHoveredShape(nextNote.id).select(nextNote.id).setCurrentTool("select.translating", {
80
75
  ...this.info,
@@ -83,12 +78,7 @@ class PointingHandle extends StateNode {
83
78
  onInteractionEnd: "note",
84
79
  isCreating: true,
85
80
  onCreate: () => {
86
- startEditingShapeWithLabel(
87
- editor,
88
- nextNote,
89
- true
90
- /* selectAll */
91
- );
81
+ startEditingShapeWithRichText(editor, nextNote, { selectAll: true });
92
82
  }
93
83
  });
94
84
  return;