@excalidraw/common 0.18.0-dda3affcb-8fc71066d → 0.18.0-e9c856d

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 (320) hide show
  1. package/dist/dev/index.js +1698 -328
  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 +47 -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/arrowheads.d.ts +3 -0
  20. package/dist/types/element/src/arrows/focus.d.ts +27 -0
  21. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  22. package/dist/types/element/src/binding.d.ts +72 -51
  23. package/dist/types/element/src/bounds.d.ts +26 -19
  24. package/dist/types/element/src/collision.d.ts +7 -2
  25. package/dist/types/element/src/comparisons.d.ts +8 -7
  26. package/dist/types/element/src/delta.d.ts +4 -5
  27. package/dist/types/element/src/distribute.d.ts +3 -2
  28. package/dist/types/element/src/dragElements.d.ts +3 -3
  29. package/dist/types/element/src/duplicate.d.ts +7 -6
  30. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  31. package/dist/types/element/src/embeddable.d.ts +2 -2
  32. package/dist/types/element/src/flowchart.d.ts +7 -7
  33. package/dist/types/element/src/fractionalIndex.d.ts +4 -4
  34. package/dist/types/element/src/frame.d.ts +16 -11
  35. package/dist/types/element/src/groups.d.ts +9 -9
  36. package/dist/types/element/src/heading.d.ts +2 -1
  37. package/dist/types/element/src/image.d.ts +1 -11
  38. package/dist/types/element/src/index.d.ts +6 -4
  39. package/dist/types/element/src/linearElementEditor.d.ts +31 -30
  40. package/dist/types/element/src/mutateElement.d.ts +5 -1
  41. package/dist/types/element/src/newElement.d.ts +7 -6
  42. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  43. package/dist/types/element/src/renderElement.d.ts +4 -10
  44. package/dist/types/element/src/resizeElements.d.ts +12 -12
  45. package/dist/types/element/src/resizeTest.d.ts +6 -5
  46. package/dist/types/element/src/selection.d.ts +14 -14
  47. package/dist/types/element/src/shape.d.ts +9 -8
  48. package/dist/types/element/src/store.d.ts +5 -0
  49. package/dist/types/element/src/textElement.d.ts +9 -9
  50. package/dist/types/element/src/textMeasurements.d.ts +1 -3
  51. package/dist/types/element/src/textWrapping.d.ts +26 -0
  52. package/dist/types/{excalidraw/data → element/src}/transform.d.ts +3 -3
  53. package/dist/types/element/src/transformHandles.d.ts +8 -27
  54. package/dist/types/element/src/typeChecks.d.ts +29 -31
  55. package/dist/types/element/src/types.d.ts +20 -14
  56. package/dist/types/element/src/utils.d.ts +9 -4
  57. package/dist/types/element/src/zindex.d.ts +7 -1
  58. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +176 -210
  59. package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
  60. package/dist/types/excalidraw/actions/actionBoundText.d.ts +102 -125
  61. package/dist/types/excalidraw/actions/actionCanvas.d.ts +406 -1576
  62. package/dist/types/excalidraw/actions/actionClipboard.d.ts +129 -893
  63. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +49 -61
  64. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +164 -202
  65. package/dist/types/excalidraw/actions/actionDeselect.d.ts +161 -0
  66. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
  67. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
  68. package/dist/types/excalidraw/actions/actionElementLink.d.ts +56 -74
  69. package/dist/types/excalidraw/actions/actionElementLock.d.ts +101 -124
  70. package/dist/types/excalidraw/actions/actionExport.d.ts +180 -1408
  71. package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
  72. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
  73. package/dist/types/excalidraw/actions/actionFrame.d.ts +277 -534
  74. package/dist/types/excalidraw/actions/actionGroup.d.ts +112 -143
  75. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +187 -236
  76. package/dist/types/excalidraw/actions/actionLink.d.ts +62 -74
  77. package/dist/types/excalidraw/actions/actionMenu.d.ts +51 -435
  78. package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -359
  79. package/dist/types/excalidraw/actions/actionProperties.d.ts +181 -2525
  80. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +56 -72
  81. package/dist/types/excalidraw/actions/actionStyles.d.ts +49 -60
  82. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
  83. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +174 -0
  84. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +64 -77
  85. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +174 -0
  86. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +63 -75
  87. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +52 -71
  88. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
  89. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +62 -74
  90. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +63 -75
  91. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +63 -75
  92. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
  93. package/dist/types/excalidraw/actions/index.d.ts +5 -3
  94. package/dist/types/excalidraw/actions/register.d.ts +2 -2
  95. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  96. package/dist/types/excalidraw/actions/types.d.ts +7 -7
  97. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  98. package/dist/types/excalidraw/appState.d.ts +45 -36
  99. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  100. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  101. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  102. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  103. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  104. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  105. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  106. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  107. package/dist/types/excalidraw/clipboard.d.ts +59 -21
  108. package/dist/types/excalidraw/components/Actions.d.ts +33 -11
  109. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  110. package/dist/types/excalidraw/components/App.d.ts +200 -109
  111. package/dist/types/excalidraw/components/App.flowchart.d.ts +19 -0
  112. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  113. package/dist/types/excalidraw/components/Card.d.ts +1 -3
  114. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
  115. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -3
  116. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  117. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  118. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  119. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
  120. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
  121. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  122. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  123. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
  124. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -4
  125. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  126. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  127. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
  128. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  129. package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
  130. package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
  131. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
  132. package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
  133. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  134. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  135. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
  136. package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
  137. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  138. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  139. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  140. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  141. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  142. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  143. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -2
  144. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  145. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  146. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
  147. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  148. package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
  149. package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
  150. package/dist/types/excalidraw/components/LockButton.d.ts +2 -4
  151. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  152. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -6
  153. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  154. package/dist/types/excalidraw/components/Modal.d.ts +0 -1
  155. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
  156. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  157. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  158. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  159. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  160. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
  161. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  162. package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
  163. package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
  164. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  165. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  166. package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
  167. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  168. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
  169. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
  170. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
  171. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
  172. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
  173. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
  174. package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
  175. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  176. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
  177. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
  178. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  179. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
  180. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  181. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  182. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  183. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  184. package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
  185. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  186. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
  187. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
  188. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
  189. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
  190. package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
  191. package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
  192. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  193. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
  194. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
  195. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
  196. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  197. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  198. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
  199. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
  200. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
  201. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
  202. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
  203. package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
  204. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
  205. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
  206. package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
  207. package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
  208. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
  209. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  210. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
  211. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
  212. package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
  213. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  214. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  215. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
  216. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  217. package/dist/types/excalidraw/components/Toast.d.ts +11 -7
  218. package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
  219. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  220. package/dist/types/excalidraw/components/Tools.d.ts +128 -0
  221. package/dist/types/excalidraw/components/Trans.d.ts +2 -2
  222. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +8 -4
  223. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  224. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  225. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +47 -35
  226. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
  227. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
  228. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
  229. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  230. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
  231. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
  232. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
  233. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
  234. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  235. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  236. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  237. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
  238. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
  239. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  240. package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
  241. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  242. package/dist/types/excalidraw/components/icons.d.ts +51 -21
  243. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
  244. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
  245. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +36 -0
  246. package/dist/types/excalidraw/data/blob.d.ts +331 -12
  247. package/dist/types/excalidraw/data/encode.d.ts +4 -4
  248. package/dist/types/excalidraw/data/encryption.d.ts +5 -5
  249. package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
  250. package/dist/types/excalidraw/data/index.d.ts +8 -9
  251. package/dist/types/excalidraw/data/json.d.ts +171 -3
  252. package/dist/types/excalidraw/data/library.d.ts +25 -10
  253. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  254. package/dist/types/excalidraw/data/restore.d.ts +25 -10
  255. package/dist/types/excalidraw/data/types.d.ts +4 -1
  256. package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
  257. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  258. package/dist/types/excalidraw/errors.d.ts +14 -0
  259. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  260. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +2 -2
  261. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +4 -3
  262. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
  263. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  264. package/dist/types/excalidraw/i18n.d.ts +2 -2
  265. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  266. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  267. package/dist/types/excalidraw/renderer/animation.d.ts +16 -0
  268. package/dist/types/excalidraw/renderer/helpers.d.ts +6 -8
  269. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
  270. package/dist/types/excalidraw/scene/Renderer.d.ts +428 -18
  271. package/dist/types/excalidraw/scene/export.d.ts +4 -4
  272. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  273. package/dist/types/excalidraw/scene/types.d.ts +23 -8
  274. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  275. package/dist/types/excalidraw/snapping.d.ts +12 -12
  276. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
  277. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
  278. package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
  279. package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
  280. package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
  281. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  282. package/dist/types/excalidraw/types.d.ts +297 -46
  283. package/dist/types/excalidraw/viewport.d.ts +316 -0
  284. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +8 -5
  285. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  286. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  287. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  288. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  289. package/dist/types/laser-pointer/src/state.d.ts +35 -0
  290. package/dist/types/math/src/constants.d.ts +0 -1
  291. package/dist/types/math/src/curve.d.ts +4 -1
  292. package/dist/types/math/src/point.d.ts +8 -2
  293. package/dist/types/math/src/polygon.d.ts +2 -2
  294. package/dist/types/math/src/range.d.ts +1 -3
  295. package/dist/types/math/src/segment.d.ts +4 -3
  296. package/dist/types/math/src/types.d.ts +25 -1
  297. package/dist/types/utils/src/export.d.ts +8 -8
  298. package/dist/types/utils/src/index.d.ts +1 -2
  299. package/dist/types/utils/src/shape.d.ts +6 -6
  300. package/package.json +7 -1
  301. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -185
  302. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  303. package/dist/types/excalidraw/charts.d.ts +0 -27
  304. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  305. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
  306. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  307. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  308. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -9
  309. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  310. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
  311. package/dist/types/excalidraw/components/shapes.d.ts +0 -62
  312. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  313. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  314. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -85
  315. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  316. package/dist/types/excalidraw/index.d.ts +0 -47
  317. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  318. package/dist/types/excalidraw/scene/scroll.d.ts +0 -23
  319. package/dist/types/utils/src/bbox.d.ts +0 -9
  320. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -7,8 +7,8 @@
7
7
  * In the future consider separating common utils into a separate shared chunk.
8
8
  */
9
9
  declare const load: () => Promise<{
10
- compress: (buffer: ArrayBuffer) => Uint8Array;
11
- decompress: (buffer: ArrayBuffer) => Uint8Array;
10
+ compress: (buffer: ArrayBuffer) => Uint8Array<ArrayBuffer>;
11
+ decompress: (buffer: ArrayBuffer) => Uint8Array<ArrayBuffer>;
12
12
  }>;
13
13
  declare const _default: () => ReturnType<typeof load>;
14
14
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: Uint8Array;
1
+ declare const _default: Uint8Array<ArrayBuffer>;
2
2
  export default _default;
@@ -0,0 +1,15 @@
1
+ import { type GlobalPoint } from "@excalidraw/math";
2
+ import type { EditorInterface } from "@excalidraw/common";
3
+ import type { ExcalidrawTextElement } from "@excalidraw/element/types";
4
+ export declare const getTextBoxPadding: (zoomValue: number) => number;
5
+ export declare const getTextAutoResizeHandle: (textElement: ExcalidrawTextElement, zoomValue: number, formFactor: EditorInterface["formFactor"]) => {
6
+ center: GlobalPoint | import("@excalidraw/math").LocalPoint;
7
+ start: GlobalPoint;
8
+ end: GlobalPoint;
9
+ hitboxWidth: number;
10
+ hitboxHeight: number;
11
+ } | null;
12
+ export declare const isPointHittingTextAutoResizeHandle: (point: Readonly<{
13
+ x: number;
14
+ y: number;
15
+ }>, textElement: ExcalidrawTextElement, zoomValue: number, formFactor: EditorInterface["formFactor"]) => boolean;
@@ -1,23 +1,24 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
2
- import type { ApplyToOptions, 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, 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
  };
@@ -125,16 +126,21 @@ 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"];
138
144
  isRotating: AppState["isRotating"];
139
145
  elementsToHighlight: AppState["elementsToHighlight"];
140
146
  collaborators: AppState["collaborators"];
@@ -145,6 +151,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
145
151
  croppingElementId: AppState["croppingElementId"];
146
152
  searchMatches: AppState["searchMatches"];
147
153
  activeLockedId: AppState["activeLockedId"];
154
+ hoveredElementIds: AppState["hoveredElementIds"];
155
+ frameRendering: AppState["frameRendering"];
156
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
157
+ exportScale: AppState["exportScale"];
158
+ currentItemArrowType: AppState["currentItemArrowType"];
148
159
  }>;
149
160
  export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
150
161
  export type ObservedStandaloneAppState = {
@@ -163,6 +174,42 @@ export type ObservedElementsAppState = {
163
174
  lockedMultiSelections: AppState["lockedMultiSelections"];
164
175
  activeLockedId: AppState["activeLockedId"];
165
176
  };
177
+ export type BoxSelectionMode = "contain" | "overlap";
178
+ /**
179
+ * A box, in scene coordinates, that pan & zoom are constrained to.
180
+ *
181
+ * This is a private type. For public API, only use specific properties,
182
+ * needed.
183
+ */
184
+ export type ScrollConstraints = {
185
+ x: number;
186
+ y: number;
187
+ width: number;
188
+ height: number;
189
+ /** when set, panning is constrained so the viewport stays within the box */
190
+ lockScroll: boolean;
191
+ /** when set, the viewport cannot zoom out below `zoom` */
192
+ lockZoom: boolean;
193
+ /**
194
+ * The zoom resolved after the `setViewport` navigation settled.
195
+ */
196
+ zoom: number;
197
+ /**
198
+ * Pixel amount the viewport may overscroll past its resting clamp before
199
+ * snapping back (rubberband). Screen pixels, zoom-independent. Resolved
200
+ * from `lock.overscroll` at the time the lock was installed (`true` →
201
+ * default give, `false` → 0).
202
+ */
203
+ overscroll: number;
204
+ /**
205
+ * Extra scrollable margin around the box (CSS-style), letting the viewport
206
+ * scroll past each box edge to reveal that much empty space. Values are
207
+ * viewport pixels and zoom-independent (a fixed on-screen distance).
208
+ * Resolved from the `offsets` passed to `setViewport` (see
209
+ * {@link ViewportOffsets}) at the time the lock was installed.
210
+ */
211
+ offsets?: Offsets;
212
+ };
166
213
  export interface AppState {
167
214
  contextMenu: {
168
215
  items: ContextMenuItems;
@@ -196,9 +243,25 @@ export interface AppState {
196
243
  * - set on pointer down, updated during pointer move
197
244
  */
198
245
  selectionElement: NonDeletedExcalidrawElement | null;
246
+ /**
247
+ * tracking current arrow binding editor state (takes into account
248
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
249
+ */
199
250
  isBindingEnabled: boolean;
200
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
201
- suggestedBindings: SuggestedBinding[];
251
+ /** user box selection preference; defaults to "contain" when unset */
252
+ boxSelectionMode: BoxSelectionMode;
253
+ /** user arrow binding preference */
254
+ bindingPreference: "enabled" | "disabled";
255
+ /** user preference whether arrow snap to midpoints while binding */
256
+ isMidpointSnappingEnabled: boolean;
257
+ /**
258
+ * The bindable element the UI highlights for the user when an arrow is
259
+ * dragged or otherwise its endpoint being close to said element.
260
+ */
261
+ suggestedBinding: {
262
+ element: NonDeleted<ExcalidrawBindableElement>;
263
+ midPoint?: GlobalPoint;
264
+ } | null;
202
265
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
203
266
  frameRendering: {
204
267
  enabled: boolean;
@@ -207,11 +270,11 @@ export interface AppState {
207
270
  clip: boolean;
208
271
  };
209
272
  editingFrame: string | null;
210
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
273
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
211
274
  /**
212
275
  * set when a new text is created or when an existing text is being edited
213
276
  */
214
- editingTextElement: NonDeletedExcalidrawElement | null;
277
+ editingTextElement: ExcalidrawTextElement | null;
215
278
  activeTool: {
216
279
  /**
217
280
  * indicates a previous tool we should revert back to if we deselect the
@@ -221,6 +284,10 @@ export interface AppState {
221
284
  locked: boolean;
222
285
  fromSelection: boolean;
223
286
  } & ActiveTool;
287
+ preferredSelectionTool: {
288
+ type: "selection" | "lasso";
289
+ initialized: boolean;
290
+ };
224
291
  penMode: boolean;
225
292
  penDetected: boolean;
226
293
  exportBackground: boolean;
@@ -230,9 +297,10 @@ export interface AppState {
230
297
  currentItemStrokeColor: string;
231
298
  currentItemBackgroundColor: string;
232
299
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
233
- currentItemStrokeWidth: number;
300
+ currentItemStrokeWidthKey: StrokeWidthKey;
234
301
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
235
302
  currentItemRoughness: number;
303
+ currentItemStrokeVariability: StrokeVariability;
236
304
  currentItemOpacity: number;
237
305
  currentItemFontFamily: FontFamilyValues;
238
306
  currentItemFontSize: number;
@@ -245,14 +313,15 @@ export interface AppState {
245
313
  viewBackgroundColor: string;
246
314
  scrollX: number;
247
315
  scrollY: number;
316
+ scrollConstraints: ScrollConstraints | null;
248
317
  cursorButton: "up" | "down";
249
318
  scrolledOutside: boolean;
250
319
  name: string | null;
251
320
  isResizing: boolean;
252
321
  isRotating: boolean;
253
322
  zoom: Zoom;
254
- openMenu: "canvas" | "shape" | null;
255
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
323
+ openMenu: "canvas" | null;
324
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
256
325
  openSidebar: {
257
326
  name: SidebarName;
258
327
  tab?: SidebarTabName;
@@ -264,9 +333,15 @@ export interface AppState {
264
333
  tab: "text-to-diagram" | "mermaid";
265
334
  } | {
266
335
  name: "commandPalette";
336
+ } | {
337
+ name: "settings";
267
338
  } | {
268
339
  name: "elementLinkSelector";
269
340
  sourceElementId: ExcalidrawElement["id"];
341
+ } | {
342
+ name: "charts";
343
+ data: Spreadsheet;
344
+ rawText: string;
270
345
  };
271
346
  /**
272
347
  * Reflects user preference for whether the default sidebar should be docked.
@@ -289,7 +364,7 @@ export interface AppState {
289
364
  selectedElementsAreBeingDragged: boolean;
290
365
  shouldCacheIgnoreZoom: boolean;
291
366
  toast: {
292
- message: string;
367
+ message: React.ReactNode;
293
368
  closable?: boolean;
294
369
  duration?: number;
295
370
  } | null;
@@ -311,21 +386,13 @@ export interface AppState {
311
386
  height: number;
312
387
  offsetTop: number;
313
388
  offsetLeft: number;
314
- fileHandle: FileSystemHandle | null;
389
+ fileHandle: FileSystemFileHandle | null;
315
390
  collaborators: Map<SocketId, Collaborator>;
316
391
  stats: {
317
392
  open: boolean;
318
393
  /** bitmap. Use `STATS_PANELS` bit values */
319
394
  panels: number;
320
395
  };
321
- currentChartType: ChartType;
322
- pasteDialog: {
323
- shown: false;
324
- data: null;
325
- } | {
326
- shown: true;
327
- data: Spreadsheet;
328
- };
329
396
  showHyperlinkPopup: false | "info" | "editor";
330
397
  selectedLinearElement: LinearElementEditor | null;
331
398
  snapLines: readonly SnapLine[];
@@ -351,6 +418,7 @@ export interface AppState {
351
418
  lockedMultiSelections: {
352
419
  [groupId: string]: true;
353
420
  };
421
+ bindMode: BindMode;
354
422
  }
355
423
  export type SearchMatch = {
356
424
  id: string;
@@ -363,7 +431,7 @@ export type SearchMatch = {
363
431
  showOnCanvas: boolean;
364
432
  }[];
365
433
  };
366
- export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
434
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "frameToHighlight" | "elementsToHighlight">;
367
435
  export type NormalizedZoomValue = number & {
368
436
  _brand: "normalizedZoom";
369
437
  };
@@ -407,15 +475,45 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
407
475
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
408
476
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
409
477
  }>;
478
+ export type ExcalidrawInitialState = {
479
+ viewport?: Omit<SetViewportOptions, "animation">;
480
+ };
410
481
  export type OnUserFollowedPayload = {
411
482
  userToFollow: UserToFollow;
412
483
  action: "FOLLOW" | "UNFOLLOW";
413
484
  };
485
+ export type OnExportProgress = {
486
+ type: "progress";
487
+ message?: React.ReactNode;
488
+ /** 0-1 range */
489
+ progress?: number;
490
+ };
414
491
  export interface ExcalidrawProps {
415
492
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
493
+ onThemeChange?: (theme: Theme | "system") => void;
494
+ /**
495
+ * note: only subscribes if the props.onIncrement is defined on initial render
496
+ */
416
497
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
417
498
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
418
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
499
+ initialState?: ExcalidrawInitialState;
500
+ /**
501
+ * Invoked as soon as the Excalidraw API is available
502
+ * NOTE editor is not yet mounted, and state is not yet initialized
503
+ */
504
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
505
+ /**
506
+ * Invoked once the editor root is mounted.
507
+ */
508
+ onMount?: (payload: ExcalidrawMountPayload) => void;
509
+ /**
510
+ * Invoked when the editor root is unmounted.
511
+ */
512
+ onUnmount?: () => void;
513
+ /**
514
+ * Invoked once the initial scene is loaded.
515
+ */
516
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
419
517
  isCollaborating?: boolean;
420
518
  onPointerUpdate?: (payload: {
421
519
  pointer: {
@@ -441,6 +539,7 @@ export interface ExcalidrawProps {
441
539
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
442
540
  /** excludes the duplicated elements */
443
541
  prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
542
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
444
543
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
445
544
  langCode?: Language["code"];
446
545
  viewModeEnabled?: boolean;
@@ -452,6 +551,10 @@ export interface ExcalidrawProps {
452
551
  name?: string;
453
552
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
454
553
  UIOptions?: Partial<UIOptions>;
554
+ /**
555
+ * dimensions and size constraints for inserted images
556
+ */
557
+ imageOptions?: ImageOptions;
455
558
  detectScroll?: boolean;
456
559
  handleKeyboardGlobally?: boolean;
457
560
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -471,6 +574,29 @@ export interface ExcalidrawProps {
471
574
  aiEnabled?: boolean;
472
575
  showDeprecatedFonts?: boolean;
473
576
  renderScrollbars?: boolean;
577
+ /**
578
+ * Called before exporting to a file.
579
+ *
580
+ * Allows the host app to intercept and delay saving until async operations
581
+ * (e.g., images are loaded) complete.
582
+ *
583
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
584
+ * until the operation completes. Generator can yield progress updates.
585
+ */
586
+ onExport?: (
587
+ /** type of export. Currently we only call for JSON exports or
588
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
589
+ type: "json", data: {
590
+ elements: readonly ExcalidrawElement[];
591
+ appState: AppState;
592
+ files: BinaryFiles;
593
+ }, options: {
594
+ /** signal that gets aborted if user cancels the export (e.g. closes
595
+ * the native file picker dialog). In that case, you can either
596
+ * return immediately, or throw AbortError.
597
+ */
598
+ signal: AbortSignal;
599
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
474
600
  }
475
601
  export type SceneData = {
476
602
  elements?: ImportedDataState["elements"];
@@ -478,18 +604,26 @@ export type SceneData = {
478
604
  collaborators?: Map<SocketId, Collaborator>;
479
605
  captureUpdate?: CaptureUpdateActionType;
480
606
  };
481
- export type ApplyDeltasOptions = Omit<ApplyToOptions, "skipRedraw">;
482
607
  export type ExportOpts = {
483
608
  saveFileToDisk?: boolean;
484
609
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
485
610
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
486
611
  };
612
+ export type ImageOptions = Partial<{
613
+ maxWidthOrHeight: number;
614
+ maxFileSizeBytes: number;
615
+ }>;
487
616
  export type CanvasActions = Partial<{
488
617
  changeViewBackgroundColor: boolean;
489
618
  clearCanvas: boolean;
490
619
  export: false | ExportOpts;
491
620
  loadScene: boolean;
492
621
  saveToActiveFile: boolean;
622
+ /**
623
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
624
+ * is supplied (at which point the theme is considered as host-app controlled),
625
+ * else default to false
626
+ * */
493
627
  toggleTheme: boolean | null;
494
628
  saveAsImage: boolean;
495
629
  }>;
@@ -499,6 +633,11 @@ export type UIOptions = Partial<{
499
633
  tools: {
500
634
  image: boolean;
501
635
  };
636
+ /**
637
+ * Optionally control the editor form factor and desktop UI mode from the host app.
638
+ * If not provided, we will take care of it internally.
639
+ */
640
+ getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
502
641
  /** @deprecated does nothing. Will be removed in 0.15 */
503
642
  welcomeScreen?: boolean;
504
643
  }>;
@@ -508,6 +647,7 @@ export type AppProps = Merge<ExcalidrawProps, {
508
647
  export: ExportOpts;
509
648
  };
510
649
  }>;
650
+ imageOptions: Required<ImageOptions>;
511
651
  detectScroll: boolean;
512
652
  handleKeyboardGlobally: boolean;
513
653
  isCollaborating: boolean;
@@ -519,6 +659,8 @@ export type AppProps = Merge<ExcalidrawProps, {
519
659
  export type AppClassProperties = {
520
660
  props: AppProps;
521
661
  state: AppState;
662
+ api: App["api"];
663
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
522
664
  interactiveCanvas: HTMLCanvasElement | null;
523
665
  /** static canvas */
524
666
  canvas: HTMLCanvasElement;
@@ -529,7 +671,7 @@ export type AppClassProperties = {
529
671
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
530
672
  }>;
531
673
  files: BinaryFiles;
532
- device: App["device"];
674
+ editorInterface: App["editorInterface"];
533
675
  scene: App["scene"];
534
676
  syncActionResult: App["syncActionResult"];
535
677
  fonts: App["fonts"];
@@ -538,7 +680,7 @@ export type AppClassProperties = {
538
680
  onInsertElements: App["onInsertElements"];
539
681
  onExportImage: App["onExportImage"];
540
682
  lastViewportPosition: App["lastViewportPosition"];
541
- scrollToContent: App["scrollToContent"];
683
+ setViewport: App["setViewport"];
542
684
  addFiles: App["addFiles"];
543
685
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
544
686
  togglePenMode: App["togglePenMode"];
@@ -549,15 +691,22 @@ export type AppClassProperties = {
549
691
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
550
692
  getName: App["getName"];
551
693
  dismissLinearEditor: App["dismissLinearEditor"];
552
- flowChartCreator: App["flowChartCreator"];
694
+ flowchart: App["flowchart"];
553
695
  getEffectiveGridSize: App["getEffectiveGridSize"];
554
696
  setPlugins: App["setPlugins"];
555
697
  plugins: App["plugins"];
556
- getEditorUIOffsets: App["getEditorUIOffsets"];
698
+ getViewportOffsets: App["getViewportOffsets"];
557
699
  visibleElements: App["visibleElements"];
558
700
  excalidrawContainerValue: App["excalidrawContainerValue"];
559
701
  onPointerUpEmitter: App["onPointerUpEmitter"];
560
702
  updateEditorAtom: App["updateEditorAtom"];
703
+ onPointerDownEmitter: App["onPointerDownEmitter"];
704
+ onEvent: App["onEvent"];
705
+ onStateChange: App["onStateChange"];
706
+ lastPointerMoveCoords: App["lastPointerMoveCoords"];
707
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
708
+ bindModeHandler: App["bindModeHandler"];
709
+ setAppState: App["setAppState"];
561
710
  };
562
711
  export type PointerDownState = Readonly<{
563
712
  origin: Readonly<{
@@ -605,6 +754,7 @@ export type PointerDownState = Readonly<{
605
754
  x: number;
606
755
  y: number;
607
756
  };
757
+ blockDragging: boolean;
608
758
  };
609
759
  eventListeners: {
610
760
  onMove: null | ReturnType<typeof throttleRAF>;
@@ -617,7 +767,18 @@ export type PointerDownState = Readonly<{
617
767
  };
618
768
  }>;
619
769
  export type UnsubscribeCallback = () => void;
770
+ export type ExcalidrawMountPayload = {
771
+ excalidrawAPI: ExcalidrawImperativeAPI;
772
+ container: HTMLDivElement | null;
773
+ };
774
+ export type ExcalidrawImperativeAPIEventMap = {
775
+ "editor:mount": [payload: ExcalidrawMountPayload];
776
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
777
+ "editor:unmount": [];
778
+ };
620
779
  export interface ExcalidrawImperativeAPI {
780
+ /** Whether the editor has been unmounted and the API is no longer usable. */
781
+ isDestroyed: boolean;
621
782
  updateScene: InstanceType<typeof App>["updateScene"];
622
783
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
623
784
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -632,7 +793,8 @@ export interface ExcalidrawImperativeAPI {
632
793
  getAppState: () => InstanceType<typeof App>["state"];
633
794
  getFiles: () => InstanceType<typeof App>["files"];
634
795
  getName: InstanceType<typeof App>["getName"];
635
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
796
+ setViewport: InstanceType<typeof App>["setViewport"];
797
+ getViewportOffsets: InstanceType<typeof App>["getViewportOffsets"];
636
798
  registerAction: (action: Action) => void;
637
799
  refresh: InstanceType<typeof App>["refresh"];
638
800
  setToast: InstanceType<typeof App>["setToast"];
@@ -642,6 +804,7 @@ export interface ExcalidrawImperativeAPI {
642
804
  setCursor: InstanceType<typeof App>["setCursor"];
643
805
  resetCursor: InstanceType<typeof App>["resetCursor"];
644
806
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
807
+ getEditorInterface: () => EditorInterface;
645
808
  /**
646
809
  * Disables rendering of frames (including element clipping), but currently
647
810
  * the frames are still interactive in edit mode. As such, this API should be
@@ -654,24 +817,14 @@ export interface ExcalidrawImperativeAPI {
654
817
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
655
818
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
656
819
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
820
+ onStateChange: InstanceType<typeof App>["onStateChange"];
821
+ onEvent: InstanceType<typeof App>["onEvent"];
657
822
  }
658
- export type Device = Readonly<{
659
- viewport: {
660
- isMobile: boolean;
661
- isLandscape: boolean;
662
- };
663
- editor: {
664
- isMobile: boolean;
665
- canFitSidebar: boolean;
666
- };
667
- isTouchScreen: boolean;
668
- }>;
669
823
  export type FrameNameBounds = {
670
824
  x: number;
671
825
  y: number;
672
826
  width: number;
673
827
  height: number;
674
- angle: number;
675
828
  };
676
829
  export type FrameNameBoundsCache = {
677
830
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -690,12 +843,12 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
690
843
  export type JSONValue = string | number | boolean | null | object;
691
844
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
692
845
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
693
- export type PendingExcalidrawElements = ExcalidrawElement[];
846
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
694
847
  /** Runtime gridSize value. Null indicates disabled grid. */
695
848
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
696
849
  export type GenerateDiagramToCode = (props: {
697
- frame: ExcalidrawMagicFrameElement;
698
- children: readonly ExcalidrawElement[];
850
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
851
+ children: readonly NonDeletedExcalidrawElement[];
699
852
  }) => MaybePromise<{
700
853
  html: string;
701
854
  }>;
@@ -705,4 +858,102 @@ export type Offsets = Partial<{
705
858
  bottom: number;
706
859
  left: number;
707
860
  }>;
708
- export {};
861
+ /**
862
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
863
+ * surface that occludes the canvas. Such nodes are measured by
864
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
865
+ *
866
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
867
+ * - `side` — a panel hugging the left or right edge. Which side is not
868
+ * declared but resolved geometrically: if the node's horizontal center
869
+ * lies in the left half of the viewport it counts against the left
870
+ * offset (by its right edge), otherwise against the right offset (by
871
+ * `viewportWidth - left edge`). Measuring the rendered position instead
872
+ * of declaring a side means RTL layouts and host-configurable docking
873
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
874
+ * actually hugs one edge; don't mark a centered/near-full-width node as
875
+ * `side` (its midpoint would classify it to one side and the offset
876
+ * would swallow most of the viewport).
877
+ *
878
+ * The attribute should only be present while the surface is actually
879
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
880
+ * push the viewport around.
881
+ */
882
+ export type ViewportUIDock = "top" | "bottom" | "side";
883
+ /**
884
+ * Options for `getViewportOffsets` (and the `ui` key of
885
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
886
+ * currently rendered editor UI.
887
+ *
888
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
889
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
890
+ * reading-direction start side).
891
+ */
892
+ export type ViewportOffsetsOptions = {
893
+ /** padding added to each measured side (default 24) */
894
+ padding?: number;
895
+ paddingTop?: number;
896
+ paddingRight?: number;
897
+ paddingBottom?: number;
898
+ paddingLeft?: number;
899
+ /** final value for the given side, replacing the measured UI size
900
+ * (padding is not added on top) */
901
+ top?: number;
902
+ bottom?: number;
903
+ left?: number;
904
+ right?: number;
905
+ /**
906
+ * Reserve space for the given conditionally-rendered surfaces even while
907
+ * they're hidden, so the resulting offsets don't shift when they
908
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
909
+ * to an approximate default if it hasn't been rendered yet. Ignored on
910
+ * phones (where these surfaces never occlude the canvas).
911
+ */
912
+ reserve?: {
913
+ /** styles panel (rendered when a tool or selection is active) */
914
+ stylesPanel?: boolean;
915
+ /** sidebar (e.g. library) */
916
+ sidebar?: boolean;
917
+ };
918
+ };
919
+ /**
920
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
921
+ * `props.initialState.viewport`), insetting the usable viewport area per
922
+ * side so the target isn't fitted/centered underneath overlaid UI.
923
+ *
924
+ * Two (combinable) ways to specify:
925
+ *
926
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
927
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
928
+ * no padding added. Sides not specified default to `0` (unless `ui` is
929
+ * set, see below).
930
+ *
931
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
932
+ * panel, sidebar...) as rendered at the time the viewport is set,
933
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
934
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
935
+ * padding or reserve space for currently-hidden surfaces.
936
+ *
937
+ * When both are given, a static side always wins for that side — it
938
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
939
+ * which — unlike the physical static sides — are RTL-relative). The
940
+ * remaining sides fall back to the `ui`-derived values.
941
+ *
942
+ * @example
943
+ * { top: 40 } // top 40px, other sides 0
944
+ * { ui: true } // measured UI + default padding
945
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
946
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
947
+ */
948
+ export type ViewportOffsets = Offsets & {
949
+ ui?: true | ViewportOffsetsOptions;
950
+ };
951
+ /**
952
+ * Value of the `data-viewport-ui-name` attribute, identifying a
953
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
954
+ * `getViewportOffsets` can reserve space for it while it's hidden (see the
955
+ * `reserve` option). Whenever a named surface is rendered, its measured
956
+ * footprint is remembered; reserving uses that remembered footprint, or an
957
+ * approximate default if the surface hasn't been rendered yet.
958
+ */
959
+ export type ViewportUIName = "sidebar" | "stylesPanel";