@excalidraw/common 0.18.0-dda3affcb → 0.18.0-dda3affcb-8fc71066d
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.
|
@@ -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;
|
|
@@ -144,7 +145,8 @@ 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
|
|
148
|
+
excludedProperties?: Set<keyof ElementPartial>;
|
|
149
|
+
skipRedraw?: true;
|
|
148
150
|
};
|
|
149
151
|
/**
|
|
150
152
|
* Elements change is a low level primitive to capture a change between two sets 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;
|
|
@@ -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,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";
|
|
@@ -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"];
|