tldraw 4.3.0-next.39f1d5b92226 → 4.3.0-next.40e4536afc8e

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 (561) hide show
  1. package/README.md +0 -2
  2. package/dist-cjs/index.d.ts +297 -237
  3. package/dist-cjs/index.js +13 -5
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
  6. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  7. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  8. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  9. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  10. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  11. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  12. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  13. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
  14. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  15. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  16. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  17. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  18. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  19. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  21. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  23. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  24. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  25. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  26. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  27. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
  29. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  31. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  32. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  33. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  34. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  35. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  36. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
  37. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  38. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
  39. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  40. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  41. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  42. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  43. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  44. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
  45. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  46. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  47. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  48. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
  49. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  50. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  51. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  52. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
  53. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  54. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  55. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  56. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
  57. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  58. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  59. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  60. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  61. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  62. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  63. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  64. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  65. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  66. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  67. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  68. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  69. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  70. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  71. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  72. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  73. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  74. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  75. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  76. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  77. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  78. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  79. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  80. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  81. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  82. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  83. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  84. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  85. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  86. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  87. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  88. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +9 -7
  89. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  90. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  91. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  92. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  93. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  94. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  95. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  96. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  97. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  99. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +7 -5
  105. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  107. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  111. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  113. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  115. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  117. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  118. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  119. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  123. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  124. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  125. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  126. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  127. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  128. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  129. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  130. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  131. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  132. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  133. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  134. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  135. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  136. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  137. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  138. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  139. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  140. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  141. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  142. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  143. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  144. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  145. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  146. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  147. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  148. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  149. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  150. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  151. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  152. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  153. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  154. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  155. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  156. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
  157. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  159. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  160. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  161. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  162. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  163. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  164. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  165. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  166. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  167. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  168. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  169. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  170. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  172. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  173. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  174. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  175. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  176. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  177. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  178. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
  179. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  180. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  181. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  182. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
  183. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  184. package/dist-cjs/lib/ui/context/actions.js +6 -6
  185. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  186. package/dist-cjs/lib/ui/context/components.js +1 -2
  187. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  188. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  189. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  190. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  191. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  192. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  193. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  194. package/dist-cjs/lib/ui/version.js +3 -3
  195. package/dist-cjs/lib/ui/version.js.map +1 -1
  196. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -6
  197. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  198. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  199. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  200. package/dist-cjs/lib/utils/text/richText.js +15 -19
  201. package/dist-cjs/lib/utils/text/richText.js.map +3 -3
  202. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  203. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  204. package/dist-esm/index.d.mts +297 -237
  205. package/dist-esm/index.mjs +14 -5
  206. package/dist-esm/index.mjs.map +2 -2
  207. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  208. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  209. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  210. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  211. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  212. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  213. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  214. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  215. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  216. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  217. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  218. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  219. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  220. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  221. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  222. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  223. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  224. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  225. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  226. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  227. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  228. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  229. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
  230. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  231. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  232. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  234. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  235. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  236. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
  238. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  239. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
  240. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  241. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  242. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  243. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  244. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  245. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
  246. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  248. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
  250. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  251. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  252. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  253. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
  254. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  255. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  256. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  257. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
  258. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  259. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  260. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  261. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  262. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  263. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  264. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  265. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  266. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  267. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  268. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  270. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  272. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  274. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  275. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  276. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  277. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  278. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  279. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
  280. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  281. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  282. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  283. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  284. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  285. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  286. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  287. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  288. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  289. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +9 -7
  290. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  291. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  292. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  293. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  294. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  295. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  296. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  297. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  298. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  299. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  300. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  301. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  302. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  303. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  304. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  305. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +7 -5
  306. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  307. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  308. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  309. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  310. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  311. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  312. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  313. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  314. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  315. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -15
  316. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  317. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  318. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  319. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  320. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  321. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  323. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  324. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  325. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  326. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  327. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  328. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  329. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  330. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  331. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  332. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  333. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  334. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  335. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  336. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  337. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  338. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  339. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  340. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  341. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  342. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  343. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  344. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  345. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  346. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  347. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  348. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  349. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  350. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  351. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  352. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  353. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  354. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  355. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  356. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  357. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
  358. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
  359. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  360. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  361. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  362. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  363. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  364. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  365. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  366. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  367. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  368. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  369. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  370. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  371. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  372. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  373. package/dist-esm/lib/ui/components/menu-items.mjs +3 -1
  374. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  375. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  376. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  377. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  378. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  379. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
  380. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  381. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  382. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  383. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
  384. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  385. package/dist-esm/lib/ui/context/actions.mjs +6 -6
  386. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  387. package/dist-esm/lib/ui/context/components.mjs +1 -2
  388. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  389. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  390. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  391. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  392. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  393. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  394. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  395. package/dist-esm/lib/ui/version.mjs +3 -3
  396. package/dist-esm/lib/ui/version.mjs.map +1 -1
  397. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +9 -6
  398. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  399. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  400. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  401. package/dist-esm/lib/utils/text/richText.mjs +12 -5
  402. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  403. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  404. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  405. package/package.json +18 -16
  406. package/src/index.ts +6 -2
  407. package/src/lib/Tldraw.test.tsx +46 -1
  408. package/src/lib/canvas/TldrawSelectionForeground.tsx +2 -2
  409. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  410. package/src/lib/defaultExternalContentHandlers.ts +10 -10
  411. package/src/lib/defaultSideEffects.ts +6 -1
  412. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  413. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  414. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +15 -15
  415. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  416. package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
  417. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
  418. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  419. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  420. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  421. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
  422. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  423. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  424. package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
  425. package/src/lib/shapes/draw/getPath.ts +31 -10
  426. package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
  427. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
  428. package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
  429. package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
  430. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  431. package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
  432. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  433. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
  434. package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
  435. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
  436. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  437. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  438. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
  439. package/src/lib/shapes/shared/PlainTextLabel.tsx +10 -1
  440. package/src/lib/shapes/shared/RichTextLabel.tsx +12 -3
  441. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  442. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  443. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  444. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  445. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  446. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  447. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  448. package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
  449. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  450. package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
  451. package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
  452. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  453. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  454. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  455. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  456. package/src/lib/tools/SelectTool/DragAndDropManager.ts +12 -7
  457. package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
  458. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  459. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
  460. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  461. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  462. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  463. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  464. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -5
  465. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
  466. package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
  467. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
  468. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  469. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
  470. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  471. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  472. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
  473. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  474. package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
  475. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  476. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
  477. package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
  478. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  479. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  480. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  481. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  482. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  483. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  484. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  485. package/src/lib/ui/TldrawUi.tsx +5 -2
  486. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  487. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  488. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  489. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  490. package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
  491. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  492. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  493. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  494. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  495. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  496. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  497. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  498. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  499. package/src/lib/ui/components/menu-items.tsx +3 -1
  500. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  501. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  502. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
  503. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  504. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  505. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
  506. package/src/lib/ui/context/actions.tsx +6 -6
  507. package/src/lib/ui/context/components.tsx +1 -2
  508. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  509. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  510. package/src/lib/ui/hooks/useTools.tsx +4 -5
  511. package/src/lib/ui/version.ts +3 -3
  512. package/src/lib/ui.css +27 -23
  513. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  514. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +11 -6
  515. package/src/lib/utils/test-helpers.ts +60 -0
  516. package/src/lib/utils/text/richText.ts +13 -8
  517. package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
  518. package/src/test/Editor.test.tsx +40 -29
  519. package/src/test/EraserTool.test.ts +10 -12
  520. package/src/test/TestEditor.ts +48 -47
  521. package/src/test/TldrawEditor.test.tsx +3 -2
  522. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  523. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  524. package/src/test/arrows-megabus.test.tsx +1 -1
  525. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  526. package/src/test/commands/cameraState.test.ts +299 -0
  527. package/src/test/commands/putContent.test.ts +79 -1
  528. package/src/test/commands/setCamera.test.ts +13 -11
  529. package/src/test/commands/stackShapes.test.ts +34 -8
  530. package/src/test/commands/zoomToBounds.test.ts +19 -3
  531. package/src/test/commands/zoomToSelection.test.ts +14 -3
  532. package/src/test/custom-clipping.test.ts +16 -9
  533. package/src/test/drawing.test.ts +17 -10
  534. package/src/test/flipShapes.test.ts +33 -0
  535. package/src/test/frames.test.ts +92 -0
  536. package/src/test/groups.test.tsx +1 -1
  537. package/src/test/modifiers.test.ts +6 -6
  538. package/src/test/resizing.test.ts +7 -9
  539. package/src/test/selection-omnibus.test.ts +2 -2
  540. package/src/test/spacebarPanning.test.ts +28 -10
  541. package/src/test/test-jsx.tsx +3 -0
  542. package/src/test/ui/BackToContent.test.tsx +111 -0
  543. package/tldraw.css +41 -35
  544. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  545. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  546. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  547. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  548. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  549. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  550. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  551. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  552. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  553. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  554. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  555. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  556. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  557. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  558. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
  559. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  560. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  561. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/EditingShape.ts"],
4
- "sourcesContent": ["import {\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLCompleteEventInfo,\n\ttlenv,\n\tTLPointerEventInfo,\n\tTLShape,\n} from '@tldraw/editor'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\nimport { renderPlaintextFromRichText } from '../../../utils/text/richText'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\n\ninterface EditingShapeInfo {\n\tisCreatingTextWhileToolLocked?: boolean\n}\n\nexport class EditingShape extends StateNode {\n\tstatic override id = 'editing_shape'\n\n\thitShapeForPointerUp: TLShape | null = null\n\tprivate info = {} as EditingShapeInfo\n\n\toverride onEnter(info: EditingShapeInfo) {\n\t\tconst editingShape = this.editor.getEditingShape()\n\t\tif (!editingShape) throw Error('Entered editing state without an editing shape')\n\t\tthis.hitShapeForPointerUp = null\n\n\t\tthis.info = info\n\n\t\tif (info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask('text')\n\t\t}\n\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.editor.select(editingShape)\n\t}\n\n\toverride onExit() {\n\t\tconst { editingShapeId } = this.editor.getCurrentPageState()\n\t\tif (!editingShapeId) return\n\n\t\t// Clear the editing shape\n\t\tthis.editor.setEditingShape(null)\n\n\t\tupdateHoveredShapeId.cancel()\n\n\t\tif (this.info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\t\tthis.editor.setCurrentTool('text', {})\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\t// In the case where on pointer down we hit a shape's label, we need to check if the user is dragging.\n\t\t// and if they are, we need to transition to translating instead.\n\t\tif (this.hitShapeForPointerUp && this.editor.inputs.isDragging) {\n\t\t\tif (this.editor.getIsReadonly()) return\n\t\t\tif (this.hitShapeForPointerUp.isLocked) return\n\t\t\tthis.editor.select(this.hitShapeForPointerUp)\n\t\t\tthis.parent.transition('translating', info)\n\t\t\tthis.hitShapeForPointerUp = null\n\t\t\treturn\n\t\t}\n\n\t\tswitch (info.target) {\n\t\t\tcase 'shape':\n\t\t\tcase 'canvas': {\n\t\t\t\tupdateHoveredShapeId(this.editor)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tthis.hitShapeForPointerUp = null\n\n\t\tswitch (info.target) {\n\t\t\t// N.B. This bit of logic has a bit of history to it.\n\t\t\t// There was a PR that got rid of this logic: https://github.com/tldraw/tldraw/pull/4237\n\t\t\t// But here we bring it back to help support the new rich text world.\n\t\t\t// The original issue which is visible in the video attachments in the PR now seem\n\t\t\t// to have been resolved anyway via some other layer.\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor, true /* hitLabels */)\n\t\t\t\tif (hitShape) {\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\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape: selectingShape } = info\n\t\t\t\tconst editingShape = this.editor.getEditingShape()\n\n\t\t\t\tif (!editingShape) {\n\t\t\t\t\tthrow Error('Expected an editing shape!')\n\t\t\t\t}\n\n\t\t\t\t// for shapes with labels, check to see if the click was inside of the shape's label\n\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t// N.B. One nuance here is that we want empty text fields to be removed from the canvas when the user clicks away from them.\n\t\t\t\tconst isEmptyTextShape =\n\t\t\t\t\tthis.editor.isShapeOfType(editingShape, 'text') &&\n\t\t\t\t\trenderPlaintextFromRichText(this.editor, editingShape.props.richText).trim() === ''\n\t\t\t\tif (textLabel && !isEmptyTextShape) {\n\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\tthis.editor.inputs.currentPagePoint\n\t\t\t\t\t)\n\t\t\t\t\tif (\n\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// it's a hit to the label!\n\t\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t\t// If we clicked on the editing geo / arrow shape's label, do nothing\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.hitShapeForPointerUp = selectingShape\n\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\tthis.editor.select(selectingShape.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} else {\n\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t// If we clicked on a frame, while editing its heading, cancel editing\n\t\t\t\t\t\tif (this.editor.isShapeOfType(selectingShape, 'frame')) {\n\t\t\t\t\t\t\tthis.editor.setEditingShape(null)\n\t\t\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If we clicked on the editing shape (which isn't a shape with a label), do nothing\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// But if we clicked on a different shape of the same type, transition to pointing_shape instead\n\t\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// still here? Cancel editing and transition back to select idle\n\t\tthis.parent.transition('idle', info)\n\t\t// then feed the pointer down event back into the state chart as if it happened in that state\n\t\tthis.editor.root.handleEvent(info)\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// If we're not dragging, and it's a hit to the label, begin editing the shape.\n\t\tconst hitShape = this.hitShapeForPointerUp\n\t\tif (!hitShape) return\n\t\tthis.hitShapeForPointerUp = null\n\n\t\t// Stay in edit mode to maintain flow of editing.\n\t\tconst util = this.editor.getShapeUtil(hitShape)\n\t\tif (hitShape.isLocked) return\n\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(hitShape)) {\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.select(hitShape.id)\n\n\t\tconst currentEditingShape = this.editor.getEditingShape()\n\t\tconst isEditToEditAction = currentEditingShape && currentEditingShape.id !== hitShape.id\n\t\tthis.editor.setEditingShape(hitShape.id)\n\n\t\tconst isMobile = tlenv.isIos || tlenv.isAndroid\n\t\tif (!isMobile || !isEditToEditAction) {\n\t\t\tthis.editor.emit('place-caret', { shapeId: hitShape.id, point: info.point })\n\t\t} else if (isMobile && isEditToEditAction) {\n\t\t\tthis.editor.emit('select-all-text', { shapeId: hitShape.id })\n\t\t}\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onComplete(info: TLCompleteEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onCancel(info: TLCancelEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,oBAA8B;AAC9B,sBAA4C;AAC5C,4CAA+C;AAC/C,kCAAqC;AAM9B,MAAM,qBAAqB,wBAAU;AAAA,EAC3C,OAAgB,KAAK;AAAA,EAErB,uBAAuC;AAAA,EAC/B,OAAO,CAAC;AAAA,EAEP,QAAQ,MAAwB;AACxC,UAAM,eAAe,KAAK,OAAO,gBAAgB;AACjD,QAAI,CAAC,aAAc,OAAM,MAAM,gDAAgD;AAC/E,SAAK,uBAAuB;AAE5B,SAAK,OAAO;AAEZ,QAAI,K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;AAC9C,QAAI,SAAS,SAAU;AAEvB,QAAI,KAAK,OAAO,cAAc,GAAG;AAChC,UAAI,CAAC,KAAK,kBAAkB,QAAQ,GAAG;AACtC,aAAK,OAAO,WAAW,kBAAkB,IAAI;AAC7C;AAAA,MACD;AAAA,IACD;AAEA,SAAK,OAAO,OAAO,SAAS,EAAE;AAE9B,UAAM,sBAAsB,KAAK,OAAO,gBAAgB;AACxD,UAAM,qBAAqB,uBAAuB,oBAAoB,OAAO,SAAS;AACtF,SAAK,OAAO,gBAAgB,SAAS,EAAE;AAEvC,UAAM,WAAW,oBAAM,SAAS,oBAAM;AACtC,QAAI,CAAC,YAAY,CAAC,oBAAoB;AACrC,WAAK,OAAO,KAAK,eAAe,EAAE,SAAS,SAAS,IAAI,OAAO,KAAK,MAAM,CAAC;AAAA,IAC5E,WAAW,YAAY,oBAAoB;AAC1C,WAAK,OAAO,KAAK,mBAAmB,EAAE,SAAS,SAAS,GAAG,CAAC;AAAA,IAC7D;AACA,0DAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,WAAW,MAA2B;AAC9C,SAAK,OAAO,aAAa,EAAE,MAAM;AACjC,SAAK,OAAO,WAAW,QAAQ,IAAI;AAAA,EACpC;AAAA,EAES,SAAS,MAAyB;AAC1C,SAAK,OAAO,aAAa,EAAE,MAAM;AACjC,SAAK,OAAO,WAAW,QAAQ,IAAI;AAAA,EACpC;AACD;",
4
+ "sourcesContent": ["import {\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLCompleteEventInfo,\n\ttlenv,\n\tTLPointerEventInfo,\n\tTLShape,\n} from '@tldraw/editor'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\nimport { renderPlaintextFromRichText } from '../../../utils/text/richText'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\n\ninterface EditingShapeInfo {\n\tisCreatingTextWhileToolLocked?: boolean\n}\n\nexport class EditingShape extends StateNode {\n\tstatic override id = 'editing_shape'\n\n\thitLabelOnShapeForPointerUp: TLShape | null = null\n\tprivate info = {} as EditingShapeInfo\n\tprivate didPointerDownOnEditingShape = false\n\n\tprivate isTextInputFocused(): boolean {\n\t\tconst container = this.editor.getContainer()\n\t\treturn (\n\t\t\tcontainer.contains(document.activeElement) &&\n\t\t\t(document.activeElement?.nodeName === 'INPUT' ||\n\t\t\t\tdocument.activeElement?.nodeName === 'TEXTAREA' ||\n\t\t\t\t(document.activeElement as HTMLElement)?.isContentEditable)\n\t\t)\n\t}\n\n\toverride onEnter(info: EditingShapeInfo) {\n\t\tconst editingShape = this.editor.getEditingShape()\n\t\tif (!editingShape) throw Error('Entered editing state without an editing shape')\n\t\tthis.hitLabelOnShapeForPointerUp = null\n\t\tthis.didPointerDownOnEditingShape = false\n\n\t\tthis.info = info\n\n\t\tif (info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask('text')\n\t\t}\n\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.editor.select(editingShape)\n\t}\n\n\toverride onExit() {\n\t\tconst { editingShapeId } = this.editor.getCurrentPageState()\n\t\tif (!editingShapeId) return\n\n\t\t// Clear the editing shape\n\t\tthis.editor.setEditingShape(null)\n\n\t\tupdateHoveredShapeId.cancel()\n\n\t\tif (this.info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\t\tthis.editor.setCurrentTool('text', {})\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\t// In the case where on pointer down we hit a shape's label, we need to check if the user is dragging.\n\t\t// and if they are, we need to transition to translating instead.\n\t\tif (this.hitLabelOnShapeForPointerUp && this.editor.inputs.getIsDragging()) {\n\t\t\tif (this.editor.getIsReadonly()) return\n\t\t\tif (this.hitLabelOnShapeForPointerUp.isLocked) return\n\n\t\t\tthis.editor.select(this.hitLabelOnShapeForPointerUp)\n\t\t\tthis.parent.transition('translating', info)\n\t\t\tthis.hitLabelOnShapeForPointerUp = null\n\t\t\treturn\n\t\t}\n\n\t\t// Check if dragging from editing shape with blurred input\n\t\tif (this.didPointerDownOnEditingShape && this.editor.inputs.isDragging) {\n\t\t\tif (this.editor.getIsReadonly()) return\n\n\t\t\tconst editingShape = this.editor.getEditingShape()\n\t\t\tif (!editingShape || editingShape.isLocked) return\n\n\t\t\tif (!this.isTextInputFocused()) {\n\t\t\t\t// Input blurred during drag - exit edit mode and start translating\n\t\t\t\tthis.editor.select(editingShape)\n\t\t\t\tthis.parent.transition('translating', info)\n\t\t\t\tthis.didPointerDownOnEditingShape = false\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Input still focused - user is selecting text, stay in edit mode\n\t\t\tthis.didPointerDownOnEditingShape = false\n\t\t}\n\n\t\tswitch (info.target) {\n\t\t\tcase 'shape':\n\t\t\tcase 'canvas': {\n\t\t\t\tupdateHoveredShapeId(this.editor)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tthis.hitLabelOnShapeForPointerUp = null\n\t\tthis.didPointerDownOnEditingShape = false\n\n\t\tswitch (info.target) {\n\t\t\t// N.B. This bit of logic has a bit of history to it.\n\t\t\t// There was a PR that got rid of this logic: https://github.com/tldraw/tldraw/pull/4237\n\t\t\t// But here we bring it back to help support the new rich text world.\n\t\t\t// The original issue which is visible in the video attachments in the PR now seem\n\t\t\t// to have been resolved anyway via some other layer.\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor, true /* hitLabels */)\n\t\t\t\tif (hitShape) {\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\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape: selectingShape } = info\n\t\t\t\tconst editingShape = this.editor.getEditingShape()\n\n\t\t\t\tif (!editingShape) {\n\t\t\t\t\tthrow Error('Expected an editing shape!')\n\t\t\t\t}\n\n\t\t\t\t// for shapes with labels, check to see if the click was inside of the shape's label\n\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t// N.B. One nuance here is that we want empty text fields to be removed from the canvas when the user clicks away from them.\n\t\t\t\tconst isEmptyTextShape =\n\t\t\t\t\tthis.editor.isShapeOfType(editingShape, 'text') &&\n\t\t\t\t\trenderPlaintextFromRichText(this.editor, editingShape.props.richText).trim() === ''\n\t\t\t\tif (textLabel && !isEmptyTextShape) {\n\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\tthis.editor.inputs.getCurrentPagePoint()\n\t\t\t\t\t)\n\t\t\t\t\tif (\n\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// it's a hit to the label!\n\t\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t\t// Track click on editing shape for drag detection\n\t\t\t\t\t\t\tthis.didPointerDownOnEditingShape = true\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.hitLabelOnShapeForPointerUp = selectingShape\n\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\tthis.editor.select(selectingShape.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} else {\n\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t// If we clicked on a frame, while editing its heading, cancel editing\n\t\t\t\t\t\tif (this.editor.isShapeOfType(selectingShape, 'frame')) {\n\t\t\t\t\t\t\tthis.editor.setEditingShape(null)\n\t\t\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If we clicked on the editing shape (which isn't a shape with a label), do nothing\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// But if we clicked on a different shape of the same type, transition to pointing_shape instead\n\t\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// still here? Cancel editing and transition back to select idle\n\t\tthis.parent.transition('idle', info)\n\t\t// then feed the pointer down event back into the state chart as if it happened in that state\n\t\tthis.editor.root.handleEvent(info)\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\tif (this.didPointerDownOnEditingShape) {\n\t\t\tthis.didPointerDownOnEditingShape = false\n\t\t\tif (!this.isTextInputFocused()) {\n\t\t\t\t// We clicked on the text label, which blured the input.\n\t\t\t\t// We want to stay in edit mode and select all the text.\n\t\t\t\tthis.editor.getRichTextEditor()?.commands.focus('all')\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// If we're not dragging, and it's a hit to the label, begin editing the shape.\n\t\tconst hitShape = this.hitLabelOnShapeForPointerUp\n\t\tif (!hitShape) return\n\t\tthis.hitLabelOnShapeForPointerUp = null\n\n\t\t// Stay in edit mode to maintain flow of editing.\n\t\tconst util = this.editor.getShapeUtil(hitShape)\n\t\tif (hitShape.isLocked) return\n\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(hitShape)) {\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.select(hitShape.id)\n\n\t\tconst currentEditingShape = this.editor.getEditingShape()\n\t\tconst isEditToEditAction = currentEditingShape && currentEditingShape.id !== hitShape.id\n\t\tthis.editor.setEditingShape(hitShape.id)\n\n\t\tconst isMobile = tlenv.isIos || tlenv.isAndroid\n\t\tif (!isMobile || !isEditToEditAction) {\n\t\t\tthis.editor.emit('place-caret', { shapeId: hitShape.id, point: info.point })\n\t\t} else if (isMobile && isEditToEditAction) {\n\t\t\tthis.editor.emit('select-all-text', { shapeId: hitShape.id })\n\t\t}\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onComplete(info: TLCompleteEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onCancel(info: TLCancelEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AACP,oBAA8B;AAC9B,sBAA4C;AAC5C,4CAA+C;AAC/C,kCAAqC;AAM9B,MAAM,qBAAqB,wBAAU;AAAA,EAC3C,OAAgB,KAAK;AAAA,EAErB,8BAA8C;AAAA,EACtC,OAAO,CAAC;AAAA,EACR,+BAA+B;AAAA,EAE/B,qBAA8B;AACrC,UAAM,YAAY,KAAK,OAAO,aAAa;AAC3C,WACC,UAAU,SAAS,SAAS,aAAa,MACxC,SAAS,eAAe,aAAa,WACrC,SAAS,eAAe,aAAa,cACpC,SAAS,eAA+B;AAAA,EAE5C;AAAA,EAES,QAAQ,MAAwB;AACxC,UAAM,eAAe,KAAK,OAAO,gBAAgB;AACjD,QAAI,CAAC,aAAc,OAAM,MAAM,gDAAgD;AAC/E,SAAK,8BAA8B;AACnC,SAAK,+BAA+B;AAEpC,SAAK,OAAO;AAEZ,QAAI,KAAK,+BAA+B;AACvC,WAAK,OAAO,qBAAqB,MAAM;AAAA,IACxC;AAEA,0DAAqB,KAAK,MAAM;AAChC,SAAK,OAAO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,SAAS,MAAyB;AAC1C,SAAK,OAAO,aAAa,EAAE,MAAM;AACjC,SAAK,OAAO,WAAW,QAAQ,IAAI;AAAA,EACpC;AACD;",
6
6
  "names": []
7
7
  }
@@ -27,7 +27,6 @@ module.exports = __toCommonJS(Idle_exports);
27
27
  var import_editor = require("@tldraw/editor");
28
28
  var import_arrowLabel = require("../../../shapes/arrow/arrowLabel");
29
29
  var import_getHitShapeOnCanvasPointerDown = require("../../selection-logic/getHitShapeOnCanvasPointerDown");
30
- var import_getShouldEnterCropModeOnPointerDown = require("../../selection-logic/getShouldEnterCropModeOnPointerDown");
31
30
  var import_selectOnCanvasPointerUp = require("../../selection-logic/selectOnCanvasPointerUp");
32
31
  var import_updateHoveredShapeId = require("../../selection-logic/updateHoveredShapeId");
33
32
  var import_selectHelpers = require("../selectHelpers");
@@ -57,7 +56,6 @@ class Idle extends import_editor.StateNode {
57
56
  (0, import_updateHoveredShapeId.updateHoveredShapeId)(this.editor);
58
57
  }
59
58
  onPointerDown(info) {
60
- const shouldEnterCropMode = info.ctrlKey && (0, import_getShouldEnterCropModeOnPointerDown.getShouldEnterCropMode)(this.editor);
61
59
  switch (info.target) {
62
60
  case "canvas": {
63
61
  const hitShape = (0, import_getHitShapeOnCanvasPointerDown.getHitShapeOnCanvasPointerDown)(this.editor);
@@ -71,9 +69,7 @@ class Idle extends import_editor.StateNode {
71
69
  }
72
70
  const selectedShapeIds = this.editor.getSelectedShapeIds();
73
71
  const onlySelectedShape = this.editor.getOnlySelectedShape();
74
- const {
75
- inputs: { currentPagePoint }
76
- } = this.editor;
72
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
77
73
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
78
74
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
79
75
  this.onPointerDown({
@@ -97,7 +93,7 @@ class Idle extends import_editor.StateNode {
97
93
  }
98
94
  case "handle": {
99
95
  if (this.editor.getIsReadonly()) break;
100
- if (this.editor.inputs.altKey) {
96
+ if (this.editor.inputs.getAltKey()) {
101
97
  this.parent.transition("pointing_shape", info);
102
98
  } else {
103
99
  this.parent.transition("pointing_handle", info);
@@ -126,7 +122,8 @@ class Idle extends import_editor.StateNode {
126
122
  case "top_right":
127
123
  case "bottom_left":
128
124
  case "bottom_right": {
129
- if (shouldEnterCropMode) {
125
+ const onlySelectedShape = this.editor.getOnlySelectedShape();
126
+ if (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {
130
127
  this.parent.transition("crop.pointing_crop_handle", info);
131
128
  } else {
132
129
  if (info.accelKey) {
@@ -155,12 +152,13 @@ class Idle extends import_editor.StateNode {
155
152
  }
156
153
  }
157
154
  onDoubleClick(info) {
158
- if (this.editor.inputs.shiftKey || info.phase !== "up") return;
155
+ if (this.editor.inputs.getShiftKey() || info.phase !== "up") return;
159
156
  if (info.ctrlKey || info.shiftKey) return;
160
157
  switch (info.target) {
161
158
  case "canvas": {
162
159
  const hoveredShape = this.editor.getHoveredShape();
163
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
160
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
161
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(currentPagePoint) ?? this.editor.getShapeAtPoint(currentPagePoint, {
164
162
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
165
163
  hitInside: false
166
164
  });
@@ -186,20 +184,31 @@ class Idle extends import_editor.StateNode {
186
184
  });
187
185
  return;
188
186
  }
189
- if (!this.editor.inputs.shiftKey) {
187
+ if (!this.editor.inputs.getShiftKey()) {
190
188
  this.handleDoubleClickOnCanvas(info);
191
189
  }
192
190
  break;
193
191
  }
194
192
  case "selection": {
195
- if (this.editor.getIsReadonly()) break;
196
193
  const onlySelectedShape = this.editor.getOnlySelectedShape();
197
194
  if (onlySelectedShape) {
198
195
  const util = this.editor.getShapeUtil(onlySelectedShape);
199
- if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {
200
- return;
196
+ const isEdge = info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom";
197
+ const isCorner = info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left";
198
+ if (this.editor.getIsReadonly()) {
199
+ if (this.editor.canEditShape(onlySelectedShape, {
200
+ type: isCorner ? "double-click-corner" : isEdge ? "double-click-edge" : "double-click"
201
+ })) {
202
+ this.startEditingShape(
203
+ onlySelectedShape,
204
+ info,
205
+ true
206
+ /* select all */
207
+ );
208
+ }
209
+ break;
201
210
  }
202
- if (info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom") {
211
+ if (isEdge) {
203
212
  const change = util.onDoubleClickEdge?.(onlySelectedShape, info);
204
213
  if (change) {
205
214
  this.editor.markHistoryStoppingPoint("double click edge");
@@ -208,7 +217,7 @@ class Idle extends import_editor.StateNode {
208
217
  return;
209
218
  }
210
219
  }
211
- if (info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left") {
220
+ if (isCorner) {
212
221
  const change = util.onDoubleClickCorner?.(onlySelectedShape, info);
213
222
  if (change) {
214
223
  this.editor.markHistoryStoppingPoint("double click corner");
@@ -217,11 +226,11 @@ class Idle extends import_editor.StateNode {
217
226
  return;
218
227
  }
219
228
  }
220
- if (util.canCrop(onlySelectedShape) && !this.editor.isShapeOrAncestorLocked(onlySelectedShape)) {
229
+ if (this.editor.canCropShape(onlySelectedShape)) {
221
230
  this.parent.transition("crop", info);
222
231
  return;
223
232
  }
224
- if (this.shouldStartEditingShape(onlySelectedShape)) {
233
+ if (this.editor.canEditShape(onlySelectedShape)) {
225
234
  this.startEditingShape(
226
235
  onlySelectedShape,
227
236
  info,
@@ -249,7 +258,7 @@ class Idle extends import_editor.StateNode {
249
258
  this.parent.transition("crop", info);
250
259
  return;
251
260
  }
252
- if (this.shouldStartEditingShape(shape)) {
261
+ if (this.editor.canEditShape(shape)) {
253
262
  this.startEditingShape(
254
263
  shape,
255
264
  info,
@@ -269,7 +278,7 @@ class Idle extends import_editor.StateNode {
269
278
  if (changes) {
270
279
  this.editor.updateShapes([changes]);
271
280
  } else {
272
- if (this.shouldStartEditingShape(shape)) {
281
+ if (this.editor.canEditShape(shape)) {
273
282
  this.startEditingShape(
274
283
  shape,
275
284
  info,
@@ -285,7 +294,7 @@ class Idle extends import_editor.StateNode {
285
294
  switch (info.target) {
286
295
  case "canvas": {
287
296
  const hoveredShape = this.editor.getHoveredShape();
288
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
297
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(), {
289
298
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
290
299
  hitInside: false,
291
300
  hitLabels: true,
@@ -303,9 +312,7 @@ class Idle extends import_editor.StateNode {
303
312
  }
304
313
  const selectedShapeIds = this.editor.getSelectedShapeIds();
305
314
  const onlySelectedShape = this.editor.getOnlySelectedShape();
306
- const {
307
- inputs: { currentPagePoint }
308
- } = this.editor;
315
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
309
316
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
310
317
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
311
318
  this.onRightClick({
@@ -374,7 +381,7 @@ class Idle extends import_editor.StateNode {
374
381
  const onlySelectedShape = this.editor.getOnlySelectedShape();
375
382
  if (onlySelectedShape && // If it's a note shape, then edit on type
376
383
  this.editor.isShapeOfType(onlySelectedShape, "note") && // If it's not locked or anything
377
- this.shouldStartEditingShape(onlySelectedShape)) {
384
+ this.editor.canEditShape(onlySelectedShape)) {
378
385
  this.startEditingShape(
379
386
  onlySelectedShape,
380
387
  {
@@ -426,7 +433,7 @@ class Idle extends import_editor.StateNode {
426
433
  return;
427
434
  }
428
435
  const onlySelectedShape = this.editor.getOnlySelectedShape();
429
- if (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {
436
+ if (onlySelectedShape && this.editor.canEditShape(onlySelectedShape, { type: "press_enter" })) {
430
437
  this.startEditingShape(
431
438
  onlySelectedShape,
432
439
  {
@@ -439,7 +446,7 @@ class Idle extends import_editor.StateNode {
439
446
  );
440
447
  return;
441
448
  }
442
- if ((0, import_getShouldEnterCropModeOnPointerDown.getShouldEnterCropMode)(this.editor)) {
449
+ if (this.editor.canCropShape(onlySelectedShape)) {
443
450
  this.parent.transition("crop", info);
444
451
  }
445
452
  break;
@@ -453,16 +460,14 @@ class Idle extends import_editor.StateNode {
453
460
  }
454
461
  }
455
462
  }
456
- shouldStartEditingShape(shape = this.editor.getOnlySelectedShape()) {
457
- if (!shape) return false;
458
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return false;
459
- if (!this.canInteractWithShapeInReadOnly(shape)) return false;
460
- return this.editor.getShapeUtil(shape).canEdit(shape);
461
- }
462
463
  startEditingShape(shape, info, shouldSelectAll) {
463
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return;
464
+ const { editor } = this;
464
465
  this.editor.markHistoryStoppingPoint("editing shape");
465
- (0, import_selectHelpers.startEditingShapeWithLabel)(this.editor, shape, shouldSelectAll);
466
+ if ((0, import_selectHelpers.hasRichText)(shape)) {
467
+ (0, import_selectHelpers.startEditingShapeWithRichText)(editor, shape, { selectAll: shouldSelectAll });
468
+ } else {
469
+ editor.setEditingShape(shape);
470
+ }
466
471
  this.parent.transition("editing_shape", info);
467
472
  }
468
473
  isOverArrowLabelTest(shape) {
@@ -474,7 +479,7 @@ class Idle extends import_editor.StateNode {
474
479
  if (!this.editor.options.createTextOnCanvasDoubleClick) return;
475
480
  this.editor.markHistoryStoppingPoint("creating text shape");
476
481
  const id = (0, import_editor.createShapeId)();
477
- const { x, y } = this.editor.inputs.currentPagePoint;
482
+ const { x, y } = this.editor.inputs.getCurrentPagePoint();
478
483
  this.editor.createShapes([
479
484
  {
480
485
  id,
@@ -489,15 +494,8 @@ class Idle extends import_editor.StateNode {
489
494
  ]);
490
495
  const shape = this.editor.getShape(id);
491
496
  if (!shape) return;
492
- const util = this.editor.getShapeUtil(shape);
493
- if (this.editor.getIsReadonly()) {
494
- if (!util.canEditInReadonly(shape)) {
495
- return;
496
- }
497
- }
498
- this.editor.setEditingShape(id);
499
- this.editor.select(id);
500
- this.parent.transition("editing_shape", info);
497
+ if (!this.editor.canEditShape(shape)) return;
498
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, id, { info });
501
499
  }
502
500
  nudgeSelectedShapes(ephemeral = false) {
503
501
  const {
@@ -519,12 +517,6 @@ class Idle extends import_editor.StateNode {
519
517
  this.editor.nudgeShapes(selectedShapeIds, delta.mul(step));
520
518
  (0, import_editor.kickoutOccludedShapes)(this.editor, selectedShapeIds);
521
519
  }
522
- canInteractWithShapeInReadOnly(shape) {
523
- if (!this.editor.getIsReadonly()) return true;
524
- const util = this.editor.getShapeUtil(shape);
525
- if (util.canEditInReadonly(shape)) return true;
526
- return false;
527
- }
528
520
  }
529
521
  const MAJOR_NUDGE_FACTOR = 10;
530
522
  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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAeO;AACP,wBAAiC;AACjC,4CAA+C;AAC/C,iDAAuC;AACvC,qCAAwC;AACxC,kCAAqC;AACrC,2BAA2C;AAE3C,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,aAAa,wBAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,0BAAqC,CAAC;AAAA,EAE7B,UAAU;AAClB,SAAK,OAAO,qBAAqB,MAAS;AAC1C,0DAAqB,KAAK,MAAM;AAChC,SAAK,0BAA0B,CAAC;AAChC,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,SAAS;AACjB,qDAAqB,OAAO;AAAA,EAC7B;AAAA,EAES,gBAAgB;AACxB,0DAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,cAAc,MAA0B;AAChD,UAAM,sBAAsB,KAAK,eAAW,mEAAuB,KAAK,MAAM;AAE9E,YAAQ,KAAK,QAAQ;AAAA,MACpB,KAAK,UAAU;AAGd,cAAM,eAAW,sEAA+B,K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ardEventInfo,\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAeO;AACP,wBAAiC;AACjC,4CAA+C;AAC/C,qCAAwC;AACxC,kCAAqC;AACrC,2BAA2D;AAE3D,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,aAAa,wBAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,0BAAqC,CAAC;AAAA,EAE7B,UAAU;AAClB,SAAK,OAAO,qBAAqB,MAAS;AAC1C,0DAAqB,KAAK,MAAM;AAChC,SAAK,0BAA0B,CAAC;AAChC,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,SAAS;AACjB,qDAAqB,OAAO;AAAA,EAC7B;AAAA,EAES,gBAAgB;AACxB,0DAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,cAAc,MAA0B;AAChD,YAAQ,KAAK,QAAQ;AAAA,MACpB,KAAK,UAAU;AAGd,cAAM,eAAW,sEAA+B,KAAK,MAAM;AAC3D,YAAI,YAAY,CAAC,SAAS,UAAU;AACnC,eAAK,cAAc;AAAA,YAClB,GAAG;AAAA,YACH,OAAO;AAAA,YACP,QAAQ;AAAA,UACT,CAAC;AACD;AAAA,QACD;AAEA,cAAM,mBAAmB,KAAK,OAAO,oBAAoB;AACzD,cAAM,oBAAoB,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AI,KAAK,OAAO,oBAAoB;AAErD,UAAM,OAAO,KAAK,OAAO,iBAAiB,EAAE,aACzC,WACC,WAAW,iBACX,WACD,WACC,qBACA;AAEJ,UAAM,mBAAmB,KAAK,OAAO,oBAAoB;AACzD,SAAK,OAAO,YAAY,kBAAkB,MAAM,IAAI,IAAI,CAAC;AACzD,6CAAsB,KAAK,QAAQ,gBAAgB;AAAA,EACpD;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,aAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,kBAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
6
6
  "names": ["shape"]
7
7
  }
@@ -23,6 +23,7 @@ __export(PointingArrowLabel_exports, {
23
23
  module.exports = __toCommonJS(PointingArrowLabel_exports);
24
24
  var import_editor = require("@tldraw/editor");
25
25
  var import_arrowLabel = require("../../../shapes/arrow/arrowLabel");
26
+ var import_selectHelpers = require("../selectHelpers");
26
27
  class PointingArrowLabel extends import_editor.StateNode {
27
28
  static id = "pointing_arrow_label";
28
29
  shapeId = "";
@@ -50,7 +51,7 @@ class PointingArrowLabel extends import_editor.StateNode {
50
51
  if (!labelGeometry) {
51
52
  throw Error(`Expected to find an arrow label geometry for shape: ${shape.id}`);
52
53
  }
53
- const { currentPagePoint } = this.editor.inputs;
54
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
54
55
  const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint);
55
56
  this._labelDragOffset = import_editor.Vec.Sub(labelGeometry.center, pointInShapeSpace);
56
57
  this.markId = this.editor.markHistoryStoppingPoint("label-drag start");
@@ -68,7 +69,7 @@ class PointingArrowLabel extends import_editor.StateNode {
68
69
  }
69
70
  _labelDragOffset = new import_editor.Vec(0, 0);
70
71
  onPointerMove() {
71
- const { isDragging } = this.editor.inputs;
72
+ const isDragging = this.editor.inputs.getIsDragging();
72
73
  if (!isDragging) return;
73
74
  if (this.didCtrlOnEnter) {
74
75
  this.parent.transition("brushing", this.info);
@@ -79,7 +80,7 @@ class PointingArrowLabel extends import_editor.StateNode {
79
80
  const options = this.editor.getShapeUtil("arrow").options;
80
81
  const geometry = (0, import_arrowLabel.getArrowBodyGeometry)(this.editor, shape);
81
82
  const transform = this.editor.getShapePageTransform(shape.id);
82
- const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint).add(this._labelDragOffset);
83
+ const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset);
83
84
  const defaultLabelPosition = (0, import_arrowLabel.getArrowLabelDefaultPosition)(this.editor, shape);
84
85
  let nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace);
85
86
  if (isNaN(nextLabelPosition)) {
@@ -108,9 +109,8 @@ class PointingArrowLabel extends import_editor.StateNode {
108
109
  if (!shape) return;
109
110
  if (this.didDrag || !this.wasAlreadySelected) {
110
111
  this.complete();
111
- } else if (!this.editor.getIsReadonly()) {
112
- this.editor.setEditingShape(shape.id);
113
- this.editor.setCurrentTool("select.editing_shape");
112
+ } else if (this.editor.canEditShape(shape)) {
113
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, shape.id);
114
114
  }
115
115
  }
116
116
  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;AAAA;AAAA;AAAA;AAAA,oBAOO;AAEP,wBAGO;AAEA,MAAM,2BAA2B,wBAAU;AAAA,EACjD,OAAgB,KAAK;AAAA,EAErB,UAAU;AAAA,EACV,SAAS;AAAA,EACT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C,WAAK,SAAS;AAAA,IACf,WAAW,CAAC,KAAK,OAAO,cAAc,GAAG;AAExC,WAAK,OAAO,gBAAgB,MAAM,EAAE;AACpC,WAAK,OAAO,eAAe,sBAAsB;AAAA,IAClD;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;",
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\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;AAAA;AAAA;AAAA;AAAA,oBAOO;AAEP,wBAGO;AACP,2BAA8C;AAEvC,MAAM,2BAA2B,wBAAU;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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AClB,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
  }
@@ -35,7 +35,7 @@ class PointingCanvas extends import_editor.StateNode {
35
35
  }
36
36
  }
37
37
  onPointerMove(info) {
38
- if (this.editor.inputs.isDragging) {
38
+ if (this.editor.inputs.getIsDragging()) {
39
39
  this.parent.transition("brushing", info);
40
40
  }
41
41
  }
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8C;AAC9C,qCAAwC;AAEjC,MAAM,uBAAuB,wBAAU;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,gEAAwB,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;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8C;AAC9C,qCAAwC;AAEjC,MAAM,uBAAuB,wBAAU;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,gEAAwB,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
  }