@zsviczian/excalidraw 0.18.0-33 → 0.18.0-34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsviczian/excalidraw",
3
- "version": "0.18.0-33",
3
+ "version": "0.18.0-34",
4
4
  "main": "main.js",
5
5
  "module": "./dist/prod/index.js",
6
6
  "types": "types/excalidraw/index.d.ts",
@@ -27,7 +27,9 @@ export declare class Scene {
27
27
  getElementsMapIncludingDeleted(): Map<string, Ordered<ExcalidrawElement>> & import("@excalidraw/common/utility-types").MakeBrand<"SceneElementsMap">;
28
28
  getNonDeletedElements(): readonly Ordered<NonDeletedExcalidrawElement>[];
29
29
  getFramesIncludingDeleted(): readonly ExcalidrawFrameLikeElement[];
30
- constructor(elements?: ElementsMapOrArray | null);
30
+ constructor(elements?: ElementsMapOrArray | null, options?: {
31
+ skipValidation?: true;
32
+ });
31
33
  getSelectedElements(opts: {
32
34
  selectedElementIds: AppState["selectedElementIds"];
33
35
  /**
@@ -55,7 +57,9 @@ export declare class Scene {
55
57
  * @returns whether a change was made
56
58
  */
57
59
  mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
58
- replaceAllElements(nextElements: ElementsMapOrArray): void;
60
+ replaceAllElements(nextElements: ElementsMapOrArray, options?: {
61
+ skipValidation?: true;
62
+ }): void;
59
63
  triggerUpdate(): void;
60
64
  onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover;
61
65
  destroy(): void;
@@ -32,13 +32,13 @@ export declare class Delta<T> {
32
32
  /**
33
33
  * Merges two deltas into a new one.
34
34
  */
35
- static merge<T>(delta1: Delta<T>, delta2: Delta<T>): Delta<T>;
35
+ static merge<T>(delta1: Delta<T>, delta2: Delta<T>, delta3?: Delta<T>): Delta<T>;
36
36
  /**
37
37
  * Merges deleted and inserted object partials.
38
38
  */
39
39
  static mergeObjects<T extends {
40
40
  [key: string]: unknown;
41
- }>(prev: T, added: T, removed: T): T;
41
+ }>(prev: T, added: T, removed?: T): T;
42
42
  /**
43
43
  * Merges deleted and inserted array partials.
44
44
  */
@@ -118,6 +118,7 @@ export interface DeltaContainer<T> {
118
118
  export declare class AppStateDelta implements DeltaContainer<AppState> {
119
119
  delta: Delta<ObservedAppState>;
120
120
  private constructor();
121
+ static create(delta: Delta<ObservedAppState>): AppStateDelta;
121
122
  static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
122
123
  static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
123
124
  static empty(): AppStateDelta;
@@ -144,7 +145,7 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
144
145
  }
145
146
  type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
146
147
  export type ApplyToOptions = {
147
- excludedProperties: Set<keyof ElementPartial>;
148
+ excludedProperties?: Set<keyof ElementPartial>;
148
149
  };
149
150
  /**
150
151
  * Elements change is a low level primitive to capture a change between two sets of elements.
@@ -163,6 +164,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
163
164
  private static satisfiesRemoval;
164
165
  private static satisfiesUpdate;
165
166
  private static satisfiesCommmonInvariants;
167
+ private static satisfiesUniqueInvariants;
166
168
  private static validate;
167
169
  /**
168
170
  * Calculates the `Delta`s between the previous and next set of elements.
@@ -212,6 +214,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
212
214
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
213
215
  */
214
216
  private static rebindAffected;
217
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
215
218
  private static redrawTextBoundingBoxes;
216
219
  private static redrawBoundArrows;
217
220
  private static reorderElements;
@@ -221,5 +224,6 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
221
224
  */
222
225
  private static postProcess;
223
226
  private static stripIrrelevantProps;
227
+ private static stripVersionProps;
224
228
  }
225
229
  export {};
@@ -169,7 +169,11 @@ export declare class StoreDelta {
169
169
  /**
170
170
  * Parse and load the delta from the remote payload.
171
171
  */
172
- static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
172
+ static load({ id, elements: { added, removed, updated }, appState: { delta: appStateDelta }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Squash the passed deltas into the aggregated delta instance.
175
+ */
176
+ static squash(...deltas: StoreDelta[]): StoreDelta;
173
177
  /**
174
178
  * Inverse store delta, creates new instance of `StoreDelta`.
175
179
  */
@@ -182,6 +186,7 @@ export declare class StoreDelta {
182
186
  * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
183
187
  */
184
188
  static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
189
+ static empty(): StoreDelta;
185
190
  isEmpty(): boolean;
186
191
  }
187
192
  /**
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { type EXPORT_IMAGE_TYPES, Emitter } from "@excalidraw/common";
3
- import { LinearElementEditor, FlowChartCreator, Scene, type ElementUpdate } from "@excalidraw/element";
4
- import type { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered } from "@excalidraw/element/types";
3
+ import { LinearElementEditor, FlowChartCreator, Scene, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
+ import type { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
5
  import type { Mutable } from "@excalidraw/common/utility-types";
6
6
  import { ActionManager } from "../actions/manager";
7
7
  import { AnimationFrameHandler } from "../animation-frame-handler";
@@ -416,6 +416,7 @@ declare class App extends React.Component<AppProps, AppState> {
416
416
  captureUpdate?: SceneData["captureUpdate"];
417
417
  forceFlushSync?: boolean | undefined;
418
418
  }) => void;
419
+ applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
419
420
  mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
420
421
  private triggerRender;
421
422
  /**
@@ -225,4 +225,6 @@ export declare const upIcon: import("react/jsx-runtime").JSX.Element;
225
225
  export declare const cropIcon: import("react/jsx-runtime").JSX.Element;
226
226
  export declare const elementLinkIcon: import("react/jsx-runtime").JSX.Element;
227
227
  export declare const markerFrameIcon: import("react/jsx-runtime").JSX.Element;
228
+ export declare const LaTeXIcon: import("react/jsx-runtime").JSX.Element;
229
+ export declare const InsertAnyFileIcon: import("react/jsx-runtime").JSX.Element;
228
230
  export {};
@@ -46,12 +46,6 @@ export declare const SHAPES: readonly [{
46
46
  readonly key: "t";
47
47
  readonly numericKey: "8";
48
48
  readonly fillable: false;
49
- }, {
50
- readonly icon: import("react/jsx-runtime").JSX.Element;
51
- readonly value: "image";
52
- readonly key: null;
53
- readonly numericKey: "9";
54
- readonly fillable: false;
55
49
  }, {
56
50
  readonly icon: import("react/jsx-runtime").JSX.Element;
57
51
  readonly value: "eraser";
@@ -59,4 +53,4 @@ export declare const SHAPES: readonly [{
59
53
  readonly numericKey: "0";
60
54
  readonly fillable: false;
61
55
  }];
62
- export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | null;
56
+ export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "freedraw" | "eraser" | null;
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, OrderedExcalidrawElement } from "@excalidraw/element/types";
1
+ import type { ExcalidrawArrowElement, ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawSelectionElement, ExcalidrawTextElement, OrderedExcalidrawElement } from "@excalidraw/element/types";
2
2
  import type { AppState, BinaryFiles, LibraryItem } from "../types";
3
3
  import type { ImportedDataState } from "./types";
4
4
  type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
@@ -8,14 +8,19 @@ export type RestoredDataState = {
8
8
  appState: RestoredAppState;
9
9
  files: BinaryFiles;
10
10
  };
11
+ export declare const restoreElement: (element: Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, opts?: {
12
+ deleteInvisibleElements?: boolean;
13
+ }) => ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | ExcalidrawArrowElement | null;
11
14
  export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, opts?: {
12
15
  refreshDimensions?: boolean;
13
16
  repairBindings?: boolean;
17
+ deleteInvisibleElements?: boolean;
14
18
  } | undefined) => OrderedExcalidrawElement[];
15
19
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
16
20
  export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined, elementsConfig?: {
17
21
  refreshDimensions?: boolean;
18
22
  repairBindings?: boolean;
23
+ deleteInvisibleElements?: boolean;
19
24
  }) => RestoredDataState;
20
25
  export declare const restoreLibraryItems: (libraryItems: ImportedDataState["libraryItems"], defaultStatus: LibraryItem["status"]) => LibraryItem[];
21
26
  export {};
@@ -12,7 +12,7 @@ export { getSceneVersion, hashElementsVersion, hashString, getNonDeletedElements
12
12
  export { getTextFromElements } from "@excalidraw/element";
13
13
  export { isInvisiblySmallElement } from "@excalidraw/element";
14
14
  export { defaultLang, useI18n, languages } from "./i18n";
15
- export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "./data/restore";
15
+ export { restore, restoreAppState, restoreElement, restoreElements, restoreLibraryItems, } from "./data/restore";
16
16
  export { reconcileElements } from "./data/reconcile";
17
17
  export { exportToCanvas, exportToBlob, exportToSvg, exportToClipboard, } from "@excalidraw/utils/export";
18
18
  export { getCommonBoundingBox } from "@excalidraw/element/bounds";
@@ -1,4 +1,4 @@
1
- import { GlobalPoint } from "@excalidraw/math/types";
1
+ import { type GlobalPoint } from "@excalidraw/math/types";
2
2
  import type { MermaidToExcalidrawLibProps } from "./components/TTDDialog/common";
3
3
  import type { ElementsMap, ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
4
4
  import type { FontMetadata } from "@excalidraw/common";
@@ -38,3 +38,5 @@ export declare const disableDoubleClickTextEditing: () => any;
38
38
  export declare const getZoomStep: () => any;
39
39
  export declare const getZoomMin: () => any;
40
40
  export declare const getZoomMax: () => any;
41
+ export declare const runAction: (action: string) => void;
42
+ export declare const t2: (key: string) => string;
@@ -681,6 +681,7 @@ export type PointerDownState = Readonly<{
681
681
  export type UnsubscribeCallback = () => void;
682
682
  export interface ExcalidrawImperativeAPI {
683
683
  updateScene: InstanceType<typeof App>["updateScene"];
684
+ applyDeltas: InstanceType<typeof App>["applyDeltas"];
684
685
  mutateElement: InstanceType<typeof App>["mutateElement"];
685
686
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
686
687
  resetScene: InstanceType<typeof App>["resetScene"];