@excalidraw/element 0.18.0-39ce38a0d-200a6bd94 → 0.18.0-508de2f3a
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/dist/dev/index.js +93 -64
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +11 -11
- package/dist/types/element/src/Scene.d.ts +6 -2
- package/dist/types/element/src/delta.d.ts +6 -3
- package/dist/types/element/src/mutateElement.d.ts +1 -0
- package/dist/types/element/src/store.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +5 -4
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- package/dist/types/excalidraw/index.d.ts +1 -1
- package/dist/types/excalidraw/types.d.ts +5 -3
- package/package.json +3 -3
|
@@ -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
|
|
60
|
+
replaceAllElements(nextElements: ElementsMapOrArray, options?: {
|
|
61
|
+
skipValidation?: true;
|
|
62
|
+
}): void;
|
|
59
63
|
triggerUpdate(): void;
|
|
60
64
|
onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover;
|
|
61
65
|
destroy(): void;
|
|
@@ -105,7 +105,7 @@ export interface DeltaContainer<T> {
|
|
|
105
105
|
*
|
|
106
106
|
* @returns a tuple of the next object `T` with applied `Delta`s, and `boolean`, indicating whether the applied deltas resulted in a visible change.
|
|
107
107
|
*/
|
|
108
|
-
applyTo(previous: T, ...options: unknown[]): [T, boolean];
|
|
108
|
+
applyTo(previous: T, ...options: unknown[]): [T, boolean, ...unknown[]];
|
|
109
109
|
/**
|
|
110
110
|
* Squashes the current delta with the given one.
|
|
111
111
|
*/
|
|
@@ -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;
|
|
@@ -131,7 +132,6 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
|
|
|
131
132
|
* @returns `true` if a visible change is found, `false` otherwise.
|
|
132
133
|
*/
|
|
133
134
|
private filterInvisibleChanges;
|
|
134
|
-
private static convertToAppStateKey;
|
|
135
135
|
private static filterSelectedElements;
|
|
136
136
|
private static filterSelectedGroups;
|
|
137
137
|
private static stripElementsProps;
|
|
@@ -145,7 +145,8 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
|
|
|
145
145
|
}
|
|
146
146
|
type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
|
|
147
147
|
export type ApplyToOptions = {
|
|
148
|
-
excludedProperties
|
|
148
|
+
excludedProperties?: Set<keyof ElementPartial>;
|
|
149
|
+
skipRedraw?: true;
|
|
149
150
|
};
|
|
150
151
|
/**
|
|
151
152
|
* Elements change is a low level primitive to capture a change between two sets of elements.
|
|
@@ -213,6 +214,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
|
213
214
|
* should be rebound (if possible) with the current element ~ bindings should be bidirectional.
|
|
214
215
|
*/
|
|
215
216
|
private static rebindAffected;
|
|
217
|
+
static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
|
|
216
218
|
private static redrawTextBoundingBoxes;
|
|
217
219
|
private static redrawBoundArrows;
|
|
218
220
|
private static reorderElements;
|
|
@@ -222,5 +224,6 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
|
222
224
|
*/
|
|
223
225
|
private static postProcess;
|
|
224
226
|
private static stripIrrelevantProps;
|
|
227
|
+
private static stripVersionProps;
|
|
225
228
|
}
|
|
226
229
|
export {};
|
|
@@ -11,6 +11,7 @@ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TEl
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
|
|
13
13
|
isDragging?: boolean;
|
|
14
|
+
force?: boolean;
|
|
14
15
|
}) => TElement;
|
|
15
16
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
|
|
16
17
|
/**
|
|
@@ -169,7 +169,7 @@ 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
173
|
/**
|
|
174
174
|
* Inverse store delta, creates new instance of `StoreDelta`.
|
|
175
175
|
*/
|
|
@@ -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, Store, type ElementUpdate } from "@excalidraw/element";
|
|
4
|
-
import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered } from "@excalidraw/element/types";
|
|
3
|
+
import { LinearElementEditor, FlowChartCreator, Scene, Store, type ElementUpdate, StoreDelta } from "@excalidraw/element";
|
|
4
|
+
import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, OrderedExcalidrawElement, 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";
|
|
@@ -14,7 +14,7 @@ import { LassoTrail } from "../lasso";
|
|
|
14
14
|
import { EraserTrail } from "../eraser";
|
|
15
15
|
import type { ExportedElements } from "../data";
|
|
16
16
|
import type { FileSystemHandle } from "../data/filesystem";
|
|
17
|
-
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
|
|
17
|
+
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, GenerateDiagramToCode, NullableGridSize, Offsets, ApplyDeltasOptions } from "../types";
|
|
18
18
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
19
19
|
import type { ActionResult } from "../actions/types";
|
|
20
20
|
export declare const ExcalidrawContainerContext: React.Context<{
|
|
@@ -265,7 +265,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
265
265
|
private toggleOverscrollBehavior;
|
|
266
266
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
267
267
|
focusContainer: AppClassProperties["focusContainer"];
|
|
268
|
-
getSceneElementsIncludingDeleted: () => readonly
|
|
268
|
+
getSceneElementsIncludingDeleted: () => readonly OrderedExcalidrawElement[];
|
|
269
269
|
getSceneElementsMapIncludingDeleted: () => Map<string, Ordered<ExcalidrawElement>> & import("@excalidraw/common/utility-types").MakeBrand<"SceneElementsMap">;
|
|
270
270
|
getSceneElements: () => readonly Ordered<NonDeletedExcalidrawElement>[];
|
|
271
271
|
onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
@@ -397,6 +397,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
397
397
|
*/
|
|
398
398
|
captureUpdate?: SceneData["captureUpdate"];
|
|
399
399
|
}) => void;
|
|
400
|
+
applyDeltas: (deltas: StoreDelta[], options?: ApplyDeltasOptions) => [SceneElementsMap, AppState, boolean];
|
|
400
401
|
mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
401
402
|
private triggerRender;
|
|
402
403
|
/**
|
|
@@ -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 { serializeAsJSON, serializeLibraryAsJSON } from "./data/json";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
|
|
2
|
-
import type { SuggestedBinding } from "@excalidraw/element";
|
|
2
|
+
import type { ApplyToOptions, SuggestedBinding } from "@excalidraw/element";
|
|
3
3
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
4
4
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
5
|
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "@excalidraw/element/types";
|
|
@@ -155,8 +155,8 @@ export type ObservedElementsAppState = {
|
|
|
155
155
|
editingGroupId: AppState["editingGroupId"];
|
|
156
156
|
selectedElementIds: AppState["selectedElementIds"];
|
|
157
157
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
selectedLinearElement: {
|
|
159
|
+
elementId: LinearElementEditor["elementId"];
|
|
160
160
|
isEditing: boolean;
|
|
161
161
|
} | null;
|
|
162
162
|
croppingElementId: AppState["croppingElementId"];
|
|
@@ -478,6 +478,7 @@ export type SceneData = {
|
|
|
478
478
|
collaborators?: Map<SocketId, Collaborator>;
|
|
479
479
|
captureUpdate?: CaptureUpdateActionType;
|
|
480
480
|
};
|
|
481
|
+
export type ApplyDeltasOptions = Omit<ApplyToOptions, "skipRedraw">;
|
|
481
482
|
export type ExportOpts = {
|
|
482
483
|
saveFileToDisk?: boolean;
|
|
483
484
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
@@ -618,6 +619,7 @@ export type PointerDownState = Readonly<{
|
|
|
618
619
|
export type UnsubscribeCallback = () => void;
|
|
619
620
|
export interface ExcalidrawImperativeAPI {
|
|
620
621
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
622
|
+
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
621
623
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
622
624
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
623
625
|
resetScene: InstanceType<typeof App>["resetScene"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@excalidraw/element",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-508de2f3a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/element/src/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@excalidraw/common": "0.18.0-
|
|
61
|
-
"@excalidraw/math": "0.18.0-
|
|
60
|
+
"@excalidraw/common": "0.18.0-508de2f3a",
|
|
61
|
+
"@excalidraw/math": "0.18.0-508de2f3a"
|
|
62
62
|
}
|
|
63
63
|
}
|