@excalidraw/element 0.18.0-4a5c9e9 → 0.18.0-4ce38fb

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 (218) hide show
  1. package/dist/dev/index.js +11944 -8172
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +21 -20
  4. package/dist/types/common/src/colors.d.ts +23 -1
  5. package/dist/types/common/src/constants.d.ts +66 -7
  6. package/dist/types/common/src/keys.d.ts +4 -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 +6 -43
  10. package/dist/types/element/src/Scene.d.ts +7 -5
  11. package/dist/types/element/src/align.d.ts +2 -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 +28 -13
  15. package/dist/types/element/src/bounds.d.ts +22 -7
  16. package/dist/types/element/src/bucketFill.d.ts +110 -0
  17. package/dist/types/element/src/collision.d.ts +14 -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/delta.d.ts +23 -1
  21. package/dist/types/element/src/distribute.d.ts +2 -2
  22. package/dist/types/element/src/dragElements.d.ts +27 -0
  23. package/dist/types/element/src/duplicate.d.ts +64 -3
  24. package/dist/types/element/src/embeddable.d.ts +2 -2
  25. package/dist/types/element/src/flowchart.d.ts +11 -7
  26. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  27. package/dist/types/element/src/frame.d.ts +11 -10
  28. package/dist/types/element/src/groups.d.ts +9 -9
  29. package/dist/types/element/src/index.d.ts +6 -1
  30. package/dist/types/element/src/linearElementEditor.d.ts +27 -10
  31. package/dist/types/element/src/listMarker.d.ts +34 -0
  32. package/dist/types/element/src/mutateElement.d.ts +1 -1
  33. package/dist/types/element/src/newElement.d.ts +53 -3
  34. package/dist/types/element/src/renderElement.d.ts +21 -7
  35. package/dist/types/element/src/resizeElements.d.ts +2 -2
  36. package/dist/types/element/src/selection.d.ts +6 -6
  37. package/dist/types/element/src/shape.d.ts +27 -1
  38. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  39. package/dist/types/element/src/sortElements.d.ts +10 -0
  40. package/dist/types/element/src/stickyNote.d.ts +183 -0
  41. package/dist/types/element/src/textElement.d.ts +20 -9
  42. package/dist/types/element/src/transform.d.ts +26 -7
  43. package/dist/types/element/src/typeChecks.d.ts +29 -27
  44. package/dist/types/element/src/types.d.ts +43 -7
  45. package/dist/types/element/src/utils.d.ts +15 -4
  46. package/dist/types/element/src/visualdebug.d.ts +1 -2
  47. package/dist/types/element/src/zindex.d.ts +2 -2
  48. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +87 -18
  49. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  50. package/dist/types/excalidraw/actions/actionBoundText.d.ts +58 -12
  51. package/dist/types/excalidraw/actions/actionCanvas.d.ts +265 -940
  52. package/dist/types/excalidraw/actions/actionClipboard.d.ts +58 -12
  53. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +29 -6
  54. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +89 -19
  55. package/dist/types/excalidraw/actions/actionDeselect.d.ts +30 -7
  56. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  57. package/dist/types/excalidraw/actions/actionElementLink.d.ts +29 -6
  58. package/dist/types/excalidraw/actions/actionElementLock.d.ts +59 -13
  59. package/dist/types/excalidraw/actions/actionExport.d.ts +60 -14
  60. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  61. package/dist/types/excalidraw/actions/actionFrame.d.ts +150 -203
  62. package/dist/types/excalidraw/actions/actionGroup.d.ts +73 -27
  63. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +84 -9
  64. package/dist/types/excalidraw/actions/actionLink.d.ts +30 -7
  65. package/dist/types/excalidraw/actions/actionMenu.d.ts +29 -6
  66. package/dist/types/excalidraw/actions/actionProperties.d.ts +96 -34
  67. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +34 -11
  68. package/dist/types/excalidraw/actions/actionStyles.d.ts +30 -7
  69. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  70. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +30 -7
  71. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +33 -11
  72. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +30 -7
  73. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +30 -7
  74. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +33 -11
  75. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  76. package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleShowHints.d.ts} +45 -19
  77. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +30 -7
  78. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +31 -8
  79. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +30 -7
  80. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  81. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  82. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  83. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  84. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  85. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  86. package/dist/types/excalidraw/appState.d.ts +30 -6
  87. package/dist/types/excalidraw/components/Actions.d.ts +17 -12
  88. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  89. package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
  90. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  91. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  92. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  93. package/dist/types/excalidraw/components/App.d.ts +301 -93
  94. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  95. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  96. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  97. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  98. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  99. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  100. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  101. package/dist/types/excalidraw/components/App.viewport.d.ts +113 -0
  102. package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
  103. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  104. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  105. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
  106. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  107. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  108. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  109. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  110. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  111. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  112. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  113. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
  114. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  115. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  116. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  117. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  118. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  119. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  120. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  121. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  122. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  123. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  124. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  125. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  126. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  127. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  128. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  129. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  130. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  131. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  132. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  133. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  134. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  135. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  136. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  137. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  138. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  139. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  140. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  141. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  142. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  143. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  144. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  145. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  146. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  147. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  148. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  149. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  150. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  151. package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
  152. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  153. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  154. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  155. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  156. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  157. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -1
  158. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
  159. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  160. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  161. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  162. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  163. package/dist/types/excalidraw/components/icons.d.ts +7 -1
  164. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +10 -4
  165. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  166. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  167. package/dist/types/excalidraw/data/blob.d.ts +62 -16
  168. package/dist/types/excalidraw/data/index.d.ts +4 -4
  169. package/dist/types/excalidraw/data/json.d.ts +37 -14
  170. package/dist/types/excalidraw/data/library.d.ts +1 -1
  171. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  172. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  173. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  174. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  175. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  176. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  177. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  178. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  179. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  180. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  181. package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
  182. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  183. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
  184. package/dist/types/excalidraw/scene/Renderer.d.ts +489 -20
  185. package/dist/types/excalidraw/scene/export.d.ts +3 -3
  186. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  187. package/dist/types/excalidraw/scene/types.d.ts +7 -4
  188. package/dist/types/excalidraw/snapping.d.ts +7 -7
  189. package/dist/types/excalidraw/types.d.ts +531 -29
  190. package/dist/types/excalidraw/viewport.d.ts +302 -0
  191. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +13 -3
  192. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  193. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  194. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  195. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  196. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  197. package/dist/types/math/src/constants.d.ts +0 -1
  198. package/dist/types/math/src/curve.d.ts +23 -13
  199. package/dist/types/math/src/index.d.ts +1 -0
  200. package/dist/types/math/src/pca.d.ts +79 -0
  201. package/dist/types/math/src/point.d.ts +1 -0
  202. package/dist/types/math/src/polygon.d.ts +25 -1
  203. package/dist/types/math/src/segment.d.ts +6 -0
  204. package/dist/types/utils/src/export.d.ts +4 -3
  205. package/dist/types/utils/src/index.d.ts +1 -2
  206. package/dist/types/utils/src/shape.d.ts +2 -2
  207. package/package.json +4 -3
  208. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  209. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  210. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  211. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  212. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  213. package/dist/types/excalidraw/components/shapes.d.ts +0 -263
  214. package/dist/types/excalidraw/cursor.d.ts +0 -5
  215. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  216. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  217. package/dist/types/utils/src/bbox.d.ts +0 -9
  218. 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, 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"];
@@ -172,6 +175,47 @@ export type ObservedElementsAppState = {
172
175
  lockedMultiSelections: AppState["lockedMultiSelections"];
173
176
  activeLockedId: AppState["activeLockedId"];
174
177
  };
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
+ };
175
219
  export interface AppState {
176
220
  contextMenu: {
177
221
  items: ContextMenuItems;
@@ -210,15 +254,48 @@ export interface AppState {
210
254
  * `bindingPreference` and keyboard modifiers (ctrl/alt)
211
255
  */
212
256
  isBindingEnabled: boolean;
257
+ /** user box selection preference; defaults to "contain" when unset */
258
+ boxSelectionMode: BoxSelectionMode;
213
259
  /** user arrow binding preference */
214
260
  bindingPreference: "enabled" | "disabled";
215
261
  /** user preference whether arrow snap to midpoints while binding */
216
262
  isMidpointSnappingEnabled: boolean;
217
- 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
+ */
218
277
  suggestedBinding: {
219
278
  element: NonDeleted<ExcalidrawBindableElement>;
220
279
  midPoint?: GlobalPoint;
221
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;
222
299
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
223
300
  frameRendering: {
224
301
  enabled: boolean;
@@ -226,8 +303,15 @@ export interface AppState {
226
303
  outline: boolean;
227
304
  clip: boolean;
228
305
  };
229
- editingFrame: string | null;
230
- 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;
231
315
  /**
232
316
  * set when a new text is created or when an existing text is being edited
233
317
  */
@@ -252,11 +336,14 @@ export interface AppState {
252
336
  exportWithDarkMode: boolean;
253
337
  exportScale: number;
254
338
  currentItemStrokeColor: string;
339
+ currentItemStickynoteStrokeColor: string;
340
+ currentItemStickynoteBackgroundColor: string;
255
341
  currentItemBackgroundColor: string;
256
342
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
257
- currentItemStrokeWidth: number;
343
+ currentItemStrokeWidthKey: StrokeWidthKey;
258
344
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
259
345
  currentItemRoughness: number;
346
+ currentItemStrokeVariability: StrokeVariability;
260
347
  currentItemOpacity: number;
261
348
  currentItemFontFamily: FontFamilyValues;
262
349
  currentItemFontSize: number;
@@ -269,6 +356,7 @@ export interface AppState {
269
356
  viewBackgroundColor: string;
270
357
  scrollX: number;
271
358
  scrollY: number;
359
+ scrollConstraints: ScrollConstraints | null;
272
360
  cursorButton: "up" | "down";
273
361
  scrolledOutside: boolean;
274
362
  name: string | null;
@@ -356,10 +444,6 @@ export interface AppState {
356
444
  y: number;
357
445
  } | null;
358
446
  objectsSnapModeEnabled: boolean;
359
- /** the user's socket id & username who is being followed on the canvas */
360
- userToFollow: UserToFollow | null;
361
- /** the socket ids of the users following the current user */
362
- followedBy: Set<SocketId>;
363
447
  /** image cropping */
364
448
  isCropping: boolean;
365
449
  croppingElementId: ExcalidrawElement["id"] | null;
@@ -374,6 +458,23 @@ export interface AppState {
374
458
  [groupId: string]: true;
375
459
  };
376
460
  bindMode: BindMode;
461
+ /** user-customized color-picker top picks (pinned via drag & drop from the
462
+ * color picker popup). `null` means no customization (defaults, or
463
+ * host-supplied `topPicks`, are used). Kept per picker. */
464
+ colorTopPicks: {
465
+ elementStroke: readonly string[] | null;
466
+ elementBackground: readonly string[] | null;
467
+ /** the bucket-fill tool keeps a list separate from `elementBackground`
468
+ * even though both drive `currentItemBackgroundColor` (its defaults and
469
+ * use case differ — no transparent) */
470
+ bucketFill: readonly string[] | null;
471
+ /** sticky notes are their own color domain (own defaults, own picks) */
472
+ stickyNoteStroke: readonly string[] | null;
473
+ stickyNoteBackground: readonly string[] | null;
474
+ };
475
+ /** user-customized font-picker top picks (pinned via drag & drop from the
476
+ * font picker popup). `null` means no customization (defaults are used) */
477
+ fontTopPicks: readonly FontFamilyValues[] | null;
377
478
  }
378
479
  export type SearchMatch = {
379
480
  id: string;
@@ -386,7 +487,7 @@ export type SearchMatch = {
386
487
  showOnCanvas: boolean;
387
488
  }[];
388
489
  };
389
- export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
490
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
390
491
  export type NormalizedZoomValue = number & {
391
492
  _brand: "normalizedZoom";
392
493
  };
@@ -430,23 +531,175 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
430
531
  export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
431
532
  libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
432
533
  }>;
534
+ export type ExcalidrawInitialState = {
535
+ viewport?: Omit<SetViewportOptions, "animation">;
536
+ };
433
537
  export type OnUserFollowedPayload = {
434
538
  userToFollow: UserToFollow;
435
539
  action: "FOLLOW" | "UNFOLLOW";
436
540
  };
541
+ export type ViewportStatusFrame = {
542
+ /** the badge (bottom-center pill) */
543
+ label?: {
544
+ label: React.ReactNode;
545
+ icon?: React.ReactNode;
546
+ /** badge background; defaults to var(--color-primary-hover) */
547
+ background?: string;
548
+ /** badge text color; defaults to var(--color-primary-light) */
549
+ color?: string;
550
+ /** makes the badge label interactive */
551
+ onClick?: () => void;
552
+ /** renders a close button when set */
553
+ onClose?: () => void;
554
+ };
555
+ /** viewport-edge border: CSS color, or `false` for none */
556
+ border: false | string;
557
+ };
437
558
  export type OnExportProgress = {
438
559
  type: "progress";
439
560
  message?: React.ReactNode;
440
561
  /** 0-1 range */
441
562
  progress?: number;
442
563
  };
564
+ export type InteractionConfig = {
565
+ /**
566
+ * Interactions that stay enabled while the editor is otherwise
567
+ * non-interactive. Opt-in: anything omitted or `false` is disabled.
568
+ */
569
+ enabled?: {
570
+ /**
571
+ * Element links render their link icon and stay clickable — clicking
572
+ * anywhere on a linked element opens the link, same as in view mode.
573
+ * When disabled, link icons are not rendered at all.
574
+ *
575
+ * @default false
576
+ */
577
+ links?: boolean;
578
+ /**
579
+ * Embeddable & iframe elements stay interactive — hovering & clicking
580
+ * activates them so their content can be used, same as in view mode.
581
+ *
582
+ * @default false
583
+ */
584
+ embeds?: boolean;
585
+ /**
586
+ * Umbrella for all interactive content on canvas — shorthand for
587
+ * enabling `links` & `embeds` (and future interactive content kinds)
588
+ * together. Additive: `interactiveContent: true` enables them
589
+ * regardless of their individual values.
590
+ *
591
+ * @default false
592
+ */
593
+ interactiveContent?: boolean;
594
+ /**
595
+ * Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
596
+ * and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
597
+ * zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
598
+ * mode. Respects `appState.scrollConstraints` if set, so it composes
599
+ * with viewport locking. The rest of the keyboard stays disabled. Note
600
+ * the editor consumes wheel & touch input again when enabled, so the
601
+ * page no longer scrolls over the editor.
602
+ *
603
+ * @default false
604
+ */
605
+ navigation?: boolean;
606
+ /**
607
+ * Whether the browser's own zoom remains available over the editor —
608
+ * ctrl/cmd + wheel, pinch, and (while the editor has focus)
609
+ * ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
610
+ * interactive editor. Regular page scrolling stays available either way.
611
+ * With `navigation` enabled, the zoom input (wheel, pinch, keyboard
612
+ * shortcuts) zooms the canvas instead either way, making this moot.
613
+ *
614
+ * @default false
615
+ */
616
+ browserZoom?: boolean;
617
+ /**
618
+ * Tools that stay user-driven while the editor is otherwise
619
+ * non-interactive: pointer input keeps driving the listed tool when it's
620
+ * the active tool. Does not enable user-driven tool *switching* — the
621
+ * keyboard stays disabled and tool selection remains host-driven
622
+ * (`ExcalidrawAPI.setActiveTool`).
623
+ *
624
+ * Composes with `navigation`: the enabled tool wins the primary-pointer
625
+ * drag, while wheel input (and wheel-button drag) still pans/zooms.
626
+ */
627
+ tools?: {
628
+ /**
629
+ * The laser pointer stays usable — pointer strokes draw laser trails
630
+ * and pointer positions keep broadcasting via `onPointerUpdate`, so
631
+ * e.g. collaborators see a presenter's laser & cursor.
632
+ *
633
+ * @default false
634
+ */
635
+ laser?: boolean;
636
+ /**
637
+ * Custom tools (`activeTool.type === "custom"`) stay usable — the
638
+ * editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
639
+ * Tool behavior is host-implemented; activate custom tools with
640
+ * `locked: true` or they revert to the selection tool (and go inert)
641
+ * after the first pointer interaction.
642
+ *
643
+ * @default false
644
+ */
645
+ custom?: boolean;
646
+ };
647
+ };
648
+ };
649
+ export type UIConfig = {
650
+ /**
651
+ * Default UI controls that stay enabled while the rest of Excalidraw's
652
+ * default UI is hidden. Opt-in: anything omitted or `false` is disabled.
653
+ */
654
+ enabled: {
655
+ /**
656
+ * The zoom-out, reset-zoom, and zoom-in controls.
657
+ *
658
+ * @default false
659
+ */
660
+ zoom?: boolean;
661
+ /**
662
+ * The button shown when the viewport is scrolled away from all content.
663
+ *
664
+ * @default false
665
+ */
666
+ scrollBackToContent?: boolean;
667
+ };
668
+ };
669
+ /** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
670
+ export type ElementRenderOverride = Readonly<{
671
+ /** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
672
+ opacity?: number;
673
+ /** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
674
+ offset?: Readonly<{
675
+ x: number;
676
+ y: number;
677
+ }>;
678
+ }>;
679
+ /** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
680
+ export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
681
+ /** The translation part of a snapshot: only the entries that carry an offset. */
682
+ export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
443
683
  export interface ExcalidrawProps {
684
+ className?: string;
685
+ /**
686
+ * Document that owns Excalidraw's mounted DOM.
687
+ *
688
+ * Set only when it differs from the global `document`, such as when code
689
+ * executing in a parent window mounts Excalidraw into an iframe document.
690
+ * The value must remain stable for the editor's lifetime.
691
+ *
692
+ * @default document
693
+ */
694
+ ownerDocument?: Document;
444
695
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
696
+ onThemeChange?: (theme: Theme | "system") => void;
445
697
  /**
446
698
  * note: only subscribes if the props.onIncrement is defined on initial render
447
699
  */
448
700
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
449
701
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
702
+ initialState?: ExcalidrawInitialState;
450
703
  /**
451
704
  * Invoked as soon as the Excalidraw API is available
452
705
  * NOTE editor is not yet mounted, and state is not yet initialized
@@ -484,15 +737,95 @@ export interface ExcalidrawProps {
484
737
  *
485
738
  * Returned elements will be used in place of the next elements
486
739
  * (you should return all elements, including deleted, and not mutate
487
- * the element if changes are made)
740
+ * the element if changes are made).
741
+ *
742
+ * The duplicates are the elements in `nextElements` which are not in
743
+ * `prevElements` (see also `data.duplicateElements`). When pasting or
744
+ * inserting onto a frame, their `frameId` is already set. To change a
745
+ * duplicate, return a new object with the same `id`. It is shallow-merged
746
+ * into the duplicate (omitted properties are kept), and your changes are
747
+ * part of the duplication itself (same undo entry, same durable increment).
748
+ *
749
+ * To prevent an element from being duplicated, omit its duplicate from the
750
+ * returned array. References to it from the remaining duplicates are
751
+ * cleared, and a bound text isn't duplicated without its container. To
752
+ * prevent the duplication as a whole, return `false`. If no duplicate
753
+ * remains, the duplication is cancelled and the returned elements are
754
+ * ignored (alt-drag then moves the original elements instead).
488
755
  */
489
756
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
490
757
  /** excludes the duplicated elements */
491
- prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
758
+ prevElements: readonly ExcalidrawElement[],
759
+ /** lookups covering just the elements taking part in the duplication */
760
+ data: OnDuplicateData) => ExcalidrawElement[] | void | false;
492
761
  renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
493
762
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
494
763
  langCode?: Language["code"];
495
764
  viewModeEnabled?: boolean;
765
+ /**
766
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
767
+ * clipboard, drag&drop). When `false`, the scene still renders and reacts
768
+ * to programmatic updates (imperative API), but the user cannot affect it
769
+ * in any way. Implies view mode.
770
+ *
771
+ * Pass a config object to keep specific interactions enabled while the
772
+ * editor is otherwise non-interactive (see `InteractionConfig`):
773
+ *
774
+ * ```tsx
775
+ * <Excalidraw interaction={{ enabled: { links: true } }} />
776
+ * ```
777
+ *
778
+ * @default true
779
+ */
780
+ interaction?: boolean | InteractionConfig;
781
+ /**
782
+ * Whether Excalidraw's default UI is rendered — toolbar, default menus,
783
+ * footer controls, sidebars, and canvas popups. Host UI passed through
784
+ * children (including exported components such as `MainMenu` and `Footer`)
785
+ * or render props continues to render, together with any supporting dialogs
786
+ * it opens.
787
+ *
788
+ * Canvas content (elements, text editing surface, frame names, embeds) still
789
+ * renders, and the editor remains interactive unless `interaction` is set to
790
+ * `false`.
791
+ *
792
+ * Pass a config object to keep specific default controls rendered while the
793
+ * rest of the default UI is hidden (see `UIConfig`):
794
+ *
795
+ * ```tsx
796
+ * <Excalidraw ui={{ enabled: { zoom: true } }} />
797
+ * ```
798
+ *
799
+ * NOTE: this is WIP and what default UI is/is not rendered when ui=false
800
+ * may yet change.
801
+ *
802
+ * @default true
803
+ */
804
+ ui?: boolean | UIConfig;
805
+ /**
806
+ * Forces the active editor tool (controlled). While set, user- and
807
+ * API-driven tool switching is ignored — `setActiveTool` refuses with a
808
+ * console warning, non-forced toolbar buttons render disabled — and the
809
+ * editor snaps back if internal flows reset the tool. The forced tool
810
+ * behaves as if locked (see the tool lock / padlock): it doesn't revert to
811
+ * the selection tool after use, and elements drawn with it aren't
812
+ * auto-selected — without mutating `appState.activeTool.locked`, so the
813
+ * user's persisted padlock preference stays untouched. Unset to return
814
+ * tool control to the editor (the current tool stays active).
815
+ *
816
+ * The forced tool must be activatable to take effect: not disabled via
817
+ * `UIOptions.tools`, and — while the editor is non-interactive — allowed
818
+ * via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
819
+ * non-interactive, resets to) the `selection` tool, and the forced tool is
820
+ * applied once it becomes activatable. `image` cannot be forced (its
821
+ * activation opens the file picker).
822
+ */
823
+ activeTool?: {
824
+ type: Exclude<ToolType, "image">;
825
+ } | {
826
+ type: "custom";
827
+ customType: string;
828
+ };
496
829
  zenModeEnabled?: boolean;
497
830
  gridModeEnabled?: boolean;
498
831
  objectsSnapModeEnabled?: boolean;
@@ -501,6 +834,10 @@ export interface ExcalidrawProps {
501
834
  name?: string;
502
835
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
503
836
  UIOptions?: Partial<UIOptions>;
837
+ /**
838
+ * dimensions and size constraints for inserted images
839
+ */
840
+ imageOptions?: ImageOptions;
504
841
  detectScroll?: boolean;
505
842
  handleKeyboardGlobally?: boolean;
506
843
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -520,6 +857,21 @@ export interface ExcalidrawProps {
520
857
  aiEnabled?: boolean;
521
858
  showDeprecatedFonts?: boolean;
522
859
  renderScrollbars?: boolean;
860
+ viewportStatusFrame?: ViewportStatusFrame | null;
861
+ /**
862
+ * Rendered inside the UserList "who's here" dropdown (desktop) and inline
863
+ * in the mobile menu's collaborators section, below a divider. Accepts a
864
+ * render function — called with `isMobile` so hosts can render different
865
+ * UI for each surface — in addition to a plain node.
866
+ */
867
+ currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
868
+ /**
869
+ * The user being followed on the canvas, if any. Controlled by the host —
870
+ * the editor never sets it; it emits follow/unfollow intents via
871
+ * `onUserFollow` (prop or imperative API) and renders the followed
872
+ * user's avatar highlight from this value.
873
+ */
874
+ userToFollow?: UserToFollow | null;
523
875
  /**
524
876
  * Called before exporting to a file.
525
877
  *
@@ -545,7 +897,8 @@ export interface ExcalidrawProps {
545
897
  }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
546
898
  }
547
899
  export type SceneData = {
548
- elements?: ImportedDataState["elements"];
900
+ /** Expects normalized elements; restore imported data before updating the scene. */
901
+ elements?: readonly ExcalidrawElement[] | null;
549
902
  appState?: ImportedDataState["appState"];
550
903
  collaborators?: Map<SocketId, Collaborator>;
551
904
  captureUpdate?: CaptureUpdateActionType;
@@ -555,12 +908,21 @@ export type ExportOpts = {
555
908
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
556
909
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
557
910
  };
911
+ export type ImageOptions = Partial<{
912
+ maxWidthOrHeight: number;
913
+ maxFileSizeBytes: number;
914
+ }>;
558
915
  export type CanvasActions = Partial<{
559
916
  changeViewBackgroundColor: boolean;
560
917
  clearCanvas: boolean;
561
918
  export: false | ExportOpts;
562
919
  loadScene: boolean;
563
920
  saveToActiveFile: boolean;
921
+ /**
922
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
923
+ * is supplied (at which point the theme is considered as host-app controlled),
924
+ * else default to false
925
+ * */
564
926
  toggleTheme: boolean | null;
565
927
  saveAsImage: boolean;
566
928
  }>;
@@ -584,6 +946,7 @@ export type AppProps = Merge<ExcalidrawProps, {
584
946
  export: ExportOpts;
585
947
  };
586
948
  }>;
949
+ imageOptions: Required<ImageOptions>;
587
950
  detectScroll: boolean;
588
951
  handleKeyboardGlobally: boolean;
589
952
  isCollaborating: boolean;
@@ -595,6 +958,8 @@ export type AppProps = Merge<ExcalidrawProps, {
595
958
  export type AppClassProperties = {
596
959
  props: AppProps;
597
960
  state: AppState;
961
+ readonly ownerDocument: Document;
962
+ readonly ownerWindow: Window & typeof globalThis;
598
963
  api: App["api"];
599
964
  sessionExportThemeOverride: App["sessionExportThemeOverride"];
600
965
  interactiveCanvas: HTMLCanvasElement | null;
@@ -611,12 +976,11 @@ export type AppClassProperties = {
611
976
  scene: App["scene"];
612
977
  syncActionResult: App["syncActionResult"];
613
978
  fonts: App["fonts"];
614
- pasteFromClipboard: App["pasteFromClipboard"];
979
+ clipboard: App["clipboard"];
615
980
  id: App["id"];
616
981
  onInsertElements: App["onInsertElements"];
617
982
  onExportImage: App["onExportImage"];
618
- lastViewportPosition: App["lastViewportPosition"];
619
- scrollToContent: App["scrollToContent"];
983
+ viewport: App["viewport"];
620
984
  addFiles: App["addFiles"];
621
985
  addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
622
986
  togglePenMode: App["togglePenMode"];
@@ -627,11 +991,19 @@ export type AppClassProperties = {
627
991
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
628
992
  getName: App["getName"];
629
993
  dismissLinearEditor: App["dismissLinearEditor"];
630
- flowChartCreator: App["flowChartCreator"];
994
+ flowchart: App["flowchart"];
995
+ drawShape: App["drawShape"];
996
+ arrowText: App["arrowText"];
997
+ textTool: App["textTool"];
998
+ cursor: App["cursor"];
999
+ bucketFill: App["bucketFill"];
1000
+ duplicate: App["duplicate"];
1001
+ toolDrag: App["toolDrag"];
1002
+ activeResizeHandle: App["activeResizeHandle"];
1003
+ isToolLocked: App["isToolLocked"];
631
1004
  getEffectiveGridSize: App["getEffectiveGridSize"];
632
1005
  setPlugins: App["setPlugins"];
633
1006
  plugins: App["plugins"];
634
- getEditorUIOffsets: App["getEditorUIOffsets"];
635
1007
  visibleElements: App["visibleElements"];
636
1008
  excalidrawContainerValue: App["excalidrawContainerValue"];
637
1009
  onPointerUpEmitter: App["onPointerUpEmitter"];
@@ -640,8 +1012,13 @@ export type AppClassProperties = {
640
1012
  onEvent: App["onEvent"];
641
1013
  onStateChange: App["onStateChange"];
642
1014
  lastPointerMoveCoords: App["lastPointerMoveCoords"];
1015
+ lastPointerMoveEvent: App["lastPointerMoveEvent"];
643
1016
  bindModeHandler: App["bindModeHandler"];
1017
+ emitUserFollowIntent: App["emitUserFollowIntent"];
1018
+ requestUnfollow: App["requestUnfollow"];
644
1019
  setAppState: App["setAppState"];
1020
+ isInteractionEnabled: App["isInteractionEnabled"];
1021
+ isNavigationEnabled: App["isNavigationEnabled"];
645
1022
  };
646
1023
  export type PointerDownState = Readonly<{
647
1024
  origin: Readonly<{
@@ -676,7 +1053,10 @@ export type PointerDownState = Readonly<{
676
1053
  allHitElements: NonDeleted<ExcalidrawElement>[];
677
1054
  wasAddedToSelection: boolean;
678
1055
  hasBeenDuplicated: boolean;
1056
+ advancedListMarkers: readonly ListMarkerAdvance[];
1057
+ editedTextId: ExcalidrawTextElement["id"] | null;
679
1058
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
1059
+ arrowLabel: boolean;
680
1060
  };
681
1061
  withCmdOrCtrl: boolean;
682
1062
  drag: {
@@ -728,15 +1108,32 @@ export interface ExcalidrawImperativeAPI {
728
1108
  getAppState: () => InstanceType<typeof App>["state"];
729
1109
  getFiles: () => InstanceType<typeof App>["files"];
730
1110
  getName: InstanceType<typeof App>["getName"];
731
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
1111
+ setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
1112
+ getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
1113
+ /**
1114
+ * Atomically replaces all transient visual overrides. Values are copied;
1115
+ * omitted IDs/fields use document values, except for inherited label offsets.
1116
+ * null clears the snapshot.
1117
+ * Repaints without document changes, history entries or onChange events;
1118
+ * an equivalent snapshot may still repaint (clearing an already clear
1119
+ * snapshot does not), so submit only when something changed.
1120
+ * Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
1121
+ * Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
1122
+ * Bound labels inherit their container's offset; offsets targeting them are
1123
+ * ignored. Label opacity remains independent. Target frame children explicitly.
1124
+ * Frame opacity still multiplies child opacity. Decorations follow their owner.
1125
+ * Exports and interactive geometry (hit tests, selection, editing) use document
1126
+ * values, including while authoring an animation preview in edit mode.
1127
+ */
1128
+ setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
732
1129
  registerAction: (action: Action) => void;
733
1130
  refresh: InstanceType<typeof App>["refresh"];
734
1131
  setToast: InstanceType<typeof App>["setToast"];
735
1132
  addFiles: (data: BinaryFileData[]) => void;
736
1133
  id: string;
737
1134
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
738
- setCursor: InstanceType<typeof App>["setCursor"];
739
- resetCursor: InstanceType<typeof App>["resetCursor"];
1135
+ setCursor: InstanceType<typeof App>["cursor"]["set"];
1136
+ resetCursor: InstanceType<typeof App>["cursor"]["reset"];
740
1137
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
741
1138
  getEditorInterface: () => EditorInterface;
742
1139
  /**
@@ -759,7 +1156,6 @@ export type FrameNameBounds = {
759
1156
  y: number;
760
1157
  width: number;
761
1158
  height: number;
762
- angle: number;
763
1159
  };
764
1160
  export type FrameNameBoundsCache = {
765
1161
  get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
@@ -778,12 +1174,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
778
1174
  export type JSONValue = string | number | boolean | null | object;
779
1175
  export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
780
1176
  export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
781
- export type PendingExcalidrawElements = ExcalidrawElement[];
1177
+ export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
782
1178
  /** Runtime gridSize value. Null indicates disabled grid. */
783
1179
  export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
784
1180
  export type GenerateDiagramToCode = (props: {
785
- frame: ExcalidrawMagicFrameElement;
786
- children: readonly ExcalidrawElement[];
1181
+ frame: NonDeleted<ExcalidrawMagicFrameElement>;
1182
+ children: readonly NonDeletedExcalidrawElement[];
1183
+ /**
1184
+ * Optional streaming hook. Call with the accumulated response text as it
1185
+ * streams in so the editor can progressively render the partial HTML
1186
+ * inside the generated frame.
1187
+ */
1188
+ onPartial?: (html: string) => void;
787
1189
  }) => MaybePromise<{
788
1190
  html: string;
789
1191
  }>;
@@ -793,3 +1195,103 @@ export type Offsets = Partial<{
793
1195
  bottom: number;
794
1196
  left: number;
795
1197
  }>;
1198
+ /**
1199
+ * Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
1200
+ * surface that occludes the canvas. Such nodes are measured by
1201
+ * `getViewportOffsets` to compute the default per-side viewport offsets:
1202
+ *
1203
+ * - `top` / `bottom` — offsets that side by the node's bottom/top edge
1204
+ * - `side` — a panel hugging the left or right edge. Which side is not
1205
+ * declared but resolved geometrically: if the node's horizontal center
1206
+ * lies in the left half of the viewport it counts against the left
1207
+ * offset (by its right edge), otherwise against the right offset (by
1208
+ * `viewportWidth - left edge`). Measuring the rendered position instead
1209
+ * of declaring a side means RTL layouts and host-configurable docking
1210
+ * (e.g. sidebar side) are handled for free — but it assumes the surface
1211
+ * actually hugs one edge; don't mark a centered/near-full-width node as
1212
+ * `side` (its midpoint would classify it to one side and the offset
1213
+ * would swallow most of the viewport).
1214
+ *
1215
+ * The attribute should only be present while the surface is actually
1216
+ * rendered — omit it (don't just hide the node) when the surface shouldn't
1217
+ * push the viewport around.
1218
+ */
1219
+ export type ViewportUIDock = "top" | "bottom" | "side";
1220
+ /**
1221
+ * Options for `getViewportOffsets` (and the `ui` key of
1222
+ * {@link ViewportOffsets}), controlling how offsets are derived from the
1223
+ * currently rendered editor UI.
1224
+ *
1225
+ * NOTE unlike the physical sides of {@link Offsets}, the horizontal values
1226
+ * here are logical, i.e. flipped in RTL layouts (`left` refers to the
1227
+ * reading-direction start side).
1228
+ */
1229
+ export type ViewportOffsetsOptions = {
1230
+ /** padding added to each measured side (default 24) */
1231
+ padding?: number;
1232
+ paddingTop?: number;
1233
+ paddingRight?: number;
1234
+ paddingBottom?: number;
1235
+ paddingLeft?: number;
1236
+ /** final value for the given side, replacing the measured UI size
1237
+ * (padding is not added on top) */
1238
+ top?: number;
1239
+ bottom?: number;
1240
+ left?: number;
1241
+ right?: number;
1242
+ /**
1243
+ * Reserve space for the given conditionally-rendered surfaces even while
1244
+ * they're hidden, so the resulting offsets don't shift when they
1245
+ * (dis)appear. Uses the surface's last-measured footprint, falling back
1246
+ * to an approximate default if it hasn't been rendered yet. Ignored on
1247
+ * phones (where these surfaces never occlude the canvas).
1248
+ */
1249
+ reserve?: {
1250
+ /** styles panel (rendered when a tool or selection is active) */
1251
+ stylesPanel?: boolean;
1252
+ /** sidebar (e.g. library) */
1253
+ sidebar?: boolean;
1254
+ };
1255
+ };
1256
+ /**
1257
+ * Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
1258
+ * `props.initialState.viewport`), insetting the usable viewport area per
1259
+ * side so the target isn't fitted/centered underneath overlaid UI.
1260
+ *
1261
+ * Two (combinable) ways to specify:
1262
+ *
1263
+ * - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
1264
+ * values, used as-is: physical (not flipped in RTL), zoom-independent,
1265
+ * no padding added. Sides not specified default to `0` (unless `ui` is
1266
+ * set, see below).
1267
+ *
1268
+ * - **`ui`** — derive the offsets from the editor UI (toolbar, styles
1269
+ * panel, sidebar...) as rendered at the time the viewport is set,
1270
+ * equivalent to calling `getViewportOffsets()`. Pass `true` for the
1271
+ * defaults, or options ({@link ViewportOffsetsOptions}) to customize
1272
+ * padding or reserve space for currently-hidden surfaces.
1273
+ *
1274
+ * When both are given, a static side always wins for that side — it
1275
+ * replaces whatever `ui` would yield (including `ui`'s own side overrides,
1276
+ * which — unlike the physical static sides — are RTL-relative). The
1277
+ * remaining sides fall back to the `ui`-derived values.
1278
+ *
1279
+ * @example
1280
+ * { top: 40 } // top 40px, other sides 0
1281
+ * { ui: true } // measured UI + default padding
1282
+ * { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
1283
+ * { top: 40, ui: true } // top exactly 40px, rest from UI
1284
+ */
1285
+ export type ViewportOffsets = Offsets & {
1286
+ ui?: true | ViewportOffsetsOptions;
1287
+ };
1288
+ /**
1289
+ * Value of the `data-viewport-ui-name` attribute, identifying a
1290
+ * conditionally-rendered surface (marked with `data-viewport-ui`) so that
1291
+ * it can be measured on its own, and so that `getViewportOffsets` can
1292
+ * reserve space for it while it's hidden (see the `reserve` option).
1293
+ * Whenever a named surface is rendered, its measured footprint is
1294
+ * remembered; reserving uses that remembered footprint, or an approximate
1295
+ * default if the surface hasn't been rendered yet.
1296
+ */
1297
+ export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";