@excalidraw/element 0.18.0-2b0e4c9 → 0.18.0-39103bd

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 (173) hide show
  1. package/dist/dev/index.js +5356 -4205
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +15 -14
  4. package/dist/types/common/src/colors.d.ts +1 -1
  5. package/dist/types/common/src/constants.d.ts +11 -7
  6. package/dist/types/common/src/points.d.ts +1 -1
  7. package/dist/types/common/src/utils.d.ts +1 -43
  8. package/dist/types/element/src/Scene.d.ts +6 -4
  9. package/dist/types/element/src/align.d.ts +2 -2
  10. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  11. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  12. package/dist/types/element/src/binding.d.ts +17 -8
  13. package/dist/types/element/src/bounds.d.ts +22 -7
  14. package/dist/types/element/src/collision.d.ts +1 -1
  15. package/dist/types/element/src/comparisons.d.ts +5 -4
  16. package/dist/types/element/src/convertToShape.d.ts +23 -0
  17. package/dist/types/element/src/distribute.d.ts +2 -2
  18. package/dist/types/element/src/dragElements.d.ts +27 -0
  19. package/dist/types/element/src/duplicate.d.ts +4 -3
  20. package/dist/types/element/src/embeddable.d.ts +2 -2
  21. package/dist/types/element/src/flowchart.d.ts +7 -7
  22. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  23. package/dist/types/element/src/frame.d.ts +9 -8
  24. package/dist/types/element/src/groups.d.ts +9 -9
  25. package/dist/types/element/src/index.d.ts +3 -1
  26. package/dist/types/element/src/linearElementEditor.d.ts +17 -10
  27. package/dist/types/element/src/newElement.d.ts +14 -0
  28. package/dist/types/element/src/renderElement.d.ts +0 -3
  29. package/dist/types/element/src/resizeElements.d.ts +2 -2
  30. package/dist/types/element/src/selection.d.ts +11 -7
  31. package/dist/types/element/src/shape.d.ts +1 -1
  32. package/dist/types/element/src/textElement.d.ts +13 -10
  33. package/dist/types/element/src/textWrapping.d.ts +26 -0
  34. package/dist/types/element/src/transform.d.ts +2 -2
  35. package/dist/types/element/src/typeChecks.d.ts +26 -25
  36. package/dist/types/element/src/types.d.ts +8 -1
  37. package/dist/types/element/src/utils.d.ts +1 -1
  38. package/dist/types/element/src/visualdebug.d.ts +1 -2
  39. package/dist/types/element/src/zindex.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +33 -15
  41. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  42. package/dist/types/excalidraw/actions/actionBoundText.d.ts +23 -11
  43. package/dist/types/excalidraw/actions/actionCanvas.d.ts +139 -933
  44. package/dist/types/excalidraw/actions/actionClipboard.d.ts +22 -10
  45. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +11 -5
  46. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +35 -16
  47. package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionDeselect.d.ts} +25 -34
  48. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  49. package/dist/types/excalidraw/actions/actionElementLink.d.ts +11 -5
  50. package/dist/types/excalidraw/actions/actionElementLock.d.ts +23 -11
  51. package/dist/types/excalidraw/actions/actionExport.d.ts +24 -12
  52. package/dist/types/excalidraw/actions/actionFrame.d.ts +45 -199
  53. package/dist/types/excalidraw/actions/actionGroup.d.ts +38 -26
  54. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -7
  55. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -6
  56. package/dist/types/excalidraw/actions/actionMenu.d.ts +11 -5
  57. package/dist/types/excalidraw/actions/actionProperties.d.ts +49 -28
  58. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -10
  59. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -5
  60. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  61. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +12 -6
  62. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +15 -10
  63. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +12 -6
  64. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +12 -6
  65. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +15 -10
  66. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  67. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +12 -6
  68. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -7
  69. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -6
  70. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  71. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  72. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  73. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  74. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  75. package/dist/types/excalidraw/appState.d.ts +7 -5
  76. package/dist/types/excalidraw/components/Actions.d.ts +17 -12
  77. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  78. package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
  79. package/dist/types/excalidraw/components/App.cursor.d.ts +31 -0
  80. package/dist/types/excalidraw/components/App.d.ts +358 -64
  81. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  82. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  83. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  84. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -2
  85. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  86. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  87. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
  88. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  89. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  90. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  91. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  92. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  93. package/dist/types/excalidraw/components/LayerUI.d.ts +4 -2
  94. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  95. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  96. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  97. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  98. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  99. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  100. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  101. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  102. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  103. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  104. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  105. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  106. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  107. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  108. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  109. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  110. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  111. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  112. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  113. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  114. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  115. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  116. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  117. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  118. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  119. package/dist/types/excalidraw/components/Tools.d.ts +145 -0
  120. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -1
  121. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  122. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  123. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  124. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  125. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  126. package/dist/types/excalidraw/components/icons.d.ts +3 -1
  127. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +8 -4
  128. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  129. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  130. package/dist/types/excalidraw/data/blob.d.ts +26 -14
  131. package/dist/types/excalidraw/data/index.d.ts +4 -4
  132. package/dist/types/excalidraw/data/json.d.ts +19 -13
  133. package/dist/types/excalidraw/data/library.d.ts +1 -1
  134. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  135. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  136. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  137. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  138. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  139. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  140. package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
  141. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
  142. package/dist/types/excalidraw/scene/Renderer.d.ts +426 -19
  143. package/dist/types/excalidraw/scene/export.d.ts +3 -3
  144. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  145. package/dist/types/excalidraw/scene/types.d.ts +4 -3
  146. package/dist/types/excalidraw/snapping.d.ts +7 -7
  147. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  148. package/dist/types/excalidraw/types.d.ts +369 -20
  149. package/dist/types/excalidraw/viewport.d.ts +272 -0
  150. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +6 -3
  151. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  152. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  153. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  154. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  155. package/dist/types/laser-pointer/src/state.d.ts +36 -0
  156. package/dist/types/math/src/constants.d.ts +0 -1
  157. package/dist/types/math/src/curve.d.ts +4 -1
  158. package/dist/types/math/src/index.d.ts +1 -0
  159. package/dist/types/math/src/pca.d.ts +79 -0
  160. package/dist/types/math/src/point.d.ts +2 -1
  161. package/dist/types/math/src/polygon.d.ts +25 -1
  162. package/dist/types/utils/src/export.d.ts +3 -3
  163. package/dist/types/utils/src/index.d.ts +1 -2
  164. package/package.json +4 -3
  165. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  166. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  167. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  168. package/dist/types/excalidraw/components/shapes.d.ts +0 -263
  169. package/dist/types/excalidraw/cursor.d.ts +0 -5
  170. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  171. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  172. package/dist/types/utils/src/bbox.d.ts +0 -9
  173. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -1,4 +1,4 @@
1
- export declare const applyDarkModeFilter: (color: string) => string;
1
+ export declare const applyDarkModeFilter: (color: string, enable?: boolean) => string;
2
2
  export type ColorTuple = readonly [string, string, string, string, string];
3
3
  export type ColorPaletteCustom = {
4
4
  [key: string]: ColorTuple | string;
@@ -240,8 +240,7 @@ export declare const DEFAULT_UI_OPTIONS: AppProps["UIOptions"];
240
240
  export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
241
241
  export declare const EXPORT_SCALES: number[];
242
242
  export declare const DEFAULT_EXPORT_PADDING = 10;
243
- export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
244
- export declare const MAX_ALLOWED_FILE_BYTES: number;
243
+ export declare const DEFAULT_IMAGE_OPTIONS: AppProps["imageOptions"];
245
244
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
246
245
  export declare const SVG_DOCUMENT_PREAMBLE = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
247
246
  export declare const ENCRYPTION_KEY_BITS = 128;
@@ -263,6 +262,7 @@ export declare const TEXT_ALIGN: {
263
262
  RIGHT: string;
264
263
  };
265
264
  export declare const ELEMENT_READY_TO_ERASE_OPACITY = 20;
265
+ export declare const ELEMENT_PENDING_DRAW_SHAPE_OPACITY = 70;
266
266
  export declare const DEFAULT_PROPORTIONAL_RADIUS = 0.25;
267
267
  export declare const DEFAULT_ADAPTIVE_RADIUS = 32;
268
268
  export declare const ROUNDNESS: {
@@ -275,11 +275,12 @@ export declare const ROUGHNESS: {
275
275
  readonly artist: 1;
276
276
  readonly cartoonist: 2;
277
277
  };
278
- export declare const STROKE_WIDTH: {
279
- readonly thin: 1;
280
- readonly bold: 2;
281
- readonly extraBold: 4;
282
- };
278
+ export type StrokeWidthKey = "thin" | "medium" | "bold";
279
+ export declare const STROKE_WIDTH_KEYS: readonly StrokeWidthKey[];
280
+ export declare const STROKE_WIDTH: Readonly<Record<StrokeWidthKey | "extraBold", ExcalidrawElement["strokeWidth"]>>;
281
+ export declare const FREEDRAW_STROKE_WIDTH: Readonly<Record<StrokeWidthKey | "extraBold", ExcalidrawElement["strokeWidth"]>>;
282
+ export declare const getStrokeWidthByKey: (elementType: ExcalidrawElement["type"], strokeWidthKey: StrokeWidthKey) => ExcalidrawElement["strokeWidth"];
283
+ export declare const DEFAULT_ELEMENT_STROKE_WIDTH_KEY: StrokeWidthKey;
283
284
  export declare const DEFAULT_ELEMENT_PROPS: {
284
285
  strokeColor: ExcalidrawElement["strokeColor"];
285
286
  backgroundColor: ExcalidrawElement["backgroundColor"];
@@ -314,6 +315,7 @@ export declare const TOOL_TYPE: {
314
315
  readonly magicframe: "magicframe";
315
316
  readonly embeddable: "embeddable";
316
317
  readonly laser: "laser";
318
+ readonly autoshape: "autoshape";
317
319
  };
318
320
  export declare const EDITOR_LS_KEYS: {
319
321
  readonly OAI_API_KEY: "excalidraw-oai-api-key";
@@ -353,3 +355,5 @@ export declare const BIND_MODE_TIMEOUT = 700;
353
355
  export declare const MOBILE_ACTION_BUTTON_BG: {
354
356
  readonly background: "var(--mobile-action-button-bg)";
355
357
  };
358
+ export declare const DEFAULT_STROKE_STREAMLINE = 0.5;
359
+ export declare const DEFAULT_STROKE_STREAMLINE_PRECISE = 0.2;
@@ -6,4 +6,4 @@ export declare const getSizeFromPoints: (points: readonly (GlobalPoint | LocalPo
6
6
  };
7
7
  /** @arg dimension, 0 for rescaling only x, 1 for y */
8
8
  export declare const rescalePoints: <Point extends GlobalPoint | LocalPoint>(dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
9
- export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => [number, number];
9
+ export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => GlobalPoint;
@@ -37,48 +37,6 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void) =>
37
37
  * @returns {number} The tweened value.
38
38
  */
39
39
  export declare const easeOut: (k: number) => number;
40
- /**
41
- * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.
42
- * Executes the `onStep` callback on each step with the interpolated values.
43
- * Returns a function that can be called to cancel the animation.
44
- *
45
- * @example
46
- * // Example usage:
47
- * const fromValues = { x: 0, y: 0 };
48
- * const toValues = { x: 100, y: 200 };
49
- * const onStep = ({x, y}) => {
50
- * setState(x, y)
51
- * };
52
- * const onCancel = () => {
53
- * console.log("Animation canceled");
54
- * };
55
- *
56
- * const cancelAnimation = easeToValuesRAF({
57
- * fromValues,
58
- * toValues,
59
- * onStep,
60
- * onCancel,
61
- * });
62
- *
63
- * // To cancel the animation:
64
- * cancelAnimation();
65
- */
66
- export declare const easeToValuesRAF: <T extends Record<keyof T, number>, K extends keyof T>({ fromValues, toValues, onStep, duration, interpolateValue, onStart, onEnd, onCancel, }: {
67
- fromValues: T;
68
- toValues: T;
69
- /**
70
- * Interpolate a single value.
71
- * Return undefined to be handled by the default interpolator.
72
- */
73
- interpolateValue?: (fromValue: number, toValue: number,
74
- /** no easing applied */
75
- progress: number, key: K) => number | undefined;
76
- onStep: (values: T) => void;
77
- duration?: number;
78
- onStart?: () => void;
79
- onEnd?: () => void;
80
- onCancel?: () => void;
81
- }) => () => void;
82
40
  export declare const chunk: <T extends any>(array: readonly T[], size: number) => T[][];
83
41
  export declare const selectNode: (node: Element) => void;
84
42
  export declare const removeSelection: () => void;
@@ -93,7 +51,7 @@ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">,
93
51
  locked?: boolean;
94
52
  fromSelection?: boolean;
95
53
  }) & {
96
- lastActiveToolBeforeEraser?: ActiveTool | null;
54
+ lastActiveTool?: ActiveTool | null;
97
55
  }) => AppState["activeTool"];
98
56
  export declare const isFullScreen: () => boolean;
99
57
  export declare const allowFullScreen: () => Promise<void>;
@@ -40,7 +40,7 @@ export declare class Scene {
40
40
  elements?: ElementsMapOrArray;
41
41
  includeBoundTextElement?: boolean;
42
42
  includeElementsInFrames?: boolean;
43
- }): NonDeleted<ExcalidrawElement>[];
43
+ }): NonDeletedExcalidrawElement[];
44
44
  getNonDeletedFramesLikes(): readonly NonDeleted<ExcalidrawFrameLikeElement>[];
45
45
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
46
46
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
@@ -63,10 +63,12 @@ export declare class Scene {
63
63
  triggerUpdate(): void;
64
64
  onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover;
65
65
  destroy(): void;
66
- insertElementAtIndex(element: ExcalidrawElement, index: number): void;
67
- insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
66
+ /** low-level - generally use app.insertNewElements() */
67
+ insertElementsAtIndex(elements: ExcalidrawElement[],
68
+ /** null indicates end of the array */
69
+ index: number | null): void;
70
+ /** low-level - generally use app.insertNewElement() */
68
71
  insertElement: (element: ExcalidrawElement) => void;
69
- insertElements: (elements: ExcalidrawElement[]) => void;
70
72
  getElementIndex(elementId: string): number;
71
73
  getContainerElement: (element: (ExcalidrawElement & {
72
74
  containerId: ExcalidrawElement["id"] | null;
@@ -1,8 +1,8 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { Scene } from "./Scene";
3
- import type { ExcalidrawElement } from "./types";
3
+ import type { NonDeletedExcalidrawElement } from "./types";
4
4
  export interface Alignment {
5
5
  position: "start" | "center" | "end";
6
6
  axis: "x" | "y";
7
7
  }
8
- export declare const alignElements: (selectedElements: ExcalidrawElement[], alignment: Alignment, scene: Scene, appState: Readonly<AppState>) => ExcalidrawElement[];
8
+ export declare const alignElements: (selectedElements: NonDeletedExcalidrawElement[], alignment: Alignment, scene: Scene, appState: Readonly<AppState>) => NonDeletedExcalidrawElement[];
@@ -0,0 +1,49 @@
1
+ import type { GlobalPoint } from "@excalidraw/math";
2
+ import type { AppState } from "@excalidraw/excalidraw/types";
3
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawTextElement, FixedPoint, NonDeleted, NonDeletedExcalidrawElement, TextAlign, VerticalAlign } from "./types";
4
+ export type ArrowEndpoint = {
5
+ arrow: NonDeleted<ExcalidrawArrowElement>;
6
+ startOrEnd: "start" | "end";
7
+ };
8
+ /**
9
+ * Finds a free (unbound) arrow endpoint under the cursor, front-most first.
10
+ * Used by the text tool to offer creating a text label anchored to the tip of
11
+ * an arrow.
12
+ */
13
+ export declare const getUnboundArrowEndpointAtPoint: (scenePointer: GlobalPoint, elements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, zoom: AppState["zoom"]) => ArrowEndpoint | null;
14
+ /**
15
+ * Describes how a text element should be created so that it reads as a label
16
+ * for the given arrow endpoint.
17
+ *
18
+ * The arrow is treated as fixed: rather than routing the arrow to the text, we
19
+ * pick the side of the text the arrow should attach to (the one it already
20
+ * points at), and place the text so that side's midpoint lands on the existing
21
+ * endpoint. The alignment returned pins that same midpoint while the text is
22
+ * typed, so the arrow doesn't swing around during editing.
23
+ */
24
+ export declare const getTextBindingForArrowEndpoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap,
25
+ /**
26
+ * stroke width the text will be created with — the binding gap is derived
27
+ * from the *bind target*, so using the arrow's would offset the anchor by
28
+ * half the difference between the two
29
+ */
30
+ targetStrokeWidth: number) => {
31
+ /** the text-local ratio the arrow binds to (a side midpoint) */
32
+ fixedPoint: FixedPoint;
33
+ textAlign: TextAlign;
34
+ verticalAlign: VerticalAlign;
35
+ /** scene position the text's bound side midpoint should sit at */
36
+ anchor: GlobalPoint;
37
+ } | null;
38
+ /**
39
+ * Whether an arrow endpoint is bound to this text — i.e. the text serves as an
40
+ * arrow-endpoint label. Checked on the arrows' own bindings: the text's
41
+ * `boundElements` only says an arrow relates to it, while the binding on the
42
+ * arrow is the authoritative side of the relationship.
43
+ */
44
+ export declare const isEndpointBoundText: (text: ExcalidrawTextElement, elementsMap: ElementsMap) => boolean;
45
+ /** the anchor a text bound to an arrow endpoint grows away from */
46
+ export declare const getEndpointBoundTextDragAnchor: (newElement: ExcalidrawTextElement) => {
47
+ anchorRatio: number;
48
+ anchorX: number;
49
+ };
@@ -1,7 +1,7 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { AppState, NullableGridSize } from "@excalidraw/excalidraw/types";
3
3
  import { LinearElementEditor } from "../linearElementEditor";
4
- import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, NonDeletedSceneElementsMap } from "../types";
4
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, FixedPointBinding, NonDeletedSceneElementsMap } from "../types";
5
5
  import type { Scene } from "../Scene";
6
6
  export declare const isFocusPointVisible: (focusPoint: GlobalPoint, arrow: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, appState: {
7
7
  isBindingEnabled: AppState["isBindingEnabled"];
@@ -22,6 +22,9 @@ export declare const handleFocusPointPointerDown: (arrow: ExcalidrawArrowElement
22
22
  x: number;
23
23
  y: number;
24
24
  };
25
+ arrowOtherEndpointInitialBinding: FixedPointBinding | null;
26
+ };
27
+ export declare const handleFocusPointPointerUp: (linearElementEditor: LinearElementEditor, scene: Scene) => {
28
+ arrowOtherEndpointInitialBinding: null;
25
29
  };
26
- export declare const handleFocusPointPointerUp: (linearElementEditor: LinearElementEditor, scene: Scene) => void;
27
30
  export declare const handleFocusPointHover: (arrow: ExcalidrawArrowElement, scenePointerX: number, scenePointerY: number, scene: Scene, appState: AppState) => "start" | "end" | null;
@@ -1,6 +1,6 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { LineSegment, LocalPoint } from "@excalidraw/math";
3
- import type { AppState } from "@excalidraw/excalidraw/types";
3
+ import type { AppState, NullableGridSize } from "@excalidraw/excalidraw/types";
4
4
  import type { Bounds } from "@excalidraw/common";
5
5
  import { type Heading } from "./heading";
6
6
  import type { Scene } from "./Scene";
@@ -28,7 +28,7 @@ export declare const BASE_BINDING_GAP = 5;
28
28
  export declare const BASE_BINDING_GAP_ELBOW = 5;
29
29
  export declare const BASE_ARROW_MIN_LENGTH = 10;
30
30
  export declare const FOCUS_POINT_SIZE: number;
31
- export declare const getBindingGap: (bindTarget: ExcalidrawBindableElement, opts: Pick<ExcalidrawArrowElement, "elbowed">) => number;
31
+ export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">, opts: Pick<ExcalidrawArrowElement, "elbowed">) => number;
32
32
  export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
33
33
  export declare const isBindingEnabled: (appState: {
34
34
  isBindingEnabled: AppState["isBindingEnabled"];
@@ -38,6 +38,7 @@ export declare const bindOrUnbindBindingElement: (arrow: NonDeleted<ExcalidrawAr
38
38
  altKey?: boolean;
39
39
  angleLocked?: boolean;
40
40
  initialBinding?: boolean;
41
+ gridSize?: NullableGridSize;
41
42
  }) => {
42
43
  start: BindingStrategy;
43
44
  end: BindingStrategy;
@@ -49,19 +50,20 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
49
50
  finalize?: boolean;
50
51
  initialBinding?: boolean;
51
52
  zoom?: AppState["zoom"];
53
+ gridSize?: NullableGridSize;
52
54
  }) => {
53
55
  start: BindingStrategy;
54
56
  end: BindingStrategy;
55
57
  };
56
58
  export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
57
- export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean) => void;
58
- export declare const unbindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
59
+ export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
60
+ export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
59
61
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
60
- simultaneouslyUpdated?: readonly ExcalidrawElement[];
62
+ simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
61
63
  changedElements?: Map<string, ExcalidrawElement>;
62
64
  }) => void;
63
- export declare const updateBindings: (latestElement: ExcalidrawElement, scene: Scene, appState: AppState, options?: {
64
- simultaneouslyUpdated?: readonly ExcalidrawElement[];
65
+ export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, options?: {
66
+ simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
65
67
  newSize?: {
66
68
  width: number;
67
69
  height: number;
@@ -75,7 +77,7 @@ export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement
75
77
  export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
76
78
  fixedPoint: FixedPoint;
77
79
  };
78
- export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
80
+ export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
79
81
  fixedPoint: FixedPoint;
80
82
  };
81
83
  export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
@@ -127,3 +129,10 @@ export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowEleme
127
129
  export declare const isFixedPoint: (fixedPoint: any) => fixedPoint is FixedPointBinding["fixedPoint"];
128
130
  export declare const normalizeFixedPoint: <T extends FixedPoint>(fixedPoint: T) => FixedPoint;
129
131
  export declare const getBindingSideMidPoint: (binding: FixedPointBinding, elementsMap: ElementsMap) => GlobalPoint | LocalPoint | null;
132
+ /**
133
+ * Binds an arrow endpoint to an explicit fixed point on a bindable element,
134
+ * bypassing the "derive the ratio from where the endpoint currently is"
135
+ * strategy used when dragging. Needed when the binding target is placed to fit
136
+ * the arrow rather than the other way round.
137
+ */
138
+ export declare const bindBindingElementToFixedPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, bindableElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", fixedPoint: FixedPoint, scene: Scene) => void;
@@ -2,7 +2,7 @@ import { type Bounds } from "@excalidraw/common";
2
2
  import type { Degrees, GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
3
3
  import type { AppState } from "@excalidraw/excalidraw/types";
4
4
  import type { Drawable, Op } from "roughjs/bin/core";
5
- import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
5
+ import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
6
6
  export type RectangleBox = {
7
7
  x: number;
8
8
  y: number;
@@ -38,7 +38,7 @@ export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBo
38
38
  export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
39
39
  export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
40
40
  export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: (p: GlobalPoint) => GlobalPoint) => Bounds;
41
- export declare const getBoundsFromPoints: (points: ExcalidrawFreeDrawElement["points"]) => Bounds;
41
+ export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
42
42
  /** @returns number in pixels */
43
43
  export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
44
44
  /** @returns number in degrees */
@@ -46,16 +46,12 @@ export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
46
46
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, offsetMultiplier?: number) => number[] | null;
47
47
  export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
48
48
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
49
- export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
49
+ export declare const getDraggedElementsBounds: (elements: readonly NonDeletedExcalidrawElement[], dragOffset: {
50
50
  x: number;
51
51
  y: number;
52
52
  }) => number[];
53
53
  export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => Bounds;
54
54
  export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => Bounds;
55
- export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
56
- x: number;
57
- y: number;
58
- }) => Bounds;
59
55
  export interface BoundingBox {
60
56
  minX: number;
61
57
  minY: number;
@@ -77,5 +73,24 @@ export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
77
73
  */
78
74
  export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
79
75
  export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
76
+ export declare const pointInsideBoundsInclusive: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
80
77
  export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
78
+ export declare const boundsContainBounds: (outerBounds: Bounds, innerBounds: Bounds) => boolean;
79
+ /**
80
+ * High level helper to get elements overlapping a bounding box.
81
+ * It can be used to get elements overlapping a selection box, for example.
82
+ *
83
+ */
84
+ export declare const elementsOverlappingBBox: <T extends ExcalidrawElement>({ elements, elementsMap, bounds, type, excludeElementsInFrames, shouldIgnoreElementFromSelection, }: {
85
+ elements: readonly T[];
86
+ elementsMap?: ElementsMap;
87
+ bounds: Bounds | ExcalidrawElement;
88
+ /**
89
+ * - overlap: elements overlapping or inside bounds
90
+ * - contain: elements inside bounds
91
+ **/
92
+ type: "contain" | "overlap";
93
+ excludeElementsInFrames?: boolean;
94
+ shouldIgnoreElementFromSelection?: (element: T) => boolean;
95
+ }) => T[];
81
96
  export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
@@ -16,7 +16,7 @@ export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsM
16
16
  export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
17
17
  export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement>[];
18
18
  export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
19
- export declare const getHoveredElementForFocusPoint: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => ExcalidrawBindableElement | null;
19
+ export declare const getHoveredElementForFocusPoint: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
20
20
  /**
21
21
  * Intersect a line with an element for binding test
22
22
  *
@@ -1,8 +1,9 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
- export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw";
4
- export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
5
- export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe";
2
+ export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
3
+ export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
4
+ export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
5
+ export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
6
+ export declare const hasFreedrawMode: (type: ElementOrToolType) => type is "freedraw";
6
7
  export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "embeddable" | "iframe" | "image";
7
8
  export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
8
9
  export declare const canHaveArrowheads: (type: ElementOrToolType) => type is "arrow";
@@ -0,0 +1,23 @@
1
+ import type { App, AppState } from "@excalidraw/excalidraw/types";
2
+ import type { LocalPoint, GlobalPoint } from "@excalidraw/math";
3
+ import type { Bounds } from "@excalidraw/common";
4
+ import type { ExcalidrawArrowElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, ExcalidrawRectangleElement, ElementsMap, NonDeleted, ExcalidrawLineElement } from "@excalidraw/element/types";
5
+ declare global {
6
+ interface Window {
7
+ LAST_POINTS?: readonly GlobalPoint[];
8
+ }
9
+ }
10
+ type NonDeletedRecognizedShapeElement = NonDeleted<ExcalidrawRectangleElement | ExcalidrawEllipseElement | ExcalidrawDiamondElement | ExcalidrawArrowElement | ExcalidrawLineElement | ExcalidrawFreeDrawElement>;
11
+ type Shape = NonDeletedRecognizedShapeElement["type"];
12
+ interface ShapeRecognitionResult<P extends LocalPoint | GlobalPoint> {
13
+ type: Shape;
14
+ points: readonly P[];
15
+ boundingBox: Bounds;
16
+ }
17
+ export declare const recognizeShape: <P extends LocalPoint | GlobalPoint>(points: P[], previousElement: ExcalidrawElement | null, zoom?: number) => ShapeRecognitionResult<P>;
18
+ export declare const convertToShape: (points: GlobalPoint[], appState: AppState, elementsMap: ElementsMap, previousElement: ExcalidrawElement | null, frames?: readonly ExcalidrawFrameLikeElement[]) => NonDeletedRecognizedShapeElement | undefined;
19
+ export declare const convertToShapeHandlePointerMoveFromPointerDown: (app: App, pointerCoords: {
20
+ x: number;
21
+ y: number;
22
+ }) => boolean;
23
+ export {};
@@ -1,8 +1,8 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { Scene } from "./Scene";
3
- import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
4
4
  export interface Distribution {
5
5
  space: "between";
6
6
  axis: "x" | "y";
7
7
  }
8
- export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => ExcalidrawElement[];
8
+ export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => NonDeletedExcalidrawElement[];
@@ -1,6 +1,7 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  import type { Scene } from "./Scene";
4
+ import type { ExcalidrawTextElement } from "./types";
4
5
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
5
6
  x: number;
6
7
  y: number;
@@ -9,6 +10,32 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
9
10
  y: number;
10
11
  }, gridSize: NullableGridSize) => void;
11
12
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
13
+ /**
14
+ * Sizes a text element as it is dragged out.
15
+ *
16
+ * A dragged text pins one point and grows away from it; `anchorRatio` says
17
+ * where along the box that point sits — 0 for its left edge, 1 for its right,
18
+ * 0.5 for its centre.
19
+ *
20
+ * A free text pins the point the drag started from and takes the ratio from
21
+ * the drag direction, so it can be pulled either way. A text bound to an arrow
22
+ * endpoint instead pins whatever the binding placed it against and takes the
23
+ * ratio from its alignment — which is also what keeps it from growing back
24
+ * over the arrow, since dragging that way makes no progress rather than
25
+ * flipping the box around.
26
+ */
27
+ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, informMutation, }: {
28
+ newElement: ExcalidrawTextElement;
29
+ anchorX: number;
30
+ /** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
31
+ anchorRatio: number;
32
+ pointerX: number;
33
+ /** free text re-tops itself to the drag origin; a bound one must not move */
34
+ nextY?: number;
35
+ zoom: NormalizedZoomValue;
36
+ scene: Scene;
37
+ informMutation?: boolean;
38
+ }) => void;
12
39
  export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
13
40
  newElement: NonDeletedExcalidrawElement;
14
41
  elementType: AppState["activeTool"]["type"];
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { AppState } from "@excalidraw/excalidraw/types";
3
- import type { ExcalidrawElement, GroupId } from "./types";
3
+ import type { ExcalidrawElement, GroupId, NonDeletedExcalidrawElement } from "./types";
4
4
  /**
5
5
  * Duplicate an element, often used in the alt-drag operation.
6
6
  * Note that this method has gotten a bit complicated since the
@@ -31,6 +31,7 @@ export declare const duplicateElements: (opts: {
31
31
  * user interaction.
32
32
  */
33
33
  type: "everything";
34
+ preserveFrameChildrenOrder?: boolean;
34
35
  } | {
35
36
  /**
36
37
  * Duplicates specified elements and inserts them back into the array
@@ -46,8 +47,8 @@ export declare const duplicateElements: (opts: {
46
47
  selectedGroupIds: AppState["selectedGroupIds"];
47
48
  };
48
49
  })) => {
49
- duplicatedElements: ExcalidrawElement[];
50
- duplicateElementsMap: Map<string, ExcalidrawElement>;
50
+ duplicatedElements: NonDeletedExcalidrawElement[];
51
+ duplicateElementsMap: Map<string, NonDeletedExcalidrawElement>;
51
52
  elementsWithDuplicates: ExcalidrawElement[];
52
53
  origIdToDuplicateId: Map<string, string>;
53
54
  };
@@ -1,10 +1,10 @@
1
1
  import type { ExcalidrawProps } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkRequired } from "@excalidraw/common/utility-types";
3
- import type { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
3
+ import type { ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
4
4
  type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
5
5
  export declare const createSrcDoc: (body: string) => string;
6
6
  export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
7
- export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => ExcalidrawElement;
7
+ export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => NonDeletedExcalidrawElement;
8
8
  export declare const maybeParseEmbedSrc: (str: string) => string;
9
9
  export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
10
10
  export {};
@@ -1,10 +1,7 @@
1
1
  import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
- import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
2
+ import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
3
3
  import type { Scene } from "./Scene";
4
- type LinkDirection = "up" | "right" | "down" | "left";
5
- export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
6
- export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
7
- export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number) => ExcalidrawElement[];
4
+ export type LinkDirection = "up" | "right" | "down" | "left";
8
5
  export declare class FlowChartNavigator {
9
6
  isExploring: boolean;
10
7
  private sameLevelNodes;
@@ -13,14 +10,17 @@ export declare class FlowChartNavigator {
13
10
  private visitedNodes;
14
11
  clear(): void;
15
12
  exploreByDirection(element: ExcalidrawElement, elementsMap: ElementsMap, direction: LinkDirection): ExcalidrawElement["id"] | null;
13
+ private static getNodeRelatives;
14
+ private static getSuccessors;
15
+ private static getPredecessors;
16
16
  }
17
17
  export declare class FlowChartCreator {
18
18
  isCreatingChart: boolean;
19
19
  private numberOfNodes;
20
20
  private direction;
21
+ private clusterCrossStart;
21
22
  pendingNodes: PendingExcalidrawElements | null;
22
- createNodes(startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene): void;
23
+ createNodes(startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene): void;
23
24
  clear(): void;
24
25
  }
25
26
  export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
26
- export {};
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -48,7 +48,7 @@ export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[],
48
48
  *
49
49
  * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
50
50
  */
51
- export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
51
+ export declare const syncInvalidIndices: <T extends ExcalidrawElement>(elements: readonly T[]) => Ordered<T>[];
52
52
  /**
53
53
  * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
54
  *
@@ -29,24 +29,25 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
29
29
  *
30
30
  * Considers non-frame bound elements (container or arrow labels) as root.
31
31
  */
32
- export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
32
+ export declare const getRootElements: <T extends ExcalidrawElement>(allElements: readonly T[]) => T[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
34
  export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
35
  export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
37
  /** */
38
38
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
39
+ export declare const getCommonFrameId: (elements: readonly ExcalidrawElement[]) => string | null;
40
+ export declare const getFrameChildrenInsertionIndex: (elements: readonly ExcalidrawElement[], frameId: ExcalidrawFrameLikeElement["id"]) => number | null;
39
41
  /**
40
- * Retains (or repairs for target frame) the ordering invriant where children
41
- * elements come right before the parent frame:
42
- * [el, el, child, child, frame, el]
42
+ * Adds elements and their bound elements to frame. Reorders added elements to
43
+ * be just below frame, or just above its highest child (whichever is higher).
43
44
  *
44
45
  * @returns mutated allElements (same data structure)
45
46
  */
46
- export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement, appState: AppState) => T;
47
- export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<NonDeletedExcalidrawElement>, elementsMap: ElementsMap) => void;
47
+ export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
48
+ export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<ExcalidrawElement>, elementsMap: ElementsMap) => void;
48
49
  export declare const removeAllElementsFromFrame: <T extends ExcalidrawElement>(allElements: readonly T[], frame: ExcalidrawFrameLikeElement) => readonly T[];
49
- export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, app: AppClassProperties) => T[];
50
+ export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T[];
50
51
  /** does not mutate elements, but returns new ones */
51
52
  export declare const updateFrameMembershipOfSelectedElements: <T extends ElementsMapOrArray>(allElements: T, appState: AppState, app: AppClassProperties) => T;
52
53
  /**
@@ -70,5 +71,5 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
70
71
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
71
72
  export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
72
73
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
73
- export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
74
+ export declare const getElementsOverlappingFrame: <T extends ExcalidrawElement>(elements: readonly T[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => T[];
74
75
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;