@excalidraw/excalidraw 0.18.0-58f7d33 → 0.18.0-6d870b1c8

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 (174) hide show
  1. package/dist/dev/chunk-CP5DND7P.js +7 -0
  2. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  3. package/dist/dev/chunk-D5WIFFIO.js +5678 -0
  4. package/dist/dev/chunk-D5WIFFIO.js.map +7 -0
  5. package/dist/dev/{chunk-X3RYHLJU.js → chunk-QF5FRM6O.js} +15 -5
  6. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  7. package/dist/dev/data/{image-U2IPNUKJ.js → image-WMAXQLTI.js} +3 -3
  8. package/dist/dev/index.css +104 -22
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +8871 -9726
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-CKWC2GMK.js → en-SMAPCEOQ.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-A66AFZZU.js +7 -0
  16. package/dist/prod/chunk-I4UNSFV6.js +12 -0
  17. package/dist/prod/chunk-KK52DCS3.js +4 -0
  18. package/dist/prod/data/image-U3WTNYT7.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +25 -17
  21. package/dist/prod/locales/{en-SBO6ZHT2.js → en-TYY6KWIJ.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/common/src/constants.d.ts +21 -3
  25. package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  26. package/dist/types/common/src/font-metadata.d.ts +4 -2
  27. package/dist/types/common/src/index.d.ts +1 -0
  28. package/dist/types/common/src/utility-types.d.ts +5 -0
  29. package/dist/types/common/src/utils.d.ts +17 -4
  30. package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
  31. package/dist/types/element/src/align.d.ts +4 -3
  32. package/dist/types/element/src/binding.d.ts +26 -16
  33. package/dist/types/element/src/bounds.d.ts +13 -5
  34. package/dist/types/element/src/collision.d.ts +18 -12
  35. package/dist/types/element/src/cropElement.d.ts +1 -1
  36. package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +74 -39
  37. package/dist/types/element/src/distance.d.ts +2 -2
  38. package/dist/types/element/src/distribute.d.ts +2 -1
  39. package/dist/types/element/src/dragElements.d.ts +3 -2
  40. package/dist/types/element/src/duplicate.d.ts +10 -13
  41. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  42. package/dist/types/element/src/flowchart.d.ts +3 -2
  43. package/dist/types/element/src/fractionalIndex.d.ts +9 -3
  44. package/dist/types/element/src/frame.d.ts +5 -4
  45. package/dist/types/element/src/groups.d.ts +1 -0
  46. package/dist/types/element/src/index.d.ts +43 -2
  47. package/dist/types/element/src/linearElementEditor.d.ts +23 -36
  48. package/dist/types/element/src/mutateElement.d.ts +11 -3
  49. package/dist/types/element/src/newElement.d.ts +4 -3
  50. package/dist/types/element/src/resizeElements.d.ts +5 -4
  51. package/dist/types/element/src/selection.d.ts +11 -5
  52. package/dist/types/element/src/shape.d.ts +42 -0
  53. package/dist/types/element/src/sizeHelpers.d.ts +2 -2
  54. package/dist/types/element/src/store.d.ts +232 -0
  55. package/dist/types/element/src/textElement.d.ts +4 -3
  56. package/dist/types/element/src/typeChecks.d.ts +19 -1
  57. package/dist/types/element/src/types.d.ts +15 -2
  58. package/dist/types/element/src/utils.d.ts +16 -6
  59. package/dist/types/element/src/zindex.d.ts +1 -1
  60. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +39 -51
  61. package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -34
  62. package/dist/types/excalidraw/actions/actionCanvas.d.ts +175 -227
  63. package/dist/types/excalidraw/actions/actionClipboard.d.ts +78 -100
  64. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -17
  65. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +39 -50
  66. package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -16
  67. package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -50
  68. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -17
  69. package/dist/types/excalidraw/actions/actionExport.d.ts +127 -163
  70. package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -40
  71. package/dist/types/excalidraw/actions/actionFrame.d.ts +99 -115
  72. package/dist/types/excalidraw/actions/actionGroup.d.ts +26 -34
  73. package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
  74. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +538 -18
  75. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -16
  76. package/dist/types/excalidraw/actions/actionMenu.d.ts +36 -48
  77. package/dist/types/excalidraw/actions/actionNavigate.d.ts +25 -33
  78. package/dist/types/excalidraw/actions/actionProperties.d.ts +203 -255
  79. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +13 -17
  80. package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -17
  81. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -17
  82. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -17
  83. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +12 -189
  84. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  85. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -17
  86. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -17
  87. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -17
  88. package/dist/types/excalidraw/actions/types.d.ts +4 -3
  89. package/dist/types/excalidraw/appState.d.ts +19 -10
  90. package/dist/types/excalidraw/components/Actions.d.ts +0 -4
  91. package/dist/types/excalidraw/components/App.d.ts +30 -19
  92. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  93. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  94. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  95. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  96. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  97. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  98. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  99. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  100. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  101. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  102. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  103. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
  104. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  105. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  106. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  107. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  108. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  109. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  110. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  111. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
  112. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  113. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  114. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  116. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  117. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
  118. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
  119. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  120. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  121. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  122. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  123. package/dist/types/excalidraw/components/icons.d.ts +3 -0
  124. package/dist/types/excalidraw/components/shapes.d.ts +1 -1
  125. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  126. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  127. package/dist/types/excalidraw/data/transform.d.ts +1 -1
  128. package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
  129. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  130. package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
  131. package/dist/types/excalidraw/history.d.ts +30 -22
  132. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  133. package/dist/types/excalidraw/index.d.ts +11 -10
  134. package/dist/types/excalidraw/lasso/index.d.ts +1 -0
  135. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  136. package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
  137. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  138. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
  139. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  140. package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
  141. package/dist/types/excalidraw/scene/types.d.ts +2 -0
  142. package/dist/types/excalidraw/snapping.d.ts +2 -2
  143. package/dist/types/excalidraw/types.d.ts +34 -14
  144. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
  145. package/dist/types/math/src/angle.d.ts +2 -0
  146. package/dist/types/math/src/constants.d.ts +3 -0
  147. package/dist/types/math/src/curve.d.ts +34 -0
  148. package/dist/types/math/src/index.d.ts +1 -0
  149. package/dist/types/math/src/point.d.ts +1 -1
  150. package/dist/types/math/src/rectangle.d.ts +2 -0
  151. package/dist/types/math/src/vector.d.ts +8 -2
  152. package/dist/types/utils/src/bbox.d.ts +1 -1
  153. package/dist/types/utils/src/index.d.ts +1 -1
  154. package/dist/types/utils/src/withinBounds.d.ts +1 -1
  155. package/history.ts +147 -110
  156. package/package.json +12 -9
  157. package/dist/dev/chunk-KKJLIRJU.js +0 -7
  158. package/dist/dev/chunk-KKJLIRJU.js.map +0 -7
  159. package/dist/dev/chunk-LEJJ2YZY.js +0 -18711
  160. package/dist/dev/chunk-LEJJ2YZY.js.map +0 -7
  161. package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
  162. package/dist/prod/chunk-IUH5AXLB.js +0 -12
  163. package/dist/prod/chunk-QUX7WTVH.js +0 -7
  164. package/dist/prod/chunk-RQK6WG4F.js +0 -33
  165. package/dist/prod/data/image-UQDATCXC.js +0 -1
  166. package/dist/types/element/src/Shape.d.ts +0 -17
  167. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  168. package/dist/types/element/src/shapes.d.ts +0 -23
  169. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  170. package/dist/types/excalidraw/store.d.ts +0 -129
  171. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  172. package/dist/types/utils/src/collision.d.ts +0 -8
  173. /package/dist/dev/data/{image-U2IPNUKJ.js.map → image-WMAXQLTI.js.map} +0 -0
  174. /package/dist/dev/locales/{en-CKWC2GMK.js.map → en-SMAPCEOQ.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- import type { ElementUpdate } from "@excalidraw/element/mutateElement";
2
1
  import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "@excalidraw/element/types";
3
- import type { ValueOf } from "@excalidraw/common/utility-types";
4
- import type { AppState, ObservedAppState } from "./types";
2
+ import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
3
+ import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
4
+ import { StoreSnapshot } from "./store";
5
5
  /**
6
6
  * Represents the difference between two objects of the same type.
7
7
  *
@@ -11,11 +11,11 @@ import type { AppState, ObservedAppState } from "./types";
11
11
  *
12
12
  * Keeping it as pure object (without transient state, side-effects, etc.), so we won't have to instantiate it on load.
13
13
  */
14
- declare class Delta<T> {
14
+ export declare class Delta<T> {
15
15
  readonly deleted: Partial<T>;
16
16
  readonly inserted: Partial<T>;
17
17
  private constructor();
18
- static create<T>(deleted: Partial<T>, inserted: Partial<T>, modifier?: (delta: Partial<T>) => Partial<T>, modifierOptions?: "deleted" | "inserted"): Delta<T>;
18
+ static create<T>(deleted: Partial<T>, inserted: Partial<T>, modifier?: (delta: Partial<T>, partialType: "deleted" | "inserted") => Partial<T>, modifierOptions?: "deleted" | "inserted" | "both"): Delta<T>;
19
19
  /**
20
20
  * Calculates the delta between two objects.
21
21
  *
@@ -29,6 +29,10 @@ 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>): Delta<T>;
32
36
  /**
33
37
  * Merges deleted and inserted object partials.
34
38
  */
@@ -56,13 +60,29 @@ declare class Delta<T> {
56
60
  */
57
61
  static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
62
  /**
59
- * Returns all the object1 keys that have distinct values.
63
+ * Compares if shared properties of object1 and object2 contain any different value (aka inner join).
64
+ */
65
+ static isInnerDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
66
+ /**
67
+ * Compares if any properties of object1 and object2 contain any different value (aka full join).
68
+ */
69
+ static isDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
70
+ /**
71
+ * Returns sorted object1 keys that have distinct values.
60
72
  */
61
73
  static getLeftDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
62
74
  /**
63
- * Returns all the object2 keys that have distinct values.
75
+ * Returns sorted object2 keys that have distinct values.
64
76
  */
65
77
  static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
78
+ /**
79
+ * Returns sorted keys of shared object1 and object2 properties that have distinct values (aka inner join).
80
+ */
81
+ static getInnerDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
82
+ /**
83
+ * Returns sorted keys that have distinct values between object1 and object2 (aka full join).
84
+ */
85
+ static getDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
66
86
  /**
67
87
  * Iterator comparing values of object properties based on the passed joining strategy.
68
88
  *
@@ -73,65 +93,76 @@ declare class Delta<T> {
73
93
  private static distinctKeysIterator;
74
94
  }
75
95
  /**
76
- * Encapsulates the modifications captured as `Delta`/s.
96
+ * Encapsulates a set of application-level `Delta`s.
77
97
  */
78
- interface Change<T> {
98
+ export interface DeltaContainer<T> {
79
99
  /**
80
- * Inverses the `Delta`s inside while creating a new `Change`.
100
+ * Inverses the `Delta`s while creating a new `DeltaContainer` instance.
81
101
  */
82
- inverse(): Change<T>;
102
+ inverse(): DeltaContainer<T>;
83
103
  /**
84
- * Applies the `Change` to the previous object.
104
+ * Applies the `Delta`s to the previous object.
85
105
  *
86
- * @returns a tuple of the next object `T` with applied change, and `boolean`, indicating whether the applied change resulted in a visible change.
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.
87
107
  */
88
108
  applyTo(previous: T, ...options: unknown[]): [T, boolean];
89
109
  /**
90
- * Checks whether there are actually `Delta`s.
110
+ * Squashes the current delta with the given one.
111
+ */
112
+ squash(delta: DeltaContainer<T>): this;
113
+ /**
114
+ * Checks whether all `Delta`s are empty.
91
115
  */
92
116
  isEmpty(): boolean;
93
117
  }
94
- export declare class AppStateChange implements Change<AppState> {
95
- private readonly delta;
118
+ export declare class AppStateDelta implements DeltaContainer<AppState> {
119
+ delta: Delta<ObservedAppState>;
96
120
  private constructor();
97
- static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateChange;
98
- static empty(): AppStateChange;
99
- inverse(): AppStateChange;
121
+ static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
122
+ static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
123
+ static empty(): AppStateDelta;
124
+ inverse(): AppStateDelta;
125
+ squash(delta: AppStateDelta): this;
100
126
  applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
101
127
  isEmpty(): boolean;
102
- /**
103
- * It is necessary to post process the partials in case of reference values,
104
- * for which we need to calculate the real diff between `deleted` and `inserted`.
105
- */
106
- private static postProcess;
107
128
  /**
108
129
  * Mutates `nextAppState` be filtering out state related to deleted elements.
109
130
  *
110
131
  * @returns `true` if a visible change is found, `false` otherwise.
111
132
  */
112
133
  private filterInvisibleChanges;
113
- private static convertToAppStateKey;
114
134
  private static filterSelectedElements;
115
135
  private static filterSelectedGroups;
116
136
  private static stripElementsProps;
117
137
  private static stripStandaloneProps;
138
+ /**
139
+ * It is necessary to post process the partials in case of reference values,
140
+ * for which we need to calculate the real diff between `deleted` and `inserted`.
141
+ */
142
+ private static postProcess;
143
+ private static orderAppStateKeys;
118
144
  }
119
- type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> = Omit<ElementUpdate<Ordered<T>>, "seed">;
145
+ type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
146
+ export type ApplyToOptions = {
147
+ excludedProperties: Set<keyof ElementPartial>;
148
+ };
120
149
  /**
121
150
  * Elements change is a low level primitive to capture a change between two sets of elements.
122
151
  * It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
123
152
  */
124
- export declare class ElementsChange implements Change<SceneElementsMap> {
125
- private readonly added;
126
- private readonly removed;
127
- private readonly updated;
153
+ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
154
+ readonly added: Record<string, Delta<ElementPartial>>;
155
+ readonly removed: Record<string, Delta<ElementPartial>>;
156
+ readonly updated: Record<string, Delta<ElementPartial>>;
128
157
  private constructor();
129
- static create(added: Map<string, Delta<ElementPartial>>, removed: Map<string, Delta<ElementPartial>>, updated: Map<string, Delta<ElementPartial>>, options?: {
158
+ static create(added: Record<string, Delta<ElementPartial>>, removed: Record<string, Delta<ElementPartial>>, updated: Record<string, Delta<ElementPartial>>, options?: {
130
159
  shouldRedistribute: boolean;
131
- }): ElementsChange;
160
+ }): ElementsDelta;
161
+ static restore(elementsDeltaDTO: DTO<ElementsDelta>): ElementsDelta;
132
162
  private static satisfiesAddition;
133
163
  private static satisfiesRemoval;
134
164
  private static satisfiesUpdate;
165
+ private static satisfiesCommmonInvariants;
135
166
  private static validate;
136
167
  /**
137
168
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -139,21 +170,22 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
139
170
  * @param prevElements - Map representing the previous state of elements.
140
171
  * @param nextElements - Map representing the next state of elements.
141
172
  *
142
- * @returns `ElementsChange` instance representing the `Delta` changes between the two sets of elements.
173
+ * @returns `ElementsDelta` instance representing the `Delta` changes between the two sets of elements.
143
174
  */
144
- static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsChange;
145
- static empty(): ElementsChange;
146
- inverse(): ElementsChange;
175
+ static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsDelta;
176
+ static empty(): ElementsDelta;
177
+ inverse(): ElementsDelta;
147
178
  isEmpty(): boolean;
148
179
  /**
149
180
  * Update delta/s based on the existing elements.
150
181
  *
151
- * @param elements current elements
182
+ * @param nextElements current elements
152
183
  * @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
153
184
  * @returns new instance with modified delta/s
154
185
  */
155
- applyLatestChanges(elements: SceneElementsMap): ElementsChange;
156
- applyTo(elements: SceneElementsMap, snapshot: Map<string, OrderedExcalidrawElement>): [SceneElementsMap, boolean];
186
+ applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
187
+ applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
188
+ squash(delta: ElementsDelta): this;
157
189
  private static createApplier;
158
190
  private static createGetter;
159
191
  private static applyDelta;
@@ -165,6 +197,8 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
165
197
  * Resolves conflicts for all previously added, removed and updated elements.
166
198
  * Updates the previous deltas with all the changes after conflict resolution.
167
199
  *
200
+ * // TODO: revisit since some bound arrows seem to be often redrawn incorrectly
201
+ *
168
202
  * @returns all elements affected by the conflict resolution
169
203
  */
170
204
  private resolveConflicts;
@@ -187,5 +221,6 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
187
221
  */
188
222
  private static postProcess;
189
223
  private static stripIrrelevantProps;
224
+ private static stripVersionProps;
190
225
  }
191
226
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { GlobalPoint } from "@excalidraw/math";
2
- import type { ExcalidrawBindableElement } from "./types";
3
- export declare const distanceToBindableElement: (element: ExcalidrawBindableElement, p: GlobalPoint) => number;
2
+ import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export declare const distanceToElement: (element: ExcalidrawElement, elementsMap: ElementsMap, p: GlobalPoint) => number;
@@ -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[];
@@ -1,6 +1,6 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
- import type Scene from "@excalidraw/excalidraw/scene/Scene";
3
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
+ import type { Scene } from "./Scene";
4
4
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
5
5
  x: number;
6
6
  y: number;
@@ -9,7 +9,7 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
9
9
  y: number;
10
10
  }, gridSize: NullableGridSize) => void;
11
11
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
12
- export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, widthAspectRatio, originOffset, informMutation, }: {
12
+ export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
13
13
  newElement: NonDeletedExcalidrawElement;
14
14
  elementType: AppState["activeTool"]["type"];
15
15
  originX: number;
@@ -21,6 +21,7 @@ export declare const dragNewElement: ({ newElement, elementType, originX, origin
21
21
  shouldMaintainAspectRatio: boolean;
22
22
  shouldResizeFromCenter: boolean;
23
23
  zoom: NormalizedZoomValue;
24
+ scene: Scene;
24
25
  /** whether to keep given aspect ratio when `isResizeWithSidesSameLength` is
25
26
  true */
26
27
  widthAspectRatio?: number | null | undefined;
@@ -13,13 +13,16 @@ import type { ExcalidrawElement, GroupId } from "./types";
13
13
  * multiple elements at once, share this map
14
14
  * amongst all of them
15
15
  * @param element Element to duplicate
16
- * @param overrides Any element properties to override
17
16
  */
18
- export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined, randomizeSeed?: boolean) => Readonly<TElement>;
17
+ export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, randomizeSeed?: boolean) => Readonly<TElement>;
19
18
  export declare const duplicateElements: (opts: {
20
19
  elements: readonly ExcalidrawElement[];
21
20
  randomizeSeed?: boolean | undefined;
22
- overrides?: ((originalElement: ExcalidrawElement) => Partial<ExcalidrawElement>) | undefined;
21
+ overrides?: ((data: {
22
+ duplicateElement: ExcalidrawElement;
23
+ origElement: ExcalidrawElement;
24
+ origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
25
+ }) => Partial<ExcalidrawElement>) | undefined;
23
26
  } & ({
24
27
  /**
25
28
  * Duplicates all elements in array.
@@ -42,17 +45,11 @@ export declare const duplicateElements: (opts: {
42
45
  editingGroupId: AppState["editingGroupId"];
43
46
  selectedGroupIds: AppState["selectedGroupIds"];
44
47
  };
45
- /**
46
- * If true, duplicated elements are inserted _before_ specified
47
- * elements. Case: alt-dragging elements to duplicate them.
48
- *
49
- * TODO: remove this once (if) we stop replacing the original element
50
- * with the duplicated one in the scene array.
51
- */
52
- reverseOrder: boolean;
53
48
  })) => {
54
- newElements: ExcalidrawElement[];
55
- elementsWithClones: ExcalidrawElement[];
49
+ duplicatedElements: ExcalidrawElement[];
50
+ duplicateElementsMap: Map<string, ExcalidrawElement>;
51
+ elementsWithDuplicates: ExcalidrawElement[];
52
+ origIdToDuplicateId: Map<string, string>;
56
53
  };
57
54
  /**
58
55
  * Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
@@ -8,7 +8,7 @@ export declare const BASE_PADDING = 40;
8
8
  */
9
9
  export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArrowElement>, elementsMap: NonDeletedSceneElementsMap, updates: {
10
10
  points?: readonly LocalPoint[];
11
- fixedSegments?: FixedSegment[] | null;
11
+ fixedSegments?: readonly FixedSegment[] | null;
12
12
  startBinding?: FixedPointBinding | null;
13
13
  endBinding?: FixedPointBinding | null;
14
14
  }, options?: {
@@ -1,9 +1,10 @@
1
1
  import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
2
  import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
3
+ import type { Scene } from "./Scene";
3
4
  type LinkDirection = "up" | "right" | "down" | "left";
4
5
  export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
5
6
  export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
6
- export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap, appState: AppState, direction: LinkDirection, numberOfNodes: number) => ExcalidrawElement[];
7
+ export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number) => ExcalidrawElement[];
7
8
  export declare class FlowChartNavigator {
8
9
  isExploring: boolean;
9
10
  private sameLevelNodes;
@@ -18,7 +19,7 @@ export declare class FlowChartCreator {
18
19
  private numberOfNodes;
19
20
  private direction;
20
21
  pendingNodes: PendingExcalidrawElements | null;
21
- createNodes(startNode: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap, appState: AppState, direction: LinkDirection): void;
22
+ createNodes(startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene): void;
22
23
  clear(): void;
23
24
  }
24
25
  export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, OrderedExcalidrawElement } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -42,10 +42,16 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
42
42
  * Synchronizes invalid fractional indices of moved elements with the array order by mutating passed elements.
43
43
  * If the synchronization fails or the result is invalid, it fallbacks to `syncInvalidIndices`.
44
44
  */
45
- export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: Map<string, ExcalidrawElement>) => OrderedExcalidrawElement[];
45
+ export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: ElementsMap) => OrderedExcalidrawElement[];
46
46
  /**
47
- * Synchronizes all invalid fractional indices with the array order by mutating passed elements.
47
+ * Synchronizes all invalid fractional indices within the array order by mutating elements in the passed array.
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
51
  export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
52
+ /**
53
+ * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
+ *
55
+ * 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.
56
+ */
57
+ export declare const syncInvalidIndicesImmutable: (elements: readonly ExcalidrawElement[]) => SceneElementsMap | undefined;
@@ -1,8 +1,8 @@
1
- import type { ExcalidrawElementsIncludingDeleted } from "@excalidraw/excalidraw/scene/Scene";
2
1
  import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
3
2
  import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
3
+ import type { ExcalidrawElementsIncludingDeleted } from "./Scene";
4
4
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
5
- export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
+ export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
6
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
7
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
8
8
  export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
31
31
  */
32
32
  export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
- export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement)[];
35
- export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement)[];
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
+ 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[];
@@ -64,6 +64,7 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
64
64
  checkedGroups?: Map<string, boolean>;
65
65
  }) => boolean;
66
66
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
67
+ export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
67
68
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
68
69
  export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
69
70
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
@@ -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[][];
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
1
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMapOrArray } from "./types";
2
2
  /**
3
3
  * @deprecated unsafe, use hashElementsVersion instead
4
4
  */
@@ -6,7 +6,7 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
6
6
  /**
7
7
  * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
8
8
  */
9
- export declare const hashElementsVersion: (elements: readonly ExcalidrawElement[]) => number;
9
+ export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
10
10
  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>[];
@@ -14,3 +14,44 @@ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element:
14
14
  export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
15
15
  export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
16
16
  export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
17
+ export * from "./align";
18
+ export * from "./binding";
19
+ export * from "./bounds";
20
+ export * from "./collision";
21
+ export * from "./comparisons";
22
+ export * from "./containerCache";
23
+ export * from "./cropElement";
24
+ export * from "./delta";
25
+ export * from "./distance";
26
+ export * from "./distribute";
27
+ export * from "./dragElements";
28
+ export * from "./duplicate";
29
+ export * from "./elbowArrow";
30
+ export * from "./elementLink";
31
+ export * from "./embeddable";
32
+ export * from "./flowchart";
33
+ export * from "./fractionalIndex";
34
+ export * from "./frame";
35
+ export * from "./groups";
36
+ export * from "./heading";
37
+ export * from "./image";
38
+ export * from "./linearElementEditor";
39
+ export * from "./mutateElement";
40
+ export * from "./newElement";
41
+ export * from "./renderElement";
42
+ export * from "./resizeElements";
43
+ export * from "./resizeTest";
44
+ export * from "./Scene";
45
+ export * from "./selection";
46
+ export * from "./shape";
47
+ export * from "./showSelectedShapeActions";
48
+ export * from "./sizeHelpers";
49
+ export * from "./sortElements";
50
+ export * from "./store";
51
+ export * from "./textElement";
52
+ export * from "./textMeasurements";
53
+ export * from "./textWrapping";
54
+ export * from "./transformHandles";
55
+ export * from "./typeChecks";
56
+ export * from "./utils";
57
+ export * from "./zindex";
@@ -1,15 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
3
- import Scene from "@excalidraw/excalidraw/scene/Scene";
4
- import type { Store } from "@excalidraw/excalidraw/store";
3
+ import { type Store } from "@excalidraw/element";
5
4
  import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
5
+ import type { Scene } from "./Scene";
6
6
  import type { Bounds } from "./bounds";
7
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
8
- declare const editorMidPointsCache: {
9
- version: number | null;
10
- points: (GlobalPoint | null)[];
11
- zoom: number | null;
12
- };
7
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
13
8
  export declare class LinearElementEditor {
14
9
  readonly elementId: ExcalidrawElement["id"] & {
15
10
  _brand: "excalidrawLinearElementId";
@@ -43,7 +38,9 @@ export declare class LinearElementEditor {
43
38
  readonly hoverPointIndex: number;
44
39
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
45
40
  readonly elbowed: boolean;
46
- constructor(element: NonDeleted<ExcalidrawLinearElement>);
41
+ readonly customLineAngle: number | null;
42
+ readonly isEditing: boolean;
43
+ constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, isEditing?: boolean);
47
44
  static POINT_HANDLE_SIZE: number;
48
45
  /**
49
46
  * @param id the `elementId` from the instance of this class (so that we can
@@ -54,19 +51,15 @@ export declare class LinearElementEditor {
54
51
  /**
55
52
  * @returns whether point was dragged
56
53
  */
57
- static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
58
- x: number;
59
- y: number;
60
- }[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): LinearElementEditor | null;
54
+ static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, keyof AppState> | null;
61
55
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
62
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
63
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
56
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
64
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
65
58
  x: number;
66
59
  y: number;
67
60
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
68
61
  static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
69
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
62
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
70
63
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
71
64
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
72
65
  x: number;
@@ -77,7 +70,7 @@ export declare class LinearElementEditor {
77
70
  linearElementEditor: LinearElementEditor | null;
78
71
  };
79
72
  static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
80
- static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): LinearElementEditor | null;
73
+ static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
81
74
  /** scene coords */
82
75
  static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
83
76
  /** scene coords */
@@ -89,30 +82,25 @@ export declare class LinearElementEditor {
89
82
  static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
90
83
  /**
91
84
  * Normalizes line points so that the start point is at [0,0]. This is
92
- * expected in various parts of the codebase. Also returns new x/y to account
93
- * for the potential normalization.
85
+ * expected in various parts of the codebase.
86
+ *
87
+ * Also returns normalized x and y coords to account for the normalization
88
+ * of the points.
94
89
  */
95
- static getNormalizedPoints(element: ExcalidrawLinearElement): {
90
+ static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
96
91
  points: LocalPoint[];
97
92
  x: number;
98
93
  y: number;
99
94
  };
100
- static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
101
- static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): AppState;
102
- static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
103
- static addPoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
104
- point: LocalPoint;
105
- }[]): void;
106
- static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
107
- index: number;
108
- point: LocalPoint;
109
- isDragging?: boolean;
110
- }[], otherUpdates?: {
95
+ static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
96
+ static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
97
+ static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
98
+ static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
111
99
  startBinding?: PointBinding | null;
112
100
  endBinding?: PointBinding | null;
113
- }, sceneElementsMap?: NonDeletedSceneElementsMap): void;
101
+ }): void;
114
102
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
115
- static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, elementsMap: ElementsMap): {
103
+ static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
116
104
  pointerDownState: LinearElementEditor["pointerDownState"];
117
105
  selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
118
106
  } | undefined;
@@ -124,7 +112,6 @@ export declare class LinearElementEditor {
124
112
  };
125
113
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
126
114
  static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
127
- static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, elementsMap: ElementsMap): LinearElementEditor;
128
- static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
115
+ static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
116
+ static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
129
117
  }
130
- export {};
@@ -1,7 +1,15 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
- import type { ExcalidrawElement } from "./types";
3
- export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
4
- export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean, options?: {
2
+ import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
4
+ /**
5
+ * This function tracks updates of text elements for the purposes for collaboration.
6
+ * The version is used to compare updates when more than one user is working in
7
+ * the same drawing.
8
+ *
9
+ * WARNING: this won't trigger the component to update, so if you need to trigger component update,
10
+ * use `scene.mutateElement` or `ExcalidrawImperativeAPI.mutateElement` instead.
11
+ */
12
+ export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
5
13
  isDragging?: boolean;
6
14
  }) => TElement;
7
15
  export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;