@zsviczian/excalidraw 0.17.1-obsidian-20 → 0.17.1-obsidian-21

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 (82) hide show
  1. package/dist/excalidraw.development.js +190 -80
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/styles.development.css +78 -50
  4. package/dist/styles.production.css +5 -5
  5. package/package.json +2 -1
  6. package/types/excalidraw/actions/actionAddToLibrary.d.ts +4 -4
  7. package/types/excalidraw/actions/actionAlign.d.ts +20 -20
  8. package/types/excalidraw/actions/actionBoundText.d.ts +7 -7
  9. package/types/excalidraw/actions/actionCanvas.d.ts +65 -65
  10. package/types/excalidraw/actions/actionClipboard.d.ts +24 -24
  11. package/types/excalidraw/actions/actionDeleteSelected.d.ts +8 -8
  12. package/types/excalidraw/actions/actionDistribute.d.ts +8 -8
  13. package/types/excalidraw/actions/actionDuplicateSelection.d.ts +5 -6
  14. package/types/excalidraw/actions/actionElementLock.d.ts +8 -8
  15. package/types/excalidraw/actions/actionExport.d.ts +32 -32
  16. package/types/excalidraw/actions/actionFinalize.d.ts +8 -8
  17. package/types/excalidraw/actions/actionFlip.d.ts +9 -9
  18. package/types/excalidraw/actions/actionFrame.d.ts +14 -202
  19. package/types/excalidraw/actions/actionGroup.d.ts +11 -387
  20. package/types/excalidraw/actions/actionHistory.d.ts +3 -2
  21. package/types/excalidraw/actions/actionLinearEditor.d.ts +2 -2
  22. package/types/excalidraw/actions/actionLink.d.ts +5 -5
  23. package/types/excalidraw/actions/actionMenu.d.ts +8 -8
  24. package/types/excalidraw/actions/actionNavigate.d.ts +3 -3
  25. package/types/excalidraw/actions/actionProperties.d.ts +32 -32
  26. package/types/excalidraw/actions/actionSelectAll.d.ts +4 -4
  27. package/types/excalidraw/actions/actionStyles.d.ts +9 -12
  28. package/types/excalidraw/actions/actionToggleGridMode.d.ts +6 -4
  29. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
  30. package/types/excalidraw/actions/actionToggleStats.d.ts +4 -4
  31. package/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
  32. package/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
  33. package/types/excalidraw/actions/actionZindex.d.ts +18 -19
  34. package/types/excalidraw/actions/manager.d.ts +3 -3
  35. package/types/excalidraw/actions/types.d.ts +4 -4
  36. package/types/excalidraw/appState.d.ts +4 -4
  37. package/types/excalidraw/change.d.ts +191 -0
  38. package/types/excalidraw/components/App.d.ts +22 -8
  39. package/types/excalidraw/components/RadioGroup.d.ts +2 -1
  40. package/types/excalidraw/components/ToolButton.d.ts +1 -0
  41. package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
  42. package/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +17 -0
  43. package/types/excalidraw/components/icons.d.ts +4 -0
  44. package/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -2
  45. package/types/excalidraw/constants.d.ts +3 -0
  46. package/types/excalidraw/data/reconcile.d.ts +6 -0
  47. package/types/excalidraw/data/restore.d.ts +3 -3
  48. package/types/excalidraw/data/transform.d.ts +1 -1
  49. package/types/excalidraw/data/url.d.ts +1 -0
  50. package/types/excalidraw/element/binding.d.ts +52 -9
  51. package/types/excalidraw/element/bounds.d.ts +0 -1
  52. package/types/excalidraw/element/collision.d.ts +14 -19
  53. package/types/excalidraw/element/embeddable.d.ts +7 -4
  54. package/types/excalidraw/element/index.d.ts +0 -1
  55. package/types/excalidraw/element/linearElementEditor.d.ts +12 -12
  56. package/types/excalidraw/element/mutateElement.d.ts +1 -2
  57. package/types/excalidraw/element/newElement.d.ts +1 -1
  58. package/types/excalidraw/element/resizeElements.d.ts +1 -1
  59. package/types/excalidraw/element/resizeTest.d.ts +4 -4
  60. package/types/excalidraw/element/textElement.d.ts +1 -2
  61. package/types/excalidraw/element/transformHandles.d.ts +22 -4
  62. package/types/excalidraw/element/typeChecks.d.ts +2 -2
  63. package/types/excalidraw/element/types.d.ts +22 -6
  64. package/types/excalidraw/errors.d.ts +3 -0
  65. package/types/excalidraw/fractionalIndex.d.ts +40 -0
  66. package/types/excalidraw/frame.d.ts +1 -1
  67. package/types/excalidraw/groups.d.ts +2 -0
  68. package/types/excalidraw/history.d.ts +34 -46
  69. package/types/excalidraw/hooks/useEmitter.d.ts +2 -0
  70. package/types/excalidraw/index.d.ts +2 -0
  71. package/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  72. package/types/excalidraw/scene/Scene.d.ts +7 -6
  73. package/types/excalidraw/scene/types.d.ts +2 -1
  74. package/types/excalidraw/store.d.ts +99 -0
  75. package/types/excalidraw/types.d.ts +18 -4
  76. package/types/excalidraw/utils.d.ts +7 -0
  77. package/types/excalidraw/webpack.prod.config.d.ts +1 -1
  78. package/types/excalidraw/zindex.d.ts +2 -2
  79. package/types/utils/collision.d.ts +4 -0
  80. package/types/utils/export.d.ts +2 -2
  81. package/types/utils/geometry/geometry.d.ts +71 -0
  82. package/types/utils/geometry/shape.d.ts +56 -0
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  export declare const actionSendBackward: {
3
2
  name: "sendBackward";
4
3
  label: string;
@@ -6,16 +5,16 @@ export declare const actionSendBackward: {
6
5
  trackEvent: {
7
6
  category: "element";
8
7
  };
9
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
10
- elements: import("../element/types").ExcalidrawElement[];
8
+ perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
9
+ elements: readonly import("../element/types").ExcalidrawElement[];
11
10
  appState: Readonly<import("../types").AppState>;
12
- commitToHistory: true;
11
+ storeAction: import("../store").StoreActionType;
13
12
  };
14
13
  keyPriority: number;
15
- keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
14
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
16
15
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
17
16
  } & {
18
- keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
17
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
19
18
  };
20
19
  export declare const actionBringForward: {
21
20
  name: "bringForward";
@@ -24,16 +23,16 @@ export declare const actionBringForward: {
24
23
  trackEvent: {
25
24
  category: "element";
26
25
  };
27
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
28
- elements: import("../element/types").ExcalidrawElement[];
26
+ perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
27
+ elements: readonly import("../element/types").ExcalidrawElement[];
29
28
  appState: Readonly<import("../types").AppState>;
30
- commitToHistory: true;
29
+ storeAction: import("../store").StoreActionType;
31
30
  };
32
31
  keyPriority: number;
33
- keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
32
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
34
33
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
35
34
  } & {
36
- keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
35
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
37
36
  };
38
37
  export declare const actionSendToBack: {
39
38
  name: "sendToBack";
@@ -42,15 +41,15 @@ export declare const actionSendToBack: {
42
41
  trackEvent: {
43
42
  category: "element";
44
43
  };
45
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
44
+ perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
46
45
  elements: readonly import("../element/types").ExcalidrawElement[] | import("../element/types").ExcalidrawElement[];
47
46
  appState: Readonly<import("../types").AppState>;
48
- commitToHistory: true;
47
+ storeAction: import("../store").StoreActionType;
49
48
  };
50
- keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
49
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
51
50
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
52
51
  } & {
53
- keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
52
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
54
53
  };
55
54
  export declare const actionBringToFront: {
56
55
  name: "bringToFront";
@@ -59,13 +58,13 @@ export declare const actionBringToFront: {
59
58
  trackEvent: {
60
59
  category: "element";
61
60
  };
62
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
61
+ perform: (elements: readonly import("../element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
63
62
  elements: readonly import("../element/types").ExcalidrawElement[] | import("../element/types").ExcalidrawElement[];
64
63
  appState: Readonly<import("../types").AppState>;
65
- commitToHistory: true;
64
+ storeAction: import("../store").StoreActionType;
66
65
  };
67
- keyTest: (event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean;
66
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
68
67
  PanelComponent: ({ updateData, appState }: import("./types").PanelComponentProps) => import("react/jsx-runtime").JSX.Element;
69
68
  } & {
70
- keyTest?: ((event: React.KeyboardEvent<Element> | KeyboardEvent) => boolean) | undefined;
69
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
71
70
  };
@@ -1,14 +1,14 @@
1
1
  import React from "react";
2
2
  import { Action, UpdaterFn, ActionName, ActionResult, PanelComponentProps, ActionSource } from "./types";
3
- import { ExcalidrawElement } from "../element/types";
3
+ import { OrderedExcalidrawElement } from "../element/types";
4
4
  import { AppClassProperties, AppState } from "../types";
5
5
  export declare class ActionManager {
6
6
  actions: Record<ActionName, Action>;
7
7
  updater: (actionResult: ActionResult | Promise<ActionResult>) => void;
8
8
  getAppState: () => Readonly<AppState>;
9
- getElementsIncludingDeleted: () => readonly ExcalidrawElement[];
9
+ getElementsIncludingDeleted: () => readonly OrderedExcalidrawElement[];
10
10
  app: AppClassProperties;
11
- constructor(updater: UpdaterFn, getAppState: () => AppState, getElementsIncludingDeleted: () => readonly ExcalidrawElement[], app: AppClassProperties);
11
+ constructor(updater: UpdaterFn, getAppState: () => AppState, getElementsIncludingDeleted: () => readonly OrderedExcalidrawElement[], app: AppClassProperties);
12
12
  registerAction(action: Action): void;
13
13
  registerAll(actions: readonly Action[]): void;
14
14
  handleKeyDown(event: React.KeyboardEvent | KeyboardEvent): boolean;
@@ -1,18 +1,18 @@
1
1
  import React from "react";
2
- import { ExcalidrawElement } from "../element/types";
2
+ import { ExcalidrawElement, OrderedExcalidrawElement } from "../element/types";
3
3
  import { AppClassProperties, AppState, ExcalidrawProps, BinaryFiles, UIAppState } from "../types";
4
4
  import { MarkOptional } from "../utility-types";
5
+ import { StoreActionType } from "../store";
5
6
  export type ActionSource = "ui" | "keyboard" | "contextMenu" | "api" | "commandPalette";
6
7
  /** if false, the action should be prevented */
7
8
  export type ActionResult = {
8
9
  elements?: readonly ExcalidrawElement[] | null;
9
10
  appState?: MarkOptional<AppState, "offsetTop" | "offsetLeft" | "width" | "height"> | null;
10
11
  files?: BinaryFiles | null;
11
- commitToHistory: boolean;
12
- syncHistory?: boolean;
12
+ storeAction: StoreActionType;
13
13
  replaceFiles?: boolean;
14
14
  } | false;
15
- type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
15
+ type ActionFn = (elements: readonly OrderedExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
16
16
  export type UpdaterFn = (res: ActionResult) => void;
17
17
  export type ActionFilterFn = (action: Action) => void;
18
18
  export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "setFrameAsActiveTool" | "setEmbeddableAsActiveTool" | "createContainerFromText" | "wrapTextInContainer" | "toggleLaserPointerTool" | "commandPalette";
@@ -1,6 +1,10 @@
1
1
  import { AppState, NormalizedZoomValue } from "./types";
2
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
+ zenModeEnabled?: boolean | undefined;
5
+ objectsSnapModeEnabled?: boolean | undefined;
6
+ theme?: import("./element/types").Theme | undefined;
7
+ name?: string | null | undefined;
4
8
  showWelcomeScreen?: boolean | undefined;
5
9
  activeTool?: ({
6
10
  lastActiveTool: import("./types").ActiveTool | null;
@@ -30,7 +34,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
30
34
  scrollY?: number | undefined;
31
35
  cursorButton?: "up" | "down" | undefined;
32
36
  scrolledOutside?: boolean | undefined;
33
- name?: string | null | undefined;
34
37
  zoom?: Readonly<{
35
38
  value: NormalizedZoomValue;
36
39
  }> | undefined;
@@ -48,8 +51,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
48
51
  [id: string]: true;
49
52
  } | undefined;
50
53
  shouldCacheIgnoreZoom?: boolean | undefined;
51
- zenModeEnabled?: boolean | undefined;
52
- theme?: import("./element/types").Theme | undefined;
53
54
  gridSize?: number | null | undefined;
54
55
  selectedGroupIds?: {
55
56
  [groupId: string]: boolean;
@@ -58,7 +59,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
58
59
  showStats?: boolean | undefined;
59
60
  currentChartType?: import("./element/types").ChartType | undefined;
60
61
  selectedLinearElement?: import("./element/linearElementEditor").LinearElementEditor | null | undefined;
61
- objectsSnapModeEnabled?: boolean | undefined;
62
62
  };
63
63
  export declare const cleanAppStateForExport: (appState: Partial<AppState>) => {
64
64
  viewBackgroundColor?: string | undefined;
@@ -0,0 +1,191 @@
1
+ import { ElementUpdate } from "./element/mutateElement";
2
+ import { OrderedExcalidrawElement, SceneElementsMap } from "./element/types";
3
+ import { AppState, ObservedAppState } from "./types";
4
+ import { ValueOf } from "./utility-types";
5
+ /**
6
+ * Represents the difference between two objects of the same type.
7
+ *
8
+ * Both `deleted` and `inserted` partials represent the same set of added, removed or updated properties, where:
9
+ * - `deleted` is a set of all the deleted values
10
+ * - `inserted` is a set of all the inserted (added, updated) values
11
+ *
12
+ * Keeping it as pure object (without transient state, side-effects, etc.), so we won't have to instantiate it on load.
13
+ */
14
+ declare class Delta<T> {
15
+ readonly deleted: Partial<T>;
16
+ readonly inserted: Partial<T>;
17
+ private constructor();
18
+ static create<T>(deleted: Partial<T>, inserted: Partial<T>, modifier?: (delta: Partial<T>) => Partial<T>, modifierOptions?: "deleted" | "inserted"): Delta<T>;
19
+ /**
20
+ * Calculates the delta between two objects.
21
+ *
22
+ * @param prevObject - The previous state of the object.
23
+ * @param nextObject - The next state of the object.
24
+ *
25
+ * @returns new delta instance.
26
+ */
27
+ static calculate<T extends {
28
+ [key: string]: any;
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
+ static empty(): Delta<unknown>;
31
+ static isEmpty<T>(delta: Delta<T>): boolean;
32
+ /**
33
+ * Merges deleted and inserted object partials.
34
+ */
35
+ static mergeObjects<T extends {
36
+ [key: string]: unknown;
37
+ }>(prev: T, added: T, removed: T): T;
38
+ /**
39
+ * Merges deleted and inserted array partials.
40
+ */
41
+ static mergeArrays<T>(prev: readonly T[] | null, added: readonly T[] | null | undefined, removed: readonly T[] | null | undefined, predicate?: (value: T) => string): T[];
42
+ /**
43
+ * Diff object partials as part of the `postProcess`.
44
+ */
45
+ static diffObjects<T, K extends keyof T, V extends ValueOf<T[K]>>(deleted: Partial<T>, inserted: Partial<T>, property: K, setValue: (prevValue: V | undefined) => V): void;
46
+ /**
47
+ * Diff array partials as part of the `postProcess`.
48
+ */
49
+ static diffArrays<T, K extends keyof T, V extends T[K]>(deleted: Partial<T>, inserted: Partial<T>, property: K, groupBy: (value: V extends ArrayLike<infer T> ? T : never) => string): void;
50
+ /**
51
+ * Compares if object1 contains any different value compared to the object2.
52
+ */
53
+ static isLeftDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
54
+ /**
55
+ * Compares if object2 contains any different value compared to the object1.
56
+ */
57
+ static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
58
+ /**
59
+ * Returns all the object1 keys that have distinct values.
60
+ */
61
+ static getLeftDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
62
+ /**
63
+ * Returns all the object2 keys that have distinct values.
64
+ */
65
+ static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
66
+ /**
67
+ * Iterator comparing values of object properties based on the passed joining strategy.
68
+ *
69
+ * @yields keys of properties with different values
70
+ *
71
+ * WARN: it's based on shallow compare performed only on the first level and doesn't go deeper than that.
72
+ */
73
+ private static distinctKeysIterator;
74
+ }
75
+ /**
76
+ * Encapsulates the modifications captured as `Delta`/s.
77
+ */
78
+ interface Change<T> {
79
+ /**
80
+ * Inverses the `Delta`s inside while creating a new `Change`.
81
+ */
82
+ inverse(): Change<T>;
83
+ /**
84
+ * Applies the `Change` to the previous object.
85
+ *
86
+ * @returns a tuple of the next object `T` with applied change, and `boolean`, indicating whether the applied change resulted in a visible change.
87
+ */
88
+ applyTo(previous: T, ...options: unknown[]): [T, boolean];
89
+ /**
90
+ * Checks whether there are actually `Delta`s.
91
+ */
92
+ isEmpty(): boolean;
93
+ }
94
+ export declare class AppStateChange implements Change<AppState> {
95
+ private readonly delta;
96
+ private constructor();
97
+ static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateChange;
98
+ static empty(): AppStateChange;
99
+ inverse(): AppStateChange;
100
+ applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
101
+ 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
+ /**
108
+ * Mutates `nextAppState` be filtering out state related to deleted elements.
109
+ *
110
+ * @returns `true` if a visible change is found, `false` otherwise.
111
+ */
112
+ private filterInvisibleChanges;
113
+ private static convertToAppStateKey;
114
+ private static filterSelectedElements;
115
+ private static filterSelectedGroups;
116
+ private static stripElementsProps;
117
+ private static stripStandaloneProps;
118
+ }
119
+ type ElementPartial = Omit<ElementUpdate<OrderedExcalidrawElement>, "seed">;
120
+ /**
121
+ * Elements change is a low level primitive to capture a change between two sets of elements.
122
+ * It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
123
+ */
124
+ export declare class ElementsChange implements Change<SceneElementsMap> {
125
+ private readonly added;
126
+ private readonly removed;
127
+ private readonly updated;
128
+ private constructor();
129
+ static create(added: Map<string, Delta<ElementPartial>>, removed: Map<string, Delta<ElementPartial>>, updated: Map<string, Delta<ElementPartial>>, options?: {
130
+ shouldRedistribute: boolean;
131
+ }): ElementsChange;
132
+ private static satisfiesAddition;
133
+ private static satisfiesRemoval;
134
+ private static satisfiesUpdate;
135
+ private static validate;
136
+ /**
137
+ * Calculates the `Delta`s between the previous and next set of elements.
138
+ *
139
+ * @param prevElements - Map representing the previous state of elements.
140
+ * @param nextElements - Map representing the next state of elements.
141
+ *
142
+ * @returns `ElementsChange` instance representing the `Delta` changes between the two sets of elements.
143
+ */
144
+ static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsChange;
145
+ static empty(): ElementsChange;
146
+ inverse(): ElementsChange;
147
+ isEmpty(): boolean;
148
+ /**
149
+ * Update delta/s based on the existing elements.
150
+ *
151
+ * @param elements current elements
152
+ * @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
153
+ * @returns new instance with modified delta/s
154
+ */
155
+ applyLatestChanges(elements: SceneElementsMap): ElementsChange;
156
+ applyTo(elements: SceneElementsMap, snapshot: Map<string, OrderedExcalidrawElement>): [SceneElementsMap, boolean];
157
+ private static createApplier;
158
+ private static createGetter;
159
+ private static applyDelta;
160
+ /**
161
+ * Check for visible changes regardless of whether they were removed, added or updated.
162
+ */
163
+ private static checkForVisibleDifference;
164
+ /**
165
+ * Resolves conflicts for all previously added, removed and updated elements.
166
+ * Updates the previous deltas with all the changes after conflict resolution.
167
+ *
168
+ * @returns all elements affected by the conflict resolution
169
+ */
170
+ private resolveConflicts;
171
+ /**
172
+ * Non deleted affected elements of removed elements (before and after applying delta),
173
+ * should be unbound ~ bindings should not point from non deleted into the deleted element/s.
174
+ */
175
+ private static unbindAffected;
176
+ /**
177
+ * Non deleted affected elements of added or updated element/s (before and after applying delta),
178
+ * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
179
+ */
180
+ private static rebindAffected;
181
+ private static redrawTextBoundingBoxes;
182
+ private static redrawBoundArrows;
183
+ private static reorderElements;
184
+ /**
185
+ * It is necessary to post process the partials in case of reference values,
186
+ * for which we need to calculate the real diff between `deleted` and `inserted`.
187
+ */
188
+ private static postProcess;
189
+ private static stripIrrelevantProps;
190
+ }
191
+ export {};
@@ -4,13 +4,15 @@ import { ActionManager } from "../actions/manager";
4
4
  import { EXPORT_IMAGE_TYPES } from "../constants";
5
5
  import { ExportedElements } from "../data";
6
6
  import { LinearElementEditor } from "../element/linearElementEditor";
7
- import { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement } from "../element/types";
8
- import History from "../history";
7
+ import { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered } from "../element/types";
8
+ import { History } from "../history";
9
9
  import Scene from "../scene/Scene";
10
+ import { GeometricShape } from "../../utils/geometry/shape";
10
11
  import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload } from "../types";
11
12
  import { FileSystemHandle } from "../data/filesystem";
12
13
  import { Renderer } from "../scene/Renderer";
13
14
  import { Emitter } from "../emitter";
15
+ import { Store } from "../store";
14
16
  import { AnimationFrameHandler } from "../animation-frame-handler";
15
17
  import { AnimatedTrail } from "../animated-trail";
16
18
  import { LaserTrails } from "../laser-trails";
@@ -57,6 +59,7 @@ declare class App extends React.Component<AppProps, AppState> {
57
59
  library: AppClassProperties["library"];
58
60
  libraryItemsFromStorage: LibraryItems | undefined;
59
61
  id: string;
62
+ private store;
60
63
  private history;
61
64
  private excalidrawContainerValue;
62
65
  files: BinaryFiles;
@@ -115,7 +118,7 @@ declare class App extends React.Component<AppProps, AppState> {
115
118
  x: number;
116
119
  y: number;
117
120
  };
118
- arrowDirection: "end" | "origin";
121
+ arrowDirection: "origin" | "end";
119
122
  center: {
120
123
  x: number;
121
124
  y: number;
@@ -179,7 +182,7 @@ declare class App extends React.Component<AppProps, AppState> {
179
182
  x: number;
180
183
  y: number;
181
184
  };
182
- arrowDirection: "end" | "origin";
185
+ arrowDirection: "origin" | "end";
183
186
  center: {
184
187
  x: number;
185
188
  y: number;
@@ -235,8 +238,8 @@ declare class App extends React.Component<AppProps, AppState> {
235
238
  private toggleOverscrollBehavior;
236
239
  render(): import("react/jsx-runtime").JSX.Element;
237
240
  focusContainer: AppClassProperties["focusContainer"];
238
- getSceneElementsIncludingDeleted: () => readonly ExcalidrawElement[];
239
- getSceneElements: () => readonly NonDeletedExcalidrawElement[];
241
+ getSceneElementsIncludingDeleted: () => readonly import("../element/types").OrderedExcalidrawElement[];
242
+ getSceneElements: () => readonly Ordered<NonDeletedExcalidrawElement>[];
240
243
  onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
241
244
  onExportImage: (type: keyof typeof EXPORT_IMAGE_TYPES, elements: ExportedElements, opts: {
242
245
  exportingFrame: ExcalidrawFrameLikeElement | null;
@@ -258,6 +261,7 @@ declare class App extends React.Component<AppProps, AppState> {
258
261
  private onUnload;
259
262
  private disableEvent;
260
263
  private resetHistory;
264
+ private resetStore;
261
265
  /**
262
266
  * Resets scene & history.
263
267
  * ! Do not use to clear scene user action !
@@ -352,7 +356,8 @@ declare class App extends React.Component<AppProps, AppState> {
352
356
  elements?: SceneData["elements"];
353
357
  appState?: Pick<AppState, K> | null | undefined;
354
358
  collaborators?: SceneData["collaborators"];
355
- commitToHistory?: SceneData["commitToHistory"];
359
+ /** @default StoreAction.CAPTURE */
360
+ storeAction?: SceneData["storeAction"];
356
361
  }) => void;
357
362
  private onSceneUpdated;
358
363
  /**
@@ -396,8 +401,17 @@ declare class App extends React.Component<AppProps, AppState> {
396
401
  private handleTextWysiwyg;
397
402
  private deselectElements;
398
403
  private getTextElementAtPosition;
404
+ /**
405
+ * get the pure geometric shape of an excalidraw element
406
+ * which is then used for hit detection
407
+ */
408
+ getElementShape(element: ExcalidrawElement): GeometricShape;
409
+ private getBoundTextShape;
399
410
  private getElementAtPosition;
400
411
  private getElementsAtPosition;
412
+ private getElementHitThreshold;
413
+ private hitElement;
414
+ private getTextBindableContainerAtPosition;
401
415
  private startTextEditing;
402
416
  private handleCanvasDoubleClick;
403
417
  private getElementLinkAtPosition;
@@ -474,7 +488,6 @@ declare class App extends React.Component<AppProps, AppState> {
474
488
  private updateBindingEnabledOnPointerMove;
475
489
  private maybeSuggestBindingAtCursor;
476
490
  private maybeSuggestBindingsForLinearElementAtCoords;
477
- private maybeSuggestBindingForAll;
478
491
  setSelection(elements: readonly NonDeletedExcalidrawElement[]): void;
479
492
  private clearSelection;
480
493
  private handleInteractiveCanvasRef;
@@ -501,6 +514,7 @@ declare global {
501
514
  setState: React.Component<any, AppState>["setState"];
502
515
  app: InstanceType<typeof App>;
503
516
  history: History;
517
+ store: Store;
504
518
  };
505
519
  }
506
520
  }
@@ -1,7 +1,8 @@
1
1
  import "./RadioGroup.scss";
2
2
  export type RadioGroupChoice<T> = {
3
3
  value: T;
4
- label: string;
4
+ label: React.ReactNode;
5
+ ariaLabel?: string;
5
6
  };
6
7
  export type RadioGroupProps<T> = {
7
8
  choices: RadioGroupChoice<T>[];
@@ -17,6 +17,7 @@ type ToolButtonBaseProps = {
17
17
  hidden?: boolean;
18
18
  visible?: boolean;
19
19
  selected?: boolean;
20
+ disabled?: boolean;
20
21
  className?: string;
21
22
  style?: CSSProperties;
22
23
  isLoading?: boolean;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import type { DOMAttributes } from "react";
3
- import type { InteractiveCanvasAppState } from "../../types";
3
+ import type { Device, InteractiveCanvasAppState } from "../../types";
4
4
  import type { RenderableElementsMap, RenderInteractiveSceneCallback } from "../../scene/types";
5
5
  import type { NonDeletedExcalidrawElement } from "../../element/types";
6
6
  type InteractiveCanvasProps = {
@@ -13,6 +13,7 @@ type InteractiveCanvasProps = {
13
13
  selectionNonce: number | undefined;
14
14
  scale: number;
15
15
  appState: InteractiveCanvasAppState;
16
+ device: Device;
16
17
  renderInteractiveSceneCallback: (data: RenderInteractiveSceneCallback) => void;
17
18
  handleCanvasRef: (canvas: HTMLCanvasElement | null) => void;
18
19
  onContextMenu: Exclude<DOMAttributes<HTMLCanvasElement | HTMLDivElement>["onContextMenu"], undefined>;
@@ -0,0 +1,17 @@
1
+ type Props<T> = {
2
+ value: T;
3
+ shortcut?: string;
4
+ choices: {
5
+ value: T;
6
+ label: React.ReactNode;
7
+ ariaLabel?: string;
8
+ }[];
9
+ onChange: (value: T) => void;
10
+ children: React.ReactNode;
11
+ name: string;
12
+ };
13
+ declare const DropdownMenuItemContentRadio: {
14
+ <T>({ value, shortcut, onChange, choices, children, name, }: Props<T>): import("react/jsx-runtime").JSX.Element;
15
+ displayName: string;
16
+ };
17
+ export default DropdownMenuItemContentRadio;
@@ -196,4 +196,8 @@ export declare const svgIcon: import("react/jsx-runtime").JSX.Element;
196
196
  export declare const pngIcon: import("react/jsx-runtime").JSX.Element;
197
197
  export declare const magnetIcon: import("react/jsx-runtime").JSX.Element;
198
198
  export declare const coffeeIcon: import("react/jsx-runtime").JSX.Element;
199
+ export declare const DeviceDesktopIcon: import("react/jsx-runtime").JSX.Element;
200
+ export declare const arrowBarToLeftIcon: import("react/jsx-runtime").JSX.Element;
201
+ export declare const youtubeIcon: import("react/jsx-runtime").JSX.Element;
202
+ export declare const gridIcon: import("react/jsx-runtime").JSX.Element;
199
203
  export {};
@@ -1,3 +1,4 @@
1
+ import type { Theme } from "../../element/types";
1
2
  import "./DefaultItems.scss";
2
3
  export declare const LoadScene: {
3
4
  (): import("react/jsx-runtime").JSX.Element | null;
@@ -12,7 +13,9 @@ export declare const SaveAsImage: {
12
13
  displayName: string;
13
14
  };
14
15
  export declare const CommandPalette: {
15
- (): import("react/jsx-runtime").JSX.Element;
16
+ (opts?: {
17
+ className?: string;
18
+ }): import("react/jsx-runtime").JSX.Element;
16
19
  displayName: string;
17
20
  };
18
21
  export declare const Help: {
@@ -24,7 +27,14 @@ export declare const ClearCanvas: {
24
27
  displayName: string;
25
28
  };
26
29
  export declare const ToggleTheme: {
27
- (): import("react/jsx-runtime").JSX.Element | null;
30
+ (props: {
31
+ allowSystemTheme: true;
32
+ theme: Theme | "system";
33
+ onSelect: (theme: Theme | "system") => void;
34
+ } | {
35
+ allowSystemTheme?: false | undefined;
36
+ onSelect?: ((theme: Theme) => void) | undefined;
37
+ }): import("react/jsx-runtime").JSX.Element | null;
28
38
  displayName: string;
29
39
  };
30
40
  export declare const ChangeCanvasBackground: {
@@ -124,6 +124,8 @@ export declare const DEFAULT_TEXT_ALIGN = "left";
124
124
  export declare const DEFAULT_VERTICAL_ALIGN = "top";
125
125
  export declare const DEFAULT_VERSION = "{version}";
126
126
  export declare const DEFAULT_TRANSFORM_HANDLE_SPACING = 2;
127
+ export declare const SIDE_RESIZING_THRESHOLD: number;
128
+ export declare const DEFAULT_COLLISION_THRESHOLD: number;
127
129
  export declare const COLOR_WHITE = "#ffffff";
128
130
  export declare const COLOR_CHARCOAL_BLACK = "#1e1e1e";
129
131
  export declare const COLOR_VOICE_CALL = "#a2f1a6";
@@ -178,6 +180,7 @@ export declare const VERSION_TIMEOUT = 30000;
178
180
  export declare const SCROLL_TIMEOUT = 100;
179
181
  export declare const ZOOM_STEP = 0.05;
180
182
  export declare const MIN_ZOOM = 0.1;
183
+ export declare const MAX_ZOOM = 30;
181
184
  export declare const HYPERLINK_TOOLTIP_DELAY = 300;
182
185
  export declare const IDLE_THRESHOLD = 60000;
183
186
  export declare const ACTIVE_THRESHOLD = 3000;
@@ -0,0 +1,6 @@
1
+ import { OrderedExcalidrawElement } from "../element/types";
2
+ import { AppState } from "../types";
3
+ import { MakeBrand } from "../utility-types";
4
+ export type ReconciledExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"ReconciledElement">;
5
+ export type RemoteExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"RemoteExcalidrawElement">;
6
+ export declare const reconcileElements: (localElements: readonly OrderedExcalidrawElement[], remoteElements: readonly RemoteExcalidrawElement[], localAppState: AppState) => ReconciledExcalidrawElement[];
@@ -1,17 +1,17 @@
1
- import { ExcalidrawElement } from "../element/types";
1
+ import { ExcalidrawElement, OrderedExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles, LibraryItem } from "../types";
3
3
  import { ImportedDataState } from "./types";
4
4
  type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
5
5
  export declare const AllowedExcalidrawActiveTools: Record<AppState["activeTool"]["type"], boolean>;
6
6
  export type RestoredDataState = {
7
- elements: ExcalidrawElement[];
7
+ elements: OrderedExcalidrawElement[];
8
8
  appState: RestoredAppState;
9
9
  files: BinaryFiles;
10
10
  };
11
11
  export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, opts?: {
12
12
  refreshDimensions?: boolean;
13
13
  repairBindings?: boolean;
14
- } | undefined) => ExcalidrawElement[];
14
+ } | undefined) => OrderedExcalidrawElement[];
15
15
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
16
16
  export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined, elementsConfig?: {
17
17
  refreshDimensions?: boolean;
@@ -78,4 +78,4 @@ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, Excal
78
78
  } & Partial<ExcalidrawMagicFrameElement>);
79
79
  export declare const convertToExcalidrawElements: (elementsSkeleton: ExcalidrawElementSkeleton[] | null, opts?: {
80
80
  regenerateIds: boolean;
81
- }) => ExcalidrawElement[];
81
+ }) => import("../element/types").OrderedExcalidrawElement[];
@@ -1,3 +1,4 @@
1
+ export declare const sanitizeHTMLAttribute: (html: string) => string;
1
2
  export declare const normalizeLink: (link: string) => string;
2
3
  export declare const isLocalLink: (link: string | null) => boolean;
3
4
  /**