@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,21 +1,36 @@
1
1
  import React from "react";
2
2
  import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
3
- import { LinearElementEditor, FlowChartCreator, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
3
+ import { LinearElementEditor, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
4
  import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
+ import type { TransformHandleDirection } from "@excalidraw/element";
5
6
  import type { Mutable } from "@excalidraw/common/utility-types";
6
7
  import { ActionManager } from "../actions/manager";
7
- import { AnimationFrameHandler } from "../animation-frame-handler";
8
8
  import { History } from "../history";
9
9
  import { Fonts } from "../fonts";
10
10
  import { type WritableAtom } from "../editor-jotai";
11
11
  import { Renderer } from "../scene/Renderer";
12
- import { LaserTrails } from "../laser-trails";
12
+ import { type SetViewportOptions } from "../viewport";
13
+ import { LaserTrails } from "../laserTrails";
13
14
  import { isOverScrollBars } from "../scene/scrollbars";
14
15
  import { LassoTrail } from "../lasso";
15
16
  import { EraserTrail } from "../eraser";
17
+ import { AppArrowText } from "./App.arrowText";
18
+ import { AppClipboard } from "./App.clipboard";
19
+ import { AppText } from "./App.text";
20
+ import { AppTextTool } from "./App.textTool";
21
+ import { AppBucketFill } from "./App.bucketFill";
22
+ import { AppToolDrag } from "./App.toolDrag";
23
+ import { AppCursor } from "./App.cursor";
24
+ import { AppDrawShape } from "./App.drawshape";
25
+ import { AppDuplicate } from "./App.duplicate";
26
+ import { AppFlowchart } from "./App.flowchart";
27
+ import { AppPan } from "./App.pan";
28
+ import { AppViewport } from "./App.viewport";
29
+ import { AppWheel } from "./App.wheel";
30
+ import { CursorHints } from "./CursorHint";
16
31
  import { type OnStateChange } from "./AppStateObserver";
17
32
  import type { ExportedElements } from "../data";
18
- import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
33
+ import type { AppClassProperties, AppProps, AppState, ElementRenderOverrides, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, PointerDownState, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, KeyboardModifiersObject, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, UIConfig } from "../types";
19
34
  import type { RoughCanvas } from "roughjs/bin/canvas";
20
35
  import type { ActionResult } from "../actions/types";
21
36
  declare const editorLifecycleEventBehavior: {
@@ -74,15 +89,21 @@ declare class App extends React.Component<AppProps, AppState> {
74
89
  editorInterface: EditorInterface;
75
90
  private stylesPanelMode;
76
91
  private excalidrawContainerRef;
92
+ private zenModeTransitionTimer;
93
+ get ownerDocument(): Document;
94
+ get ownerWindow(): Window & typeof globalThis;
77
95
  scene: Scene;
78
96
  fonts: Fonts;
79
97
  renderer: Renderer;
80
98
  visibleElements: readonly NonDeletedExcalidrawElement[];
99
+ /** whether the last render had any renderable elements (excludes e.g. the
100
+ * in-progress `newElement` and the edited text element) */
101
+ private hasRenderableElements;
81
102
  private resizeObserver;
82
103
  library: AppClassProperties["library"];
83
104
  libraryItemsFromStorage: LibraryItems | undefined;
84
105
  id: string;
85
- private store;
106
+ store: Store;
86
107
  private history;
87
108
  excalidrawContainerValue: {
88
109
  container: HTMLDivElement | null;
@@ -107,11 +128,28 @@ declare class App extends React.Component<AppProps, AppState> {
107
128
  onEvent: AppEventBus<ExcalidrawImperativeAPIEventMap, typeof editorLifecycleEventBehavior>["on"];
108
129
  private appStateObserver;
109
130
  onStateChange: OnStateChange;
110
- flowChartCreator: FlowChartCreator;
111
- private flowChartNavigator;
131
+ bucketFill: AppBucketFill;
132
+ duplicate: AppDuplicate;
133
+ toolDrag: AppToolDrag;
134
+ flowchart: AppFlowchart;
135
+ cursor: AppCursor;
136
+ arrowText: AppArrowText;
137
+ pan: AppPan;
138
+ textTool: AppTextTool;
139
+ clipboard: AppClipboard;
140
+ text: AppText;
141
+ viewport: AppViewport;
142
+ wheel: AppWheel;
112
143
  bindModeHandler: ReturnType<typeof setTimeout> | null;
113
144
  hitLinkElement?: NonDeletedExcalidrawElement;
114
145
  lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
146
+ /**
147
+ * the handle of the resize in progress while `state.isResizing` — for UI
148
+ * that words itself by handle (a sticky note's corners resize
149
+ * proportionally, its edges freely); not app state, so it costs no
150
+ * re-render of its own
151
+ */
152
+ activeResizeHandle: TransformHandleDirection | null;
115
153
  lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
116
154
  lastPointerUpIsDoubleClick: boolean;
117
155
  lastPointerMoveEvent: PointerEvent | null;
@@ -126,14 +164,11 @@ declare class App extends React.Component<AppProps, AppState> {
126
164
  x: number;
127
165
  y: number;
128
166
  } | null;
129
- lastViewportPosition: {
130
- x: number;
131
- y: number;
132
- };
133
- animationFrameHandler: AnimationFrameHandler;
167
+ drawShape: AppDrawShape;
134
168
  laserTrails: LaserTrails;
135
169
  eraserTrail: EraserTrail;
136
170
  lassoTrail: LassoTrail;
171
+ cursorHints: CursorHints;
137
172
  onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
138
173
  onPointerDownEmitter: Emitter<[activeTool: {
139
174
  lastActiveTool: import("../types").ActiveTool | null;
@@ -172,7 +207,10 @@ declare class App extends React.Component<AppProps, AppState> {
172
207
  allHitElements: NonDeleted<ExcalidrawElement>[];
173
208
  wasAddedToSelection: boolean;
174
209
  hasBeenDuplicated: boolean;
210
+ advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
211
+ editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
175
212
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
213
+ arrowLabel: boolean;
176
214
  };
177
215
  withCmdOrCtrl: boolean;
178
216
  drag: {
@@ -234,7 +272,10 @@ declare class App extends React.Component<AppProps, AppState> {
234
272
  allHitElements: NonDeleted<ExcalidrawElement>[];
235
273
  wasAddedToSelection: boolean;
236
274
  hasBeenDuplicated: boolean;
275
+ advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
276
+ editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
237
277
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
278
+ arrowLabel: boolean;
238
279
  };
239
280
  withCmdOrCtrl: boolean;
240
281
  drag: {
@@ -266,8 +307,83 @@ declare class App extends React.Component<AppProps, AppState> {
266
307
  missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
267
308
  onRemoveEventListenersEmitter: Emitter<[]>;
268
309
  api: ExcalidrawImperativeAPI;
310
+ private elementRenderOverrides;
311
+ /** offsets of `elementRenderOverrides`; keeps its identity while they don't change */
312
+ private elementRenderOffsets;
313
+ private renderOverridesUpdatePending;
314
+ private getRenderOverrideConfig;
315
+ private getElementRenderState;
269
316
  private createExcalidrawAPI;
270
317
  constructor(props: AppProps);
318
+ /**
319
+ * Whether the editor accepts user input (pointer, keyboard, wheel, touch,
320
+ * clipboard, drag&drop). When `false`, the editor is fully inert for the
321
+ * user, but remains controllable through the imperative API.
322
+ *
323
+ * All user-input entry points must consult this getter (directly or by
324
+ * not being attached/rendered at all).
325
+ */
326
+ isInteractionEnabled(props?: Pick<AppProps, "interaction">): boolean;
327
+ /**
328
+ * Whether element links render their link icon and are clickable.
329
+ * True when fully interactive, or when `interaction: { enabled: { links:
330
+ * true } }`
331
+ * (in which case clicking anywhere on a linked element opens the link,
332
+ * same as in view mode).
333
+ */
334
+ isLinksEnabled(props?: Pick<AppProps, "interaction">): boolean;
335
+ /**
336
+ * Whether canvas navigation — panning & zooming, view-mode style — is
337
+ * enabled. True when fully interactive, or when `interaction: { enabled:
338
+ * { navigation: true } }`. Respects `appState.scrollConstraints`.
339
+ */
340
+ isNavigationEnabled(props?: Pick<AppProps, "interaction">): boolean;
341
+ /**
342
+ * Whether embeddable & iframe elements are interactive (hover & click to
343
+ * activate, view-mode style). True when fully interactive, or when
344
+ * allowed via `interaction.enabled.embeds` / `.interactiveContent`.
345
+ */
346
+ isEmbedsEnabled(props?: Pick<AppProps, "interaction">): boolean;
347
+ /**
348
+ * Whether the browser's own zoom (ctrl/cmd + wheel, pinch, keyboard
349
+ * shortcuts) stays available over the non-interactive editor.
350
+ * Prevented by default.
351
+ */
352
+ isBrowserZoomEnabled(props?: Pick<AppProps, "interaction">): boolean;
353
+ /**
354
+ * Whether the tool can be activated & driven by user input. False when
355
+ * disabled via `UIOptions.tools`, or when the editor is non-interactive
356
+ * and the tool isn't kept user-driven via `interaction.enabled.tools`.
357
+ *
358
+ * (Once UI tool availability is split from input availability — e.g.
359
+ * `props.ui.tools` vs `interaction.disabled.tools` — the UI axis moves
360
+ * out into its own predicate.)
361
+ *
362
+ * We purposely widen the `tool` type so this helper can be called with
363
+ * any tool without having to type check it.
364
+ */
365
+ isToolSupported: <T extends ToolType | "custom">(tool: T, props?: Pick<AppProps, "interaction" | "UIOptions">) => boolean;
366
+ /**
367
+ * Whether the active tool is locked in place — via the tool lock
368
+ * (padlock / Q) or by being host-forced (`props.activeTool`). A locked
369
+ * tool doesn't revert to the selection tool after use, and elements drawn
370
+ * with it aren't selected. Forcing deliberately does not mutate
371
+ * `activeTool.locked`, which is the user's persisted padlock preference.
372
+ */
373
+ isToolLocked(): boolean;
374
+ /**
375
+ * Whether the active tool captures the primary pointer instead of the
376
+ * view-mode drag-to-pan — the laser and host-implemented custom tools do;
377
+ * while non-interactive, any tool allowed via
378
+ * `interaction.enabled.tools` does. (Editing tools capture the pointer
379
+ * trivially since view mode implies they're not active; this predicate only
380
+ * matters where view-mode gates apply.)
381
+ */
382
+ isActiveToolPointerCapturing(): boolean;
383
+ /** Whether Excalidraw's full default UI is rendered. */
384
+ isDefaultUIEnabled(props?: Pick<AppProps, "ui">): boolean;
385
+ /** Whether an individual default UI control is rendered. */
386
+ isUIControlEnabled(control: keyof UIConfig["enabled"], props?: Pick<AppProps, "ui">): boolean;
271
387
  updateEditorAtom: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
272
388
  private onWindowMessage;
273
389
  private handleSkipBindMode;
@@ -280,8 +396,12 @@ declare class App extends React.Component<AppProps, AppState> {
280
396
  * If disabled, returns null.
281
397
  */
282
398
  getEffectiveGridSize: () => NullableGridSize;
283
- private getTextCreationGridPoint;
284
399
  private getHTMLIFrameElement;
400
+ /**
401
+ * AI-generated iframe elements aren't interactive while their generation
402
+ * is still in progress (the partial content is render-only).
403
+ */
404
+ private isIframeLikeInteractive;
285
405
  private handleIframeLikeElementHover;
286
406
  /** @returns true if iframe-like element click handled */
287
407
  private handleIframeLikeCenterClick;
@@ -302,7 +422,7 @@ declare class App extends React.Component<AppProps, AppState> {
302
422
  getSceneElements: () => readonly Ordered<NonDeletedExcalidrawElement>[];
303
423
  onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
304
424
  onExportImage: (type: keyof typeof EXPORT_IMAGE_TYPES, elements: ExportedElements, opts: {
305
- exportingFrame: ExcalidrawFrameLikeElement | null;
425
+ exportingFrame: NonDeleted<ExcalidrawFrameLikeElement> | null;
306
426
  }) => Promise<void>;
307
427
  private magicGenerations;
308
428
  private updateMagicGeneration;
@@ -318,9 +438,35 @@ declare class App extends React.Component<AppProps, AppState> {
318
438
  private openEyeDropper;
319
439
  dismissLinearEditor: () => void;
320
440
  syncActionResult: (actionResult: ActionResult) => void;
441
+ scheduleCapture: () => void;
321
442
  private onBlur;
322
443
  private onUnload;
323
444
  private disableEvent;
445
+ private isFileDropEnabled;
446
+ private onDragOver;
447
+ private handleNavigationModeKeyDown;
448
+ /**
449
+ * PageUp/PageDown scroll the canvas by a page — vertically, or
450
+ * horizontally with shift. Respects `appState.scrollConstraints`
451
+ * (via `viewport.translate`).
452
+ */
453
+ private maybeHandlePageScrollKeyDown;
454
+ private preventBrowserZoomKeyDown;
455
+ /** Ends active input sessions before switching to a view-mode/non-interactive
456
+ * mode. */
457
+ private terminateActiveInteraction;
458
+ private handleInteractionStateChange;
459
+ /** whether the two values reference the same tool (incl. custom subtype) */
460
+ private isSameForcedTool;
461
+ /**
462
+ * Keeps `state.activeTool` synced to the host-controlled
463
+ * `props.activeTool`. `setActiveTool` refuses non-matching activations
464
+ * while forced (user input, API); this backstop covers the writers that
465
+ * bypass the funnel (`actionFinalize`/`actionDeselect`, `restore()` on
466
+ * scene load, ...) and re-applies the tool once it becomes activatable
467
+ * (e.g. `interaction` config changes).
468
+ */
469
+ private handleForcedToolChange;
324
470
  private resetHistory;
325
471
  private resetStore;
326
472
  /**
@@ -342,16 +488,20 @@ declare class App extends React.Component<AppProps, AppState> {
342
488
  private onFullscreenChange;
343
489
  private removeEventListeners;
344
490
  private addEventListeners;
491
+ getSnapshotBeforeUpdate(prevProps: AppProps, prevState: AppState): null;
492
+ /**
493
+ * Flags the container while toggling zen mode so that UI chrome
494
+ * (backgrounds etc.) animates only then, and hover transitions stay
495
+ * instant. A data attribute so that React doesn't reset it on re-render.
496
+ */
497
+ private markZenModeTransition;
498
+ private unmarkZenModeTransition;
345
499
  componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
346
500
  private renderInteractiveSceneCallback;
347
501
  private onScroll;
348
- private onCut;
349
- private onCopy;
350
502
  private static resetTapTwice;
351
503
  private onTouchStart;
352
504
  private onTouchEnd;
353
- private insertClipboardContent;
354
- pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
355
505
  addElementsFromPasteOrLibrary: (opts: {
356
506
  elements: readonly ExcalidrawElement[];
357
507
  files: BinaryFiles | null;
@@ -360,57 +510,25 @@ declare class App extends React.Component<AppProps, AppState> {
360
510
  clientY: number;
361
511
  } | "cursor" | "center";
362
512
  retainSeed?: boolean;
363
- fitToContent?: boolean;
513
+ fit?: SetViewportOptions["fit"];
514
+ preserveFrameChildrenOrder?: boolean;
364
515
  }) => void;
365
- private addElementsFromMixedContentPaste;
366
- private addTextFromPaste;
367
516
  setAppState: React.Component<any, AppState>["setState"];
368
517
  removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
369
518
  toggleLock: (source?: "keyboard" | "ui") => void;
370
519
  updateFrameRendering: (opts: Partial<AppState["frameRendering"]> | ((prevState: AppState["frameRendering"]) => Partial<AppState["frameRendering"]>)) => void;
371
520
  togglePenMode: (force: boolean | null) => void;
372
- onHandToolToggle: () => void;
373
- /**
374
- * Zooms on canvas viewport center
375
- */
376
- zoomCanvas: (
377
- /**
378
- * Decimal fraction, auto-clamped between MIN_ZOOM and MAX_ZOOM.
379
- * 1 = 100% zoom, 2 = 200% zoom, 0.5 = 50% zoom
380
- */
381
- value: number) => void;
382
- private cancelInProgressAnimation;
383
- scrollToContent: (
384
- /**
385
- * target to scroll to
386
- *
387
- * - string - id of element or group, or url containing elementLink
388
- * - ExcalidrawElement | ExcalidrawElement[] - element(s) objects
389
- */
390
- target?: string | ExcalidrawElement | readonly ExcalidrawElement[], opts?: ({
391
- fitToContent?: boolean;
392
- fitToViewport?: never;
393
- viewportZoomFactor?: number;
394
- animate?: boolean;
395
- duration?: number;
396
- } | {
397
- fitToContent?: never;
398
- fitToViewport?: boolean;
399
- /** when fitToViewport=true, how much screen should the content cover,
400
- * between 0.1 (10%) and 1 (100%)
401
- */
402
- viewportZoomFactor?: number;
403
- animate?: boolean;
404
- duration?: number;
405
- }) & {
406
- minZoom?: number;
407
- maxZoom?: number;
408
- canvasOffsets?: Offsets;
409
- }) => void;
410
- private maybeUnfollowRemoteUser;
411
- /** use when changing scrollX/scrollY/zoom based on user interaction */
412
- private translateCanvas;
521
+ revealIfHidden: (elements: NonDeletedExcalidrawElement[]) => void;
522
+ /** emits a follow/unfollow intent to the host (which owns the
523
+ * `userToFollow` state) via both the `onUserFollow` prop and the
524
+ * imperative API emitter */
525
+ emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
526
+ /** emits an UNFOLLOW intent if currently following someone — use on
527
+ * viewport changes that take the view over from the followed user (user
528
+ * pans and zooms, `setViewport` navigation) */
529
+ requestUnfollow: () => void;
413
530
  setToast: (toast: AppState["toast"]) => void;
531
+ private showSceneReplacedToast;
414
532
  restoreFileFromShare: () => Promise<void>;
415
533
  /**
416
534
  * adds supplied files to existing files in the appState.
@@ -435,9 +553,15 @@ declare class App extends React.Component<AppProps, AppState> {
435
553
  */
436
554
  captureUpdate?: SceneData["captureUpdate"];
437
555
  }) => void;
556
+ /**
557
+ * see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details
558
+ */
559
+ setElementRenderOverrides: (overrides: ElementRenderOverrides | null) => void;
438
560
  applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
439
561
  mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
440
- private triggerRender;
562
+ triggerRender: (
563
+ /** force always re-renders canvas even if no change */
564
+ force?: boolean) => void;
441
565
  /**
442
566
  * @returns whether the menu was toggled on or off
443
567
  */
@@ -447,10 +571,8 @@ declare class App extends React.Component<AppProps, AppState> {
447
571
  force?: boolean;
448
572
  }) => boolean;
449
573
  private updateCurrentCursorPosition;
450
- getEditorUIOffsets: () => Offsets;
451
574
  private onKeyDown;
452
575
  private onKeyUp;
453
- private isToolSupported;
454
576
  setActiveTool: (tool: ({
455
577
  type: ToolType;
456
578
  } | {
@@ -459,10 +581,18 @@ declare class App extends React.Component<AppProps, AppState> {
459
581
  }) & {
460
582
  locked?: boolean;
461
583
  fromSelection?: boolean;
462
- }, keepSelection?: boolean) => void;
584
+ }, opts?: {
585
+ keepSelection?: boolean;
586
+ /**
587
+ * When `true`, re-activating an already-active toggle tool (see
588
+ * `TOGGLE_TOOLS`) switches back to the previously active tool.
589
+ * Activation is idempotent by default; toggle tools always record the
590
+ * previously active tool regardless (so ESC and the next `toggle`
591
+ * activation can switch back to it).
592
+ */
593
+ toggle?: boolean;
594
+ }) => void;
463
595
  setOpenDialog: (dialogType: AppState["openDialog"]) => void;
464
- private setCursor;
465
- private resetCursor;
466
596
  /**
467
597
  * returns whether user is making a gesture with >= 2 fingers (points)
468
598
  * on o touch screen (not on a trackpad). Currently only relates to Darwin
@@ -474,19 +604,26 @@ declare class App extends React.Component<AppProps, AppState> {
474
604
  private onGestureStart;
475
605
  private onGestureChange;
476
606
  private onGestureEnd;
477
- private handleTextWysiwyg;
478
- private deselectElements;
479
- private getSelectedTextElement;
480
- private getSelectedTextEditingContainerAtPosition;
481
- private getTextElementAtPosition;
482
- private isHittingTextAutoResizeHandle;
483
- private handleTextAutoResizeHandlePointerDown;
484
- private getElementAtPosition;
485
- private getElementsAtPosition;
607
+ deselectElements(): void;
608
+ getElementAtPosition(x: number, y: number, opts?: ({
609
+ includeBoundTextElement?: boolean;
610
+ includeLockedElements?: boolean;
611
+ } | {
612
+ allHitElements: NonDeleted<ExcalidrawElement>[];
613
+ }) & {
614
+ preferSelected?: boolean;
615
+ }): NonDeleted<ExcalidrawElement> | null;
616
+ getElementsAtPosition(x: number, y: number, opts?: {
617
+ includeBoundTextElement?: boolean;
618
+ includeLockedElements?: boolean;
619
+ }): NonDeleted<ExcalidrawElement>[];
620
+ /**
621
+ * Whether the element's frame clips it away at the position — hitting a
622
+ * frame's element from outside the frame is not considered a hit.
623
+ */
624
+ isClippedByFrameAt(x: number, y: number, element: ExcalidrawElement): boolean;
486
625
  getElementHitThreshold(element: ExcalidrawElement): number;
487
- private hitElement;
488
- private getTextBindableContainerAtPosition;
489
- private startTextEditing;
626
+ hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
490
627
  private startImageCropping;
491
628
  private finishImageCropping;
492
629
  private shouldHandleBrowserCanvasDoubleClick;
@@ -494,12 +631,64 @@ declare class App extends React.Component<AppProps, AppState> {
494
631
  private handleCanvasClick;
495
632
  private getElementLinkAtPosition;
496
633
  private handleElementLinkClick;
497
- private getTopLayerFrameAtSceneCoords;
634
+ /**
635
+ * Applies (or clears) the element-link hover affordances — pointer cursor
636
+ * and tooltip — based on the current `hitLinkElement`. Returns whether a
637
+ * link is being hovered.
638
+ */
639
+ private applyElementLinkHoverAffordance;
640
+ /**
641
+ * On touchscreens (where no hover precedes the tap) re-derives
642
+ * `hitLinkElement`, then opens the hit element link, if any.
643
+ * Returns whether a link click was handled.
644
+ */
645
+ private maybeHandleElementLinkClick;
646
+ /**
647
+ * Restricted pointer handling for the non-interactive editor with links
648
+ * and/or embeds allowed (`interaction.enabled.links` / `.embeds` /
649
+ * `.interactiveContent`) — runs only the element-link & embed concerns
650
+ * (shared with the full pointer handlers above) so they behave like in
651
+ * view mode without the rest of the canvas pointer machinery.
652
+ */
653
+ private handleInteractiveContentPointerMove;
654
+ private handleInteractiveContentPointerUp;
655
+ /**
656
+ * finds candidate frame under cursor (when dragging frame children/elements
657
+ * inside frames)
658
+ */
659
+ getTopLayerFrameAtSceneCoords: (
660
+ /**
661
+ * should be already grid aligned (basically should be what the call site
662
+ * sets the element's coords to, if applicable)
663
+ */
664
+ sceneCoords: {
665
+ x: number;
666
+ y: number;
667
+ }, opts?: {
668
+ /** to exclude selected elements when dragging, etc. */
669
+ excludeElementIds?: AppState["selectedElementIds"];
670
+ currentFrameId?: ExcalidrawElement["frameId"];
671
+ }) => NonDeleted<ExcalidrawFrameLikeElement> | null;
672
+ private updateFrameToHighlight;
673
+ private maybeUpdateFrameToHighlightOnPointerMove;
674
+ insertNewElements: (elements: readonly ExcalidrawElement[]) => void;
675
+ insertNewElement: (element: ExcalidrawElement) => void;
498
676
  private handleCanvasPointerMove;
499
677
  private handleEraser;
500
678
  private handleTouchMove;
679
+ /**
680
+ * Applies the hover affordances of a selected linear element: the cursor,
681
+ * plus the hovered-handle state that renders them highlighted.
682
+ */
501
683
  handleHoverSelectedLinearElement(linearElementEditor: LinearElementEditor, scenePointerX: number, scenePointerY: number): void;
502
684
  private handleCanvasPointerDown;
685
+ /**
686
+ * The browser took the pointer over (scroll, pinch, palm rejection): no
687
+ * pointerup will follow, so the gesture is torn down here and now — the
688
+ * same cleanup a lost pointerup gets at the next press, only not left
689
+ * lying in wait for it, where its replay would tangle with that press.
690
+ */
691
+ private handleCanvasPointerCancel;
503
692
  private handleCanvasPointerUp;
504
693
  private maybeOpenContextMenuAfterPointerDownOnTouchDevices;
505
694
  private resetContextMenuTimer;
@@ -509,8 +698,12 @@ declare class App extends React.Component<AppProps, AppState> {
509
698
  * pointerup handlers manually
510
699
  */
511
700
  private maybeCleanupAfterMissingPointerUp;
512
- handleCanvasPanUsingWheelOrSpaceDrag: (event: React.PointerEvent<HTMLElement> | MouseEvent) => boolean;
513
701
  private updateGestureOnPointerDown;
702
+ /**
703
+ * Tracks the pointer within the ongoing multi-touch gesture and applies
704
+ * the two-finger pinch zoom/pan, if any.
705
+ */
706
+ private updateMultiTouchGesture;
514
707
  private initialPointerDownState;
515
708
  private handleDraggingScrollBar;
516
709
  private clearSelectionIfNotUsingSelection;
@@ -520,7 +713,6 @@ declare class App extends React.Component<AppProps, AppState> {
520
713
  private handleSelectionOnPointerDown;
521
714
  private isASelectedElement;
522
715
  private isHittingCommonBoundingBoxOfSelectedElements;
523
- private handleTextOnPointerDown;
524
716
  private handleFreeDrawElementOnPointerDown;
525
717
  insertIframeElement: ({ sceneX, sceneY, width, height, }: {
526
718
  sceneX: number;
@@ -535,11 +727,14 @@ declare class App extends React.Component<AppProps, AppState> {
535
727
  }) => NonDeleted<ExcalidrawEmbeddableElement> | undefined;
536
728
  private newImagePlaceholder;
537
729
  private handleLinearElementOnPointerDown;
538
- private getCurrentItemRoundness;
730
+ getCurrentItemRoundness(elementType: "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "iframe" | "embeddable"): {
731
+ type: 2 | 3;
732
+ } | null;
733
+ getCurrentItemStrokeWidth(elementType: ExcalidrawElement["type"]): number;
539
734
  private createGenericElementOnPointerDown;
540
735
  private createFrameElementOnPointerDown;
541
- private maybeCacheReferenceSnapPoints;
542
- private maybeCacheVisibleGaps;
736
+ maybeCacheReferenceSnapPoints(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
737
+ maybeCacheVisibleGaps(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
543
738
  private onKeyDownFromPointerDownHandler;
544
739
  private onKeyUpFromPointerDownHandler;
545
740
  private onPointerMoveFromPointerDownHandler;
@@ -566,18 +761,31 @@ declare class App extends React.Component<AppProps, AppState> {
566
761
  private scheduleImageRefresh;
567
762
  private clearSelection;
568
763
  private handleInteractiveCanvasRef;
569
- private insertImages;
764
+ insertImages: (imageFiles: File[], sceneX: number, sceneY: number) => Promise<void>;
570
765
  private handleAppOnDrop;
571
- loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null) => Promise<void>;
766
+ /** @returns true if the file replaced the scene */
767
+ loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null, insertPosition?: {
768
+ clientX: number;
769
+ clientY: number;
770
+ }) => Promise<true | undefined>;
572
771
  private handleCanvasContextMenu;
573
- private maybeDragNewGenericElement;
772
+ /** opens the context menu for the element under the pointer, or the canvas */
773
+ openContextMenu: (pointer: {
774
+ clientX: number;
775
+ clientY: number;
776
+ button?: number;
777
+ pointerType?: string;
778
+ }) => void;
779
+ maybeDragNewGenericElement: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent, informMutation?: boolean) => void;
574
780
  private maybeHandleCrop;
575
781
  private maybeHandleResize;
576
782
  private getContextMenuItems;
577
- private handleWheel;
578
- private getTextWysiwygSnappedToCenterPosition;
579
- private savePointer;
580
- private resetShouldCacheIgnoreZoomDebounced;
783
+ savePointer: (x: number, y: number, button: "up" | "down") => void;
784
+ resetShouldCacheIgnoreZoomDebounced: {
785
+ (): void;
786
+ flush(): void;
787
+ cancel(): void;
788
+ };
581
789
  private updateDOMRect;
582
790
  refresh: () => void;
583
791
  private getCanvasOffsets;
@@ -0,0 +1,55 @@
1
+ import { DrawShapeTrail } from "../drawShapeTrail";
2
+ import type App from "./App";
3
+ import type { PointerDownState } from "../types";
4
+ /**
5
+ * Captures the App state management for the drawShape tool (free-form
6
+ * sketch converted into a recognized excalidraw element). Pointer events
7
+ * are piped here from App.
8
+ *
9
+ * The gesture is committed by `finalize()` — recognize → (maybe upgrade
10
+ * line to arrow) → insert → bind endpoints — which is invoked from within
11
+ * `actionFinalize`, the editor's single finalization funnel. Whatever
12
+ * triggers a finalize (the gesture's own pointerup, a mid-gesture paste
13
+ * switching tools, …), the pending sketch resolves there exactly once.
14
+ */
15
+ export declare class AppDrawShape {
16
+ private app;
17
+ trail: DrawShapeTrail;
18
+ /** a pointerdown started a sketch that `finalize()` hasn't resolved yet */
19
+ private gestureInProgress;
20
+ constructor(app: App);
21
+ stop: () => void;
22
+ hasPendingGesture: () => boolean;
23
+ handlePointerDown: (pointerDownState: PointerDownState) => void;
24
+ /** returns true when the pointermove was consumed by the shape preview */
25
+ handlePointerMove: (pointerCoords: {
26
+ x: number;
27
+ y: number;
28
+ }) => boolean;
29
+ /**
30
+ * Binds both endpoints of a freshly inserted drawShape arrow to the
31
+ * bindable elements they hover, if any.
32
+ *
33
+ * Endpoints bind in "orbit" mode — the arrow starts/ends at the target's
34
+ * outline — even when the stroke was started or released inside the shape
35
+ * (a sketched connector aims at the shape, not at a point inside it). The
36
+ * exception is a sketch contained in a single shape: both ends then bind
37
+ * "inside" and stay where they were drawn, like the interactive
38
+ * inside→inside flow.
39
+ */
40
+ private bindRecognizedArrow;
41
+ /**
42
+ * A sketched line that connects a bindable element with something else —
43
+ * another element or blank canvas — was meant as a connector: upgrade it
44
+ * to an arrow (called before insertion). A line touching no shape, or
45
+ * contained in a single shape (an annotation, not a connector), stays a
46
+ * line.
47
+ */
48
+ private maybeUpgradeLineToArrow;
49
+ /**
50
+ * Commits the pending sketch, if any, and clears the trail. Invoked from
51
+ * within `actionFinalize` — never call directly, execute `actionFinalize`
52
+ * instead so element insertion flows into the action's returned elements.
53
+ */
54
+ finalize: () => void;
55
+ }