@zsviczian/excalidraw 0.18.0-19 → 0.18.0-20

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 (59) hide show
  1. package/dist/excalidraw.development.js +57 -123
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/common/src/constants.d.ts +10 -1
  5. package/types/common/src/utils.d.ts +2 -2
  6. package/types/element/src/Shape.d.ts +6 -2
  7. package/types/element/src/binding.d.ts +7 -8
  8. package/types/element/src/bounds.d.ts +3 -2
  9. package/types/element/src/collision.d.ts +18 -12
  10. package/types/element/src/cropElement.d.ts +1 -1
  11. package/types/element/src/delta.d.ts +26 -6
  12. package/types/element/src/distance.d.ts +2 -2
  13. package/types/element/src/fractionalIndex.d.ts +8 -2
  14. package/types/element/src/linearElementEditor.d.ts +1 -0
  15. package/types/element/src/mutateElement.d.ts +1 -1
  16. package/types/element/src/shapes.d.ts +1 -1
  17. package/types/element/src/sizeHelpers.d.ts +1 -1
  18. package/types/element/src/store.d.ts +11 -7
  19. package/types/element/src/typeChecks.d.ts +4 -0
  20. package/types/element/src/types.d.ts +1 -1
  21. package/types/element/src/utils.d.ts +2 -1
  22. package/types/excalidraw/actions/actionAddToLibrary.d.ts +0 -3
  23. package/types/excalidraw/actions/actionBoundText.d.ts +0 -2
  24. package/types/excalidraw/actions/actionCanvas.d.ts +0 -15
  25. package/types/excalidraw/actions/actionClipboard.d.ts +1 -6
  26. package/types/excalidraw/actions/actionCropEditor.d.ts +0 -1
  27. package/types/excalidraw/actions/actionDeleteSelected.d.ts +1 -3
  28. package/types/excalidraw/actions/actionElementLink.d.ts +0 -1
  29. package/types/excalidraw/actions/actionElementLock.d.ts +0 -2
  30. package/types/excalidraw/actions/actionEmbeddable.d.ts +0 -1
  31. package/types/excalidraw/actions/actionExport.d.ts +0 -9
  32. package/types/excalidraw/actions/actionFinalize.d.ts +1 -3
  33. package/types/excalidraw/actions/actionFrame.d.ts +0 -4
  34. package/types/excalidraw/actions/actionGroup.d.ts +0 -2
  35. package/types/excalidraw/actions/actionLinearEditor.d.ts +0 -1
  36. package/types/excalidraw/actions/actionLink.d.ts +0 -1
  37. package/types/excalidraw/actions/actionMenu.d.ts +0 -3
  38. package/types/excalidraw/actions/actionNavigate.d.ts +0 -2
  39. package/types/excalidraw/actions/actionProperties.d.ts +0 -15
  40. package/types/excalidraw/actions/actionSelectAll.d.ts +0 -1
  41. package/types/excalidraw/actions/actionStyles.d.ts +0 -1
  42. package/types/excalidraw/actions/actionToggleGridMode.d.ts +0 -1
  43. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -1
  44. package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +0 -1
  45. package/types/excalidraw/actions/actionToggleStats.d.ts +0 -1
  46. package/types/excalidraw/actions/actionToggleViewMode.d.ts +0 -1
  47. package/types/excalidraw/actions/actionToggleZenMode.d.ts +0 -1
  48. package/types/excalidraw/components/App.d.ts +7 -13
  49. package/types/excalidraw/eraser/index.d.ts +0 -2
  50. package/types/excalidraw/history.d.ts +21 -5
  51. package/types/excalidraw/lasso/utils.d.ts +2 -1
  52. package/types/excalidraw/renderer/helpers.d.ts +3 -3
  53. package/types/excalidraw/scene/Renderer.d.ts +0 -1
  54. package/types/excalidraw/types.d.ts +2 -4
  55. package/types/math/src/angle.d.ts +2 -0
  56. package/types/math/src/curve.d.ts +4 -0
  57. package/types/math/src/index.d.ts +1 -0
  58. package/types/math/src/vector.d.ts +4 -2
  59. package/types/utils/src/collision.d.ts +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsviczian/excalidraw",
3
- "version": "0.18.0-19",
3
+ "version": "0.18.0-20",
4
4
  "main": "main.js",
5
5
  "module": "./dist/prod/index.js",
6
6
  "types": "types/excalidraw/index.d.ts",
@@ -114,10 +114,19 @@ export declare const FONT_FAMILY: {
114
114
  "Liberation Sans": number;
115
115
  Assistant: number;
116
116
  };
117
+ export declare const SANS_SERIF_GENERIC_FONT = "sans-serif";
118
+ export declare const MONOSPACE_GENERIC_FONT = "monospace";
119
+ export declare const FONT_FAMILY_GENERIC_FALLBACKS: {
120
+ "sans-serif": number;
121
+ monospace: number;
122
+ };
117
123
  export declare const FONT_FAMILY_FALLBACKS: {
118
- Xiaolai: number;
119
124
  "Segoe UI Emoji": number;
125
+ "sans-serif": number;
126
+ monospace: number;
127
+ Xiaolai: number;
120
128
  };
129
+ export declare function getGenericFontFamilyFallback(fontFamily: number): keyof typeof FONT_FAMILY_GENERIC_FALLBACKS;
121
130
  export declare const getFontFamilyFallbacks: (fontFamily: number) => Array<keyof typeof FONT_FAMILY_FALLBACKS>;
122
131
  export declare const THEME: {
123
132
  readonly LIGHT: "light";
@@ -1,5 +1,5 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
- import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement, ElementsMap } from "@excalidraw/element/types";
3
3
  import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "@excalidraw/excalidraw/types";
4
4
  import type { MaybePromise } from "./utility-types";
5
5
  import type { EVENT } from "./constants";
@@ -261,7 +261,7 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
261
261
  */
262
262
  export declare const escapeDoubleQuotes: (str: string) => string;
263
263
  export declare const castArray: <T>(value: T | T[]) => T[];
264
- export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
264
+ export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
265
265
  /** hack for Array.isArray type guard not working with readonly value[] */
266
266
  export declare const isReadonlyArray: (value?: any) => value is readonly any[];
267
267
  export declare const sizeOf: (value: readonly unknown[] | Readonly<Map<string, unknown>> | Readonly<Record<string, unknown>> | ReadonlySet<unknown>) => number;
@@ -1,8 +1,12 @@
1
+ import { RoughGenerator } from "roughjs/bin/generator";
1
2
  import type { EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
2
- import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "./types";
3
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement, ExcalidrawLinearElement, ExcalidrawFreeDrawElement, ElementsMap } from "./types";
3
4
  import type { Drawable, Options } from "roughjs/bin/core";
4
- import type { RoughGenerator } from "roughjs/bin/generator";
5
5
  export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
6
+ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement, elementsMap: ElementsMap) => {
7
+ op: string;
8
+ data: number[];
9
+ }[];
6
10
  /**
7
11
  * Generates the roughjs shape for given element.
8
12
  *
@@ -16,7 +16,6 @@ export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEv
16
16
  export declare const isBindingEnabled: (appState: AppState) => boolean;
17
17
  export declare const FIXED_BINDING_DISTANCE = 5;
18
18
  export declare const BINDING_HIGHLIGHT_THICKNESS = 10;
19
- export declare const BINDING_HIGHLIGHT_OFFSET = 4;
20
19
  export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", scene: Scene) => void;
21
20
  export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], isBindingEnabled: boolean, draggingPoints: readonly number[] | null, scene: Scene, zoom?: AppState["zoom"]) => void;
22
21
  export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => SuggestedBinding[];
@@ -46,11 +45,11 @@ export declare const updateBindings: (latestElement: ExcalidrawElement, scene: S
46
45
  };
47
46
  zoom?: AppState["zoom"];
48
47
  }) => void;
49
- export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
50
- export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => GlobalPoint;
51
- export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
52
- export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
53
- export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => {
48
+ export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, elementsMap: ElementsMap, zoom?: AppState["zoom"]) => Heading;
49
+ export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => GlobalPoint;
50
+ export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
51
+ export declare const snapToMid: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number) => GlobalPoint;
52
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
54
53
  fixedPoint: FixedPoint;
55
54
  };
56
55
  export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
@@ -60,7 +59,7 @@ export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableE
60
59
  y: number;
61
60
  }, elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], fullShape?: boolean) => boolean;
62
61
  export declare const maxBindingGap: (element: ExcalidrawElement, elementWidth: number, elementHeight: number, zoom?: AppState["zoom"]) => number;
63
- export declare const determineFocusDistance: (element: ExcalidrawBindableElement, a: GlobalPoint, b: GlobalPoint) => number;
62
+ export declare const determineFocusDistance: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, a: GlobalPoint, b: GlobalPoint) => number;
64
63
  export declare const bindingProperties: Set<BindableProp | BindingProp>;
65
64
  export type BindableProp = "boundElements";
66
65
  export type BindingProp = "frameId" | "containerId" | "startBinding" | "endBinding";
@@ -102,7 +101,7 @@ export declare class BindableElement {
102
101
  */
103
102
  static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
104
103
  }
105
- export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => GlobalPoint;
104
+ export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement, elementsMap: ElementsMap) => GlobalPoint;
106
105
  export declare const getGlobalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
107
106
  export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
108
107
  export declare const normalizeFixedPoint: <T extends FixedPoint | null>(fixedPoint: T) => T extends null ? null : FixedPoint;
@@ -26,7 +26,8 @@ export type SceneBounds = readonly [
26
26
  ];
27
27
  export declare class ElementBounds {
28
28
  private static boundsCache;
29
- static getBounds(element: ExcalidrawElement, elementsMap: ElementsMap): Bounds;
29
+ private static nonRotatedBoundsCache;
30
+ static getBounds(element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean): Bounds;
30
31
  private static calculateBounds;
31
32
  }
32
33
  export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
@@ -50,7 +51,7 @@ export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
50
51
  /** @returns number in degrees */
51
52
  export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
52
53
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
53
- export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap) => Bounds;
54
+ export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
54
55
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
55
56
  export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
56
57
  x: number;
@@ -1,20 +1,18 @@
1
- import { type GeometricShape } from "@excalidraw/utils/shape";
2
- import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
1
+ import type { GlobalPoint, LineSegment } from "@excalidraw/math";
3
2
  import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
4
3
  import type { ElementsMap, ExcalidrawElement } from "./types";
5
4
  export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
6
- export type HitTestArgs<Point extends GlobalPoint | LocalPoint> = {
7
- x: number;
8
- y: number;
5
+ export type HitTestArgs = {
6
+ point: GlobalPoint;
9
7
  element: ExcalidrawElement;
10
- shape: GeometricShape<Point>;
11
- threshold?: number;
8
+ threshold: number;
9
+ elementsMap: ElementsMap;
12
10
  frameNameBound?: FrameNameBounds | null;
13
11
  };
14
- export declare const hitElementItself: <Point extends GlobalPoint | LocalPoint>({ x, y, element, shape, threshold, frameNameBound, }: HitTestArgs<Point>) => boolean;
15
- export declare const hitElementBoundingBox: (x: number, y: number, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
16
- export declare const hitElementBoundingBoxOnly: <Point extends GlobalPoint | LocalPoint>(hitArgs: HitTestArgs<Point>, elementsMap: ElementsMap) => boolean;
17
- export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoint>(x: number, y: number, textShape: GeometricShape<Point> | null) => boolean;
12
+ export declare const hitElementItself: ({ point, element, threshold, elementsMap, frameNameBound, }: HitTestArgs) => boolean;
13
+ export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
14
+ export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
15
+ export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
18
16
  /**
19
17
  * Intersect a line with an element for binding test
20
18
  *
@@ -23,4 +21,12 @@ export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoin
23
21
  * @param offset
24
22
  * @returns
25
23
  */
26
- export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, line: LineSegment<GlobalPoint>, offset?: number) => GlobalPoint[];
24
+ export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, elementsMap: ElementsMap, line: LineSegment<GlobalPoint>, offset?: number, onlyFirst?: boolean) => GlobalPoint[];
25
+ /**
26
+ * Check if the given point is considered inside the element's border
27
+ *
28
+ * @param point
29
+ * @param element
30
+ * @returns
31
+ */
32
+ export declare const isPointInElement: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { TransformHandleType } from "./transformHandles";
2
2
  import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
3
3
  export declare const MINIMAL_CROP_SIZE = 10;
4
- export declare const cropElement: (element: ExcalidrawImageElement, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
4
+ export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
5
5
  x: number;
6
6
  y: number;
7
7
  width: number;
@@ -1,7 +1,7 @@
1
1
  import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "@excalidraw/element/types";
2
2
  import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
4
- import type { ElementUpdate } from "./mutateElement";
4
+ import { StoreSnapshot } from "./store";
5
5
  /**
6
6
  * Represents the difference between two objects of the same type.
7
7
  *
@@ -15,7 +15,7 @@ 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
  *
@@ -55,6 +55,14 @@ export declare class Delta<T> {
55
55
  * Compares if object2 contains any different value compared to the object1.
56
56
  */
57
57
  static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
+ /**
59
+ * Compares if shared properties of object1 and object2 contain any different value (aka inner join).
60
+ */
61
+ static isInnerDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
62
+ /**
63
+ * Compares if any properties of object1 and object2 contain any different value (aka full join).
64
+ */
65
+ static isDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
66
  /**
59
67
  * Returns sorted object1 keys that have distinct values.
60
68
  */
@@ -63,6 +71,14 @@ export declare class Delta<T> {
63
71
  * Returns sorted object2 keys that have distinct values.
64
72
  */
65
73
  static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
74
+ /**
75
+ * Returns sorted keys of shared object1 and object2 properties that have distinct values (aka inner join).
76
+ */
77
+ static getInnerDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
78
+ /**
79
+ * Returns sorted keys that have distinct values between object1 and object2 (aka full join).
80
+ */
81
+ static getDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
66
82
  /**
67
83
  * Iterator comparing values of object properties based on the passed joining strategy.
68
84
  *
@@ -118,7 +134,10 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
118
134
  private static postProcess;
119
135
  private static orderAppStateKeys;
120
136
  }
121
- type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> = Omit<ElementUpdate<Ordered<T>>, "seed">;
137
+ type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
138
+ export type ApplyToOptions = {
139
+ excludedProperties: Set<keyof ElementPartial>;
140
+ };
122
141
  /**
123
142
  * Elements change is a low level primitive to capture a change between two sets of elements.
124
143
  * It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
@@ -135,6 +154,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
135
154
  private static satisfiesAddition;
136
155
  private static satisfiesRemoval;
137
156
  private static satisfiesUpdate;
157
+ private static satisfiesCommmonInvariants;
138
158
  private static validate;
139
159
  /**
140
160
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -151,12 +171,12 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
151
171
  /**
152
172
  * Update delta/s based on the existing elements.
153
173
  *
154
- * @param elements current elements
174
+ * @param nextElements current elements
155
175
  * @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
156
176
  * @returns new instance with modified delta/s
157
177
  */
158
- applyLatestChanges(elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): ElementsDelta;
159
- applyTo(elements: SceneElementsMap, elementsSnapshot: Map<string, OrderedExcalidrawElement>): [SceneElementsMap, boolean];
178
+ applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
179
+ applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
160
180
  private static createApplier;
161
181
  private static createGetter;
162
182
  private static applyDelta;
@@ -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,4 +1,4 @@
1
- import type { ElementsMap, 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
  }
@@ -44,8 +44,14 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
44
44
  */
45
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;
@@ -37,6 +37,7 @@ export declare class LinearElementEditor {
37
37
  readonly hoverPointIndex: number;
38
38
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
39
39
  readonly elbowed: boolean;
40
+ readonly customLineAngle: number | null;
40
41
  constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap);
41
42
  static POINT_HANDLE_SIZE: number;
42
43
  /**
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
- export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
4
4
  /**
5
5
  * This function tracks updates of text elements for the purposes for collaboration.
6
6
  * The version is used to compare updates when more than one user is working in
@@ -16,7 +16,7 @@ export declare const mapIntervalToBezierT: <P extends GlobalPoint | LocalPoint>(
16
16
  /**
17
17
  * Get the axis-aligned bounding box for a given element
18
18
  */
19
- export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, offset?: [number, number, number, number]) => Bounds;
19
+ export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
20
20
  export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
21
21
  export declare const aabbsOverlapping: (a: Bounds, b: Bounds) => boolean;
22
22
  export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
@@ -23,7 +23,7 @@ export declare const getPerfectElementSize: (elementType: AppState["activeTool"]
23
23
  width: number;
24
24
  height: number;
25
25
  };
26
- export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number) => {
26
+ export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number, customAngle?: number) => {
27
27
  width: number;
28
28
  height: number;
29
29
  };
@@ -3,7 +3,7 @@ import type App from "@excalidraw/excalidraw/components/App";
3
3
  import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
4
4
  import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
5
5
  import { ElementsDelta, AppStateDelta } from "./delta";
6
- import type { OrderedExcalidrawElement, SceneElementsMap } from "./types";
6
+ import type { ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
7
7
  export declare const CaptureUpdateAction: {
8
8
  /**
9
9
  * Immediately undoable.
@@ -60,7 +60,7 @@ export declare class Store {
60
60
  */
61
61
  scheduleMicroAction(params: {
62
62
  action: CaptureUpdateActionType;
63
- elements: SceneElementsMap | undefined;
63
+ elements: readonly ExcalidrawElement[] | undefined;
64
64
  appState: AppState | ObservedAppState | undefined;
65
65
  } | {
66
66
  action: typeof CaptureUpdateAction.IMMEDIATELY;
@@ -157,6 +157,10 @@ export declare class StoreDelta {
157
157
  static create(elements: ElementsDelta, appState: AppStateDelta, opts?: {
158
158
  id: string;
159
159
  }): StoreDelta;
160
+ /**
161
+ * Calculate the delta between the previous and next snapshot.
162
+ */
163
+ static calculate(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreDelta;
160
164
  /**
161
165
  * Restore a store delta instance from a DTO.
162
166
  */
@@ -170,13 +174,13 @@ export declare class StoreDelta {
170
174
  */
171
175
  static inverse(delta: StoreDelta): StoreDelta;
172
176
  /**
173
- * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
177
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
174
178
  */
175
- static applyLatestChanges(delta: StoreDelta, elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): StoreDelta;
179
+ static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState): [SceneElementsMap, AppState, boolean];
176
180
  /**
177
- * Apply the delta to the passed elements and appState, does not modify the snapshot.
181
+ * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
178
182
  */
179
- static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, prevSnapshot?: StoreSnapshot): [SceneElementsMap, AppState, boolean];
183
+ static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
180
184
  isEmpty(): boolean;
181
185
  }
182
186
  /**
@@ -224,4 +228,4 @@ export declare class StoreSnapshot {
224
228
  */
225
229
  private createElementsSnapshot;
226
230
  }
227
- export declare const getObservedAppState: (appState: AppState) => ObservedAppState;
231
+ export declare const getObservedAppState: (appState: AppState | ObservedAppState) => ObservedAppState;
@@ -17,6 +17,10 @@ export declare const isLinearElement: (element?: ExcalidrawElement | null) => el
17
17
  export declare const isLineElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLineElement;
18
18
  export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawArrowElement;
19
19
  export declare const isElbowArrow: (element?: ExcalidrawElement) => element is ExcalidrawElbowArrowElement;
20
+ /**
21
+ * sharp or curved arrow, but not elbow
22
+ */
23
+ export declare const isSimpleArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
20
24
  export declare const isSharpArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
21
25
  export declare const isCurvedArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
22
26
  export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
@@ -153,7 +153,7 @@ export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagi
153
153
  */
154
154
  export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
155
155
  export type ExcalidrawFlowchartNodeElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
156
- export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement;
156
+ export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawSelectionElement;
157
157
  /**
158
158
  * ExcalidrawElement should be JSON serializable and (eventually) contain
159
159
  * no computed data. The list of all ExcalidrawElements should be shareable
@@ -1,6 +1,7 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { Curve, LineSegment } from "@excalidraw/math";
3
- import type { ExcalidrawDiamondElement, ExcalidrawRectanguloidElement } from "./types";
3
+ import type { ElementsMap, ExcalidrawDiamondElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, ExcalidrawRectanguloidElement } from "./types";
4
+ export declare function deconstructLinearOrFreeDrawElement(element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement, elementsMap: ElementsMap): [LineSegment<GlobalPoint>[], Curve<GlobalPoint>[]];
4
5
  /**
5
6
  * Get the building components of a rectanguloid element in the form of
6
7
  * line segments and curves.
@@ -153,7 +153,6 @@ export declare const actionAddToLibrary: {
153
153
  shown: true;
154
154
  data: import("../charts").Spreadsheet;
155
155
  };
156
- pendingImageElementId: string | null;
157
156
  showHyperlinkPopup: false | "info" | "editor";
158
157
  linkOpacity: number;
159
158
  trayModeEnabled: boolean;
@@ -363,7 +362,6 @@ export declare const actionAddToLibrary: {
363
362
  shown: true;
364
363
  data: import("../charts").Spreadsheet;
365
364
  };
366
- pendingImageElementId: string | null;
367
365
  showHyperlinkPopup: false | "info" | "editor";
368
366
  linkOpacity: number;
369
367
  trayModeEnabled: boolean;
@@ -573,7 +571,6 @@ export declare const actionAddToLibrary: {
573
571
  shown: true;
574
572
  data: import("../charts").Spreadsheet;
575
573
  };
576
- pendingImageElementId: string | null;
577
574
  showHyperlinkPopup: false | "info" | "editor";
578
575
  linkOpacity: number;
579
576
  trayModeEnabled: boolean;
@@ -175,7 +175,6 @@ export declare const actionBindText: {
175
175
  shown: true;
176
176
  data: import("../charts").Spreadsheet;
177
177
  };
178
- pendingImageElementId: string | null;
179
178
  showHyperlinkPopup: false | "info" | "editor";
180
179
  linkOpacity: number;
181
180
  trayModeEnabled: boolean;
@@ -397,7 +396,6 @@ export declare const actionWrapTextInContainer: {
397
396
  shown: true;
398
397
  data: import("../charts").Spreadsheet;
399
398
  };
400
- pendingImageElementId: string | null;
401
399
  showHyperlinkPopup: false | "info" | "editor";
402
400
  linkOpacity: number;
403
401
  trayModeEnabled: boolean;
@@ -186,7 +186,6 @@ export declare const actionClearCanvas: {
186
186
  isMuted?: boolean | undefined;
187
187
  }>>;
188
188
  currentChartType: import("@excalidraw/element/types").ChartType;
189
- pendingImageElementId: string | null;
190
189
  showHyperlinkPopup: false | "info" | "editor";
191
190
  linkOpacity: number;
192
191
  currentStrokeOptions?: any;
@@ -394,7 +393,6 @@ export declare const actionZoomIn: {
394
393
  shown: true;
395
394
  data: import("../charts").Spreadsheet;
396
395
  };
397
- pendingImageElementId: string | null;
398
396
  showHyperlinkPopup: false | "info" | "editor";
399
397
  linkOpacity: number;
400
398
  trayModeEnabled: boolean;
@@ -618,7 +616,6 @@ export declare const actionZoomOut: {
618
616
  shown: true;
619
617
  data: import("../charts").Spreadsheet;
620
618
  };
621
- pendingImageElementId: string | null;
622
619
  showHyperlinkPopup: false | "info" | "editor";
623
620
  linkOpacity: number;
624
621
  trayModeEnabled: boolean;
@@ -842,7 +839,6 @@ export declare const actionResetZoom: {
842
839
  shown: true;
843
840
  data: import("../charts").Spreadsheet;
844
841
  };
845
- pendingImageElementId: string | null;
846
842
  showHyperlinkPopup: false | "info" | "editor";
847
843
  linkOpacity: number;
848
844
  trayModeEnabled: boolean;
@@ -1072,7 +1068,6 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fitToV
1072
1068
  shown: true;
1073
1069
  data: import("../charts").Spreadsheet;
1074
1070
  };
1075
- pendingImageElementId: string | null;
1076
1071
  showHyperlinkPopup: false | "info" | "editor";
1077
1072
  linkOpacity: number;
1078
1073
  trayModeEnabled: boolean;
@@ -1298,7 +1293,6 @@ export declare const zoomToFit: ({ canvasOffsets, targetElements, appState, fitT
1298
1293
  shown: true;
1299
1294
  data: import("../charts").Spreadsheet;
1300
1295
  };
1301
- pendingImageElementId: string | null;
1302
1296
  showHyperlinkPopup: false | "info" | "editor";
1303
1297
  linkOpacity: number;
1304
1298
  trayModeEnabled: boolean;
@@ -1516,7 +1510,6 @@ export declare const actionZoomToFitSelectionInViewport: {
1516
1510
  shown: true;
1517
1511
  data: import("../charts").Spreadsheet;
1518
1512
  };
1519
- pendingImageElementId: string | null;
1520
1513
  showHyperlinkPopup: false | "info" | "editor";
1521
1514
  linkOpacity: number;
1522
1515
  trayModeEnabled: boolean;
@@ -1738,7 +1731,6 @@ export declare const actionZoomToFitSelection: {
1738
1731
  shown: true;
1739
1732
  data: import("../charts").Spreadsheet;
1740
1733
  };
1741
- pendingImageElementId: string | null;
1742
1734
  showHyperlinkPopup: false | "info" | "editor";
1743
1735
  linkOpacity: number;
1744
1736
  trayModeEnabled: boolean;
@@ -1961,7 +1953,6 @@ export declare const actionZoomToFit: {
1961
1953
  shown: true;
1962
1954
  data: import("../charts").Spreadsheet;
1963
1955
  };
1964
- pendingImageElementId: string | null;
1965
1956
  showHyperlinkPopup: false | "info" | "editor";
1966
1957
  linkOpacity: number;
1967
1958
  trayModeEnabled: boolean;
@@ -2185,7 +2176,6 @@ export declare const actionToggleTheme: {
2185
2176
  shown: true;
2186
2177
  data: import("../charts").Spreadsheet;
2187
2178
  };
2188
- pendingImageElementId: string | null;
2189
2179
  showHyperlinkPopup: false | "info" | "editor";
2190
2180
  linkOpacity: number;
2191
2181
  trayModeEnabled: boolean;
@@ -2400,7 +2390,6 @@ export declare const actionToggleEraserTool: {
2400
2390
  shown: true;
2401
2391
  data: import("../charts").Spreadsheet;
2402
2392
  };
2403
- pendingImageElementId: string | null;
2404
2393
  showHyperlinkPopup: false | "info" | "editor";
2405
2394
  linkOpacity: number;
2406
2395
  trayModeEnabled: boolean;
@@ -2615,7 +2604,6 @@ export declare const actionToggleLassoTool: {
2615
2604
  shown: true;
2616
2605
  data: import("../charts").Spreadsheet;
2617
2606
  };
2618
- pendingImageElementId: string | null;
2619
2607
  showHyperlinkPopup: false | "info" | "editor";
2620
2608
  linkOpacity: number;
2621
2609
  trayModeEnabled: boolean;
@@ -2830,7 +2818,6 @@ export declare const actionToggleHandTool: {
2830
2818
  shown: true;
2831
2819
  data: import("../charts").Spreadsheet;
2832
2820
  };
2833
- pendingImageElementId: string | null;
2834
2821
  showHyperlinkPopup: false | "info" | "editor";
2835
2822
  linkOpacity: number;
2836
2823
  trayModeEnabled: boolean;
@@ -3044,7 +3031,6 @@ export declare const actionToggleLaserPointer: {
3044
3031
  shown: true;
3045
3032
  data: import("../charts").Spreadsheet;
3046
3033
  };
3047
- pendingImageElementId: string | null;
3048
3034
  showHyperlinkPopup: false | "info" | "editor";
3049
3035
  linkOpacity: number;
3050
3036
  trayModeEnabled: boolean;
@@ -3261,7 +3247,6 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
3261
3247
  shown: true;
3262
3248
  data: import("../charts").Spreadsheet;
3263
3249
  };
3264
- pendingImageElementId: string | null;
3265
3250
  showHyperlinkPopup: false | "info" | "editor";
3266
3251
  linkOpacity: number;
3267
3252
  trayModeEnabled: boolean;
@@ -157,7 +157,6 @@ export declare const actionCopy: {
157
157
  shown: true;
158
158
  data: import("../charts").Spreadsheet;
159
159
  };
160
- pendingImageElementId: string | null;
161
160
  showHyperlinkPopup: false | "info" | "editor";
162
161
  linkOpacity: number;
163
162
  trayModeEnabled: boolean;
@@ -381,7 +380,6 @@ export declare const actionPaste: {
381
380
  shown: true;
382
381
  data: import("../charts").Spreadsheet;
383
382
  };
384
- pendingImageElementId: string | null;
385
383
  showHyperlinkPopup: false | "info" | "editor";
386
384
  linkOpacity: number;
387
385
  trayModeEnabled: boolean;
@@ -606,7 +604,6 @@ export declare const actionCut: {
606
604
  shown: true;
607
605
  data: import("../charts").Spreadsheet;
608
606
  };
609
- pendingImageElementId: string | null;
610
607
  showHyperlinkPopup: false | "info" | "editor";
611
608
  linkOpacity: number;
612
609
  trayModeEnabled: boolean;
@@ -698,6 +695,7 @@ export declare const actionCut: {
698
695
  hoverPointIndex: number;
699
696
  segmentMidPointHoveredCoords: import("@excalidraw/math").GlobalPoint | null;
700
697
  elbowed: boolean;
698
+ customLineAngle: number | null;
701
699
  };
702
700
  contextMenu: {
703
701
  items: import("../components/ContextMenu").ContextMenuItems;
@@ -847,7 +845,6 @@ export declare const actionCut: {
847
845
  shown: true;
848
846
  data: import("../charts").Spreadsheet;
849
847
  };
850
- pendingImageElementId: string | null;
851
848
  showHyperlinkPopup: false | "info" | "editor";
852
849
  linkOpacity: number;
853
850
  trayModeEnabled: boolean;
@@ -1056,7 +1053,6 @@ export declare const actionCut: {
1056
1053
  shown: true;
1057
1054
  data: import("../charts").Spreadsheet;
1058
1055
  };
1059
- pendingImageElementId: string | null;
1060
1056
  showHyperlinkPopup: false | "info" | "editor";
1061
1057
  linkOpacity: number;
1062
1058
  trayModeEnabled: boolean;
@@ -1310,7 +1306,6 @@ export declare const actionCopyAsPng: {
1310
1306
  shown: true;
1311
1307
  data: import("../charts").Spreadsheet;
1312
1308
  };
1313
- pendingImageElementId: string | null;
1314
1309
  showHyperlinkPopup: false | "info" | "editor";
1315
1310
  linkOpacity: number;
1316
1311
  trayModeEnabled: boolean;