tldraw 5.4.0-next.ebc95cf01337 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/DOCS.md +2826 -3226
  2. package/RELEASE_NOTES.md +190 -2
  3. package/dist-cjs/index.js +1 -1
  4. package/dist-cjs/lib/defaultExternalContentHandlers.js +30 -14
  5. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  6. package/dist-cjs/lib/shapes/arrow/curved-arrow.js +2 -2
  7. package/dist-cjs/lib/shapes/arrow/curved-arrow.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +2 -2
  9. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/getArrowInfo.js +1 -1
  11. package/dist-cjs/lib/shapes/arrow/getArrowInfo.js.map +2 -2
  12. package/dist-cjs/lib/shapes/arrow/straight-arrow.js +2 -2
  13. package/dist-cjs/lib/shapes/arrow/straight-arrow.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +2 -3
  15. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  16. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -5
  17. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  18. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +8 -6
  19. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
  20. package/dist-cjs/lib/shapes/geo/getGeoShapePath.js +3 -1
  21. package/dist-cjs/lib/shapes/geo/getGeoShapePath.js.map +2 -2
  22. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +2 -3
  23. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  24. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +1 -1
  25. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  26. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +2 -6
  27. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  28. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
  29. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/note/noteHelpers.js +6 -5
  31. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  32. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +1 -1
  33. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  34. package/dist-cjs/lib/shapes/shared/crop.js +1 -1
  35. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  36. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +1 -1
  37. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  38. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +1 -0
  39. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  40. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -2
  41. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  42. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +2 -0
  43. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  44. package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js +6 -0
  45. package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js.map +2 -2
  46. package/dist-cjs/lib/tools/SelectTool/SelectTool.js +3 -0
  47. package/dist-cjs/lib/tools/SelectTool/SelectTool.js.map +2 -2
  48. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +1 -0
  49. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  50. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js +1 -0
  51. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js.map +2 -2
  52. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -3
  53. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  54. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +6 -3
  55. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  56. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +1 -1
  57. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  58. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +3 -0
  59. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  60. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +1 -0
  61. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  62. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +1 -1
  63. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  64. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +22 -30
  65. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  66. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +1 -3
  67. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  68. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +4 -1
  69. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  70. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +10 -0
  71. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  72. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +1 -8
  73. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  74. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +6 -1
  75. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  76. package/dist-cjs/lib/ui/components/Dialogs.js +8 -0
  77. package/dist-cjs/lib/ui/components/Dialogs.js.map +2 -2
  78. package/dist-cjs/lib/ui/components/EditLinkDialog.js +5 -5
  79. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  80. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +4 -20
  81. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  82. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js +2 -0
  83. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +2 -2
  84. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +1 -0
  85. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  86. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +10 -8
  87. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  88. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +20 -1
  89. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  90. package/dist-cjs/lib/ui/context/actions.js +8 -7
  91. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  92. package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js +1 -1
  93. package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js.map +2 -2
  94. package/dist-cjs/lib/ui/version.js +3 -3
  95. package/dist-cjs/lib/ui/version.js.map +1 -1
  96. package/dist-esm/index.mjs +1 -1
  97. package/dist-esm/lib/defaultExternalContentHandlers.mjs +30 -14
  98. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  99. package/dist-esm/lib/shapes/arrow/curved-arrow.mjs +2 -2
  100. package/dist-esm/lib/shapes/arrow/curved-arrow.mjs.map +2 -2
  101. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +2 -2
  102. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  103. package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs +1 -1
  104. package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs.map +2 -2
  105. package/dist-esm/lib/shapes/arrow/straight-arrow.mjs +2 -2
  106. package/dist-esm/lib/shapes/arrow/straight-arrow.mjs.map +2 -2
  107. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +3 -4
  108. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  109. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -5
  110. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  111. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +8 -6
  112. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
  113. package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs +3 -1
  114. package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs.map +2 -2
  115. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +3 -4
  116. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  117. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +1 -1
  118. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  119. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +2 -7
  120. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  121. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +4 -4
  122. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  123. package/dist-esm/lib/shapes/note/noteHelpers.mjs +6 -5
  124. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  125. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +1 -1
  126. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  127. package/dist-esm/lib/shapes/shared/crop.mjs +1 -1
  128. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  129. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +2 -2
  130. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  131. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +1 -0
  132. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  133. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -2
  134. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  135. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +2 -0
  136. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  137. package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs +6 -0
  138. package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs.map +2 -2
  139. package/dist-esm/lib/tools/SelectTool/SelectTool.mjs +3 -0
  140. package/dist-esm/lib/tools/SelectTool/SelectTool.mjs.map +2 -2
  141. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +1 -0
  142. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  143. package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs +1 -0
  144. package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs.map +2 -2
  145. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -3
  146. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  147. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +6 -3
  148. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  149. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +1 -1
  150. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  151. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +3 -0
  152. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  153. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -1
  154. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  155. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +1 -1
  156. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  157. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +22 -31
  158. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  159. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +1 -3
  160. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  161. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +4 -1
  162. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  163. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +10 -0
  164. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  165. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +1 -8
  166. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  167. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +7 -2
  168. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  169. package/dist-esm/lib/ui/components/Dialogs.mjs +9 -1
  170. package/dist-esm/lib/ui/components/Dialogs.mjs.map +2 -2
  171. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +5 -5
  172. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  173. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +5 -22
  174. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  175. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs +2 -0
  176. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +2 -2
  177. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +1 -0
  178. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  179. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +10 -8
  180. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  181. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +20 -1
  182. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  183. package/dist-esm/lib/ui/context/actions.mjs +8 -7
  184. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  185. package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs +2 -2
  186. package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs.map +2 -2
  187. package/dist-esm/lib/ui/version.mjs +3 -3
  188. package/dist-esm/lib/ui/version.mjs.map +1 -1
  189. package/package.json +12 -6
  190. package/src/lib/defaultExternalContentHandlers.test.ts +43 -0
  191. package/src/lib/defaultExternalContentHandlers.ts +38 -16
  192. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +17 -0
  193. package/src/lib/shapes/arrow/curved-arrow.ts +2 -2
  194. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +5 -3
  195. package/src/lib/shapes/arrow/getArrowInfo.ts +2 -1
  196. package/src/lib/shapes/arrow/straight-arrow.ts +2 -2
  197. package/src/lib/shapes/arrow/toolStates/Idle.tsx +3 -4
  198. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +10 -6
  199. package/src/lib/shapes/draw/DrawShapeTool.test.ts +19 -0
  200. package/src/lib/shapes/draw/toolStates/Drawing.ts +12 -6
  201. package/src/lib/shapes/frame/FrameShapeTool.test.ts +17 -0
  202. package/src/lib/shapes/geo/GeoShapeTool.test.ts +28 -0
  203. package/src/lib/shapes/geo/getGeoShapePath.ts +3 -1
  204. package/src/lib/shapes/geo/toolStates/Idle.ts +3 -4
  205. package/src/lib/shapes/geo/toolStates/Pointing.ts +2 -1
  206. package/src/lib/shapes/line/LineShapeTool.test.ts +30 -1
  207. package/src/lib/shapes/line/toolStates/Pointing.ts +6 -7
  208. package/src/lib/shapes/note/NoteShapeTool.test.ts +45 -0
  209. package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -4
  210. package/src/lib/shapes/note/noteHelpers.ts +18 -8
  211. package/src/lib/shapes/note/toolStates/Pointing.ts +2 -1
  212. package/src/lib/shapes/shared/crop.ts +7 -1
  213. package/src/lib/shapes/text/TextShapeTool.test.ts +33 -0
  214. package/src/lib/shapes/text/toolStates/Idle.ts +2 -2
  215. package/src/lib/shapes/text/toolStates/Pointing.ts +3 -0
  216. package/src/lib/shapes/video/VideoShapeUtil.tsx +4 -2
  217. package/src/lib/tools/EraserTool/childStates/Erasing.ts +5 -0
  218. package/src/lib/tools/HandTool/childStates/OneFingerZooming.ts +10 -0
  219. package/src/lib/tools/SelectTool/SelectTool.ts +4 -0
  220. package/src/lib/tools/SelectTool/childStates/Brushing.ts +4 -0
  221. package/src/lib/tools/SelectTool/childStates/Crop/Crop.ts +4 -0
  222. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +3 -4
  223. package/src/lib/tools/SelectTool/childStates/Idle.ts +10 -3
  224. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
  225. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +4 -0
  226. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +6 -1
  227. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -1
  228. package/src/lib/tools/SelectTool/childStates/Resizing.ts +30 -33
  229. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +3 -3
  230. package/src/lib/tools/SelectTool/childStates/Translating.ts +6 -0
  231. package/src/lib/tools/SelectTool/selectHelpers.ts +21 -0
  232. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -9
  233. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +8 -2
  234. package/src/lib/ui/components/Dialogs.tsx +17 -1
  235. package/src/lib/ui/components/EditLinkDialog.tsx +8 -7
  236. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +5 -23
  237. package/src/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.tsx +2 -0
  238. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +1 -0
  239. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +13 -8
  240. package/src/lib/ui/components/primitives/TldrawUiSlider.test.tsx +92 -0
  241. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +25 -1
  242. package/src/lib/ui/context/actions.tsx +25 -7
  243. package/src/lib/ui/hooks/useCommentingEnabled.ts +5 -3
  244. package/src/lib/ui/version.ts +3 -3
  245. package/src/test/ClickManager.test.ts +18 -0
  246. package/src/test/Editor.test.tsx +3 -0
  247. package/src/test/EraserTool.test.ts +18 -2
  248. package/src/test/HandTool.test.ts +21 -0
  249. package/src/test/LaserTool.test.ts +46 -0
  250. package/src/test/ScribbleManager.test.ts +19 -0
  251. package/src/test/SelectTool.test.ts +110 -0
  252. package/src/test/TldrawEditor.test.tsx +18 -0
  253. package/src/test/VideoShapeUtil.test.tsx +126 -0
  254. package/src/test/actions-menu-readonly.test.tsx +37 -0
  255. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +6 -6
  256. package/src/test/commands/lockShapes.test.ts +11 -0
  257. package/src/test/commands/packShapes.test.ts +20 -0
  258. package/src/test/commands/putContent.test.ts +35 -1
  259. package/src/test/commands/setCamera.test.ts +69 -0
  260. package/src/test/commands/stackShapes.test.ts +12 -0
  261. package/src/test/commands/updateViewportPageBounds.test.ts +8 -0
  262. package/src/test/cropping.test.ts +162 -0
  263. package/src/test/customSnapping.test.tsx +32 -0
  264. package/src/test/defaultHandleExternalFileContent.test.ts +86 -0
  265. package/src/test/drawing.test.ts +60 -1
  266. package/src/test/duplicate.test.ts +22 -0
  267. package/src/test/frames.test.ts +51 -0
  268. package/src/test/getShapeAtPoint.test.ts +44 -1
  269. package/src/test/handleDeepLink.test.tsx +15 -0
  270. package/src/test/minimap-wheel.test.tsx +48 -0
  271. package/src/test/resizing.test.ts +46 -0
  272. package/src/test/selection-omnibus.test.ts +50 -0
  273. package/src/test/spacebarPanning.test.ts +58 -0
  274. package/src/test/translating.test.ts +42 -0
  275. package/src/test/ui/AltTextEditor.test.tsx +51 -0
  276. package/src/test/ui/ContextMenu.test.tsx +61 -2
  277. package/src/test/ui/EditLinkDialog.test.tsx +77 -0
  278. package/src/test/ui/ImageToolbar.test.tsx +58 -0
  279. package/src/test/ui/StylePanel.test.tsx +33 -2
  280. package/src/test/ui/keyboardShortcuts.test.tsx +27 -0
  281. package/src/test/ui/presenceActivity.test.tsx +44 -0
  282. package/src/test/ui/unlockAll.test.tsx +55 -0
  283. package/src/test/ui-outside-editor.test.tsx +74 -0
  284. package/src/test/viewport-following.test.ts +29 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/ui/hooks/useCommentingEnabled.ts"],
4
- "sourcesContent": ["import { useLicenseContext, useLicenseFeatureFlag } from '@tldraw/editor'\n\n/**\n * Whether the commenting feature is licensed for this editor. The default comment quick action and\n * its keyboard shortcut are hidden/disabled unless this is true. Enabled in development; in\n * production it requires a license that includes the commenting feature (or the collaboration\n * umbrella that grants it). Reactive: re-reads when license validation resolves.\n *\n * @internal\n */\nexport function useCommentingEnabled(): boolean {\n\treturn useLicenseFeatureFlag(useLicenseContext(), 'commenting')\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB,6BAA6B;AAUlD,SAAS,uBAAgC;AAC/C,SAAO,sBAAsB,kBAAkB,GAAG,YAAY;AAC/D;",
4
+ "sourcesContent": ["import { useLicenseFeatureFlag, useMaybeLicenseManager } from '@tldraw/editor'\n\n/**\n * Whether the commenting feature is licensed for this editor. The default comment quick action and\n * its keyboard shortcut are hidden/disabled unless this is true. Enabled in development; in\n * production it requires a license that includes the commenting feature (or the collaboration\n * umbrella that grants it). Reactive: re-reads when license validation resolves. Works outside\n * `<Tldraw />` too: UI mounted via `EditorProvider` resolves the license through the editor, and\n * with no editor at all this is `false`.\n *\n * @internal\n */\nexport function useCommentingEnabled(): boolean {\n\treturn useLicenseFeatureFlag(useMaybeLicenseManager(), 'commenting')\n}\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB,8BAA8B;AAYvD,SAAS,uBAAgC;AAC/C,SAAO,sBAAsB,uBAAuB,GAAG,YAAY;AACpE;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,8 @@
1
- const version = "5.4.0-next.ebc95cf01337";
1
+ const version = "5.4.0";
2
2
  const publishDates = {
3
3
  major: "2026-05-06T16:28:18.473Z",
4
- minor: "2026-08-13T15:10:11.500Z",
5
- patch: "2026-08-13T15:10:11.500Z"
4
+ minor: "2026-09-02T11:04:02.901Z",
5
+ patch: "2026-09-02T11:04:02.901Z"
6
6
  };
7
7
  export {
8
8
  publishDates,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/ui/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.4.0-next.ebc95cf01337'\nexport const publishDates = {\n\tmajor: '2026-05-06T16:28:18.473Z',\n\tminor: '2026-08-13T15:10:11.500Z',\n\tpatch: '2026-08-13T15:10:11.500Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.4.0'\nexport const publishDates = {\n\tmajor: '2026-05-06T16:28:18.473Z',\n\tminor: '2026-09-02T11:04:02.901Z',\n\tpatch: '2026-09-02T11:04:02.901Z',\n}\n"],
5
5
  "mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "tldraw",
3
3
  "description": "A tiny little drawing editor.",
4
- "version": "5.4.0-next.ebc95cf01337",
4
+ "version": "5.4.0",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
8
8
  },
9
9
  "homepage": "https://tldraw.dev",
10
10
  "license": "SEE LICENSE IN LICENSE.md",
11
+ "tldraw_product": {
12
+ "stableId": "tldraw:sdk-core",
13
+ "name": "SDK",
14
+ "type": "product",
15
+ "premium": false
16
+ },
11
17
  "repository": {
12
18
  "type": "git",
13
19
  "url": "https://github.com/tldraw/tldraw"
@@ -63,11 +69,11 @@
63
69
  "@tiptap/pm": "^3.12.1",
64
70
  "@tiptap/react": "^3.12.1",
65
71
  "@tiptap/starter-kit": "^3.12.1",
66
- "@tldraw/driver": "5.4.0-next.ebc95cf01337",
67
- "@tldraw/editor": "5.4.0-next.ebc95cf01337",
68
- "@tldraw/state": "5.4.0-next.ebc95cf01337",
69
- "@tldraw/store": "5.4.0-next.ebc95cf01337",
70
- "@tldraw/tlschema": "5.4.0-next.ebc95cf01337",
72
+ "@tldraw/driver": "5.4.0",
73
+ "@tldraw/editor": "5.4.0",
74
+ "@tldraw/state": "5.4.0",
75
+ "@tldraw/store": "5.4.0",
76
+ "@tldraw/tlschema": "5.4.0",
71
77
  "classnames": "^2.5.1",
72
78
  "idb": "^7.1.1",
73
79
  "lz-string": "^1.5.0",
@@ -9,6 +9,7 @@ import {
9
9
  import { TestEditor } from '../test/TestEditor'
10
10
  import { defaultAssetUtils } from './defaultAssetUtils'
11
11
  import {
12
+ defaultHandleExternalTextContent,
12
13
  defaultHandleExternalUrlContent,
13
14
  notifyIfFileNotAllowed,
14
15
  registerDefaultExternalContentHandlers,
@@ -201,6 +202,21 @@ describe('defaultHandleExternalUrlContent', () => {
201
202
  expect(addToast).not.toHaveBeenCalled()
202
203
  })
203
204
 
205
+ it('selects the created bookmark', async () => {
206
+ editor = new TestEditor()
207
+ const { opts } = makeOpts()
208
+
209
+ await defaultHandleExternalUrlContent(
210
+ editor,
211
+ { url: 'https://example.com', point: { x: 0, y: 0 } },
212
+ opts
213
+ )
214
+
215
+ const [bookmark] = editor.getCurrentPageShapes()
216
+ expect(bookmark.type).toBe('bookmark')
217
+ expect(editor.getSelectedShapeIds()).toEqual([bookmark.id])
218
+ })
219
+
204
220
  it('shows a toast and logs the url for a url with an invalid protocol', async () => {
205
221
  // Regression test for #8097: dragging content from a browser tab in Chrome
206
222
  // with an ad blocker active supplies a DataTransfer url rewritten to
@@ -231,3 +247,30 @@ describe('defaultHandleExternalUrlContent', () => {
231
247
  consoleWarn.mockRestore()
232
248
  })
233
249
  })
250
+
251
+ describe('defaultHandleExternalTextContent', () => {
252
+ let editor: TestEditor
253
+
254
+ afterEach(() => {
255
+ editor?.dispose()
256
+ })
257
+
258
+ it('selects the created text shape', async () => {
259
+ editor = new TestEditor()
260
+
261
+ await defaultHandleExternalTextContent(editor, { text: 'hello', point: { x: 0, y: 0 } })
262
+
263
+ const [text] = editor.getCurrentPageShapes()
264
+ expect(text.type).toBe('text')
265
+ expect(editor.getSelectedShapeIds()).toEqual([text.id])
266
+ })
267
+
268
+ it('does not select anything when the page is full and no shape is created', async () => {
269
+ editor = new TestEditor({ options: { maxShapesPerPage: 0 } })
270
+
271
+ await defaultHandleExternalTextContent(editor, { text: 'hello', point: { x: 0, y: 0 } })
272
+
273
+ expect(editor.getCurrentPageShapes()).toEqual([])
274
+ expect(editor.getSelectedShapeIds()).toEqual([])
275
+ })
276
+ })
@@ -424,7 +424,19 @@ export async function defaultHandleExternalFileContent(
424
424
  })
425
425
  continue
426
426
  }
427
- const assetInfo = await getAssetInfo(editor, sanitizedFile)
427
+ // An undecodable image rejects here; uncaught, it aborts the whole drop,
428
+ // including files that already succeeded, with no toast (#10438).
429
+ let assetInfo: TLAsset | null
430
+ try {
431
+ assetInfo = await getAssetInfo(editor, sanitizedFile)
432
+ } catch (error) {
433
+ toasts.addToast({
434
+ title: msg('assets.files.upload-failed'),
435
+ severity: 'error',
436
+ })
437
+ console.error(error)
438
+ continue
439
+ }
428
440
  if (!assetInfo) continue
429
441
  if (assetInfo.type === 'image') {
430
442
  editor.createTemporaryAssetPreview(assetInfo.id, sanitizedFile)
@@ -554,22 +566,30 @@ export async function defaultHandleExternalTextContent(
554
566
  const newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)
555
567
  const shapeId = createShapeId()
556
568
 
557
- // Allow this to trigger the max shapes reached alert
558
- editor.createShapes([
559
- {
560
- id: shapeId,
561
- type: 'text',
562
- x: newPoint.x,
563
- y: newPoint.y,
564
- props: {
565
- richText: richTextToPaste,
566
- // if the text has more than one line, align it to the left
567
- textAlign: align,
568
- autoSize,
569
- w,
569
+ editor.run(() => {
570
+ // Allow this to trigger the max shapes reached alert
571
+ editor.createShapes([
572
+ {
573
+ id: shapeId,
574
+ type: 'text',
575
+ x: newPoint.x,
576
+ y: newPoint.y,
577
+ props: {
578
+ richText: richTextToPaste,
579
+ // if the text has more than one line, align it to the left
580
+ textAlign: align,
581
+ autoSize,
582
+ w,
583
+ },
570
584
  },
571
- },
572
- ])
585
+ ])
586
+
587
+ // createShapes silently creates nothing when the page is full, so only
588
+ // select the shape if it actually exists
589
+ if (editor.getShape(shapeId)) {
590
+ editor.select(shapeId)
591
+ }
592
+ })
573
593
  }
574
594
 
575
595
  /** @public */
@@ -623,6 +643,8 @@ export async function defaultHandleExternalUrlContent(
623
643
  })
624
644
  return
625
645
  }
646
+
647
+ editor.select(result.value.id)
626
648
  }
627
649
 
628
650
  /** @public */
@@ -88,6 +88,23 @@ describe('When in the pointing state', () => {
88
88
  editor.setCurrentTool('arrow').pointerDown(0, 0).pointerMove(10, 10)
89
89
  editor.expectToBeIn('select.dragging_handle')
90
90
  })
91
+
92
+ it('removes the pressed arrow when switching tools before dragging', () => {
93
+ const shapesBefore = editor.getCurrentPageShapes().length
94
+ editor.setCurrentTool('arrow').pointerDown(0, 0)
95
+ expect(editor.getCurrentPageShapes().length).toBe(shapesBefore + 1)
96
+ editor.setCurrentTool('geo')
97
+ expect(editor.getCurrentPageShapes().length).toBe(shapesBefore)
98
+ editor.expectToBeIn('geo.idle')
99
+ })
100
+
101
+ it('removes the pressed arrow when switching to the select tool before dragging', () => {
102
+ const shapesBefore = editor.getCurrentPageShapes().length
103
+ editor.setCurrentTool('arrow').pointerDown(0, 0)
104
+ editor.setCurrentTool('select')
105
+ expect(editor.getCurrentPageShapes().length).toBe(shapesBefore)
106
+ editor.expectToBeIn('select.idle')
107
+ })
91
108
  })
92
109
 
93
110
  // This could be moved to dragging_handle
@@ -182,7 +182,7 @@ export function getCurvedArrowInfo(
182
182
  const strokeOffset =
183
183
  arrowSW / 2 +
184
184
  ('size' in startShapeInfo.shape.props
185
- ? (theme.strokeWidth * STROKE_SIZES[startShapeInfo.shape.props.size]) / 2
185
+ ? (theme.strokeWidth * (STROKE_SIZES[startShapeInfo.shape.props.size] ?? 0)) / 2
186
186
  : 0)
187
187
  offsetA = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale
188
188
  minLength += strokeOffset * shape.props.scale
@@ -265,7 +265,7 @@ export function getCurvedArrowInfo(
265
265
  const strokeOffset =
266
266
  arrowSW / 2 +
267
267
  ('size' in endShapeInfo.shape.props
268
- ? (theme.strokeWidth * STROKE_SIZES[endShapeInfo.shape.props.size]) / 2
268
+ ? (theme.strokeWidth * (STROKE_SIZES[endShapeInfo.shape.props.size] ?? 0)) / 2
269
269
  : 0)
270
270
  offsetB = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale
271
271
  minLength += strokeOffset * shape.props.scale
@@ -142,12 +142,14 @@ export function getElbowArrowInfo(
142
142
  }
143
143
 
144
144
  // We expand the bounds of the terminals so we can route arrows around them without the arrows
145
- // being too close to the shapes.
145
+ // being too close to the shapes. Always a separate Box from `bounds`: ElbowArrowWorkingInfo
146
+ // transforms `original` and `expanded` in place, so sharing one object would transform a point
147
+ // terminal twice (a no-op for flips, a 180° turn for rotations) and corrupt the route.
146
148
  const expandedA = aTerminal.isPoint
147
- ? aTerminal.bounds
149
+ ? aTerminal.bounds.clone()
148
150
  : aTerminal.bounds.clone().expandBy(options.expandElbowLegLength)
149
151
  const expandedB = bTerminal.isPoint
150
- ? bTerminal.bounds
152
+ ? bTerminal.bounds.clone()
151
153
  : bTerminal.bounds.clone().expandBy(options.expandElbowLegLength)
152
154
 
153
155
  const common: ElbowArrowBox = {
@@ -18,8 +18,9 @@ const arrowInfoCache = createComputedCache<Editor, TLArrowInfo, TLArrowShape>(
18
18
  (editor: Editor, shape: TLArrowShape): TLArrowInfo => {
19
19
  const bindings = getArrowBindings(editor, shape)
20
20
  const util = editor.getShapeUtil(shape)
21
+ // A replacement arrow util may not carry display values; fall back to the theme width.
21
22
  const sw =
22
- 'getDisplayValues' in util.options
23
+ 'getDefaultDisplayValues' in util.options && 'getCustomDisplayValues' in util.options
23
24
  ? (getDisplayValues(util as any, shape) as { strokeWidth: number }).strokeWidth
24
25
  : editor.getCurrentTheme().strokeWidth * STROKE_SIZES[shape.props.size]
25
26
 
@@ -139,7 +139,7 @@ export function getStraightArrowInfo(
139
139
  strokeOffsetA =
140
140
  arrowSW / 2 +
141
141
  ('size' in startShapeInfo.shape.props
142
- ? (theme.strokeWidth * STROKE_SIZES[startShapeInfo.shape.props.size]) / 2
142
+ ? (theme.strokeWidth * (STROKE_SIZES[startShapeInfo.shape.props.size] ?? 0)) / 2
143
143
  : 0)
144
144
  offsetA = (BOUND_ARROW_OFFSET + strokeOffsetA) * shape.props.scale
145
145
  minLength += strokeOffsetA * shape.props.scale
@@ -156,7 +156,7 @@ export function getStraightArrowInfo(
156
156
  strokeOffsetB =
157
157
  arrowSW / 2 +
158
158
  ('size' in endShapeInfo.shape.props
159
- ? (theme.strokeWidth * STROKE_SIZES[endShapeInfo.shape.props.size]) / 2
159
+ ? (theme.strokeWidth * (STROKE_SIZES[endShapeInfo.shape.props.size] ?? 0)) / 2
160
160
  : 0)
161
161
  offsetB = (BOUND_ARROW_OFFSET + strokeOffsetB) * shape.props.scale
162
162
  minLength += strokeOffsetB * shape.props.scale
@@ -1,5 +1,5 @@
1
1
  import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo, TLShapeId } from '@tldraw/editor'
2
- import { startEditingShapeWithRichText } from '../../../tools/SelectTool/selectHelpers'
2
+ import { startEditingShape } from '../../../tools/SelectTool/selectHelpers'
3
3
  import { ArrowShapeUtil } from '../ArrowShapeUtil'
4
4
  import { clearArrowTargetState, updateArrowTargetState } from '../arrowTargetState'
5
5
 
@@ -42,9 +42,8 @@ export class Idle extends StateNode {
42
42
  this.update()
43
43
  if (info.key === 'Enter') {
44
44
  const onlySelectedShape = this.editor.getOnlySelectedShape()
45
- if (this.editor.canEditShape(onlySelectedShape)) {
46
- startEditingShapeWithRichText(this.editor, onlySelectedShape, { selectAll: true })
47
- }
45
+ if (!this.editor.canEditShape(onlySelectedShape)) return
46
+ startEditingShape(this.editor, onlySelectedShape, { selectAll: true })
48
47
  }
49
48
  }
50
49
 
@@ -37,7 +37,12 @@ export class Pointing extends StateNode {
37
37
  }
38
38
 
39
39
  override onExit() {
40
- this.shape = undefined
40
+ // The press already created the arrow, so leaving without a drag (pointer up, cancel, or a
41
+ // tool switch) would otherwise strand a zero-length stub on the canvas
42
+ if (this.shape) {
43
+ this.editor.bailToMark(this.markId)
44
+ this.shape = undefined
45
+ }
41
46
  clearArrowTargetState(this.editor)
42
47
  this.clearPreciseTimeout()
43
48
  }
@@ -55,8 +60,11 @@ export class Pointing extends StateNode {
55
60
 
56
61
  this.updateArrowShapeEndHandle()
57
62
 
63
+ // Hand the arrow off before exiting so onExit does not bail it away
64
+ const shape = this.shape
65
+ this.shape = undefined
58
66
  this.editor.setCurrentTool('select.dragging_handle', {
59
- shape: this.shape,
67
+ shape,
60
68
  handle: { id: 'end', type: 'vertex', index: 'a3', x: 0, y: 0 },
61
69
  isCreating: true,
62
70
  creatingMarkId: this.markId || undefined,
@@ -87,10 +95,6 @@ export class Pointing extends StateNode {
87
95
  }
88
96
 
89
97
  cancel() {
90
- if (this.shape) {
91
- // the arrow might not have been created yet!
92
- this.editor.bailToMark(this.markId)
93
- }
94
98
  this.parent.transition('idle')
95
99
  }
96
100
 
@@ -109,6 +109,25 @@ describe('Close threshold with zoom', () => {
109
109
  expect(shape.props.isClosed).toBe(true)
110
110
  })
111
111
 
112
+ it('Closes a small shape with densely sampled points', () => {
113
+ // Match the point density of the reported shape that exposed the length calculation bug.
114
+ const samples = 476
115
+ const radius = 20
116
+ const center = { x: 100, y: 100 }
117
+
118
+ editor.setCurrentTool('draw')
119
+ editor.pointerDown(center.x + radius, center.y)
120
+ for (let i = 1; i <= samples; i++) {
121
+ const angle = (i / samples) * Math.PI * 2
122
+ editor.pointerMove(center.x + Math.cos(angle) * radius, center.y + Math.sin(angle) * radius)
123
+ }
124
+ editor.pointerUp()
125
+
126
+ const shapes = editor.getCurrentPageShapes() as TLDrawShape[]
127
+ expect(shapes).toHaveLength(1)
128
+ expect(shapes[0].props.isClosed).toBe(true)
129
+ })
130
+
112
131
  it('Does not close a shape when the endpoint is far from the start', () => {
113
132
  const shape = drawNearlyClosedShape(50)
114
133
  expect(shape.props.isClosed).toBe(false)
@@ -233,7 +233,9 @@ export class Drawing extends StateNode {
233
233
  if (this.initialShape) {
234
234
  const shape = this.editor.getShape<DrawableShape>(this.initialShape.id)
235
235
 
236
- if (shape && this.segmentMode === 'straight') {
236
+ // The remembered shape survives a page change; extending it from another
237
+ // page would silently append a segment to content the user can't see (#10400)
238
+ if (shape && this.segmentMode === 'straight' && this.editor.isShapeInPage(shape)) {
237
239
  // Connect dots
238
240
 
239
241
  this.didJustShiftClickToExtendPreviousShapeLine = true
@@ -347,8 +349,10 @@ export class Drawing extends StateNode {
347
349
  throw Error('We should have a point where the segment changed')
348
350
  }
349
351
 
352
+ // page-space distance against a screen-space threshold, so scale by the zoom
353
+ const zoom = this.editor.getZoomLevel()
350
354
  const hasMovedFarEnough =
351
- Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >
355
+ Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >
352
356
  this.editor.options.dragDistanceSquared
353
357
 
354
358
  // Find the distance from where the pointer was when shift was released and
@@ -414,8 +418,10 @@ export class Drawing extends StateNode {
414
418
  throw Error('We should have a point where the segment changed')
415
419
  }
416
420
 
421
+ // page-space distance against a screen-space threshold, so scale by the zoom
422
+ const zoom = this.editor.getZoomLevel()
417
423
  const hasMovedFarEnough =
418
- Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >
424
+ Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >
419
425
  this.editor.options.dragDistanceSquared
420
426
 
421
427
  // Find the distance from where the pointer was when shift was released and
@@ -693,7 +699,7 @@ export class Drawing extends StateNode {
693
699
  const currentPagePoint = inputs.getCurrentPagePoint()
694
700
 
695
701
  // Reset cache for the new shape's segment
696
- const initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed() : 0.5)
702
+ const initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed(2) : 0.5)
697
703
  this.currentSegmentPoints = [initialPoint]
698
704
 
699
705
  this.editor.createShape({
@@ -733,11 +739,11 @@ export class Drawing extends StateNode {
733
739
  for (let j = 0; j < segments.length; j++) {
734
740
  const points = b64Vecs.decodePoints(segments[j].path, segments[j].dim)
735
741
  for (let i = 0; i < points.length - 1; i++) {
736
- length += Vec.Dist2(points[i], points[i + 1])
742
+ length += Vec.Dist(points[i], points[i + 1])
737
743
  }
738
744
  }
739
745
 
740
- return Math.sqrt(length)
746
+ return length
741
747
  }
742
748
 
743
749
  override onPointerUp() {
@@ -131,6 +131,23 @@ describe('When in the pointing state', () => {
131
131
  editor.expectToBeIn('frame.idle')
132
132
  expect(editor.getCurrentPageShapes().length).toBe(1)
133
133
  })
134
+
135
+ it('Leaves nothing behind on complete before the pointer is released', () => {
136
+ editor.setCurrentTool('frame')
137
+ editor.pointerDown(50, 50)
138
+ editor.expectToBeIn('frame.pointing')
139
+ editor.complete()
140
+ editor.expectToBeIn('frame.idle')
141
+ expect(editor.getCurrentPageShapes().length).toBe(0)
142
+ })
143
+
144
+ it('Does not create a frame when undo is pressed mid-press', () => {
145
+ editor.setCurrentTool('frame')
146
+ editor.pointerDown(50, 50)
147
+ editor.undo()
148
+ editor.expectToBeIn('frame.idle')
149
+ expect(editor.getCurrentPageShapes().length).toBe(0)
150
+ })
134
151
  })
135
152
 
136
153
  describe('When in the resizing state', () => {
@@ -209,6 +209,23 @@ describe('When in the pointing state', () => {
209
209
  editor.expectToBeIn('geo.idle')
210
210
  expect(editor.getCurrentPageShapes().length).toBe(1)
211
211
  })
212
+
213
+ it('Leaves nothing behind on complete before the pointer is released', () => {
214
+ editor.setCurrentTool('geo')
215
+ editor.pointerDown(50, 50)
216
+ editor.expectToBeIn('geo.pointing')
217
+ editor.complete()
218
+ editor.expectToBeIn('geo.idle')
219
+ expect(editor.getCurrentPageShapes().length).toBe(0)
220
+ })
221
+
222
+ it('Does not create a geo when undo is pressed mid-press', () => {
223
+ editor.setCurrentTool('geo')
224
+ editor.pointerDown(50, 50)
225
+ editor.undo()
226
+ editor.expectToBeIn('geo.idle')
227
+ expect(editor.getCurrentPageShapes().length).toBe(0)
228
+ })
212
229
  })
213
230
 
214
231
  describe('When in the resizing state while creating a geo shape', () => {
@@ -229,6 +246,17 @@ describe('When in the resizing state while creating a geo shape', () => {
229
246
  editor.expectToBeIn('select.idle')
230
247
  })
231
248
 
249
+ it('Removes the pending geo shape when another tool is selected mid-drag', () => {
250
+ editor.setCurrentTool('geo')
251
+ editor.pointerDown(50, 50)
252
+ editor.pointerMove(100, 100)
253
+ editor.expectToBeIn('select.resizing')
254
+ expect(editor.getCurrentPageShapes().length).toBe(1)
255
+ editor.setCurrentTool('draw')
256
+ editor.expectToBeIn('draw.idle')
257
+ expect(editor.getCurrentPageShapes().length).toBe(0)
258
+ })
259
+
232
260
  it('Returns to geo.idle on complete if tool lock is enabled', () => {
233
261
  editor.updateInstanceState({ isToolLocked: true })
234
262
  editor.setCurrentTool('geo')
@@ -447,7 +447,9 @@ function getXBoxPath(
447
447
  geometry: { isInternal: true, isFilled: false },
448
448
  })
449
449
  .lineTo(clamp(w - sw * inset, 0, w), clamp(h - sw * inset, 0, h))
450
- .moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h))
450
+ .moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h), {
451
+ geometry: { isInternal: true, isFilled: false },
452
+ })
451
453
  .lineTo(clamp(sw * inset, 0, w), clamp(h - sw * inset, 0, h))
452
454
 
453
455
  return path
@@ -1,5 +1,5 @@
1
1
  import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'
2
- import { startEditingShapeWithRichText } from '../../../tools/SelectTool/selectHelpers'
2
+ import { startEditingShape } from '../../../tools/SelectTool/selectHelpers'
3
3
 
4
4
  export class Idle extends StateNode {
5
5
  static override id = 'idle'
@@ -16,9 +16,8 @@ export class Idle extends StateNode {
16
16
  const { editor } = this
17
17
  if (info.key === 'Enter') {
18
18
  const onlySelectedShape = editor.getOnlySelectedShape()
19
- if (editor.canEditShape(onlySelectedShape)) {
20
- startEditingShapeWithRichText(editor, onlySelectedShape, { selectAll: true })
21
- }
19
+ if (!editor.canEditShape(onlySelectedShape)) return
20
+ startEditingShape(editor, onlySelectedShape, { selectAll: true })
22
21
  }
23
22
  }
24
23
 
@@ -70,7 +70,8 @@ export class Pointing extends StateNode {
70
70
  }
71
71
 
72
72
  override onComplete() {
73
- this.complete()
73
+ // Not a release: see BaseBoxShapeTool's Pointing state for why this cancels.
74
+ this.cancel()
74
75
  }
75
76
 
76
77
  override onInterrupt() {
@@ -1,4 +1,4 @@
1
- import { assert } from '@tldraw/editor'
1
+ import { PageRecordType, assert } from '@tldraw/editor'
2
2
  import { TestEditor } from '../../../test/TestEditor'
3
3
 
4
4
  let editor: TestEditor
@@ -203,6 +203,35 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
203
203
  assert(editor.isShapeOfType(line, 'line'))
204
204
  expect(Object.keys(line.props.points).length).toBe(3)
205
205
  })
206
+
207
+ it('does not extend a line on another page after changing page', () => {
208
+ // regression for #10400: shift-clicking after a page change added a point
209
+ // to the line on the old page instead of starting a new line
210
+ editor.updateInstanceState({ isToolLocked: true })
211
+ editor
212
+ .setCurrentTool('line')
213
+ .pointerDown(0, 0, { target: 'canvas' })
214
+ .pointerMove(10, 10)
215
+ .pointerUp(10, 10)
216
+
217
+ const lineOnPage1 = editor.getCurrentPageShapes()[0]
218
+ assert(editor.isShapeOfType(lineOnPage1, 'line'))
219
+ expect(Object.keys(lineOnPage1.props.points).length).toBe(2)
220
+
221
+ const page2Id = PageRecordType.createId()
222
+ editor.createPage({ id: page2Id, name: 'Page 2' })
223
+ editor.setCurrentPage(page2Id)
224
+ editor.keyDown('Shift').pointerDown(20, 10, { target: 'canvas' }).pointerUp(20, 10)
225
+
226
+ expect(editor.getCurrentPageShapes()).toHaveLength(1)
227
+ const lineOnPage2 = editor.getCurrentPageShapes()[0]
228
+ assert(editor.isShapeOfType(lineOnPage2, 'line'))
229
+ expect(lineOnPage2.id).not.toBe(lineOnPage1.id)
230
+ expect(editor.isShapeInPage(lineOnPage2, page2Id)).toBe(true)
231
+
232
+ // The line on the first page is untouched
233
+ expect(editor.getShape(lineOnPage1.id)).toEqual(lineOnPage1)
234
+ })
206
235
  })
207
236
 
208
237
  describe('minimum bend distance for shift-clicked handles is measured in screen space', () => {
@@ -1,5 +1,4 @@
1
1
  import {
2
- Mat,
3
2
  StateNode,
4
3
  TLLineShape,
5
4
  TLShapeId,
@@ -31,7 +30,9 @@ export class Pointing extends StateNode {
31
30
  // Previously created line shape that we might be extending
32
31
  const shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)
33
32
 
34
- if (shape && inputs.getShiftKey()) {
33
+ // The shape id carried through idle survives a page change; extending it from
34
+ // another page would silently add a point to content the user can't see (#10400)
35
+ if (shape && inputs.getShiftKey() && this.editor.isShapeInPage(shape)) {
35
36
  // Extending a previous shape
36
37
  this.markId = this.editor.markHistoryStoppingPoint(`creating_line:${shape.id}`)
37
38
  this.shape = shape
@@ -43,12 +44,10 @@ export class Pointing extends StateNode {
43
44
  const endHandle = vertexHandles[vertexHandles.length - 1]
44
45
  const prevEndHandle = vertexHandles[vertexHandles.length - 2]
45
46
 
46
- const shapePagePoint = Mat.applyToPoint(
47
- this.editor.getShapeParentTransform(this.shape)!,
48
- new Vec(this.shape.x, this.shape.y)
49
- )
50
47
  // nudge the point slightly to avoid zero-length lines
51
- const nudgedPoint = Vec.Sub(currentPagePoint, shapePagePoint).addXY(0.1, 0.1)
48
+ const nudgedPoint = this.editor
49
+ .getPointInShapeSpace(this.shape, currentPagePoint)
50
+ .addXY(0.1, 0.1)
52
51
  const nextPoint = maybeSnapToGrid(nudgedPoint, this.editor)
53
52
  const points = structuredClone(this.shape.props.points)
54
53