tldraw 4.3.0-next.f13438eb7775 → 4.3.0

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 (636) hide show
  1. package/README.md +0 -2
  2. package/dist-cjs/index.d.ts +311 -242
  3. package/dist-cjs/index.js +13 -5
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
  6. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
  7. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  8. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  9. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  10. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  11. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  12. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  13. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
  15. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  17. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  18. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  19. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  20. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  21. package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  23. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  24. package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
  25. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  26. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  27. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  28. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  29. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  30. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  31. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
  32. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
  33. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  35. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  36. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  37. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  38. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  39. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  40. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  41. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
  42. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  43. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
  44. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  45. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  46. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  47. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  48. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  49. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
  50. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  51. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  52. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  53. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
  54. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  55. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  56. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  57. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  58. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
  59. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  60. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  61. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  62. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
  63. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  64. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  65. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  66. package/dist-cjs/lib/shapes/shared/crop.js +1 -0
  67. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  68. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  69. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  70. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  71. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  72. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  73. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  74. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  75. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  76. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  77. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  78. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  79. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  80. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  81. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  82. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  83. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  84. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  85. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  86. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  87. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  88. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  89. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  90. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  91. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  92. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  93. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  94. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  95. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  96. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  97. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +10 -11
  99. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  105. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  107. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  111. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  113. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +8 -6
  115. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  117. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  118. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  119. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  123. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  124. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  125. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  126. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  127. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  128. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  129. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  130. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  131. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  132. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  133. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  134. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  135. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  136. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  137. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  138. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  139. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  140. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  141. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  142. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  143. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  144. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  145. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  146. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  147. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  148. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  149. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  150. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  151. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  152. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  153. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  154. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  155. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  156. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  157. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  159. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  160. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  161. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  163. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  164. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  165. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  166. package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
  167. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  168. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
  169. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
  170. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  172. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  173. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  174. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  175. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  176. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  177. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  178. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  179. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  180. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  181. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  182. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  183. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  184. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  185. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  186. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  187. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  188. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  189. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  190. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  191. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
  192. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  193. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  194. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  195. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
  196. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  197. package/dist-cjs/lib/ui/context/actions.js +7 -8
  198. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  199. package/dist-cjs/lib/ui/context/components.js +1 -2
  200. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  201. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  202. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  203. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  204. package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
  205. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  206. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  207. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  208. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  209. package/dist-cjs/lib/ui/version.js +3 -3
  210. package/dist-cjs/lib/ui/version.js.map +1 -1
  211. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +16 -6
  212. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  213. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  214. package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
  215. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  216. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  217. package/dist-cjs/lib/utils/text/richText.js +15 -19
  218. package/dist-cjs/lib/utils/text/richText.js.map +3 -3
  219. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  220. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  221. package/dist-esm/index.d.mts +311 -242
  222. package/dist-esm/index.mjs +14 -5
  223. package/dist-esm/index.mjs.map +2 -2
  224. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  225. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  226. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  227. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  228. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  229. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  230. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  231. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  232. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  234. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  235. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  236. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  238. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  239. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
  240. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  241. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  242. package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
  243. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  244. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  245. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  246. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  248. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  250. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
  251. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  252. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  253. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  254. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  255. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  256. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  257. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  258. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  259. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
  260. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  261. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
  262. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  263. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  264. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  265. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  266. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  267. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
  268. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  270. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
  272. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  274. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  275. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  276. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
  277. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  278. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  279. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  280. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
  281. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  282. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  283. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  284. package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
  285. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  286. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  287. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  288. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  289. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  290. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  291. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  292. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  293. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  294. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  295. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  296. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  297. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  298. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  299. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  300. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  301. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  302. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  303. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  304. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  305. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  306. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +3 -8
  307. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  308. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  309. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  310. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  311. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  312. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  313. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  314. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  315. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  316. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +10 -11
  317. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  318. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  319. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  320. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  321. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  323. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  324. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  325. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  326. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  327. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  328. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  329. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  330. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  331. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  332. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +8 -6
  333. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  334. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  335. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  336. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  337. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  338. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  339. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  340. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  341. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  342. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +6 -19
  343. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  344. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  345. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  346. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  347. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  348. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  349. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  350. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  351. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  352. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  353. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  354. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  355. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  356. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  357. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  358. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  359. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  360. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  361. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  362. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  363. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  364. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  365. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  366. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  367. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  368. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  369. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  370. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  371. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  372. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  373. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  374. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  375. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  376. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  377. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  378. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  379. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  380. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  381. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  382. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  383. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  384. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
  385. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  386. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
  387. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
  388. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  389. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  390. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  391. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  392. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  393. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  394. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  395. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  396. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  397. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  398. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  399. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  400. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  401. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  402. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  403. package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
  404. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  405. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  406. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  407. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  408. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  409. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
  410. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  411. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  412. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  413. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
  414. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  415. package/dist-esm/lib/ui/context/actions.mjs +7 -8
  416. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  417. package/dist-esm/lib/ui/context/components.mjs +1 -2
  418. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  419. package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
  420. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  421. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  422. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  423. package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
  424. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  425. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  426. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  427. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  428. package/dist-esm/lib/ui/version.mjs +3 -3
  429. package/dist-esm/lib/ui/version.mjs.map +1 -1
  430. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +17 -6
  431. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  432. package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
  433. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  434. package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
  435. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  436. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  437. package/dist-esm/lib/utils/text/richText.mjs +12 -5
  438. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  439. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  440. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  441. package/package.json +18 -16
  442. package/src/index.ts +6 -2
  443. package/src/lib/Tldraw.test.tsx +46 -1
  444. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
  445. package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
  446. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  447. package/src/lib/defaultExternalContentHandlers.ts +13 -14
  448. package/src/lib/defaultSideEffects.ts +6 -1
  449. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  450. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  451. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
  452. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
  453. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  454. package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
  455. package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
  456. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
  457. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  458. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  459. package/src/lib/shapes/arrow/shared.ts +4 -4
  460. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  461. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +8 -5
  462. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  463. package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
  464. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  465. package/src/lib/shapes/draw/DrawShapeUtil.tsx +33 -27
  466. package/src/lib/shapes/draw/getPath.ts +31 -10
  467. package/src/lib/shapes/draw/toolStates/Drawing.ts +100 -90
  468. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +8 -1
  469. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  470. package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
  471. package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
  472. package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
  473. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  474. package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
  475. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  476. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +27 -24
  477. package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
  478. package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
  479. package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
  480. package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
  481. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
  482. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  483. package/src/lib/shapes/note/noteHelpers.ts +2 -2
  484. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  485. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
  486. package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
  487. package/src/lib/shapes/shared/RichTextLabel.tsx +14 -4
  488. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  489. package/src/lib/shapes/shared/crop.ts +1 -0
  490. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  491. package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
  492. package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
  493. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  494. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  495. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  496. package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
  497. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  498. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  499. package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
  500. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  501. package/src/lib/tools/EraserTool/childStates/Erasing.ts +7 -10
  502. package/src/lib/tools/EraserTool/childStates/Pointing.ts +5 -20
  503. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  504. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  505. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  506. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  507. package/src/lib/tools/SelectTool/DragAndDropManager.ts +14 -11
  508. package/src/lib/tools/SelectTool/childStates/Brushing.ts +8 -11
  509. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  510. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -4
  511. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  512. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  513. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  514. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  515. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +11 -12
  516. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +57 -16
  517. package/src/lib/tools/SelectTool/childStates/Idle.ts +64 -81
  518. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +7 -8
  519. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  520. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +9 -17
  521. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  522. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  523. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
  524. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  525. package/src/lib/tools/SelectTool/childStates/Resizing.ts +8 -10
  526. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  527. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +9 -10
  528. package/src/lib/tools/SelectTool/childStates/Translating.ts +16 -15
  529. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  530. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  531. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  532. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  533. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  534. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  535. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  536. package/src/lib/ui/TldrawUi.tsx +5 -2
  537. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  538. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  539. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  540. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  541. package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
  542. package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
  543. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  544. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  545. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  546. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  547. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  548. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
  549. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  550. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  551. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  552. package/src/lib/ui/components/menu-items.tsx +9 -15
  553. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  554. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  555. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
  556. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  557. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  558. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
  559. package/src/lib/ui/context/actions.tsx +15 -19
  560. package/src/lib/ui/context/components.tsx +1 -2
  561. package/src/lib/ui/hooks/menu-hooks.ts +9 -19
  562. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  563. package/src/lib/ui/hooks/useFlatten.ts +1 -2
  564. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  565. package/src/lib/ui/hooks/useTools.tsx +5 -7
  566. package/src/lib/ui/version.ts +3 -3
  567. package/src/lib/ui.css +27 -23
  568. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  569. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +19 -6
  570. package/src/lib/utils/export/exportAs.ts +2 -9
  571. package/src/lib/utils/frames/frames.ts +1 -1
  572. package/src/lib/utils/test-helpers.ts +62 -0
  573. package/src/lib/utils/text/richText.ts +13 -8
  574. package/src/lib/utils/tldr/buildFromV1Document.ts +21 -19
  575. package/src/test/Editor.test.tsx +78 -41
  576. package/src/test/EraserTool.test.ts +10 -12
  577. package/src/test/SelectTool.test.ts +11 -19
  578. package/src/test/TestEditor.ts +49 -51
  579. package/src/test/TldrawEditor.test.tsx +24 -20
  580. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  581. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  582. package/src/test/arrows-megabus.test.tsx +1 -1
  583. package/src/test/bindings.test.tsx +29 -25
  584. package/src/test/bindingsIndex.test.tsx +4 -4
  585. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  586. package/src/test/commands/cameraState.test.ts +299 -0
  587. package/src/test/commands/createShape.test.ts +64 -0
  588. package/src/test/commands/createShapes.test.ts +15 -1
  589. package/src/test/commands/getSvgString.test.ts +2 -2
  590. package/src/test/commands/isShapeOfType.test.ts +44 -0
  591. package/src/test/commands/putContent.test.ts +80 -1
  592. package/src/test/commands/setCamera.test.ts +13 -11
  593. package/src/test/commands/stackShapes.test.ts +34 -8
  594. package/src/test/commands/updateShape.test.ts +67 -0
  595. package/src/test/commands/updateShapes.test.ts +21 -5
  596. package/src/test/commands/zoomToBounds.test.ts +19 -3
  597. package/src/test/commands/zoomToSelection.test.ts +14 -3
  598. package/src/test/custom-clipping.test.ts +52 -44
  599. package/src/test/customSnapping.test.tsx +77 -62
  600. package/src/test/drawing.test.ts +17 -10
  601. package/src/test/duplicate.test.ts +1 -1
  602. package/src/test/flipShapes.test.ts +33 -0
  603. package/src/test/frames.test.ts +94 -2
  604. package/src/test/getCulledShapes.test.tsx +11 -3
  605. package/src/test/getShapeAtPoint.test.ts +2 -2
  606. package/src/test/groups.test.tsx +7 -4
  607. package/src/test/modifiers.test.ts +6 -6
  608. package/src/test/resizing.test.ts +16 -22
  609. package/src/test/selection-omnibus.test.ts +13 -13
  610. package/src/test/shapeutils.test.ts +1 -1
  611. package/src/test/spacebarPanning.test.ts +28 -10
  612. package/src/test/styles2.test.tsx +1 -1
  613. package/src/test/styles3.test.ts +5 -5
  614. package/src/test/test-jsx.tsx +72 -57
  615. package/src/test/text.test.ts +15 -17
  616. package/src/test/translating.test.ts +6 -8
  617. package/src/test/ui/BackToContent.test.tsx +111 -0
  618. package/tldraw.css +41 -35
  619. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  620. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  621. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  622. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  623. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  624. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  625. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  626. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  627. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  628. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  629. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  630. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  631. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  632. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  633. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
  634. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  635. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  636. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -27,7 +27,6 @@ module.exports = __toCommonJS(Idle_exports);
27
27
  var import_editor = require("@tldraw/editor");
28
28
  var import_arrowLabel = require("../../../shapes/arrow/arrowLabel");
29
29
  var import_getHitShapeOnCanvasPointerDown = require("../../selection-logic/getHitShapeOnCanvasPointerDown");
30
- var import_getShouldEnterCropModeOnPointerDown = require("../../selection-logic/getShouldEnterCropModeOnPointerDown");
31
30
  var import_selectOnCanvasPointerUp = require("../../selection-logic/selectOnCanvasPointerUp");
32
31
  var import_updateHoveredShapeId = require("../../selection-logic/updateHoveredShapeId");
33
32
  var import_selectHelpers = require("../selectHelpers");
@@ -57,7 +56,6 @@ class Idle extends import_editor.StateNode {
57
56
  (0, import_updateHoveredShapeId.updateHoveredShapeId)(this.editor);
58
57
  }
59
58
  onPointerDown(info) {
60
- const shouldEnterCropMode = info.ctrlKey && (0, import_getShouldEnterCropModeOnPointerDown.getShouldEnterCropMode)(this.editor);
61
59
  switch (info.target) {
62
60
  case "canvas": {
63
61
  const hitShape = (0, import_getHitShapeOnCanvasPointerDown.getHitShapeOnCanvasPointerDown)(this.editor);
@@ -71,9 +69,7 @@ class Idle extends import_editor.StateNode {
71
69
  }
72
70
  const selectedShapeIds = this.editor.getSelectedShapeIds();
73
71
  const onlySelectedShape = this.editor.getOnlySelectedShape();
74
- const {
75
- inputs: { currentPagePoint }
76
- } = this.editor;
72
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
77
73
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
78
74
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
79
75
  this.onPointerDown({
@@ -97,7 +93,7 @@ class Idle extends import_editor.StateNode {
97
93
  }
98
94
  case "handle": {
99
95
  if (this.editor.getIsReadonly()) break;
100
- if (this.editor.inputs.altKey) {
96
+ if (this.editor.inputs.getAltKey()) {
101
97
  this.parent.transition("pointing_shape", info);
102
98
  } else {
103
99
  this.parent.transition("pointing_handle", info);
@@ -126,7 +122,8 @@ class Idle extends import_editor.StateNode {
126
122
  case "top_right":
127
123
  case "bottom_left":
128
124
  case "bottom_right": {
129
- if (shouldEnterCropMode) {
125
+ const onlySelectedShape = this.editor.getOnlySelectedShape();
126
+ if (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {
130
127
  this.parent.transition("crop.pointing_crop_handle", info);
131
128
  } else {
132
129
  if (info.accelKey) {
@@ -155,12 +152,13 @@ class Idle extends import_editor.StateNode {
155
152
  }
156
153
  }
157
154
  onDoubleClick(info) {
158
- if (this.editor.inputs.shiftKey || info.phase !== "up") return;
155
+ if (this.editor.inputs.getShiftKey() || info.phase !== "up") return;
159
156
  if (info.ctrlKey || info.shiftKey) return;
160
157
  switch (info.target) {
161
158
  case "canvas": {
162
159
  const hoveredShape = this.editor.getHoveredShape();
163
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
160
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
161
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(currentPagePoint) ?? this.editor.getShapeAtPoint(currentPagePoint, {
164
162
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
165
163
  hitInside: false
166
164
  });
@@ -186,20 +184,31 @@ class Idle extends import_editor.StateNode {
186
184
  });
187
185
  return;
188
186
  }
189
- if (!this.editor.inputs.shiftKey) {
187
+ if (!this.editor.inputs.getShiftKey()) {
190
188
  this.handleDoubleClickOnCanvas(info);
191
189
  }
192
190
  break;
193
191
  }
194
192
  case "selection": {
195
- if (this.editor.getIsReadonly()) break;
196
193
  const onlySelectedShape = this.editor.getOnlySelectedShape();
197
194
  if (onlySelectedShape) {
198
195
  const util = this.editor.getShapeUtil(onlySelectedShape);
199
- if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {
200
- return;
196
+ const isEdge = info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom";
197
+ const isCorner = info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left";
198
+ if (this.editor.getIsReadonly()) {
199
+ if (this.editor.canEditShape(onlySelectedShape, {
200
+ type: isCorner ? "double-click-corner" : isEdge ? "double-click-edge" : "double-click"
201
+ })) {
202
+ this.startEditingShape(
203
+ onlySelectedShape,
204
+ info,
205
+ true
206
+ /* select all */
207
+ );
208
+ }
209
+ break;
201
210
  }
202
- if (info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom") {
211
+ if (isEdge) {
203
212
  const change = util.onDoubleClickEdge?.(onlySelectedShape, info);
204
213
  if (change) {
205
214
  this.editor.markHistoryStoppingPoint("double click edge");
@@ -208,7 +217,7 @@ class Idle extends import_editor.StateNode {
208
217
  return;
209
218
  }
210
219
  }
211
- if (info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left") {
220
+ if (isCorner) {
212
221
  const change = util.onDoubleClickCorner?.(onlySelectedShape, info);
213
222
  if (change) {
214
223
  this.editor.markHistoryStoppingPoint("double click corner");
@@ -217,11 +226,11 @@ class Idle extends import_editor.StateNode {
217
226
  return;
218
227
  }
219
228
  }
220
- if (util.canCrop(onlySelectedShape) && !this.editor.isShapeOrAncestorLocked(onlySelectedShape)) {
229
+ if (this.editor.canCropShape(onlySelectedShape)) {
221
230
  this.parent.transition("crop", info);
222
231
  return;
223
232
  }
224
- if (this.shouldStartEditingShape(onlySelectedShape)) {
233
+ if (this.editor.canEditShape(onlySelectedShape)) {
225
234
  this.startEditingShape(
226
235
  onlySelectedShape,
227
236
  info,
@@ -249,7 +258,7 @@ class Idle extends import_editor.StateNode {
249
258
  this.parent.transition("crop", info);
250
259
  return;
251
260
  }
252
- if (this.shouldStartEditingShape(shape)) {
261
+ if (this.editor.canEditShape(shape)) {
253
262
  this.startEditingShape(
254
263
  shape,
255
264
  info,
@@ -269,7 +278,7 @@ class Idle extends import_editor.StateNode {
269
278
  if (changes) {
270
279
  this.editor.updateShapes([changes]);
271
280
  } else {
272
- if (this.shouldStartEditingShape(shape)) {
281
+ if (this.editor.canEditShape(shape)) {
273
282
  this.startEditingShape(
274
283
  shape,
275
284
  info,
@@ -285,7 +294,7 @@ class Idle extends import_editor.StateNode {
285
294
  switch (info.target) {
286
295
  case "canvas": {
287
296
  const hoveredShape = this.editor.getHoveredShape();
288
- const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
297
+ const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(), {
289
298
  margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
290
299
  hitInside: false,
291
300
  hitLabels: true,
@@ -303,9 +312,7 @@ class Idle extends import_editor.StateNode {
303
312
  }
304
313
  const selectedShapeIds = this.editor.getSelectedShapeIds();
305
314
  const onlySelectedShape = this.editor.getOnlySelectedShape();
306
- const {
307
- inputs: { currentPagePoint }
308
- } = this.editor;
315
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
309
316
  if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
310
317
  if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
311
318
  this.onRightClick({
@@ -374,7 +381,7 @@ class Idle extends import_editor.StateNode {
374
381
  const onlySelectedShape = this.editor.getOnlySelectedShape();
375
382
  if (onlySelectedShape && // If it's a note shape, then edit on type
376
383
  this.editor.isShapeOfType(onlySelectedShape, "note") && // If it's not locked or anything
377
- this.shouldStartEditingShape(onlySelectedShape)) {
384
+ this.editor.canEditShape(onlySelectedShape)) {
378
385
  this.startEditingShape(
379
386
  onlySelectedShape,
380
387
  {
@@ -426,7 +433,7 @@ class Idle extends import_editor.StateNode {
426
433
  return;
427
434
  }
428
435
  const onlySelectedShape = this.editor.getOnlySelectedShape();
429
- if (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {
436
+ if (onlySelectedShape && this.editor.canEditShape(onlySelectedShape, { type: "press_enter" })) {
430
437
  this.startEditingShape(
431
438
  onlySelectedShape,
432
439
  {
@@ -439,7 +446,7 @@ class Idle extends import_editor.StateNode {
439
446
  );
440
447
  return;
441
448
  }
442
- if ((0, import_getShouldEnterCropModeOnPointerDown.getShouldEnterCropMode)(this.editor)) {
449
+ if (this.editor.canCropShape(onlySelectedShape)) {
443
450
  this.parent.transition("crop", info);
444
451
  }
445
452
  break;
@@ -453,16 +460,14 @@ class Idle extends import_editor.StateNode {
453
460
  }
454
461
  }
455
462
  }
456
- shouldStartEditingShape(shape = this.editor.getOnlySelectedShape()) {
457
- if (!shape) return false;
458
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return false;
459
- if (!this.canInteractWithShapeInReadOnly(shape)) return false;
460
- return this.editor.getShapeUtil(shape).canEdit(shape);
461
- }
462
463
  startEditingShape(shape, info, shouldSelectAll) {
463
- if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return;
464
+ const { editor } = this;
464
465
  this.editor.markHistoryStoppingPoint("editing shape");
465
- (0, import_selectHelpers.startEditingShapeWithLabel)(this.editor, shape, shouldSelectAll);
466
+ if ((0, import_selectHelpers.hasRichText)(shape)) {
467
+ (0, import_selectHelpers.startEditingShapeWithRichText)(editor, shape, { selectAll: shouldSelectAll });
468
+ } else {
469
+ editor.setEditingShape(shape);
470
+ }
466
471
  this.parent.transition("editing_shape", info);
467
472
  }
468
473
  isOverArrowLabelTest(shape) {
@@ -474,7 +479,7 @@ class Idle extends import_editor.StateNode {
474
479
  if (!this.editor.options.createTextOnCanvasDoubleClick) return;
475
480
  this.editor.markHistoryStoppingPoint("creating text shape");
476
481
  const id = (0, import_editor.createShapeId)();
477
- const { x, y } = this.editor.inputs.currentPagePoint;
482
+ const { x, y } = this.editor.inputs.getCurrentPagePoint();
478
483
  this.editor.createShapes([
479
484
  {
480
485
  id,
@@ -489,15 +494,8 @@ class Idle extends import_editor.StateNode {
489
494
  ]);
490
495
  const shape = this.editor.getShape(id);
491
496
  if (!shape) return;
492
- const util = this.editor.getShapeUtil(shape);
493
- if (this.editor.getIsReadonly()) {
494
- if (!util.canEditInReadonly(shape)) {
495
- return;
496
- }
497
- }
498
- this.editor.setEditingShape(id);
499
- this.editor.select(id);
500
- this.parent.transition("editing_shape", info);
497
+ if (!this.editor.canEditShape(shape)) return;
498
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, id, { info });
501
499
  }
502
500
  nudgeSelectedShapes(ephemeral = false) {
503
501
  const {
@@ -519,12 +517,6 @@ class Idle extends import_editor.StateNode {
519
517
  this.editor.nudgeShapes(selectedShapeIds, delta.mul(step));
520
518
  (0, import_editor.kickoutOccludedShapes)(this.editor, selectedShapeIds);
521
519
  }
522
- canInteractWithShapeInReadOnly(shape) {
523
- if (!this.editor.getIsReadonly()) return true;
524
- const util = this.editor.getShapeUtil(shape);
525
- if (util.canEditInReadonly(shape)) return true;
526
- return false;
527
- }
528
520
  }
529
521
  const MAJOR_NUDGE_FACTOR = 10;
530
522
  const MINOR_NUDGE_FACTOR = 1;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/Idle.ts"],
4
- "sourcesContent": ["import {\n\tEditor,\n\tStateNode,\n\tTLAdjacentDirection,\n\tTLClickEventInfo,\n\tTLGroupShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLTextShape,\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<TLGroupShape>(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<TLGroupShape>(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<TLGroupShape>(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<TLGroupShape>(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 (\n\t\t\t\t\tselectedShapes.every((shape) => this.editor.isShapeOfType<TLGroupShape>(shape, 'group'))\n\t\t\t\t) {\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<TLTextShape>([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'text',\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tprops: {\n\t\t\t\t\trichText: toRichText(''),\n\t\t\t\t\tautoSize: true,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape(id)\n\t\tif (!shape) return\n\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(shape)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.setEditingShape(id)\n\t\tthis.editor.select(id)\n\t\tthis.parent.transition('editing_shape', info)\n\t}\n\n\tprivate nudgeSelectedShapes(ephemeral = false) {\n\t\tconst {\n\t\t\teditor: {\n\t\t\t\tinputs: { keys },\n\t\t\t},\n\t\t} = this\n\n\t\t// We want to use the \"actual\" shift key state,\n\t\t// not the one that's in the editor.inputs.shiftKey,\n\t\t// because that one uses a short timeout on release\n\t\tconst shiftKey = keys.has('ShiftLeft')\n\n\t\tconst delta = new Vec(0, 0)\n\n\t\tif (keys.has('ArrowLeft')) delta.x -= 1\n\t\tif (keys.has('ArrowRight')) delta.x += 1\n\t\tif (keys.has('ArrowUp')) delta.y -= 1\n\t\tif (keys.has('ArrowDown')) delta.y += 1\n\n\t\tif (delta.equals(new Vec(0, 0))) return\n\n\t\tif (!ephemeral) this.editor.markHistoryStoppingPoint('nudge shapes')\n\n\t\tconst { gridSize } = this.editor.getDocumentSettings()\n\n\t\tconst step = this.editor.getInstanceState().isGridMode\n\t\t\t? shiftKey\n\t\t\t\t? gridSize * GRID_INCREMENT\n\t\t\t\t: gridSize\n\t\t\t: shiftKey\n\t\t\t\t? MAJOR_NUDGE_FACTOR\n\t\t\t\t: MINOR_NUDGE_FACTOR\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\tthis.editor.nudgeShapes(selectedShapeIds, delta.mul(step))\n\t\tkickoutOccludedShapes(this.editor, selectedShapeIds)\n\t}\n\n\tprivate canInteractWithShapeInReadOnly(shape: TLShape) {\n\t\tif (!this.editor.getIsReadonly()) return true\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tif (util.canEditInReadonly(shape)) return true\n\t\treturn false\n\t}\n}\n\nexport const MAJOR_NUDGE_FACTOR = 10\nexport const MINOR_NUDGE_FACTOR = 1\nexport const GRID_INCREMENT = 5\n\nfunction isPointInRotatedSelectionBounds(editor: Editor, point: VecLike) {\n\tconst selectionBounds = editor.getSelectionRotatedPageBounds()\n\tif (!selectionBounds) return false\n\n\tconst selectionRotation = editor.getSelectionRotation()\n\tif (!selectionRotation) return selectionBounds.containsPoint(point)\n\n\treturn pointInPolygon(\n\t\tpoint,\n\t\tselectionBounds.corners.map((c) => Vec.RotWith(c, selectionBounds.point, selectionRotation))\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAiBO;AACP,wBAAiC;AACjC,4CAA+C;AAC/C,iDAAuC;AACvC,qCAAwC;AACxC,kCAAqC;AACrC,2BAA2C;AAE3C,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,aAAa,wBAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,0BAAqC,CAAC;AAAA,EAE7B,UAAU;AAClB,SAAK,OAAO,qBAAqB,MAAS;AAC1C,0DAAqB,KAAK,MAAM;AAChC,SAAK,0BAA0B,CAAC;AAChC,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU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B,OAAO,qBAAqB;AACtD,MAAI,CAAC,kBAAmB,QAAO,gBAAgB,cAAc,KAAK;AAElE,aAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,kBAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAeO;AACP,wBAAiC;AACjC,4CAA+C;AAC/C,qCAAwC;AACxC,kCAAqC;AACrC,2BAA2D;AAE3D,MAAM,gCAAgC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,aAAa,wBAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAErB,0BAAqC,CAAC;AAAA,EAE7B,UAAU;AAClB,SAAK,OAAO,qBAAqB,MAAS;AAC1C,0DAAqB,KAAK,MAAM;AAChC,SAAK,0BAA0B,CAAC;AAChC,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,SAAS;AACjB,qDAAqB,OAAO;AAAA,EAC7B;AAAA,EAES,gBAAgB;AACxB,0DAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,cAAc,MAA0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,KAAK;AACtC,QAAI,KAAK,IAAI,YAAY,EAAG,OAAM,KAAK;AACvC,QAAI,KAAK,IAAI,SAAS,EAAG,OAAM,KAAK;AACpC,QAAI,KAAK,IAAI,WAAW,EAAG,OAAM,KAAK;AAEtC,QAAI,MAAM,OAAO,IAAI,kBAAI,GAAG,CAAC,CAAC,EAAG;AAEjC,QAAI,CAAC,UAAW,MAAK,OAAO,yBAAyB,cAAc;AAEnE,UAAM,EAAE,SAAS,IAAI,KAAK,OAAO,oBAAoB;AAErD,UAAM,OAAO,KAAK,OAAO,iBAAiB,EAAE,aACzC,WACC,WAAW,iBACX,WACD,WACC,qBACA;AAEJ,UAAM,mBAAmB,KAAK,OAAO,oBAAoB;AACzD,SAAK,OAAO,YAAY,kBAAkB,MAAM,IAAI,IAAI,CAAC;AACzD,6CAAsB,KAAK,QAAQ,gBAAgB;AAAA,EACpD;AACD;AAEO,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB;AAE9B,SAAS,gCAAgC,QAAgB,OAAgB;AACxE,QAAM,kBAAkB,OAAO,8BAA8B;AAC7D,MAAI,CAAC,gBAAiB,QAAO;AAE7B,QAAM,oBAAoB,OAAO,qBAAqB;AACtD,MAAI,CAAC,kBAAmB,QAAO,gBAAgB,cAAc,KAAK;AAElE,aAAO;AAAA,IACN;AAAA,IACA,gBAAgB,QAAQ,IAAI,CAAC,MAAM,kBAAI,QAAQ,GAAG,gBAAgB,OAAO,iBAAiB,CAAC;AAAA,EAC5F;AACD;",
6
6
  "names": ["shape"]
7
7
  }
@@ -23,6 +23,7 @@ __export(PointingArrowLabel_exports, {
23
23
  module.exports = __toCommonJS(PointingArrowLabel_exports);
24
24
  var import_editor = require("@tldraw/editor");
25
25
  var import_arrowLabel = require("../../../shapes/arrow/arrowLabel");
26
+ var import_selectHelpers = require("../selectHelpers");
26
27
  class PointingArrowLabel extends import_editor.StateNode {
27
28
  static id = "pointing_arrow_label";
28
29
  shapeId = "";
@@ -50,7 +51,7 @@ class PointingArrowLabel extends import_editor.StateNode {
50
51
  if (!labelGeometry) {
51
52
  throw Error(`Expected to find an arrow label geometry for shape: ${shape.id}`);
52
53
  }
53
- const { currentPagePoint } = this.editor.inputs;
54
+ const currentPagePoint = this.editor.inputs.getCurrentPagePoint();
54
55
  const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint);
55
56
  this._labelDragOffset = import_editor.Vec.Sub(labelGeometry.center, pointInShapeSpace);
56
57
  this.markId = this.editor.markHistoryStoppingPoint("label-drag start");
@@ -68,7 +69,7 @@ class PointingArrowLabel extends import_editor.StateNode {
68
69
  }
69
70
  _labelDragOffset = new import_editor.Vec(0, 0);
70
71
  onPointerMove() {
71
- const { isDragging } = this.editor.inputs;
72
+ const isDragging = this.editor.inputs.getIsDragging();
72
73
  if (!isDragging) return;
73
74
  if (this.didCtrlOnEnter) {
74
75
  this.parent.transition("brushing", this.info);
@@ -79,7 +80,7 @@ class PointingArrowLabel extends import_editor.StateNode {
79
80
  const options = this.editor.getShapeUtil("arrow").options;
80
81
  const geometry = (0, import_arrowLabel.getArrowBodyGeometry)(this.editor, shape);
81
82
  const transform = this.editor.getShapePageTransform(shape.id);
82
- const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint).add(this._labelDragOffset);
83
+ const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset);
83
84
  const defaultLabelPosition = (0, import_arrowLabel.getArrowLabelDefaultPosition)(this.editor, shape);
84
85
  let nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace);
85
86
  if (isNaN(nextLabelPosition)) {
@@ -108,9 +109,8 @@ class PointingArrowLabel extends import_editor.StateNode {
108
109
  if (!shape) return;
109
110
  if (this.didDrag || !this.wasAlreadySelected) {
110
111
  this.complete();
111
- } else if (!this.editor.getIsReadonly()) {
112
- this.editor.setEditingShape(shape.id);
113
- this.editor.setCurrentTool("select.editing_shape");
112
+ } else if (this.editor.canEditShape(shape)) {
113
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, shape.id);
114
114
  }
115
115
  }
116
116
  onCancel() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts"],
4
- "sourcesContent": ["import {\n\tGroup2d,\n\tStateNode,\n\tTLArrowShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tVec,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport {\n\tgetArrowBodyGeometry,\n\tgetArrowLabelDefaultPosition,\n} from '../../../shapes/arrow/arrowLabel'\n\nexport class PointingArrowLabel extends StateNode {\n\tstatic override id = 'pointing_arrow_label'\n\n\tshapeId = '' as TLShapeId\n\tmarkId = ''\n\twasAlreadySelected = false\n\tdidDrag = false\n\tdidCtrlOnEnter = false\n\n\tprivate info = {} as TLPointerEventInfo & {\n\t\tshape: TLArrowShape\n\t\tonInteractionEnd?: string | (() => void)\n\t\tisCreating: boolean\n\t}\n\n\tprivate updateCursor() {\n\t\tthis.editor.setCursor({ type: 'grabbing', rotation: 0 })\n\t}\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\tshape: TLArrowShape\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t\tisCreating: boolean\n\t\t}\n\t) {\n\t\tconst { shape } = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.info = info\n\t\tthis.shapeId = shape.id\n\t\tthis.didDrag = false\n\t\tthis.didCtrlOnEnter = info.accelKey\n\t\tthis.wasAlreadySelected = this.editor.getOnlySelectedShapeId() === shape.id\n\t\tthis.updateCursor()\n\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst labelGeometry = geometry.children[1]\n\t\tif (!labelGeometry) {\n\t\t\tthrow Error(`Expected to find an arrow label geometry for shape: ${shape.id}`)\n\t\t}\n\t\tconst { currentPagePoint } = this.editor.inputs\n\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint)\n\n\t\tthis._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace)\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('label-drag start')\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\t\tif (additiveSelectionKey) {\n\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, this.shapeId])\n\n\t\t\treturn\n\t\t}\n\n\t\tthis.editor.setSelectedShapes([this.shapeId])\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate _labelDragOffset = new Vec(0, 0)\n\n\toverride onPointerMove() {\n\t\tconst { isDragging } = this.editor.inputs\n\t\tif (!isDragging) return\n\n\t\tif (this.didCtrlOnEnter) {\n\t\t\tthis.parent.transition('brushing', this.info)\n\t\t\treturn\n\t\t}\n\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tconst options = this.editor.getShapeUtil<ArrowShapeUtil>('arrow').options\n\t\tconst geometry = getArrowBodyGeometry(this.editor, shape)\n\t\tconst transform = this.editor.getShapePageTransform(shape.id)\n\n\t\tconst pointInShapeSpace = this.editor\n\t\t\t.getPointInShapeSpace(shape, this.editor.inputs.currentPagePoint)\n\t\t\t.add(this._labelDragOffset)\n\n\t\tconst defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\n\t\tlet nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace)\n\n\t\tif (isNaN(nextLabelPosition)) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tconst nextLabelPoint = transform.applyToPoint(geometry.interpolateAlongEdge(nextLabelPosition))\n\t\tconst labelDefaultPoint = transform.applyToPoint(\n\t\t\tgeometry.interpolateAlongEdge(defaultLabelPosition)\n\t\t)\n\n\t\tif (\n\t\t\tVec.DistMin(\n\t\t\t\tnextLabelPoint,\n\t\t\t\tlabelDefaultPoint,\n\t\t\t\toptions.labelCenterSnapDistance / this.editor.getZoomLevel()\n\t\t\t)\n\t\t) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tthis.didDrag = true\n\t\tthis.editor.updateShape<TLArrowShape>({\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(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tTLShapeId,\n\tVec,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport {\n\tgetArrowBodyGeometry,\n\tgetArrowLabelDefaultPosition,\n} from '../../../shapes/arrow/arrowLabel'\nimport { startEditingShapeWithRichText } from '../selectHelpers'\n\nexport class PointingArrowLabel extends StateNode {\n\tstatic override id = 'pointing_arrow_label'\n\n\tshapeId = '' as TLShapeId\n\tmarkId = ''\n\twasAlreadySelected = false\n\tdidDrag = false\n\tdidCtrlOnEnter = false\n\n\tprivate info = {} as TLPointerEventInfo & {\n\t\tshape: TLArrowShape\n\t\tonInteractionEnd?: string | (() => void)\n\t\tisCreating: boolean\n\t}\n\n\tprivate updateCursor() {\n\t\tthis.editor.setCursor({ type: 'grabbing', rotation: 0 })\n\t}\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\tshape: TLArrowShape\n\t\t\tonInteractionEnd?: string | (() => void)\n\t\t\tisCreating: boolean\n\t\t}\n\t) {\n\t\tconst { shape } = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.info = info\n\t\tthis.shapeId = shape.id\n\t\tthis.didDrag = false\n\t\tthis.didCtrlOnEnter = info.accelKey\n\t\tthis.wasAlreadySelected = this.editor.getOnlySelectedShapeId() === shape.id\n\t\tthis.updateCursor()\n\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst labelGeometry = geometry.children[1]\n\t\tif (!labelGeometry) {\n\t\t\tthrow Error(`Expected to find an arrow label geometry for shape: ${shape.id}`)\n\t\t}\n\t\tconst currentPagePoint = this.editor.inputs.getCurrentPagePoint()\n\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint)\n\n\t\tthis._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace)\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('label-drag start')\n\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\t\tif (additiveSelectionKey) {\n\t\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\t\t\tthis.editor.setSelectedShapes([...selectedShapeIds, this.shapeId])\n\n\t\t\treturn\n\t\t}\n\n\t\tthis.editor.setSelectedShapes([this.shapeId])\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate _labelDragOffset = new Vec(0, 0)\n\n\toverride onPointerMove() {\n\t\tconst isDragging = this.editor.inputs.getIsDragging()\n\t\tif (!isDragging) return\n\n\t\tif (this.didCtrlOnEnter) {\n\t\t\tthis.parent.transition('brushing', this.info)\n\t\t\treturn\n\t\t}\n\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tconst options = this.editor.getShapeUtil<ArrowShapeUtil>('arrow').options\n\t\tconst geometry = getArrowBodyGeometry(this.editor, shape)\n\t\tconst transform = this.editor.getShapePageTransform(shape.id)\n\n\t\tconst pointInShapeSpace = this.editor\n\t\t\t.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint())\n\t\t\t.add(this._labelDragOffset)\n\n\t\tconst defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\n\t\tlet nextLabelPosition = geometry.uninterpolateAlongEdge(pointInShapeSpace)\n\n\t\tif (isNaN(nextLabelPosition)) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tconst nextLabelPoint = transform.applyToPoint(geometry.interpolateAlongEdge(nextLabelPosition))\n\t\tconst labelDefaultPoint = transform.applyToPoint(\n\t\t\tgeometry.interpolateAlongEdge(defaultLabelPosition)\n\t\t)\n\n\t\tif (\n\t\t\tVec.DistMin(\n\t\t\t\tnextLabelPoint,\n\t\t\t\tlabelDefaultPoint,\n\t\t\t\toptions.labelCenterSnapDistance / this.editor.getZoomLevel()\n\t\t\t)\n\t\t) {\n\t\t\tnextLabelPosition = defaultLabelPosition\n\t\t}\n\n\t\tthis.didDrag = true\n\t\tthis.editor.updateShape({\n\t\t\tid: shape.id,\n\t\t\ttype: shape.type,\n\t\t\tprops: { labelPosition: nextLabelPosition },\n\t\t})\n\t}\n\n\toverride onPointerUp() {\n\t\tconst shape = this.editor.getShape<TLArrowShape>(this.shapeId)\n\t\tif (!shape) return\n\n\t\tif (this.didDrag || !this.wasAlreadySelected) {\n\t\t\tthis.complete()\n\t\t} else if (this.editor.canEditShape(shape)) {\n\t\t\tstartEditingShapeWithRichText(this.editor, shape.id)\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, {})\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, {})\n\t\t\t} else {\n\t\t\t\tonInteractionEnd()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOO;AAEP,wBAGO;AACP,2BAA8C;AAEvC,MAAM,2BAA2B,wBAAU;AAAA,EACjD,OAAgB,KAAK;AAAA,EAErB,UAAU;AAAA,EACV,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AC,KAAK,oBAAoB;AAC7C,WAAK,SAAS;AAAA,IACf,WAAW,KAAK,OAAO,aAAa,KAAK,GAAG;AAC3C,8DAA8B,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
  }
@@ -35,7 +35,7 @@ class PointingCanvas extends import_editor.StateNode {
35
35
  }
36
36
  }
37
37
  onPointerMove(info) {
38
- if (this.editor.inputs.isDragging) {
38
+ if (this.editor.inputs.getIsDragging()) {
39
39
  this.parent.transition("brushing", info);
40
40
  }
41
41
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/tools/SelectTool/childStates/PointingCanvas.ts"],
4
- "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\n\nexport class PointingCanvas extends StateNode {\n\tstatic override id = 'pointing_canvas'\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tif (!additiveSelectionKey) {\n\t\t\tif (this.editor.getSelectedShapeIds().length > 0) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting none')\n\t\t\t\tthis.editor.selectNone()\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tthis.parent.transition('brushing', info)\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// todo: also make this deselect\n\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8C;AAC9C,qCAAwC;AAEjC,MAAM,uBAAuB,wBAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAEZ,QAAQ,MAAiD;AACjE,UAAM,uBAAuB,KAAK,YAAY,KAAK;AAEnD,QAAI,CAAC,sBAAsB;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,SAAS,GAAG;AACjD,aAAK,OAAO,yBAAyB,gBAAgB;AACrD,aAAK,OAAO,WAAW;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,WAAK,OAAO,WAAW,YAAY,IAAI;AAAA,IACxC;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAE9C,gEAAwB,KAAK,QAAQ,IAAI;AACzC,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,WAAW;AAClB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { StateNode, TLPointerEventInfo } from '@tldraw/editor'\nimport { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'\n\nexport class PointingCanvas extends StateNode {\n\tstatic override id = 'pointing_canvas'\n\n\toverride onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {\n\t\tconst additiveSelectionKey = info.shiftKey || info.accelKey\n\n\t\tif (!additiveSelectionKey) {\n\t\t\tif (this.editor.getSelectedShapeIds().length > 0) {\n\t\t\t\tthis.editor.markHistoryStoppingPoint('selecting none')\n\t\t\t\tthis.editor.selectNone()\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tthis.parent.transition('brushing', info)\n\t\t}\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// todo: also make this deselect\n\t\tselectOnCanvasPointerUp(this.editor, info)\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate complete() {\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA8C;AAC9C,qCAAwC;AAEjC,MAAM,uBAAuB,wBAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAEZ,QAAQ,MAAiD;AACjE,UAAM,uBAAuB,KAAK,YAAY,KAAK;AAEnD,QAAI,CAAC,sBAAsB;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,SAAS,GAAG;AACjD,aAAK,OAAO,yBAAyB,gBAAgB;AACrD,aAAK,OAAO,WAAW;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,WAAK,OAAO,WAAW,YAAY,IAAI;AAAA,IACxC;AAAA,EACD;AAAA,EAES,YAAY,MAA0B;AAE9C,gEAAwB,KAAK,QAAQ,IAAI;AACzC,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEQ,WAAW;AAClB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -62,12 +62,7 @@ class PointingHandle extends import_editor.StateNode {
62
62
  const { editor } = this;
63
63
  const nextNote = getNoteForAdjacentPosition(editor, shape, handle, false);
64
64
  if (nextNote) {
65
- (0, import_selectHelpers.startEditingShapeWithLabel)(
66
- editor,
67
- nextNote,
68
- true
69
- /* selectAll */
70
- );
65
+ (0, import_selectHelpers.startEditingShapeWithRichText)(editor, nextNote, { selectAll: true });
71
66
  return;
72
67
  }
73
68
  }
@@ -75,7 +70,7 @@ class PointingHandle extends import_editor.StateNode {
75
70
  }
76
71
  onPointerMove(info) {
77
72
  const { editor } = this;
78
- if (editor.inputs.isDragging) {
73
+ if (editor.inputs.getIsDragging()) {
79
74
  if (this.didCtrlOnEnter) {
80
75
  this.parent.transition("brushing", info);
81
76
  } else {
@@ -93,7 +88,7 @@ class PointingHandle extends import_editor.StateNode {
93
88
  if (editor.isShapeOfType(shape, "note")) {
94
89
  const nextNote = getNoteForAdjacentPosition(editor, shape, handle, true);
95
90
  if (nextNote) {
96
- const centeredOnPointer = editor.getPointInParentSpace(nextNote, editor.inputs.originPagePoint).sub(import_editor.Vec.Rot(import_noteHelpers.NOTE_CENTER_OFFSET.clone().mul(shape.props.scale), nextNote.rotation));
91
+ const centeredOnPointer = editor.getPointInParentSpace(nextNote, editor.inputs.getOriginPagePoint()).sub(import_editor.Vec.Rot(import_noteHelpers.NOTE_CENTER_OFFSET.clone().mul(shape.props.scale), nextNote.rotation));
97
92
  editor.updateShape({ ...nextNote, x: centeredOnPointer.x, y: centeredOnPointer.y });
98
93
  editor.setHoveredShape(nextNote.id).select(nextNote.id).setCurrentTool("select.translating", {
99
94
  ...this.info,
@@ -102,12 +97,7 @@ class PointingHandle extends import_editor.StateNode {
102
97
  onInteractionEnd: "note",
103
98
  isCreating: true,
104
99
  onCreate: () => {
105
- (0, import_selectHelpers.startEditingShapeWithLabel)(
106
- editor,
107
- nextNote,
108
- true
109
- /* selectAll */
110
- );
100
+ (0, import_selectHelpers.startEditingShapeWithRichText)(editor, nextNote, { selectAll: true });
111
101
  }
112
102
  });
113
103
  return;