@excalidraw/excalidraw 0.18.0-6fc8502 → 0.18.0-7876ee524
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/chunk-CP5DND7P.js +7 -0
- package/dist/dev/chunk-CP5DND7P.js.map +7 -0
- package/dist/dev/chunk-CRKRRBMD.js +5677 -0
- package/dist/dev/chunk-CRKRRBMD.js.map +7 -0
- package/dist/dev/{chunk-X3RYHLJU.js → chunk-QF5FRM6O.js} +15 -5
- package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
- package/dist/dev/data/{image-NKFINVKH.js → image-IWGLHPIX.js} +3 -3
- package/dist/dev/index.css +104 -22
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +15054 -15792
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-CKWC2GMK.js → en-SMAPCEOQ.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-A66AFZZU.js +7 -0
- package/dist/prod/chunk-HHV2PJKY.js +4 -0
- package/dist/prod/chunk-I4UNSFV6.js +12 -0
- package/dist/prod/data/image-4SM4COIL.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +25 -17
- package/dist/prod/locales/{en-SBO6ZHT2.js → en-TYY6KWIJ.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +23 -3
- package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/utility-types.d.ts +5 -0
- package/dist/types/common/src/utils.d.ts +17 -1
- package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +16 -15
- package/dist/types/element/src/align.d.ts +4 -3
- package/dist/types/element/src/binding.d.ts +26 -16
- package/dist/types/element/src/bounds.d.ts +13 -5
- package/dist/types/element/src/collision.d.ts +18 -12
- package/dist/types/element/src/cropElement.d.ts +1 -1
- package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +79 -41
- package/dist/types/element/src/distance.d.ts +2 -2
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/dragElements.d.ts +3 -2
- package/dist/types/element/src/duplicate.d.ts +10 -13
- package/dist/types/element/src/elbowArrow.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +3 -2
- package/dist/types/element/src/fractionalIndex.d.ts +9 -3
- package/dist/types/element/src/frame.d.ts +5 -4
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/index.d.ts +43 -2
- package/dist/types/element/src/linearElementEditor.d.ts +23 -36
- package/dist/types/element/src/mutateElement.d.ts +11 -3
- package/dist/types/element/src/newElement.d.ts +4 -3
- package/dist/types/element/src/resizeElements.d.ts +5 -4
- package/dist/types/element/src/selection.d.ts +11 -5
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/sizeHelpers.d.ts +2 -2
- package/dist/types/element/src/store.d.ts +236 -0
- package/dist/types/element/src/textElement.d.ts +5 -3
- package/dist/types/element/src/typeChecks.d.ts +19 -1
- package/dist/types/element/src/types.d.ts +15 -2
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +39 -51
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -34
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +175 -227
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +78 -100
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +39 -50
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -16
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -50
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionExport.d.ts +127 -163
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -40
- package/dist/types/excalidraw/actions/actionFrame.d.ts +99 -115
- package/dist/types/excalidraw/actions/actionGroup.d.ts +26 -34
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +538 -18
- package/dist/types/excalidraw/actions/actionLink.d.ts +12 -16
- package/dist/types/excalidraw/actions/actionMenu.d.ts +36 -48
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +25 -33
- package/dist/types/excalidraw/actions/actionProperties.d.ts +203 -255
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +12 -189
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -17
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -17
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/appState.d.ts +19 -10
- package/dist/types/excalidraw/components/Actions.d.ts +0 -4
- package/dist/types/excalidraw/components/App.d.ts +34 -22
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Range.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +3 -0
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- package/dist/types/excalidraw/data/transform.d.ts +1 -1
- package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
- package/dist/types/excalidraw/eraser/index.d.ts +12 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +30 -22
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +11 -10
- package/dist/types/excalidraw/lasso/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +3 -3
- package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
- package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
- package/dist/types/excalidraw/scene/types.d.ts +2 -0
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +35 -14
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/angle.d.ts +2 -0
- package/dist/types/math/src/constants.d.ts +3 -0
- package/dist/types/math/src/curve.d.ts +34 -0
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/rectangle.d.ts +2 -0
- package/dist/types/math/src/types.d.ts +1 -0
- package/dist/types/math/src/vector.d.ts +8 -2
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/index.d.ts +1 -1
- package/dist/types/utils/src/withinBounds.d.ts +1 -1
- package/history.ts +146 -109
- package/package.json +12 -9
- package/dist/dev/chunk-H7XJ5UVD.js +0 -7
- package/dist/dev/chunk-H7XJ5UVD.js.map +0 -7
- package/dist/dev/chunk-KYBDXI6F.js +0 -18739
- package/dist/dev/chunk-KYBDXI6F.js.map +0 -7
- package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
- package/dist/prod/chunk-CAN5RS4P.js +0 -31
- package/dist/prod/chunk-IUH5AXLB.js +0 -12
- package/dist/prod/chunk-KJYFYP64.js +0 -7
- package/dist/prod/data/image-5XD47O4X.js +0 -1
- package/dist/types/element/src/Shape.d.ts +0 -17
- package/dist/types/element/src/ShapeCache.d.ts +0 -25
- package/dist/types/element/src/shapes.d.ts +0 -23
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/store.d.ts +0 -129
- package/dist/types/excalidraw/visualdebug.d.ts +0 -41
- package/dist/types/utils/src/collision.d.ts +0 -8
- /package/dist/dev/data/{image-NKFINVKH.js.map → image-IWGLHPIX.js.map} +0 -0
- /package/dist/dev/locales/{en-CKWC2GMK.js.map → en-SMAPCEOQ.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementUpdate } from "@excalidraw/element/mutateElement";
|
|
2
1
|
import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "@excalidraw/element/types";
|
|
3
|
-
import type { ValueOf } from "@excalidraw/common/utility-types";
|
|
4
|
-
import type { AppState, ObservedAppState } from "
|
|
2
|
+
import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
|
|
3
|
+
import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
|
|
4
|
+
import { StoreSnapshot } from "./store";
|
|
5
5
|
/**
|
|
6
6
|
* Represents the difference between two objects of the same type.
|
|
7
7
|
*
|
|
@@ -11,11 +11,11 @@ import type { AppState, ObservedAppState } from "./types";
|
|
|
11
11
|
*
|
|
12
12
|
* Keeping it as pure object (without transient state, side-effects, etc.), so we won't have to instantiate it on load.
|
|
13
13
|
*/
|
|
14
|
-
declare class Delta<T> {
|
|
14
|
+
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
|
|
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
|
*
|
|
@@ -29,12 +29,16 @@ declare class Delta<T> {
|
|
|
29
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
30
|
static empty(): Delta<unknown>;
|
|
31
31
|
static isEmpty<T>(delta: Delta<T>): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Merges two deltas into a new one.
|
|
34
|
+
*/
|
|
35
|
+
static merge<T>(delta1: Delta<T>, delta2: Delta<T>, delta3?: Delta<T>): Delta<T>;
|
|
32
36
|
/**
|
|
33
37
|
* Merges deleted and inserted object partials.
|
|
34
38
|
*/
|
|
35
39
|
static mergeObjects<T extends {
|
|
36
40
|
[key: string]: unknown;
|
|
37
|
-
}>(prev: T, added: T, removed
|
|
41
|
+
}>(prev: T, added: T, removed?: T): T;
|
|
38
42
|
/**
|
|
39
43
|
* Merges deleted and inserted array partials.
|
|
40
44
|
*/
|
|
@@ -56,13 +60,29 @@ declare class Delta<T> {
|
|
|
56
60
|
*/
|
|
57
61
|
static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
58
62
|
/**
|
|
59
|
-
*
|
|
63
|
+
* Compares if shared properties of object1 and object2 contain any different value (aka inner join).
|
|
64
|
+
*/
|
|
65
|
+
static isInnerDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Compares if any properties of object1 and object2 contain any different value (aka full join).
|
|
68
|
+
*/
|
|
69
|
+
static isDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Returns sorted object1 keys that have distinct values.
|
|
60
72
|
*/
|
|
61
73
|
static getLeftDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
62
74
|
/**
|
|
63
|
-
* Returns
|
|
75
|
+
* Returns sorted object2 keys that have distinct values.
|
|
64
76
|
*/
|
|
65
77
|
static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
78
|
+
/**
|
|
79
|
+
* Returns sorted keys of shared object1 and object2 properties that have distinct values (aka inner join).
|
|
80
|
+
*/
|
|
81
|
+
static getInnerDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Returns sorted keys that have distinct values between object1 and object2 (aka full join).
|
|
84
|
+
*/
|
|
85
|
+
static getDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
66
86
|
/**
|
|
67
87
|
* Iterator comparing values of object properties based on the passed joining strategy.
|
|
68
88
|
*
|
|
@@ -73,65 +93,78 @@ declare class Delta<T> {
|
|
|
73
93
|
private static distinctKeysIterator;
|
|
74
94
|
}
|
|
75
95
|
/**
|
|
76
|
-
* Encapsulates
|
|
96
|
+
* Encapsulates a set of application-level `Delta`s.
|
|
77
97
|
*/
|
|
78
|
-
interface
|
|
98
|
+
export interface DeltaContainer<T> {
|
|
79
99
|
/**
|
|
80
|
-
* Inverses the `Delta`s
|
|
100
|
+
* Inverses the `Delta`s while creating a new `DeltaContainer` instance.
|
|
81
101
|
*/
|
|
82
|
-
inverse():
|
|
102
|
+
inverse(): DeltaContainer<T>;
|
|
83
103
|
/**
|
|
84
|
-
* Applies the `
|
|
104
|
+
* Applies the `Delta`s to the previous object.
|
|
85
105
|
*
|
|
86
|
-
* @returns a tuple of the next object `T` with applied
|
|
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
|
+
*/
|
|
108
|
+
applyTo(previous: T, ...options: unknown[]): [T, boolean, ...unknown[]];
|
|
109
|
+
/**
|
|
110
|
+
* Squashes the current delta with the given one.
|
|
87
111
|
*/
|
|
88
|
-
|
|
112
|
+
squash(delta: DeltaContainer<T>): this;
|
|
89
113
|
/**
|
|
90
|
-
* Checks whether
|
|
114
|
+
* Checks whether all `Delta`s are empty.
|
|
91
115
|
*/
|
|
92
116
|
isEmpty(): boolean;
|
|
93
117
|
}
|
|
94
|
-
export declare class
|
|
95
|
-
|
|
118
|
+
export declare class AppStateDelta implements DeltaContainer<AppState> {
|
|
119
|
+
delta: Delta<ObservedAppState>;
|
|
96
120
|
private constructor();
|
|
97
|
-
static
|
|
98
|
-
static
|
|
99
|
-
|
|
121
|
+
static create(delta: Delta<ObservedAppState>): AppStateDelta;
|
|
122
|
+
static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
|
|
123
|
+
static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
|
|
124
|
+
static empty(): AppStateDelta;
|
|
125
|
+
inverse(): AppStateDelta;
|
|
126
|
+
squash(delta: AppStateDelta): this;
|
|
100
127
|
applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
|
|
101
128
|
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
129
|
/**
|
|
108
130
|
* Mutates `nextAppState` be filtering out state related to deleted elements.
|
|
109
131
|
*
|
|
110
132
|
* @returns `true` if a visible change is found, `false` otherwise.
|
|
111
133
|
*/
|
|
112
134
|
private filterInvisibleChanges;
|
|
113
|
-
private static convertToAppStateKey;
|
|
114
135
|
private static filterSelectedElements;
|
|
115
136
|
private static filterSelectedGroups;
|
|
116
137
|
private static stripElementsProps;
|
|
117
138
|
private static stripStandaloneProps;
|
|
139
|
+
/**
|
|
140
|
+
* It is necessary to post process the partials in case of reference values,
|
|
141
|
+
* for which we need to calculate the real diff between `deleted` and `inserted`.
|
|
142
|
+
*/
|
|
143
|
+
private static postProcess;
|
|
144
|
+
private static orderAppStateKeys;
|
|
118
145
|
}
|
|
119
|
-
type ElementPartial<
|
|
146
|
+
type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
|
|
147
|
+
export type ApplyToOptions = {
|
|
148
|
+
excludedProperties?: Set<keyof ElementPartial>;
|
|
149
|
+
};
|
|
120
150
|
/**
|
|
121
151
|
* Elements change is a low level primitive to capture a change between two sets of elements.
|
|
122
152
|
* It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
|
|
123
153
|
*/
|
|
124
|
-
export declare class
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
154
|
+
export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
155
|
+
readonly added: Record<string, Delta<ElementPartial>>;
|
|
156
|
+
readonly removed: Record<string, Delta<ElementPartial>>;
|
|
157
|
+
readonly updated: Record<string, Delta<ElementPartial>>;
|
|
128
158
|
private constructor();
|
|
129
|
-
static create(added:
|
|
159
|
+
static create(added: Record<string, Delta<ElementPartial>>, removed: Record<string, Delta<ElementPartial>>, updated: Record<string, Delta<ElementPartial>>, options?: {
|
|
130
160
|
shouldRedistribute: boolean;
|
|
131
|
-
}):
|
|
161
|
+
}): ElementsDelta;
|
|
162
|
+
static restore(elementsDeltaDTO: DTO<ElementsDelta>): ElementsDelta;
|
|
132
163
|
private static satisfiesAddition;
|
|
133
164
|
private static satisfiesRemoval;
|
|
134
165
|
private static satisfiesUpdate;
|
|
166
|
+
private static satisfiesCommmonInvariants;
|
|
167
|
+
private static satisfiesUniqueInvariants;
|
|
135
168
|
private static validate;
|
|
136
169
|
/**
|
|
137
170
|
* Calculates the `Delta`s between the previous and next set of elements.
|
|
@@ -139,21 +172,22 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
139
172
|
* @param prevElements - Map representing the previous state of elements.
|
|
140
173
|
* @param nextElements - Map representing the next state of elements.
|
|
141
174
|
*
|
|
142
|
-
* @returns `
|
|
175
|
+
* @returns `ElementsDelta` instance representing the `Delta` changes between the two sets of elements.
|
|
143
176
|
*/
|
|
144
|
-
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>):
|
|
145
|
-
static empty():
|
|
146
|
-
inverse():
|
|
177
|
+
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsDelta;
|
|
178
|
+
static empty(): ElementsDelta;
|
|
179
|
+
inverse(): ElementsDelta;
|
|
147
180
|
isEmpty(): boolean;
|
|
148
181
|
/**
|
|
149
182
|
* Update delta/s based on the existing elements.
|
|
150
183
|
*
|
|
151
|
-
* @param
|
|
184
|
+
* @param nextElements current elements
|
|
152
185
|
* @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
|
|
153
186
|
* @returns new instance with modified delta/s
|
|
154
187
|
*/
|
|
155
|
-
applyLatestChanges(
|
|
156
|
-
applyTo(elements: SceneElementsMap, snapshot
|
|
188
|
+
applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
|
|
189
|
+
applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
|
|
190
|
+
squash(delta: ElementsDelta): this;
|
|
157
191
|
private static createApplier;
|
|
158
192
|
private static createGetter;
|
|
159
193
|
private static applyDelta;
|
|
@@ -165,6 +199,8 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
165
199
|
* Resolves conflicts for all previously added, removed and updated elements.
|
|
166
200
|
* Updates the previous deltas with all the changes after conflict resolution.
|
|
167
201
|
*
|
|
202
|
+
* // TODO: revisit since some bound arrows seem to be often redrawn incorrectly
|
|
203
|
+
*
|
|
168
204
|
* @returns all elements affected by the conflict resolution
|
|
169
205
|
*/
|
|
170
206
|
private resolveConflicts;
|
|
@@ -178,6 +214,7 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
178
214
|
* should be rebound (if possible) with the current element ~ bindings should be bidirectional.
|
|
179
215
|
*/
|
|
180
216
|
private static rebindAffected;
|
|
217
|
+
static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
|
|
181
218
|
private static redrawTextBoundingBoxes;
|
|
182
219
|
private static redrawBoundArrows;
|
|
183
220
|
private static reorderElements;
|
|
@@ -187,5 +224,6 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
187
224
|
*/
|
|
188
225
|
private static postProcess;
|
|
189
226
|
private static stripIrrelevantProps;
|
|
227
|
+
private static stripVersionProps;
|
|
190
228
|
}
|
|
191
229
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GlobalPoint } from "@excalidraw/math";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
3
|
+
export declare const distanceToElement: (element: ExcalidrawElement, elementsMap: ElementsMap, p: GlobalPoint) => number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
1
2
|
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
2
3
|
export interface Distribution {
|
|
3
4
|
space: "between";
|
|
4
5
|
axis: "x" | "y";
|
|
5
6
|
}
|
|
6
|
-
export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution) => ExcalidrawElement[];
|
|
7
|
+
export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>) => ExcalidrawElement[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
|
|
2
|
-
import type Scene from "@excalidraw/excalidraw/scene/Scene";
|
|
3
2
|
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
|
+
import type { Scene } from "./Scene";
|
|
4
4
|
export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -9,7 +9,7 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
|
|
|
9
9
|
y: number;
|
|
10
10
|
}, gridSize: NullableGridSize) => void;
|
|
11
11
|
export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
12
|
-
export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, widthAspectRatio, originOffset, informMutation, }: {
|
|
12
|
+
export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
|
|
13
13
|
newElement: NonDeletedExcalidrawElement;
|
|
14
14
|
elementType: AppState["activeTool"]["type"];
|
|
15
15
|
originX: number;
|
|
@@ -21,6 +21,7 @@ export declare const dragNewElement: ({ newElement, elementType, originX, origin
|
|
|
21
21
|
shouldMaintainAspectRatio: boolean;
|
|
22
22
|
shouldResizeFromCenter: boolean;
|
|
23
23
|
zoom: NormalizedZoomValue;
|
|
24
|
+
scene: Scene;
|
|
24
25
|
/** whether to keep given aspect ratio when `isResizeWithSidesSameLength` is
|
|
25
26
|
true */
|
|
26
27
|
widthAspectRatio?: number | null | undefined;
|
|
@@ -13,13 +13,16 @@ import type { ExcalidrawElement, GroupId } from "./types";
|
|
|
13
13
|
* multiple elements at once, share this map
|
|
14
14
|
* amongst all of them
|
|
15
15
|
* @param element Element to duplicate
|
|
16
|
-
* @param overrides Any element properties to override
|
|
17
16
|
*/
|
|
18
|
-
export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement,
|
|
17
|
+
export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, randomizeSeed?: boolean) => Readonly<TElement>;
|
|
19
18
|
export declare const duplicateElements: (opts: {
|
|
20
19
|
elements: readonly ExcalidrawElement[];
|
|
21
20
|
randomizeSeed?: boolean | undefined;
|
|
22
|
-
overrides?: ((
|
|
21
|
+
overrides?: ((data: {
|
|
22
|
+
duplicateElement: ExcalidrawElement;
|
|
23
|
+
origElement: ExcalidrawElement;
|
|
24
|
+
origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
|
|
25
|
+
}) => Partial<ExcalidrawElement>) | undefined;
|
|
23
26
|
} & ({
|
|
24
27
|
/**
|
|
25
28
|
* Duplicates all elements in array.
|
|
@@ -42,17 +45,11 @@ export declare const duplicateElements: (opts: {
|
|
|
42
45
|
editingGroupId: AppState["editingGroupId"];
|
|
43
46
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
44
47
|
};
|
|
45
|
-
/**
|
|
46
|
-
* If true, duplicated elements are inserted _before_ specified
|
|
47
|
-
* elements. Case: alt-dragging elements to duplicate them.
|
|
48
|
-
*
|
|
49
|
-
* TODO: remove this once (if) we stop replacing the original element
|
|
50
|
-
* with the duplicated one in the scene array.
|
|
51
|
-
*/
|
|
52
|
-
reverseOrder: boolean;
|
|
53
48
|
})) => {
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
duplicatedElements: ExcalidrawElement[];
|
|
50
|
+
duplicateElementsMap: Map<string, ExcalidrawElement>;
|
|
51
|
+
elementsWithDuplicates: ExcalidrawElement[];
|
|
52
|
+
origIdToDuplicateId: Map<string, string>;
|
|
56
53
|
};
|
|
57
54
|
/**
|
|
58
55
|
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
@@ -8,7 +8,7 @@ export declare const BASE_PADDING = 40;
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArrowElement>, elementsMap: NonDeletedSceneElementsMap, updates: {
|
|
10
10
|
points?: readonly LocalPoint[];
|
|
11
|
-
fixedSegments?: FixedSegment[] | null;
|
|
11
|
+
fixedSegments?: readonly FixedSegment[] | null;
|
|
12
12
|
startBinding?: FixedPointBinding | null;
|
|
13
13
|
endBinding?: FixedPointBinding | null;
|
|
14
14
|
}, options?: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
|
|
2
2
|
import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
|
|
3
|
+
import type { Scene } from "./Scene";
|
|
3
4
|
type LinkDirection = "up" | "right" | "down" | "left";
|
|
4
5
|
export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
|
|
5
6
|
export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
|
|
6
|
-
export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement,
|
|
7
|
+
export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number) => ExcalidrawElement[];
|
|
7
8
|
export declare class FlowChartNavigator {
|
|
8
9
|
isExploring: boolean;
|
|
9
10
|
private sameLevelNodes;
|
|
@@ -18,7 +19,7 @@ export declare class FlowChartCreator {
|
|
|
18
19
|
private numberOfNodes;
|
|
19
20
|
private direction;
|
|
20
21
|
pendingNodes: PendingExcalidrawElements | null;
|
|
21
|
-
createNodes(startNode: ExcalidrawFlowchartNodeElement,
|
|
22
|
+
createNodes(startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene): void;
|
|
22
23
|
clear(): void;
|
|
23
24
|
}
|
|
24
25
|
export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { 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
|
}
|
|
@@ -42,10 +42,16 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
|
|
|
42
42
|
* Synchronizes invalid fractional indices of moved elements with the array order by mutating passed elements.
|
|
43
43
|
* If the synchronization fails or the result is invalid, it fallbacks to `syncInvalidIndices`.
|
|
44
44
|
*/
|
|
45
|
-
export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements:
|
|
45
|
+
export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: ElementsMap) => OrderedExcalidrawElement[];
|
|
46
46
|
/**
|
|
47
|
-
* Synchronizes all invalid fractional indices
|
|
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExcalidrawElementsIncludingDeleted } from "@excalidraw/excalidraw/scene/Scene";
|
|
2
1
|
import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
|
|
3
2
|
import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
|
|
3
|
+
import type { ExcalidrawElementsIncludingDeleted } from "./Scene";
|
|
4
4
|
import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
|
|
5
|
-
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[],
|
|
5
|
+
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
6
6
|
export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
|
|
7
7
|
export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
|
|
8
8
|
export declare const isElementContainingFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
|
|
33
33
|
export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
|
|
34
|
-
export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").
|
|
35
|
-
export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").
|
|
34
|
+
export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
|
|
35
|
+
export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
|
|
36
36
|
export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
|
|
37
37
|
/** */
|
|
38
38
|
export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
|
|
@@ -64,6 +64,7 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
|
|
|
64
64
|
checkedGroups?: Map<string, boolean>;
|
|
65
65
|
}) => boolean;
|
|
66
66
|
export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
|
|
67
|
+
export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
|
|
67
68
|
export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
|
|
68
69
|
export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
|
|
69
70
|
export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
|
|
@@ -31,3 +31,4 @@ export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<strin
|
|
|
31
31
|
export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
|
|
32
32
|
export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
|
|
33
33
|
export declare const getNewGroupIdsForDuplication: (groupIds: ExcalidrawElement["groupIds"], editingGroupId: AppState["editingGroupId"], mapper: (groupId: GroupId) => GroupId) => string[];
|
|
34
|
+
export declare const getSelectedElementsByGroup: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<AppState>) => ExcalidrawElement[][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
1
|
+
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMapOrArray } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated unsafe, use hashElementsVersion instead
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
|
|
|
6
6
|
/**
|
|
7
7
|
* Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
|
|
8
8
|
*/
|
|
9
|
-
export declare const hashElementsVersion: (elements:
|
|
9
|
+
export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
|
|
10
10
|
export declare const hashString: (s: string) => number;
|
|
11
11
|
export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
12
12
|
export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
|
|
@@ -14,3 +14,44 @@ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element:
|
|
|
14
14
|
export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
15
15
|
export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
16
16
|
export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
17
|
+
export * from "./align";
|
|
18
|
+
export * from "./binding";
|
|
19
|
+
export * from "./bounds";
|
|
20
|
+
export * from "./collision";
|
|
21
|
+
export * from "./comparisons";
|
|
22
|
+
export * from "./containerCache";
|
|
23
|
+
export * from "./cropElement";
|
|
24
|
+
export * from "./delta";
|
|
25
|
+
export * from "./distance";
|
|
26
|
+
export * from "./distribute";
|
|
27
|
+
export * from "./dragElements";
|
|
28
|
+
export * from "./duplicate";
|
|
29
|
+
export * from "./elbowArrow";
|
|
30
|
+
export * from "./elementLink";
|
|
31
|
+
export * from "./embeddable";
|
|
32
|
+
export * from "./flowchart";
|
|
33
|
+
export * from "./fractionalIndex";
|
|
34
|
+
export * from "./frame";
|
|
35
|
+
export * from "./groups";
|
|
36
|
+
export * from "./heading";
|
|
37
|
+
export * from "./image";
|
|
38
|
+
export * from "./linearElementEditor";
|
|
39
|
+
export * from "./mutateElement";
|
|
40
|
+
export * from "./newElement";
|
|
41
|
+
export * from "./renderElement";
|
|
42
|
+
export * from "./resizeElements";
|
|
43
|
+
export * from "./resizeTest";
|
|
44
|
+
export * from "./Scene";
|
|
45
|
+
export * from "./selection";
|
|
46
|
+
export * from "./shape";
|
|
47
|
+
export * from "./showSelectedShapeActions";
|
|
48
|
+
export * from "./sizeHelpers";
|
|
49
|
+
export * from "./sortElements";
|
|
50
|
+
export * from "./store";
|
|
51
|
+
export * from "./textElement";
|
|
52
|
+
export * from "./textMeasurements";
|
|
53
|
+
export * from "./textWrapping";
|
|
54
|
+
export * from "./transformHandles";
|
|
55
|
+
export * from "./typeChecks";
|
|
56
|
+
export * from "./utils";
|
|
57
|
+
export * from "./zindex";
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
|
|
3
|
-
import
|
|
4
|
-
import type { Store } from "@excalidraw/excalidraw/store";
|
|
3
|
+
import { type Store } from "@excalidraw/element";
|
|
5
4
|
import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
|
|
5
|
+
import type { Scene } from "./Scene";
|
|
6
6
|
import type { Bounds } from "./bounds";
|
|
7
|
-
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap,
|
|
8
|
-
declare const editorMidPointsCache: {
|
|
9
|
-
version: number | null;
|
|
10
|
-
points: (GlobalPoint | null)[];
|
|
11
|
-
zoom: number | null;
|
|
12
|
-
};
|
|
7
|
+
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
|
|
13
8
|
export declare class LinearElementEditor {
|
|
14
9
|
readonly elementId: ExcalidrawElement["id"] & {
|
|
15
10
|
_brand: "excalidrawLinearElementId";
|
|
@@ -43,7 +38,9 @@ export declare class LinearElementEditor {
|
|
|
43
38
|
readonly hoverPointIndex: number;
|
|
44
39
|
readonly segmentMidPointHoveredCoords: GlobalPoint | null;
|
|
45
40
|
readonly elbowed: boolean;
|
|
46
|
-
|
|
41
|
+
readonly customLineAngle: number | null;
|
|
42
|
+
readonly isEditing: boolean;
|
|
43
|
+
constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, isEditing?: boolean);
|
|
47
44
|
static POINT_HANDLE_SIZE: number;
|
|
48
45
|
/**
|
|
49
46
|
* @param id the `elementId` from the instance of this class (so that we can
|
|
@@ -54,19 +51,15 @@ export declare class LinearElementEditor {
|
|
|
54
51
|
/**
|
|
55
52
|
* @returns whether point was dragged
|
|
56
53
|
*/
|
|
57
|
-
static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number,
|
|
58
|
-
x: number;
|
|
59
|
-
y: number;
|
|
60
|
-
}[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): LinearElementEditor | null;
|
|
54
|
+
static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, keyof AppState> | null;
|
|
61
55
|
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
|
|
62
|
-
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (
|
|
63
|
-
static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
|
|
56
|
+
static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
|
|
64
57
|
static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
65
58
|
x: number;
|
|
66
59
|
y: number;
|
|
67
60
|
}, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
|
|
68
61
|
static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
|
|
69
|
-
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>,
|
|
62
|
+
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
|
|
70
63
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
|
|
71
64
|
static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
|
|
72
65
|
x: number;
|
|
@@ -77,7 +70,7 @@ export declare class LinearElementEditor {
|
|
|
77
70
|
linearElementEditor: LinearElementEditor | null;
|
|
78
71
|
};
|
|
79
72
|
static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
|
|
80
|
-
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties
|
|
73
|
+
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
|
|
81
74
|
/** scene coords */
|
|
82
75
|
static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
|
|
83
76
|
/** scene coords */
|
|
@@ -89,30 +82,25 @@ export declare class LinearElementEditor {
|
|
|
89
82
|
static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
|
|
90
83
|
/**
|
|
91
84
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
92
|
-
* expected in various parts of the codebase.
|
|
93
|
-
*
|
|
85
|
+
* expected in various parts of the codebase.
|
|
86
|
+
*
|
|
87
|
+
* Also returns normalized x and y coords to account for the normalization
|
|
88
|
+
* of the points.
|
|
94
89
|
*/
|
|
95
|
-
static
|
|
90
|
+
static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
|
|
96
91
|
points: LocalPoint[];
|
|
97
92
|
x: number;
|
|
98
93
|
y: number;
|
|
99
94
|
};
|
|
100
|
-
static
|
|
101
|
-
static
|
|
102
|
-
static
|
|
103
|
-
static
|
|
104
|
-
point: LocalPoint;
|
|
105
|
-
}[]): void;
|
|
106
|
-
static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
|
|
107
|
-
index: number;
|
|
108
|
-
point: LocalPoint;
|
|
109
|
-
isDragging?: boolean;
|
|
110
|
-
}[], otherUpdates?: {
|
|
95
|
+
static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
|
|
96
|
+
static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
|
|
97
|
+
static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
|
|
98
|
+
static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
|
|
111
99
|
startBinding?: PointBinding | null;
|
|
112
100
|
endBinding?: PointBinding | null;
|
|
113
|
-
}
|
|
101
|
+
}): void;
|
|
114
102
|
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
|
|
115
|
-
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean,
|
|
103
|
+
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
|
|
116
104
|
pointerDownState: LinearElementEditor["pointerDownState"];
|
|
117
105
|
selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
|
|
118
106
|
} | undefined;
|
|
@@ -124,7 +112,6 @@ export declare class LinearElementEditor {
|
|
|
124
112
|
};
|
|
125
113
|
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
126
114
|
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
127
|
-
static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number,
|
|
128
|
-
static deleteFixedSegment(element: ExcalidrawElbowArrowElement, index: number): void;
|
|
115
|
+
static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
|
|
116
|
+
static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
|
|
129
117
|
}
|
|
130
|
-
export {};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
2
|
-
import type { ExcalidrawElement } from "./types";
|
|
3
|
-
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "
|
|
4
|
-
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
3
|
+
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
|
|
4
|
+
/**
|
|
5
|
+
* This function tracks updates of text elements for the purposes for collaboration.
|
|
6
|
+
* The version is used to compare updates when more than one user is working in
|
|
7
|
+
* the same drawing.
|
|
8
|
+
*
|
|
9
|
+
* WARNING: this won't trigger the component to update, so if you need to trigger component update,
|
|
10
|
+
* use `scene.mutateElement` or `ExcalidrawImperativeAPI.mutateElement` instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, elementsMap: ElementsMap, updates: ElementUpdate<TElement>, options?: {
|
|
5
13
|
isDragging?: boolean;
|
|
6
14
|
}) => TElement;
|
|
7
15
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>, force?: boolean) => TElement;
|