@excalidraw/math 0.18.0-414182f → 0.18.0-43a92e6

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 (371) 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 +92 -31
  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 +5 -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 +52 -77
  17. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  18. package/dist/types/element/src/Scene.d.ts +12 -8
  19. package/dist/types/element/src/align.d.ts +2 -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 +85 -51
  25. package/dist/types/element/src/bounds.d.ts +27 -18
  26. package/dist/types/element/src/bucketFill.d.ts +110 -0
  27. package/dist/types/element/src/collision.d.ts +17 -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 +23 -1
  32. package/dist/types/element/src/distribute.d.ts +3 -2
  33. package/dist/types/element/src/dragElements.d.ts +30 -3
  34. package/dist/types/element/src/duplicate.d.ts +67 -6
  35. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  36. package/dist/types/element/src/embeddable.d.ts +2 -2
  37. package/dist/types/element/src/flowchart.d.ts +11 -7
  38. package/dist/types/element/src/fractionalIndex.d.ts +4 -4
  39. package/dist/types/element/src/frame.d.ts +16 -11
  40. package/dist/types/element/src/groups.d.ts +10 -15
  41. package/dist/types/element/src/heading.d.ts +2 -1
  42. package/dist/types/element/src/image.d.ts +1 -11
  43. package/dist/types/element/src/index.d.ts +10 -4
  44. package/dist/types/element/src/linearElementEditor.d.ts +48 -30
  45. package/dist/types/element/src/listMarker.d.ts +34 -0
  46. package/dist/types/element/src/mutateElement.d.ts +6 -2
  47. package/dist/types/element/src/newElement.d.ts +59 -9
  48. package/dist/types/element/src/renderElement.d.ts +23 -12
  49. package/dist/types/element/src/resizeElements.d.ts +18 -11
  50. package/dist/types/element/src/resizeTest.d.ts +6 -5
  51. package/dist/types/element/src/selection.d.ts +11 -17
  52. package/dist/types/element/src/shape.d.ts +36 -9
  53. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  54. package/dist/types/element/src/sortElements.d.ts +10 -0
  55. package/dist/types/element/src/stickyNote.d.ts +183 -0
  56. package/dist/types/element/src/textElement.d.ts +21 -10
  57. package/dist/types/element/src/textMeasurements.d.ts +1 -3
  58. package/dist/types/element/src/textWrapping.d.ts +26 -0
  59. package/dist/types/{excalidraw/data → element/src}/transform.d.ts +27 -8
  60. package/dist/types/element/src/transformHandles.d.ts +8 -27
  61. package/dist/types/element/src/typeChecks.d.ts +30 -31
  62. package/dist/types/element/src/types.d.ts +55 -20
  63. package/dist/types/element/src/utils.d.ts +22 -6
  64. package/dist/types/element/src/zindex.d.ts +7 -1
  65. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +248 -219
  66. package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
  67. package/dist/types/excalidraw/actions/actionBoundText.d.ts +116 -272
  68. package/dist/types/excalidraw/actions/actionCanvas.d.ts +549 -1582
  69. package/dist/types/excalidraw/actions/actionClipboard.d.ts +177 -899
  70. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +73 -64
  71. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -562
  72. package/dist/types/excalidraw/actions/actionDeselect.d.ts +182 -0
  73. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
  74. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
  75. package/dist/types/excalidraw/actions/actionElementLink.d.ts +80 -77
  76. package/dist/types/excalidraw/actions/actionElementLock.d.ts +149 -130
  77. package/dist/types/excalidraw/actions/actionExport.d.ts +230 -1416
  78. package/dist/types/excalidraw/actions/actionFinalize.d.ts +11 -394
  79. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
  80. package/dist/types/excalidraw/actions/actionFrame.d.ts +247 -875
  81. package/dist/types/excalidraw/actions/actionGroup.d.ts +160 -149
  82. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +220 -197
  83. package/dist/types/excalidraw/actions/actionLink.d.ts +86 -77
  84. package/dist/types/excalidraw/actions/actionMenu.d.ts +75 -438
  85. package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -359
  86. package/dist/types/excalidraw/actions/actionProperties.d.ts +238 -2533
  87. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +80 -75
  88. package/dist/types/excalidraw/actions/actionStyles.d.ts +74 -64
  89. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
  90. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +195 -0
  91. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +88 -80
  92. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +195 -0
  93. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +87 -78
  94. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +76 -74
  95. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
  96. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
  97. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +86 -77
  98. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +87 -78
  99. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  100. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +87 -78
  101. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
  102. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  103. package/dist/types/excalidraw/actions/index.d.ts +7 -3
  104. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  105. package/dist/types/excalidraw/actions/register.d.ts +2 -2
  106. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  107. package/dist/types/excalidraw/actions/types.d.ts +11 -7
  108. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  109. package/dist/types/excalidraw/appState.d.ts +59 -28
  110. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  111. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  112. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  113. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  114. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  115. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  116. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  117. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  118. package/dist/types/excalidraw/clipboard.d.ts +13 -36
  119. package/dist/types/excalidraw/components/Actions.d.ts +33 -11
  120. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  121. package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
  122. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  123. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  124. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  125. package/dist/types/excalidraw/components/App.d.ts +406 -154
  126. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  127. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  128. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  129. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  130. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  131. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  132. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  133. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  134. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  135. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  136. package/dist/types/excalidraw/components/App.viewport.d.ts +113 -0
  137. package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
  138. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  139. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  140. package/dist/types/excalidraw/components/Card.d.ts +1 -3
  141. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
  142. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -4
  143. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  144. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +7 -1
  145. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +10 -2
  146. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +5 -2
  147. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  148. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
  149. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  150. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  151. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  152. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  153. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
  154. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -4
  155. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  156. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  157. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
  158. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  159. package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
  160. package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
  161. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
  162. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  163. package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
  164. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +5 -1
  165. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  166. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  167. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  168. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
  169. package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
  170. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  171. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  172. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  173. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  174. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  175. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  176. package/dist/types/excalidraw/components/LayerUI.d.ts +6 -2
  177. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  178. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  179. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
  180. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +7 -3
  181. package/dist/types/excalidraw/components/LibraryUnit.d.ts +9 -5
  182. package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
  183. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  184. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  185. package/dist/types/excalidraw/components/MobileMenu.d.ts +5 -7
  186. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  187. package/dist/types/excalidraw/components/Modal.d.ts +0 -1
  188. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
  189. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  190. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  191. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  192. package/dist/types/excalidraw/components/Popover.d.ts +2 -3
  193. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
  194. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  195. package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
  196. package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
  197. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  198. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  199. package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
  200. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  201. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
  202. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
  203. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
  204. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
  205. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
  206. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
  207. package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
  208. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  209. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
  210. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
  211. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  212. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
  213. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  214. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  215. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  216. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  217. package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
  218. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  219. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
  220. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
  221. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
  222. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
  223. package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
  224. package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
  225. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  226. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
  227. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
  228. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
  229. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  230. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  231. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
  232. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
  233. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
  234. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
  235. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
  236. package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
  237. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
  238. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
  239. package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
  240. package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
  241. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
  242. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  243. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
  244. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
  245. package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
  246. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  247. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  248. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
  249. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  250. package/dist/types/excalidraw/components/Toast.d.ts +11 -7
  251. package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
  252. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  253. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  254. package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
  255. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  256. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  257. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  258. package/dist/types/excalidraw/components/Trans.d.ts +2 -2
  259. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  260. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  261. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +10 -4
  262. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
  263. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  264. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +47 -35
  265. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
  266. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
  267. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
  268. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  269. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
  270. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
  271. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
  272. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
  273. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  274. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  275. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  276. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
  277. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
  278. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  279. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  280. package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
  281. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  282. package/dist/types/excalidraw/components/icons.d.ts +56 -22
  283. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +26 -3
  284. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
  285. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  286. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  287. package/dist/types/excalidraw/data/blob.d.ts +373 -8
  288. package/dist/types/excalidraw/data/encode.d.ts +4 -4
  289. package/dist/types/excalidraw/data/encryption.d.ts +5 -5
  290. package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
  291. package/dist/types/excalidraw/data/index.d.ts +8 -9
  292. package/dist/types/excalidraw/data/json.d.ts +192 -3
  293. package/dist/types/excalidraw/data/library.d.ts +25 -10
  294. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  295. package/dist/types/excalidraw/data/restore.d.ts +25 -10
  296. package/dist/types/excalidraw/data/types.d.ts +4 -1
  297. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  298. package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
  299. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  300. package/dist/types/excalidraw/errors.d.ts +14 -0
  301. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  302. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  303. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +2 -2
  304. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +4 -3
  305. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
  306. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  307. package/dist/types/excalidraw/i18n.d.ts +2 -2
  308. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  309. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  310. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  311. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  312. package/dist/types/excalidraw/renderer/animation.d.ts +16 -0
  313. package/dist/types/excalidraw/renderer/helpers.d.ts +31 -8
  314. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
  315. package/dist/types/excalidraw/scene/Renderer.d.ts +491 -19
  316. package/dist/types/excalidraw/scene/export.d.ts +4 -4
  317. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  318. package/dist/types/excalidraw/scene/types.d.ts +28 -8
  319. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  320. package/dist/types/excalidraw/snapping.d.ts +12 -12
  321. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
  322. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
  323. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
  324. package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
  325. package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
  326. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  327. package/dist/types/excalidraw/types.d.ts +672 -61
  328. package/dist/types/excalidraw/viewport.d.ts +302 -0
  329. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +19 -5
  330. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  331. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  332. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  333. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  334. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  335. package/dist/types/math/src/constants.d.ts +0 -1
  336. package/dist/types/math/src/curve.d.ts +23 -13
  337. package/dist/types/math/src/index.d.ts +1 -0
  338. package/dist/types/math/src/pca.d.ts +79 -0
  339. package/dist/types/math/src/point.d.ts +8 -2
  340. package/dist/types/math/src/polygon.d.ts +26 -2
  341. package/dist/types/math/src/range.d.ts +1 -3
  342. package/dist/types/math/src/segment.d.ts +10 -3
  343. package/dist/types/math/src/types.d.ts +25 -1
  344. package/dist/types/utils/src/export.d.ts +9 -8
  345. package/dist/types/utils/src/index.d.ts +1 -2
  346. package/dist/types/utils/src/shape.d.ts +8 -8
  347. package/package.json +2 -2
  348. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -185
  349. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  350. package/dist/types/excalidraw/charts.d.ts +0 -27
  351. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  352. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
  353. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  354. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  355. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  356. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -9
  357. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  358. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  359. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
  360. package/dist/types/excalidraw/components/shapes.d.ts +0 -190
  361. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  362. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  363. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -85
  364. package/dist/types/excalidraw/cursor.d.ts +0 -5
  365. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  366. package/dist/types/excalidraw/index.d.ts +0 -47
  367. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  368. package/dist/types/excalidraw/scene/scroll.d.ts +0 -23
  369. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  370. package/dist/types/utils/src/bbox.d.ts +0 -9
  371. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -1,23 +1,24 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
2
- import type { SuggestedBinding } from "@excalidraw/element";
1
+ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
3
2
  import type { LinearElementEditor } from "@excalidraw/element";
4
- import type { MaybeTransformHandleType } from "@excalidraw/element";
5
- import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
3
+ import type { ListMarkerAdvance, MaybeTransformHandleType } from "@excalidraw/element";
4
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, ExcalidrawArrowElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
6
5
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
7
- import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
6
+ import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, OnDuplicateData } from "@excalidraw/element";
7
+ import type { GlobalPoint } from "@excalidraw/math";
8
8
  import type { Action } from "./actions/types";
9
9
  import type { Spreadsheet } from "./charts";
10
10
  import type { ClipboardData } from "./clipboard";
11
11
  import type App from "./components/App";
12
12
  import type Library from "./data/library";
13
- import type { FileSystemHandle } from "./data/filesystem";
14
13
  import type { ContextMenuItems } from "./components/ContextMenu";
15
14
  import type { SnapLine } from "./snapping";
16
15
  import type { ImportedDataState } from "./data/types";
16
+ import type { SetViewportOptions } from "./viewport";
17
17
  import type { Language } from "./i18n";
18
18
  import type { isOverScrollBars } from "./scene/scrollbars";
19
19
  import type React from "react";
20
20
  import type { JSX } from "react";
21
+ export type { App };
21
22
  export type SocketId = string & {
22
23
  _brand: "SocketId";
23
24
  };
@@ -84,7 +85,7 @@ export type BinaryFileData = {
84
85
  };
85
86
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
86
87
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
87
- export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
88
+ export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "stickynote" | "embeddable" | "laser" | "autoshape" | "bucketfill";
88
89
  export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
89
90
  export type ActiveTool = {
90
91
  type: ToolType;
@@ -125,16 +126,22 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
125
126
  frameRendering: AppState["frameRendering"];
126
127
  currentHoveredFontFamily: AppState["currentHoveredFontFamily"];
127
128
  hoveredElementIds: AppState["hoveredElementIds"];
129
+ suggestedBinding: AppState["suggestedBinding"];
128
130
  croppingElementId: AppState["croppingElementId"];
129
131
  }>;
130
132
  export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
133
+ activeTool: AppState["activeTool"];
131
134
  activeEmbeddable: AppState["activeEmbeddable"];
132
135
  selectionElement: AppState["selectionElement"];
133
136
  selectedGroupIds: AppState["selectedGroupIds"];
134
137
  selectedLinearElement: AppState["selectedLinearElement"];
135
138
  multiElement: AppState["multiElement"];
139
+ newElement: AppState["newElement"];
136
140
  isBindingEnabled: AppState["isBindingEnabled"];
137
- suggestedBindings: AppState["suggestedBindings"];
141
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
142
+ gridModeEnabled: AppState["gridModeEnabled"];
143
+ suggestedBinding: AppState["suggestedBinding"];
144
+ textToolHover: AppState["textToolHover"];
138
145
  isRotating: AppState["isRotating"];
139
146
  elementsToHighlight: AppState["elementsToHighlight"];
140
147
  collaborators: AppState["collaborators"];
@@ -145,6 +152,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
145
152
  croppingElementId: AppState["croppingElementId"];
146
153
  searchMatches: AppState["searchMatches"];
147
154
  activeLockedId: AppState["activeLockedId"];
155
+ hoveredElementIds: AppState["hoveredElementIds"];
156
+ frameRendering: AppState["frameRendering"];
157
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
158
+ exportScale: AppState["exportScale"];
159
+ currentItemArrowType: AppState["currentItemArrowType"];
148
160
  }>;
149
161
  export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
150
162
  export type ObservedStandaloneAppState = {
@@ -163,6 +175,47 @@ export type ObservedElementsAppState = {
163
175
  lockedMultiSelections: AppState["lockedMultiSelections"];
164
176
  activeLockedId: AppState["activeLockedId"];
165
177
  };
178
+ export type BoxSelectionMode = "contain" | "overlap";
179
+ /**
180
+ * The pointing device the wheel mappings are tuned for. `auto` is reserved
181
+ * for detecting it from the wheel events; see `resolveInputDevice`.
182
+ */
183
+ export type InputDevice = "auto" | "mouse" | "trackpad";
184
+ /**
185
+ * A box, in scene coordinates, that pan & zoom are constrained to.
186
+ *
187
+ * This is a private type. For public API, only use specific properties,
188
+ * needed.
189
+ */
190
+ export type ScrollConstraints = {
191
+ x: number;
192
+ y: number;
193
+ width: number;
194
+ height: number;
195
+ /** when set, panning is constrained so the viewport stays within the box */
196
+ lockScroll: boolean;
197
+ /** when set, the viewport cannot zoom out below `zoom` */
198
+ lockZoom: boolean;
199
+ /**
200
+ * The zoom resolved after the `setViewport` navigation settled.
201
+ */
202
+ zoom: number;
203
+ /**
204
+ * Pixel amount the viewport may overscroll past its resting clamp before
205
+ * snapping back (rubberband). Screen pixels, zoom-independent. Resolved
206
+ * from `lock.overscroll` at the time the lock was installed (`true` →
207
+ * default give, `false` → 0).
208
+ */
209
+ overscroll: number;
210
+ /**
211
+ * Extra scrollable margin around the box (CSS-style), letting the viewport
212
+ * scroll past each box edge to reveal that much empty space. Values are
213
+ * viewport pixels and zoom-independent (a fixed on-screen distance).
214
+ * Resolved from the `offsets` passed to `setViewport` (see
215
+ * {@link ViewportOffsets}) at the time the lock was installed.
216
+ */
217
+ offsets?: Offsets;
218
+ };
166
219
  export interface AppState {
167
220
  contextMenu: {
168
221
  items: ContextMenuItems;
@@ -196,9 +249,53 @@ export interface AppState {
196
249
  * - set on pointer down, updated during pointer move
197
250
  */
198
251
  selectionElement: NonDeletedExcalidrawElement | null;
252
+ /**
253
+ * tracking current arrow binding editor state (takes into account
254
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
255
+ */
199
256
  isBindingEnabled: boolean;
200
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
201
- suggestedBindings: SuggestedBinding[];
257
+ /** user box selection preference; defaults to "contain" when unset */
258
+ boxSelectionMode: BoxSelectionMode;
259
+ /** user arrow binding preference */
260
+ bindingPreference: "enabled" | "disabled";
261
+ /** user preference whether arrow snap to midpoints while binding */
262
+ isMidpointSnappingEnabled: boolean;
263
+ /** user preference whether to show contextual hints above the toolbar */
264
+ showHints: boolean;
265
+ /**
266
+ * user preference for what the wheel does: with a `trackpad` a plain wheel
267
+ * pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
268
+ * delivered) zooms with either device. Shift+wheel pans horizontally;
269
+ * ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
270
+ * device detection exists — see `resolveInputDevice`
271
+ */
272
+ inputDevice: InputDevice;
273
+ /**
274
+ * The bindable element the UI highlights for the user when an arrow is
275
+ * dragged or otherwise its endpoint being close to said element.
276
+ */
277
+ suggestedBinding: {
278
+ element: NonDeleted<ExcalidrawBindableElement>;
279
+ midPoint?: GlobalPoint;
280
+ } | null;
281
+ /**
282
+ * What a text-tool click at the hovered position would act on — the text
283
+ * it would edit, the empty container it would label, or the arrow anchor
284
+ * (a free endpoint, or the midpoint for a label) it would attach text to.
285
+ * `null` when the click would create free text, or the tool isn't active.
286
+ * Drives the hover affordance only.
287
+ */
288
+ textToolHover: {
289
+ type: "text";
290
+ elementId: ExcalidrawElement["id"];
291
+ } | {
292
+ type: "container";
293
+ elementId: ExcalidrawElement["id"];
294
+ } | {
295
+ type: "arrow";
296
+ elementId: ExcalidrawArrowElement["id"];
297
+ anchor: "start" | "end" | "label";
298
+ } | null;
202
299
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
203
300
  frameRendering: {
204
301
  enabled: boolean;
@@ -206,12 +303,19 @@ export interface AppState {
206
303
  outline: boolean;
207
304
  clip: boolean;
208
305
  };
209
- editingFrame: string | null;
210
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
306
+ /**
307
+ * frame-like element whose name is currently being edited
308
+ */
309
+ editingFrame: ExcalidrawFrameLikeElement["id"] | null;
310
+ /**
311
+ * Elements the UI highlights with a bounding-box outline — those that
312
+ * would get added to a frame being dragged/resized.
313
+ */
314
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
211
315
  /**
212
316
  * set when a new text is created or when an existing text is being edited
213
317
  */
214
- editingTextElement: NonDeletedExcalidrawElement | null;
318
+ editingTextElement: ExcalidrawTextElement | null;
215
319
  activeTool: {
216
320
  /**
217
321
  * indicates a previous tool we should revert back to if we deselect the
@@ -221,6 +325,10 @@ export interface AppState {
221
325
  locked: boolean;
222
326
  fromSelection: boolean;
223
327
  } & ActiveTool;
328
+ preferredSelectionTool: {
329
+ type: "selection" | "lasso";
330
+ initialized: boolean;
331
+ };
224
332
  penMode: boolean;
225
333
  penDetected: boolean;
226
334
  exportBackground: boolean;
@@ -228,11 +336,14 @@ export interface AppState {
228
336
  exportWithDarkMode: boolean;
229
337
  exportScale: number;
230
338
  currentItemStrokeColor: string;
339
+ currentItemStickynoteStrokeColor: string;
340
+ currentItemStickynoteBackgroundColor: string;
231
341
  currentItemBackgroundColor: string;
232
342
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
233
- currentItemStrokeWidth: number;
343
+ currentItemStrokeWidthKey: StrokeWidthKey;
234
344
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
235
345
  currentItemRoughness: number;
346
+ currentItemStrokeVariability: StrokeVariability;
236
347
  currentItemOpacity: number;
237
348
  currentItemFontFamily: FontFamilyValues;
238
349
  currentItemFontSize: number;
@@ -245,14 +356,15 @@ export interface AppState {
245
356
  viewBackgroundColor: string;
246
357
  scrollX: number;
247
358
  scrollY: number;
359
+ scrollConstraints: ScrollConstraints | null;
248
360
  cursorButton: "up" | "down";
249
361
  scrolledOutside: boolean;
250
362
  name: string | null;
251
363
  isResizing: boolean;
252
364
  isRotating: boolean;
253
365
  zoom: Zoom;
254
- openMenu: "canvas" | "shape" | null;
255
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
366
+ openMenu: "canvas" | null;
367
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
256
368
  openSidebar: {
257
369
  name: SidebarName;
258
370
  tab?: SidebarTabName;
@@ -264,9 +376,15 @@ export interface AppState {
264
376
  tab: "text-to-diagram" | "mermaid";
265
377
  } | {
266
378
  name: "commandPalette";
379
+ } | {
380
+ name: "settings";
267
381
  } | {
268
382
  name: "elementLinkSelector";
269
383
  sourceElementId: ExcalidrawElement["id"];
384
+ } | {
385
+ name: "charts";
386
+ data: Spreadsheet;
387
+ rawText: string;
270
388
  };
271
389
  /**
272
390
  * Reflects user preference for whether the default sidebar should be docked.
@@ -289,7 +407,7 @@ export interface AppState {
289
407
  selectedElementsAreBeingDragged: boolean;
290
408
  shouldCacheIgnoreZoom: boolean;
291
409
  toast: {
292
- message: string;
410
+ message: React.ReactNode;
293
411
  closable?: boolean;
294
412
  duration?: number;
295
413
  } | null;
@@ -311,21 +429,13 @@ export interface AppState {
311
429
  height: number;
312
430
  offsetTop: number;
313
431
  offsetLeft: number;
314
- fileHandle: FileSystemHandle | null;
432
+ fileHandle: FileSystemFileHandle | null;
315
433
  collaborators: Map<SocketId, Collaborator>;
316
434
  stats: {
317
435
  open: boolean;
318
436
  /** bitmap. Use `STATS_PANELS` bit values */
319
437
  panels: number;
320
438
  };
321
- currentChartType: ChartType;
322
- pasteDialog: {
323
- shown: false;
324
- data: null;
325
- } | {
326
- shown: true;
327
- data: Spreadsheet;
328
- };
329
439
  showHyperlinkPopup: false | "info" | "editor";
330
440
  selectedLinearElement: LinearElementEditor | null;
331
441
  snapLines: readonly SnapLine[];
@@ -334,10 +444,6 @@ export interface AppState {
334
444
  y: number;
335
445
  } | null;
336
446
  objectsSnapModeEnabled: boolean;
337
- /** the user's socket id & username who is being followed on the canvas */
338
- userToFollow: UserToFollow | null;
339
- /** the socket ids of the users following the current user */
340
- followedBy: Set<SocketId>;
341
447
  /** image cropping */
342
448
  isCropping: boolean;
343
449
  croppingElementId: ExcalidrawElement["id"] | null;
@@ -351,6 +457,24 @@ export interface AppState {
351
457
  lockedMultiSelections: {
352
458
  [groupId: string]: true;
353
459
  };
460
+ bindMode: BindMode;
461
+ /** user-customized color-picker top picks (pinned via drag & drop from the
462
+ * color picker popup). `null` means no customization (defaults, or
463
+ * host-supplied `topPicks`, are used). Kept per picker. */
464
+ colorTopPicks: {
465
+ elementStroke: readonly string[] | null;
466
+ elementBackground: readonly string[] | null;
467
+ /** the bucket-fill tool keeps a list separate from `elementBackground`
468
+ * even though both drive `currentItemBackgroundColor` (its defaults and
469
+ * use case differ — no transparent) */
470
+ bucketFill: readonly string[] | null;
471
+ /** sticky notes are their own color domain (own defaults, own picks) */
472
+ stickyNoteStroke: readonly string[] | null;
473
+ stickyNoteBackground: readonly string[] | null;
474
+ };
475
+ /** user-customized font-picker top picks (pinned via drag & drop from the
476
+ * font picker popup). `null` means no customization (defaults are used) */
477
+ fontTopPicks: readonly FontFamilyValues[] | null;
354
478
  }
355
479
  export type SearchMatch = {
356
480
  id: string;
@@ -363,7 +487,7 @@ export type SearchMatch = {
363
487
  showOnCanvas: boolean;
364
488
  }[];
365
489
  };
366
- export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
490
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
367
491
  export type NormalizedZoomValue = number & {
368
492
  _brand: "normalizedZoom";
369
493
  };
@@ -407,15 +531,192 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
407
531
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
408
532
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
409
533
  }>;
534
+ export type ExcalidrawInitialState = {
535
+ viewport?: Omit<SetViewportOptions, "animation">;
536
+ };
410
537
  export type OnUserFollowedPayload = {
411
538
  userToFollow: UserToFollow;
412
539
  action: "FOLLOW" | "UNFOLLOW";
413
540
  };
541
+ export type ViewportStatusFrame = {
542
+ /** the badge (bottom-center pill) */
543
+ label?: {
544
+ label: React.ReactNode;
545
+ icon?: React.ReactNode;
546
+ /** badge background; defaults to var(--color-primary-hover) */
547
+ background?: string;
548
+ /** badge text color; defaults to var(--color-primary-light) */
549
+ color?: string;
550
+ /** makes the badge label interactive */
551
+ onClick?: () => void;
552
+ /** renders a close button when set */
553
+ onClose?: () => void;
554
+ };
555
+ /** viewport-edge border: CSS color, or `false` for none */
556
+ border: false | string;
557
+ };
558
+ export type OnExportProgress = {
559
+ type: "progress";
560
+ message?: React.ReactNode;
561
+ /** 0-1 range */
562
+ progress?: number;
563
+ };
564
+ export type InteractionConfig = {
565
+ /**
566
+ * Interactions that stay enabled while the editor is otherwise
567
+ * non-interactive. Opt-in: anything omitted or `false` is disabled.
568
+ */
569
+ enabled?: {
570
+ /**
571
+ * Element links render their link icon and stay clickable — clicking
572
+ * anywhere on a linked element opens the link, same as in view mode.
573
+ * When disabled, link icons are not rendered at all.
574
+ *
575
+ * @default false
576
+ */
577
+ links?: boolean;
578
+ /**
579
+ * Embeddable & iframe elements stay interactive — hovering & clicking
580
+ * activates them so their content can be used, same as in view mode.
581
+ *
582
+ * @default false
583
+ */
584
+ embeds?: boolean;
585
+ /**
586
+ * Umbrella for all interactive content on canvas — shorthand for
587
+ * enabling `links` & `embeds` (and future interactive content kinds)
588
+ * together. Additive: `interactiveContent: true` enables them
589
+ * regardless of their individual values.
590
+ *
591
+ * @default false
592
+ */
593
+ interactiveContent?: boolean;
594
+ /**
595
+ * Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
596
+ * and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
597
+ * zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
598
+ * mode. Respects `appState.scrollConstraints` if set, so it composes
599
+ * with viewport locking. The rest of the keyboard stays disabled. Note
600
+ * the editor consumes wheel & touch input again when enabled, so the
601
+ * page no longer scrolls over the editor.
602
+ *
603
+ * @default false
604
+ */
605
+ navigation?: boolean;
606
+ /**
607
+ * Whether the browser's own zoom remains available over the editor —
608
+ * ctrl/cmd + wheel, pinch, and (while the editor has focus)
609
+ * ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
610
+ * interactive editor. Regular page scrolling stays available either way.
611
+ * With `navigation` enabled, the zoom input (wheel, pinch, keyboard
612
+ * shortcuts) zooms the canvas instead either way, making this moot.
613
+ *
614
+ * @default false
615
+ */
616
+ browserZoom?: boolean;
617
+ /**
618
+ * Tools that stay user-driven while the editor is otherwise
619
+ * non-interactive: pointer input keeps driving the listed tool when it's
620
+ * the active tool. Does not enable user-driven tool *switching* — the
621
+ * keyboard stays disabled and tool selection remains host-driven
622
+ * (`ExcalidrawAPI.setActiveTool`).
623
+ *
624
+ * Composes with `navigation`: the enabled tool wins the primary-pointer
625
+ * drag, while wheel input (and wheel-button drag) still pans/zooms.
626
+ */
627
+ tools?: {
628
+ /**
629
+ * The laser pointer stays usable — pointer strokes draw laser trails
630
+ * and pointer positions keep broadcasting via `onPointerUpdate`, so
631
+ * e.g. collaborators see a presenter's laser & cursor.
632
+ *
633
+ * @default false
634
+ */
635
+ laser?: boolean;
636
+ /**
637
+ * Custom tools (`activeTool.type === "custom"`) stay usable — the
638
+ * editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
639
+ * Tool behavior is host-implemented; activate custom tools with
640
+ * `locked: true` or they revert to the selection tool (and go inert)
641
+ * after the first pointer interaction.
642
+ *
643
+ * @default false
644
+ */
645
+ custom?: boolean;
646
+ };
647
+ };
648
+ };
649
+ export type UIConfig = {
650
+ /**
651
+ * Default UI controls that stay enabled while the rest of Excalidraw's
652
+ * default UI is hidden. Opt-in: anything omitted or `false` is disabled.
653
+ */
654
+ enabled: {
655
+ /**
656
+ * The zoom-out, reset-zoom, and zoom-in controls.
657
+ *
658
+ * @default false
659
+ */
660
+ zoom?: boolean;
661
+ /**
662
+ * The button shown when the viewport is scrolled away from all content.
663
+ *
664
+ * @default false
665
+ */
666
+ scrollBackToContent?: boolean;
667
+ };
668
+ };
669
+ /** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
670
+ export type ElementRenderOverride = Readonly<{
671
+ /** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
672
+ opacity?: number;
673
+ /** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
674
+ offset?: Readonly<{
675
+ x: number;
676
+ y: number;
677
+ }>;
678
+ }>;
679
+ /** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
680
+ export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
681
+ /** The translation part of a snapshot: only the entries that carry an offset. */
682
+ export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
414
683
  export interface ExcalidrawProps {
684
+ className?: string;
685
+ /**
686
+ * Document that owns Excalidraw's mounted DOM.
687
+ *
688
+ * Set only when it differs from the global `document`, such as when code
689
+ * executing in a parent window mounts Excalidraw into an iframe document.
690
+ * The value must remain stable for the editor's lifetime.
691
+ *
692
+ * @default document
693
+ */
694
+ ownerDocument?: Document;
415
695
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
696
+ onThemeChange?: (theme: Theme | "system") => void;
697
+ /**
698
+ * note: only subscribes if the props.onIncrement is defined on initial render
699
+ */
416
700
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
417
701
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
418
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
702
+ initialState?: ExcalidrawInitialState;
703
+ /**
704
+ * Invoked as soon as the Excalidraw API is available
705
+ * NOTE editor is not yet mounted, and state is not yet initialized
706
+ */
707
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
708
+ /**
709
+ * Invoked once the editor root is mounted.
710
+ */
711
+ onMount?: (payload: ExcalidrawMountPayload) => void;
712
+ /**
713
+ * Invoked when the editor root is unmounted.
714
+ */
715
+ onUnmount?: () => void;
716
+ /**
717
+ * Invoked once the initial scene is loaded.
718
+ */
719
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
419
720
  isCollaborating?: boolean;
420
721
  onPointerUpdate?: (payload: {
421
722
  pointer: {
@@ -436,14 +737,95 @@ export interface ExcalidrawProps {
436
737
  *
437
738
  * Returned elements will be used in place of the next elements
438
739
  * (you should return all elements, including deleted, and not mutate
439
- * the element if changes are made)
740
+ * the element if changes are made).
741
+ *
742
+ * The duplicates are the elements in `nextElements` which are not in
743
+ * `prevElements` (see also `data.duplicateElements`). When pasting or
744
+ * inserting onto a frame, their `frameId` is already set. To change a
745
+ * duplicate, return a new object with the same `id`. It is shallow-merged
746
+ * into the duplicate (omitted properties are kept), and your changes are
747
+ * part of the duplication itself (same undo entry, same durable increment).
748
+ *
749
+ * To prevent an element from being duplicated, omit its duplicate from the
750
+ * returned array. References to it from the remaining duplicates are
751
+ * cleared, and a bound text isn't duplicated without its container. To
752
+ * prevent the duplication as a whole, return `false`. If no duplicate
753
+ * remains, the duplication is cancelled and the returned elements are
754
+ * ignored (alt-drag then moves the original elements instead).
440
755
  */
441
756
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
442
757
  /** excludes the duplicated elements */
443
- prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
758
+ prevElements: readonly ExcalidrawElement[],
759
+ /** lookups covering just the elements taking part in the duplication */
760
+ data: OnDuplicateData) => ExcalidrawElement[] | void | false;
761
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
444
762
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
445
763
  langCode?: Language["code"];
446
764
  viewModeEnabled?: boolean;
765
+ /**
766
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
767
+ * clipboard, drag&drop). When `false`, the scene still renders and reacts
768
+ * to programmatic updates (imperative API), but the user cannot affect it
769
+ * in any way. Implies view mode.
770
+ *
771
+ * Pass a config object to keep specific interactions enabled while the
772
+ * editor is otherwise non-interactive (see `InteractionConfig`):
773
+ *
774
+ * ```tsx
775
+ * <Excalidraw interaction={{ enabled: { links: true } }} />
776
+ * ```
777
+ *
778
+ * @default true
779
+ */
780
+ interaction?: boolean | InteractionConfig;
781
+ /**
782
+ * Whether Excalidraw's default UI is rendered — toolbar, default menus,
783
+ * footer controls, sidebars, and canvas popups. Host UI passed through
784
+ * children (including exported components such as `MainMenu` and `Footer`)
785
+ * or render props continues to render, together with any supporting dialogs
786
+ * it opens.
787
+ *
788
+ * Canvas content (elements, text editing surface, frame names, embeds) still
789
+ * renders, and the editor remains interactive unless `interaction` is set to
790
+ * `false`.
791
+ *
792
+ * Pass a config object to keep specific default controls rendered while the
793
+ * rest of the default UI is hidden (see `UIConfig`):
794
+ *
795
+ * ```tsx
796
+ * <Excalidraw ui={{ enabled: { zoom: true } }} />
797
+ * ```
798
+ *
799
+ * NOTE: this is WIP and what default UI is/is not rendered when ui=false
800
+ * may yet change.
801
+ *
802
+ * @default true
803
+ */
804
+ ui?: boolean | UIConfig;
805
+ /**
806
+ * Forces the active editor tool (controlled). While set, user- and
807
+ * API-driven tool switching is ignored — `setActiveTool` refuses with a
808
+ * console warning, non-forced toolbar buttons render disabled — and the
809
+ * editor snaps back if internal flows reset the tool. The forced tool
810
+ * behaves as if locked (see the tool lock / padlock): it doesn't revert to
811
+ * the selection tool after use, and elements drawn with it aren't
812
+ * auto-selected — without mutating `appState.activeTool.locked`, so the
813
+ * user's persisted padlock preference stays untouched. Unset to return
814
+ * tool control to the editor (the current tool stays active).
815
+ *
816
+ * The forced tool must be activatable to take effect: not disabled via
817
+ * `UIOptions.tools`, and — while the editor is non-interactive — allowed
818
+ * via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
819
+ * non-interactive, resets to) the `selection` tool, and the forced tool is
820
+ * applied once it becomes activatable. `image` cannot be forced (its
821
+ * activation opens the file picker).
822
+ */
823
+ activeTool?: {
824
+ type: Exclude<ToolType, "image">;
825
+ } | {
826
+ type: "custom";
827
+ customType: string;
828
+ };
447
829
  zenModeEnabled?: boolean;
448
830
  gridModeEnabled?: boolean;
449
831
  objectsSnapModeEnabled?: boolean;
@@ -452,6 +834,10 @@ export interface ExcalidrawProps {
452
834
  name?: string;
453
835
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
454
836
  UIOptions?: Partial<UIOptions>;
837
+ /**
838
+ * dimensions and size constraints for inserted images
839
+ */
840
+ imageOptions?: ImageOptions;
455
841
  detectScroll?: boolean;
456
842
  handleKeyboardGlobally?: boolean;
457
843
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -471,9 +857,48 @@ export interface ExcalidrawProps {
471
857
  aiEnabled?: boolean;
472
858
  showDeprecatedFonts?: boolean;
473
859
  renderScrollbars?: boolean;
860
+ viewportStatusFrame?: ViewportStatusFrame | null;
861
+ /**
862
+ * Rendered inside the UserList "who's here" dropdown (desktop) and inline
863
+ * in the mobile menu's collaborators section, below a divider. Accepts a
864
+ * render function — called with `isMobile` so hosts can render different
865
+ * UI for each surface — in addition to a plain node.
866
+ */
867
+ currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
868
+ /**
869
+ * The user being followed on the canvas, if any. Controlled by the host —
870
+ * the editor never sets it; it emits follow/unfollow intents via
871
+ * `onUserFollow` (prop or imperative API) and renders the followed
872
+ * user's avatar highlight from this value.
873
+ */
874
+ userToFollow?: UserToFollow | null;
875
+ /**
876
+ * Called before exporting to a file.
877
+ *
878
+ * Allows the host app to intercept and delay saving until async operations
879
+ * (e.g., images are loaded) complete.
880
+ *
881
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
882
+ * until the operation completes. Generator can yield progress updates.
883
+ */
884
+ onExport?: (
885
+ /** type of export. Currently we only call for JSON exports or
886
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
887
+ type: "json", data: {
888
+ elements: readonly ExcalidrawElement[];
889
+ appState: AppState;
890
+ files: BinaryFiles;
891
+ }, options: {
892
+ /** signal that gets aborted if user cancels the export (e.g. closes
893
+ * the native file picker dialog). In that case, you can either
894
+ * return immediately, or throw AbortError.
895
+ */
896
+ signal: AbortSignal;
897
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
474
898
  }
475
899
  export type SceneData = {
476
- elements?: ImportedDataState["elements"];
900
+ /** Expects normalized elements; restore imported data before updating the scene. */
901
+ elements?: readonly ExcalidrawElement[] | null;
477
902
  appState?: ImportedDataState["appState"];
478
903
  collaborators?: Map<SocketId, Collaborator>;
479
904
  captureUpdate?: CaptureUpdateActionType;
@@ -483,12 +908,21 @@ export type ExportOpts = {
483
908
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
484
909
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
485
910
  };
911
+ export type ImageOptions = Partial<{
912
+ maxWidthOrHeight: number;
913
+ maxFileSizeBytes: number;
914
+ }>;
486
915
  export type CanvasActions = Partial<{
487
916
  changeViewBackgroundColor: boolean;
488
917
  clearCanvas: boolean;
489
918
  export: false | ExportOpts;
490
919
  loadScene: boolean;
491
920
  saveToActiveFile: boolean;
921
+ /**
922
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
923
+ * is supplied (at which point the theme is considered as host-app controlled),
924
+ * else default to false
925
+ * */
492
926
  toggleTheme: boolean | null;
493
927
  saveAsImage: boolean;
494
928
  }>;
@@ -498,6 +932,11 @@ export type UIOptions = Partial<{
498
932
  tools: {
499
933
  image: boolean;
500
934
  };
935
+ /**
936
+ * Optionally control the editor form factor and desktop UI mode from the host app.
937
+ * If not provided, we will take care of it internally.
938
+ */
939
+ getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
501
940
  /** @deprecated does nothing. Will be removed in 0.15 */
502
941
  welcomeScreen?: boolean;
503
942
  }>;
@@ -507,6 +946,7 @@ export type AppProps = Merge<ExcalidrawProps, {
507
946
  export: ExportOpts;
508
947
  };
509
948
  }>;
949
+ imageOptions: Required<ImageOptions>;
510
950
  detectScroll: boolean;
511
951
  handleKeyboardGlobally: boolean;
512
952
  isCollaborating: boolean;
@@ -518,6 +958,10 @@ export type AppProps = Merge<ExcalidrawProps, {
518
958
  export type AppClassProperties = {
519
959
  props: AppProps;
520
960
  state: AppState;
961
+ readonly ownerDocument: Document;
962
+ readonly ownerWindow: Window & typeof globalThis;
963
+ api: App["api"];
964
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
521
965
  interactiveCanvas: HTMLCanvasElement | null;
522
966
  /** static canvas */
523
967
  canvas: HTMLCanvasElement;
@@ -528,16 +972,15 @@ export type AppClassProperties = {
528
972
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
529
973
  }>;
530
974
  files: BinaryFiles;
531
- device: App["device"];
975
+ editorInterface: App["editorInterface"];
532
976
  scene: App["scene"];
533
977
  syncActionResult: App["syncActionResult"];
534
978
  fonts: App["fonts"];
535
- pasteFromClipboard: App["pasteFromClipboard"];
979
+ clipboard: App["clipboard"];
536
980
  id: App["id"];
537
981
  onInsertElements: App["onInsertElements"];
538
982
  onExportImage: App["onExportImage"];
539
- lastViewportPosition: App["lastViewportPosition"];
540
- scrollToContent: App["scrollToContent"];
983
+ viewport: App["viewport"];
541
984
  addFiles: App["addFiles"];
542
985
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
543
986
  togglePenMode: App["togglePenMode"];
@@ -548,16 +991,37 @@ export type AppClassProperties = {
548
991
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
549
992
  getName: App["getName"];
550
993
  dismissLinearEditor: App["dismissLinearEditor"];
551
- flowChartCreator: App["flowChartCreator"];
994
+ flowchart: App["flowchart"];
995
+ drawShape: App["drawShape"];
996
+ arrowText: App["arrowText"];
997
+ textTool: App["textTool"];
998
+ cursor: App["cursor"];
999
+ bucketFill: App["bucketFill"];
1000
+ duplicate: App["duplicate"];
1001
+ toolDrag: App["toolDrag"];
1002
+ activeResizeHandle: App["activeResizeHandle"];
1003
+ selectionTool: App["selectionTool"];
1004
+ wrap: App["wrap"];
1005
+ modifiers: App["modifiers"];
1006
+ isToolLocked: App["isToolLocked"];
552
1007
  getEffectiveGridSize: App["getEffectiveGridSize"];
553
1008
  setPlugins: App["setPlugins"];
554
1009
  plugins: App["plugins"];
555
- getEditorUIOffsets: App["getEditorUIOffsets"];
556
1010
  visibleElements: App["visibleElements"];
557
1011
  excalidrawContainerValue: App["excalidrawContainerValue"];
558
1012
  onPointerUpEmitter: App["onPointerUpEmitter"];
559
1013
  updateEditorAtom: App["updateEditorAtom"];
560
- defaultSelectionTool: "selection" | "lasso";
1014
+ onPointerDownEmitter: App["onPointerDownEmitter"];
1015
+ onEvent: App["onEvent"];
1016
+ onStateChange: App["onStateChange"];
1017
+ lastPointerMoveCoords: App["lastPointerMoveCoords"];
1018
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
1019
+ bindModeHandler: App["bindModeHandler"];
1020
+ emitUserFollowIntent: App["emitUserFollowIntent"];
1021
+ requestUnfollow: App["requestUnfollow"];
1022
+ setAppState: App["setAppState"];
1023
+ isInteractionEnabled: App["isInteractionEnabled"];
1024
+ isNavigationEnabled: App["isNavigationEnabled"];
561
1025
  };
562
1026
  export type PointerDownState = Readonly<{
563
1027
  origin: Readonly<{
@@ -591,8 +1055,12 @@ export type PointerDownState = Readonly<{
591
1055
  element: NonDeleted<ExcalidrawElement> | null;
592
1056
  allHitElements: NonDeleted<ExcalidrawElement>[];
593
1057
  wasAddedToSelection: boolean;
1058
+ cycleTarget: NonDeleted<ExcalidrawElement> | null;
594
1059
  hasBeenDuplicated: boolean;
1060
+ advancedListMarkers: readonly ListMarkerAdvance[];
1061
+ editedTextId: ExcalidrawTextElement["id"] | null;
595
1062
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
1063
+ arrowLabel: boolean;
596
1064
  };
597
1065
  withCmdOrCtrl: boolean;
598
1066
  drag: {
@@ -605,6 +1073,10 @@ export type PointerDownState = Readonly<{
605
1073
  x: number;
606
1074
  y: number;
607
1075
  };
1076
+ lastOffset: {
1077
+ x: number;
1078
+ y: number;
1079
+ };
608
1080
  blockDragging: boolean;
609
1081
  };
610
1082
  eventListeners: {
@@ -618,7 +1090,18 @@ export type PointerDownState = Readonly<{
618
1090
  };
619
1091
  }>;
620
1092
  export type UnsubscribeCallback = () => void;
1093
+ export type ExcalidrawMountPayload = {
1094
+ excalidrawAPI: ExcalidrawImperativeAPI;
1095
+ container: HTMLDivElement | null;
1096
+ };
1097
+ export type ExcalidrawImperativeAPIEventMap = {
1098
+ "editor:mount": [payload: ExcalidrawMountPayload];
1099
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
1100
+ "editor:unmount": [];
1101
+ };
621
1102
  export interface ExcalidrawImperativeAPI {
1103
+ /** Whether the editor has been unmounted and the API is no longer usable. */
1104
+ isDestroyed: boolean;
622
1105
  updateScene: InstanceType<typeof App>["updateScene"];
623
1106
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
624
1107
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -629,20 +1112,53 @@ export interface ExcalidrawImperativeAPI {
629
1112
  history: {
630
1113
  clear: InstanceType<typeof App>["resetHistory"];
631
1114
  };
1115
+ /**
1116
+ * Selects elements (or their ids — one or many), adds them to or removes
1117
+ * them from the selection, or clears it — as the editor does: an element is
1118
+ * selected with its group (unless `deep`), a frame and its children aren't
1119
+ * selected at the same time, and locked elements are skipped (unless
1120
+ * `includeLocked`). Text editing and cropping end, and the link popup of a
1121
+ * lone selected element shows. Missing and deleted elements are skipped.
1122
+ *
1123
+ * By default the change is recorded for undo along with the next undoable
1124
+ * change — pass `captureUpdate` as for `updateScene()` otherwise. Like
1125
+ * `updateScene()`, it applies on the next render: read it back through
1126
+ * `onChange()` or `getAppState()` after that. Works in view mode too, where
1127
+ * the selection shows without transform handles.
1128
+ */
1129
+ selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
632
1130
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
633
1131
  getAppState: () => InstanceType<typeof App>["state"];
634
1132
  getFiles: () => InstanceType<typeof App>["files"];
635
1133
  getName: InstanceType<typeof App>["getName"];
636
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
1134
+ setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
1135
+ getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
1136
+ /**
1137
+ * Atomically replaces all transient visual overrides. Values are copied;
1138
+ * omitted IDs/fields use document values, except for inherited label offsets.
1139
+ * null clears the snapshot.
1140
+ * Repaints without document changes, history entries or onChange events;
1141
+ * an equivalent snapshot may still repaint (clearing an already clear
1142
+ * snapshot does not), so submit only when something changed.
1143
+ * Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
1144
+ * Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
1145
+ * Bound labels inherit their container's offset; offsets targeting them are
1146
+ * ignored. Label opacity remains independent. Target frame children explicitly.
1147
+ * Frame opacity still multiplies child opacity. Decorations follow their owner.
1148
+ * Exports and interactive geometry (hit tests, selection, editing) use document
1149
+ * values, including while authoring an animation preview in edit mode.
1150
+ */
1151
+ setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
637
1152
  registerAction: (action: Action) => void;
638
1153
  refresh: InstanceType<typeof App>["refresh"];
639
1154
  setToast: InstanceType<typeof App>["setToast"];
640
1155
  addFiles: (data: BinaryFileData[]) => void;
641
1156
  id: string;
642
1157
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
643
- setCursor: InstanceType<typeof App>["setCursor"];
644
- resetCursor: InstanceType<typeof App>["resetCursor"];
1158
+ setCursor: InstanceType<typeof App>["cursor"]["set"];
1159
+ resetCursor: InstanceType<typeof App>["cursor"]["reset"];
645
1160
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
1161
+ getEditorInterface: () => EditorInterface;
646
1162
  /**
647
1163
  * Disables rendering of frames (including element clipping), but currently
648
1164
  * the frames are still interactive in edit mode. As such, this API should be
@@ -655,24 +1171,14 @@ export interface ExcalidrawImperativeAPI {
655
1171
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
656
1172
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
657
1173
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
1174
+ onStateChange: InstanceType<typeof App>["onStateChange"];
1175
+ onEvent: InstanceType<typeof App>["onEvent"];
658
1176
  }
659
- export type Device = Readonly<{
660
- viewport: {
661
- isMobile: boolean;
662
- isLandscape: boolean;
663
- };
664
- editor: {
665
- isMobile: boolean;
666
- canFitSidebar: boolean;
667
- };
668
- isTouchScreen: boolean;
669
- }>;
670
1177
  export type FrameNameBounds = {
671
1178
  x: number;
672
1179
  y: number;
673
1180
  width: number;
674
1181
  height: number;
675
- angle: number;
676
1182
  };
677
1183
  export type FrameNameBoundsCache = {
678
1184
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -691,12 +1197,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
691
1197
  export type JSONValue = string | number | boolean | null | object;
692
1198
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
693
1199
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
694
- export type PendingExcalidrawElements = ExcalidrawElement[];
1200
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
695
1201
  /** Runtime gridSize value. Null indicates disabled grid. */
696
1202
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
697
1203
  export type GenerateDiagramToCode = (props: {
698
- frame: ExcalidrawMagicFrameElement;
699
- children: readonly ExcalidrawElement[];
1204
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
1205
+ children: readonly NonDeletedExcalidrawElement[];
1206
+ /**
1207
+ * Optional streaming hook. Call with the accumulated response text as it
1208
+ * streams in so the editor can progressively render the partial HTML
1209
+ * inside the generated frame.
1210
+ */
1211
+ onPartial?: (html: string) => void;
700
1212
  }) => MaybePromise<{
701
1213
  html: string;
702
1214
  }>;
@@ -706,4 +1218,103 @@ export type Offsets = Partial<{
706
1218
  bottom: number;
707
1219
  left: number;
708
1220
  }>;
709
- export {};
1221
+ /**
1222
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
1223
+ * surface that occludes the canvas. Such nodes are measured by
1224
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
1225
+ *
1226
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
1227
+ * - `side` — a panel hugging the left or right edge. Which side is not
1228
+ * declared but resolved geometrically: if the node's horizontal center
1229
+ * lies in the left half of the viewport it counts against the left
1230
+ * offset (by its right edge), otherwise against the right offset (by
1231
+ * `viewportWidth - left edge`). Measuring the rendered position instead
1232
+ * of declaring a side means RTL layouts and host-configurable docking
1233
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
1234
+ * actually hugs one edge; don't mark a centered/near-full-width node as
1235
+ * `side` (its midpoint would classify it to one side and the offset
1236
+ * would swallow most of the viewport).
1237
+ *
1238
+ * The attribute should only be present while the surface is actually
1239
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
1240
+ * push the viewport around.
1241
+ */
1242
+ export type ViewportUIDock = "top" | "bottom" | "side";
1243
+ /**
1244
+ * Options for `getViewportOffsets` (and the `ui` key of
1245
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
1246
+ * currently rendered editor UI.
1247
+ *
1248
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
1249
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
1250
+ * reading-direction start side).
1251
+ */
1252
+ export type ViewportOffsetsOptions = {
1253
+ /** padding added to each measured side (default 24) */
1254
+ padding?: number;
1255
+ paddingTop?: number;
1256
+ paddingRight?: number;
1257
+ paddingBottom?: number;
1258
+ paddingLeft?: number;
1259
+ /** final value for the given side, replacing the measured UI size
1260
+ * (padding is not added on top) */
1261
+ top?: number;
1262
+ bottom?: number;
1263
+ left?: number;
1264
+ right?: number;
1265
+ /**
1266
+ * Reserve space for the given conditionally-rendered surfaces even while
1267
+ * they're hidden, so the resulting offsets don't shift when they
1268
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
1269
+ * to an approximate default if it hasn't been rendered yet. Ignored on
1270
+ * phones (where these surfaces never occlude the canvas).
1271
+ */
1272
+ reserve?: {
1273
+ /** styles panel (rendered when a tool or selection is active) */
1274
+ stylesPanel?: boolean;
1275
+ /** sidebar (e.g. library) */
1276
+ sidebar?: boolean;
1277
+ };
1278
+ };
1279
+ /**
1280
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
1281
+ * `props.initialState.viewport`), insetting the usable viewport area per
1282
+ * side so the target isn't fitted/centered underneath overlaid UI.
1283
+ *
1284
+ * Two (combinable) ways to specify:
1285
+ *
1286
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
1287
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
1288
+ * no padding added. Sides not specified default to `0` (unless `ui` is
1289
+ * set, see below).
1290
+ *
1291
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
1292
+ * panel, sidebar...) as rendered at the time the viewport is set,
1293
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
1294
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
1295
+ * padding or reserve space for currently-hidden surfaces.
1296
+ *
1297
+ * When both are given, a static side always wins for that side — it
1298
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
1299
+ * which — unlike the physical static sides — are RTL-relative). The
1300
+ * remaining sides fall back to the `ui`-derived values.
1301
+ *
1302
+ * @example
1303
+ * { top: 40 } // top 40px, other sides 0
1304
+ * { ui: true } // measured UI + default padding
1305
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
1306
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
1307
+ */
1308
+ export type ViewportOffsets = Offsets & {
1309
+ ui?: true | ViewportOffsetsOptions;
1310
+ };
1311
+ /**
1312
+ * Value of the `data-viewport-ui-name` attribute, identifying a
1313
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1314
+ * it can be measured on its own, and so that `getViewportOffsets` can
1315
+ * reserve space for it while it's hidden (see the `reserve` option).
1316
+ * Whenever a named surface is rendered, its measured footprint is
1317
+ * remembered; reserving uses that remembered footprint, or an approximate
1318
+ * default if the surface hasn't been rendered yet.
1319
+ */
1320
+ export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";