@excalidraw/common 0.18.0-b1c6bfc → 0.18.0-b55c9ee

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 (254) hide show
  1. package/dist/dev/index.js +239 -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 +70 -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 +95 -18
  54. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  55. package/dist/types/excalidraw/actions/actionBoundText.d.ts +78 -204
  56. package/dist/types/excalidraw/actions/actionCanvas.d.ts +299 -951
  57. package/dist/types/excalidraw/actions/actionClipboard.d.ts +66 -12
  58. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +33 -6
  59. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -521
  60. package/dist/types/excalidraw/actions/actionDeselect.d.ts +34 -7
  61. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  62. package/dist/types/excalidraw/actions/actionElementLink.d.ts +33 -6
  63. package/dist/types/excalidraw/actions/actionElementLock.d.ts +67 -13
  64. package/dist/types/excalidraw/actions/actionExport.d.ts +74 -20
  65. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  66. package/dist/types/excalidraw/actions/actionFrame.d.ts +129 -652
  67. package/dist/types/excalidraw/actions/actionGroup.d.ts +81 -27
  68. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +88 -9
  69. package/dist/types/excalidraw/actions/actionLink.d.ts +34 -7
  70. package/dist/types/excalidraw/actions/actionMenu.d.ts +33 -6
  71. package/dist/types/excalidraw/actions/actionProperties.d.ts +104 -34
  72. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +38 -11
  73. package/dist/types/excalidraw/actions/actionStyles.d.ts +30 -7
  74. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  75. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +34 -7
  76. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +37 -11
  77. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +34 -7
  78. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +205 -0
  79. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +34 -7
  80. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +37 -11
  81. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  82. package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleShowHints.d.ts} +49 -19
  83. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +34 -7
  84. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +35 -8
  85. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  86. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +34 -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 +36 -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/EditorLocalStorage.d.ts +8 -4
  199. package/dist/types/excalidraw/data/blob.d.ts +82 -28
  200. package/dist/types/excalidraw/data/index.d.ts +7 -7
  201. package/dist/types/excalidraw/data/json.d.ts +47 -20
  202. package/dist/types/excalidraw/data/library.d.ts +1 -1
  203. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  204. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  205. package/dist/types/excalidraw/fonts/Fonts.d.ts +12 -8
  206. package/dist/types/excalidraw/history.d.ts +10 -4
  207. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  208. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  209. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  210. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  211. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  212. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  213. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  214. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  215. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  216. package/dist/types/excalidraw/renderer/animation.d.ts +15 -4
  217. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  218. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
  219. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  220. package/dist/types/excalidraw/scene/Renderer.d.ts +490 -21
  221. package/dist/types/excalidraw/scene/export.d.ts +344 -21
  222. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  223. package/dist/types/excalidraw/scene/types.d.ts +30 -5
  224. package/dist/types/excalidraw/snapping.d.ts +7 -7
  225. package/dist/types/excalidraw/types.d.ts +612 -29
  226. package/dist/types/excalidraw/viewport.d.ts +307 -0
  227. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +13 -3
  228. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  229. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  230. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  231. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  232. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  233. package/dist/types/math/src/constants.d.ts +0 -1
  234. package/dist/types/math/src/curve.d.ts +19 -12
  235. package/dist/types/math/src/index.d.ts +1 -0
  236. package/dist/types/math/src/pca.d.ts +79 -0
  237. package/dist/types/math/src/point.d.ts +1 -0
  238. package/dist/types/math/src/polygon.d.ts +25 -1
  239. package/dist/types/math/src/segment.d.ts +6 -0
  240. package/dist/types/utils/src/index.d.ts +4 -3
  241. package/dist/types/utils/src/shape.d.ts +2 -2
  242. package/package.json +1 -1
  243. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  244. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  245. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  246. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  247. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  248. package/dist/types/excalidraw/components/shapes.d.ts +0 -263
  249. package/dist/types/excalidraw/cursor.d.ts +0 -5
  250. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  251. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  252. package/dist/types/utils/src/bbox.d.ts +0 -9
  253. package/dist/types/utils/src/export.d.ts +0 -35
  254. 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,42 @@ 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 for what the wheel does: with a `trackpad` a plain wheel
267
+ * pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
268
+ * delivered) zooms with either device. Shift+wheel pans horizontally;
269
+ * ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
270
+ * device detection exists — see `resolveInputDevice`
271
+ */
272
+ inputDevice: InputDevice;
273
+ /**
274
+ * The bindable element the UI highlights for the user when an arrow is
275
+ * dragged or otherwise its endpoint being close to said element.
276
+ */
221
277
  suggestedBinding: {
222
278
  element: NonDeleted<ExcalidrawBindableElement>;
223
279
  midPoint?: GlobalPoint;
224
280
  } | null;
281
+ /**
282
+ * What a text-tool click at the hovered position would act on — the text
283
+ * it would edit, the empty container it would label, or the arrow anchor
284
+ * (a free endpoint, or the midpoint for a label) it would attach text to.
285
+ * `null` when the click would create free text, or the tool isn't active.
286
+ * Drives the hover affordance only.
287
+ */
288
+ textToolHover: {
289
+ type: "text";
290
+ elementId: ExcalidrawElement["id"];
291
+ } | {
292
+ type: "container";
293
+ elementId: ExcalidrawElement["id"];
294
+ } | {
295
+ type: "arrow";
296
+ elementId: ExcalidrawArrowElement["id"];
297
+ anchor: "start" | "end" | "label";
298
+ } | null;
225
299
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
226
300
  frameRendering: {
227
301
  enabled: boolean;
@@ -229,8 +303,15 @@ export interface AppState {
229
303
  outline: boolean;
230
304
  clip: boolean;
231
305
  };
232
- editingFrame: string | null;
233
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
306
+ /**
307
+ * frame-like element whose name is currently being edited
308
+ */
309
+ editingFrame: ExcalidrawFrameLikeElement["id"] | null;
310
+ /**
311
+ * Elements the UI highlights with a bounding-box outline — those that
312
+ * would get added to a frame being dragged/resized.
313
+ */
314
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
234
315
  /**
235
316
  * set when a new text is created or when an existing text is being edited
236
317
  */
@@ -255,11 +336,14 @@ export interface AppState {
255
336
  exportWithDarkMode: boolean;
256
337
  exportScale: number;
257
338
  currentItemStrokeColor: string;
339
+ currentItemStickynoteStrokeColor: string;
340
+ currentItemStickynoteBackgroundColor: string;
258
341
  currentItemBackgroundColor: string;
259
342
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
260
- currentItemStrokeWidth: number;
343
+ currentItemStrokeWidthKey: StrokeWidthKey;
261
344
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
262
345
  currentItemRoughness: number;
346
+ currentItemStrokeVariability: StrokeVariability;
263
347
  currentItemOpacity: number;
264
348
  currentItemFontFamily: FontFamilyValues;
265
349
  currentItemFontSize: number;
@@ -272,6 +356,7 @@ export interface AppState {
272
356
  viewBackgroundColor: string;
273
357
  scrollX: number;
274
358
  scrollY: number;
359
+ scrollConstraints: ScrollConstraints | null;
275
360
  cursorButton: "up" | "down";
276
361
  scrolledOutside: boolean;
277
362
  name: string | null;
@@ -325,8 +410,14 @@ export interface AppState {
325
410
  message: React.ReactNode;
326
411
  closable?: boolean;
327
412
  duration?: number;
413
+ /** a link-like button after the message; it closes the toast, too */
414
+ action?: {
415
+ label: string;
416
+ onClick: () => void;
417
+ };
328
418
  } | null;
329
419
  zenModeEnabled: boolean;
420
+ minimapEnabled: boolean;
330
421
  theme: Theme;
331
422
  /** grid cell px size */
332
423
  gridSize: number;
@@ -359,10 +450,6 @@ export interface AppState {
359
450
  y: number;
360
451
  } | null;
361
452
  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
453
  /** image cropping */
367
454
  isCropping: boolean;
368
455
  croppingElementId: ExcalidrawElement["id"] | null;
@@ -377,6 +464,23 @@ export interface AppState {
377
464
  [groupId: string]: true;
378
465
  };
379
466
  bindMode: BindMode;
467
+ /** user-customized color-picker top picks (pinned via drag & drop from the
468
+ * color picker popup). `null` means no customization (defaults, or
469
+ * host-supplied `topPicks`, are used). Kept per picker. */
470
+ colorTopPicks: {
471
+ elementStroke: readonly string[] | null;
472
+ elementBackground: readonly string[] | null;
473
+ /** the bucket-fill tool keeps a list separate from `elementBackground`
474
+ * even though both drive `currentItemBackgroundColor` (its defaults and
475
+ * use case differ — no transparent) */
476
+ bucketFill: readonly string[] | null;
477
+ /** sticky notes are their own color domain (own defaults, own picks) */
478
+ stickyNoteStroke: readonly string[] | null;
479
+ stickyNoteBackground: readonly string[] | null;
480
+ };
481
+ /** user-customized font-picker top picks (pinned via drag & drop from the
482
+ * font picker popup). `null` means no customization (defaults are used) */
483
+ fontTopPicks: readonly FontFamilyValues[] | null;
380
484
  }
381
485
  export type SearchMatch = {
382
486
  id: string;
@@ -389,7 +493,7 @@ export type SearchMatch = {
389
493
  showOnCanvas: boolean;
390
494
  }[];
391
495
  };
392
- export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
496
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
393
497
  export type NormalizedZoomValue = number & {
394
498
  _brand: "normalizedZoom";
395
499
  };
@@ -433,23 +537,224 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
433
537
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
434
538
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
435
539
  }>;
540
+ export type ExcalidrawInitialState = {
541
+ viewport?: Omit<SetViewportOptions, "animation">;
542
+ };
436
543
  export type OnUserFollowedPayload = {
437
544
  userToFollow: UserToFollow;
438
545
  action: "FOLLOW" | "UNFOLLOW";
439
546
  };
547
+ export type ViewportStatusFrame = {
548
+ /** the badge (bottom-center pill) */
549
+ label?: {
550
+ label: React.ReactNode;
551
+ icon?: React.ReactNode;
552
+ /** badge background; defaults to var(--color-primary-hover) */
553
+ background?: string;
554
+ /** badge text color; defaults to var(--color-primary-light) */
555
+ color?: string;
556
+ /** makes the badge label interactive */
557
+ onClick?: () => void;
558
+ /** renders a close button when set */
559
+ onClose?: () => void;
560
+ };
561
+ /** viewport-edge border: CSS color, or `false` for none */
562
+ border: false | string;
563
+ };
440
564
  export type OnExportProgress = {
441
565
  type: "progress";
442
566
  message?: React.ReactNode;
443
567
  /** 0-1 range */
444
568
  progress?: number;
445
569
  };
570
+ export type InteractionConfig = {
571
+ /**
572
+ * Interactions that stay enabled while the editor is otherwise
573
+ * non-interactive. Opt-in: anything omitted or `false` is disabled.
574
+ */
575
+ enabled?: {
576
+ /**
577
+ * Element links render their link icon and stay clickable — clicking
578
+ * anywhere on a linked element opens the link, same as in view mode.
579
+ * When disabled, link icons are not rendered at all.
580
+ *
581
+ * @default false
582
+ */
583
+ links?: boolean;
584
+ /**
585
+ * Embeddable & iframe elements stay interactive — hovering & clicking
586
+ * activates them so their content can be used, same as in view mode.
587
+ *
588
+ * @default false
589
+ */
590
+ embeds?: boolean;
591
+ /**
592
+ * Umbrella for all interactive content on canvas — shorthand for
593
+ * enabling `links` & `embeds` (and future interactive content kinds)
594
+ * together. Additive: `interactiveContent: true` enables them
595
+ * regardless of their individual values.
596
+ *
597
+ * @default false
598
+ */
599
+ interactiveContent?: boolean;
600
+ /**
601
+ * Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
602
+ * and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
603
+ * zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
604
+ * mode. Respects `appState.scrollConstraints` if set, so it composes
605
+ * with viewport locking. The rest of the keyboard stays disabled. Note
606
+ * the editor consumes wheel & touch input again when enabled, so the
607
+ * page no longer scrolls over the editor.
608
+ *
609
+ * @default false
610
+ */
611
+ navigation?: boolean;
612
+ /**
613
+ * Whether the browser's own zoom remains available over the editor —
614
+ * ctrl/cmd + wheel, pinch, and (while the editor has focus)
615
+ * ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
616
+ * interactive editor. Regular page scrolling stays available either way.
617
+ * With `navigation` enabled, the zoom input (wheel, pinch, keyboard
618
+ * shortcuts) zooms the canvas instead either way, making this moot.
619
+ *
620
+ * @default false
621
+ */
622
+ browserZoom?: boolean;
623
+ /**
624
+ * Tools that stay user-driven while the editor is otherwise
625
+ * non-interactive: pointer input keeps driving the listed tool when it's
626
+ * the active tool. Does not enable user-driven tool *switching* — the
627
+ * keyboard stays disabled and tool selection remains host-driven
628
+ * (`ExcalidrawAPI.setActiveTool`).
629
+ *
630
+ * Composes with `navigation`: the enabled tool wins the primary-pointer
631
+ * drag, while wheel input (and wheel-button drag) still pans/zooms.
632
+ */
633
+ tools?: {
634
+ /**
635
+ * The laser pointer stays usable — pointer strokes draw laser trails
636
+ * and pointer positions keep broadcasting via `onPointerUpdate`, so
637
+ * e.g. collaborators see a presenter's laser & cursor.
638
+ *
639
+ * @default false
640
+ */
641
+ laser?: boolean;
642
+ /**
643
+ * Custom tools (`activeTool.type === "custom"`) stay usable — the
644
+ * editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
645
+ * Tool behavior is host-implemented; activate custom tools with
646
+ * `locked: true` or they revert to the selection tool (and go inert)
647
+ * after the first pointer interaction.
648
+ *
649
+ * @default false
650
+ */
651
+ custom?: boolean;
652
+ };
653
+ };
654
+ };
655
+ export type UIConfig = {
656
+ /**
657
+ * Default UI controls that stay enabled while the rest of Excalidraw's
658
+ * default UI is hidden. Opt-in: anything omitted or `false` is
659
+ * disabled.
660
+ */
661
+ enabled: {
662
+ /**
663
+ * The zoom controls (zoom out, the zoom level resetting it, zoom in).
664
+ *
665
+ * @default false
666
+ */
667
+ zoom?: boolean;
668
+ /**
669
+ * The button shown when the viewport is scrolled away from all
670
+ * content.
671
+ *
672
+ * @default false
673
+ */
674
+ scrollBackToContent?: boolean;
675
+ };
676
+ } | {
677
+ /**
678
+ * Default UI controls that are removed while the rest of Excalidraw's
679
+ * default UI is rendered. Opt-out: anything omitted or `false` stays.
680
+ */
681
+ disabled: {
682
+ /**
683
+ * The minimap, and every way to toggle it (its footer button, the
684
+ * Preferences menu item, and the command palette and context menu
685
+ * entries). Without the minimap toggle next to them, the zoom
686
+ * controls are the zoom out / zoom level / zoom in buttons instead of
687
+ * the zoom menu.
688
+ *
689
+ * @default false
690
+ */
691
+ minimap?: boolean;
692
+ };
693
+ };
694
+ /** A default UI control that `UIConfig` can keep or remove. */
695
+ export type UIControl = keyof Extract<UIConfig, {
696
+ enabled: unknown;
697
+ }>["enabled"] | keyof Extract<UIConfig, {
698
+ disabled: unknown;
699
+ }>["disabled"];
700
+ /** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
701
+ export type ElementRenderOverride = Readonly<{
702
+ /** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
703
+ opacity?: number;
704
+ /** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
705
+ offset?: Readonly<{
706
+ x: number;
707
+ y: number;
708
+ }>;
709
+ }>;
710
+ /** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
711
+ export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
712
+ /** The translation part of a snapshot: only the entries that carry an offset. */
713
+ export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
446
714
  export interface ExcalidrawProps {
715
+ className?: string;
716
+ /**
717
+ * Document that owns Excalidraw's mounted DOM.
718
+ *
719
+ * Set only when it differs from the global `document`, such as when code
720
+ * executing in a parent window mounts Excalidraw into an iframe document.
721
+ * The value must remain stable for the editor's lifetime.
722
+ *
723
+ * @default document
724
+ */
725
+ ownerDocument?: Document;
726
+ /**
727
+ * Host environment used by the renderer and export pipeline to create
728
+ * canvases and images. Supply a custom implementation to redirect canvas
729
+ * creation and image decoding to e.g. a host canvas pool, an
730
+ * `OffscreenCanvas`, or a non-DOM image decoder. When omitted, canvas and
731
+ * image creation fall back to `ownerDocument` / `ownerWindow`.
732
+ *
733
+ * The value must be referentially stable -- every render cache (element
734
+ * canvases, text metrics, char widths, link icons) is keyed by this
735
+ * object's identity, so a new identity is a full cache miss. Passing an
736
+ * inline object literal mints a fresh identity on every React render,
737
+ * which silently re-rasterizes every element on every frame; hoist it to a
738
+ * module constant or memoize it (e.g. `useMemo`) instead.
739
+ *
740
+ * Only `createCanvas` and `createImage` are required. `createPath` (used to
741
+ * fill freedraw strokes) falls back to the global `Path2D`, which every
742
+ * browser has -- a non-browser host without one must supply it. Pass
743
+ * `document` (the owner document) for SVG exports to be built in it rather
744
+ * than in the global `document`, and `textMetrics` to measure the editor's
745
+ * text with your own provider.
746
+ *
747
+ * @default { createCanvas: () => ownerDocument.createElement("canvas"), createImage: () => new ownerWindow.Image(), createPath: (d) => new ownerWindow.Path2D(d), document: ownerDocument }
748
+ */
749
+ renderEnvironment?: RenderEnvironment;
447
750
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
751
+ onThemeChange?: (theme: Theme | "system") => void;
448
752
  /**
449
753
  * note: only subscribes if the props.onIncrement is defined on initial render
450
754
  */
451
755
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
452
756
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
757
+ initialState?: ExcalidrawInitialState;
453
758
  /**
454
759
  * Invoked as soon as the Excalidraw API is available
455
760
  * NOTE editor is not yet mounted, and state is not yet initialized
@@ -487,15 +792,97 @@ export interface ExcalidrawProps {
487
792
  *
488
793
  * Returned elements will be used in place of the next elements
489
794
  * (you should return all elements, including deleted, and not mutate
490
- * the element if changes are made)
795
+ * the element if changes are made).
796
+ *
797
+ * The duplicates are the elements in `nextElements` which are not in
798
+ * `prevElements` (see also `data.duplicateElements`). When pasting or
799
+ * inserting onto a frame, their `frameId` is already set. To change a
800
+ * duplicate, return a new object with the same `id`. It is shallow-merged
801
+ * into the duplicate (omitted properties are kept), and your changes are
802
+ * part of the duplication itself (same undo entry, same durable increment).
803
+ *
804
+ * To prevent an element from being duplicated, omit its duplicate from the
805
+ * returned array. References to it from the remaining duplicates are
806
+ * cleared, and a bound text isn't duplicated without its container. To
807
+ * prevent the duplication as a whole, return `false`. If no duplicate
808
+ * remains, the duplication is cancelled and the returned elements are
809
+ * ignored (alt-drag then moves the original elements instead).
491
810
  */
492
811
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
493
812
  /** excludes the duplicated elements */
494
- prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
813
+ prevElements: readonly ExcalidrawElement[],
814
+ /** lookups covering just the elements taking part in the duplication */
815
+ data: OnDuplicateData) => ExcalidrawElement[] | void | false;
495
816
  renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
496
817
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
497
818
  langCode?: Language["code"];
498
819
  viewModeEnabled?: boolean;
820
+ /**
821
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
822
+ * clipboard, drag&drop). When `false`, the scene still renders and reacts
823
+ * to programmatic updates (imperative API), but the user cannot affect it
824
+ * in any way. Implies view mode.
825
+ *
826
+ * Pass a config object to keep specific interactions enabled while the
827
+ * editor is otherwise non-interactive (see `InteractionConfig`):
828
+ *
829
+ * ```tsx
830
+ * <Excalidraw interaction={{ enabled: { links: true } }} />
831
+ * ```
832
+ *
833
+ * @default true
834
+ */
835
+ interaction?: boolean | InteractionConfig;
836
+ /**
837
+ * Whether Excalidraw's default UI is rendered — toolbar, default menus,
838
+ * footer controls, sidebars, and canvas popups. Host UI passed through
839
+ * children (including exported components such as `MainMenu` and `Footer`)
840
+ * or render props continues to render, together with any supporting dialogs
841
+ * it opens.
842
+ *
843
+ * Canvas content (elements, text editing surface, frame names, embeds) still
844
+ * renders, and the editor remains interactive unless `interaction` is set to
845
+ * `false`.
846
+ *
847
+ * Pass a config object to keep specific default controls rendered while the
848
+ * rest of the default UI is hidden, or to remove specific controls from the
849
+ * otherwise full default UI (see `UIConfig`):
850
+ *
851
+ * ```tsx
852
+ * <Excalidraw ui={{ enabled: { zoom: true } }} />
853
+ * <Excalidraw ui={{ disabled: { minimap: true } }} />
854
+ * ```
855
+ *
856
+ * NOTE: this is WIP and what default UI is/is not rendered when ui=false
857
+ * may yet change.
858
+ *
859
+ * @default true
860
+ */
861
+ ui?: boolean | UIConfig;
862
+ /**
863
+ * Forces the active editor tool (controlled). While set, user- and
864
+ * API-driven tool switching is ignored — `setActiveTool` refuses with a
865
+ * console warning, non-forced toolbar buttons render disabled — and the
866
+ * editor snaps back if internal flows reset the tool. The forced tool
867
+ * behaves as if locked (see the tool lock / padlock): it doesn't revert to
868
+ * the selection tool after use, and elements drawn with it aren't
869
+ * auto-selected — without mutating `appState.activeTool.locked`, so the
870
+ * user's persisted padlock preference stays untouched. Unset to return
871
+ * tool control to the editor (the current tool stays active).
872
+ *
873
+ * The forced tool must be activatable to take effect: not disabled via
874
+ * `UIOptions.tools`, and — while the editor is non-interactive — allowed
875
+ * via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
876
+ * non-interactive, resets to) the `selection` tool, and the forced tool is
877
+ * applied once it becomes activatable. `image` cannot be forced (its
878
+ * activation opens the file picker).
879
+ */
880
+ activeTool?: {
881
+ type: Exclude<ToolType, "image">;
882
+ } | {
883
+ type: "custom";
884
+ customType: string;
885
+ };
499
886
  zenModeEnabled?: boolean;
500
887
  gridModeEnabled?: boolean;
501
888
  objectsSnapModeEnabled?: boolean;
@@ -504,6 +891,10 @@ export interface ExcalidrawProps {
504
891
  name?: string;
505
892
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
506
893
  UIOptions?: Partial<UIOptions>;
894
+ /**
895
+ * dimensions and size constraints for inserted images
896
+ */
897
+ imageOptions?: ImageOptions;
507
898
  detectScroll?: boolean;
508
899
  handleKeyboardGlobally?: boolean;
509
900
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -523,6 +914,21 @@ export interface ExcalidrawProps {
523
914
  aiEnabled?: boolean;
524
915
  showDeprecatedFonts?: boolean;
525
916
  renderScrollbars?: boolean;
917
+ viewportStatusFrame?: ViewportStatusFrame | null;
918
+ /**
919
+ * Rendered inside the UserList "who's here" dropdown (desktop) and inline
920
+ * in the mobile menu's collaborators section, below a divider. Accepts a
921
+ * render function — called with `isMobile` so hosts can render different
922
+ * UI for each surface — in addition to a plain node.
923
+ */
924
+ currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
925
+ /**
926
+ * The user being followed on the canvas, if any. Controlled by the host —
927
+ * the editor never sets it; it emits follow/unfollow intents via
928
+ * `onUserFollow` (prop or imperative API) and renders the followed
929
+ * user's avatar highlight from this value.
930
+ */
931
+ userToFollow?: UserToFollow | null;
526
932
  /**
527
933
  * Called before exporting to a file.
528
934
  *
@@ -548,7 +954,8 @@ export interface ExcalidrawProps {
548
954
  }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
549
955
  }
550
956
  export type SceneData = {
551
- elements?: ImportedDataState["elements"];
957
+ /** Expects normalized elements; restore imported data before updating the scene. */
958
+ elements?: readonly ExcalidrawElement[] | null;
552
959
  appState?: ImportedDataState["appState"];
553
960
  collaborators?: Map<SocketId, Collaborator>;
554
961
  captureUpdate?: CaptureUpdateActionType;
@@ -558,12 +965,21 @@ export type ExportOpts = {
558
965
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
559
966
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
560
967
  };
968
+ export type ImageOptions = Partial<{
969
+ maxWidthOrHeight: number;
970
+ maxFileSizeBytes: number;
971
+ }>;
561
972
  export type CanvasActions = Partial<{
562
973
  changeViewBackgroundColor: boolean;
563
974
  clearCanvas: boolean;
564
975
  export: false | ExportOpts;
565
976
  loadScene: boolean;
566
977
  saveToActiveFile: boolean;
978
+ /**
979
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
980
+ * is supplied (at which point the theme is considered as host-app controlled),
981
+ * else default to false
982
+ * */
567
983
  toggleTheme: boolean | null;
568
984
  saveAsImage: boolean;
569
985
  }>;
@@ -587,6 +1003,7 @@ export type AppProps = Merge<ExcalidrawProps, {
587
1003
  export: ExportOpts;
588
1004
  };
589
1005
  }>;
1006
+ imageOptions: Required<ImageOptions>;
590
1007
  detectScroll: boolean;
591
1008
  handleKeyboardGlobally: boolean;
592
1009
  isCollaborating: boolean;
@@ -598,6 +1015,9 @@ export type AppProps = Merge<ExcalidrawProps, {
598
1015
  export type AppClassProperties = {
599
1016
  props: AppProps;
600
1017
  state: AppState;
1018
+ readonly ownerDocument: Document;
1019
+ readonly ownerWindow: Window & typeof globalThis;
1020
+ renderEnvironment: RenderEnvironment;
601
1021
  api: App["api"];
602
1022
  sessionExportThemeOverride: App["sessionExportThemeOverride"];
603
1023
  interactiveCanvas: HTMLCanvasElement | null;
@@ -614,12 +1034,12 @@ export type AppClassProperties = {
614
1034
  scene: App["scene"];
615
1035
  syncActionResult: App["syncActionResult"];
616
1036
  fonts: App["fonts"];
617
- pasteFromClipboard: App["pasteFromClipboard"];
1037
+ clipboard: App["clipboard"];
618
1038
  id: App["id"];
619
1039
  onInsertElements: App["onInsertElements"];
620
1040
  onExportImage: App["onExportImage"];
621
- lastViewportPosition: App["lastViewportPosition"];
622
- scrollToContent: App["scrollToContent"];
1041
+ viewport: App["viewport"];
1042
+ wheel: App["wheel"];
623
1043
  addFiles: App["addFiles"];
624
1044
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
625
1045
  togglePenMode: App["togglePenMode"];
@@ -630,11 +1050,23 @@ export type AppClassProperties = {
630
1050
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
631
1051
  getName: App["getName"];
632
1052
  dismissLinearEditor: App["dismissLinearEditor"];
633
- flowChartCreator: App["flowChartCreator"];
1053
+ flowchart: App["flowchart"];
1054
+ drawShape: App["drawShape"];
1055
+ arrowText: App["arrowText"];
1056
+ text: App["text"];
1057
+ textTool: App["textTool"];
1058
+ cursor: App["cursor"];
1059
+ bucketFill: App["bucketFill"];
1060
+ duplicate: App["duplicate"];
1061
+ toolDrag: App["toolDrag"];
1062
+ activeResizeHandle: App["activeResizeHandle"];
1063
+ selectionTool: App["selectionTool"];
1064
+ wrap: App["wrap"];
1065
+ modifiers: App["modifiers"];
1066
+ isToolLocked: App["isToolLocked"];
634
1067
  getEffectiveGridSize: App["getEffectiveGridSize"];
635
1068
  setPlugins: App["setPlugins"];
636
1069
  plugins: App["plugins"];
637
- getEditorUIOffsets: App["getEditorUIOffsets"];
638
1070
  visibleElements: App["visibleElements"];
639
1071
  excalidrawContainerValue: App["excalidrawContainerValue"];
640
1072
  onPointerUpEmitter: App["onPointerUpEmitter"];
@@ -643,8 +1075,14 @@ export type AppClassProperties = {
643
1075
  onEvent: App["onEvent"];
644
1076
  onStateChange: App["onStateChange"];
645
1077
  lastPointerMoveCoords: App["lastPointerMoveCoords"];
1078
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
646
1079
  bindModeHandler: App["bindModeHandler"];
1080
+ emitUserFollowIntent: App["emitUserFollowIntent"];
1081
+ requestUnfollow: App["requestUnfollow"];
647
1082
  setAppState: App["setAppState"];
1083
+ isInteractionEnabled: App["isInteractionEnabled"];
1084
+ isNavigationEnabled: App["isNavigationEnabled"];
1085
+ isUIControlEnabled: App["isUIControlEnabled"];
648
1086
  };
649
1087
  export type PointerDownState = Readonly<{
650
1088
  origin: Readonly<{
@@ -678,8 +1116,12 @@ export type PointerDownState = Readonly<{
678
1116
  element: NonDeleted<ExcalidrawElement> | null;
679
1117
  allHitElements: NonDeleted<ExcalidrawElement>[];
680
1118
  wasAddedToSelection: boolean;
1119
+ cycleTarget: NonDeleted<ExcalidrawElement> | null;
681
1120
  hasBeenDuplicated: boolean;
1121
+ advancedListMarkers: readonly ListMarkerAdvance[];
1122
+ editedTextId: ExcalidrawTextElement["id"] | null;
682
1123
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
1124
+ arrowLabel: boolean;
683
1125
  };
684
1126
  withCmdOrCtrl: boolean;
685
1127
  drag: {
@@ -692,6 +1134,10 @@ export type PointerDownState = Readonly<{
692
1134
  x: number;
693
1135
  y: number;
694
1136
  };
1137
+ lastOffset: {
1138
+ x: number;
1139
+ y: number;
1140
+ };
695
1141
  blockDragging: boolean;
696
1142
  };
697
1143
  eventListeners: {
@@ -727,19 +1173,51 @@ export interface ExcalidrawImperativeAPI {
727
1173
  history: {
728
1174
  clear: InstanceType<typeof App>["resetHistory"];
729
1175
  };
1176
+ /**
1177
+ * Selects elements (or their ids — one or many), adds them to or removes
1178
+ * them from the selection, or clears it — as the editor does: an element is
1179
+ * selected with its group (unless `deep`), a frame and its children aren't
1180
+ * selected at the same time, and locked elements are skipped (unless
1181
+ * `includeLocked`). Text editing and cropping end, and the link popup of a
1182
+ * lone selected element shows. Missing and deleted elements are skipped.
1183
+ *
1184
+ * By default the change is recorded for undo along with the next undoable
1185
+ * change — pass `captureUpdate` as for `updateScene()` otherwise. Like
1186
+ * `updateScene()`, it applies on the next render: read it back through
1187
+ * `onChange()` or `getAppState()` after that. Works in view mode too, where
1188
+ * the selection shows without transform handles.
1189
+ */
1190
+ selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
730
1191
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
731
1192
  getAppState: () => InstanceType<typeof App>["state"];
732
1193
  getFiles: () => InstanceType<typeof App>["files"];
733
1194
  getName: InstanceType<typeof App>["getName"];
734
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
1195
+ setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
1196
+ getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
1197
+ /**
1198
+ * Atomically replaces all transient visual overrides. Values are copied;
1199
+ * omitted IDs/fields use document values, except for inherited label offsets.
1200
+ * null clears the snapshot.
1201
+ * Repaints without document changes, history entries or onChange events;
1202
+ * an equivalent snapshot may still repaint (clearing an already clear
1203
+ * snapshot does not), so submit only when something changed.
1204
+ * Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
1205
+ * Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
1206
+ * Bound labels inherit their container's offset; offsets targeting them are
1207
+ * ignored. Label opacity remains independent. Target frame children explicitly.
1208
+ * Frame opacity still multiplies child opacity. Decorations follow their owner.
1209
+ * Exports and interactive geometry (hit tests, selection, editing) use document
1210
+ * values, including while authoring an animation preview in edit mode.
1211
+ */
1212
+ setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
735
1213
  registerAction: (action: Action) => void;
736
1214
  refresh: InstanceType<typeof App>["refresh"];
737
1215
  setToast: InstanceType<typeof App>["setToast"];
738
1216
  addFiles: (data: BinaryFileData[]) => void;
739
1217
  id: string;
740
1218
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
741
- setCursor: InstanceType<typeof App>["setCursor"];
742
- resetCursor: InstanceType<typeof App>["resetCursor"];
1219
+ setCursor: InstanceType<typeof App>["cursor"]["set"];
1220
+ resetCursor: InstanceType<typeof App>["cursor"]["reset"];
743
1221
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
744
1222
  getEditorInterface: () => EditorInterface;
745
1223
  /**
@@ -762,7 +1240,6 @@ export type FrameNameBounds = {
762
1240
  y: number;
763
1241
  width: number;
764
1242
  height: number;
765
- angle: number;
766
1243
  };
767
1244
  export type FrameNameBoundsCache = {
768
1245
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -781,12 +1258,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
781
1258
  export type JSONValue = string | number | boolean | null | object;
782
1259
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
783
1260
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
784
- export type PendingExcalidrawElements = ExcalidrawElement[];
1261
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
785
1262
  /** Runtime gridSize value. Null indicates disabled grid. */
786
1263
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
787
1264
  export type GenerateDiagramToCode = (props: {
788
- frame: ExcalidrawMagicFrameElement;
789
- children: readonly ExcalidrawElement[];
1265
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
1266
+ children: readonly NonDeletedExcalidrawElement[];
1267
+ /**
1268
+ * Optional streaming hook. Call with the accumulated response text as it
1269
+ * streams in so the editor can progressively render the partial HTML
1270
+ * inside the generated frame.
1271
+ */
1272
+ onPartial?: (html: string) => void;
790
1273
  }) => MaybePromise<{
791
1274
  html: string;
792
1275
  }>;
@@ -796,3 +1279,103 @@ export type Offsets = Partial<{
796
1279
  bottom: number;
797
1280
  left: number;
798
1281
  }>;
1282
+ /**
1283
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
1284
+ * surface that occludes the canvas. Such nodes are measured by
1285
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
1286
+ *
1287
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
1288
+ * - `side` — a panel hugging the left or right edge. Which side is not
1289
+ * declared but resolved geometrically: if the node's horizontal center
1290
+ * lies in the left half of the viewport it counts against the left
1291
+ * offset (by its right edge), otherwise against the right offset (by
1292
+ * `viewportWidth - left edge`). Measuring the rendered position instead
1293
+ * of declaring a side means RTL layouts and host-configurable docking
1294
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
1295
+ * actually hugs one edge; don't mark a centered/near-full-width node as
1296
+ * `side` (its midpoint would classify it to one side and the offset
1297
+ * would swallow most of the viewport).
1298
+ *
1299
+ * The attribute should only be present while the surface is actually
1300
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
1301
+ * push the viewport around.
1302
+ */
1303
+ export type ViewportUIDock = "top" | "bottom" | "side";
1304
+ /**
1305
+ * Options for `getViewportOffsets` (and the `ui` key of
1306
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
1307
+ * currently rendered editor UI.
1308
+ *
1309
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
1310
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
1311
+ * reading-direction start side).
1312
+ */
1313
+ export type ViewportOffsetsOptions = {
1314
+ /** padding added to each measured side (default 24) */
1315
+ padding?: number;
1316
+ paddingTop?: number;
1317
+ paddingRight?: number;
1318
+ paddingBottom?: number;
1319
+ paddingLeft?: number;
1320
+ /** final value for the given side, replacing the measured UI size
1321
+ * (padding is not added on top) */
1322
+ top?: number;
1323
+ bottom?: number;
1324
+ left?: number;
1325
+ right?: number;
1326
+ /**
1327
+ * Reserve space for the given conditionally-rendered surfaces even while
1328
+ * they're hidden, so the resulting offsets don't shift when they
1329
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
1330
+ * to an approximate default if it hasn't been rendered yet. Ignored on
1331
+ * phones (where these surfaces never occlude the canvas).
1332
+ */
1333
+ reserve?: {
1334
+ /** styles panel (rendered when a tool or selection is active) */
1335
+ stylesPanel?: boolean;
1336
+ /** sidebar (e.g. library) */
1337
+ sidebar?: boolean;
1338
+ };
1339
+ };
1340
+ /**
1341
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
1342
+ * `props.initialState.viewport`), insetting the usable viewport area per
1343
+ * side so the target isn't fitted/centered underneath overlaid UI.
1344
+ *
1345
+ * Two (combinable) ways to specify:
1346
+ *
1347
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
1348
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
1349
+ * no padding added. Sides not specified default to `0` (unless `ui` is
1350
+ * set, see below).
1351
+ *
1352
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
1353
+ * panel, sidebar...) as rendered at the time the viewport is set,
1354
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
1355
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
1356
+ * padding or reserve space for currently-hidden surfaces.
1357
+ *
1358
+ * When both are given, a static side always wins for that side — it
1359
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
1360
+ * which — unlike the physical static sides — are RTL-relative). The
1361
+ * remaining sides fall back to the `ui`-derived values.
1362
+ *
1363
+ * @example
1364
+ * { top: 40 } // top 40px, other sides 0
1365
+ * { ui: true } // measured UI + default padding
1366
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
1367
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
1368
+ */
1369
+ export type ViewportOffsets = Offsets & {
1370
+ ui?: true | ViewportOffsetsOptions;
1371
+ };
1372
+ /**
1373
+ * Value of the `data-viewport-ui-name` attribute, identifying a
1374
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1375
+ * it can be measured on its own, and so that `getViewportOffsets` can
1376
+ * reserve space for it while it's hidden (see the `reserve` option).
1377
+ * Whenever a named surface is rendered, its measured footprint is
1378
+ * remembered; reserving uses that remembered footprint, or an approximate
1379
+ * default if the surface hasn't been rendered yet.
1380
+ */
1381
+ export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";