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

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