@excalidraw/common 0.18.0-4e471c107 → 0.18.0-51ad895

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 (115) hide show
  1. package/dist/dev/index.js +329 -46
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/constants.d.ts +21 -15
  5. package/dist/types/common/src/editorInterface.d.ts +34 -0
  6. package/dist/types/common/src/index.d.ts +2 -0
  7. package/dist/types/common/src/utils.d.ts +9 -3
  8. package/dist/types/common/src/visualdebug.d.ts +41 -0
  9. package/dist/types/element/src/Scene.d.ts +6 -2
  10. package/dist/types/element/src/align.d.ts +2 -1
  11. package/dist/types/element/src/binding.d.ts +55 -43
  12. package/dist/types/element/src/bounds.d.ts +1 -1
  13. package/dist/types/element/src/collision.d.ts +6 -2
  14. package/dist/types/element/src/delta.d.ts +16 -4
  15. package/dist/types/element/src/distribute.d.ts +2 -1
  16. package/dist/types/element/src/groups.d.ts +1 -0
  17. package/dist/types/element/src/index.d.ts +1 -3
  18. package/dist/types/element/src/linearElementEditor.d.ts +17 -19
  19. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  20. package/dist/types/element/src/renderElement.d.ts +5 -2
  21. package/dist/types/element/src/resizeTest.d.ts +5 -4
  22. package/dist/types/element/src/store.d.ts +6 -1
  23. package/dist/types/element/src/textElement.d.ts +1 -1
  24. package/dist/types/element/src/transformHandles.d.ts +5 -4
  25. package/dist/types/element/src/typeChecks.d.ts +2 -3
  26. package/dist/types/element/src/types.d.ts +7 -11
  27. package/dist/types/element/src/utils.d.ts +2 -1
  28. package/dist/types/element/src/zindex.d.ts +7 -1
  29. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +34 -16
  30. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  31. package/dist/types/excalidraw/actions/actionBoundText.d.ts +25 -13
  32. package/dist/types/excalidraw/actions/actionCanvas.d.ts +153 -275
  33. package/dist/types/excalidraw/actions/actionClipboard.d.ts +45 -777
  34. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -6
  35. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +45 -29
  36. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  37. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  38. package/dist/types/excalidraw/actions/actionElementLink.d.ts +11 -7
  39. package/dist/types/excalidraw/actions/actionElementLock.d.ts +23 -11
  40. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -6
  41. package/dist/types/excalidraw/actions/actionExport.d.ts +68 -952
  42. package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
  43. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -2
  44. package/dist/types/excalidraw/actions/actionFrame.d.ts +50 -28
  45. package/dist/types/excalidraw/actions/actionGroup.d.ts +24 -12
  46. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +47 -14
  47. package/dist/types/excalidraw/actions/actionLink.d.ts +9 -3
  48. package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -374
  49. package/dist/types/excalidraw/actions/actionNavigate.d.ts +21 -361
  50. package/dist/types/excalidraw/actions/actionProperties.d.ts +87 -2418
  51. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -6
  52. package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -7
  53. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  54. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +11 -5
  55. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +11 -5
  56. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -6
  57. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  58. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +11 -5
  59. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +11 -5
  60. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -6
  61. package/dist/types/excalidraw/actions/actionZindex.d.ts +2 -2
  62. package/dist/types/excalidraw/actions/index.d.ts +2 -2
  63. package/dist/types/excalidraw/actions/manager.d.ts +1 -1
  64. package/dist/types/excalidraw/actions/register.d.ts +1 -1
  65. package/dist/types/excalidraw/actions/types.d.ts +4 -4
  66. package/dist/types/excalidraw/appState.d.ts +9 -4
  67. package/dist/types/excalidraw/clipboard.d.ts +64 -1
  68. package/dist/types/excalidraw/components/Actions.d.ts +20 -7
  69. package/dist/types/excalidraw/components/App.d.ts +35 -25
  70. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  71. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  72. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  73. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  74. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -2
  75. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  76. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  77. package/dist/types/excalidraw/components/FilledButton.d.ts +1 -1
  78. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  79. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  80. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  81. package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
  82. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  83. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  84. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
  85. package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
  86. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  87. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  88. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  89. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  90. package/dist/types/excalidraw/components/TextField.d.ts +1 -0
  91. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  92. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +6 -3
  93. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  94. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  95. package/dist/types/excalidraw/components/icons.d.ts +10 -0
  96. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
  97. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
  98. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  99. package/dist/types/excalidraw/data/blob.d.ts +3 -7
  100. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  101. package/dist/types/excalidraw/data/restore.d.ts +7 -2
  102. package/dist/types/excalidraw/data/types.d.ts +4 -1
  103. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  104. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
  105. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  106. package/dist/types/excalidraw/index.d.ts +4 -4
  107. package/dist/types/excalidraw/renderer/animation.d.ts +12 -0
  108. package/dist/types/excalidraw/renderer/helpers.d.ts +2 -6
  109. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +5 -13
  110. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  111. package/dist/types/excalidraw/scene/types.d.ts +15 -3
  112. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  113. package/dist/types/excalidraw/types.d.ts +37 -24
  114. package/dist/types/math/src/segment.d.ts +1 -0
  115. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { GlobalPoint, LineSegment } from "@excalidraw/math";
2
2
  import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
3
- import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered } from "./types";
4
4
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
5
5
  export type HitTestArgs = {
6
6
  point: GlobalPoint;
@@ -8,11 +8,14 @@ export type HitTestArgs = {
8
8
  threshold: number;
9
9
  elementsMap: ElementsMap;
10
10
  frameNameBound?: FrameNameBounds | null;
11
+ overrideShouldTestInside?: boolean;
11
12
  };
12
- export declare const hitElementItself: ({ point, element, threshold, elementsMap, frameNameBound, }: HitTestArgs) => boolean;
13
+ export declare const hitElementItself: ({ point, element, threshold, elementsMap, frameNameBound, overrideShouldTestInside, }: HitTestArgs) => boolean;
13
14
  export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
14
15
  export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
15
16
  export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
17
+ export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, toleranceFn?: ((element: ExcalidrawBindableElement) => number) | undefined) => NonDeleted<ExcalidrawBindableElement>[];
18
+ export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, toleranceFn?: ((element: ExcalidrawBindableElement) => number) | undefined) => NonDeleted<ExcalidrawBindableElement> | null;
16
19
  /**
17
20
  * Intersect a line with an element for binding test
18
21
  *
@@ -30,3 +33,4 @@ export declare const intersectElementWithLineSegment: (element: ExcalidrawElemen
30
33
  * @returns
31
34
  */
32
35
  export declare const isPointInElement: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
36
+ export declare const isBindableElementInsideOtherBindable: (innerElement: ExcalidrawBindableElement, outerElement: ExcalidrawBindableElement, elementsMap: ElementsMap) => boolean;
@@ -29,12 +29,16 @@ export declare class Delta<T> {
29
29
  }>(prevObject: T, nextObject: T, modifier?: (partial: Partial<T>) => Partial<T>, postProcess?: (deleted: Partial<T>, inserted: Partial<T>) => [Partial<T>, Partial<T>]): Delta<T>;
30
30
  static empty(): Delta<unknown>;
31
31
  static isEmpty<T>(delta: Delta<T>): boolean;
32
+ /**
33
+ * Merges two deltas into a new one.
34
+ */
35
+ static merge<T>(delta1: Delta<T>, delta2: Delta<T>, delta3?: Delta<T>): Delta<T>;
32
36
  /**
33
37
  * Merges deleted and inserted object partials.
34
38
  */
35
39
  static mergeObjects<T extends {
36
40
  [key: string]: unknown;
37
- }>(prev: T, added: T, removed: T): T;
41
+ }>(prev: T, added: T, removed?: T): T;
38
42
  /**
39
43
  * Merges deleted and inserted array partials.
40
44
  */
@@ -102,18 +106,24 @@ export interface DeltaContainer<T> {
102
106
  * @returns a tuple of the next object `T` with applied `Delta`s, and `boolean`, indicating whether the applied deltas resulted in a visible change.
103
107
  */
104
108
  applyTo(previous: T, ...options: unknown[]): [T, boolean];
109
+ /**
110
+ * Squashes the current delta with the given one.
111
+ */
112
+ squash(delta: DeltaContainer<T>): this;
105
113
  /**
106
114
  * Checks whether all `Delta`s are empty.
107
115
  */
108
116
  isEmpty(): boolean;
109
117
  }
110
118
  export declare class AppStateDelta implements DeltaContainer<AppState> {
111
- readonly delta: Delta<ObservedAppState>;
119
+ delta: Delta<ObservedAppState>;
112
120
  private constructor();
121
+ static create(delta: Delta<ObservedAppState>): AppStateDelta;
113
122
  static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
114
123
  static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
115
124
  static empty(): AppStateDelta;
116
125
  inverse(): AppStateDelta;
126
+ squash(delta: AppStateDelta): this;
117
127
  applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
118
128
  isEmpty(): boolean;
119
129
  /**
@@ -122,7 +132,6 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
122
132
  * @returns `true` if a visible change is found, `false` otherwise.
123
133
  */
124
134
  private filterInvisibleChanges;
125
- private static convertToAppStateKey;
126
135
  private static filterSelectedElements;
127
136
  private static filterSelectedGroups;
128
137
  private static stripElementsProps;
@@ -136,7 +145,7 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
136
145
  }
137
146
  type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
138
147
  export type ApplyToOptions = {
139
- excludedProperties: Set<keyof ElementPartial>;
148
+ excludedProperties?: Set<keyof ElementPartial>;
140
149
  };
141
150
  /**
142
151
  * Elements change is a low level primitive to capture a change between two sets of elements.
@@ -155,6 +164,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
155
164
  private static satisfiesRemoval;
156
165
  private static satisfiesUpdate;
157
166
  private static satisfiesCommmonInvariants;
167
+ private static satisfiesUniqueInvariants;
158
168
  private static validate;
159
169
  /**
160
170
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -177,6 +187,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
177
187
  */
178
188
  applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
179
189
  applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
190
+ squash(delta: ElementsDelta): this;
180
191
  private static createApplier;
181
192
  private static createGetter;
182
193
  private static applyDelta;
@@ -203,6 +214,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
203
214
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
204
215
  */
205
216
  private static rebindAffected;
217
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
206
218
  private static redrawTextBoundingBoxes;
207
219
  private static redrawBoundArrows;
208
220
  private static reorderElements;
@@ -1,6 +1,7 @@
1
+ import type { AppState } from "@excalidraw/excalidraw/types";
1
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
2
3
  export interface Distribution {
3
4
  space: "between";
4
5
  axis: "x" | "y";
5
6
  }
6
- export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution) => ExcalidrawElement[];
7
+ export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>) => ExcalidrawElement[];
@@ -31,3 +31,4 @@ export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<strin
31
31
  export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
32
32
  export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
33
33
  export declare const getNewGroupIdsForDuplication: (groupIds: ExcalidrawElement["groupIds"], editingGroupId: AppState["editingGroupId"], mapper: (groupId: GroupId) => GroupId) => string[];
34
+ export declare const getSelectedElementsByGroup: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<AppState>) => ExcalidrawElement[][];
@@ -11,9 +11,6 @@ export declare const hashString: (s: string) => number;
11
11
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
12
12
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
13
13
  export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
14
- export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
15
- export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
16
- export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
17
14
  export * from "./align";
18
15
  export * from "./binding";
19
16
  export * from "./bounds";
@@ -38,6 +35,7 @@ export * from "./image";
38
35
  export * from "./linearElementEditor";
39
36
  export * from "./mutateElement";
40
37
  export * from "./newElement";
38
+ export * from "./positionElementsOnGrid";
41
39
  export * from "./renderElement";
42
40
  export * from "./resizeElements";
43
41
  export * from "./resizeTest";
@@ -4,42 +4,41 @@ import { type Store } from "@excalidraw/element";
4
4
  import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
5
5
  import type { Scene } from "./Scene";
6
6
  import type { Bounds } from "./bounds";
7
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
7
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, FixedPointBinding, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
8
8
  export declare class LinearElementEditor {
9
9
  readonly elementId: ExcalidrawElement["id"] & {
10
10
  _brand: "excalidrawLinearElementId";
11
11
  };
12
12
  /** indices */
13
13
  readonly selectedPointsIndices: readonly number[] | null;
14
- readonly pointerDownState: Readonly<{
14
+ readonly initialState: Readonly<{
15
15
  prevSelectedPointsIndices: readonly number[] | null;
16
16
  /** index */
17
17
  lastClickedPoint: number;
18
- lastClickedIsEndPoint: boolean;
19
- origin: Readonly<{
20
- x: number;
21
- y: number;
22
- }> | null;
18
+ origin: Readonly<GlobalPoint> | null;
23
19
  segmentMidpoint: {
24
20
  value: GlobalPoint | null;
25
21
  index: number | null;
26
22
  added: boolean;
27
23
  };
24
+ arrowStartIsInside: boolean;
25
+ altFocusPoint: Readonly<GlobalPoint> | null;
28
26
  }>;
29
27
  /** whether you're dragging a point */
30
28
  readonly isDragging: boolean;
31
29
  readonly lastUncommittedPoint: LocalPoint | null;
30
+ readonly lastCommittedPoint: LocalPoint | null;
32
31
  readonly pointerOffset: Readonly<{
33
32
  x: number;
34
33
  y: number;
35
34
  }>;
36
- readonly startBindingElement: ExcalidrawBindableElement | null | "keep";
37
- readonly endBindingElement: ExcalidrawBindableElement | null | "keep";
38
35
  readonly hoverPointIndex: number;
39
36
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
40
37
  readonly elbowed: boolean;
41
38
  readonly customLineAngle: number | null;
42
- constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap);
39
+ readonly isEditing: boolean;
40
+ readonly pointerDownState: never;
41
+ constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, isEditing?: boolean);
43
42
  static POINT_HANDLE_SIZE: number;
44
43
  /**
45
44
  * @param id the `elementId` from the instance of this class (so that we can
@@ -47,10 +46,8 @@ export declare class LinearElementEditor {
47
46
  */
48
47
  static getElement<T extends ExcalidrawLinearElement>(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): T | null;
49
48
  static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"], elementsMap: NonDeletedSceneElementsMap): false | undefined;
50
- /**
51
- * @returns whether point was dragged
52
- */
53
- static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, keyof AppState> | null;
49
+ static handlePointerMove(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null;
50
+ static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null;
54
51
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
55
52
  static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
56
53
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
@@ -69,7 +66,7 @@ export declare class LinearElementEditor {
69
66
  linearElementEditor: LinearElementEditor | null;
70
67
  };
71
68
  static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
72
- static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
69
+ static handlePointerMoveInEditMode(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
73
70
  /** scene coords */
74
71
  static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
75
72
  /** scene coords */
@@ -95,12 +92,13 @@ export declare class LinearElementEditor {
95
92
  static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
96
93
  static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
97
94
  static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
98
- startBinding?: PointBinding | null;
99
- endBinding?: PointBinding | null;
95
+ startBinding?: FixedPointBinding | null;
96
+ endBinding?: FixedPointBinding | null;
97
+ moveMidPointsWithElement?: boolean | null;
100
98
  }): void;
101
99
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
102
100
  static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
103
- pointerDownState: LinearElementEditor["pointerDownState"];
101
+ pointerDownState: LinearElementEditor["initialState"];
104
102
  selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
105
103
  } | undefined;
106
104
  private static _updatePoints;
@@ -111,6 +109,6 @@ export declare class LinearElementEditor {
111
109
  };
112
110
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
113
111
  static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
114
- static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
112
+ static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): Pick<LinearElementEditor, "segmentMidPointHoveredCoords" | "initialState">;
115
113
  static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
116
114
  }
@@ -0,0 +1,2 @@
1
+ import type { ExcalidrawElement } from "./types";
2
+ export declare const positionElementsOnGrid: <TElement extends ExcalidrawElement>(elements: TElement[] | TElement[][], centerX: number, centerY: number, padding?: number) => TElement[];
@@ -1,6 +1,7 @@
1
+ import { type GlobalPoint } from "@excalidraw/math";
1
2
  import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
3
  import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "@excalidraw/excalidraw/scene/types";
3
- import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "./types";
4
+ import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap, ElementsMap } from "./types";
4
5
  import type { RoughCanvas } from "roughjs/bin/canvas";
5
6
  export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
6
7
  export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure, pendingNodes: Readonly<PendingExcalidrawElements> | null, globalAlpha?: number) => number;
@@ -21,8 +22,10 @@ export interface ExcalidrawElementWithCanvas {
21
22
  export declare const DEFAULT_LINK_SIZE = 14;
22
23
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
23
24
  export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState, selectionColor: InteractiveCanvasRenderConfig["selectionColor"]) => void;
24
- export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
25
+ export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState | InteractiveCanvasAppState) => void;
25
26
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
26
27
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
27
28
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
28
29
  export declare function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement): string;
30
+ export declare function getFreedrawOutlineAsSegments(element: ExcalidrawFreeDrawElement, points: [number, number][], elementsMap: ElementsMap): import("@excalidraw/math").LineSegment<GlobalPoint>[];
31
+ export declare function getFreedrawOutlinePoints(element: ExcalidrawFreeDrawElement): [number, number][];
@@ -1,14 +1,15 @@
1
+ import { type EditorInterface } from "@excalidraw/common";
1
2
  import type { GlobalPoint, LocalPoint } from "@excalidraw/math";
2
- import type { AppState, Device, Zoom } from "@excalidraw/excalidraw/types";
3
+ import type { AppState, Zoom } from "@excalidraw/excalidraw/types";
3
4
  import type { Bounds } from "./bounds";
4
5
  import type { MaybeTransformHandleType } from "./transformHandles";
5
6
  import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
6
- export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
7
- export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
7
+ export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, editorInterface: EditorInterface) => MaybeTransformHandleType;
8
+ export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, editorInterface: EditorInterface) => {
8
9
  element: NonDeletedExcalidrawElement;
9
10
  transformHandleType: MaybeTransformHandleType;
10
11
  } | null;
11
- export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
12
+ export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, editorInterface: EditorInterface) => MaybeTransformHandleType;
12
13
  export declare const getCursorForResizingElement: (resizingElement: {
13
14
  element?: ExcalidrawElement;
14
15
  transformHandleType: MaybeTransformHandleType;
@@ -169,7 +169,11 @@ export declare class StoreDelta {
169
169
  /**
170
170
  * Parse and load the delta from the remote payload.
171
171
  */
172
- static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
172
+ static load({ id, elements: { added, removed, updated }, appState: { delta: appStateDelta }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Squash the passed deltas into the aggregated delta instance.
175
+ */
176
+ static squash(...deltas: StoreDelta[]): StoreDelta;
173
177
  /**
174
178
  * Inverse store delta, creates new instance of `StoreDelta`.
175
179
  */
@@ -182,6 +186,7 @@ export declare class StoreDelta {
182
186
  * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
183
187
  */
184
188
  static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
189
+ static empty(): StoreDelta;
185
190
  isEmpty(): boolean;
186
191
  }
187
192
  /**
@@ -1,6 +1,6 @@
1
+ import { type Radians } from "@excalidraw/math";
1
2
  import type { AppState } from "@excalidraw/excalidraw/types";
2
3
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
- import type { Radians } from "@excalidraw/math";
4
4
  import type { Scene } from "./Scene";
5
5
  import type { MaybeTransformHandleType } from "./transformHandles";
6
6
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
@@ -1,5 +1,6 @@
1
+ import { type EditorInterface } from "@excalidraw/common";
1
2
  import type { Radians } from "@excalidraw/math";
2
- import type { Device, InteractiveCanvasAppState, Zoom } from "@excalidraw/excalidraw/types";
3
+ import type { InteractiveCanvasAppState, Zoom } from "@excalidraw/excalidraw/types";
3
4
  import type { Bounds } from "./bounds";
4
5
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
5
6
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
@@ -28,8 +29,8 @@ export declare const OMIT_SIDES_FOR_FRAME: {
28
29
  w: boolean;
29
30
  rotation: boolean;
30
31
  };
31
- export declare const canResizeFromSides: (device: Device) => boolean;
32
- export declare const getOmitSidesForDevice: (device: Device) => {};
32
+ export declare const canResizeFromSides: (editorInterface: EditorInterface) => boolean;
33
+ export declare const getOmitSidesForEditorInterface: (editorInterface: EditorInterface) => {};
33
34
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: Radians, zoom: Zoom, pointerType: PointerType, omitSides?: {
34
35
  s?: boolean | undefined;
35
36
  e?: boolean | undefined;
@@ -52,4 +53,4 @@ export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoo
52
53
  se?: boolean | undefined;
53
54
  rotation?: boolean | undefined;
54
55
  }) => TransformHandles;
55
- export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
56
+ export declare const hasBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState, editorInterface: EditorInterface) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkNonNullable } from "@excalidraw/common/utility-types";
3
3
  import type { Bounds } from "./bounds";
4
- import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement, PointBinding, FixedPointBinding, ExcalidrawFlowchartNodeElement, ExcalidrawLinearElementSubType } from "./types";
4
+ import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement, ExcalidrawFlowchartNodeElement, ExcalidrawLinearElementSubType } from "./types";
5
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
6
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
7
  export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
@@ -24,7 +24,7 @@ export declare const isSimpleArrow: (element?: ExcalidrawElement) => element is
24
24
  export declare const isSharpArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
25
25
  export declare const isCurvedArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
26
26
  export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
27
- export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
27
+ export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawArrowElement;
28
28
  export declare const isBindingElementType: (elementType: ElementOrToolType) => boolean;
29
29
  export declare const isBindableElement: (element: ExcalidrawElement | null | undefined, includeLocked?: boolean) => element is ExcalidrawBindableElement;
30
30
  export declare const isRectanguloidElement: (element?: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
@@ -43,7 +43,6 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
43
43
  } | {
44
44
  type: 3;
45
45
  } | null;
46
- export declare const isFixedPointBinding: (binding: PointBinding | FixedPointBinding) => binding is FixedPointBinding;
47
46
  export declare const isBounds: (box: unknown) => box is Bounds;
48
47
  export declare const getLinearElementSubType: (element: ExcalidrawLinearElement) => ExcalidrawLinearElementSubType;
49
48
  /**
@@ -197,14 +197,12 @@ export type ExcalidrawTextElementWithContainer = {
197
197
  containerId: ExcalidrawTextContainer["id"];
198
198
  } & ExcalidrawTextElement;
199
199
  export type FixedPoint = [number, number];
200
- export type PointBinding = {
200
+ export type BindMode = "inside" | "orbit" | "skip";
201
+ export type FixedPointBinding = {
201
202
  elementId: ExcalidrawBindableElement["id"];
202
- focus: number;
203
- gap: number;
204
- };
205
- export type FixedPointBinding = Merge<PointBinding, {
206
203
  fixedPoint: FixedPoint;
207
- }>;
204
+ mode: BindMode;
205
+ };
208
206
  type Index = number;
209
207
  export type PointsPositionUpdates = Map<Index, {
210
208
  point: LocalPoint;
@@ -214,9 +212,8 @@ export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" |
214
212
  export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
215
213
  type: "line" | "arrow";
216
214
  points: readonly LocalPoint[];
217
- lastCommittedPoint: LocalPoint | null;
218
- startBinding: PointBinding | null;
219
- endBinding: PointBinding | null;
215
+ startBinding: FixedPointBinding | null;
216
+ endBinding: FixedPointBinding | null;
220
217
  startArrowhead: Arrowhead | null;
221
218
  endArrowhead: Arrowhead | null;
222
219
  }>;
@@ -235,9 +232,9 @@ export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
235
232
  }>;
236
233
  export type ExcalidrawElbowArrowElement = Merge<ExcalidrawArrowElement, {
237
234
  elbowed: true;
235
+ fixedSegments: readonly FixedSegment[] | null;
238
236
  startBinding: FixedPointBinding | null;
239
237
  endBinding: FixedPointBinding | null;
240
- fixedSegments: readonly FixedSegment[] | null;
241
238
  /**
242
239
  * Marks that the 3rd point should be used as the 2nd point of the arrow in
243
240
  * order to temporarily hide the first segment of the arrow without losing
@@ -260,7 +257,6 @@ export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
260
257
  points: readonly LocalPoint[];
261
258
  pressures: readonly number[];
262
259
  simulatePressure: boolean;
263
- lastCommittedPoint: LocalPoint | null;
264
260
  }>;
265
261
  export type FileId = string & {
266
262
  _brand: "FileId";
@@ -1,7 +1,7 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { Curve, LineSegment } from "@excalidraw/math";
3
3
  import type { Zoom } from "@excalidraw/excalidraw/types";
4
- import type { ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, ExcalidrawRectanguloidElement } from "./types";
4
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, ExcalidrawRectanguloidElement } from "./types";
5
5
  /**
6
6
  * Returns the **rotated** components of freedraw, line or arrow elements.
7
7
  *
@@ -29,3 +29,4 @@ export declare function deconstructRectanguloidElement(element: ExcalidrawRectan
29
29
  export declare function deconstructDiamondElement(element: ExcalidrawDiamondElement, offset?: number): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
30
30
  export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
31
31
  export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
32
+ export declare const projectFixedPointOntoDiagonal: (arrow: ExcalidrawArrowElement, point: GlobalPoint, element: ExcalidrawElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => GlobalPoint | null;
@@ -1,6 +1,12 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
+ import type { GlobalPoint } from "@excalidraw/math";
2
3
  import type { Scene } from "./Scene";
3
- import type { ExcalidrawElement } from "./types";
4
+ import type { ExcalidrawArrowElement, ExcalidrawElement, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered, OrderedExcalidrawElement } from "./types";
5
+ /**
6
+ * Moves the arrow element above any bindable elements it intersects with or
7
+ * hovers over.
8
+ */
9
+ export declare const moveArrowAboveBindable: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, scene: Scene) => readonly OrderedExcalidrawElement[];
4
10
  export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
5
11
  export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState, scene: Scene) => readonly ExcalidrawElement[];
6
12
  export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];