@excalidraw/math 0.18.0-c65b684e9 → 0.18.0-cf212b2

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