@excalidraw/common 0.18.0-d9e8a33 → 0.18.0-dabd83c

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 (253) hide show
  1. package/dist/dev/index.js +237 -104
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/colors.d.ts +23 -1
  5. package/dist/types/common/src/constants.d.ts +68 -7
  6. package/dist/types/common/src/keys.d.ts +6 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/random.d.ts +7 -0
  9. package/dist/types/common/src/utils.d.ts +13 -44
  10. package/dist/types/element/src/Scene.d.ts +7 -5
  11. package/dist/types/element/src/align.d.ts +5 -2
  12. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  13. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  14. package/dist/types/element/src/binding.d.ts +90 -13
  15. package/dist/types/element/src/bounds.d.ts +28 -7
  16. package/dist/types/element/src/bucketFill.d.ts +110 -0
  17. package/dist/types/element/src/collision.d.ts +21 -5
  18. package/dist/types/element/src/comparisons.d.ts +8 -5
  19. package/dist/types/element/src/convertToShape.d.ts +23 -0
  20. package/dist/types/element/src/cropElement.d.ts +36 -4
  21. package/dist/types/element/src/delta.d.ts +30 -2
  22. package/dist/types/element/src/distribute.d.ts +5 -2
  23. package/dist/types/element/src/dragElements.d.ts +34 -2
  24. package/dist/types/element/src/duplicate.d.ts +64 -3
  25. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  26. package/dist/types/element/src/embeddable.d.ts +3 -2
  27. package/dist/types/element/src/flowchart.d.ts +9 -11
  28. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  29. package/dist/types/element/src/frame.d.ts +30 -11
  30. package/dist/types/element/src/groups.d.ts +10 -15
  31. package/dist/types/element/src/image.d.ts +5 -2
  32. package/dist/types/element/src/index.d.ts +7 -1
  33. package/dist/types/element/src/linearElementEditor.d.ts +31 -11
  34. package/dist/types/element/src/listMarker.d.ts +39 -0
  35. package/dist/types/element/src/mutateElement.d.ts +1 -1
  36. package/dist/types/element/src/newElement.d.ts +55 -3
  37. package/dist/types/element/src/renderElement.d.ts +31 -7
  38. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  39. package/dist/types/element/src/resizeElements.d.ts +14 -4
  40. package/dist/types/element/src/selection.d.ts +7 -13
  41. package/dist/types/element/src/shape.d.ts +29 -1
  42. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  43. package/dist/types/element/src/sortElements.d.ts +10 -0
  44. package/dist/types/element/src/stickyNote.d.ts +191 -0
  45. package/dist/types/element/src/textElement.d.ts +22 -10
  46. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  47. package/dist/types/element/src/textWrapping.d.ts +3 -2
  48. package/dist/types/element/src/transform.d.ts +31 -8
  49. package/dist/types/element/src/typeChecks.d.ts +29 -27
  50. package/dist/types/element/src/types.d.ts +43 -7
  51. package/dist/types/element/src/utils.d.ts +15 -4
  52. package/dist/types/element/src/zindex.d.ts +2 -2
  53. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +98 -18
  54. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  55. package/dist/types/excalidraw/actions/actionBoundText.d.ts +79 -204
  56. package/dist/types/excalidraw/actions/actionCanvas.d.ts +306 -951
  57. package/dist/types/excalidraw/actions/actionClipboard.d.ts +68 -12
  58. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +34 -6
  59. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -521
  60. package/dist/types/excalidraw/actions/actionDeselect.d.ts +35 -7
  61. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  62. package/dist/types/excalidraw/actions/actionElementLink.d.ts +34 -6
  63. package/dist/types/excalidraw/actions/actionElementLock.d.ts +69 -13
  64. package/dist/types/excalidraw/actions/actionExport.d.ts +76 -20
  65. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  66. package/dist/types/excalidraw/actions/actionFrame.d.ts +132 -652
  67. package/dist/types/excalidraw/actions/actionGroup.d.ts +83 -27
  68. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +89 -9
  69. package/dist/types/excalidraw/actions/actionLink.d.ts +35 -7
  70. package/dist/types/excalidraw/actions/actionMenu.d.ts +34 -6
  71. package/dist/types/excalidraw/actions/actionProperties.d.ts +106 -34
  72. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +39 -11
  73. package/dist/types/excalidraw/actions/actionStyles.d.ts +31 -7
  74. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  75. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +35 -7
  76. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +38 -11
  77. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +35 -7
  78. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +206 -0
  79. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +35 -7
  80. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +38 -11
  81. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  82. package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleShowHints.d.ts} +50 -19
  83. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +35 -7
  84. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +36 -8
  85. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  86. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +35 -7
  87. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  88. package/dist/types/excalidraw/actions/index.d.ts +4 -2
  89. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  90. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  91. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  92. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  93. package/dist/types/excalidraw/appState.d.ts +37 -12
  94. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  95. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  96. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  97. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  98. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  99. package/dist/types/excalidraw/components/Actions.d.ts +26 -13
  100. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  101. package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
  102. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  103. package/dist/types/excalidraw/components/App.clipboard.d.ts +59 -0
  104. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  105. package/dist/types/excalidraw/components/App.d.ts +335 -111
  106. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  107. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  108. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  109. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  110. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  111. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  112. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  113. package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
  114. package/dist/types/excalidraw/components/App.text.d.ts +194 -0
  115. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  116. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  117. package/dist/types/excalidraw/components/App.viewport.d.ts +133 -0
  118. package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
  119. package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
  120. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  121. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  122. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
  123. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  124. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  125. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  126. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  127. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  128. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  129. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  130. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -3
  131. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  132. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  133. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  134. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  135. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  136. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  137. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  138. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  139. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  140. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  141. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  142. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  143. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  144. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  145. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  146. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  147. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  148. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  149. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  150. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  151. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  152. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  153. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  154. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  155. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  156. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  157. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  158. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  159. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  160. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  161. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  162. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  163. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  164. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  165. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  166. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  167. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  168. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  169. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  170. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  171. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  172. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  173. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  174. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  175. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  176. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  177. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  178. package/dist/types/excalidraw/components/Toast.d.ts +12 -1
  179. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  180. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  181. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  182. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  183. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  184. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  185. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  186. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  187. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  188. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  189. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
  190. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  191. package/dist/types/excalidraw/components/footer/Footer.d.ts +5 -1
  192. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  193. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +15 -4
  194. package/dist/types/excalidraw/components/icons.d.ts +8 -1
  195. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +10 -4
  196. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  197. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  198. package/dist/types/excalidraw/data/blob.d.ts +84 -28
  199. package/dist/types/excalidraw/data/index.d.ts +7 -7
  200. package/dist/types/excalidraw/data/json.d.ts +48 -20
  201. package/dist/types/excalidraw/data/library.d.ts +1 -1
  202. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  203. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  204. package/dist/types/excalidraw/fonts/Fonts.d.ts +12 -8
  205. package/dist/types/excalidraw/history.d.ts +10 -4
  206. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  207. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  208. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  209. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  210. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  211. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  212. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  213. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  214. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  215. package/dist/types/excalidraw/renderer/animation.d.ts +15 -4
  216. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  217. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
  218. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  219. package/dist/types/excalidraw/scene/Renderer.d.ts +490 -21
  220. package/dist/types/excalidraw/scene/export.d.ts +344 -21
  221. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  222. package/dist/types/excalidraw/scene/types.d.ts +30 -5
  223. package/dist/types/excalidraw/snapping.d.ts +7 -7
  224. package/dist/types/excalidraw/types.d.ts +617 -29
  225. package/dist/types/excalidraw/viewport.d.ts +308 -0
  226. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +13 -3
  227. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  228. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  229. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  230. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  231. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  232. package/dist/types/math/src/constants.d.ts +0 -1
  233. package/dist/types/math/src/curve.d.ts +19 -12
  234. package/dist/types/math/src/index.d.ts +1 -0
  235. package/dist/types/math/src/pca.d.ts +79 -0
  236. package/dist/types/math/src/point.d.ts +1 -0
  237. package/dist/types/math/src/polygon.d.ts +25 -1
  238. package/dist/types/math/src/segment.d.ts +6 -0
  239. package/dist/types/utils/src/index.d.ts +4 -3
  240. package/dist/types/utils/src/shape.d.ts +2 -2
  241. package/package.json +1 -1
  242. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  243. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  244. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  245. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  246. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  247. package/dist/types/excalidraw/components/shapes.d.ts +0 -263
  248. package/dist/types/excalidraw/cursor.d.ts +0 -5
  249. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  250. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  251. package/dist/types/utils/src/bbox.d.ts +0 -9
  252. package/dist/types/utils/src/export.d.ts +0 -35
  253. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -1,9 +1,9 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
1
+ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
2
2
  import type { LinearElementEditor } from "@excalidraw/element";
3
- import type { MaybeTransformHandleType } from "@excalidraw/element";
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 } from "@excalidraw/element/types";
3
+ import type { ListMarkerAdvance, MaybeTransformHandleType } from "@excalidraw/element";
4
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, ExcalidrawArrowElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
5
5
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
6
- import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
6
+ import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, RenderEnvironment, OnDuplicateData } from "@excalidraw/element";
7
7
  import type { GlobalPoint } from "@excalidraw/math";
8
8
  import type { Action } from "./actions/types";
9
9
  import type { Spreadsheet } from "./charts";
@@ -13,6 +13,7 @@ import type Library from "./data/library";
13
13
  import type { ContextMenuItems } from "./components/ContextMenu";
14
14
  import type { SnapLine } from "./snapping";
15
15
  import type { ImportedDataState } from "./data/types";
16
+ import type { SetViewportOptions } from "./viewport";
16
17
  import type { Language } from "./i18n";
17
18
  import type { isOverScrollBars } from "./scene/scrollbars";
18
19
  import type React from "react";
@@ -84,7 +85,7 @@ export type BinaryFileData = {
84
85
  };
85
86
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
86
87
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
87
- export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
88
+ export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "stickynote" | "embeddable" | "laser" | "autoshape" | "bucketfill";
88
89
  export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
89
90
  export type ActiveTool = {
90
91
  type: ToolType;
@@ -138,7 +139,9 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
138
139
  newElement: AppState["newElement"];
139
140
  isBindingEnabled: AppState["isBindingEnabled"];
140
141
  isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
142
+ gridModeEnabled: AppState["gridModeEnabled"];
141
143
  suggestedBinding: AppState["suggestedBinding"];
144
+ textToolHover: AppState["textToolHover"];
142
145
  isRotating: AppState["isRotating"];
143
146
  elementsToHighlight: AppState["elementsToHighlight"];
144
147
  collaborators: AppState["collaborators"];
@@ -173,6 +176,46 @@ export type ObservedElementsAppState = {
173
176
  activeLockedId: AppState["activeLockedId"];
174
177
  };
175
178
  export type BoxSelectionMode = "contain" | "overlap";
179
+ /**
180
+ * The pointing device the wheel mappings are tuned for. `auto` is reserved
181
+ * for detecting it from the wheel events; see `resolveInputDevice`.
182
+ */
183
+ export type InputDevice = "auto" | "mouse" | "trackpad";
184
+ /**
185
+ * A box, in scene coordinates, that pan & zoom are constrained to.
186
+ *
187
+ * This is a private type. For public API, only use specific properties,
188
+ * needed.
189
+ */
190
+ export type ScrollConstraints = {
191
+ x: number;
192
+ y: number;
193
+ width: number;
194
+ height: number;
195
+ /** when set, panning is constrained so the viewport stays within the box */
196
+ lockScroll: boolean;
197
+ /** when set, the viewport cannot zoom out below `zoom` */
198
+ lockZoom: boolean;
199
+ /**
200
+ * The zoom resolved after the `setViewport` navigation settled.
201
+ */
202
+ zoom: number;
203
+ /**
204
+ * Pixel amount the viewport may overscroll past its resting clamp before
205
+ * snapping back (rubberband). Screen pixels, zoom-independent. Resolved
206
+ * from `lock.overscroll` at the time the lock was installed (`true` →
207
+ * default give, `false` → 0).
208
+ */
209
+ overscroll: number;
210
+ /**
211
+ * Extra scrollable margin around the box (CSS-style), letting the viewport
212
+ * scroll past each box edge to reveal that much empty space. Values are
213
+ * viewport pixels and zoom-independent (a fixed on-screen distance).
214
+ * Resolved from the `offsets` passed to `setViewport` (see
215
+ * {@link ViewportOffsets}) at the time the lock was installed.
216
+ */
217
+ offsets?: Offsets;
218
+ };
176
219
  export interface AppState {
177
220
  contextMenu: {
178
221
  items: ContextMenuItems;
@@ -217,11 +260,47 @@ export interface AppState {
217
260
  bindingPreference: "enabled" | "disabled";
218
261
  /** user preference whether arrow snap to midpoints while binding */
219
262
  isMidpointSnappingEnabled: boolean;
220
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
263
+ /** user preference whether to show contextual hints above the toolbar */
264
+ showHints: boolean;
265
+ /**
266
+ * user preference whether multiline text is pasted split into a text
267
+ * element per line (set from the toast shown after such a paste)
268
+ */
269
+ splitOnPaste: boolean;
270
+ /**
271
+ * user preference for what the wheel does: with a `trackpad` a plain wheel
272
+ * pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
273
+ * delivered) zooms with either device. Shift+wheel pans horizontally;
274
+ * ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
275
+ * device detection exists — see `resolveInputDevice`
276
+ */
277
+ inputDevice: InputDevice;
278
+ /**
279
+ * The bindable element the UI highlights for the user when an arrow is
280
+ * dragged or otherwise its endpoint being close to said element.
281
+ */
221
282
  suggestedBinding: {
222
283
  element: NonDeleted<ExcalidrawBindableElement>;
223
284
  midPoint?: GlobalPoint;
224
285
  } | null;
286
+ /**
287
+ * What a text-tool click at the hovered position would act on — the text
288
+ * it would edit, the empty container it would label, or the arrow anchor
289
+ * (a free endpoint, or the midpoint for a label) it would attach text to.
290
+ * `null` when the click would create free text, or the tool isn't active.
291
+ * Drives the hover affordance only.
292
+ */
293
+ textToolHover: {
294
+ type: "text";
295
+ elementId: ExcalidrawElement["id"];
296
+ } | {
297
+ type: "container";
298
+ elementId: ExcalidrawElement["id"];
299
+ } | {
300
+ type: "arrow";
301
+ elementId: ExcalidrawArrowElement["id"];
302
+ anchor: "start" | "end" | "label";
303
+ } | null;
225
304
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
226
305
  frameRendering: {
227
306
  enabled: boolean;
@@ -229,8 +308,15 @@ export interface AppState {
229
308
  outline: boolean;
230
309
  clip: boolean;
231
310
  };
232
- editingFrame: string | null;
233
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
311
+ /**
312
+ * frame-like element whose name is currently being edited
313
+ */
314
+ editingFrame: ExcalidrawFrameLikeElement["id"] | null;
315
+ /**
316
+ * Elements the UI highlights with a bounding-box outline — those that
317
+ * would get added to a frame being dragged/resized.
318
+ */
319
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
234
320
  /**
235
321
  * set when a new text is created or when an existing text is being edited
236
322
  */
@@ -255,11 +341,14 @@ export interface AppState {
255
341
  exportWithDarkMode: boolean;
256
342
  exportScale: number;
257
343
  currentItemStrokeColor: string;
344
+ currentItemStickynoteStrokeColor: string;
345
+ currentItemStickynoteBackgroundColor: string;
258
346
  currentItemBackgroundColor: string;
259
347
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
260
- currentItemStrokeWidth: number;
348
+ currentItemStrokeWidthKey: StrokeWidthKey;
261
349
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
262
350
  currentItemRoughness: number;
351
+ currentItemStrokeVariability: StrokeVariability;
263
352
  currentItemOpacity: number;
264
353
  currentItemFontFamily: FontFamilyValues;
265
354
  currentItemFontSize: number;
@@ -272,6 +361,7 @@ export interface AppState {
272
361
  viewBackgroundColor: string;
273
362
  scrollX: number;
274
363
  scrollY: number;
364
+ scrollConstraints: ScrollConstraints | null;
275
365
  cursorButton: "up" | "down";
276
366
  scrolledOutside: boolean;
277
367
  name: string | null;
@@ -325,8 +415,14 @@ export interface AppState {
325
415
  message: React.ReactNode;
326
416
  closable?: boolean;
327
417
  duration?: number;
418
+ /** a link-like button after the message; it closes the toast, too */
419
+ action?: {
420
+ label: string;
421
+ onClick: () => void;
422
+ };
328
423
  } | null;
329
424
  zenModeEnabled: boolean;
425
+ minimapEnabled: boolean;
330
426
  theme: Theme;
331
427
  /** grid cell px size */
332
428
  gridSize: number;
@@ -359,10 +455,6 @@ export interface AppState {
359
455
  y: number;
360
456
  } | null;
361
457
  objectsSnapModeEnabled: boolean;
362
- /** the user's socket id & username who is being followed on the canvas */
363
- userToFollow: UserToFollow | null;
364
- /** the socket ids of the users following the current user */
365
- followedBy: Set<SocketId>;
366
458
  /** image cropping */
367
459
  isCropping: boolean;
368
460
  croppingElementId: ExcalidrawElement["id"] | null;
@@ -377,6 +469,23 @@ export interface AppState {
377
469
  [groupId: string]: true;
378
470
  };
379
471
  bindMode: BindMode;
472
+ /** user-customized color-picker top picks (pinned via drag & drop from the
473
+ * color picker popup). `null` means no customization (defaults, or
474
+ * host-supplied `topPicks`, are used). Kept per picker. */
475
+ colorTopPicks: {
476
+ elementStroke: readonly string[] | null;
477
+ elementBackground: readonly string[] | null;
478
+ /** the bucket-fill tool keeps a list separate from `elementBackground`
479
+ * even though both drive `currentItemBackgroundColor` (its defaults and
480
+ * use case differ — no transparent) */
481
+ bucketFill: readonly string[] | null;
482
+ /** sticky notes are their own color domain (own defaults, own picks) */
483
+ stickyNoteStroke: readonly string[] | null;
484
+ stickyNoteBackground: readonly string[] | null;
485
+ };
486
+ /** user-customized font-picker top picks (pinned via drag & drop from the
487
+ * font picker popup). `null` means no customization (defaults are used) */
488
+ fontTopPicks: readonly FontFamilyValues[] | null;
380
489
  }
381
490
  export type SearchMatch = {
382
491
  id: string;
@@ -389,7 +498,7 @@ export type SearchMatch = {
389
498
  showOnCanvas: boolean;
390
499
  }[];
391
500
  };
392
- export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
501
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
393
502
  export type NormalizedZoomValue = number & {
394
503
  _brand: "normalizedZoom";
395
504
  };
@@ -433,23 +542,224 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
433
542
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
434
543
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
435
544
  }>;
545
+ export type ExcalidrawInitialState = {
546
+ viewport?: Omit<SetViewportOptions, "animation">;
547
+ };
436
548
  export type OnUserFollowedPayload = {
437
549
  userToFollow: UserToFollow;
438
550
  action: "FOLLOW" | "UNFOLLOW";
439
551
  };
552
+ export type ViewportStatusFrame = {
553
+ /** the badge (bottom-center pill) */
554
+ label?: {
555
+ label: React.ReactNode;
556
+ icon?: React.ReactNode;
557
+ /** badge background; defaults to var(--color-primary-hover) */
558
+ background?: string;
559
+ /** badge text color; defaults to var(--color-primary-light) */
560
+ color?: string;
561
+ /** makes the badge label interactive */
562
+ onClick?: () => void;
563
+ /** renders a close button when set */
564
+ onClose?: () => void;
565
+ };
566
+ /** viewport-edge border: CSS color, or `false` for none */
567
+ border: false | string;
568
+ };
440
569
  export type OnExportProgress = {
441
570
  type: "progress";
442
571
  message?: React.ReactNode;
443
572
  /** 0-1 range */
444
573
  progress?: number;
445
574
  };
575
+ export type InteractionConfig = {
576
+ /**
577
+ * Interactions that stay enabled while the editor is otherwise
578
+ * non-interactive. Opt-in: anything omitted or `false` is disabled.
579
+ */
580
+ enabled?: {
581
+ /**
582
+ * Element links render their link icon and stay clickable — clicking
583
+ * anywhere on a linked element opens the link, same as in view mode.
584
+ * When disabled, link icons are not rendered at all.
585
+ *
586
+ * @default false
587
+ */
588
+ links?: boolean;
589
+ /**
590
+ * Embeddable & iframe elements stay interactive — hovering & clicking
591
+ * activates them so their content can be used, same as in view mode.
592
+ *
593
+ * @default false
594
+ */
595
+ embeds?: boolean;
596
+ /**
597
+ * Umbrella for all interactive content on canvas — shorthand for
598
+ * enabling `links` & `embeds` (and future interactive content kinds)
599
+ * together. Additive: `interactiveContent: true` enables them
600
+ * regardless of their individual values.
601
+ *
602
+ * @default false
603
+ */
604
+ interactiveContent?: boolean;
605
+ /**
606
+ * Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
607
+ * and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
608
+ * zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
609
+ * mode. Respects `appState.scrollConstraints` if set, so it composes
610
+ * with viewport locking. The rest of the keyboard stays disabled. Note
611
+ * the editor consumes wheel & touch input again when enabled, so the
612
+ * page no longer scrolls over the editor.
613
+ *
614
+ * @default false
615
+ */
616
+ navigation?: boolean;
617
+ /**
618
+ * Whether the browser's own zoom remains available over the editor —
619
+ * ctrl/cmd + wheel, pinch, and (while the editor has focus)
620
+ * ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
621
+ * interactive editor. Regular page scrolling stays available either way.
622
+ * With `navigation` enabled, the zoom input (wheel, pinch, keyboard
623
+ * shortcuts) zooms the canvas instead either way, making this moot.
624
+ *
625
+ * @default false
626
+ */
627
+ browserZoom?: boolean;
628
+ /**
629
+ * Tools that stay user-driven while the editor is otherwise
630
+ * non-interactive: pointer input keeps driving the listed tool when it's
631
+ * the active tool. Does not enable user-driven tool *switching* — the
632
+ * keyboard stays disabled and tool selection remains host-driven
633
+ * (`ExcalidrawAPI.setActiveTool`).
634
+ *
635
+ * Composes with `navigation`: the enabled tool wins the primary-pointer
636
+ * drag, while wheel input (and wheel-button drag) still pans/zooms.
637
+ */
638
+ tools?: {
639
+ /**
640
+ * The laser pointer stays usable — pointer strokes draw laser trails
641
+ * and pointer positions keep broadcasting via `onPointerUpdate`, so
642
+ * e.g. collaborators see a presenter's laser & cursor.
643
+ *
644
+ * @default false
645
+ */
646
+ laser?: boolean;
647
+ /**
648
+ * Custom tools (`activeTool.type === "custom"`) stay usable — the
649
+ * editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
650
+ * Tool behavior is host-implemented; activate custom tools with
651
+ * `locked: true` or they revert to the selection tool (and go inert)
652
+ * after the first pointer interaction.
653
+ *
654
+ * @default false
655
+ */
656
+ custom?: boolean;
657
+ };
658
+ };
659
+ };
660
+ export type UIConfig = {
661
+ /**
662
+ * Default UI controls that stay enabled while the rest of Excalidraw's
663
+ * default UI is hidden. Opt-in: anything omitted or `false` is
664
+ * disabled.
665
+ */
666
+ enabled: {
667
+ /**
668
+ * The zoom controls (zoom out, the zoom level resetting it, zoom in).
669
+ *
670
+ * @default false
671
+ */
672
+ zoom?: boolean;
673
+ /**
674
+ * The button shown when the viewport is scrolled away from all
675
+ * content.
676
+ *
677
+ * @default false
678
+ */
679
+ scrollBackToContent?: boolean;
680
+ };
681
+ } | {
682
+ /**
683
+ * Default UI controls that are removed while the rest of Excalidraw's
684
+ * default UI is rendered. Opt-out: anything omitted or `false` stays.
685
+ */
686
+ disabled: {
687
+ /**
688
+ * The minimap, and every way to toggle it (its footer button, the
689
+ * Preferences menu item, and the command palette and context menu
690
+ * entries). Without the minimap toggle next to them, the zoom
691
+ * controls are the zoom out / zoom level / zoom in buttons instead of
692
+ * the zoom menu.
693
+ *
694
+ * @default false
695
+ */
696
+ minimap?: boolean;
697
+ };
698
+ };
699
+ /** A default UI control that `UIConfig` can keep or remove. */
700
+ export type UIControl = keyof Extract<UIConfig, {
701
+ enabled: unknown;
702
+ }>["enabled"] | keyof Extract<UIConfig, {
703
+ disabled: unknown;
704
+ }>["disabled"];
705
+ /** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
706
+ export type ElementRenderOverride = Readonly<{
707
+ /** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
708
+ opacity?: number;
709
+ /** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
710
+ offset?: Readonly<{
711
+ x: number;
712
+ y: number;
713
+ }>;
714
+ }>;
715
+ /** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
716
+ export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
717
+ /** The translation part of a snapshot: only the entries that carry an offset. */
718
+ export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
446
719
  export interface ExcalidrawProps {
720
+ className?: string;
721
+ /**
722
+ * Document that owns Excalidraw's mounted DOM.
723
+ *
724
+ * Set only when it differs from the global `document`, such as when code
725
+ * executing in a parent window mounts Excalidraw into an iframe document.
726
+ * The value must remain stable for the editor's lifetime.
727
+ *
728
+ * @default document
729
+ */
730
+ ownerDocument?: Document;
731
+ /**
732
+ * Host environment used by the renderer and export pipeline to create
733
+ * canvases and images. Supply a custom implementation to redirect canvas
734
+ * creation and image decoding to e.g. a host canvas pool, an
735
+ * `OffscreenCanvas`, or a non-DOM image decoder. When omitted, canvas and
736
+ * image creation fall back to `ownerDocument` / `ownerWindow`.
737
+ *
738
+ * The value must be referentially stable -- every render cache (element
739
+ * canvases, text metrics, char widths, link icons) is keyed by this
740
+ * object's identity, so a new identity is a full cache miss. Passing an
741
+ * inline object literal mints a fresh identity on every React render,
742
+ * which silently re-rasterizes every element on every frame; hoist it to a
743
+ * module constant or memoize it (e.g. `useMemo`) instead.
744
+ *
745
+ * Only `createCanvas` and `createImage` are required. `createPath` (used to
746
+ * fill freedraw strokes) falls back to the global `Path2D`, which every
747
+ * browser has -- a non-browser host without one must supply it. Pass
748
+ * `document` (the owner document) for SVG exports to be built in it rather
749
+ * than in the global `document`, and `textMetrics` to measure the editor's
750
+ * text with your own provider.
751
+ *
752
+ * @default { createCanvas: () => ownerDocument.createElement("canvas"), createImage: () => new ownerWindow.Image(), createPath: (d) => new ownerWindow.Path2D(d), document: ownerDocument }
753
+ */
754
+ renderEnvironment?: RenderEnvironment;
447
755
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
756
+ onThemeChange?: (theme: Theme | "system") => void;
448
757
  /**
449
758
  * note: only subscribes if the props.onIncrement is defined on initial render
450
759
  */
451
760
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
452
761
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
762
+ initialState?: ExcalidrawInitialState;
453
763
  /**
454
764
  * Invoked as soon as the Excalidraw API is available
455
765
  * NOTE editor is not yet mounted, and state is not yet initialized
@@ -487,15 +797,97 @@ export interface ExcalidrawProps {
487
797
  *
488
798
  * Returned elements will be used in place of the next elements
489
799
  * (you should return all elements, including deleted, and not mutate
490
- * the element if changes are made)
800
+ * the element if changes are made).
801
+ *
802
+ * The duplicates are the elements in `nextElements` which are not in
803
+ * `prevElements` (see also `data.duplicateElements`). When pasting or
804
+ * inserting onto a frame, their `frameId` is already set. To change a
805
+ * duplicate, return a new object with the same `id`. It is shallow-merged
806
+ * into the duplicate (omitted properties are kept), and your changes are
807
+ * part of the duplication itself (same undo entry, same durable increment).
808
+ *
809
+ * To prevent an element from being duplicated, omit its duplicate from the
810
+ * returned array. References to it from the remaining duplicates are
811
+ * cleared, and a bound text isn't duplicated without its container. To
812
+ * prevent the duplication as a whole, return `false`. If no duplicate
813
+ * remains, the duplication is cancelled and the returned elements are
814
+ * ignored (alt-drag then moves the original elements instead).
491
815
  */
492
816
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
493
817
  /** excludes the duplicated elements */
494
- prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
818
+ prevElements: readonly ExcalidrawElement[],
819
+ /** lookups covering just the elements taking part in the duplication */
820
+ data: OnDuplicateData) => ExcalidrawElement[] | void | false;
495
821
  renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
496
822
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
497
823
  langCode?: Language["code"];
498
824
  viewModeEnabled?: boolean;
825
+ /**
826
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
827
+ * clipboard, drag&drop). When `false`, the scene still renders and reacts
828
+ * to programmatic updates (imperative API), but the user cannot affect it
829
+ * in any way. Implies view mode.
830
+ *
831
+ * Pass a config object to keep specific interactions enabled while the
832
+ * editor is otherwise non-interactive (see `InteractionConfig`):
833
+ *
834
+ * ```tsx
835
+ * <Excalidraw interaction={{ enabled: { links: true } }} />
836
+ * ```
837
+ *
838
+ * @default true
839
+ */
840
+ interaction?: boolean | InteractionConfig;
841
+ /**
842
+ * Whether Excalidraw's default UI is rendered — toolbar, default menus,
843
+ * footer controls, sidebars, and canvas popups. Host UI passed through
844
+ * children (including exported components such as `MainMenu` and `Footer`)
845
+ * or render props continues to render, together with any supporting dialogs
846
+ * it opens.
847
+ *
848
+ * Canvas content (elements, text editing surface, frame names, embeds) still
849
+ * renders, and the editor remains interactive unless `interaction` is set to
850
+ * `false`.
851
+ *
852
+ * Pass a config object to keep specific default controls rendered while the
853
+ * rest of the default UI is hidden, or to remove specific controls from the
854
+ * otherwise full default UI (see `UIConfig`):
855
+ *
856
+ * ```tsx
857
+ * <Excalidraw ui={{ enabled: { zoom: true } }} />
858
+ * <Excalidraw ui={{ disabled: { minimap: true } }} />
859
+ * ```
860
+ *
861
+ * NOTE: this is WIP and what default UI is/is not rendered when ui=false
862
+ * may yet change.
863
+ *
864
+ * @default true
865
+ */
866
+ ui?: boolean | UIConfig;
867
+ /**
868
+ * Forces the active editor tool (controlled). While set, user- and
869
+ * API-driven tool switching is ignored — `setActiveTool` refuses with a
870
+ * console warning, non-forced toolbar buttons render disabled — and the
871
+ * editor snaps back if internal flows reset the tool. The forced tool
872
+ * behaves as if locked (see the tool lock / padlock): it doesn't revert to
873
+ * the selection tool after use, and elements drawn with it aren't
874
+ * auto-selected — without mutating `appState.activeTool.locked`, so the
875
+ * user's persisted padlock preference stays untouched. Unset to return
876
+ * tool control to the editor (the current tool stays active).
877
+ *
878
+ * The forced tool must be activatable to take effect: not disabled via
879
+ * `UIOptions.tools`, and — while the editor is non-interactive — allowed
880
+ * via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
881
+ * non-interactive, resets to) the `selection` tool, and the forced tool is
882
+ * applied once it becomes activatable. `image` cannot be forced (its
883
+ * activation opens the file picker).
884
+ */
885
+ activeTool?: {
886
+ type: Exclude<ToolType, "image">;
887
+ } | {
888
+ type: "custom";
889
+ customType: string;
890
+ };
499
891
  zenModeEnabled?: boolean;
500
892
  gridModeEnabled?: boolean;
501
893
  objectsSnapModeEnabled?: boolean;
@@ -504,6 +896,10 @@ export interface ExcalidrawProps {
504
896
  name?: string;
505
897
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
506
898
  UIOptions?: Partial<UIOptions>;
899
+ /**
900
+ * dimensions and size constraints for inserted images
901
+ */
902
+ imageOptions?: ImageOptions;
507
903
  detectScroll?: boolean;
508
904
  handleKeyboardGlobally?: boolean;
509
905
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -523,6 +919,21 @@ export interface ExcalidrawProps {
523
919
  aiEnabled?: boolean;
524
920
  showDeprecatedFonts?: boolean;
525
921
  renderScrollbars?: boolean;
922
+ viewportStatusFrame?: ViewportStatusFrame | null;
923
+ /**
924
+ * Rendered inside the UserList "who's here" dropdown (desktop) and inline
925
+ * in the mobile menu's collaborators section, below a divider. Accepts a
926
+ * render function — called with `isMobile` so hosts can render different
927
+ * UI for each surface — in addition to a plain node.
928
+ */
929
+ currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
930
+ /**
931
+ * The user being followed on the canvas, if any. Controlled by the host —
932
+ * the editor never sets it; it emits follow/unfollow intents via
933
+ * `onUserFollow` (prop or imperative API) and renders the followed
934
+ * user's avatar highlight from this value.
935
+ */
936
+ userToFollow?: UserToFollow | null;
526
937
  /**
527
938
  * Called before exporting to a file.
528
939
  *
@@ -548,7 +959,8 @@ export interface ExcalidrawProps {
548
959
  }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
549
960
  }
550
961
  export type SceneData = {
551
- elements?: ImportedDataState["elements"];
962
+ /** Expects normalized elements; restore imported data before updating the scene. */
963
+ elements?: readonly ExcalidrawElement[] | null;
552
964
  appState?: ImportedDataState["appState"];
553
965
  collaborators?: Map<SocketId, Collaborator>;
554
966
  captureUpdate?: CaptureUpdateActionType;
@@ -558,12 +970,21 @@ export type ExportOpts = {
558
970
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
559
971
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
560
972
  };
973
+ export type ImageOptions = Partial<{
974
+ maxWidthOrHeight: number;
975
+ maxFileSizeBytes: number;
976
+ }>;
561
977
  export type CanvasActions = Partial<{
562
978
  changeViewBackgroundColor: boolean;
563
979
  clearCanvas: boolean;
564
980
  export: false | ExportOpts;
565
981
  loadScene: boolean;
566
982
  saveToActiveFile: boolean;
983
+ /**
984
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
985
+ * is supplied (at which point the theme is considered as host-app controlled),
986
+ * else default to false
987
+ * */
567
988
  toggleTheme: boolean | null;
568
989
  saveAsImage: boolean;
569
990
  }>;
@@ -587,6 +1008,7 @@ export type AppProps = Merge<ExcalidrawProps, {
587
1008
  export: ExportOpts;
588
1009
  };
589
1010
  }>;
1011
+ imageOptions: Required<ImageOptions>;
590
1012
  detectScroll: boolean;
591
1013
  handleKeyboardGlobally: boolean;
592
1014
  isCollaborating: boolean;
@@ -598,6 +1020,9 @@ export type AppProps = Merge<ExcalidrawProps, {
598
1020
  export type AppClassProperties = {
599
1021
  props: AppProps;
600
1022
  state: AppState;
1023
+ readonly ownerDocument: Document;
1024
+ readonly ownerWindow: Window & typeof globalThis;
1025
+ renderEnvironment: RenderEnvironment;
601
1026
  api: App["api"];
602
1027
  sessionExportThemeOverride: App["sessionExportThemeOverride"];
603
1028
  interactiveCanvas: HTMLCanvasElement | null;
@@ -614,12 +1039,12 @@ export type AppClassProperties = {
614
1039
  scene: App["scene"];
615
1040
  syncActionResult: App["syncActionResult"];
616
1041
  fonts: App["fonts"];
617
- pasteFromClipboard: App["pasteFromClipboard"];
1042
+ clipboard: App["clipboard"];
618
1043
  id: App["id"];
619
1044
  onInsertElements: App["onInsertElements"];
620
1045
  onExportImage: App["onExportImage"];
621
- lastViewportPosition: App["lastViewportPosition"];
622
- scrollToContent: App["scrollToContent"];
1046
+ viewport: App["viewport"];
1047
+ wheel: App["wheel"];
623
1048
  addFiles: App["addFiles"];
624
1049
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
625
1050
  togglePenMode: App["togglePenMode"];
@@ -630,11 +1055,23 @@ export type AppClassProperties = {
630
1055
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
631
1056
  getName: App["getName"];
632
1057
  dismissLinearEditor: App["dismissLinearEditor"];
633
- flowChartCreator: App["flowChartCreator"];
1058
+ flowchart: App["flowchart"];
1059
+ drawShape: App["drawShape"];
1060
+ arrowText: App["arrowText"];
1061
+ text: App["text"];
1062
+ textTool: App["textTool"];
1063
+ cursor: App["cursor"];
1064
+ bucketFill: App["bucketFill"];
1065
+ duplicate: App["duplicate"];
1066
+ toolDrag: App["toolDrag"];
1067
+ activeResizeHandle: App["activeResizeHandle"];
1068
+ selectionTool: App["selectionTool"];
1069
+ wrap: App["wrap"];
1070
+ modifiers: App["modifiers"];
1071
+ isToolLocked: App["isToolLocked"];
634
1072
  getEffectiveGridSize: App["getEffectiveGridSize"];
635
1073
  setPlugins: App["setPlugins"];
636
1074
  plugins: App["plugins"];
637
- getEditorUIOffsets: App["getEditorUIOffsets"];
638
1075
  visibleElements: App["visibleElements"];
639
1076
  excalidrawContainerValue: App["excalidrawContainerValue"];
640
1077
  onPointerUpEmitter: App["onPointerUpEmitter"];
@@ -643,8 +1080,14 @@ export type AppClassProperties = {
643
1080
  onEvent: App["onEvent"];
644
1081
  onStateChange: App["onStateChange"];
645
1082
  lastPointerMoveCoords: App["lastPointerMoveCoords"];
1083
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
646
1084
  bindModeHandler: App["bindModeHandler"];
1085
+ emitUserFollowIntent: App["emitUserFollowIntent"];
1086
+ requestUnfollow: App["requestUnfollow"];
647
1087
  setAppState: App["setAppState"];
1088
+ isInteractionEnabled: App["isInteractionEnabled"];
1089
+ isNavigationEnabled: App["isNavigationEnabled"];
1090
+ isUIControlEnabled: App["isUIControlEnabled"];
648
1091
  };
649
1092
  export type PointerDownState = Readonly<{
650
1093
  origin: Readonly<{
@@ -678,8 +1121,12 @@ export type PointerDownState = Readonly<{
678
1121
  element: NonDeleted<ExcalidrawElement> | null;
679
1122
  allHitElements: NonDeleted<ExcalidrawElement>[];
680
1123
  wasAddedToSelection: boolean;
1124
+ cycleTarget: NonDeleted<ExcalidrawElement> | null;
681
1125
  hasBeenDuplicated: boolean;
1126
+ advancedListMarkers: readonly ListMarkerAdvance[];
1127
+ editedTextId: ExcalidrawTextElement["id"] | null;
682
1128
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
1129
+ arrowLabel: boolean;
683
1130
  };
684
1131
  withCmdOrCtrl: boolean;
685
1132
  drag: {
@@ -692,6 +1139,10 @@ export type PointerDownState = Readonly<{
692
1139
  x: number;
693
1140
  y: number;
694
1141
  };
1142
+ lastOffset: {
1143
+ x: number;
1144
+ y: number;
1145
+ };
695
1146
  blockDragging: boolean;
696
1147
  };
697
1148
  eventListeners: {
@@ -727,19 +1178,51 @@ export interface ExcalidrawImperativeAPI {
727
1178
  history: {
728
1179
  clear: InstanceType<typeof App>["resetHistory"];
729
1180
  };
1181
+ /**
1182
+ * Selects elements (or their ids — one or many), adds them to or removes
1183
+ * them from the selection, or clears it — as the editor does: an element is
1184
+ * selected with its group (unless `deep`), a frame and its children aren't
1185
+ * selected at the same time, and locked elements are skipped (unless
1186
+ * `includeLocked`). Text editing and cropping end, and the link popup of a
1187
+ * lone selected element shows. Missing and deleted elements are skipped.
1188
+ *
1189
+ * By default the change is recorded for undo along with the next undoable
1190
+ * change — pass `captureUpdate` as for `updateScene()` otherwise. Like
1191
+ * `updateScene()`, it applies on the next render: read it back through
1192
+ * `onChange()` or `getAppState()` after that. Works in view mode too, where
1193
+ * the selection shows without transform handles.
1194
+ */
1195
+ selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
730
1196
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
731
1197
  getAppState: () => InstanceType<typeof App>["state"];
732
1198
  getFiles: () => InstanceType<typeof App>["files"];
733
1199
  getName: InstanceType<typeof App>["getName"];
734
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
1200
+ setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
1201
+ getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
1202
+ /**
1203
+ * Atomically replaces all transient visual overrides. Values are copied;
1204
+ * omitted IDs/fields use document values, except for inherited label offsets.
1205
+ * null clears the snapshot.
1206
+ * Repaints without document changes, history entries or onChange events;
1207
+ * an equivalent snapshot may still repaint (clearing an already clear
1208
+ * snapshot does not), so submit only when something changed.
1209
+ * Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
1210
+ * Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
1211
+ * Bound labels inherit their container's offset; offsets targeting them are
1212
+ * ignored. Label opacity remains independent. Target frame children explicitly.
1213
+ * Frame opacity still multiplies child opacity. Decorations follow their owner.
1214
+ * Exports and interactive geometry (hit tests, selection, editing) use document
1215
+ * values, including while authoring an animation preview in edit mode.
1216
+ */
1217
+ setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
735
1218
  registerAction: (action: Action) => void;
736
1219
  refresh: InstanceType<typeof App>["refresh"];
737
1220
  setToast: InstanceType<typeof App>["setToast"];
738
1221
  addFiles: (data: BinaryFileData[]) => void;
739
1222
  id: string;
740
1223
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
741
- setCursor: InstanceType<typeof App>["setCursor"];
742
- resetCursor: InstanceType<typeof App>["resetCursor"];
1224
+ setCursor: InstanceType<typeof App>["cursor"]["set"];
1225
+ resetCursor: InstanceType<typeof App>["cursor"]["reset"];
743
1226
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
744
1227
  getEditorInterface: () => EditorInterface;
745
1228
  /**
@@ -762,7 +1245,6 @@ export type FrameNameBounds = {
762
1245
  y: number;
763
1246
  width: number;
764
1247
  height: number;
765
- angle: number;
766
1248
  };
767
1249
  export type FrameNameBoundsCache = {
768
1250
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -781,12 +1263,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
781
1263
  export type JSONValue = string | number | boolean | null | object;
782
1264
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
783
1265
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
784
- export type PendingExcalidrawElements = ExcalidrawElement[];
1266
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
785
1267
  /** Runtime gridSize value. Null indicates disabled grid. */
786
1268
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
787
1269
  export type GenerateDiagramToCode = (props: {
788
- frame: ExcalidrawMagicFrameElement;
789
- children: readonly ExcalidrawElement[];
1270
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
1271
+ children: readonly NonDeletedExcalidrawElement[];
1272
+ /**
1273
+ * Optional streaming hook. Call with the accumulated response text as it
1274
+ * streams in so the editor can progressively render the partial HTML
1275
+ * inside the generated frame.
1276
+ */
1277
+ onPartial?: (html: string) => void;
790
1278
  }) => MaybePromise<{
791
1279
  html: string;
792
1280
  }>;
@@ -796,3 +1284,103 @@ export type Offsets = Partial<{
796
1284
  bottom: number;
797
1285
  left: number;
798
1286
  }>;
1287
+ /**
1288
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
1289
+ * surface that occludes the canvas. Such nodes are measured by
1290
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
1291
+ *
1292
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
1293
+ * - `side` — a panel hugging the left or right edge. Which side is not
1294
+ * declared but resolved geometrically: if the node's horizontal center
1295
+ * lies in the left half of the viewport it counts against the left
1296
+ * offset (by its right edge), otherwise against the right offset (by
1297
+ * `viewportWidth - left edge`). Measuring the rendered position instead
1298
+ * of declaring a side means RTL layouts and host-configurable docking
1299
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
1300
+ * actually hugs one edge; don't mark a centered/near-full-width node as
1301
+ * `side` (its midpoint would classify it to one side and the offset
1302
+ * would swallow most of the viewport).
1303
+ *
1304
+ * The attribute should only be present while the surface is actually
1305
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
1306
+ * push the viewport around.
1307
+ */
1308
+ export type ViewportUIDock = "top" | "bottom" | "side";
1309
+ /**
1310
+ * Options for `getViewportOffsets` (and the `ui` key of
1311
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
1312
+ * currently rendered editor UI.
1313
+ *
1314
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
1315
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
1316
+ * reading-direction start side).
1317
+ */
1318
+ export type ViewportOffsetsOptions = {
1319
+ /** padding added to each measured side (default 24) */
1320
+ padding?: number;
1321
+ paddingTop?: number;
1322
+ paddingRight?: number;
1323
+ paddingBottom?: number;
1324
+ paddingLeft?: number;
1325
+ /** final value for the given side, replacing the measured UI size
1326
+ * (padding is not added on top) */
1327
+ top?: number;
1328
+ bottom?: number;
1329
+ left?: number;
1330
+ right?: number;
1331
+ /**
1332
+ * Reserve space for the given conditionally-rendered surfaces even while
1333
+ * they're hidden, so the resulting offsets don't shift when they
1334
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
1335
+ * to an approximate default if it hasn't been rendered yet. Ignored on
1336
+ * phones (where these surfaces never occlude the canvas).
1337
+ */
1338
+ reserve?: {
1339
+ /** styles panel (rendered when a tool or selection is active) */
1340
+ stylesPanel?: boolean;
1341
+ /** sidebar (e.g. library) */
1342
+ sidebar?: boolean;
1343
+ };
1344
+ };
1345
+ /**
1346
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
1347
+ * `props.initialState.viewport`), insetting the usable viewport area per
1348
+ * side so the target isn't fitted/centered underneath overlaid UI.
1349
+ *
1350
+ * Two (combinable) ways to specify:
1351
+ *
1352
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
1353
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
1354
+ * no padding added. Sides not specified default to `0` (unless `ui` is
1355
+ * set, see below).
1356
+ *
1357
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
1358
+ * panel, sidebar...) as rendered at the time the viewport is set,
1359
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
1360
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
1361
+ * padding or reserve space for currently-hidden surfaces.
1362
+ *
1363
+ * When both are given, a static side always wins for that side — it
1364
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
1365
+ * which — unlike the physical static sides — are RTL-relative). The
1366
+ * remaining sides fall back to the `ui`-derived values.
1367
+ *
1368
+ * @example
1369
+ * { top: 40 } // top 40px, other sides 0
1370
+ * { ui: true } // measured UI + default padding
1371
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
1372
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
1373
+ */
1374
+ export type ViewportOffsets = Offsets & {
1375
+ ui?: true | ViewportOffsetsOptions;
1376
+ };
1377
+ /**
1378
+ * Value of the `data-viewport-ui-name` attribute, identifying a
1379
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1380
+ * it can be measured on its own, and so that `getViewportOffsets` can
1381
+ * reserve space for it while it's hidden (see the `reserve` option).
1382
+ * Whenever a named surface is rendered, its measured footprint is
1383
+ * remembered; reserving uses that remembered footprint, or an approximate
1384
+ * default if the surface hasn't been rendered yet.
1385
+ */
1386
+ export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";