@excalidraw/math 0.18.0-b7aac689a → 0.18.0-c0a0ca3

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 (386) hide show
  1. package/dist/dev/index.js +363 -163
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/debug.d.ts +21 -0
  5. package/dist/types/common/src/appEventBus.d.ts +27 -0
  6. package/dist/types/common/src/bounds.d.ts +10 -0
  7. package/dist/types/common/src/colors.d.ts +81 -39
  8. package/dist/types/common/src/constants.d.ts +106 -33
  9. package/dist/types/common/src/editorInterface.d.ts +34 -0
  10. package/dist/types/common/src/font-metadata.d.ts +1 -3
  11. package/dist/types/common/src/index.d.ts +5 -0
  12. package/dist/types/common/src/keys.d.ts +7 -1
  13. package/dist/types/common/src/points.d.ts +1 -1
  14. package/dist/types/common/src/random.d.ts +7 -0
  15. package/dist/types/common/src/utility-types.d.ts +0 -1
  16. package/dist/types/common/src/utils.d.ts +58 -77
  17. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  18. package/dist/types/element/src/Scene.d.ts +18 -10
  19. package/dist/types/element/src/align.d.ts +6 -2
  20. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  21. package/dist/types/element/src/arrowheads.d.ts +3 -0
  22. package/dist/types/element/src/arrows/focus.d.ts +30 -0
  23. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  24. package/dist/types/element/src/binding.d.ts +145 -49
  25. package/dist/types/element/src/bounds.d.ts +35 -20
  26. package/dist/types/element/src/bucketFill.d.ts +110 -0
  27. package/dist/types/element/src/collision.d.ts +24 -3
  28. package/dist/types/element/src/comparisons.d.ts +10 -7
  29. package/dist/types/element/src/convertToShape.d.ts +23 -0
  30. package/dist/types/element/src/cropElement.d.ts +36 -4
  31. package/dist/types/element/src/delta.d.ts +45 -5
  32. package/dist/types/element/src/distribute.d.ts +7 -2
  33. package/dist/types/element/src/dragElements.d.ts +37 -5
  34. package/dist/types/element/src/duplicate.d.ts +67 -6
  35. package/dist/types/element/src/elbowArrow.d.ts +7 -0
  36. package/dist/types/element/src/embeddable.d.ts +3 -2
  37. package/dist/types/element/src/flowchart.d.ts +9 -11
  38. package/dist/types/element/src/fractionalIndex.d.ts +4 -4
  39. package/dist/types/element/src/frame.d.ts +35 -12
  40. package/dist/types/element/src/groups.d.ts +10 -14
  41. package/dist/types/element/src/heading.d.ts +2 -1
  42. package/dist/types/element/src/image.d.ts +6 -13
  43. package/dist/types/element/src/index.d.ts +12 -4
  44. package/dist/types/element/src/linearElementEditor.d.ts +53 -31
  45. package/dist/types/element/src/listMarker.d.ts +39 -0
  46. package/dist/types/element/src/mutateElement.d.ts +6 -2
  47. package/dist/types/element/src/newElement.d.ts +61 -9
  48. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  49. package/dist/types/element/src/renderElement.d.ts +33 -12
  50. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  51. package/dist/types/element/src/resizeElements.d.ts +24 -14
  52. package/dist/types/element/src/resizeTest.d.ts +6 -5
  53. package/dist/types/element/src/selection.d.ts +11 -17
  54. package/dist/types/element/src/shape.d.ts +38 -9
  55. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  56. package/dist/types/element/src/sortElements.d.ts +10 -0
  57. package/dist/types/element/src/stickyNote.d.ts +191 -0
  58. package/dist/types/element/src/store.d.ts +6 -1
  59. package/dist/types/element/src/textElement.d.ts +24 -12
  60. package/dist/types/element/src/textMeasurements.d.ts +16 -14
  61. package/dist/types/element/src/textWrapping.d.ts +28 -1
  62. package/dist/types/{excalidraw/data → element/src}/transform.d.ts +32 -9
  63. package/dist/types/element/src/transformHandles.d.ts +8 -27
  64. package/dist/types/element/src/typeChecks.d.ts +30 -31
  65. package/dist/types/element/src/types.d.ts +55 -20
  66. package/dist/types/element/src/utils.d.ts +22 -6
  67. package/dist/types/element/src/zindex.d.ts +7 -1
  68. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +251 -222
  69. package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
  70. package/dist/types/excalidraw/actions/actionBoundText.d.ts +117 -274
  71. package/dist/types/excalidraw/actions/actionCanvas.d.ts +556 -1581
  72. package/dist/types/excalidraw/actions/actionClipboard.d.ts +179 -904
  73. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +74 -65
  74. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -565
  75. package/dist/types/excalidraw/actions/actionDeselect.d.ts +183 -0
  76. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
  77. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
  78. package/dist/types/excalidraw/actions/actionElementLink.d.ts +81 -78
  79. package/dist/types/excalidraw/actions/actionElementLock.d.ts +151 -132
  80. package/dist/types/excalidraw/actions/actionExport.d.ts +232 -1425
  81. package/dist/types/excalidraw/actions/actionFinalize.d.ts +11 -395
  82. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
  83. package/dist/types/excalidraw/actions/actionFrame.d.ts +253 -879
  84. package/dist/types/excalidraw/actions/actionGroup.d.ts +162 -151
  85. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +245 -191
  86. package/dist/types/excalidraw/actions/actionLink.d.ts +87 -78
  87. package/dist/types/excalidraw/actions/actionMenu.d.ts +76 -441
  88. package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -361
  89. package/dist/types/excalidraw/actions/actionProperties.d.ts +240 -2548
  90. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +81 -76
  91. package/dist/types/excalidraw/actions/actionStyles.d.ts +75 -65
  92. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  93. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +196 -0
  94. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +89 -81
  95. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +196 -0
  96. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  97. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +88 -79
  98. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +77 -75
  99. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
  100. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  101. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +87 -78
  102. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +88 -79
  103. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  104. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +88 -79
  105. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
  106. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  107. package/dist/types/excalidraw/actions/index.d.ts +8 -3
  108. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  109. package/dist/types/excalidraw/actions/register.d.ts +2 -2
  110. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  111. package/dist/types/excalidraw/actions/types.d.ts +11 -7
  112. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  113. package/dist/types/excalidraw/appState.d.ts +60 -28
  114. package/dist/types/excalidraw/charts/charts.bar.d.ts +3 -0
  115. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  116. package/dist/types/excalidraw/charts/charts.helpers.d.ts +33 -0
  117. package/dist/types/excalidraw/charts/charts.line.d.ts +3 -0
  118. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  119. package/dist/types/excalidraw/charts/charts.radar.d.ts +3 -0
  120. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  121. package/dist/types/excalidraw/charts/index.d.ts +8 -0
  122. package/dist/types/excalidraw/clipboard.d.ts +57 -19
  123. package/dist/types/excalidraw/components/Actions.d.ts +40 -14
  124. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  125. package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
  126. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  127. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  128. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  129. package/dist/types/excalidraw/components/App.d.ts +424 -157
  130. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  131. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  132. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  133. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  134. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  135. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  136. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  137. package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
  138. package/dist/types/excalidraw/components/App.text.d.ts +197 -0
  139. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  140. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  141. package/dist/types/excalidraw/components/App.viewport.d.ts +133 -0
  142. package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
  143. package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
  144. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  145. package/dist/types/excalidraw/components/Card.d.ts +1 -3
  146. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
  147. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -4
  148. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  149. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +7 -1
  150. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +10 -2
  151. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +5 -2
  152. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  153. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
  154. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  155. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  156. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  157. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  158. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
  159. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +6 -5
  160. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  161. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  162. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
  163. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  164. package/dist/types/excalidraw/components/Ellipsify.d.ts +3 -0
  165. package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
  166. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
  167. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  168. package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
  169. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +5 -1
  170. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  171. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  172. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  173. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
  174. package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
  175. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  176. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  177. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  178. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  179. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  180. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  181. package/dist/types/excalidraw/components/LayerUI.d.ts +6 -2
  182. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  183. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  184. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
  185. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +7 -3
  186. package/dist/types/excalidraw/components/LibraryUnit.d.ts +9 -5
  187. package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
  188. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  189. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  190. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  191. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  192. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  193. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  194. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  195. package/dist/types/excalidraw/components/MobileMenu.d.ts +5 -7
  196. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  197. package/dist/types/excalidraw/components/Modal.d.ts +0 -1
  198. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
  199. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  200. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  201. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  202. package/dist/types/excalidraw/components/Popover.d.ts +2 -3
  203. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
  204. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  205. package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
  206. package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
  207. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  208. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  209. package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
  210. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  211. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
  212. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
  213. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
  214. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
  215. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
  216. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
  217. package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
  218. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  219. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
  220. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
  221. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  222. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
  223. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  224. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  225. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  226. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  227. package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
  228. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  229. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
  230. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
  231. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
  232. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
  233. package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
  234. package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
  235. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  236. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +4 -2
  237. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
  238. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
  239. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  240. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +9 -3
  241. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
  242. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
  243. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
  244. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
  245. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +12 -0
  246. package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
  247. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +10 -0
  248. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +19 -16
  249. package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
  250. package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
  251. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +8 -0
  252. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  253. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +108 -0
  254. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
  255. package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
  256. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  257. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +26 -0
  258. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
  259. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  260. package/dist/types/excalidraw/components/Toast.d.ts +11 -7
  261. package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
  262. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  263. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  264. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  265. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  266. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  267. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  268. package/dist/types/excalidraw/components/Trans.d.ts +2 -2
  269. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  270. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  271. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +11 -4
  272. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
  273. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  274. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +47 -35
  275. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
  276. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
  277. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
  278. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  279. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
  280. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
  281. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
  282. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
  283. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  284. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  285. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  286. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
  287. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
  288. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  289. package/dist/types/excalidraw/components/footer/Footer.d.ts +5 -1
  290. package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
  291. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  292. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +16 -5
  293. package/dist/types/excalidraw/components/icons.d.ts +57 -22
  294. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +27 -3
  295. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
  296. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  297. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  298. package/dist/types/excalidraw/data/blob.d.ts +375 -12
  299. package/dist/types/excalidraw/data/encode.d.ts +4 -4
  300. package/dist/types/excalidraw/data/encryption.d.ts +5 -5
  301. package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
  302. package/dist/types/excalidraw/data/index.d.ts +11 -12
  303. package/dist/types/excalidraw/data/json.d.ts +193 -3
  304. package/dist/types/excalidraw/data/library.d.ts +25 -10
  305. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  306. package/dist/types/excalidraw/data/restore.d.ts +27 -7
  307. package/dist/types/excalidraw/data/types.d.ts +4 -1
  308. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  309. package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
  310. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  311. package/dist/types/excalidraw/errors.d.ts +14 -0
  312. package/dist/types/excalidraw/fonts/Fonts.d.ts +12 -8
  313. package/dist/types/excalidraw/history.d.ts +10 -4
  314. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  315. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +2 -2
  316. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +4 -3
  317. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
  318. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  319. package/dist/types/excalidraw/i18n.d.ts +2 -2
  320. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  321. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  322. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  323. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  324. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  325. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  326. package/dist/types/excalidraw/renderer/animation.d.ts +23 -0
  327. package/dist/types/excalidraw/renderer/helpers.d.ts +31 -8
  328. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
  329. package/dist/types/excalidraw/renderer/staticScene.d.ts +15 -7
  330. package/dist/types/excalidraw/scene/Renderer.d.ts +492 -20
  331. package/dist/types/excalidraw/scene/export.d.ts +344 -21
  332. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  333. package/dist/types/excalidraw/scene/types.d.ts +51 -9
  334. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  335. package/dist/types/excalidraw/snapping.d.ts +12 -12
  336. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
  337. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
  338. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
  339. package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
  340. package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
  341. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  342. package/dist/types/excalidraw/types.d.ts +734 -64
  343. package/dist/types/excalidraw/viewport.d.ts +303 -0
  344. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +19 -5
  345. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  346. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  347. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  348. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  349. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  350. package/dist/types/math/src/constants.d.ts +0 -1
  351. package/dist/types/math/src/curve.d.ts +23 -13
  352. package/dist/types/math/src/index.d.ts +1 -0
  353. package/dist/types/math/src/pca.d.ts +79 -0
  354. package/dist/types/math/src/point.d.ts +8 -2
  355. package/dist/types/math/src/polygon.d.ts +26 -2
  356. package/dist/types/math/src/range.d.ts +1 -3
  357. package/dist/types/math/src/segment.d.ts +10 -3
  358. package/dist/types/math/src/types.d.ts +25 -1
  359. package/dist/types/utils/src/index.d.ts +4 -3
  360. package/dist/types/utils/src/shape.d.ts +8 -8
  361. package/package.json +2 -2
  362. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -186
  363. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  364. package/dist/types/excalidraw/charts.d.ts +0 -27
  365. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  366. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
  367. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  368. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  369. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  370. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -9
  371. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  372. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  373. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
  374. package/dist/types/excalidraw/components/shapes.d.ts +0 -62
  375. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  376. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  377. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -85
  378. package/dist/types/excalidraw/cursor.d.ts +0 -5
  379. package/dist/types/excalidraw/data/reconcile.d.ts +0 -6
  380. package/dist/types/excalidraw/index.d.ts +0 -46
  381. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  382. package/dist/types/excalidraw/scene/scroll.d.ts +0 -23
  383. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  384. package/dist/types/utils/src/bbox.d.ts +0 -9
  385. package/dist/types/utils/src/export.d.ts +0 -35
  386. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -0,0 +1,94 @@
1
+ import type { TransformHandleType } from "@excalidraw/element";
2
+ import type { ExcalidrawElement, ExcalidrawImageElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, PointerType } from "@excalidraw/element/types";
3
+ import type React from "react";
4
+ import type { PointerDownState } from "../types";
5
+ import type App from "./App";
6
+ /**
7
+ * The selection tool's (and the lasso's) selection: what a pointer down
8
+ * selects, what a click (a pointer up without a drag) does to the selection —
9
+ * including alt-click cycling through the overlapping elements — and the
10
+ * selection's transform handles (resizing, rotating, cropping).
11
+ */
12
+ export declare class AppSelectionTool {
13
+ private app;
14
+ constructor(app: App);
15
+ clearSelectionIfNotUsingSelection: () => void;
16
+ /**
17
+ * @returns whether the pointer event has been completely handled
18
+ */
19
+ handleSelectionOnPointerDown: (event: React.PointerEvent<HTMLElement>, pointerDownState: PointerDownState) => boolean;
20
+ maybeHandleCrop: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
21
+ /**
22
+ * In the crop editor, a double-click on a handle uncrops its side (a
23
+ * corner's two), and mirrored, the opposite side(s) too.
24
+ *
25
+ * @returns whether the double-click has been handled
26
+ */
27
+ maybeUncropSides: (image: NonDeleted<ExcalidrawImageElement>, sceneX: number, sceneY: number, mirrored: boolean) => boolean;
28
+ maybeHandleResize: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
29
+ /**
30
+ * Drags the selection (or, in the crop editor, the image within its crop) —
31
+ * duplicating it on an alt-drag past the drag threshold.
32
+ *
33
+ * @returns whether the pointer event has been completely handled
34
+ */
35
+ handleSelectionDragOnPointerMove: (event: PointerEvent, pointerDownState: PointerDownState, pointerCoords: {
36
+ x: number;
37
+ y: number;
38
+ }, elementsMap: NonDeletedSceneElementsMap) => boolean;
39
+ /**
40
+ * Box-selects with the selection tool — the line editor's points, while
41
+ * editing a line.
42
+ */
43
+ handleBoxSelectionOnPointerMove: (event: PointerEvent, pointerDownState: PointerDownState) => void;
44
+ /**
45
+ * After dragging the selection: the dragged elements join the frame they're
46
+ * dropped in, or leave theirs (and the edited group, if they leave it).
47
+ */
48
+ handleSelectionDragOnPointerUp: (childEvent: PointerEvent) => void;
49
+ /**
50
+ * The selection's transform handle at the scene point, if any — with its
51
+ * element, for a lone selected element.
52
+ *
53
+ * A lone selected element has none while the line editor is open or one of
54
+ * its line points is hovered, nor does an elbow arrow, a two-point line or
55
+ * arrow, (on mobile devices) any line or arrow, or the text being edited
56
+ * (none are drawn for it; see `AppText.getEditedTextResizeHandleAt()` for
57
+ * its sides). The selection has none in the element link selector.
58
+ */
59
+ getTransformHandleAt(selectedElements: readonly NonDeletedExcalidrawElement[], sceneX: number, sceneY: number, pointerType: PointerType): {
60
+ element?: NonDeletedExcalidrawElement;
61
+ transformHandleType: TransformHandleType;
62
+ } | null;
63
+ /**
64
+ * Updates the selection on a click (no drag): the element below the
65
+ * selected one on an alt-click, the clicked element added to or removed
66
+ * from the selection with shift, or selected, and the selection cleared
67
+ * by a click hitting only a bounding box.
68
+ *
69
+ * @returns whether the pointer event has been completely handled
70
+ */
71
+ handleSelectionOnPointerUp: (childEvent: PointerEvent, pointerDownState: PointerDownState, elementsMap: NonDeletedSceneElementsMap) => boolean;
72
+ clearSelection(hitElement: ExcalidrawElement | null): void;
73
+ /** whether an alt-click on the selection (over other elements) cycles it */
74
+ canCycleSelection: () => boolean;
75
+ /**
76
+ * The selectable unit (an element, or the group a click would select) an
77
+ * element belongs to. Inside an edited group, its elements are units of
78
+ * their own.
79
+ */
80
+ private getSelectableUnit;
81
+ /**
82
+ * The selected unit, if an alt-click can cycle away from it: exactly one
83
+ * is selected, and neither the linear nor the crop editor is open.
84
+ */
85
+ private getCyclableSelectedUnit;
86
+ /**
87
+ * The element an alt-click selects: the selectable unit below the selected
88
+ * one among the hit elements, wrapping around to the topmost — or `null`
89
+ * unless it's an alt-click, the selection can cycle, and it's under the
90
+ * pointer. Inside an edited group, it cycles through the group's elements
91
+ * only, never leaving the group.
92
+ */
93
+ private getSelectionCycleTarget;
94
+ }
@@ -0,0 +1,197 @@
1
+ import { type Bounds, type StylesPanelMode } from "@excalidraw/common";
2
+ import type { ArrowEndpoint } from "@excalidraw/element";
3
+ import type { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
4
+ import { textWysiwyg } from "../wysiwyg/textWysiwyg";
5
+ import type App from "./App";
6
+ import type { AppState, Offsets, ViewportUIName } from "../types";
7
+ type AppTextDependencies = {
8
+ getContainer: () => HTMLDivElement | null;
9
+ getStylesPanelMode: () => StylesPanelMode;
10
+ };
11
+ /**
12
+ * Texts, but for the text tool's pointer interaction (`AppTextTool`):
13
+ *
14
+ * - the editing session: what text to edit, or create, and where
15
+ * (`startTextEditing`), and the editor's lifecycle (`handleTextWysiwyg`)
16
+ * - the part of the canvas a typed or pasted text is kept within
17
+ * (`getTextViewportOffsets`, `getMaxTextWidth`)
18
+ * - the queries that find the text or container to edit at a position
19
+ * - the handle that turns a fixed-width text back into a growing one
20
+ *
21
+ * Every way into editing ends up here: Enter, double-click, pointerup on a
22
+ * selected text or container, the text tool, a drag-created text or sticky
23
+ * note, and a sticky note dropped from the toolbar.
24
+ */
25
+ export declare class AppText {
26
+ private app;
27
+ private dependencies;
28
+ constructor(app: App, dependencies: AppTextDependencies);
29
+ textWysiwygSubmitHandler: ReturnType<typeof textWysiwyg> | null;
30
+ private getTextCreationGridPoint;
31
+ /**
32
+ * The side panels, besides the sidebar, that a typed or pasted text is
33
+ * kept clear of: the stats panel, and the full styles panel (desktop),
34
+ * which shows next to a text while it's edited, and once it's pasted and
35
+ * selected.
36
+ */
37
+ getTextSidePanels: () => ViewportUIName[];
38
+ /**
39
+ * The part of the canvas a typed or pasted text is kept within, as offsets
40
+ * from its edges (screen px): all of it but the sidebar and the side
41
+ * panels (see getTextSidePanels), less some room at each side. The stats
42
+ * panel covers the top of a side only, and counts only for a text beside
43
+ * it: one (given by its scene bounds) with rows within that room of it.
44
+ */
45
+ getTextViewportOffsets: (textBounds?: Bounds) => Required<Offsets>;
46
+ /**
47
+ * The widest a text may grow to as it's typed or pasted, in scene units:
48
+ * TEXT_MAX_WRAP_WIDTH — when zoomed out, that much on screen, up to
49
+ * TEXT_MAX_WRAP_WIDTH_ZOOMED_OUT — or less, so that a text never outgrows
50
+ * the part of the canvas it's kept within.
51
+ */
52
+ getMaxTextWidth: (offsets: Required<Offsets>) => number;
53
+ handleTextWysiwyg(element: NonDeleted<ExcalidrawTextElement>, { isExistingElement, initialCaretSceneCoords, initialSelection, }: {
54
+ isExistingElement?: boolean;
55
+ /**
56
+ * supply null if no caret positioning is desired, and instead
57
+ * text should be auto-selected
58
+ */
59
+ initialCaretSceneCoords?: {
60
+ x: number;
61
+ y: number;
62
+ } | null;
63
+ /** range of the text to select (takes precedence over the caret) */
64
+ initialSelection?: {
65
+ start: number;
66
+ end: number;
67
+ } | null;
68
+ }): void;
69
+ private getSelectedTextElement;
70
+ getSelectedTextEditingContainerAtPosition(hitElement: NonDeletedExcalidrawElement | null, sceneCoords: {
71
+ x: number;
72
+ y: number;
73
+ }): ExcalidrawTextContainer | null | undefined;
74
+ getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
75
+ isHittingTextAutoResizeHandle: (selectedElements: NonDeleted<ExcalidrawElement>[], point: Readonly<{
76
+ x: number;
77
+ y: number;
78
+ }>) => boolean;
79
+ handleTextAutoResizeHandlePointerDown: (selectedElements: NonDeleted<ExcalidrawElement>[], point: Readonly<{
80
+ x: number;
81
+ y: number;
82
+ }>) => boolean;
83
+ /**
84
+ * The side handle of the text being edited under the pointer (see
85
+ * `getEditedTextResizeHandleAt()`), drawn as the affordance for dragging
86
+ * it: a text that doesn't wrap yet has no box showing its sides. Not app
87
+ * state — the interactive canvas takes it as a prop.
88
+ */
89
+ editedTextHoveredSide: "e" | "w" | null;
90
+ setEditedTextHoveredSide: (side: "e" | "w" | null) => void;
91
+ /**
92
+ * The side handle, at a scene point, of the free text being edited: dragging
93
+ * it sets the width the text wraps at, as it does for a selected text.
94
+ *
95
+ * A side's handle is the strip from the text's edge — where the editor
96
+ * ends, leaving no gap between the two — to as far past the box drawn
97
+ * around a wrapped text as the box is from the text.
98
+ *
99
+ * (The edited text isn't necessarily selected, and has no transform handles
100
+ * of the selection's: see `AppSelectionTool.getTransformHandleAt()`.)
101
+ */
102
+ getEditedTextResizeHandleAt: (point: Readonly<{
103
+ x: number;
104
+ y: number;
105
+ }>) => {
106
+ element: NonDeleted<ExcalidrawTextElement>;
107
+ transformHandleType: "e" | "w";
108
+ } | null;
109
+ /**
110
+ * Gives the canvas, while the pointer is over the editor (at the scene
111
+ * point), the cursor of what the pointer would leave the editor onto: the
112
+ * side handle (see `getEditedTextResizeHandleAt()`) if a side is its
113
+ * nearest edge, the canvas itself otherwise.
114
+ *
115
+ * The browser shows the canvas' cursor as it is when the pointer gets
116
+ * there, and what the canvas then sets only a frame later — a flash of
117
+ * another cursor between the editor's and the handle's.
118
+ */
119
+ primeCursorAroundEditedText: (point: Readonly<{
120
+ x: number;
121
+ y: number;
122
+ }>) => void;
123
+ /** the free text being edited, where texts are resized from their sides */
124
+ private getEditedTextResizableFromSides;
125
+ /**
126
+ * Resizes the text being edited for as long as the pointer, pressed on one
127
+ * of its side handles, is dragged — without leaving the editor.
128
+ *
129
+ * @param onClick called on release if the pointer wasn't dragged
130
+ * @returns `false` if the press isn't on a side handle of the edited text
131
+ */
132
+ resizeEditedTextOnPointerDown: (event: PointerEvent, onClick: () => void) => boolean;
133
+ /**
134
+ * The text container at a position — an arrow hit on its path, any other
135
+ * container hit anywhere in its bounds (frames are skipped so a container
136
+ * inside one can be hit, and a frame's children are only hit inside it,
137
+ * where they are drawn). Purely positional: the selection plays no part.
138
+ *
139
+ * Only what hides the rest ends the search — a filled element or an image
140
+ * (as for arrow binding), or an arrow — so containers below a transparent
141
+ * one stay in reach whatever their z-order. Of the containers found, the
142
+ * innermost one centered on the position wins, since that is where its
143
+ * label would go (an arrow counting as innermost: it is pointed at, not just
144
+ * enclosing); failing that, the top-most.
145
+ */
146
+ getTextBindableContainerAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextContainer>;
147
+ /**
148
+ * Whether a text element's content is still being authored.
149
+ *
150
+ * Creating a text reverts the tool to selection during pointerdown, so the
151
+ * pointerup that follows looks like an ordinary canvas click and would
152
+ * capture the still-empty element as a history entry of its own. Undo would
153
+ * then rewind only the typing, restoring an invisible, zero-content element
154
+ * (and, for an endpoint label, leaving the arrow bound to it) rather than
155
+ * removing it. The editor's own submit captures the finished text instead,
156
+ * so the whole create-and-type lands in a single entry.
157
+ */
158
+ isEditingTextContent(): boolean;
159
+ startTextEditing: ({ sceneX, sceneY, insertAtParentCenter, container, autoEdit, initialCaretSceneCoords, initialSelection, arrowEndpoint, textElement, }: {
160
+ /** X position to insert text at */
161
+ sceneX: number;
162
+ /** Y position to insert text at */
163
+ sceneY: number;
164
+ /** whether to attempt to insert at element center if applicable */
165
+ insertAtParentCenter?: boolean;
166
+ container?: ExcalidrawTextContainer | null;
167
+ autoEdit?: boolean;
168
+ initialCaretSceneCoords?: {
169
+ x: number;
170
+ y: number;
171
+ };
172
+ /** range of an existing text to select (takes precedence over the caret) */
173
+ initialSelection?: {
174
+ start: number;
175
+ end: number;
176
+ };
177
+ /**
178
+ * creates the text as a label for this arrow endpoint: the binding then
179
+ * dictates the text's position and alignment, overriding (sceneX, sceneY)
180
+ */
181
+ arrowEndpoint?: ArrowEndpoint | null;
182
+ /**
183
+ * the text to edit: an element to edit exactly that one; `null` to always
184
+ * create, never adopting a selected text or one under the pointer;
185
+ * `undefined` to resolve it here — a single selected text, the label of a
186
+ * selected or passed arrow container, else the text at (sceneX, sceneY)
187
+ */
188
+ textElement?: NonDeleted<ExcalidrawTextElement> | null;
189
+ }) => void;
190
+ getTextWysiwygSnappedToCenterPosition(x: number, y: number, appState: AppState, container?: ExcalidrawTextContainer | null): {
191
+ viewportX: number;
192
+ viewportY: number;
193
+ elementCenterX: number;
194
+ elementCenterY: number;
195
+ } | undefined;
196
+ }
197
+ export {};
@@ -0,0 +1,140 @@
1
+ import type { ArrowEndpoint } from "@excalidraw/element";
2
+ import type { ExcalidrawTextContainer, ExcalidrawTextElement, NonDeleted } from "@excalidraw/element/types";
3
+ import type React from "react";
4
+ import type App from "./App";
5
+ import type { PointerDownState } from "../types";
6
+ type ScenePoint = {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ /** the modifier state a target depends on — off a pointer or keyboard event */
11
+ export type Modifiers = Pick<KeyboardEvent, "ctrlKey" | "metaKey">;
12
+ /** What a text-tool click at a position does. */
13
+ export type TextToolTarget =
14
+ /** binds a new text to a free arrow endpoint */
15
+ {
16
+ type: "endpoint";
17
+ endpoint: ArrowEndpoint;
18
+ }
19
+ /** edits this text (a label included, at its derived position) */
20
+ | {
21
+ type: "text";
22
+ element: NonDeleted<ExcalidrawTextElement>;
23
+ }
24
+ /** binds a new label to this empty container (an arrow included) */
25
+ | {
26
+ type: "container";
27
+ element: NonDeleted<ExcalidrawTextContainer>;
28
+ }
29
+ /** creates free text at the pointer */
30
+ | {
31
+ type: "free";
32
+ };
33
+ /**
34
+ * The text tool's pointer interaction.
35
+ *
36
+ * Everything hangs off one question — what would a click at this position
37
+ * do (`getTargetAt`)? — answered once and used for the hover affordance
38
+ * (`appState.textToolHover`), the cursor and the pointerdown itself, so the
39
+ * affordance can never promise something the click won't deliver.
40
+ *
41
+ * A click on an empty container's center is armed on pointerdown and
42
+ * committed on pointerup as a bound label; dragging past the autowrap
43
+ * threshold first turns it into a free fixed-width text at the origin
44
+ * instead.
45
+ *
46
+ * Text editing itself (`app.text.startTextEditing`, see `AppText`) is
47
+ * shared with Enter, double-click and the other entry points.
48
+ */
49
+ export declare class AppTextTool {
50
+ private app;
51
+ constructor(app: App);
52
+ /**
53
+ * A click on an empty container's center, armed on pointerdown and decided
54
+ * on the pointer's way out: a click binds a label, a drag creates free
55
+ * text instead. Deferring is what keeps the drag from first binding to
56
+ * (and provisionally enlarging) the container.
57
+ */
58
+ private pending;
59
+ /**
60
+ * The modifiers the hover was last resolved with — what a refresh without
61
+ * an event of its own (the viewport moving under a still pointer) uses.
62
+ */
63
+ private lastModifiers;
64
+ /**
65
+ * What a click at this position would do, in the order the click resolves
66
+ * it: a free arrow endpoint (the smaller, more deliberate target; z-aware,
67
+ * and off while ctrl/cmd disables binding) → the text under the pointer,
68
+ * which the click edits → an empty container near its center, which gets
69
+ * a label unless ctrl/cmd opts out → free text at the pointer.
70
+ *
71
+ * Ctrl/cmd is "no binding" throughout the tool, as elsewhere in the
72
+ * editor. For the container it is read off the event rather than the
73
+ * arrow-binding preference: a label is not an arrow binding.
74
+ */
75
+ getTargetAt: (scenePointer: ScenePoint, modifiers: Modifiers) => TextToolTarget;
76
+ /**
77
+ * Keeps `appState.textToolHover` — the affordance for what a click would
78
+ * do — in sync with the pointer, and returns the target (for the cursor).
79
+ * Suppressed while something else owns the interaction: a text being
80
+ * edited or drag-sized, a multi-point element, a box selection, a drag of
81
+ * the selection, or the pointer over a scrollbar.
82
+ */
83
+ updateHover: (scenePointer: ScenePoint, modifiers: Modifiers, isOverScrollBar?: boolean) => TextToolTarget | null;
84
+ /**
85
+ * Re-resolves the hover — and the cursor that goes with it — where the
86
+ * pointer last was, for what changes a click's outcome without the pointer
87
+ * moving: the ctrl/cmd toggle (pass its event), or the viewport scrolling
88
+ * or zooming under the pointer (no event; the last modifiers stand). The
89
+ * scene position is re-derived from the pointer's viewport position, so a
90
+ * moved viewport resolves what is under the pointer now.
91
+ *
92
+ * Nothing to refresh with another tool or without a hovering pointer — a
93
+ * finger never hovers (its last move is where it lifted), and the
94
+ * affordance a press armed is cleared when the press resolves or is
95
+ * canceled. The cursor is left to viewport navigation (space/wheel
96
+ * panning, a scrollbar drag, the hand tool), as on pointermove.
97
+ */
98
+ refresh: (modifiers?: Modifiers) => void;
99
+ /**
100
+ * Drops a pending center click without acting on it — the tool was left,
101
+ * the browser took the pointer (pointercancel), or a second finger turned
102
+ * the press into a pinch/pan — so no pointerup of ours will decide it. The
103
+ * outline it armed goes with it: while pending, the hover is that click's.
104
+ */
105
+ cancel: () => void;
106
+ clearHover: () => void;
107
+ private setHover;
108
+ /**
109
+ * The cursor for what a click would do: a pointer over the arrow anchors
110
+ * text would attach to, a text cursor over text the click would edit, the
111
+ * tool's crosshair otherwise — also while the affordance is suppressed
112
+ * (editing, drag-sizing), where a click has nothing to point at.
113
+ */
114
+ cursorFor: (target: TextToolTarget | null) => string;
115
+ handlePointerDown: (event: React.PointerEvent<HTMLElement>, pointerDownState: PointerDownState) => void;
116
+ /**
117
+ * The pointer-move half of a pending center click. Once the pointer has
118
+ * moved past the autowrap threshold the click is a drag: free text is
119
+ * created at the origin and sized by the drag from here on. Horizontal
120
+ * only (a text is only ever sized that way) and in screen space, and
121
+ * deliberately wider than the generic drag threshold so a jittery click
122
+ * still binds. Returns whether a pending click owned the move.
123
+ */
124
+ handlePointerMove: (event: PointerEvent, pointerDownState: PointerDownState) => boolean;
125
+ /**
126
+ * The pointer-up half: a genuine pointerup binds the label. The
127
+ * missing-pointerup cleanup replays this with the pointerdown event (a
128
+ * second finger landing mid-press), and a tool switch orphans the click —
129
+ * both discard it instead.
130
+ */
131
+ handlePointerUp: (event: PointerEvent, pointerDownState: PointerDownState) => void;
132
+ private isDrag;
133
+ private resolvePending;
134
+ /**
135
+ * The click has been acted on: drop the affordance, revert the tool unless
136
+ * it is locked, restore the cursor.
137
+ */
138
+ private finish;
139
+ }
140
+ export {};
@@ -0,0 +1,63 @@
1
+ import type { ExcalidrawNonSelectionElement, NonDeleted } from "@excalidraw/element/types";
2
+ import type App from "./App";
3
+ import type { ToolType } from "../types";
4
+ type ScenePoint = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ /** what a drag places: any element the new-element canvas can preview */
9
+ type DraggedElement = NonDeleted<ExcalidrawNonSelectionElement>;
10
+ /**
11
+ * A tool the user can drag out of the toolbar to drop a default-sized element
12
+ * where the pointer is released.
13
+ */
14
+ type DraggableTool = {
15
+ /** the element the drop creates, centered on the pointer */
16
+ createElement: (app: App, center: ScenePoint) => DraggedElement;
17
+ /** what the tool does once its element is on the canvas (e.g. start editing) */
18
+ onDrop?: (app: App, element: DraggedElement) => void;
19
+ };
20
+ /**
21
+ * The tools that can be dragged out of the toolbar. Add an entry to make a
22
+ * tool's button draggable — the gesture, preview and drop are shared.
23
+ */
24
+ export declare const DRAGGABLE_TOOLS: Partial<Record<ToolType, DraggableTool>>;
25
+ /** CSS opacity of the preview canvas while dragging */
26
+ export declare const TOOL_DRAG_PREVIEW_OPACITY = 0.5;
27
+ /**
28
+ * Dragging a tool out of the toolbar. The preview element exists only here
29
+ * until the drop — it is not in the scene, the store or the history, so
30
+ * collaborators never see it and an aborted drag leaves nothing behind. It
31
+ * is painted by the `NewElementCanvas`, drawn exactly as it will land, with
32
+ * the canvas itself made translucent.
33
+ *
34
+ * The button arms on pointerdown; the drag starts once the pointer has
35
+ * moved `DRAGGING_THRESHOLD`, so a plain click still selects the tool. The
36
+ * gesture lives on the owner window (the pointer leaves the button at once),
37
+ * like the other pointer gestures in `App`.
38
+ */
39
+ export declare class AppToolDrag {
40
+ private app;
41
+ constructor(app: App);
42
+ /** the element under the pointer while dragging, `null` otherwise */
43
+ preview: DraggedElement | null;
44
+ private armed;
45
+ private tool;
46
+ private type;
47
+ static isDraggable: (type: ToolType) => boolean;
48
+ isDragging: () => boolean;
49
+ /**
50
+ * Arm a drag from a tool button's pointerdown. Returns whether the tool is
51
+ * draggable (the caller lets a non-draggable press fall through).
52
+ */
53
+ handleButtonPointerDown: (type: ToolType, event: PointerEvent) => boolean;
54
+ private onPointerMove;
55
+ private onPointerUp;
56
+ private onKeyDown;
57
+ /** drop the gesture without a trace */
58
+ cancel: () => void;
59
+ private isOverCanvas;
60
+ private addListeners;
61
+ private removeListeners;
62
+ }
63
+ export {};
@@ -0,0 +1,133 @@
1
+ import { type StylesPanelMode } from "@excalidraw/common";
2
+ import type { NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
+ import { type AnimationKey, type AnimationScheduler } from "../renderer/animation";
4
+ import { type SetViewportOptions } from "../viewport";
5
+ import type { AppProps, AppState, Offsets, ScrollConstraints, ViewportOffsets, ViewportOffsetsOptions, ViewportUIName } from "../types";
6
+ import type App from "./App";
7
+ /** The AnimationController keys a viewport uses, unique per AppViewport so
8
+ * concurrent editors in the same window never share (or cancel) each
9
+ * other's animations. */
10
+ export type ViewportAnimationKeys = {
11
+ scrollToContent: AnimationKey;
12
+ snapBack: AnimationKey;
13
+ };
14
+ /** single source of truth for the `--right-sidebar-width` CSS variable */
15
+ export declare const RIGHT_SIDEBAR_WIDTH = 302;
16
+ type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
17
+ type AppViewportDependencies = {
18
+ getContainer: () => HTMLDivElement | null;
19
+ getStylesPanelMode: () => StylesPanelMode;
20
+ isGestureActive: () => boolean;
21
+ };
22
+ /**
23
+ * Rubberband snap-back: animates the viewport from its current (possibly
24
+ * overscrolled) position back inside the lock box via the shared
25
+ * AnimationController. No-op when already within the hard bounds (or when
26
+ * there is no lock).
27
+ */
28
+ export declare const snapBackToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (updater: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => Viewport | null) => void, keys: ViewportAnimationKeys, scheduler?: AnimationScheduler, duration?: number) => void;
29
+ /**
30
+ * Owns viewport state transitions and App-bound viewport concerns. Pure
31
+ * viewport geometry remains in `viewport.ts` so actions and public helpers can
32
+ * calculate state without an App instance.
33
+ */
34
+ export declare class AppViewport {
35
+ private app;
36
+ private dependencies;
37
+ lastPosition: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ private activeTransition;
42
+ private uiLastMeasured;
43
+ /** @see beginGesture */
44
+ private activeExternalGestures;
45
+ /** Unique per instance (see `ViewportAnimationKeys`); exposed for tests
46
+ * observing the animations. */
47
+ readonly scrollToContentAnimationKey: symbol;
48
+ readonly snapBackAnimationKey: symbol;
49
+ constructor(app: App, dependencies: AppViewportDependencies);
50
+ get isAnimating(): boolean;
51
+ /** Whether a programmatic transition into a locked viewport currently owns
52
+ * user pan/zoom input. */
53
+ get isLockedTransitionPending(): boolean;
54
+ invalidateUIOffset: (name: ViewportUIName) => void;
55
+ /**
56
+ * The side a rendered side UI (`data-viewport-ui="side"`) docks to, and
57
+ * how far it reaches into the canvas from it, in screen px.
58
+ */
59
+ private measureSide;
60
+ /**
61
+ * The side a named surface docks to while it's hidden, and how far it
62
+ * reaches into the canvas from it: as last measured, else approximately.
63
+ */
64
+ private getReservedSide;
65
+ private querySideUI;
66
+ /**
67
+ * Where a rendered side UI is, relative to the editor's container, in
68
+ * screen px; null when it isn't rendered.
69
+ */
70
+ getSideUIRect: (name: ViewportUIName) => {
71
+ left: number;
72
+ right: number;
73
+ top: number;
74
+ bottom: number;
75
+ } | null;
76
+ /**
77
+ * How far the named side UIs reach into the canvas, in screen px, from
78
+ * the left and the right: the part of the canvas they cover. Zero at a
79
+ * side none of them is rendered at — e.g. with the sidebar closed, or on
80
+ * phones, where it's an overlay that doesn't count as viewport UI — unless
81
+ * a hidden one is reserved (see `ViewportOffsetsOptions.reserve`).
82
+ */
83
+ getSideInsets: (names: readonly ViewportUIName[], opts?: Pick<ViewportOffsetsOptions, "reserve">) => {
84
+ left: number;
85
+ right: number;
86
+ };
87
+ /** How far the sidebar reaches into the canvas (see `getSideInsets`). */
88
+ getSidebarInsets: () => {
89
+ left: number;
90
+ right: number;
91
+ };
92
+ /**
93
+ * Resolves user-supplied viewport offsets into concrete per-side pixel
94
+ * values. Static sides take precedence over UI-derived sides.
95
+ */
96
+ resolveOffsets: (offsets: ViewportOffsets | undefined) => Offsets | undefined;
97
+ /**
98
+ * Measures the currently rendered editor UI and returns the usable viewport
99
+ * offsets, including optional padding and reserved hidden surfaces.
100
+ */
101
+ getOffsets: (opts?: ViewportOffsetsOptions) => Offsets;
102
+ /** Resolves the host-supplied initial viewport against restored scene data. */
103
+ resolveInitialViewport: (opts: Omit<SetViewportOptions, "animation">, elementsMap: NonDeletedSceneElementsMap, appState: AppState) => (Viewport & {
104
+ scrollConstraints: ScrollConstraints | null;
105
+ }) | null;
106
+ /**
107
+ * Navigates to a target and optionally installs scroll/zoom constraints.
108
+ * Navigating stops following a collaborator, as a user's pan does.
109
+ */
110
+ setViewport: (opts: SetViewportOptions | null) => void;
111
+ /** Use when changing scrollX/scrollY/zoom based on user interaction. */
112
+ translate: <K extends keyof AppState>(state: AppState | Pick<AppState, K> | null | ((prevState: Readonly<AppState>, props: Readonly<AppProps>) => AppState | Pick<AppState, K> | null), opts?: {
113
+ zoomPreConstrained?: boolean;
114
+ preserveScrollConstraintsSnapBack?: boolean;
115
+ }) => boolean;
116
+ /** Clamps the viewport into the active scroll constraints. */
117
+ constrain: (overscroll?: number) => void;
118
+ /**
119
+ * Marks a viewport gesture driven from outside of the canvas (e.g. dragging
120
+ * the minimap) as active, so that a rubberband overscroll is held for as
121
+ * long as it lasts, same as during a pan — including one that's snapping
122
+ * back already. Returns the function ending it, which releases the
123
+ * overscroll.
124
+ */
125
+ beginGesture: () => () => void;
126
+ /** Releases a held rubberband overscroll. */
127
+ releaseOverscroll: () => void;
128
+ private snapBack;
129
+ private snapBackDebounced;
130
+ private cancelTransition;
131
+ destroy: () => void;
132
+ }
133
+ export {};
@@ -0,0 +1,30 @@
1
+ import type App from "./App";
2
+ /**
3
+ * Wheel input over the editor: pans the canvas, or zooms it around the
4
+ * pointer (`viewport.lastPosition`) — on ctrl/cmd+wheel (which is also how
5
+ * a trackpad pinch is delivered), while the wheel button itself is held
6
+ * down, or on a plain wheel when the input device is a mouse
7
+ * (`appState.inputDevice`). Shift+wheel pans horizontally;
8
+ * ctrl/cmd+shift+wheel pans vertically.
9
+ */
10
+ export declare class AppWheel {
11
+ private app;
12
+ constructor(app: App);
13
+ /** the editor surfaces whose wheel input the editor consumes; everywhere
14
+ * else (menus, sidebars, …) the DOM keeps scrolling. The frame-name labels
15
+ * are DOM, but sit inside the container this listener is attached to */
16
+ private isOverEditorSurface;
17
+ handle: (event: WheelEvent) => void;
18
+ /**
19
+ * Prevents the browser's own zoom over the non-interactive editor while
20
+ * letting regular scroll through (trackpad pinch is delivered as
21
+ * ctrl+wheel).
22
+ */
23
+ preventBrowserZoom: (event: WheelEvent) => void;
24
+ /**
25
+ * Zooms by a wheel delta (positive = zoom out) — around the pointer, or
26
+ * around the center of the viewport (when wheeling elsewhere than over
27
+ * the canvas, e.g. over the minimap).
28
+ */
29
+ zoomBy: (deltaY: number, anchor?: "pointer" | "center") => void;
30
+ }