tldraw 4.3.0-canary.d8da2a99f394 → 4.3.0-canary.da3162650c27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (636) hide show
  1. package/README.md +0 -2
  2. package/dist-cjs/index.d.ts +311 -242
  3. package/dist-cjs/index.js +13 -5
  4. package/dist-cjs/index.js.map +2 -2
  5. package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
  6. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
  7. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  8. package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
  9. package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
  10. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
  11. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  12. package/dist-cjs/lib/defaultSideEffects.js +6 -1
  13. package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
  14. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
  15. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  17. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
  18. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  19. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  20. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  21. package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
  23. package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
  24. package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
  25. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
  26. package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
  27. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
  28. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  29. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
  30. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  31. package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
  32. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
  33. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
  35. package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
  36. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
  37. package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
  38. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
  39. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
  40. package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
  41. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
  42. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  43. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
  44. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  45. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
  46. package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
  47. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
  48. package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
  49. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
  50. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  51. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
  52. package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
  53. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
  54. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  55. package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
  56. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
  57. package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
  58. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
  59. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  60. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
  61. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
  62. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
  63. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
  64. package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
  65. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  66. package/dist-cjs/lib/shapes/shared/crop.js +1 -0
  67. package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
  68. package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
  69. package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
  70. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  71. package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
  72. package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
  73. package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
  74. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
  75. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  76. package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
  77. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  78. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
  79. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  80. package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
  81. package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
  82. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
  83. package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
  84. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
  85. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
  86. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
  87. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  88. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
  89. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  90. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
  91. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  92. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
  93. package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
  94. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
  95. package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
  96. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
  97. package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
  98. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +10 -11
  99. package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
  100. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
  101. package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
  102. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
  103. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
  104. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
  105. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
  106. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
  107. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  108. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
  109. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
  110. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
  111. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
  112. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
  113. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
  114. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +8 -6
  115. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  116. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
  117. package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
  118. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
  119. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  120. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
  121. package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
  122. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
  123. package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
  124. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
  125. package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
  126. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
  127. package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
  128. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
  129. package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
  130. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
  131. package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
  132. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
  133. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  134. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
  135. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  136. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
  137. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  138. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
  139. package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
  140. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
  141. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  142. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
  143. package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
  144. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
  145. package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
  146. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
  147. package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
  148. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
  149. package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
  150. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
  151. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  152. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
  153. package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
  154. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
  155. package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
  156. package/dist-cjs/lib/ui/TldrawUi.js +2 -2
  157. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  158. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
  159. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
  160. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
  161. package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
  162. package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
  163. package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
  164. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +1 -21
  165. package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
  166. package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
  167. package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
  168. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
  169. package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
  170. package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
  171. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
  172. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  173. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
  174. package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
  175. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
  176. package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
  177. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
  178. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
  179. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  180. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
  181. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
  182. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
  183. package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
  184. package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
  185. package/dist-cjs/lib/ui/components/menu-items.js +3 -1
  186. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  187. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
  188. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  189. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
  190. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  191. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
  192. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  193. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
  194. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
  195. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
  196. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  197. package/dist-cjs/lib/ui/context/actions.js +7 -8
  198. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  199. package/dist-cjs/lib/ui/context/components.js +1 -2
  200. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  201. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  202. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
  203. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  204. package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
  205. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  206. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  207. package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
  208. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  209. package/dist-cjs/lib/ui/version.js +3 -3
  210. package/dist-cjs/lib/ui/version.js.map +1 -1
  211. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +16 -6
  212. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  213. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  214. package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
  215. package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
  216. package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
  217. package/dist-cjs/lib/utils/text/richText.js +11 -19
  218. package/dist-cjs/lib/utils/text/richText.js.map +3 -3
  219. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
  220. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  221. package/dist-esm/index.d.mts +311 -242
  222. package/dist-esm/index.mjs +14 -5
  223. package/dist-esm/index.mjs.map +2 -2
  224. package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
  225. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
  226. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  227. package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
  228. package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
  229. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
  230. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  231. package/dist-esm/lib/defaultSideEffects.mjs +6 -1
  232. package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
  234. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  235. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
  236. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  237. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  238. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  239. package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
  240. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
  241. package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
  242. package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
  243. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
  244. package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
  245. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
  246. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  247. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
  248. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  249. package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
  250. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
  251. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  252. package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
  253. package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
  254. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
  255. package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
  256. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
  257. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
  258. package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
  259. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
  260. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  261. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
  262. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  263. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
  264. package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
  265. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
  266. package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
  267. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
  268. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  269. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
  270. package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
  271. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
  272. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  273. package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
  274. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
  275. package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
  276. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
  277. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  278. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
  279. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  280. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
  281. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  282. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
  283. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  284. package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
  285. package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
  286. package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
  287. package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
  288. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  289. package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
  290. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
  291. package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
  292. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
  293. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  294. package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
  295. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  296. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
  297. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  298. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
  299. package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
  300. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
  301. package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
  302. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
  303. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
  304. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
  305. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  306. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +3 -8
  307. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  308. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
  309. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  310. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
  311. package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
  312. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
  313. package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
  314. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
  315. package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
  316. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +10 -11
  317. package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
  318. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
  319. package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
  320. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
  321. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
  322. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
  323. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
  324. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
  325. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  326. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
  327. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
  328. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
  329. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
  330. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
  331. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
  332. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +8 -6
  333. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  334. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
  335. package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
  336. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
  337. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  338. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
  339. package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
  340. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
  341. package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
  342. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +6 -19
  343. package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
  344. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
  345. package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
  346. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
  347. package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
  348. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
  349. package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
  350. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
  351. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  352. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
  353. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  354. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
  355. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  356. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
  357. package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
  358. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
  359. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  360. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
  361. package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
  362. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
  363. package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
  364. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
  365. package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
  366. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
  367. package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
  368. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
  369. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  370. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
  371. package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
  372. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
  373. package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
  374. package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
  375. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  376. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
  377. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
  378. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
  379. package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
  380. package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
  381. package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
  382. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +3 -30
  383. package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
  384. package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
  385. package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
  386. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
  387. package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
  388. package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
  389. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
  390. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  391. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
  392. package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
  393. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
  394. package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
  395. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
  396. package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
  397. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  398. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
  399. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
  400. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
  401. package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
  402. package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
  403. package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
  404. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  405. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
  406. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  407. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
  408. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  409. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
  410. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  411. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
  412. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
  413. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
  414. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  415. package/dist-esm/lib/ui/context/actions.mjs +7 -8
  416. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  417. package/dist-esm/lib/ui/context/components.mjs +1 -2
  418. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  419. package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
  420. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  421. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  422. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  423. package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
  424. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  425. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  426. package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
  427. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  428. package/dist-esm/lib/ui/version.mjs +3 -3
  429. package/dist-esm/lib/ui/version.mjs.map +1 -1
  430. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +17 -6
  431. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  432. package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
  433. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  434. package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
  435. package/dist-esm/lib/utils/test-helpers.mjs +21 -0
  436. package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
  437. package/dist-esm/lib/utils/text/richText.mjs +8 -5
  438. package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
  439. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
  440. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  441. package/package.json +18 -16
  442. package/src/index.ts +6 -2
  443. package/src/lib/Tldraw.test.tsx +46 -1
  444. package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
  445. package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
  446. package/src/lib/defaultEmbedDefinitions.ts +2 -1
  447. package/src/lib/defaultExternalContentHandlers.ts +13 -14
  448. package/src/lib/defaultSideEffects.ts +6 -1
  449. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
  450. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
  451. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
  452. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
  453. package/src/lib/shapes/arrow/arrow-types.ts +2 -0
  454. package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
  455. package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
  456. package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
  457. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
  458. package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
  459. package/src/lib/shapes/arrow/shared.ts +4 -4
  460. package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
  461. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +8 -5
  462. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
  463. package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
  464. package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
  465. package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
  466. package/src/lib/shapes/draw/getPath.ts +31 -10
  467. package/src/lib/shapes/draw/toolStates/Drawing.ts +100 -90
  468. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +8 -1
  469. package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
  470. package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
  471. package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
  472. package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
  473. package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
  474. package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
  475. package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
  476. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
  477. package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
  478. package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
  479. package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
  480. package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
  481. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
  482. package/src/lib/shapes/note/noteCloning.test.ts +3 -1
  483. package/src/lib/shapes/note/noteHelpers.ts +2 -2
  484. package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
  485. package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
  486. package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
  487. package/src/lib/shapes/shared/RichTextLabel.tsx +14 -4
  488. package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
  489. package/src/lib/shapes/shared/crop.ts +1 -0
  490. package/src/lib/shapes/shared/interpolate-props.ts +4 -4
  491. package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
  492. package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
  493. package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
  494. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
  495. package/src/lib/shapes/text/RichTextArea.tsx +5 -0
  496. package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
  497. package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
  498. package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
  499. package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
  500. package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
  501. package/src/lib/tools/EraserTool/childStates/Erasing.ts +7 -10
  502. package/src/lib/tools/EraserTool/childStates/Pointing.ts +5 -20
  503. package/src/lib/tools/HandTool/HandTool.ts +3 -5
  504. package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
  505. package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
  506. package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
  507. package/src/lib/tools/SelectTool/DragAndDropManager.ts +14 -11
  508. package/src/lib/tools/SelectTool/childStates/Brushing.ts +8 -11
  509. package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
  510. package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -4
  511. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
  512. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
  513. package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
  514. package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
  515. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +11 -12
  516. package/src/lib/tools/SelectTool/childStates/EditingShape.ts +57 -16
  517. package/src/lib/tools/SelectTool/childStates/Idle.ts +64 -81
  518. package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +7 -8
  519. package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
  520. package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +9 -17
  521. package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
  522. package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
  523. package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
  524. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
  525. package/src/lib/tools/SelectTool/childStates/Resizing.ts +8 -10
  526. package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
  527. package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +9 -10
  528. package/src/lib/tools/SelectTool/childStates/Translating.ts +16 -15
  529. package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
  530. package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
  531. package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
  532. package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
  533. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
  534. package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
  535. package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
  536. package/src/lib/ui/TldrawUi.tsx +5 -2
  537. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
  538. package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
  539. package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
  540. package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
  541. package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
  542. package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
  543. package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
  544. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
  545. package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
  546. package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
  547. package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
  548. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
  549. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
  550. package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
  551. package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
  552. package/src/lib/ui/components/menu-items.tsx +9 -15
  553. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
  554. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
  555. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
  556. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
  557. package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
  558. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
  559. package/src/lib/ui/context/actions.tsx +15 -19
  560. package/src/lib/ui/context/components.tsx +1 -2
  561. package/src/lib/ui/hooks/menu-hooks.ts +9 -19
  562. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  563. package/src/lib/ui/hooks/useFlatten.ts +1 -2
  564. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
  565. package/src/lib/ui/hooks/useTools.tsx +5 -7
  566. package/src/lib/ui/version.ts +3 -3
  567. package/src/lib/ui.css +27 -23
  568. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
  569. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +19 -6
  570. package/src/lib/utils/export/exportAs.ts +2 -9
  571. package/src/lib/utils/frames/frames.ts +1 -1
  572. package/src/lib/utils/test-helpers.ts +60 -0
  573. package/src/lib/utils/text/richText.ts +9 -8
  574. package/src/lib/utils/tldr/buildFromV1Document.ts +21 -19
  575. package/src/test/Editor.test.tsx +78 -41
  576. package/src/test/EraserTool.test.ts +10 -12
  577. package/src/test/SelectTool.test.ts +11 -19
  578. package/src/test/TestEditor.ts +49 -51
  579. package/src/test/TldrawEditor.test.tsx +24 -20
  580. package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
  581. package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
  582. package/src/test/arrows-megabus.test.tsx +1 -1
  583. package/src/test/bindings.test.tsx +29 -25
  584. package/src/test/bindingsIndex.test.tsx +4 -4
  585. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
  586. package/src/test/commands/cameraState.test.ts +299 -0
  587. package/src/test/commands/createShape.test.ts +64 -0
  588. package/src/test/commands/createShapes.test.ts +15 -1
  589. package/src/test/commands/getSvgString.test.ts +2 -2
  590. package/src/test/commands/isShapeOfType.test.ts +44 -0
  591. package/src/test/commands/putContent.test.ts +80 -1
  592. package/src/test/commands/setCamera.test.ts +13 -11
  593. package/src/test/commands/stackShapes.test.ts +34 -8
  594. package/src/test/commands/updateShape.test.ts +67 -0
  595. package/src/test/commands/updateShapes.test.ts +21 -5
  596. package/src/test/commands/zoomToBounds.test.ts +19 -3
  597. package/src/test/commands/zoomToSelection.test.ts +14 -3
  598. package/src/test/custom-clipping.test.ts +52 -44
  599. package/src/test/customSnapping.test.tsx +77 -62
  600. package/src/test/drawing.test.ts +17 -10
  601. package/src/test/duplicate.test.ts +1 -1
  602. package/src/test/flipShapes.test.ts +33 -0
  603. package/src/test/frames.test.ts +94 -2
  604. package/src/test/getCulledShapes.test.tsx +11 -3
  605. package/src/test/getShapeAtPoint.test.ts +2 -2
  606. package/src/test/groups.test.tsx +7 -4
  607. package/src/test/modifiers.test.ts +6 -6
  608. package/src/test/resizing.test.ts +16 -22
  609. package/src/test/selection-omnibus.test.ts +13 -13
  610. package/src/test/shapeutils.test.ts +1 -1
  611. package/src/test/spacebarPanning.test.ts +28 -10
  612. package/src/test/styles2.test.tsx +1 -1
  613. package/src/test/styles3.test.ts +5 -5
  614. package/src/test/test-jsx.tsx +72 -57
  615. package/src/test/text.test.ts +15 -17
  616. package/src/test/translating.test.ts +6 -8
  617. package/src/test/ui/BackToContent.test.tsx +111 -0
  618. package/tldraw.css +41 -35
  619. package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
  620. package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
  621. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
  622. package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
  623. package/dist-cjs/lib/utils/text/textDirection.js +0 -51
  624. package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
  625. package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
  626. package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
  627. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
  628. package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
  629. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
  630. package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
  631. package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
  632. package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
  633. package/src/lib/shapes/shared/useForceSolid.ts +0 -6
  634. package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
  635. package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
  636. package/src/lib/utils/text/textDirection.ts +0 -32
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/shapes/geo/toolStates/Pointing.ts"],
4
- "sourcesContent": ["import {\n\tGeoShapeGeoStyle,\n\tStateNode,\n\tTLGeoShape,\n\tTLPointerEventInfo,\n\tVec,\n\tcreateShapeId,\n\tmaybeSnapToGrid,\n} from '@tldraw/editor'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tconst { originPagePoint } = this.editor.inputs\n\n\t\t\tconst id = createShapeId()\n\n\t\t\tconst creatingMarkId = this.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\t\t\tconst newPoint = maybeSnapToGrid(originPagePoint, this.editor)\n\t\t\tthis.editor\n\t\t\t\t.createShapes<TLGeoShape>([\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: 1,\n\t\t\t\t\t\t\th: 1,\n\t\t\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\t.select(id)\n\n\t\t\tconst shape = this.editor.getShape(id)\n\t\t\tif (!shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.setCurrentTool('select.resizing', {\n\t\t\t\t...info,\n\t\t\t\ttarget: 'selection',\n\t\t\t\thandle: 'bottom_right',\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId,\n\t\t\t\tcreationCursorOffset: { x: 1, y: 1 },\n\t\t\t\tonInteractionEnd: 'geo',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\n\t\tconst { originPagePoint } = this.editor.inputs\n\n\t\tconst id = createShapeId()\n\n\t\tthis.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\n\t\tconst scale = this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1\n\n\t\tconst geo = this.editor.getStyleForNextShape(GeoShapeGeoStyle)\n\n\t\tconst size =\n\t\t\tgeo === 'star'\n\t\t\t\t? { w: 200, h: 190 }\n\t\t\t\t: geo === 'cloud'\n\t\t\t\t\t? { w: 300, h: 180 }\n\t\t\t\t\t: { w: 200, h: 200 }\n\n\t\tthis.editor.createShapes<TLGeoShape>([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'geo',\n\t\t\t\tx: originPagePoint.x,\n\t\t\t\ty: originPagePoint.y,\n\t\t\t\tprops: {\n\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\tscale,\n\t\t\t\t\t...size,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape<TLGeoShape>(id)!\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\n\t\tconst { w, h } = shape.props\n\n\t\tconst delta = new Vec(w / 2, h / 2).mul(scale)\n\t\tconst parentTransform = this.editor.getShapeParentTransform(shape)\n\t\tif (parentTransform) delta.rot(-parentTransform.rotation())\n\t\tconst newPoint = maybeSnapToGrid(new Vec(shape.x - delta.x, shape.y - delta.y), this.editor)\n\t\tthis.editor.select(id)\n\t\tthis.editor.updateShape<TLGeoShape>({\n\t\t\tid: shape.id,\n\t\t\ttype: 'geo',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\tw: w * scale,\n\t\t\t\th: h * scale,\n\t\t\t},\n\t\t})\n\n\t\tif (this.editor.getInstanceState().isToolLocked) {\n\t\t\tthis.parent.transition('idle')\n\t\t} else {\n\t\t\tthis.editor.setCurrentTool('select', {})\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\t// we should not have created any shapes yet, so no need to bail\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AAEA,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAEZ,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC,YAAM,EAAE,gBAAgB,IAAI,KAAK,OAAO;AAExC,YAAM,SAAK,6BAAc;AAEzB,YAAM,iBAAiB,KAAK,OAAO,yBAAyB,gBAAgB,EAAE,EAAE;AAChF,YAAM,eAAW,+BAAgB,iBAAiB,KAAK,MAAM;AAC7D,WAAK,OACH,aAAyB;AAAA,QACzB;AAAA,UACC;AAAA,UACA,MAAM;AAAA,UACN,GAAG,SAAS;AAAA,UACZ,GAAG,SAAS;AAAA,UACZ,OAAO;AAAA,YACN,GAAG;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AK,OAAO,qBAAqB,8BAAgB;AAAA,UACtD;AAAA,UACA,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD,CAAC;AAED,UAAM,QAAQ,KAAK,OAAO,SAAqB,EAAE;AACjD,QAAI,CAAC,OAAO;AACX,WAAK,OAAO;AACZ;AAAA,IACD;AAEA,UAAM,EAAE,GAAG,EAAE,IAAI,MAAM;AAEvB,UAAM,QAAQ,IAAI,kBAAI,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,KAAK;AAC7C,UAAM,kBAAkB,KAAK,OAAO,wBAAwB,KAAK;AACjE,QAAI,gBAAiB,OAAM,IAAI,CAAC,gBAAgB,SAAS,CAAC;AAC1D,UAAM,eAAW,+BAAgB,IAAI,kBAAI,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,MAAM;AAC3F,SAAK,OAAO,OAAO,EAAE;AACrB,SAAK,OAAO,YAAwB;AAAA,MACnC,IAAI,MAAM;AAAA,MACV,MAAM;AAAA,MACN,GAAG,SAAS;AAAA,MACZ,GAAG,SAAS;AAAA,MACZ,OAAO;AAAA,QACN,KAAK,KAAK,OAAO,qBAAqB,8BAAgB;AAAA,QACtD,GAAG,IAAI;AAAA,QACP,GAAG,IAAI;AAAA,MACR;AAAA,IACD,CAAC;AAED,QAAI,KAAK,OAAO,iBAAiB,EAAE,cAAc;AAChD,WAAK,OAAO,WAAW,MAAM;AAAA,IAC9B,OAAO;AACN,WAAK,OAAO,eAAe,UAAU,CAAC,CAAC;AAAA,IACxC;AAAA,EACD;AAAA,EAEQ,SAAS;AAEhB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import {\n\tGeoShapeGeoStyle,\n\tStateNode,\n\tTLGeoShape,\n\tTLPointerEventInfo,\n\tVec,\n\tcreateShapeId,\n\tmaybeSnapToGrid,\n} from '@tldraw/editor'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\t\tconst id = createShapeId()\n\n\t\t\tconst creatingMarkId = this.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\t\t\tconst newPoint = maybeSnapToGrid(originPagePoint, this.editor)\n\t\t\tthis.editor\n\t\t\t\t.createShapes([\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: 1,\n\t\t\t\t\t\t\th: 1,\n\t\t\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\t.select(id)\n\n\t\t\tconst shape = this.editor.getShape(id)\n\t\t\tif (!shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.setCurrentTool('select.resizing', {\n\t\t\t\t...info,\n\t\t\t\ttarget: 'selection',\n\t\t\t\thandle: 'bottom_right',\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId,\n\t\t\t\tcreationCursorOffset: { x: 1, y: 1 },\n\t\t\t\tonInteractionEnd: 'geo',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\tconst id = createShapeId()\n\n\t\tthis.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\n\t\tconst scale = this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1\n\n\t\tconst geo = this.editor.getStyleForNextShape(GeoShapeGeoStyle)\n\n\t\tconst size =\n\t\t\tgeo === 'star'\n\t\t\t\t? { w: 200, h: 190 }\n\t\t\t\t: geo === 'cloud'\n\t\t\t\t\t? { w: 300, h: 180 }\n\t\t\t\t\t: { w: 200, h: 200 }\n\n\t\tthis.editor.createShapes([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'geo',\n\t\t\t\tx: originPagePoint.x,\n\t\t\t\ty: originPagePoint.y,\n\t\t\t\tprops: {\n\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\tscale,\n\t\t\t\t\t...size,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape<TLGeoShape>(id)!\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\n\t\tconst { w, h } = shape.props\n\n\t\tconst delta = new Vec(w / 2, h / 2).mul(scale)\n\t\tconst parentTransform = this.editor.getShapeParentTransform(shape)\n\t\tif (parentTransform) delta.rot(-parentTransform.rotation())\n\t\tconst newPoint = maybeSnapToGrid(new Vec(shape.x - delta.x, shape.y - delta.y), this.editor)\n\t\tthis.editor.select(id)\n\t\tthis.editor.updateShape({\n\t\t\tid: shape.id,\n\t\t\ttype: 'geo',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\tw: w * scale,\n\t\t\t\th: h * scale,\n\t\t\t},\n\t\t})\n\n\t\tif (this.editor.getInstanceState().isToolLocked) {\n\t\t\tthis.parent.transition('idle')\n\t\t} else {\n\t\t\tthis.editor.setCurrentTool('select', {})\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\t// we should not have created any shapes yet, so no need to bail\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AAEA,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAEZ,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,YAAM,kBAAkB,KAAK,OAAO,OAAO,mBAAmB;AAE9D,YAAM,SAAK,6BAAc;AAEzB,YAAM,iBAAiB,KAAK,OAAO,yBAAyB,gBAAgB,EAAE,EAAE;AAChF,YAAM,eAAW,+BAAgB,iBAAiB,KAAK,MAAM;AAC7D,WAAK,OACH,aAAa;AAAA,QACb;AAAA,UACC;AAAA,UACA,MAAM;AAAA,UACN,GAAG,SAAS;AAAA,UACZ,GAAG,SAAS;AAAA,UACZ,OAAO;AAAA,YACN,GAAG;AAAA,YACH,GAAG;AAAA,YACH,KAAK,KAAK,OAAO,qBAAqB,8BAAgB;AAAA,YACtD,OAAO,KAAK,OAAO,KAAK,uBAAuB,IAAI,IAAI,KAAK,OAAO,aAAa,IAAI;AAAA,UACrF;AAAA,QACD;AAAA,MACD,CAAC,EACA,OAAO,EAAE;AAEX,YAAM,QAAQ,KAAK,OAAO,SAAS,EAAE;AACrC,UAAI,CAAC,OAAO;AACX,aAAK,OAAO;AACZ;AAAA,MACD;AAEA,WAAK,OAAO,eAAe,mBAAmB;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ;AAAA,QACA,sBAAsB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,QACnC,kBAAkB;AAAA,MACnB,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAA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AAI,MAAM;AAAA,MACV,MAAM;AAAA,MACN,GAAG,SAAS;AAAA,MACZ,GAAG,SAAS;AAAA,MACZ,OAAO;AAAA,QACN,KAAK,KAAK,OAAO,qBAAqB,8BAAgB;AAAA,QACtD,GAAG,IAAI;AAAA,QACP,GAAG,IAAI;AAAA,MACR;AAAA,IACD,CAAC;AAED,QAAI,KAAK,OAAO,iBAAiB,EAAE,cAAc;AAChD,WAAK,OAAO,WAAW,MAAM;AAAA,IAC9B,OAAO;AACN,WAAK,OAAO,eAAe,UAAU,CAAC,CAAC;AAAA,IACxC;AAAA,EACD;AAAA,EAEQ,SAAS;AAEhB,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -57,7 +57,9 @@ class HighlightShapeUtil extends import_editor.ShapeUtil {
57
57
  size: "m",
58
58
  isComplete: false,
59
59
  isPen: false,
60
- scale: 1
60
+ scale: 1,
61
+ scaleX: 1,
62
+ scaleY: 1
61
63
  };
62
64
  }
63
65
  getGeometry(shape) {
@@ -108,7 +110,11 @@ class HighlightShapeUtil extends import_editor.ShapeUtil {
108
110
  const forceSolid = useHighlightForceSolid(this.editor, shape);
109
111
  const strokeWidth = getStrokeWidth(shape);
110
112
  const { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, forceSolid);
111
- const allPointsFromSegments = (0, import_getPath.getPointsFromSegments)(shape.props.segments);
113
+ const allPointsFromSegments = (0, import_getPath.getPointsFromDrawSegments)(
114
+ shape.props.segments,
115
+ shape.props.scaleX,
116
+ shape.props.scaleY
117
+ );
112
118
  let strokePath;
113
119
  if (strokePoints.length < 2) {
114
120
  strokePath = getIndicatorDot(allPointsFromSegments[0], sw);
@@ -147,22 +153,10 @@ class HighlightShapeUtil extends import_editor.ShapeUtil {
147
153
  }
148
154
  onResize(shape, info) {
149
155
  const { scaleX, scaleY } = info;
150
- const newSegments = [];
151
- for (const segment of shape.props.segments) {
152
- newSegments.push({
153
- ...segment,
154
- points: segment.points.map(({ x, y, z }) => {
155
- return {
156
- x: scaleX * x,
157
- y: scaleY * y,
158
- z
159
- };
160
- })
161
- });
162
- }
163
156
  return {
164
157
  props: {
165
- segments: newSegments
158
+ scaleX: scaleX * shape.props.scaleX,
159
+ scaleY: scaleY * shape.props.scaleY
166
160
  }
167
161
  };
168
162
  }
@@ -184,7 +178,11 @@ function getIndicatorDot(point, sw) {
184
178
  return `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${r * 2},0`;
185
179
  }
186
180
  function getHighlightStrokePoints(shape, strokeWidth, forceSolid) {
187
- const allPointsFromSegments = (0, import_getPath.getPointsFromSegments)(shape.props.segments);
181
+ const allPointsFromSegments = (0, import_getPath.getPointsFromDrawSegments)(
182
+ shape.props.segments,
183
+ shape.props.scaleX,
184
+ shape.props.scaleY
185
+ );
188
186
  const showAsComplete = shape.props.isComplete || (0, import_editor.last)(shape.props.segments)?.type === "straight";
189
187
  let sw = strokeWidth;
190
188
  if (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {
@@ -201,7 +199,7 @@ function getStrokeWidth(shape) {
201
199
  return import_default_shape_constants.FONT_SIZES[shape.props.size] * 1.12 * shape.props.scale;
202
200
  }
203
201
  function getIsDot(shape) {
204
- return shape.props.segments.length === 1 && shape.props.segments[0].points.length < 2;
202
+ return shape.props.segments.length === 1 && shape.props.segments[0].points.length < 16;
205
203
  }
206
204
  function HighlightRenderer({
207
205
  strokeWidth,
@@ -210,7 +208,11 @@ function HighlightRenderer({
210
208
  opacity
211
209
  }) {
212
210
  const theme = (0, import_useDefaultColorTheme.useDefaultColorTheme)();
213
- const allPointsFromSegments = (0, import_getPath.getPointsFromSegments)(shape.props.segments);
211
+ const allPointsFromSegments = (0, import_getPath.getPointsFromDrawSegments)(
212
+ shape.props.segments,
213
+ shape.props.scaleX,
214
+ shape.props.scaleY
215
+ );
214
216
  let sw = strokeWidth;
215
217
  if (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {
216
218
  sw += (0, import_editor.rng)(shape.id)() * (sw / 6);
@@ -220,7 +222,7 @@ function HighlightRenderer({
220
222
  showAsComplete: shape.props.isComplete || (0, import_editor.last)(shape.props.segments)?.type === "straight"
221
223
  });
222
224
  const strokePoints = (0, import_getStrokePoints.getStrokePoints)(allPointsFromSegments, options);
223
- const solidStrokePath = strokePoints.length > 1 ? (0, import_svg.getSvgPathFromStrokePoints)(strokePoints, false) : getShapeDot(shape.props.segments[0].points[0]);
225
+ const solidStrokePath = strokePoints.length > 1 ? (0, import_svg.getSvgPathFromStrokePoints)(strokePoints, false) : getShapeDot(allPointsFromSegments[0]);
224
226
  const colorSpace = (0, import_useColorSpace.useColorSpace)();
225
227
  const color = (0, import_editor.getColorValue)(
226
228
  theme,
@@ -245,7 +247,7 @@ function useHighlightForceSolid(editor, shape) {
245
247
  "forceSolid",
246
248
  () => {
247
249
  const sw = getStrokeWidth(shape);
248
- const zoomLevel = editor.getZoomLevel();
250
+ const zoomLevel = editor.getEfficientZoomLevel();
249
251
  if (sw / zoomLevel < 1.5) {
250
252
  return true;
251
253
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/shapes/highlight/HighlightShapeUtil.tsx"],
4
- "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport {\n\tCircle2d,\n\tEditor,\n\tPolygon2d,\n\tSVGContainer,\n\tShapeUtil,\n\tTLDrawShapeSegment,\n\tTLHighlightShape,\n\tTLHighlightShapeProps,\n\tTLResizeInfo,\n\tVecLike,\n\tgetColorValue,\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\tlast,\n\tlerp,\n\trng,\n\tuseValue,\n} from '@tldraw/editor'\n\nimport { getHighlightFreehandSettings, getPointsFromSegments } from '../draw/getPath'\nimport { FONT_SIZES } from '../shared/default-shape-constants'\nimport { getStrokeOutlinePoints } from '../shared/freehand/getStrokeOutlinePoints'\nimport { getStrokePoints } from '../shared/freehand/getStrokePoints'\nimport { setStrokePointRadii } from '../shared/freehand/setStrokePointRadii'\nimport { getSvgPathFromStrokePoints } from '../shared/freehand/svg'\nimport { interpolateSegments } from '../shared/interpolate-props'\nimport { useColorSpace } from '../shared/useColorSpace'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\n\n/** @public */\nexport interface HighlightShapeOptions {\n\t/**\n\t * The maximum number of points in a line before the draw tool will begin a new shape.\n\t * A higher number will lead to poor performance while drawing very long lines.\n\t */\n\treadonly maxPointsPerShape: number\n\treadonly underlayOpacity: number\n\treadonly overlayOpacity: number\n}\n\n/** @public */\nexport class HighlightShapeUtil extends ShapeUtil<TLHighlightShape> {\n\tstatic override type = 'highlight' as const\n\tstatic override props = highlightShapeProps\n\tstatic override migrations = highlightShapeMigrations\n\n\toverride options: HighlightShapeOptions = {\n\t\tmaxPointsPerShape: 600,\n\t\tunderlayOpacity: 0.82,\n\t\toverlayOpacity: 0.35,\n\t}\n\n\toverride hideResizeHandles(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\toverride hideRotateHandle(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\toverride hideSelectionBoundsFg(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\n\toverride getDefaultProps(): TLHighlightShape['props'] {\n\t\treturn {\n\t\t\tsegments: [],\n\t\t\tcolor: 'black',\n\t\t\tsize: 'm',\n\t\t\tisComplete: false,\n\t\t\tisPen: false,\n\t\t\tscale: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tif (getIsDot(shape)) {\n\t\t\treturn new Circle2d({\n\t\t\t\tx: -strokeWidth / 2,\n\t\t\t\ty: -strokeWidth / 2,\n\t\t\t\tradius: strokeWidth / 2,\n\t\t\t\tisFilled: true,\n\t\t\t})\n\t\t}\n\n\t\tconst { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, true)\n\t\tconst opts = getHighlightFreehandSettings({ strokeWidth: sw, showAsComplete: true })\n\t\tsetStrokePointRadii(strokePoints, opts)\n\n\t\treturn new Polygon2d({\n\t\t\tpoints: getStrokeOutlinePoints(strokePoints, opts),\n\t\t\tisFilled: true,\n\t\t})\n\t}\n\n\tcomponent(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tshape={shape}\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\topacity={this.options.overlayOpacity}\n\t\t\t\t/>\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\toverride backgroundComponent(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tshape={shape}\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\topacity={this.options.underlayOpacity}\n\t\t\t\t/>\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\tindicator(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\n\t\tconst { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, forceSolid)\n\t\tconst allPointsFromSegments = getPointsFromSegments(shape.props.segments)\n\n\t\tlet strokePath\n\t\tif (strokePoints.length < 2) {\n\t\t\tstrokePath = getIndicatorDot(allPointsFromSegments[0], sw)\n\t\t} else {\n\t\t\tstrokePath = getSvgPathFromStrokePoints(strokePoints, false)\n\t\t}\n\n\t\treturn <path d={strokePath} />\n\t}\n\n\toverride toSvg(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tconst forceSolid = strokeWidth < 1.5\n\t\tconst scaleFactor = 1 / shape.props.scale\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\tshape={shape}\n\t\t\t\t\topacity={this.options.overlayOpacity}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride toBackgroundSvg(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tconst forceSolid = strokeWidth < 1.5\n\t\tconst scaleFactor = 1 / shape.props.scale\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\tshape={shape}\n\t\t\t\t\topacity={this.options.underlayOpacity}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride onResize(shape: TLHighlightShape, info: TLResizeInfo<TLHighlightShape>) {\n\t\tconst { scaleX, scaleY } = info\n\n\t\tconst newSegments: TLDrawShapeSegment[] = []\n\n\t\tfor (const segment of shape.props.segments) {\n\t\t\tnewSegments.push({\n\t\t\t\t...segment,\n\t\t\t\tpoints: segment.points.map(({ x, y, z }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: scaleX * x,\n\t\t\t\t\t\ty: scaleY * y,\n\t\t\t\t\t\tz,\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t})\n\t\t}\n\n\t\treturn {\n\t\t\tprops: {\n\t\t\t\tsegments: newSegments,\n\t\t\t},\n\t\t}\n\t}\n\toverride getInterpolatedProps(\n\t\tstartShape: TLHighlightShape,\n\t\tendShape: TLHighlightShape,\n\t\tt: number\n\t): TLHighlightShapeProps {\n\t\treturn {\n\t\t\t...(t > 0.5 ? endShape.props : startShape.props),\n\t\t\t...endShape.props,\n\t\t\tsegments: interpolateSegments(startShape.props.segments, endShape.props.segments, t),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, t),\n\t\t}\n\t}\n}\n\nfunction getShapeDot(point: VecLike) {\n\tconst r = 0.1\n\treturn `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${\n\t\tr * 2\n\t},0`\n}\n\nfunction getIndicatorDot(point: VecLike, sw: number) {\n\tconst r = sw / 2\n\treturn `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${\n\t\tr * 2\n\t},0`\n}\n\nfunction getHighlightStrokePoints(\n\tshape: TLHighlightShape,\n\tstrokeWidth: number,\n\tforceSolid: boolean\n) {\n\tconst allPointsFromSegments = getPointsFromSegments(shape.props.segments)\n\tconst showAsComplete = shape.props.isComplete || last(shape.props.segments)?.type === 'straight'\n\n\tlet sw = strokeWidth\n\tif (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {\n\t\tsw += rng(shape.id)() * (strokeWidth / 6)\n\t}\n\n\tconst options = getHighlightFreehandSettings({\n\t\tstrokeWidth: sw,\n\t\tshowAsComplete,\n\t})\n\n\tconst strokePoints = getStrokePoints(allPointsFromSegments, options)\n\n\treturn { strokePoints, sw }\n}\n\nfunction getStrokeWidth(shape: TLHighlightShape) {\n\treturn FONT_SIZES[shape.props.size] * 1.12 * shape.props.scale\n}\n\nfunction getIsDot(shape: TLHighlightShape) {\n\treturn shape.props.segments.length === 1 && shape.props.segments[0].points.length < 2\n}\n\nfunction HighlightRenderer({\n\tstrokeWidth,\n\tforceSolid,\n\tshape,\n\topacity,\n}: {\n\tstrokeWidth: number\n\tforceSolid: boolean\n\tshape: TLHighlightShape\n\topacity: number\n}) {\n\tconst theme = useDefaultColorTheme()\n\n\tconst allPointsFromSegments = getPointsFromSegments(shape.props.segments)\n\n\tlet sw = strokeWidth\n\tif (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {\n\t\tsw += rng(shape.id)() * (sw / 6)\n\t}\n\n\tconst options = getHighlightFreehandSettings({\n\t\tstrokeWidth: sw,\n\t\tshowAsComplete: shape.props.isComplete || last(shape.props.segments)?.type === 'straight',\n\t})\n\n\tconst strokePoints = getStrokePoints(allPointsFromSegments, options)\n\n\tconst solidStrokePath =\n\t\tstrokePoints.length > 1\n\t\t\t? getSvgPathFromStrokePoints(strokePoints, false)\n\t\t\t: getShapeDot(shape.props.segments[0].points[0])\n\n\tconst colorSpace = useColorSpace()\n\n\tconst color = getColorValue(\n\t\ttheme,\n\t\tshape.props.color,\n\t\tcolorSpace === 'p3' ? 'highlightP3' : 'highlightSrgb'\n\t)\n\n\treturn (\n\t\t<path\n\t\t\td={solidStrokePath}\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tfill=\"none\"\n\t\t\tpointerEvents=\"all\"\n\t\t\tstroke={color}\n\t\t\tstrokeWidth={sw}\n\t\t\topacity={opacity}\n\t\t/>\n\t)\n}\n\nfunction useHighlightForceSolid(editor: Editor, shape: TLHighlightShape) {\n\treturn useValue(\n\t\t'forceSolid',\n\t\t() => {\n\t\t\tconst sw = getStrokeWidth(shape)\n\t\t\tconst zoomLevel = editor.getZoomLevel()\n\t\t\tif (sw / zoomLevel < 1.5) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\t\t[editor]\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsGI;AArGJ,oBAkBO;AAEP,qBAAoE;AACpE,qCAA2B;AAC3B,oCAAuC;AACvC,6BAAgC;AAChC,iCAAoC;AACpC,iBAA2C;AAC3C,+BAAoC;AACpC,2BAA8B;AAC9B,kCAAqC;AAc9B,MAAM,2BAA2B,wBAA4B;AAAA,EACnE,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Q;AAAA,IACb;AAAA,IACA,MAAM,MAAM;AAAA,IACZ,eAAe,OAAO,gBAAgB;AAAA,EACvC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,GAAG;AAAA,MACH,eAAc;AAAA,MACd,MAAK;AAAA,MACL,eAAc;AAAA,MACd,QAAQ;AAAA,MACR,aAAa;AAAA,MACb;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,uBAAuB,QAAgB,OAAyB;AACxE,aAAO;AAAA,IACN;AAAA,IACA,MAAM;AACL,YAAM,KAAK,eAAe,KAAK;AAC/B,YAAM,YAAY,OAAO,aAAa;AACtC,UAAI,KAAK,YAAY,KAAK;AACzB,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AACD;",
4
+ "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport {\n\tCircle2d,\n\tEditor,\n\tPolygon2d,\n\tSVGContainer,\n\tShapeUtil,\n\tTLHighlightShape,\n\tTLHighlightShapeProps,\n\tTLResizeInfo,\n\tVecLike,\n\tgetColorValue,\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\tlast,\n\tlerp,\n\trng,\n\tuseValue,\n} from '@tldraw/editor'\n\nimport { getHighlightFreehandSettings, getPointsFromDrawSegments } from '../draw/getPath'\nimport { FONT_SIZES } from '../shared/default-shape-constants'\nimport { getStrokeOutlinePoints } from '../shared/freehand/getStrokeOutlinePoints'\nimport { getStrokePoints } from '../shared/freehand/getStrokePoints'\nimport { setStrokePointRadii } from '../shared/freehand/setStrokePointRadii'\nimport { getSvgPathFromStrokePoints } from '../shared/freehand/svg'\nimport { interpolateSegments } from '../shared/interpolate-props'\nimport { useColorSpace } from '../shared/useColorSpace'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\n\n/** @public */\nexport interface HighlightShapeOptions {\n\t/**\n\t * The maximum number of points in a line before the draw tool will begin a new shape.\n\t * A higher number will lead to poor performance while drawing very long lines.\n\t */\n\treadonly maxPointsPerShape: number\n\treadonly underlayOpacity: number\n\treadonly overlayOpacity: number\n}\n\n/** @public */\nexport class HighlightShapeUtil extends ShapeUtil<TLHighlightShape> {\n\tstatic override type = 'highlight' as const\n\tstatic override props = highlightShapeProps\n\tstatic override migrations = highlightShapeMigrations\n\n\toverride options: HighlightShapeOptions = {\n\t\tmaxPointsPerShape: 600,\n\t\tunderlayOpacity: 0.82,\n\t\toverlayOpacity: 0.35,\n\t}\n\n\toverride hideResizeHandles(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\toverride hideRotateHandle(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\toverride hideSelectionBoundsFg(shape: TLHighlightShape) {\n\t\treturn getIsDot(shape)\n\t}\n\n\toverride getDefaultProps(): TLHighlightShape['props'] {\n\t\treturn {\n\t\t\tsegments: [],\n\t\t\tcolor: 'black',\n\t\t\tsize: 'm',\n\t\t\tisComplete: false,\n\t\t\tisPen: false,\n\t\t\tscale: 1,\n\t\t\tscaleX: 1,\n\t\t\tscaleY: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tif (getIsDot(shape)) {\n\t\t\treturn new Circle2d({\n\t\t\t\tx: -strokeWidth / 2,\n\t\t\t\ty: -strokeWidth / 2,\n\t\t\t\tradius: strokeWidth / 2,\n\t\t\t\tisFilled: true,\n\t\t\t})\n\t\t}\n\n\t\tconst { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, true)\n\t\tconst opts = getHighlightFreehandSettings({ strokeWidth: sw, showAsComplete: true })\n\t\tsetStrokePointRadii(strokePoints, opts)\n\n\t\treturn new Polygon2d({\n\t\t\tpoints: getStrokeOutlinePoints(strokePoints, opts),\n\t\t\tisFilled: true,\n\t\t})\n\t}\n\n\tcomponent(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tshape={shape}\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\topacity={this.options.overlayOpacity}\n\t\t\t\t/>\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\toverride backgroundComponent(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tshape={shape}\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\topacity={this.options.underlayOpacity}\n\t\t\t\t/>\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\tindicator(shape: TLHighlightShape) {\n\t\tconst forceSolid = useHighlightForceSolid(this.editor, shape)\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\n\t\tconst { strokePoints, sw } = getHighlightStrokePoints(shape, strokeWidth, forceSolid)\n\t\tconst allPointsFromSegments = getPointsFromDrawSegments(\n\t\t\tshape.props.segments,\n\t\t\tshape.props.scaleX,\n\t\t\tshape.props.scaleY\n\t\t)\n\n\t\tlet strokePath\n\t\tif (strokePoints.length < 2) {\n\t\t\tstrokePath = getIndicatorDot(allPointsFromSegments[0], sw)\n\t\t} else {\n\t\t\tstrokePath = getSvgPathFromStrokePoints(strokePoints, false)\n\t\t}\n\n\t\treturn <path d={strokePath} />\n\t}\n\n\toverride toSvg(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tconst forceSolid = strokeWidth < 1.5\n\t\tconst scaleFactor = 1 / shape.props.scale\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\tshape={shape}\n\t\t\t\t\topacity={this.options.overlayOpacity}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride toBackgroundSvg(shape: TLHighlightShape) {\n\t\tconst strokeWidth = getStrokeWidth(shape)\n\t\tconst forceSolid = strokeWidth < 1.5\n\t\tconst scaleFactor = 1 / shape.props.scale\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<HighlightRenderer\n\t\t\t\t\tforceSolid={forceSolid}\n\t\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\t\tshape={shape}\n\t\t\t\t\topacity={this.options.underlayOpacity}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride onResize(shape: TLHighlightShape, info: TLResizeInfo<TLHighlightShape>) {\n\t\tconst { scaleX, scaleY } = info\n\n\t\treturn {\n\t\t\tprops: {\n\t\t\t\tscaleX: scaleX * shape.props.scaleX,\n\t\t\t\tscaleY: scaleY * shape.props.scaleY,\n\t\t\t},\n\t\t}\n\t}\n\toverride getInterpolatedProps(\n\t\tstartShape: TLHighlightShape,\n\t\tendShape: TLHighlightShape,\n\t\tt: number\n\t): TLHighlightShapeProps {\n\t\treturn {\n\t\t\t...(t > 0.5 ? endShape.props : startShape.props),\n\t\t\t...endShape.props,\n\t\t\tsegments: interpolateSegments(startShape.props.segments, endShape.props.segments, t),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, t),\n\t\t}\n\t}\n}\n\nfunction getShapeDot(point: VecLike) {\n\tconst r = 0.1\n\treturn `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${\n\t\tr * 2\n\t},0`\n}\n\nfunction getIndicatorDot(point: VecLike, sw: number) {\n\tconst r = sw / 2\n\treturn `M ${point.x} ${point.y} m -${r}, 0 a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${\n\t\tr * 2\n\t},0`\n}\n\nfunction getHighlightStrokePoints(\n\tshape: TLHighlightShape,\n\tstrokeWidth: number,\n\tforceSolid: boolean\n) {\n\tconst allPointsFromSegments = getPointsFromDrawSegments(\n\t\tshape.props.segments,\n\t\tshape.props.scaleX,\n\t\tshape.props.scaleY\n\t)\n\tconst showAsComplete = shape.props.isComplete || last(shape.props.segments)?.type === 'straight'\n\n\tlet sw = strokeWidth\n\tif (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {\n\t\tsw += rng(shape.id)() * (strokeWidth / 6)\n\t}\n\n\tconst options = getHighlightFreehandSettings({\n\t\tstrokeWidth: sw,\n\t\tshowAsComplete,\n\t})\n\n\tconst strokePoints = getStrokePoints(allPointsFromSegments, options)\n\n\treturn { strokePoints, sw }\n}\n\nfunction getStrokeWidth(shape: TLHighlightShape) {\n\treturn FONT_SIZES[shape.props.size] * 1.12 * shape.props.scale\n}\n\nfunction getIsDot(shape: TLHighlightShape) {\n\t// Each point is 8 base64 characters (3 Float16s = 6 bytes = 8 base64 chars)\n\t// Check if we have less than 2 points without decoding\n\treturn shape.props.segments.length === 1 && shape.props.segments[0].points.length < 16\n}\n\nfunction HighlightRenderer({\n\tstrokeWidth,\n\tforceSolid,\n\tshape,\n\topacity,\n}: {\n\tstrokeWidth: number\n\tforceSolid: boolean\n\tshape: TLHighlightShape\n\topacity: number\n}) {\n\tconst theme = useDefaultColorTheme()\n\n\tconst allPointsFromSegments = getPointsFromDrawSegments(\n\t\tshape.props.segments,\n\t\tshape.props.scaleX,\n\t\tshape.props.scaleY\n\t)\n\n\tlet sw = strokeWidth\n\tif (!forceSolid && !shape.props.isPen && allPointsFromSegments.length === 1) {\n\t\tsw += rng(shape.id)() * (sw / 6)\n\t}\n\n\tconst options = getHighlightFreehandSettings({\n\t\tstrokeWidth: sw,\n\t\tshowAsComplete: shape.props.isComplete || last(shape.props.segments)?.type === 'straight',\n\t})\n\n\tconst strokePoints = getStrokePoints(allPointsFromSegments, options)\n\n\tconst solidStrokePath =\n\t\tstrokePoints.length > 1\n\t\t\t? getSvgPathFromStrokePoints(strokePoints, false)\n\t\t\t: getShapeDot(allPointsFromSegments[0])\n\n\tconst colorSpace = useColorSpace()\n\n\tconst color = getColorValue(\n\t\ttheme,\n\t\tshape.props.color,\n\t\tcolorSpace === 'p3' ? 'highlightP3' : 'highlightSrgb'\n\t)\n\n\treturn (\n\t\t<path\n\t\t\td={solidStrokePath}\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tfill=\"none\"\n\t\t\tpointerEvents=\"all\"\n\t\t\tstroke={color}\n\t\t\tstrokeWidth={sw}\n\t\t\topacity={opacity}\n\t\t/>\n\t)\n}\n\nfunction useHighlightForceSolid(editor: Editor, shape: TLHighlightShape) {\n\treturn useValue(\n\t\t'forceSolid',\n\t\t() => {\n\t\t\tconst sw = getStrokeWidth(shape)\n\t\t\tconst zoomLevel = editor.getEfficientZoomLevel()\n\t\t\tif (sw / zoomLevel < 1.5) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t},\n\t\t[editor]\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuGI;AAtGJ,oBAiBO;AAEP,qBAAwE;AACxE,qCAA2B;AAC3B,oCAAuC;AACvC,6BAAgC;AAChC,iCAAoC;AACpC,iBAA2C;AAC3C,+BAAoC;AACpC,2BAA8B;AAC9B,kCAAqC;AAc9B,MAAM,2BAA2B,wBAA4B;AAAA,EACnE,OAAgB,OAAO;AAAA,EACvB,OAAgB,QAAQ;AAAA,EACxB,OAAgB,aAAa;AAAA,EAEpB,UAAiC;AAAA,IACzC,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,EACjB;AAAA,EAES,kBAAkB,OAAyB;AACnD,WAAO,SAAS,KAAK;AAAA,EACtB;AAAA,EACS,iBAAiB,OAAyB;AAClD,WAAO,SAAS,KA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K,eAAe,KAAK;AAC/B,YAAM,YAAY,OAAO,sBAAsB;AAC/C,UAAI,KAAK,YAAY,KAAK;AACzB,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AACD;",
6
6
  "names": []
7
7
  }
@@ -29,10 +29,10 @@ class Pointing extends import_editor.StateNode {
29
29
  markId;
30
30
  onEnter(info) {
31
31
  const { inputs } = this.editor;
32
- const { currentPagePoint } = inputs;
32
+ const currentPagePoint = inputs.getCurrentPagePoint();
33
33
  this.markId = void 0;
34
34
  const shape = info.shapeId && this.editor.getShape(info.shapeId);
35
- if (shape && inputs.shiftKey) {
35
+ if (shape && inputs.getShiftKey()) {
36
36
  this.markId = this.editor.markHistoryStoppingPoint(`creating_line:${shape.id}`);
37
37
  this.shape = shape;
38
38
  const handles = this.editor.getShapeHandles(this.shape);
@@ -97,7 +97,7 @@ class Pointing extends import_editor.StateNode {
97
97
  }
98
98
  onPointerMove() {
99
99
  if (!this.shape) return;
100
- if (this.editor.inputs.isDragging) {
100
+ if (this.editor.inputs.getIsDragging()) {
101
101
  const handles = this.editor.getShapeHandles(this.shape);
102
102
  if (!handles) {
103
103
  if (this.markId) this.editor.bailToMark(this.markId);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/shapes/line/toolStates/Pointing.ts"],
4
- "sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLLineShape,\n\tTLShapeId,\n\tVec,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tlast,\n\tmaybeSnapToGrid,\n\tsortByIndex,\n\tstructuredClone,\n} from '@tldraw/editor'\n\nconst MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES = 2\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\tshape = {} as TLLineShape\n\n\tmarkId: string | undefined\n\n\toverride onEnter(info: { shapeId?: TLShapeId }) {\n\t\tconst { inputs } = this.editor\n\t\tconst { currentPagePoint } = inputs\n\n\t\tthis.markId = undefined\n\n\t\t// Previously created line shape that we might be extending\n\t\tconst shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)\n\n\t\tif (shape && inputs.shiftKey) {\n\t\t\t// Extending a previous shape\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint(`creating_line:${shape.id}`)\n\t\t\tthis.shape = shape\n\n\t\t\tconst handles = this.editor.getShapeHandles(this.shape)\n\t\t\tif (!handles) return\n\n\t\t\tconst vertexHandles = handles.filter((h) => h.type === 'vertex').sort(sortByIndex)\n\t\t\tconst endHandle = vertexHandles[vertexHandles.length - 1]\n\t\t\tconst prevEndHandle = vertexHandles[vertexHandles.length - 2]\n\n\t\t\tconst shapePagePoint = Mat.applyToPoint(\n\t\t\t\tthis.editor.getShapeParentTransform(this.shape)!,\n\t\t\t\tnew Vec(this.shape.x, this.shape.y)\n\t\t\t)\n\t\t\t// nudge the point slightly to avoid zero-length lines\n\t\t\tconst nudgedPoint = Vec.Sub(currentPagePoint, shapePagePoint).addXY(0.1, 0.1)\n\t\t\tconst nextPoint = maybeSnapToGrid(nudgedPoint, this.editor)\n\t\t\tconst points = structuredClone(this.shape.props.points)\n\n\t\t\tif (\n\t\t\t\tVec.DistMin(endHandle, prevEndHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES) ||\n\t\t\t\tVec.DistMin(nextPoint, endHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES)\n\t\t\t) {\n\t\t\t\t// Don't add a new point if the distance between the last two points is too small\n\t\t\t\tpoints[endHandle.id] = {\n\t\t\t\t\tid: endHandle.id,\n\t\t\t\t\tindex: endHandle.index,\n\t\t\t\t\tx: nextPoint.x,\n\t\t\t\t\ty: nextPoint.y,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Add a new point\n\t\t\t\tconst nextIndex = getIndexAbove(endHandle.index)\n\t\t\t\tpoints[nextIndex] = {\n\t\t\t\t\tid: nextIndex,\n\t\t\t\t\tindex: nextIndex,\n\t\t\t\t\tx: nextPoint.x,\n\t\t\t\t\ty: nextPoint.y,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.editor.updateShapes([\n\t\t\t\t{\n\t\t\t\t\tid: this.shape.id,\n\t\t\t\t\ttype: this.shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\t\t} else {\n\t\t\tconst id = createShapeId()\n\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint(`creating_line:${id}`)\n\n\t\t\tconst newPoint = maybeSnapToGrid(currentPagePoint, this.editor)\n\n\t\t\tthis.editor.createShapes<TLLineShape>([\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\n\t\t\tif (!this.editor.getShape(id)) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.select(id)\n\t\t\tthis.shape = this.editor.getShape(id)!\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tif (!this.shape) return\n\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\tconst handles = this.editor.getShapeHandles(this.shape)\n\t\t\tif (!handles) {\n\t\t\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\t\t\tthrow Error('No handles found')\n\t\t\t}\n\t\t\tconst lastHandle = last(handles)!\n\t\t\tthis.editor.setCurrentTool('select.dragging_handle', {\n\t\t\t\tshape: this.shape,\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId: this.markId,\n\t\t\t\t// remove the offset that we added to the handle when we created it\n\t\t\t\thandle: { ...lastHandle, x: lastHandle.x - 0.1, y: lastHandle.y - 0.1 },\n\t\t\t\tonInteractionEnd: 'line',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tcomplete() {\n\t\tthis.parent.transition('idle', { shapeId: this.shape.id })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tcancel() {\n\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\tthis.parent.transition('idle', { shapeId: this.shape.id })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AAEP,MAAM,iDAAiD;AAEhD,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB,QAAQ,CAAC;AAAA,EAET;AAAA,EAES,QAAQ,MAA+B;AAC/C,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,UAAM,EAAE,iBAAiB,IAAI;AAE7B,SAAK,SAAS;AAGd,UAAM,QAAQ,KAAK,WAAW,KAAK,OAAO,SAAsB,KAAK,OAAO;AAE5E,QAAI,SAAS,OAAO,UAAU;AAE7B,WAAK,SAAS,KAAK,OAAO,yBAAyB,iBAAiB,MAAM,EAAE,EAAE;AAC9E,WAAK,QAAQ;AAEb,YAAM,UAAU,KAAK,OAAO,gBAAgB,KAAK,KAAK;AACtD,UAAI,CAAC,QAAS;AAEd,YAAM,gBAAgB,QAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,KAAK,yBAAW;AACjF,YAAM,YAAY,cAAc,cAAc,SAAS,CAAC;AACxD,YAAM,g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A,SAAS;AACR,QAAI,KAAK,OAAQ,MAAK,OAAO,WAAW,KAAK,MAAM;AACnD,SAAK,OAAO,WAAW,QAAQ,EAAE,SAAS,KAAK,MAAM,GAAG,CAAC;AACzD,SAAK,OAAO,MAAM,gBAAgB;AAAA,EACnC;AACD;",
4
+ "sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLLineShape,\n\tTLShapeId,\n\tVec,\n\tcreateShapeId,\n\tgetIndexAbove,\n\tlast,\n\tmaybeSnapToGrid,\n\tsortByIndex,\n\tstructuredClone,\n} from '@tldraw/editor'\n\nconst MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES = 2\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\tshape = {} as TLLineShape\n\n\tmarkId: string | undefined\n\n\toverride onEnter(info: { shapeId?: TLShapeId }) {\n\t\tconst { inputs } = this.editor\n\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\tthis.markId = undefined\n\n\t\t// Previously created line shape that we might be extending\n\t\tconst shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)\n\n\t\tif (shape && inputs.getShiftKey()) {\n\t\t\t// Extending a previous shape\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint(`creating_line:${shape.id}`)\n\t\t\tthis.shape = shape\n\n\t\t\tconst handles = this.editor.getShapeHandles(this.shape)\n\t\t\tif (!handles) return\n\n\t\t\tconst vertexHandles = handles.filter((h) => h.type === 'vertex').sort(sortByIndex)\n\t\t\tconst endHandle = vertexHandles[vertexHandles.length - 1]\n\t\t\tconst prevEndHandle = vertexHandles[vertexHandles.length - 2]\n\n\t\t\tconst shapePagePoint = Mat.applyToPoint(\n\t\t\t\tthis.editor.getShapeParentTransform(this.shape)!,\n\t\t\t\tnew Vec(this.shape.x, this.shape.y)\n\t\t\t)\n\t\t\t// nudge the point slightly to avoid zero-length lines\n\t\t\tconst nudgedPoint = Vec.Sub(currentPagePoint, shapePagePoint).addXY(0.1, 0.1)\n\t\t\tconst nextPoint = maybeSnapToGrid(nudgedPoint, this.editor)\n\t\t\tconst points = structuredClone(this.shape.props.points)\n\n\t\t\tif (\n\t\t\t\tVec.DistMin(endHandle, prevEndHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES) ||\n\t\t\t\tVec.DistMin(nextPoint, endHandle, MINIMUM_DISTANCE_BETWEEN_SHIFT_CLICKED_HANDLES)\n\t\t\t) {\n\t\t\t\t// Don't add a new point if the distance between the last two points is too small\n\t\t\t\tpoints[endHandle.id] = {\n\t\t\t\t\tid: endHandle.id,\n\t\t\t\t\tindex: endHandle.index,\n\t\t\t\t\tx: nextPoint.x,\n\t\t\t\t\ty: nextPoint.y,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Add a new point\n\t\t\t\tconst nextIndex = getIndexAbove(endHandle.index)\n\t\t\t\tpoints[nextIndex] = {\n\t\t\t\t\tid: nextIndex,\n\t\t\t\t\tindex: nextIndex,\n\t\t\t\t\tx: nextPoint.x,\n\t\t\t\t\ty: nextPoint.y,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.editor.updateShapes([\n\t\t\t\t{\n\t\t\t\t\tid: this.shape.id,\n\t\t\t\t\ttype: this.shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\t\t} else {\n\t\t\tconst id = createShapeId()\n\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint(`creating_line:${id}`)\n\n\t\t\tconst newPoint = maybeSnapToGrid(currentPagePoint, this.editor)\n\n\t\t\tthis.editor.createShapes([\n\t\t\t\t{\n\t\t\t\t\tid,\n\t\t\t\t\ttype: 'line',\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\n\t\t\tif (!this.editor.getShape(id)) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.select(id)\n\t\t\tthis.shape = this.editor.getShape(id)!\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tif (!this.shape) return\n\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tconst handles = this.editor.getShapeHandles(this.shape)\n\t\t\tif (!handles) {\n\t\t\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\t\t\tthrow Error('No handles found')\n\t\t\t}\n\t\t\tconst lastHandle = last(handles)!\n\t\t\tthis.editor.setCurrentTool('select.dragging_handle', {\n\t\t\t\tshape: this.shape,\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId: this.markId,\n\t\t\t\t// remove the offset that we added to the handle when we created it\n\t\t\t\thandle: { ...lastHandle, x: lastHandle.x - 0.1, y: lastHandle.y - 0.1 },\n\t\t\t\tonInteractionEnd: 'line',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.parent.transition('idle')\n\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tcomplete() {\n\t\tthis.parent.transition('idle', { shapeId: this.shape.id })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n\n\tcancel() {\n\t\tif (this.markId) this.editor.bailToMark(this.markId)\n\t\tthis.parent.transition('idle', { shapeId: this.shape.id })\n\t\tthis.editor.snaps.clearIndicators()\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AAEP,MAAM,iDAAiD;AAEhD,MAAM,iBAAiB,wBAAU;AAAA,EAC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AAA;AAAA,QAErB,QAAQ,EAAE,GAAG,YAAY,GAAG,WAAW,IAAI,KAAK,GAAG,WAAW,IAAI,IAAI;AAAA,QACtE,kBAAkB;AAAA,MACnB,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAES,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,SAAK,OAAO,WAAW,MAAM;AAC7B,QAAI,KAAK,OAAQ,MAAK,OAAO,WAAW,KAAK,MAAM;AACnD,SAAK,OAAO,MAAM,gBAAgB;AAAA,EACnC;AAAA,EAEA,WAAW;AACV,SAAK,OAAO,WAAW,QAAQ,EAAE,SAAS,KAAK,MAAM,GAAG,CAAC;AACzD,SAAK,OAAO,MAAM,gBAAgB;AAAA,EACnC;AAAA,EAEA,SAAS;AACR,QAAI,KAAK,OAAQ,MAAK,OAAO,WAAW,KAAK,MAAM;AACnD,SAAK,OAAO,WAAW,QAAQ,EAAE,SAAS,KAAK,MAAM,GAAG,CAAC;AACzD,SAAK,OAAO,MAAM,gBAAgB;AAAA,EACnC;AACD;",
6
6
  "names": []
7
7
  }
@@ -33,6 +33,7 @@ var import_RichTextLabel = require("../shared/RichTextLabel");
33
33
  var import_default_shape_constants = require("../shared/default-shape-constants");
34
34
  var import_useDefaultColorTheme = require("../shared/useDefaultColorTheme");
35
35
  var import_useEditablePlainText = require("../shared/useEditablePlainText");
36
+ var import_useEfficientZoomThreshold = require("../shared/useEfficientZoomThreshold");
36
37
  var import_noteHelpers = require("./noteHelpers");
37
38
  class NoteShapeUtil extends import_editor.ShapeUtil {
38
39
  static type = "note";
@@ -105,7 +106,7 @@ class NoteShapeUtil extends import_editor.ShapeUtil {
105
106
  const { scale } = shape.props;
106
107
  const isCoarsePointer = this.editor.getInstanceState().isCoarsePointer;
107
108
  if (isCoarsePointer) return [];
108
- const zoom = this.editor.getZoomLevel();
109
+ const zoom = this.editor.getEfficientZoomLevel();
109
110
  if (zoom * scale < 0.25) return [];
110
111
  const nh = getNoteHeight(shape);
111
112
  const nw = import_noteHelpers.NOTE_SIZE * scale;
@@ -204,11 +205,9 @@ class NoteShapeUtil extends import_editor.ShapeUtil {
204
205
  () => this.editor.getShapePageTransform(id)?.rotation() ?? 0,
205
206
  [this.editor]
206
207
  );
207
- const hideShadows = (0, import_editor.useValue)("zoom", () => this.editor.getZoomLevel() < 0.35 / scale, [
208
- scale,
209
- this.editor
210
- ]);
211
208
  const isDarkMode = (0, import_editor.useValue)("dark mode", () => this.editor.user.getIsDarkMode(), [this.editor]);
209
+ let hideShadows = (0, import_useEfficientZoomThreshold.useEfficientZoomThreshold)(scale * 0.25);
210
+ if (isDarkMode) hideShadows = true;
212
211
  const isSelected = shape.id === this.editor.getOnlySelectedShapeId();
213
212
  const isReadyForEditing = (0, import_useEditablePlainText.useIsReadyForEditing)(this.editor, shape.id);
214
213
  const isEmpty = (0, import_richText.isEmptyRichText)(richText);
@@ -241,6 +240,7 @@ class NoteShapeUtil extends import_editor.ShapeUtil {
241
240
  wrap: true,
242
241
  padding: import_default_shape_constants.LABEL_PADDING * scale,
243
242
  hasCustomTabBehavior: true,
243
+ showTextOutline: false,
244
244
  onKeyDown: handleKeyDown
245
245
  }
246
246
  )
@@ -395,12 +395,7 @@ function useNoteKeydownHandler(id) {
395
395
  ).mul(offsetLength).add(import_noteHelpers.NOTE_CENTER_OFFSET.clone().mul(shape.props.scale)).rot(pageRotation).add(pageTransform.point());
396
396
  const newNote = (0, import_noteHelpers.getNoteShapeForAdjacentPosition)(editor, shape, adjacentCenter, pageRotation);
397
397
  if (newNote) {
398
- (0, import_selectHelpers.startEditingShapeWithLabel)(
399
- editor,
400
- newNote,
401
- true
402
- /* selectAll */
403
- );
398
+ (0, import_selectHelpers.startEditingShapeWithRichText)(editor, newNote, { selectAll: true });
404
399
  }
405
400
  }
406
401
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/shapes/note/NoteShapeUtil.tsx"],
4
- "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport {\n\tBox,\n\tEMPTY_ARRAY,\n\tEditor,\n\tGroup2d,\n\tIndexKey,\n\tRectangle2d,\n\tShapeUtil,\n\tSvgExportContext,\n\tTLHandle,\n\tTLNoteShape,\n\tTLNoteShapeProps,\n\tTLResizeInfo,\n\tTLShape,\n\tTLShapeId,\n\tVec,\n\tWeakCache,\n\texhaustiveSwitchError,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\tgetFontsFromRichText,\n\tisEqual,\n\tlerp,\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\tresizeScaled,\n\trng,\n\ttoDomPrecision,\n\ttoRichText,\n\tuseEditor,\n\tuseValue,\n} from '@tldraw/editor'\nimport { useCallback, useContext } from 'react'\nimport { startEditingShapeWithLabel } from '../../tools/SelectTool/selectHelpers'\nimport { TranslationsContext } from '../../ui/hooks/useTranslation/useTranslation'\nimport {\n\tisEmptyRichText,\n\trenderHtmlFromRichTextForMeasurement,\n\trenderPlaintextFromRichText,\n} from '../../utils/text/richText'\nimport { isRightToLeftLanguage } from '../../utils/text/text'\nimport { HyperlinkButton } from '../shared/HyperlinkButton'\nimport { RichTextLabel, RichTextSVG } from '../shared/RichTextLabel'\nimport {\n\tFONT_FAMILIES,\n\tLABEL_FONT_SIZES,\n\tLABEL_PADDING,\n\tTEXT_PROPS,\n} from '../shared/default-shape-constants'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\nimport { useIsReadyForEditing } from '../shared/useEditablePlainText'\nimport {\n\tCLONE_HANDLE_MARGIN,\n\tNOTE_CENTER_OFFSET,\n\tNOTE_SIZE,\n\tgetNoteShapeForAdjacentPosition,\n} from './noteHelpers'\n\n/** @public */\nexport interface NoteShapeOptions {\n\t/**\n\t * How should the note shape resize? By default it does not resize (except automatically based on its text content),\n\t * but you can set it to be user-resizable using scale.\n\t */\n\tresizeMode: 'none' | 'scale'\n}\n\n/** @public */\nexport class NoteShapeUtil extends ShapeUtil<TLNoteShape> {\n\tstatic override type = 'note' as const\n\tstatic override props = noteShapeProps\n\tstatic override migrations = noteShapeMigrations\n\n\toverride options: NoteShapeOptions = {\n\t\tresizeMode: 'none',\n\t}\n\n\toverride canEdit() {\n\t\treturn true\n\t}\n\toverride hideResizeHandles() {\n\t\tconst { resizeMode } = this.options\n\t\tswitch (resizeMode) {\n\t\t\tcase 'none': {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tcase 'scale': {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow exhaustiveSwitchError(resizeMode)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride isAspectRatioLocked() {\n\t\treturn this.options.resizeMode === 'scale'\n\t}\n\n\toverride hideSelectionBoundsFg() {\n\t\treturn false\n\t}\n\n\tgetDefaultProps(): TLNoteShape['props'] {\n\t\treturn {\n\t\t\tcolor: 'black',\n\t\t\trichText: toRichText(''),\n\t\t\tsize: 'm',\n\t\t\tfont: 'draw',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t\tlabelColor: 'black',\n\t\t\tgrowY: 0,\n\t\t\tfontSizeAdjustment: 0,\n\t\t\turl: '',\n\t\t\tscale: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLNoteShape) {\n\t\tconst { labelHeight, labelWidth } = getLabelSize(this.editor, shape)\n\t\tconst { scale } = shape.props\n\n\t\tconst lh = labelHeight * scale\n\t\tconst lw = labelWidth * scale\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst nh = getNoteHeight(shape)\n\n\t\treturn new Group2d({\n\t\t\tchildren: [\n\t\t\t\tnew Rectangle2d({ width: nw, height: nh, isFilled: true }),\n\t\t\t\tnew Rectangle2d({\n\t\t\t\t\tx:\n\t\t\t\t\t\tshape.props.align === 'start'\n\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t: shape.props.align === 'end'\n\t\t\t\t\t\t\t\t? nw - lw\n\t\t\t\t\t\t\t\t: (nw - lw) / 2,\n\t\t\t\t\ty:\n\t\t\t\t\t\tshape.props.verticalAlign === 'start'\n\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t: shape.props.verticalAlign === 'end'\n\t\t\t\t\t\t\t\t? nh - lh\n\t\t\t\t\t\t\t\t: (nh - lh) / 2,\n\t\t\t\t\twidth: lw,\n\t\t\t\t\theight: lh,\n\t\t\t\t\tisFilled: true,\n\t\t\t\t\tisLabel: true,\n\t\t\t\t\texcludeFromShapeBounds: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\toverride getHandles(shape: TLNoteShape): TLHandle[] {\n\t\tconst { scale } = shape.props\n\t\tconst isCoarsePointer = this.editor.getInstanceState().isCoarsePointer\n\t\tif (isCoarsePointer) return []\n\n\t\tconst zoom = this.editor.getZoomLevel()\n\t\tif (zoom * scale < 0.25) return []\n\n\t\tconst nh = getNoteHeight(shape)\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst offset = (CLONE_HANDLE_MARGIN / zoom) * scale\n\n\t\tif (zoom * scale < 0.5) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: 'bottom',\n\t\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\t\ttype: 'clone',\n\t\t\t\t\tx: nw / 2,\n\t\t\t\t\ty: nh + offset,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'top',\n\t\t\t\tindex: 'a1' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw / 2,\n\t\t\t\ty: -offset,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'right',\n\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw + offset,\n\t\t\t\ty: nh / 2,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'bottom',\n\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw / 2,\n\t\t\t\ty: nh + offset,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'left',\n\t\t\t\tindex: 'a4' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: -offset,\n\t\t\t\ty: nh / 2,\n\t\t\t},\n\t\t]\n\t}\n\n\toverride onResize(shape: any, info: TLResizeInfo<any>) {\n\t\tconst { resizeMode } = this.options\n\t\tswitch (resizeMode) {\n\t\t\tcase 'none': {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tcase 'scale': {\n\t\t\t\treturn resizeScaled(shape, info)\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow exhaustiveSwitchError(resizeMode)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride getText(shape: TLNoteShape) {\n\t\treturn renderPlaintextFromRichText(this.editor, shape.props.richText)\n\t}\n\n\toverride getFontFaces(shape: TLNoteShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) {\n\t\t\treturn EMPTY_ARRAY\n\t\t}\n\t\treturn getFontsFromRichText(this.editor, shape.props.richText, {\n\t\t\tfamily: `tldraw_${shape.props.font}`,\n\t\t\tweight: 'normal',\n\t\t\tstyle: 'normal',\n\t\t})\n\t}\n\n\tcomponent(shape: TLNoteShape) {\n\t\tconst {\n\t\t\tid,\n\t\t\ttype,\n\t\t\tprops: {\n\t\t\t\tlabelColor,\n\t\t\t\tscale,\n\t\t\t\tcolor,\n\t\t\t\tfont,\n\t\t\t\tsize,\n\t\t\t\talign,\n\t\t\t\trichText,\n\t\t\t\tverticalAlign,\n\t\t\t\tfontSizeAdjustment,\n\t\t\t},\n\t\t} = shape\n\n\t\tconst handleKeyDown = useNoteKeydownHandler(id)\n\n\t\tconst theme = useDefaultColorTheme()\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst nh = getNoteHeight(shape)\n\n\t\tconst rotation = useValue(\n\t\t\t'shape rotation',\n\t\t\t() => this.editor.getShapePageTransform(id)?.rotation() ?? 0,\n\t\t\t[this.editor]\n\t\t)\n\n\t\t// todo: consider hiding shadows on dark mode if they're invisible anyway\n\n\t\tconst hideShadows = useValue('zoom', () => this.editor.getZoomLevel() < 0.35 / scale, [\n\t\t\tscale,\n\t\t\tthis.editor,\n\t\t])\n\n\t\tconst isDarkMode = useValue('dark mode', () => this.editor.user.getIsDarkMode(), [this.editor])\n\n\t\tconst isSelected = shape.id === this.editor.getOnlySelectedShapeId()\n\n\t\tconst isReadyForEditing = useIsReadyForEditing(this.editor, shape.id)\n\t\tconst isEmpty = isEmptyRichText(richText)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div\n\t\t\t\t\tid={id}\n\t\t\t\t\tclassName=\"tl-note__container\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\twidth: nw,\n\t\t\t\t\t\theight: nh,\n\t\t\t\t\t\tbackgroundColor: getColorValue(theme, color, 'noteFill'),\n\t\t\t\t\t\tborderBottom: hideShadows\n\t\t\t\t\t\t\t? isDarkMode\n\t\t\t\t\t\t\t\t? `${2 * scale}px solid rgb(20, 20, 20)`\n\t\t\t\t\t\t\t\t: `${2 * scale}px solid rgb(144, 144, 144)`\n\t\t\t\t\t\t\t: 'none',\n\t\t\t\t\t\tboxShadow: hideShadows ? 'none' : getNoteShadow(shape.id, rotation, scale),\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{(isSelected || isReadyForEditing || !isEmpty) && (\n\t\t\t\t\t\t<RichTextLabel\n\t\t\t\t\t\t\tshapeId={id}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t\tfont={font}\n\t\t\t\t\t\t\tfontSize={(fontSizeAdjustment || LABEL_FONT_SIZES[size]) * scale}\n\t\t\t\t\t\t\tlineHeight={TEXT_PROPS.lineHeight}\n\t\t\t\t\t\t\talign={align}\n\t\t\t\t\t\t\tverticalAlign={verticalAlign}\n\t\t\t\t\t\t\trichText={richText}\n\t\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t\t\tlabelColor={\n\t\t\t\t\t\t\t\tlabelColor === 'black'\n\t\t\t\t\t\t\t\t\t? getColorValue(theme, color, 'noteText')\n\t\t\t\t\t\t\t\t\t: getColorValue(theme, labelColor, 'fill')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twrap\n\t\t\t\t\t\t\tpadding={LABEL_PADDING * scale}\n\t\t\t\t\t\t\thasCustomTabBehavior\n\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{'url' in shape.props && shape.props.url && <HyperlinkButton url={shape.props.url} />}\n\t\t\t</>\n\t\t)\n\t}\n\n\tindicator(shape: TLNoteShape) {\n\t\tconst { scale } = shape.props\n\t\treturn (\n\t\t\t<rect\n\t\t\t\trx={scale}\n\t\t\t\twidth={toDomPrecision(NOTE_SIZE * scale)}\n\t\t\t\theight={toDomPrecision(getNoteHeight(shape))}\n\t\t\t/>\n\t\t)\n\t}\n\n\toverride toSvg(shape: TLNoteShape, ctx: SvgExportContext) {\n\t\tconst theme = getDefaultColorTheme({ isDarkMode: ctx.isDarkMode })\n\t\tconst bounds = getBoundsForSVG(shape)\n\n\t\tconst textLabel = (\n\t\t\t<RichTextSVG\n\t\t\t\tfontSize={shape.props.fontSizeAdjustment || LABEL_FONT_SIZES[shape.props.size]}\n\t\t\t\tfont={shape.props.font}\n\t\t\t\talign={shape.props.align}\n\t\t\t\tverticalAlign={shape.props.verticalAlign}\n\t\t\t\trichText={shape.props.richText}\n\t\t\t\tlabelColor={getColorValue(theme, shape.props.color, 'noteText')}\n\t\t\t\tbounds={bounds}\n\t\t\t\tpadding={LABEL_PADDING}\n\t\t\t\tshowTextOutline={false}\n\t\t\t/>\n\t\t)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<rect x={5} y={5} rx={1} width={NOTE_SIZE - 10} height={bounds.h} fill=\"rgba(0,0,0,.1)\" />\n\t\t\t\t<rect\n\t\t\t\t\trx={1}\n\t\t\t\t\twidth={NOTE_SIZE}\n\t\t\t\t\theight={bounds.h}\n\t\t\t\t\tfill={getColorValue(theme, shape.props.color, 'noteFill')}\n\t\t\t\t/>\n\t\t\t\t{textLabel}\n\t\t\t</>\n\t\t)\n\t}\n\n\toverride onBeforeCreate(next: TLNoteShape) {\n\t\treturn getNoteSizeAdjustments(this.editor, next)\n\t}\n\n\toverride onBeforeUpdate(prev: TLNoteShape, next: TLNoteShape) {\n\t\tif (\n\t\t\tisEqual(prev.props.richText, next.props.richText) &&\n\t\t\tprev.props.font === next.props.font &&\n\t\t\tprev.props.size === next.props.size\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\treturn getNoteSizeAdjustments(this.editor, next)\n\t}\n\n\toverride getInterpolatedProps(\n\t\tstartShape: TLNoteShape,\n\t\tendShape: TLNoteShape,\n\t\tt: number\n\t): TLNoteShapeProps {\n\t\treturn {\n\t\t\t...(t > 0.5 ? endShape.props : startShape.props),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, t),\n\t\t}\n\t}\n}\n\n/**\n * Get the growY and fontSizeAdjustment for a shape.\n */\nfunction getNoteSizeAdjustments(editor: Editor, shape: TLNoteShape) {\n\tconst { labelHeight, fontSizeAdjustment } = getLabelSize(editor, shape)\n\t// When the label height is more than the height of the shape, we add extra height to it\n\tconst growY = Math.max(0, labelHeight - NOTE_SIZE)\n\n\tif (growY !== shape.props.growY || fontSizeAdjustment !== shape.props.fontSizeAdjustment) {\n\t\treturn {\n\t\t\t...shape,\n\t\t\tprops: {\n\t\t\t\t...shape.props,\n\t\t\t\tgrowY,\n\t\t\t\tfontSizeAdjustment,\n\t\t\t},\n\t\t}\n\t}\n}\n\n/**\n * Get the label size for a note.\n */\nfunction getNoteLabelSize(editor: Editor, shape: TLNoteShape) {\n\tconst { richText } = shape.props\n\n\tif (isEmptyRichText(richText)) {\n\t\tconst minHeight = LABEL_FONT_SIZES[shape.props.size] * TEXT_PROPS.lineHeight + LABEL_PADDING * 2\n\t\treturn { labelHeight: minHeight, labelWidth: 100, fontSizeAdjustment: 0 }\n\t}\n\n\tconst unadjustedFontSize = LABEL_FONT_SIZES[shape.props.size]\n\n\tlet fontSizeAdjustment = 0\n\tlet iterations = 0\n\tlet labelHeight = NOTE_SIZE\n\tlet labelWidth = NOTE_SIZE\n\n\t// N.B. For some note shapes with text like 'hjhjhjhjhjhjhjhj', you'll run into\n\t// some text measurement fuzziness where the browser swears there's no overflow (scrollWidth === width)\n\t// but really there is when you enable overflow-wrap again. This helps account for that little bit\n\t// of give.\n\tconst FUZZ = 1\n\n\t// We slightly make the font smaller if the text is too big for the note, width-wise.\n\tdo {\n\t\tfontSizeAdjustment = Math.min(unadjustedFontSize, unadjustedFontSize - iterations)\n\t\tconst html = renderHtmlFromRichTextForMeasurement(editor, richText)\n\t\tconst nextTextSize = editor.textMeasure.measureHtml(html, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\tfontSize: fontSizeAdjustment,\n\t\t\tmaxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ,\n\t\t\tdisableOverflowWrapBreaking: true,\n\t\t\tmeasureScrollWidth: true,\n\t\t})\n\n\t\tlabelHeight = nextTextSize.h + LABEL_PADDING * 2\n\t\tlabelWidth = nextTextSize.w + LABEL_PADDING * 2\n\n\t\tif (fontSizeAdjustment <= 14) {\n\t\t\t// Too small, just rely now on CSS `overflow-wrap: break-word`\n\t\t\t// We need to recalculate the text measurement here with break-word enabled.\n\t\t\tconst html = renderHtmlFromRichTextForMeasurement(editor, richText)\n\t\t\tconst nextTextSizeWithOverflowBreak = editor.textMeasure.measureHtml(html, {\n\t\t\t\t...TEXT_PROPS,\n\t\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\t\tfontSize: fontSizeAdjustment,\n\t\t\t\tmaxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ,\n\t\t\t})\n\t\t\tlabelHeight = nextTextSizeWithOverflowBreak.h + LABEL_PADDING * 2\n\t\t\tlabelWidth = nextTextSizeWithOverflowBreak.w + LABEL_PADDING * 2\n\t\t\tbreak\n\t\t}\n\n\t\tif (nextTextSize.scrollWidth.toFixed(0) === nextTextSize.w.toFixed(0)) {\n\t\t\tbreak\n\t\t}\n\t} while (iterations++ < 50)\n\n\treturn {\n\t\tlabelHeight: labelHeight,\n\t\tlabelWidth: labelWidth,\n\t\tfontSizeAdjustment: fontSizeAdjustment,\n\t}\n}\n\nconst labelSizesForNote = new WeakCache<TLShape, ReturnType<typeof getNoteLabelSize>>()\n\nfunction getLabelSize(editor: Editor, shape: TLNoteShape) {\n\treturn labelSizesForNote.get(shape, () => getNoteLabelSize(editor, shape))\n}\n\nfunction useNoteKeydownHandler(id: TLShapeId) {\n\tconst editor = useEditor()\n\t// Try to get the translation context, but fallback to ltr if it doesn't exist\n\tconst translation = useContext(TranslationsContext)\n\n\treturn useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst shape = editor.getShape<TLNoteShape>(id)\n\t\t\tif (!shape) return\n\n\t\t\tconst isTab = e.key === 'Tab'\n\t\t\tconst isCmdEnter = (e.metaKey || e.ctrlKey) && e.key === 'Enter'\n\t\t\tif (isTab || isCmdEnter) {\n\t\t\t\te.preventDefault()\n\n\t\t\t\tconst pageTransform = editor.getShapePageTransform(id)\n\t\t\t\tconst pageRotation = pageTransform.rotation()\n\n\t\t\t\t// Based on the inputs, calculate the offset to the next note\n\t\t\t\t// tab controls x axis (shift inverts direction set by RTL)\n\t\t\t\t// cmd enter is the y axis (shift inverts direction)\n\t\t\t\tconst isRTL = !!(\n\t\t\t\t\ttranslation?.dir === 'rtl' ||\n\t\t\t\t\t// todo: can we check a partial of the text, so that we don't have to render the whole thing?\n\t\t\t\t\tisRightToLeftLanguage(renderPlaintextFromRichText(editor, shape.props.richText))\n\t\t\t\t)\n\n\t\t\t\tconst offsetLength =\n\t\t\t\t\t(NOTE_SIZE +\n\t\t\t\t\t\teditor.options.adjacentShapeMargin +\n\t\t\t\t\t\t// If we're growing down, we need to account for the current shape's growY\n\t\t\t\t\t\t(isCmdEnter && !e.shiftKey ? shape.props.growY : 0)) *\n\t\t\t\t\tshape.props.scale\n\n\t\t\t\tconst adjacentCenter = new Vec(\n\t\t\t\t\tisTab ? (e.shiftKey != isRTL ? -1 : 1) : 0,\n\t\t\t\t\tisCmdEnter ? (e.shiftKey ? -1 : 1) : 0\n\t\t\t\t)\n\t\t\t\t\t.mul(offsetLength)\n\t\t\t\t\t.add(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale))\n\t\t\t\t\t.rot(pageRotation)\n\t\t\t\t\t.add(pageTransform.point())\n\n\t\t\t\tconst newNote = getNoteShapeForAdjacentPosition(editor, shape, adjacentCenter, pageRotation)\n\n\t\t\t\tif (newNote) {\n\t\t\t\t\tstartEditingShapeWithLabel(editor, newNote, true /* selectAll */)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[id, editor, translation?.dir]\n\t)\n}\n\nfunction getNoteHeight(shape: TLNoteShape) {\n\treturn (NOTE_SIZE + shape.props.growY) * shape.props.scale\n}\n\nfunction getNoteShadow(id: string, rotation: number, scale: number) {\n\tconst random = rng(id) // seeded based on id\n\tconst lift = Math.abs(random()) + 0.5 // 0 to 1.5\n\tconst oy = Math.cos(rotation)\n\tconst a = 5 * scale\n\tconst b = 4 * scale\n\tconst c = 6 * scale\n\tconst d = 7 * scale\n\treturn `0px ${a - lift}px ${a}px -${a}px rgba(15, 23, 31, .6),\n\t0px ${(b + lift * d) * Math.max(0, oy)}px ${c + lift * d}px -${b + lift * c}px rgba(15, 23, 31, ${(0.3 + lift * 0.1).toFixed(2)}), \n\t0px ${48 * scale}px ${10 * scale}px -${10 * scale}px inset rgba(15, 23, 44, ${((0.022 + random() * 0.005) * ((1 + oy) / 2)).toFixed(2)})`\n}\n\nfunction getBoundsForSVG(shape: TLNoteShape) {\n\t// When rendering the SVG we don't want to adjust for scale\n\treturn new Box(0, 0, NOTE_SIZE, NOTE_SIZE + shape.props.growY)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6RG;AA5RH,oBA+BO;AACP,mBAAwC;AACxC,2BAA2C;AAC3C,4BAAoC;AACpC,sBAIO;AACP,kBAAsC;AACtC,6BAAgC;AAChC,2BAA2C;AAC3C,qCAKO;AACP,kCAAqC;AACrC,kCAAqC;AACrC,yBAKO;AAYA,MAAM,sBAAsB,wBAAuB;AAAA,EACzD,OAAgB,OAAO;AAAA,EACvB,OAAgB,QAAQ;AAAA,EACxB,OAAgB,aAAa;AAAA,EAEpB,UAA4B;AAAA,IACpC,YAAY;AAAA,EACb;AAAA,EAES,UAAU;AAClB,WAAO;AAAA,EACR;AAAA,EACS,oBAAoB;AAC5B,UAAM,EAAE,WAAW,IAAI,KAAK;AAC5B,YAAQ,YAAY;AAAA,MACnB,KAAK,QAAQ;AACZ,eAAO;AAAA,MACR;AAAA,MACA,KAAK,SAAS;AACb,eAAO;AAAA,MACR;AAAA,MACA,SAAS;AACR,kBAAM,qCAAsB,UAAU;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AAAA,EAES,sBAAsB;AAC9B,WAAO,KAAK,QAAQ,eAAe;AAAA,EACpC;AAAA,EAES,wBAAwB;AAChC,WAAO;AAAA,EACR;AAAA,EAEA,kBAAwC;AACvC,WAAO;AAAA,MACN,OAAO;AAAA,MACP,cAAU,0BAAW,EAAE;AAAA,MACvB,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,MACP,eAAe;AAAA,MACf,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,oBAAoB;AAAA,MACpB,KAAK;AAAA,MACL,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAEA,YAAY,OAAoB;AAC/B,UAAM,EAAE,aAAa,WAAW,IAAI,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IAAI,IAAI;AACd,QAAM,IAAI,IAAI;AACd,SAAO,OAAO,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC;AAAA,QAC9B,IAAI,OAAO,KAAK,KAAK,IAAI,GAAG,EAAE,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,wBAAwB,MAAM,OAAO,KAAK,QAAQ,CAAC,CAAC;AAAA,OACzH,KAAK,KAAK,MAAM,KAAK,KAAK,OAAO,KAAK,KAAK,+BAA+B,QAAQ,OAAO,IAAI,UAAW,IAAI,MAAM,IAAI,QAAQ,CAAC,CAAC;AACvI;AAEA,SAAS,gBAAgB,OAAoB;AAE5C,SAAO,IAAI,kBAAI,GAAG,GAAG,8BAAW,+BAAY,MAAM,MAAM,KAAK;AAC9D;",
4
+ "sourcesContent": ["/* eslint-disable react-hooks/rules-of-hooks */\nimport {\n\tBox,\n\tEMPTY_ARRAY,\n\tEditor,\n\tGroup2d,\n\tIndexKey,\n\tRectangle2d,\n\tShapeUtil,\n\tSvgExportContext,\n\tTLHandle,\n\tTLNoteShape,\n\tTLNoteShapeProps,\n\tTLResizeInfo,\n\tTLShape,\n\tTLShapeId,\n\tVec,\n\tWeakCache,\n\texhaustiveSwitchError,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\tgetFontsFromRichText,\n\tisEqual,\n\tlerp,\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\tresizeScaled,\n\trng,\n\ttoDomPrecision,\n\ttoRichText,\n\tuseEditor,\n\tuseValue,\n} from '@tldraw/editor'\nimport { useCallback, useContext } from 'react'\nimport { startEditingShapeWithRichText } from '../../tools/SelectTool/selectHelpers'\nimport { TranslationsContext } from '../../ui/hooks/useTranslation/useTranslation'\nimport {\n\tisEmptyRichText,\n\trenderHtmlFromRichTextForMeasurement,\n\trenderPlaintextFromRichText,\n} from '../../utils/text/richText'\nimport { isRightToLeftLanguage } from '../../utils/text/text'\nimport { HyperlinkButton } from '../shared/HyperlinkButton'\nimport { RichTextLabel, RichTextSVG } from '../shared/RichTextLabel'\nimport {\n\tFONT_FAMILIES,\n\tLABEL_FONT_SIZES,\n\tLABEL_PADDING,\n\tTEXT_PROPS,\n} from '../shared/default-shape-constants'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\nimport { useIsReadyForEditing } from '../shared/useEditablePlainText'\nimport { useEfficientZoomThreshold } from '../shared/useEfficientZoomThreshold'\nimport {\n\tCLONE_HANDLE_MARGIN,\n\tNOTE_CENTER_OFFSET,\n\tNOTE_SIZE,\n\tgetNoteShapeForAdjacentPosition,\n} from './noteHelpers'\n\n/** @public */\nexport interface NoteShapeOptions {\n\t/**\n\t * How should the note shape resize? By default it does not resize (except automatically based on its text content),\n\t * but you can set it to be user-resizable using scale.\n\t */\n\tresizeMode: 'none' | 'scale'\n}\n\n/** @public */\nexport class NoteShapeUtil extends ShapeUtil<TLNoteShape> {\n\tstatic override type = 'note' as const\n\tstatic override props = noteShapeProps\n\tstatic override migrations = noteShapeMigrations\n\n\toverride options: NoteShapeOptions = {\n\t\tresizeMode: 'none',\n\t}\n\n\toverride canEdit() {\n\t\treturn true\n\t}\n\toverride hideResizeHandles() {\n\t\tconst { resizeMode } = this.options\n\t\tswitch (resizeMode) {\n\t\t\tcase 'none': {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tcase 'scale': {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow exhaustiveSwitchError(resizeMode)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride isAspectRatioLocked() {\n\t\treturn this.options.resizeMode === 'scale'\n\t}\n\n\toverride hideSelectionBoundsFg() {\n\t\treturn false\n\t}\n\n\tgetDefaultProps(): TLNoteShape['props'] {\n\t\treturn {\n\t\t\tcolor: 'black',\n\t\t\trichText: toRichText(''),\n\t\t\tsize: 'm',\n\t\t\tfont: 'draw',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t\tlabelColor: 'black',\n\t\t\tgrowY: 0,\n\t\t\tfontSizeAdjustment: 0,\n\t\t\turl: '',\n\t\t\tscale: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLNoteShape) {\n\t\tconst { labelHeight, labelWidth } = getLabelSize(this.editor, shape)\n\t\tconst { scale } = shape.props\n\n\t\tconst lh = labelHeight * scale\n\t\tconst lw = labelWidth * scale\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst nh = getNoteHeight(shape)\n\n\t\treturn new Group2d({\n\t\t\tchildren: [\n\t\t\t\tnew Rectangle2d({ width: nw, height: nh, isFilled: true }),\n\t\t\t\tnew Rectangle2d({\n\t\t\t\t\tx:\n\t\t\t\t\t\tshape.props.align === 'start'\n\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t: shape.props.align === 'end'\n\t\t\t\t\t\t\t\t? nw - lw\n\t\t\t\t\t\t\t\t: (nw - lw) / 2,\n\t\t\t\t\ty:\n\t\t\t\t\t\tshape.props.verticalAlign === 'start'\n\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t: shape.props.verticalAlign === 'end'\n\t\t\t\t\t\t\t\t? nh - lh\n\t\t\t\t\t\t\t\t: (nh - lh) / 2,\n\t\t\t\t\twidth: lw,\n\t\t\t\t\theight: lh,\n\t\t\t\t\tisFilled: true,\n\t\t\t\t\tisLabel: true,\n\t\t\t\t\texcludeFromShapeBounds: true,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\toverride getHandles(shape: TLNoteShape): TLHandle[] {\n\t\tconst { scale } = shape.props\n\t\tconst isCoarsePointer = this.editor.getInstanceState().isCoarsePointer\n\t\tif (isCoarsePointer) return []\n\n\t\tconst zoom = this.editor.getEfficientZoomLevel()\n\t\tif (zoom * scale < 0.25) return []\n\n\t\tconst nh = getNoteHeight(shape)\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst offset = (CLONE_HANDLE_MARGIN / zoom) * scale\n\n\t\tif (zoom * scale < 0.5) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: 'bottom',\n\t\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\t\ttype: 'clone',\n\t\t\t\t\tx: nw / 2,\n\t\t\t\t\ty: nh + offset,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'top',\n\t\t\t\tindex: 'a1' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw / 2,\n\t\t\t\ty: -offset,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'right',\n\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw + offset,\n\t\t\t\ty: nh / 2,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'bottom',\n\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: nw / 2,\n\t\t\t\ty: nh + offset,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'left',\n\t\t\t\tindex: 'a4' as IndexKey,\n\t\t\t\ttype: 'clone',\n\t\t\t\tx: -offset,\n\t\t\t\ty: nh / 2,\n\t\t\t},\n\t\t]\n\t}\n\n\toverride onResize(shape: any, info: TLResizeInfo<any>) {\n\t\tconst { resizeMode } = this.options\n\t\tswitch (resizeMode) {\n\t\t\tcase 'none': {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tcase 'scale': {\n\t\t\t\treturn resizeScaled(shape, info)\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow exhaustiveSwitchError(resizeMode)\n\t\t\t}\n\t\t}\n\t}\n\n\toverride getText(shape: TLNoteShape) {\n\t\treturn renderPlaintextFromRichText(this.editor, shape.props.richText)\n\t}\n\n\toverride getFontFaces(shape: TLNoteShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) {\n\t\t\treturn EMPTY_ARRAY\n\t\t}\n\t\treturn getFontsFromRichText(this.editor, shape.props.richText, {\n\t\t\tfamily: `tldraw_${shape.props.font}`,\n\t\t\tweight: 'normal',\n\t\t\tstyle: 'normal',\n\t\t})\n\t}\n\n\tcomponent(shape: TLNoteShape) {\n\t\tconst {\n\t\t\tid,\n\t\t\ttype,\n\t\t\tprops: {\n\t\t\t\tlabelColor,\n\t\t\t\tscale,\n\t\t\t\tcolor,\n\t\t\t\tfont,\n\t\t\t\tsize,\n\t\t\t\talign,\n\t\t\t\trichText,\n\t\t\t\tverticalAlign,\n\t\t\t\tfontSizeAdjustment,\n\t\t\t},\n\t\t} = shape\n\n\t\tconst handleKeyDown = useNoteKeydownHandler(id)\n\n\t\tconst theme = useDefaultColorTheme()\n\t\tconst nw = NOTE_SIZE * scale\n\t\tconst nh = getNoteHeight(shape)\n\n\t\tconst rotation = useValue(\n\t\t\t'shape rotation',\n\t\t\t() => this.editor.getShapePageTransform(id)?.rotation() ?? 0,\n\t\t\t[this.editor]\n\t\t)\n\n\t\tconst isDarkMode = useValue('dark mode', () => this.editor.user.getIsDarkMode(), [this.editor])\n\n\t\t// Shadows are hidden when zoomed out far enough or in dark mode\n\t\tlet hideShadows = useEfficientZoomThreshold(scale * 0.25)\n\t\tif (isDarkMode) hideShadows = true\n\n\t\tconst isSelected = shape.id === this.editor.getOnlySelectedShapeId()\n\n\t\tconst isReadyForEditing = useIsReadyForEditing(this.editor, shape.id)\n\t\tconst isEmpty = isEmptyRichText(richText)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div\n\t\t\t\t\tid={id}\n\t\t\t\t\tclassName=\"tl-note__container\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\twidth: nw,\n\t\t\t\t\t\theight: nh,\n\t\t\t\t\t\tbackgroundColor: getColorValue(theme, color, 'noteFill'),\n\t\t\t\t\t\tborderBottom: hideShadows\n\t\t\t\t\t\t\t? isDarkMode\n\t\t\t\t\t\t\t\t? `${2 * scale}px solid rgb(20, 20, 20)`\n\t\t\t\t\t\t\t\t: `${2 * scale}px solid rgb(144, 144, 144)`\n\t\t\t\t\t\t\t: 'none',\n\t\t\t\t\t\tboxShadow: hideShadows ? 'none' : getNoteShadow(shape.id, rotation, scale),\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{(isSelected || isReadyForEditing || !isEmpty) && (\n\t\t\t\t\t\t<RichTextLabel\n\t\t\t\t\t\t\tshapeId={id}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t\tfont={font}\n\t\t\t\t\t\t\tfontSize={(fontSizeAdjustment || LABEL_FONT_SIZES[size]) * scale}\n\t\t\t\t\t\t\tlineHeight={TEXT_PROPS.lineHeight}\n\t\t\t\t\t\t\talign={align}\n\t\t\t\t\t\t\tverticalAlign={verticalAlign}\n\t\t\t\t\t\t\trichText={richText}\n\t\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t\t\tlabelColor={\n\t\t\t\t\t\t\t\tlabelColor === 'black'\n\t\t\t\t\t\t\t\t\t? getColorValue(theme, color, 'noteText')\n\t\t\t\t\t\t\t\t\t: getColorValue(theme, labelColor, 'fill')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twrap\n\t\t\t\t\t\t\tpadding={LABEL_PADDING * scale}\n\t\t\t\t\t\t\thasCustomTabBehavior\n\t\t\t\t\t\t\tshowTextOutline={false}\n\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{'url' in shape.props && shape.props.url && <HyperlinkButton url={shape.props.url} />}\n\t\t\t</>\n\t\t)\n\t}\n\n\tindicator(shape: TLNoteShape) {\n\t\tconst { scale } = shape.props\n\t\treturn (\n\t\t\t<rect\n\t\t\t\trx={scale}\n\t\t\t\twidth={toDomPrecision(NOTE_SIZE * scale)}\n\t\t\t\theight={toDomPrecision(getNoteHeight(shape))}\n\t\t\t/>\n\t\t)\n\t}\n\n\toverride toSvg(shape: TLNoteShape, ctx: SvgExportContext) {\n\t\tconst theme = getDefaultColorTheme({ isDarkMode: ctx.isDarkMode })\n\t\tconst bounds = getBoundsForSVG(shape)\n\n\t\tconst textLabel = (\n\t\t\t<RichTextSVG\n\t\t\t\tfontSize={shape.props.fontSizeAdjustment || LABEL_FONT_SIZES[shape.props.size]}\n\t\t\t\tfont={shape.props.font}\n\t\t\t\talign={shape.props.align}\n\t\t\t\tverticalAlign={shape.props.verticalAlign}\n\t\t\t\trichText={shape.props.richText}\n\t\t\t\tlabelColor={getColorValue(theme, shape.props.color, 'noteText')}\n\t\t\t\tbounds={bounds}\n\t\t\t\tpadding={LABEL_PADDING}\n\t\t\t\tshowTextOutline={false}\n\t\t\t/>\n\t\t)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<rect x={5} y={5} rx={1} width={NOTE_SIZE - 10} height={bounds.h} fill=\"rgba(0,0,0,.1)\" />\n\t\t\t\t<rect\n\t\t\t\t\trx={1}\n\t\t\t\t\twidth={NOTE_SIZE}\n\t\t\t\t\theight={bounds.h}\n\t\t\t\t\tfill={getColorValue(theme, shape.props.color, 'noteFill')}\n\t\t\t\t/>\n\t\t\t\t{textLabel}\n\t\t\t</>\n\t\t)\n\t}\n\n\toverride onBeforeCreate(next: TLNoteShape) {\n\t\treturn getNoteSizeAdjustments(this.editor, next)\n\t}\n\n\toverride onBeforeUpdate(prev: TLNoteShape, next: TLNoteShape) {\n\t\tif (\n\t\t\tisEqual(prev.props.richText, next.props.richText) &&\n\t\t\tprev.props.font === next.props.font &&\n\t\t\tprev.props.size === next.props.size\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\treturn getNoteSizeAdjustments(this.editor, next)\n\t}\n\n\toverride getInterpolatedProps(\n\t\tstartShape: TLNoteShape,\n\t\tendShape: TLNoteShape,\n\t\tt: number\n\t): TLNoteShapeProps {\n\t\treturn {\n\t\t\t...(t > 0.5 ? endShape.props : startShape.props),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, t),\n\t\t}\n\t}\n}\n\n/**\n * Get the growY and fontSizeAdjustment for a shape.\n */\nfunction getNoteSizeAdjustments(editor: Editor, shape: TLNoteShape) {\n\tconst { labelHeight, fontSizeAdjustment } = getLabelSize(editor, shape)\n\t// When the label height is more than the height of the shape, we add extra height to it\n\tconst growY = Math.max(0, labelHeight - NOTE_SIZE)\n\n\tif (growY !== shape.props.growY || fontSizeAdjustment !== shape.props.fontSizeAdjustment) {\n\t\treturn {\n\t\t\t...shape,\n\t\t\tprops: {\n\t\t\t\t...shape.props,\n\t\t\t\tgrowY,\n\t\t\t\tfontSizeAdjustment,\n\t\t\t},\n\t\t}\n\t}\n}\n\n/**\n * Get the label size for a note.\n */\nfunction getNoteLabelSize(editor: Editor, shape: TLNoteShape) {\n\tconst { richText } = shape.props\n\n\tif (isEmptyRichText(richText)) {\n\t\tconst minHeight = LABEL_FONT_SIZES[shape.props.size] * TEXT_PROPS.lineHeight + LABEL_PADDING * 2\n\t\treturn { labelHeight: minHeight, labelWidth: 100, fontSizeAdjustment: 0 }\n\t}\n\n\tconst unadjustedFontSize = LABEL_FONT_SIZES[shape.props.size]\n\n\tlet fontSizeAdjustment = 0\n\tlet iterations = 0\n\tlet labelHeight = NOTE_SIZE\n\tlet labelWidth = NOTE_SIZE\n\n\t// N.B. For some note shapes with text like 'hjhjhjhjhjhjhjhj', you'll run into\n\t// some text measurement fuzziness where the browser swears there's no overflow (scrollWidth === width)\n\t// but really there is when you enable overflow-wrap again. This helps account for that little bit\n\t// of give.\n\tconst FUZZ = 1\n\n\t// We slightly make the font smaller if the text is too big for the note, width-wise.\n\tdo {\n\t\tfontSizeAdjustment = Math.min(unadjustedFontSize, unadjustedFontSize - iterations)\n\t\tconst html = renderHtmlFromRichTextForMeasurement(editor, richText)\n\t\tconst nextTextSize = editor.textMeasure.measureHtml(html, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\tfontSize: fontSizeAdjustment,\n\t\t\tmaxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ,\n\t\t\tdisableOverflowWrapBreaking: true,\n\t\t\tmeasureScrollWidth: true,\n\t\t})\n\n\t\tlabelHeight = nextTextSize.h + LABEL_PADDING * 2\n\t\tlabelWidth = nextTextSize.w + LABEL_PADDING * 2\n\n\t\tif (fontSizeAdjustment <= 14) {\n\t\t\t// Too small, just rely now on CSS `overflow-wrap: break-word`\n\t\t\t// We need to recalculate the text measurement here with break-word enabled.\n\t\t\tconst html = renderHtmlFromRichTextForMeasurement(editor, richText)\n\t\t\tconst nextTextSizeWithOverflowBreak = editor.textMeasure.measureHtml(html, {\n\t\t\t\t...TEXT_PROPS,\n\t\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\t\tfontSize: fontSizeAdjustment,\n\t\t\t\tmaxWidth: NOTE_SIZE - LABEL_PADDING * 2 - FUZZ,\n\t\t\t})\n\t\t\tlabelHeight = nextTextSizeWithOverflowBreak.h + LABEL_PADDING * 2\n\t\t\tlabelWidth = nextTextSizeWithOverflowBreak.w + LABEL_PADDING * 2\n\t\t\tbreak\n\t\t}\n\n\t\tif (nextTextSize.scrollWidth.toFixed(0) === nextTextSize.w.toFixed(0)) {\n\t\t\tbreak\n\t\t}\n\t} while (iterations++ < 50)\n\n\treturn {\n\t\tlabelHeight: labelHeight,\n\t\tlabelWidth: labelWidth,\n\t\tfontSizeAdjustment: fontSizeAdjustment,\n\t}\n}\n\nconst labelSizesForNote = new WeakCache<TLShape, ReturnType<typeof getNoteLabelSize>>()\n\nfunction getLabelSize(editor: Editor, shape: TLNoteShape) {\n\treturn labelSizesForNote.get(shape, () => getNoteLabelSize(editor, shape))\n}\n\nfunction useNoteKeydownHandler(id: TLShapeId) {\n\tconst editor = useEditor()\n\t// Try to get the translation context, but fallback to ltr if it doesn't exist\n\tconst translation = useContext(TranslationsContext)\n\n\treturn useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst shape = editor.getShape<TLNoteShape>(id)\n\t\t\tif (!shape) return\n\n\t\t\tconst isTab = e.key === 'Tab'\n\t\t\tconst isCmdEnter = (e.metaKey || e.ctrlKey) && e.key === 'Enter'\n\t\t\tif (isTab || isCmdEnter) {\n\t\t\t\te.preventDefault()\n\n\t\t\t\tconst pageTransform = editor.getShapePageTransform(id)\n\t\t\t\tconst pageRotation = pageTransform.rotation()\n\n\t\t\t\t// Based on the inputs, calculate the offset to the next note\n\t\t\t\t// tab controls x axis (shift inverts direction set by RTL)\n\t\t\t\t// cmd enter is the y axis (shift inverts direction)\n\t\t\t\tconst isRTL = !!(\n\t\t\t\t\ttranslation?.dir === 'rtl' ||\n\t\t\t\t\t// todo: can we check a partial of the text, so that we don't have to render the whole thing?\n\t\t\t\t\tisRightToLeftLanguage(renderPlaintextFromRichText(editor, shape.props.richText))\n\t\t\t\t)\n\n\t\t\t\tconst offsetLength =\n\t\t\t\t\t(NOTE_SIZE +\n\t\t\t\t\t\teditor.options.adjacentShapeMargin +\n\t\t\t\t\t\t// If we're growing down, we need to account for the current shape's growY\n\t\t\t\t\t\t(isCmdEnter && !e.shiftKey ? shape.props.growY : 0)) *\n\t\t\t\t\tshape.props.scale\n\n\t\t\t\tconst adjacentCenter = new Vec(\n\t\t\t\t\tisTab ? (e.shiftKey != isRTL ? -1 : 1) : 0,\n\t\t\t\t\tisCmdEnter ? (e.shiftKey ? -1 : 1) : 0\n\t\t\t\t)\n\t\t\t\t\t.mul(offsetLength)\n\t\t\t\t\t.add(NOTE_CENTER_OFFSET.clone().mul(shape.props.scale))\n\t\t\t\t\t.rot(pageRotation)\n\t\t\t\t\t.add(pageTransform.point())\n\n\t\t\t\tconst newNote = getNoteShapeForAdjacentPosition(editor, shape, adjacentCenter, pageRotation)\n\n\t\t\t\tif (newNote) {\n\t\t\t\t\tstartEditingShapeWithRichText(editor, newNote, { selectAll: true })\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[id, editor, translation?.dir]\n\t)\n}\n\nfunction getNoteHeight(shape: TLNoteShape) {\n\treturn (NOTE_SIZE + shape.props.growY) * shape.props.scale\n}\n\nfunction getNoteShadow(id: string, rotation: number, scale: number) {\n\tconst random = rng(id) // seeded based on id\n\tconst lift = Math.abs(random()) + 0.5 // 0 to 1.5\n\tconst oy = Math.cos(rotation)\n\tconst a = 5 * scale\n\tconst b = 4 * scale\n\tconst c = 6 * scale\n\tconst d = 7 * scale\n\treturn `0px ${a - lift}px ${a}px -${a}px rgba(15, 23, 31, .6),\n\t0px ${(b + lift * d) * Math.max(0, oy)}px ${c + lift * d}px -${b + lift * c}px rgba(15, 23, 31, ${(0.3 + lift * 0.1).toFixed(2)}), \n\t0px ${48 * scale}px ${10 * scale}px -${10 * scale}px inset rgba(15, 23, 44, ${((0.022 + random() * 0.005) * ((1 + oy) / 2)).toFixed(2)})`\n}\n\nfunction getBoundsForSVG(shape: TLNoteShape) {\n\t// When rendering the SVG we don't want to adjust for scale\n\treturn new Box(0, 0, NOTE_SIZE, NOTE_SIZE + shape.props.growY)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2RG;AA1RH,oBA+BO;AACP,mBAAwC;AACxC,2BAA8C;AAC9C,4BAAoC;AACpC,sBAIO;AACP,kBAAsC;AACtC,6BAAgC;AAChC,2BAA2C;AAC3C,qCAKO;AACP,kCAAqC;AACrC,kCAAqC;AACrC,uCAA0C;AAC1C,yBAKO;AAYA,MAAM,sBAAsB,wBAAuB;AAAA,EACzD,OAAgB,OAAO;AAAA,EACvB,OAAgB,QAAQ;AAAA,EACxB,OAAgB,aAAa;AAAA,EAEpB,UAA4B;AAAA,IACpC,YAAY;AAAA,EACb;AAAA,EAES,UAAU;AAClB,WAAO;AAAA,EACR;AAAA,EACS,oBAAoB;AAC5B,UAAM,EAAE,WAAW,IAAI,KAAK;AAC5B,YAAQ,YAAY;AAAA,MACnB,KAAK,QAAQ;AACZ,eAAO;AAAA,MACR;AAAA,MACA,KAAK,SAAS;AACb,eAAO;AAAA,MACR;AAAA,MACA,SAAS;AACR,kBAAM,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AA8B,QAAQ,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,QACnE;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC,IAAI,QAAQ,aAAa,GAAG;AAAA,EAC9B;AACD;AAEA,SAAS,cAAc,OAAoB;AAC1C,UAAQ,+BAAY,MAAM,MAAM,SAAS,MAAM,MAAM;AACtD;AAEA,SAAS,cAAc,IAAY,UAAkB,OAAe;AACnE,QAAM,aAAS,mBAAI,EAAE;AACrB,QAAM,OAAO,KAAK,IAAI,OAAO,CAAC,IAAI;AAClC,QAAM,KAAK,KAAK,IAAI,QAAQ;AAC5B,QAAM,IAAI,IAAI;AACd,QAAM,IAAI,IAAI;AACd,QAAM,IAAI,IAAI;AACd,QAAM,IAAI,IAAI;AACd,SAAO,OAAO,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC;AAAA,QAC9B,IAAI,OAAO,KAAK,KAAK,IAAI,GAAG,EAAE,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,wBAAwB,MAAM,OAAO,KAAK,QAAQ,CAAC,CAAC;AAAA,OACzH,KAAK,KAAK,MAAM,KAAK,KAAK,OAAO,KAAK,KAAK,+BAA+B,QAAQ,OAAO,IAAI,UAAW,IAAI,MAAM,IAAI,QAAQ,CAAC,CAAC;AACvI;AAEA,SAAS,gBAAgB,OAAoB;AAE5C,SAAO,IAAI,kBAAI,GAAG,GAAG,8BAAW,+BAAY,MAAM,MAAM,KAAK;AAC9D;",
6
6
  "names": ["html"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/shapes/note/noteHelpers.ts"],
4
- "sourcesContent": ["import {\n\tEditor,\n\tIndexKey,\n\tTLNoteShape,\n\tTLShape,\n\tVec,\n\tcompact,\n\tcreateShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/** @internal */\nexport const CLONE_HANDLE_MARGIN = 0\n/** @internal */\nexport const NOTE_SIZE = 200\n/** @internal */\nexport const NOTE_CENTER_OFFSET = new Vec(NOTE_SIZE / 2, NOTE_SIZE / 2)\n/** @internal */\nexport const NOTE_ADJACENT_POSITION_SNAP_RADIUS = 10\n\nconst BASE_NOTE_POSITIONS = (editor: Editor) =>\n\t[\n\t\t[\n\t\t\t['a1' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 0.5, NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin),\n\t\t], // t\n\t\t[\n\t\t\t['a2' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5),\n\t\t], // r\n\t\t[\n\t\t\t['a3' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 0.5, NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin),\n\t\t], // b\n\t\t[\n\t\t\t['a4' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5),\n\t\t], // l\n\t] as const\n\nfunction getBaseAdjacentNotePositions(editor: Editor, scale: number) {\n\tif (scale === 1) return BASE_NOTE_POSITIONS(editor)\n\tconst s = NOTE_SIZE * scale\n\tconst m = editor.options.adjacentShapeMargin * scale\n\treturn [\n\t\t[['a1' as IndexKey], new Vec(s * 0.5, s * -0.5 - m)], // t\n\t\t[['a2' as IndexKey], new Vec(s * 1.5 + m, s * 0.5)], // r\n\t\t[['a3' as IndexKey], new Vec(s * 0.5, s * 1.5 + m)], // b\n\t\t[['a4' as IndexKey], new Vec(s * -0.5 - m, s * 0.5)], // l\n\t] as const\n}\n\n/**\n * Get the adjacent positions for a particular note shape.\n *\n * @param pagePoint - The point of the note shape on the page.\n * @param pageRotation - The rotation of the note shape on the page.\n * @param growY - The growY of the note shape.\n * @param extraHeight - The extra height to add to the top position above the note shape (ie the growY of the dragging shape).\n *\n * @internal */\nexport function getNoteAdjacentPositions(\n\teditor: Editor,\n\tpagePoint: Vec,\n\tpageRotation: number,\n\tgrowY: number,\n\textraHeight: number,\n\tscale: number\n): Record<IndexKey, Vec> {\n\treturn Object.fromEntries(\n\t\tgetBaseAdjacentNotePositions(editor, scale).map(([id, v], i) => {\n\t\t\tconst point = v.clone()\n\t\t\tif (i === 0 && extraHeight) {\n\t\t\t\t// apply top margin (the growY of the moving note shape)\n\t\t\t\tpoint.y -= extraHeight\n\t\t\t} else if (i === 2 && growY) {\n\t\t\t\t// apply bottom margin (the growY of this note shape)\n\t\t\t\tpoint.y += growY\n\t\t\t}\n\t\t\treturn [id, point.rot(pageRotation).add(pagePoint)]\n\t\t})\n\t)\n}\n\n/**\n * Get all of the available note adjacent positions, excluding the selected shapes.\n *\n * @param editor - The editor instance.\n * @param rotation - The rotation of the note shape.\n * @param extraHeight - The extra height to add to the top position above the note shape (ie the growY of the dragging shape).\n *\n * @internal */\nexport function getAvailableNoteAdjacentPositions(\n\teditor: Editor,\n\trotation: number,\n\tscale: number,\n\textraHeight: number\n) {\n\tconst selectedShapeIds = new Set(editor.getSelectedShapeIds())\n\tconst minSize = (NOTE_SIZE + editor.options.adjacentShapeMargin + extraHeight) ** 2\n\tconst allCenters = new Map<TLNoteShape, Vec>()\n\tconst positions: (Vec | undefined)[] = []\n\n\t// Get all the positions that are adjacent to the selected note shapes\n\tfor (const shape of editor.getCurrentPageShapes()) {\n\t\tif (\n\t\t\t!editor.isShapeOfType<TLNoteShape>(shape, 'note') ||\n\t\t\tscale !== shape.props.scale ||\n\t\t\tselectedShapeIds.has(shape.id)\n\t\t) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst transform = editor.getShapePageTransform(shape.id)!\n\n\t\t// If the note has a different rotation, we can't use its adjacent positions\n\t\tif (rotation !== transform.rotation()) continue\n\n\t\t// Save the unselected note shape's center\n\t\tallCenters.set(shape, editor.getShapePageBounds(shape)!.center)\n\n\t\t// And push its position to the positions array\n\t\tpositions.push(\n\t\t\t...Object.values(\n\t\t\t\tgetNoteAdjacentPositions(\n\t\t\t\t\teditor,\n\t\t\t\t\ttransform.point(),\n\t\t\t\t\trotation,\n\t\t\t\t\tshape.props.growY,\n\t\t\t\t\textraHeight,\n\t\t\t\t\tscale\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t}\n\n\t// Remove positions that are inside of another note shape\n\tconst len = positions.length\n\tlet position: Vec | undefined\n\tfor (const [shape, center] of allCenters) {\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tposition = positions[i]\n\t\t\tif (!position) continue\n\t\t\tif (Vec.Dist2(center, position) > minSize) continue\n\t\t\tif (editor.isPointInShape(shape, position)) {\n\t\t\t\tpositions[i] = undefined\n\t\t\t}\n\t\t}\n\t}\n\n\treturn compact(positions)\n}\n\n/**\n * For a particular adjacent note position, get the shape in that position or create a new one.\n *\n * @param editor - The editor instance.\n * @param shape - The note shape to create or select.\n * @param center - The center of the note shape.\n * @param pageRotation - The rotation of the note shape on the page.\n * @param forceNew - Whether to force the creation of a new note shape.\n *\n * @internal */\nexport function getNoteShapeForAdjacentPosition(\n\teditor: Editor,\n\tshape: TLNoteShape,\n\tcenter: Vec,\n\tpageRotation: number,\n\tforceNew = false\n) {\n\t// There might already be a note in that position! If there is, we'll\n\t// select the next note and switch focus to it. If there's not, then\n\t// we'll create a new note in that position.\n\n\tlet nextNote: TLShape | undefined\n\n\t// Check the center of where a new note would be\n\t// Start from the top of the stack, and work our way down\n\tconst allShapesOnPage = editor.getCurrentPageShapesSorted()\n\n\tconst minDistance = (NOTE_SIZE + editor.options.adjacentShapeMargin ** 2) ** shape.props.scale\n\n\tfor (let i = allShapesOnPage.length - 1; i >= 0; i--) {\n\t\tconst otherNote = allShapesOnPage[i]\n\t\tif (otherNote.type === 'note' && otherNote.id !== shape.id) {\n\t\t\tconst otherBounds = editor.getShapePageBounds(otherNote)\n\t\t\tif (\n\t\t\t\totherBounds &&\n\t\t\t\tVec.Dist2(otherBounds.center, center) < minDistance &&\n\t\t\t\teditor.isPointInShape(otherNote, center)\n\t\t\t) {\n\t\t\t\tnextNote = otherNote\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.complete()\n\n\t// If we didn't find any in that position, then create a new one\n\tif (!nextNote || forceNew) {\n\t\teditor.markHistoryStoppingPoint('creating note shape')\n\t\tconst id = createShapeId()\n\n\t\t// We create it at the center first, so that it becomes\n\t\t// the child of whatever parent was at that center\n\t\teditor.createShape<TLNoteShape>({\n\t\t\tid,\n\t\t\ttype: 'note',\n\t\t\tx: center.x,\n\t\t\ty: center.y,\n\t\t\trotation: pageRotation,\n\t\t\topacity: shape.opacity,\n\t\t\tprops: {\n\t\t\t\t// Use the props of the shape we're cloning\n\t\t\t\t...shape.props,\n\t\t\t\trichText: toRichText(''),\n\t\t\t\tgrowY: 0,\n\t\t\t\tfontSizeAdjustment: 0,\n\t\t\t\turl: '',\n\t\t\t},\n\t\t})\n\n\t\t// Now we need to correct its location within its new parent\n\n\t\tconst createdShape = editor.getShape<TLNoteShape>(id)!\n\t\tif (!createdShape) return // may have hit max shapes\n\n\t\t// We need to put the page point in the same coordinate space as the newly created shape (i.e its parent's space)\n\t\tconst topLeft = editor.getPointInParentSpace(\n\t\t\tcreatedShape,\n\t\t\tVec.Sub(\n\t\t\t\tcenter,\n\t\t\t\tVec.Rot(NOTE_CENTER_OFFSET.clone().mul(createdShape.props.scale), pageRotation)\n\t\t\t)\n\t\t)\n\n\t\teditor.updateShape({\n\t\t\tid,\n\t\t\ttype: 'note',\n\t\t\tx: topLeft.x,\n\t\t\ty: topLeft.y,\n\t\t})\n\n\t\tnextNote = editor.getShape(id)!\n\t}\n\n\teditor.zoomToSelectionIfOffscreen(16, {\n\t\tanimation: {\n\t\t\tduration: editor.options.animationMediumMs,\n\t\t},\n\t\tinset: 0,\n\t})\n\treturn nextNote\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBASO;AAGA,MAAM,sBAA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AAK,GAAG,YAAY;AAAA,MAC/E;AAAA,IACD;AAEA,WAAO,YAAY;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,MACN,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ;AAAA,IACZ,CAAC;AAED,eAAW,OAAO,SAAS,EAAE;AAAA,EAC9B;AAEA,SAAO,2BAA2B,IAAI;AAAA,IACrC,WAAW;AAAA,MACV,UAAU,OAAO,QAAQ;AAAA,IAC1B;AAAA,IACA,OAAO;AAAA,EACR,CAAC;AACD,SAAO;AACR;",
4
+ "sourcesContent": ["import {\n\tEditor,\n\tIndexKey,\n\tTLNoteShape,\n\tTLShape,\n\tVec,\n\tcompact,\n\tcreateShapeId,\n\ttoRichText,\n} from '@tldraw/editor'\n\n/** @internal */\nexport const CLONE_HANDLE_MARGIN = 0\n/** @internal */\nexport const NOTE_SIZE = 200\n/** @internal */\nexport const NOTE_CENTER_OFFSET = new Vec(NOTE_SIZE / 2, NOTE_SIZE / 2)\n/** @internal */\nexport const NOTE_ADJACENT_POSITION_SNAP_RADIUS = 10\n\nconst BASE_NOTE_POSITIONS = (editor: Editor) =>\n\t[\n\t\t[\n\t\t\t['a1' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 0.5, NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin),\n\t\t], // t\n\t\t[\n\t\t\t['a2' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5),\n\t\t], // r\n\t\t[\n\t\t\t['a3' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * 0.5, NOTE_SIZE * 1.5 + editor.options.adjacentShapeMargin),\n\t\t], // b\n\t\t[\n\t\t\t['a4' as IndexKey],\n\t\t\tnew Vec(NOTE_SIZE * -0.5 - editor.options.adjacentShapeMargin, NOTE_SIZE * 0.5),\n\t\t], // l\n\t] as const\n\nfunction getBaseAdjacentNotePositions(editor: Editor, scale: number) {\n\tif (scale === 1) return BASE_NOTE_POSITIONS(editor)\n\tconst s = NOTE_SIZE * scale\n\tconst m = editor.options.adjacentShapeMargin * scale\n\treturn [\n\t\t[['a1' as IndexKey], new Vec(s * 0.5, s * -0.5 - m)], // t\n\t\t[['a2' as IndexKey], new Vec(s * 1.5 + m, s * 0.5)], // r\n\t\t[['a3' as IndexKey], new Vec(s * 0.5, s * 1.5 + m)], // b\n\t\t[['a4' as IndexKey], new Vec(s * -0.5 - m, s * 0.5)], // l\n\t] as const\n}\n\n/**\n * Get the adjacent positions for a particular note shape.\n *\n * @param pagePoint - The point of the note shape on the page.\n * @param pageRotation - The rotation of the note shape on the page.\n * @param growY - The growY of the note shape.\n * @param extraHeight - The extra height to add to the top position above the note shape (ie the growY of the dragging shape).\n *\n * @internal */\nexport function getNoteAdjacentPositions(\n\teditor: Editor,\n\tpagePoint: Vec,\n\tpageRotation: number,\n\tgrowY: number,\n\textraHeight: number,\n\tscale: number\n): Record<IndexKey, Vec> {\n\treturn Object.fromEntries(\n\t\tgetBaseAdjacentNotePositions(editor, scale).map(([id, v], i) => {\n\t\t\tconst point = v.clone()\n\t\t\tif (i === 0 && extraHeight) {\n\t\t\t\t// apply top margin (the growY of the moving note shape)\n\t\t\t\tpoint.y -= extraHeight\n\t\t\t} else if (i === 2 && growY) {\n\t\t\t\t// apply bottom margin (the growY of this note shape)\n\t\t\t\tpoint.y += growY\n\t\t\t}\n\t\t\treturn [id, point.rot(pageRotation).add(pagePoint)]\n\t\t})\n\t)\n}\n\n/**\n * Get all of the available note adjacent positions, excluding the selected shapes.\n *\n * @param editor - The editor instance.\n * @param rotation - The rotation of the note shape.\n * @param extraHeight - The extra height to add to the top position above the note shape (ie the growY of the dragging shape).\n *\n * @internal */\nexport function getAvailableNoteAdjacentPositions(\n\teditor: Editor,\n\trotation: number,\n\tscale: number,\n\textraHeight: number\n) {\n\tconst selectedShapeIds = new Set(editor.getSelectedShapeIds())\n\tconst minSize = (NOTE_SIZE + editor.options.adjacentShapeMargin + extraHeight) ** 2\n\tconst allCenters = new Map<TLNoteShape, Vec>()\n\tconst positions: (Vec | undefined)[] = []\n\n\t// Get all the positions that are adjacent to the selected note shapes\n\tfor (const shape of editor.getCurrentPageShapes()) {\n\t\tif (\n\t\t\t!editor.isShapeOfType(shape, 'note') ||\n\t\t\tscale !== shape.props.scale ||\n\t\t\tselectedShapeIds.has(shape.id)\n\t\t) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst transform = editor.getShapePageTransform(shape.id)!\n\n\t\t// If the note has a different rotation, we can't use its adjacent positions\n\t\tif (rotation !== transform.rotation()) continue\n\n\t\t// Save the unselected note shape's center\n\t\tallCenters.set(shape, editor.getShapePageBounds(shape)!.center)\n\n\t\t// And push its position to the positions array\n\t\tpositions.push(\n\t\t\t...Object.values(\n\t\t\t\tgetNoteAdjacentPositions(\n\t\t\t\t\teditor,\n\t\t\t\t\ttransform.point(),\n\t\t\t\t\trotation,\n\t\t\t\t\tshape.props.growY,\n\t\t\t\t\textraHeight,\n\t\t\t\t\tscale\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t}\n\n\t// Remove positions that are inside of another note shape\n\tconst len = positions.length\n\tlet position: Vec | undefined\n\tfor (const [shape, center] of allCenters) {\n\t\tfor (let i = 0; i < len; i++) {\n\t\t\tposition = positions[i]\n\t\t\tif (!position) continue\n\t\t\tif (Vec.Dist2(center, position) > minSize) continue\n\t\t\tif (editor.isPointInShape(shape, position)) {\n\t\t\t\tpositions[i] = undefined\n\t\t\t}\n\t\t}\n\t}\n\n\treturn compact(positions)\n}\n\n/**\n * For a particular adjacent note position, get the shape in that position or create a new one.\n *\n * @param editor - The editor instance.\n * @param shape - The note shape to create or select.\n * @param center - The center of the note shape.\n * @param pageRotation - The rotation of the note shape on the page.\n * @param forceNew - Whether to force the creation of a new note shape.\n *\n * @internal */\nexport function getNoteShapeForAdjacentPosition(\n\teditor: Editor,\n\tshape: TLNoteShape,\n\tcenter: Vec,\n\tpageRotation: number,\n\tforceNew = false\n) {\n\t// There might already be a note in that position! If there is, we'll\n\t// select the next note and switch focus to it. If there's not, then\n\t// we'll create a new note in that position.\n\n\tlet nextNote: TLShape | undefined\n\n\t// Check the center of where a new note would be\n\t// Start from the top of the stack, and work our way down\n\tconst allShapesOnPage = editor.getCurrentPageShapesSorted()\n\n\tconst minDistance = (NOTE_SIZE + editor.options.adjacentShapeMargin ** 2) ** shape.props.scale\n\n\tfor (let i = allShapesOnPage.length - 1; i >= 0; i--) {\n\t\tconst otherNote = allShapesOnPage[i]\n\t\tif (otherNote.type === 'note' && otherNote.id !== shape.id) {\n\t\t\tconst otherBounds = editor.getShapePageBounds(otherNote)\n\t\t\tif (\n\t\t\t\totherBounds &&\n\t\t\t\tVec.Dist2(otherBounds.center, center) < minDistance &&\n\t\t\t\teditor.isPointInShape(otherNote, center)\n\t\t\t) {\n\t\t\t\tnextNote = otherNote\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.complete()\n\n\t// If we didn't find any in that position, then create a new one\n\tif (!nextNote || forceNew) {\n\t\teditor.markHistoryStoppingPoint('creating note shape')\n\t\tconst id = createShapeId()\n\n\t\t// We create it at the center first, so that it becomes\n\t\t// the child of whatever parent was at that center\n\t\teditor.createShape({\n\t\t\tid,\n\t\t\ttype: 'note',\n\t\t\tx: center.x,\n\t\t\ty: center.y,\n\t\t\trotation: pageRotation,\n\t\t\topacity: shape.opacity,\n\t\t\tprops: {\n\t\t\t\t// Use the props of the shape we're cloning\n\t\t\t\t...shape.props,\n\t\t\t\trichText: toRichText(''),\n\t\t\t\tgrowY: 0,\n\t\t\t\tfontSizeAdjustment: 0,\n\t\t\t\turl: '',\n\t\t\t},\n\t\t})\n\n\t\t// Now we need to correct its location within its new parent\n\n\t\tconst createdShape = editor.getShape<TLNoteShape>(id)!\n\t\tif (!createdShape) return // may have hit max shapes\n\n\t\t// We need to put the page point in the same coordinate space as the newly created shape (i.e its parent's space)\n\t\tconst topLeft = editor.getPointInParentSpace(\n\t\t\tcreatedShape,\n\t\t\tVec.Sub(\n\t\t\t\tcenter,\n\t\t\t\tVec.Rot(NOTE_CENTER_OFFSET.clone().mul(createdShape.props.scale), pageRotation)\n\t\t\t)\n\t\t)\n\n\t\teditor.updateShape({\n\t\t\tid,\n\t\t\ttype: 'note',\n\t\t\tx: topLeft.x,\n\t\t\ty: topLeft.y,\n\t\t})\n\n\t\tnextNote = editor.getShape(id)!\n\t}\n\n\teditor.zoomToSelectionIfOffscreen(16, {\n\t\tanimation: {\n\t\t\tduration: editor.options.animationMediumMs,\n\t\t},\n\t\tinset: 0,\n\t})\n\treturn nextNote\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBASO;AAGA,MAAM,sBAAsB;AAE5B,MAAM,YAAY;AAElB,MAAM,qBAAqB,IAAI,kBAAI,YAAY,GAAG,YAAY,CAAC;AAE/D,MAAM,qCAAqC;AAElD,MAAM,sBAAsB,CAAC,WAC5B;AAAA,EACC;AAAA,IACC,CAAC,IAAgB;AAAA,IACjB,IAAI,kBAAI,YAAY,KAAK,YAAY,OAAO,OAAO,QAAQ,mBAAmB;AAAA,EAC/E;AAAA;AAAA,EACA;AAAA,IACC,CAAC,IAAgB;AAAA,IACjB,IAAI,kBAAI,YAAY,MAAM,OAAO,QAAQ,qBAAqB,YAAY,GAAG;AAAA,EAC9E;AAAA;AAAA,EACA;AAAA,IACC,CAAC,IAAgB;AAAA,IACjB,IAAI,kBAAI,YAAY,KAAK,YAAY,MAAM,OAAO,QAAQ,mBAAmB;AAAA,EAC9E;AAAA;AAAA,EACA;AAAA,IACC,CAAC,IAAgB;AAAA,IACjB,IAAI,kBAAI,YAAY,OAAO,OAAO,QAAQ,qBAAqB,YAAY,GAAG;AAAA,EAC/E;AAAA;AACD;AAED,SAAS,6BAA6B,QAAgB,OAAe;AACpE,MAAI,UAAU,EAAG,QAAO,oBAAoB,MAAM;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;AACrD,UAAM,SAAK,6BAAc;AAIzB,WAAO,YAAY;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,MACN,GAAG,OAAO;AAAA,MACV,GAAG,OAAO;AAAA,MACV,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,OAAO;AAAA;AAAA,QAEN,GAAG,MAAM;AAAA,QACT,cAAU,0BAAW,EAAE;AAAA,QACvB,OAAO;AAAA,QACP,oBAAoB;AAAA,QACpB,KAAK;AAAA,MACN;AAAA,IACD,CAAC;AAID,UAAM,eAAe,OAAO,SAAsB,EAAE;AACpD,QAAI,CAAC,aAAc;AAGnB,UAAM,UAAU,OAAO;AAAA,MACtB;AAAA,MACA,kBAAI;AAAA,QACH;AAAA,QACA,kBAAI,IAAI,mBAAmB,MAAM,EAAE,IAAI,aAAa,MAAM,KAAK,GAAG,YAAY;AAAA,MAC/E;AAAA,IACD;AAEA,WAAO,YAAY;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,MACN,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ;AAAA,IACZ,CAAC;AAED,eAAW,OAAO,SAAS,EAAE;AAAA,EAC9B;AAEA,SAAO,2BAA2B,IAAI;AAAA,IACrC,WAAW;AAAA,MACV,UAAU,OAAO,QAAQ;AAAA,IAC1B;AAAA,IACA,OAAO;AAAA,EACR,CAAC;AACD,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -24,6 +24,7 @@ __export(Pointing_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(Pointing_exports);
26
26
  var import_editor = require("@tldraw/editor");
27
+ var import_selectHelpers = require("../../../tools/SelectTool/selectHelpers");
27
28
  var import_noteHelpers = require("../noteHelpers");
28
29
  class Pointing extends import_editor.StateNode {
29
30
  static id = "pointing";
@@ -35,7 +36,7 @@ class Pointing extends import_editor.StateNode {
35
36
  const { editor } = this;
36
37
  const id = (0, import_editor.createShapeId)();
37
38
  this.markId = editor.markHistoryStoppingPoint(`creating_note:${id}`);
38
- const center = this.editor.inputs.originPagePoint.clone();
39
+ const center = this.editor.inputs.getOriginPagePoint().clone();
39
40
  const offset = getNoteShapeAdjacentPositionOffset(
40
41
  this.editor,
41
42
  center,
@@ -52,7 +53,7 @@ class Pointing extends import_editor.StateNode {
52
53
  }
53
54
  }
54
55
  onPointerMove(info) {
55
- if (this.editor.inputs.isDragging) {
56
+ if (this.editor.inputs.getIsDragging()) {
56
57
  this.editor.setCurrentTool("select.translating", {
57
58
  ...info,
58
59
  target: "shape",
@@ -61,8 +62,7 @@ class Pointing extends import_editor.StateNode {
61
62
  isCreating: true,
62
63
  creatingMarkId: this.markId,
63
64
  onCreate: () => {
64
- this.editor.setEditingShape(this.shape.id);
65
- this.editor.setCurrentTool("select.editing_shape");
65
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, this.shape.id);
66
66
  }
67
67
  });
68
68
  }
@@ -83,12 +83,7 @@ class Pointing extends import_editor.StateNode {
83
83
  if (this.editor.getInstanceState().isToolLocked) {
84
84
  this.parent.transition("idle");
85
85
  } else {
86
- this.editor.setEditingShape(this.shape.id);
87
- this.editor.setCurrentTool("select.editing_shape", {
88
- ...this.info,
89
- target: "shape",
90
- shape: this.shape
91
- });
86
+ (0, import_selectHelpers.startEditingShapeWithRichText)(this.editor, this.shape.id, { info: this.info });
92
87
  }
93
88
  }
94
89
  cancel() {