tldraw 4.2.2 → 4.2.3

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