@excalidraw/common 0.18.0-0fc927cb4 → 0.18.0-1acf66e

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 (334) hide show
  1. package/dist/dev/index.js +1702 -329
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +3 -3
  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 +59 -39
  8. package/dist/types/common/src/constants.d.ts +49 -34
  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 +1 -1
  13. package/dist/types/common/src/points.d.ts +1 -1
  14. package/dist/types/common/src/utility-types.d.ts +0 -1
  15. package/dist/types/common/src/utils.d.ts +48 -78
  16. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  17. package/dist/types/element/src/Scene.d.ts +12 -8
  18. package/dist/types/element/src/align.d.ts +2 -2
  19. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  20. package/dist/types/element/src/arrowheads.d.ts +3 -0
  21. package/dist/types/element/src/arrows/focus.d.ts +30 -0
  22. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  23. package/dist/types/element/src/binding.d.ts +79 -51
  24. package/dist/types/element/src/bounds.d.ts +26 -19
  25. package/dist/types/element/src/collision.d.ts +7 -2
  26. package/dist/types/element/src/comparisons.d.ts +8 -7
  27. package/dist/types/element/src/convertToShape.d.ts +23 -0
  28. package/dist/types/element/src/delta.d.ts +2 -2
  29. package/dist/types/element/src/distribute.d.ts +3 -2
  30. package/dist/types/element/src/dragElements.d.ts +30 -3
  31. package/dist/types/element/src/duplicate.d.ts +7 -6
  32. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  33. package/dist/types/element/src/embeddable.d.ts +2 -2
  34. package/dist/types/element/src/flowchart.d.ts +7 -7
  35. package/dist/types/element/src/fractionalIndex.d.ts +4 -4
  36. package/dist/types/element/src/frame.d.ts +16 -11
  37. package/dist/types/element/src/groups.d.ts +9 -9
  38. package/dist/types/element/src/heading.d.ts +2 -1
  39. package/dist/types/element/src/image.d.ts +1 -11
  40. package/dist/types/element/src/index.d.ts +8 -4
  41. package/dist/types/element/src/linearElementEditor.d.ts +38 -30
  42. package/dist/types/element/src/mutateElement.d.ts +5 -1
  43. package/dist/types/element/src/newElement.d.ts +20 -6
  44. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  45. package/dist/types/element/src/renderElement.d.ts +4 -10
  46. package/dist/types/element/src/resizeElements.d.ts +12 -12
  47. package/dist/types/element/src/resizeTest.d.ts +6 -5
  48. package/dist/types/element/src/selection.d.ts +14 -14
  49. package/dist/types/element/src/shape.d.ts +9 -8
  50. package/dist/types/element/src/store.d.ts +3 -2
  51. package/dist/types/element/src/textElement.d.ts +14 -11
  52. package/dist/types/element/src/textMeasurements.d.ts +1 -3
  53. package/dist/types/element/src/textWrapping.d.ts +26 -0
  54. package/dist/types/{excalidraw/data → element/src}/transform.d.ts +3 -3
  55. package/dist/types/element/src/transformHandles.d.ts +8 -27
  56. package/dist/types/element/src/typeChecks.d.ts +29 -31
  57. package/dist/types/element/src/types.d.ts +20 -14
  58. package/dist/types/element/src/utils.d.ts +9 -4
  59. package/dist/types/element/src/zindex.d.ts +7 -1
  60. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +191 -213
  61. package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
  62. package/dist/types/excalidraw/actions/actionBoundText.d.ts +112 -127
  63. package/dist/types/excalidraw/actions/actionCanvas.d.ts +447 -1585
  64. package/dist/types/excalidraw/actions/actionClipboard.d.ts +139 -895
  65. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +54 -62
  66. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +180 -205
  67. package/dist/types/excalidraw/actions/actionDeselect.d.ts +162 -0
  68. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
  69. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
  70. package/dist/types/excalidraw/actions/actionElementLink.d.ts +61 -75
  71. package/dist/types/excalidraw/actions/actionElementLock.d.ts +111 -126
  72. package/dist/types/excalidraw/actions/actionExport.d.ts +189 -1409
  73. package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
  74. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
  75. package/dist/types/excalidraw/actions/actionFrame.d.ts +292 -537
  76. package/dist/types/excalidraw/actions/actionGroup.d.ts +122 -145
  77. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +193 -237
  78. package/dist/types/excalidraw/actions/actionLink.d.ts +67 -75
  79. package/dist/types/excalidraw/actions/actionMenu.d.ts +56 -436
  80. package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -359
  81. package/dist/types/excalidraw/actions/actionProperties.d.ts +191 -2527
  82. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +61 -73
  83. package/dist/types/excalidraw/actions/actionStyles.d.ts +54 -61
  84. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
  85. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +178 -0
  86. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +69 -78
  87. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +178 -0
  88. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +68 -76
  89. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +57 -72
  90. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
  91. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +67 -75
  92. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +68 -76
  93. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +68 -76
  94. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
  95. package/dist/types/excalidraw/actions/index.d.ts +5 -3
  96. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  97. package/dist/types/excalidraw/actions/register.d.ts +2 -2
  98. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  99. package/dist/types/excalidraw/actions/types.d.ts +11 -7
  100. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  101. package/dist/types/excalidraw/appState.d.ts +46 -37
  102. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  103. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  104. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  105. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  106. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  107. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  108. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  109. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  110. package/dist/types/excalidraw/clipboard.d.ts +59 -21
  111. package/dist/types/excalidraw/components/Actions.d.ts +33 -11
  112. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  113. package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
  114. package/dist/types/excalidraw/components/App.cursor.d.ts +31 -0
  115. package/dist/types/excalidraw/components/App.d.ts +447 -122
  116. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  117. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  118. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  119. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  120. package/dist/types/excalidraw/components/Card.d.ts +1 -3
  121. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
  122. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -3
  123. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  124. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  125. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  126. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
  127. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
  128. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  129. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  130. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
  131. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -4
  132. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  133. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  134. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
  135. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  136. package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
  137. package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
  138. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
  139. package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
  140. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  141. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  142. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
  143. package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
  144. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  145. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  146. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  147. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  148. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  149. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  150. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  151. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  152. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  153. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
  154. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  155. package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
  156. package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
  157. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  158. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  159. package/dist/types/excalidraw/components/MobileMenu.d.ts +5 -7
  160. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  161. package/dist/types/excalidraw/components/Modal.d.ts +0 -1
  162. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
  163. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  164. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  165. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  166. package/dist/types/excalidraw/components/Popover.d.ts +2 -3
  167. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
  168. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  169. package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
  170. package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
  171. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  172. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  173. package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
  174. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  175. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
  176. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
  177. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
  178. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
  179. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
  180. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
  181. package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
  182. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  183. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
  184. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
  185. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  186. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
  187. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  188. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  189. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  190. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  191. package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
  192. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  193. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
  194. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
  195. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
  196. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
  197. package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
  198. package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
  199. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  200. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
  201. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
  202. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
  203. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  204. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  205. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
  206. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
  207. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
  208. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
  209. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
  210. package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
  211. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
  212. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
  213. package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
  214. package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
  215. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
  216. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  217. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
  218. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
  219. package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
  220. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  221. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  222. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
  223. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  224. package/dist/types/excalidraw/components/Toast.d.ts +11 -7
  225. package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
  226. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  227. package/dist/types/excalidraw/components/Tools.d.ts +145 -0
  228. package/dist/types/excalidraw/components/Trans.d.ts +2 -2
  229. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +10 -4
  230. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  231. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  232. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +47 -35
  233. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
  234. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
  235. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
  236. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  237. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
  238. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
  239. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
  240. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
  241. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  242. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  243. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  244. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
  245. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
  246. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  247. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  248. package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
  249. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  250. package/dist/types/excalidraw/components/icons.d.ts +52 -22
  251. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
  252. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
  253. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  254. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  255. package/dist/types/excalidraw/data/blob.d.ts +339 -12
  256. package/dist/types/excalidraw/data/encode.d.ts +4 -4
  257. package/dist/types/excalidraw/data/encryption.d.ts +5 -5
  258. package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
  259. package/dist/types/excalidraw/data/index.d.ts +8 -9
  260. package/dist/types/excalidraw/data/json.d.ts +175 -3
  261. package/dist/types/excalidraw/data/library.d.ts +25 -10
  262. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  263. package/dist/types/excalidraw/data/restore.d.ts +25 -10
  264. package/dist/types/excalidraw/data/types.d.ts +4 -1
  265. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  266. package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
  267. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  268. package/dist/types/excalidraw/errors.d.ts +14 -0
  269. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  270. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +2 -2
  271. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +4 -3
  272. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
  273. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  274. package/dist/types/excalidraw/i18n.d.ts +2 -2
  275. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  276. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  277. package/dist/types/excalidraw/renderer/animation.d.ts +16 -0
  278. package/dist/types/excalidraw/renderer/helpers.d.ts +6 -8
  279. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
  280. package/dist/types/excalidraw/scene/Renderer.d.ts +428 -18
  281. package/dist/types/excalidraw/scene/export.d.ts +4 -4
  282. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  283. package/dist/types/excalidraw/scene/types.d.ts +26 -8
  284. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  285. package/dist/types/excalidraw/snapping.d.ts +12 -12
  286. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
  287. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
  288. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
  289. package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
  290. package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
  291. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  292. package/dist/types/excalidraw/types.d.ts +487 -50
  293. package/dist/types/excalidraw/viewport.d.ts +272 -0
  294. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +8 -5
  295. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  296. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  297. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  298. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  299. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  300. package/dist/types/math/src/constants.d.ts +0 -1
  301. package/dist/types/math/src/curve.d.ts +4 -1
  302. package/dist/types/math/src/index.d.ts +1 -0
  303. package/dist/types/math/src/pca.d.ts +79 -0
  304. package/dist/types/math/src/point.d.ts +8 -2
  305. package/dist/types/math/src/polygon.d.ts +26 -2
  306. package/dist/types/math/src/range.d.ts +1 -3
  307. package/dist/types/math/src/segment.d.ts +4 -3
  308. package/dist/types/math/src/types.d.ts +25 -1
  309. package/dist/types/utils/src/export.d.ts +8 -8
  310. package/dist/types/utils/src/index.d.ts +1 -2
  311. package/dist/types/utils/src/shape.d.ts +6 -6
  312. package/package.json +7 -1
  313. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -185
  314. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  315. package/dist/types/excalidraw/charts.d.ts +0 -27
  316. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  317. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
  318. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  319. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  320. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -9
  321. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  322. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
  323. package/dist/types/excalidraw/components/shapes.d.ts +0 -62
  324. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  325. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  326. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -85
  327. package/dist/types/excalidraw/cursor.d.ts +0 -5
  328. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  329. package/dist/types/excalidraw/index.d.ts +0 -47
  330. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  331. package/dist/types/excalidraw/scene/scroll.d.ts +0 -23
  332. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  333. package/dist/types/utils/src/bbox.d.ts +0 -9
  334. 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
3
  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";
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
6
  import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } 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" | "embeddable" | "laser" | "autoshape";
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
+ hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];
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,42 @@ export type ObservedElementsAppState = {
163
175
  lockedMultiSelections: AppState["lockedMultiSelections"];
164
176
  activeLockedId: AppState["activeLockedId"];
165
177
  };
178
+ export type BoxSelectionMode = "contain" | "overlap";
179
+ /**
180
+ * A box, in scene coordinates, that pan & zoom are constrained to.
181
+ *
182
+ * This is a private type. For public API, only use specific properties,
183
+ * needed.
184
+ */
185
+ export type ScrollConstraints = {
186
+ x: number;
187
+ y: number;
188
+ width: number;
189
+ height: number;
190
+ /** when set, panning is constrained so the viewport stays within the box */
191
+ lockScroll: boolean;
192
+ /** when set, the viewport cannot zoom out below `zoom` */
193
+ lockZoom: boolean;
194
+ /**
195
+ * The zoom resolved after the `setViewport` navigation settled.
196
+ */
197
+ zoom: number;
198
+ /**
199
+ * Pixel amount the viewport may overscroll past its resting clamp before
200
+ * snapping back (rubberband). Screen pixels, zoom-independent. Resolved
201
+ * from `lock.overscroll` at the time the lock was installed (`true` →
202
+ * default give, `false` → 0).
203
+ */
204
+ overscroll: number;
205
+ /**
206
+ * Extra scrollable margin around the box (CSS-style), letting the viewport
207
+ * scroll past each box edge to reveal that much empty space. Values are
208
+ * viewport pixels and zoom-independent (a fixed on-screen distance).
209
+ * Resolved from the `offsets` passed to `setViewport` (see
210
+ * {@link ViewportOffsets}) at the time the lock was installed.
211
+ */
212
+ offsets?: Offsets;
213
+ };
166
214
  export interface AppState {
167
215
  contextMenu: {
168
216
  items: ContextMenuItems;
@@ -196,9 +244,34 @@ export interface AppState {
196
244
  * - set on pointer down, updated during pointer move
197
245
  */
198
246
  selectionElement: NonDeletedExcalidrawElement | null;
247
+ /**
248
+ * tracking current arrow binding editor state (takes into account
249
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
250
+ */
199
251
  isBindingEnabled: boolean;
200
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
201
- suggestedBindings: SuggestedBinding[];
252
+ /** user box selection preference; defaults to "contain" when unset */
253
+ boxSelectionMode: BoxSelectionMode;
254
+ /** user arrow binding preference */
255
+ bindingPreference: "enabled" | "disabled";
256
+ /** user preference whether arrow snap to midpoints while binding */
257
+ isMidpointSnappingEnabled: boolean;
258
+ /**
259
+ * The bindable element the UI highlights for the user when an arrow is
260
+ * dragged or otherwise its endpoint being close to said element.
261
+ */
262
+ suggestedBinding: {
263
+ element: NonDeleted<ExcalidrawBindableElement>;
264
+ midPoint?: GlobalPoint;
265
+ } | null;
266
+ /**
267
+ * Where on a hovered arrow the text tool would attach text if clicked —
268
+ * a free endpoint (binds the arrow to a new text element positioned against
269
+ * that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
270
+ */
271
+ hoveredArrowTextAnchor: {
272
+ elementId: ExcalidrawArrowElement["id"];
273
+ anchor: "start" | "end" | "label";
274
+ } | null;
202
275
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
203
276
  frameRendering: {
204
277
  enabled: boolean;
@@ -206,12 +279,15 @@ export interface AppState {
206
279
  outline: boolean;
207
280
  clip: boolean;
208
281
  };
209
- editingFrame: string | null;
210
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
282
+ /**
283
+ * frame-like element whose name is currently being edited
284
+ */
285
+ editingFrame: ExcalidrawFrameLikeElement["id"] | null;
286
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
211
287
  /**
212
288
  * set when a new text is created or when an existing text is being edited
213
289
  */
214
- editingTextElement: NonDeletedExcalidrawElement | null;
290
+ editingTextElement: ExcalidrawTextElement | null;
215
291
  activeTool: {
216
292
  /**
217
293
  * indicates a previous tool we should revert back to if we deselect the
@@ -221,6 +297,10 @@ export interface AppState {
221
297
  locked: boolean;
222
298
  fromSelection: boolean;
223
299
  } & ActiveTool;
300
+ preferredSelectionTool: {
301
+ type: "selection" | "lasso";
302
+ initialized: boolean;
303
+ };
224
304
  penMode: boolean;
225
305
  penDetected: boolean;
226
306
  exportBackground: boolean;
@@ -230,9 +310,10 @@ export interface AppState {
230
310
  currentItemStrokeColor: string;
231
311
  currentItemBackgroundColor: string;
232
312
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
233
- currentItemStrokeWidth: number;
313
+ currentItemStrokeWidthKey: StrokeWidthKey;
234
314
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
235
315
  currentItemRoughness: number;
316
+ currentItemStrokeVariability: StrokeVariability;
236
317
  currentItemOpacity: number;
237
318
  currentItemFontFamily: FontFamilyValues;
238
319
  currentItemFontSize: number;
@@ -245,14 +326,15 @@ export interface AppState {
245
326
  viewBackgroundColor: string;
246
327
  scrollX: number;
247
328
  scrollY: number;
329
+ scrollConstraints: ScrollConstraints | null;
248
330
  cursorButton: "up" | "down";
249
331
  scrolledOutside: boolean;
250
332
  name: string | null;
251
333
  isResizing: boolean;
252
334
  isRotating: boolean;
253
335
  zoom: Zoom;
254
- openMenu: "canvas" | "shape" | null;
255
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
336
+ openMenu: "canvas" | null;
337
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
256
338
  openSidebar: {
257
339
  name: SidebarName;
258
340
  tab?: SidebarTabName;
@@ -264,9 +346,15 @@ export interface AppState {
264
346
  tab: "text-to-diagram" | "mermaid";
265
347
  } | {
266
348
  name: "commandPalette";
349
+ } | {
350
+ name: "settings";
267
351
  } | {
268
352
  name: "elementLinkSelector";
269
353
  sourceElementId: ExcalidrawElement["id"];
354
+ } | {
355
+ name: "charts";
356
+ data: Spreadsheet;
357
+ rawText: string;
270
358
  };
271
359
  /**
272
360
  * Reflects user preference for whether the default sidebar should be docked.
@@ -289,7 +377,7 @@ export interface AppState {
289
377
  selectedElementsAreBeingDragged: boolean;
290
378
  shouldCacheIgnoreZoom: boolean;
291
379
  toast: {
292
- message: string;
380
+ message: React.ReactNode;
293
381
  closable?: boolean;
294
382
  duration?: number;
295
383
  } | null;
@@ -311,21 +399,13 @@ export interface AppState {
311
399
  height: number;
312
400
  offsetTop: number;
313
401
  offsetLeft: number;
314
- fileHandle: FileSystemHandle | null;
402
+ fileHandle: FileSystemFileHandle | null;
315
403
  collaborators: Map<SocketId, Collaborator>;
316
404
  stats: {
317
405
  open: boolean;
318
406
  /** bitmap. Use `STATS_PANELS` bit values */
319
407
  panels: number;
320
408
  };
321
- currentChartType: ChartType;
322
- pasteDialog: {
323
- shown: false;
324
- data: null;
325
- } | {
326
- shown: true;
327
- data: Spreadsheet;
328
- };
329
409
  showHyperlinkPopup: false | "info" | "editor";
330
410
  selectedLinearElement: LinearElementEditor | null;
331
411
  snapLines: readonly SnapLine[];
@@ -351,6 +431,7 @@ export interface AppState {
351
431
  lockedMultiSelections: {
352
432
  [groupId: string]: true;
353
433
  };
434
+ bindMode: BindMode;
354
435
  }
355
436
  export type SearchMatch = {
356
437
  id: string;
@@ -363,7 +444,7 @@ export type SearchMatch = {
363
444
  showOnCanvas: boolean;
364
445
  }[];
365
446
  };
366
- export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
447
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
367
448
  export type NormalizedZoomValue = number & {
368
449
  _brand: "normalizedZoom";
369
450
  };
@@ -407,15 +488,150 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
407
488
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
408
489
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
409
490
  }>;
491
+ export type ExcalidrawInitialState = {
492
+ viewport?: Omit<SetViewportOptions, "animation">;
493
+ };
410
494
  export type OnUserFollowedPayload = {
411
495
  userToFollow: UserToFollow;
412
496
  action: "FOLLOW" | "UNFOLLOW";
413
497
  };
498
+ export type OnExportProgress = {
499
+ type: "progress";
500
+ message?: React.ReactNode;
501
+ /** 0-1 range */
502
+ progress?: number;
503
+ };
504
+ export type InteractionConfig = {
505
+ /**
506
+ * Interactions that stay enabled while the editor is otherwise
507
+ * non-interactive. Opt-in: anything omitted or `false` is disabled.
508
+ */
509
+ enabled?: {
510
+ /**
511
+ * Element links render their link icon and stay clickable — clicking
512
+ * anywhere on a linked element opens the link, same as in view mode.
513
+ * When disabled, link icons are not rendered at all.
514
+ *
515
+ * @default false
516
+ */
517
+ links?: boolean;
518
+ /**
519
+ * Embeddable & iframe elements stay interactive — hovering & clicking
520
+ * activates them so their content can be used, same as in view mode.
521
+ *
522
+ * @default false
523
+ */
524
+ embeds?: boolean;
525
+ /**
526
+ * Umbrella for all interactive content on canvas — shorthand for
527
+ * enabling `links` & `embeds` (and future interactive content kinds)
528
+ * together. Additive: `interactiveContent: true` enables them
529
+ * regardless of their individual values.
530
+ *
531
+ * @default false
532
+ */
533
+ interactiveContent?: boolean;
534
+ /**
535
+ * Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
536
+ * and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
537
+ * zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
538
+ * mode. Respects `appState.scrollConstraints` if set, so it composes
539
+ * with viewport locking. The rest of the keyboard stays disabled. Note
540
+ * the editor consumes wheel & touch input again when enabled, so the
541
+ * page no longer scrolls over the editor.
542
+ *
543
+ * @default false
544
+ */
545
+ navigation?: boolean;
546
+ /**
547
+ * Whether the browser's own zoom remains available over the editor —
548
+ * ctrl/cmd + wheel, pinch, and (while the editor has focus)
549
+ * ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
550
+ * interactive editor. Regular page scrolling stays available either way.
551
+ * With `navigation` enabled, the zoom input (wheel, pinch, keyboard
552
+ * shortcuts) zooms the canvas instead either way, making this moot.
553
+ *
554
+ * @default false
555
+ */
556
+ browserZoom?: boolean;
557
+ /**
558
+ * Tools that stay user-driven while the editor is otherwise
559
+ * non-interactive: pointer input keeps driving the listed tool when it's
560
+ * the active tool. Does not enable user-driven tool *switching* — the
561
+ * keyboard stays disabled and tool selection remains host-driven
562
+ * (`ExcalidrawAPI.setActiveTool`).
563
+ *
564
+ * Composes with `navigation`: the enabled tool wins the primary-pointer
565
+ * drag, while wheel input (and wheel-button drag) still pans/zooms.
566
+ */
567
+ tools?: {
568
+ /**
569
+ * The laser pointer stays usable — pointer strokes draw laser trails
570
+ * and pointer positions keep broadcasting via `onPointerUpdate`, so
571
+ * e.g. collaborators see a presenter's laser & cursor.
572
+ *
573
+ * @default false
574
+ */
575
+ laser?: boolean;
576
+ /**
577
+ * Custom tools (`activeTool.type === "custom"`) stay usable — the
578
+ * editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
579
+ * Tool behavior is host-implemented; activate custom tools with
580
+ * `locked: true` or they revert to the selection tool (and go inert)
581
+ * after the first pointer interaction.
582
+ *
583
+ * @default false
584
+ */
585
+ custom?: boolean;
586
+ };
587
+ };
588
+ };
589
+ export type UIConfig = {
590
+ /**
591
+ * Default UI controls that stay enabled while the rest of Excalidraw's
592
+ * default UI is hidden. Opt-in: anything omitted or `false` is disabled.
593
+ */
594
+ enabled: {
595
+ /**
596
+ * The zoom-out, reset-zoom, and zoom-in controls.
597
+ *
598
+ * @default false
599
+ */
600
+ zoom?: boolean;
601
+ /**
602
+ * The button shown when the viewport is scrolled away from all content.
603
+ *
604
+ * @default false
605
+ */
606
+ scrollBackToContent?: boolean;
607
+ };
608
+ };
414
609
  export interface ExcalidrawProps {
415
610
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
611
+ onThemeChange?: (theme: Theme | "system") => void;
612
+ /**
613
+ * note: only subscribes if the props.onIncrement is defined on initial render
614
+ */
416
615
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
417
616
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
418
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
617
+ initialState?: ExcalidrawInitialState;
618
+ /**
619
+ * Invoked as soon as the Excalidraw API is available
620
+ * NOTE editor is not yet mounted, and state is not yet initialized
621
+ */
622
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
623
+ /**
624
+ * Invoked once the editor root is mounted.
625
+ */
626
+ onMount?: (payload: ExcalidrawMountPayload) => void;
627
+ /**
628
+ * Invoked when the editor root is unmounted.
629
+ */
630
+ onUnmount?: () => void;
631
+ /**
632
+ * Invoked once the initial scene is loaded.
633
+ */
634
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
419
635
  isCollaborating?: boolean;
420
636
  onPointerUpdate?: (payload: {
421
637
  pointer: {
@@ -441,9 +657,74 @@ export interface ExcalidrawProps {
441
657
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
442
658
  /** excludes the duplicated elements */
443
659
  prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
660
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
444
661
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
445
662
  langCode?: Language["code"];
446
663
  viewModeEnabled?: boolean;
664
+ /**
665
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
666
+ * clipboard, drag&drop). When `false`, the scene still renders and reacts
667
+ * to programmatic updates (imperative API), but the user cannot affect it
668
+ * in any way. Implies view mode.
669
+ *
670
+ * Pass a config object to keep specific interactions enabled while the
671
+ * editor is otherwise non-interactive (see `InteractionConfig`):
672
+ *
673
+ * ```tsx
674
+ * <Excalidraw interaction={{ enabled: { links: true } }} />
675
+ * ```
676
+ *
677
+ * @default true
678
+ */
679
+ interaction?: boolean | InteractionConfig;
680
+ /**
681
+ * Whether Excalidraw's default UI is rendered — toolbar, default menus,
682
+ * footer controls, sidebars, and canvas popups. Host UI passed through
683
+ * children (including exported components such as `MainMenu` and `Footer`)
684
+ * or render props continues to render, together with any supporting dialogs
685
+ * it opens.
686
+ *
687
+ * Canvas content (elements, text editing surface, frame names, embeds) still
688
+ * renders, and the editor remains interactive unless `interaction` is set to
689
+ * `false`.
690
+ *
691
+ * Pass a config object to keep specific default controls rendered while the
692
+ * rest of the default UI is hidden (see `UIConfig`):
693
+ *
694
+ * ```tsx
695
+ * <Excalidraw ui={{ enabled: { zoom: true } }} />
696
+ * ```
697
+ *
698
+ * NOTE: this is WIP and what default UI is/is not rendered when ui=false
699
+ * may yet change.
700
+ *
701
+ * @default true
702
+ */
703
+ ui?: boolean | UIConfig;
704
+ /**
705
+ * Forces the active editor tool (controlled). While set, user- and
706
+ * API-driven tool switching is ignored — `setActiveTool` refuses with a
707
+ * console warning, non-forced toolbar buttons render disabled — and the
708
+ * editor snaps back if internal flows reset the tool. The forced tool
709
+ * behaves as if locked (see the tool lock / padlock): it doesn't revert to
710
+ * the selection tool after use, and elements drawn with it aren't
711
+ * auto-selected — without mutating `appState.activeTool.locked`, so the
712
+ * user's persisted padlock preference stays untouched. Unset to return
713
+ * tool control to the editor (the current tool stays active).
714
+ *
715
+ * The forced tool must be activatable to take effect: not disabled via
716
+ * `UIOptions.tools`, and — while the editor is non-interactive — allowed
717
+ * via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
718
+ * non-interactive, resets to) the `selection` tool, and the forced tool is
719
+ * applied once it becomes activatable. `image` cannot be forced (its
720
+ * activation opens the file picker).
721
+ */
722
+ activeTool?: {
723
+ type: Exclude<ToolType, "image">;
724
+ } | {
725
+ type: "custom";
726
+ customType: string;
727
+ };
447
728
  zenModeEnabled?: boolean;
448
729
  gridModeEnabled?: boolean;
449
730
  objectsSnapModeEnabled?: boolean;
@@ -452,6 +733,10 @@ export interface ExcalidrawProps {
452
733
  name?: string;
453
734
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
454
735
  UIOptions?: Partial<UIOptions>;
736
+ /**
737
+ * dimensions and size constraints for inserted images
738
+ */
739
+ imageOptions?: ImageOptions;
455
740
  detectScroll?: boolean;
456
741
  handleKeyboardGlobally?: boolean;
457
742
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -471,6 +756,29 @@ export interface ExcalidrawProps {
471
756
  aiEnabled?: boolean;
472
757
  showDeprecatedFonts?: boolean;
473
758
  renderScrollbars?: boolean;
759
+ /**
760
+ * Called before exporting to a file.
761
+ *
762
+ * Allows the host app to intercept and delay saving until async operations
763
+ * (e.g., images are loaded) complete.
764
+ *
765
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
766
+ * until the operation completes. Generator can yield progress updates.
767
+ */
768
+ onExport?: (
769
+ /** type of export. Currently we only call for JSON exports or
770
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
771
+ type: "json", data: {
772
+ elements: readonly ExcalidrawElement[];
773
+ appState: AppState;
774
+ files: BinaryFiles;
775
+ }, options: {
776
+ /** signal that gets aborted if user cancels the export (e.g. closes
777
+ * the native file picker dialog). In that case, you can either
778
+ * return immediately, or throw AbortError.
779
+ */
780
+ signal: AbortSignal;
781
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
474
782
  }
475
783
  export type SceneData = {
476
784
  elements?: ImportedDataState["elements"];
@@ -483,12 +791,21 @@ export type ExportOpts = {
483
791
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
484
792
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
485
793
  };
794
+ export type ImageOptions = Partial<{
795
+ maxWidthOrHeight: number;
796
+ maxFileSizeBytes: number;
797
+ }>;
486
798
  export type CanvasActions = Partial<{
487
799
  changeViewBackgroundColor: boolean;
488
800
  clearCanvas: boolean;
489
801
  export: false | ExportOpts;
490
802
  loadScene: boolean;
491
803
  saveToActiveFile: boolean;
804
+ /**
805
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
806
+ * is supplied (at which point the theme is considered as host-app controlled),
807
+ * else default to false
808
+ * */
492
809
  toggleTheme: boolean | null;
493
810
  saveAsImage: boolean;
494
811
  }>;
@@ -498,6 +815,11 @@ export type UIOptions = Partial<{
498
815
  tools: {
499
816
  image: boolean;
500
817
  };
818
+ /**
819
+ * Optionally control the editor form factor and desktop UI mode from the host app.
820
+ * If not provided, we will take care of it internally.
821
+ */
822
+ getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
501
823
  /** @deprecated does nothing. Will be removed in 0.15 */
502
824
  welcomeScreen?: boolean;
503
825
  }>;
@@ -507,6 +829,7 @@ export type AppProps = Merge<ExcalidrawProps, {
507
829
  export: ExportOpts;
508
830
  };
509
831
  }>;
832
+ imageOptions: Required<ImageOptions>;
510
833
  detectScroll: boolean;
511
834
  handleKeyboardGlobally: boolean;
512
835
  isCollaborating: boolean;
@@ -518,6 +841,8 @@ export type AppProps = Merge<ExcalidrawProps, {
518
841
  export type AppClassProperties = {
519
842
  props: AppProps;
520
843
  state: AppState;
844
+ api: App["api"];
845
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
521
846
  interactiveCanvas: HTMLCanvasElement | null;
522
847
  /** static canvas */
523
848
  canvas: HTMLCanvasElement;
@@ -528,7 +853,7 @@ export type AppClassProperties = {
528
853
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
529
854
  }>;
530
855
  files: BinaryFiles;
531
- device: App["device"];
856
+ editorInterface: App["editorInterface"];
532
857
  scene: App["scene"];
533
858
  syncActionResult: App["syncActionResult"];
534
859
  fonts: App["fonts"];
@@ -536,8 +861,7 @@ export type AppClassProperties = {
536
861
  id: App["id"];
537
862
  onInsertElements: App["onInsertElements"];
538
863
  onExportImage: App["onExportImage"];
539
- lastViewportPosition: App["lastViewportPosition"];
540
- scrollToContent: App["scrollToContent"];
864
+ viewport: App["viewport"];
541
865
  addFiles: App["addFiles"];
542
866
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
543
867
  togglePenMode: App["togglePenMode"];
@@ -548,15 +872,26 @@ export type AppClassProperties = {
548
872
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
549
873
  getName: App["getName"];
550
874
  dismissLinearEditor: App["dismissLinearEditor"];
551
- flowChartCreator: App["flowChartCreator"];
875
+ flowchart: App["flowchart"];
876
+ drawShape: App["drawShape"];
877
+ cursor: App["cursor"];
878
+ isToolLocked: App["isToolLocked"];
552
879
  getEffectiveGridSize: App["getEffectiveGridSize"];
553
880
  setPlugins: App["setPlugins"];
554
881
  plugins: App["plugins"];
555
- getEditorUIOffsets: App["getEditorUIOffsets"];
556
882
  visibleElements: App["visibleElements"];
557
883
  excalidrawContainerValue: App["excalidrawContainerValue"];
558
884
  onPointerUpEmitter: App["onPointerUpEmitter"];
559
885
  updateEditorAtom: App["updateEditorAtom"];
886
+ onPointerDownEmitter: App["onPointerDownEmitter"];
887
+ onEvent: App["onEvent"];
888
+ onStateChange: App["onStateChange"];
889
+ lastPointerMoveCoords: App["lastPointerMoveCoords"];
890
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
891
+ bindModeHandler: App["bindModeHandler"];
892
+ setAppState: App["setAppState"];
893
+ isInteractionEnabled: App["isInteractionEnabled"];
894
+ isNavigationEnabled: App["isNavigationEnabled"];
560
895
  };
561
896
  export type PointerDownState = Readonly<{
562
897
  origin: Readonly<{
@@ -604,6 +939,7 @@ export type PointerDownState = Readonly<{
604
939
  x: number;
605
940
  y: number;
606
941
  };
942
+ blockDragging: boolean;
607
943
  };
608
944
  eventListeners: {
609
945
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -616,7 +952,18 @@ export type PointerDownState = Readonly<{
616
952
  };
617
953
  }>;
618
954
  export type UnsubscribeCallback = () => void;
955
+ export type ExcalidrawMountPayload = {
956
+ excalidrawAPI: ExcalidrawImperativeAPI;
957
+ container: HTMLDivElement | null;
958
+ };
959
+ export type ExcalidrawImperativeAPIEventMap = {
960
+ "editor:mount": [payload: ExcalidrawMountPayload];
961
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
962
+ "editor:unmount": [];
963
+ };
619
964
  export interface ExcalidrawImperativeAPI {
965
+ /** Whether the editor has been unmounted and the API is no longer usable. */
966
+ isDestroyed: boolean;
620
967
  updateScene: InstanceType<typeof App>["updateScene"];
621
968
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
622
969
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -631,16 +978,18 @@ export interface ExcalidrawImperativeAPI {
631
978
  getAppState: () => InstanceType<typeof App>["state"];
632
979
  getFiles: () => InstanceType<typeof App>["files"];
633
980
  getName: InstanceType<typeof App>["getName"];
634
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
981
+ setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
982
+ getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
635
983
  registerAction: (action: Action) => void;
636
984
  refresh: InstanceType<typeof App>["refresh"];
637
985
  setToast: InstanceType<typeof App>["setToast"];
638
986
  addFiles: (data: BinaryFileData[]) => void;
639
987
  id: string;
640
988
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
641
- setCursor: InstanceType<typeof App>["setCursor"];
642
- resetCursor: InstanceType<typeof App>["resetCursor"];
989
+ setCursor: InstanceType<typeof App>["cursor"]["set"];
990
+ resetCursor: InstanceType<typeof App>["cursor"]["reset"];
643
991
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
992
+ getEditorInterface: () => EditorInterface;
644
993
  /**
645
994
  * Disables rendering of frames (including element clipping), but currently
646
995
  * the frames are still interactive in edit mode. As such, this API should be
@@ -653,24 +1002,14 @@ export interface ExcalidrawImperativeAPI {
653
1002
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
654
1003
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
655
1004
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
1005
+ onStateChange: InstanceType<typeof App>["onStateChange"];
1006
+ onEvent: InstanceType<typeof App>["onEvent"];
656
1007
  }
657
- export type Device = Readonly<{
658
- viewport: {
659
- isMobile: boolean;
660
- isLandscape: boolean;
661
- };
662
- editor: {
663
- isMobile: boolean;
664
- canFitSidebar: boolean;
665
- };
666
- isTouchScreen: boolean;
667
- }>;
668
1008
  export type FrameNameBounds = {
669
1009
  x: number;
670
1010
  y: number;
671
1011
  width: number;
672
1012
  height: number;
673
- angle: number;
674
1013
  };
675
1014
  export type FrameNameBoundsCache = {
676
1015
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -689,12 +1028,12 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
689
1028
  export type JSONValue = string | number | boolean | null | object;
690
1029
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
691
1030
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
692
- export type PendingExcalidrawElements = ExcalidrawElement[];
1031
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
693
1032
  /** Runtime gridSize value. Null indicates disabled grid. */
694
1033
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
695
1034
  export type GenerateDiagramToCode = (props: {
696
- frame: ExcalidrawMagicFrameElement;
697
- children: readonly ExcalidrawElement[];
1035
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
1036
+ children: readonly NonDeletedExcalidrawElement[];
698
1037
  }) => MaybePromise<{
699
1038
  html: string;
700
1039
  }>;
@@ -704,4 +1043,102 @@ export type Offsets = Partial<{
704
1043
  bottom: number;
705
1044
  left: number;
706
1045
  }>;
707
- export {};
1046
+ /**
1047
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
1048
+ * surface that occludes the canvas. Such nodes are measured by
1049
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
1050
+ *
1051
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
1052
+ * - `side` — a panel hugging the left or right edge. Which side is not
1053
+ * declared but resolved geometrically: if the node's horizontal center
1054
+ * lies in the left half of the viewport it counts against the left
1055
+ * offset (by its right edge), otherwise against the right offset (by
1056
+ * `viewportWidth - left edge`). Measuring the rendered position instead
1057
+ * of declaring a side means RTL layouts and host-configurable docking
1058
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
1059
+ * actually hugs one edge; don't mark a centered/near-full-width node as
1060
+ * `side` (its midpoint would classify it to one side and the offset
1061
+ * would swallow most of the viewport).
1062
+ *
1063
+ * The attribute should only be present while the surface is actually
1064
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
1065
+ * push the viewport around.
1066
+ */
1067
+ export type ViewportUIDock = "top" | "bottom" | "side";
1068
+ /**
1069
+ * Options for `getViewportOffsets` (and the `ui` key of
1070
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
1071
+ * currently rendered editor UI.
1072
+ *
1073
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
1074
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
1075
+ * reading-direction start side).
1076
+ */
1077
+ export type ViewportOffsetsOptions = {
1078
+ /** padding added to each measured side (default 24) */
1079
+ padding?: number;
1080
+ paddingTop?: number;
1081
+ paddingRight?: number;
1082
+ paddingBottom?: number;
1083
+ paddingLeft?: number;
1084
+ /** final value for the given side, replacing the measured UI size
1085
+ * (padding is not added on top) */
1086
+ top?: number;
1087
+ bottom?: number;
1088
+ left?: number;
1089
+ right?: number;
1090
+ /**
1091
+ * Reserve space for the given conditionally-rendered surfaces even while
1092
+ * they're hidden, so the resulting offsets don't shift when they
1093
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
1094
+ * to an approximate default if it hasn't been rendered yet. Ignored on
1095
+ * phones (where these surfaces never occlude the canvas).
1096
+ */
1097
+ reserve?: {
1098
+ /** styles panel (rendered when a tool or selection is active) */
1099
+ stylesPanel?: boolean;
1100
+ /** sidebar (e.g. library) */
1101
+ sidebar?: boolean;
1102
+ };
1103
+ };
1104
+ /**
1105
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
1106
+ * `props.initialState.viewport`), insetting the usable viewport area per
1107
+ * side so the target isn't fitted/centered underneath overlaid UI.
1108
+ *
1109
+ * Two (combinable) ways to specify:
1110
+ *
1111
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
1112
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
1113
+ * no padding added. Sides not specified default to `0` (unless `ui` is
1114
+ * set, see below).
1115
+ *
1116
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
1117
+ * panel, sidebar...) as rendered at the time the viewport is set,
1118
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
1119
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
1120
+ * padding or reserve space for currently-hidden surfaces.
1121
+ *
1122
+ * When both are given, a static side always wins for that side — it
1123
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
1124
+ * which — unlike the physical static sides — are RTL-relative). The
1125
+ * remaining sides fall back to the `ui`-derived values.
1126
+ *
1127
+ * @example
1128
+ * { top: 40 } // top 40px, other sides 0
1129
+ * { ui: true } // measured UI + default padding
1130
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
1131
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
1132
+ */
1133
+ export type ViewportOffsets = Offsets & {
1134
+ ui?: true | ViewportOffsetsOptions;
1135
+ };
1136
+ /**
1137
+ * Value of the `data-viewport-ui-name` attribute, identifying a
1138
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1139
+ * `getViewportOffsets` can reserve space for it while it's hidden (see the
1140
+ * `reserve` option). Whenever a named surface is rendered, its measured
1141
+ * footprint is remembered; reserving uses that remembered footprint, or an
1142
+ * approximate default if the surface hasn't been rendered yet.
1143
+ */
1144
+ export type ViewportUIName = "sidebar" | "stylesPanel";