@excalidraw/excalidraw 0.18.0-195a743 → 0.18.0-1b287a8ba
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-CBGOW5JB.js +5669 -0
- package/dist/dev/chunk-CBGOW5JB.js.map +7 -0
- package/dist/dev/chunk-CP5DND7P.js +7 -0
- package/dist/dev/chunk-CP5DND7P.js.map +7 -0
- package/dist/dev/{chunk-T3M44BFV.js → chunk-QF5FRM6O.js} +12 -4
- package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
- package/dist/dev/data/{image-TTQKTTOH.js → image-SURZSZNX.js} +3 -3
- package/dist/dev/index.css +89 -22
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +7516 -9372
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-I23TB6DJ.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-I4UNSFV6.js +12 -0
- package/dist/prod/chunk-IRHK23LL.js +4 -0
- package/dist/prod/data/image-HXEZYJPQ.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +26 -19
- package/dist/prod/locales/{en-TC3OFDA6.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 +19 -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 +15 -5
- package/dist/types/element/src/Scene.d.ts +4 -4
- package/dist/types/element/src/align.d.ts +3 -2
- package/dist/types/element/src/binding.d.ts +11 -8
- package/dist/types/element/src/bounds.d.ts +12 -4
- 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} +63 -38
- 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 +1 -1
- package/dist/types/element/src/flowchart.d.ts +1 -1
- package/dist/types/element/src/fractionalIndex.d.ts +8 -2
- package/dist/types/element/src/frame.d.ts +3 -2
- 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 +15 -29
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +3 -2
- package/dist/types/element/src/resizeElements.d.ts +2 -1
- package/dist/types/element/src/selection.d.ts +0 -5
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/sizeHelpers.d.ts +2 -1
- package/dist/types/element/src/store.d.ts +232 -0
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/typeChecks.d.ts +16 -1
- package/dist/types/element/src/types.d.ts +13 -3
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/element/src/zindex.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +39 -48
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -32
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +173 -212
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +75 -92
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +34 -42
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -15
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -48
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionExport.d.ts +127 -154
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +69 -35
- package/dist/types/excalidraw/actions/actionFrame.d.ts +99 -111
- package/dist/types/excalidraw/actions/actionGroup.d.ts +26 -32
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +505 -15
- package/dist/types/excalidraw/actions/actionLink.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionMenu.d.ts +38 -47
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +26 -32
- package/dist/types/excalidraw/actions/actionProperties.d.ts +186 -223
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -15
- package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +12 -188
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionZindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/types.d.ts +3 -2
- package/dist/types/excalidraw/appState.d.ts +16 -7
- package/dist/types/excalidraw/components/App.d.ts +18 -20
- 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 +2 -28
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
- 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 +2 -1
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
- 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/transform.d.ts +1 -1
- package/dist/types/excalidraw/eraser/index.d.ts +0 -2
- 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 +10 -9
- package/dist/types/excalidraw/lasso/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +23 -10
- 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/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 +147 -110
- package/package.json +12 -9
- package/dist/dev/chunk-H3EW23X2.js +0 -18294
- package/dist/dev/chunk-H3EW23X2.js.map +0 -7
- package/dist/dev/chunk-T3M44BFV.js.map +0 -7
- package/dist/dev/chunk-WMGEUIQQ.js +0 -7
- package/dist/dev/chunk-WMGEUIQQ.js.map +0 -7
- package/dist/prod/chunk-2Z7RPVPO.js +0 -12
- package/dist/prod/chunk-7M43VNIB.js +0 -33
- package/dist/prod/chunk-GK4XUKZB.js +0 -7
- package/dist/prod/data/image-7YYIWLVQ.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-TTQKTTOH.js.map → image-SURZSZNX.js.map} +0 -0
- /package/dist/dev/locales/{en-I23TB6DJ.js.map → en-SMAPCEOQ.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-I4UNSFV6.js";import"../chunk-SRAX5OIU.js";export{f as alerts,e as buttons,l as canvasError,s as clearCanvasDialog,C as colorPicker,A as colors,I as commandPalette,v as confirmDialog,J as default,i as element,b as elementLink,x as encrypted,p as errorDialog,m as errorSplash,g as errors,q as exportDialog,G as fontList,j as headings,r as helpDialog,k as hints,w as imageExportDialog,a as labels,c as library,E as mermaid,D as overwriteConfirm,t as publishDialog,u as publishSuccessDialog,F as quickSearch,o as roomDialog,d as search,n as shareDialog,y as stats,z as toast,h as toolBar,H as userList,B as welcomeScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-
|
|
1
|
+
import{a,b,c,d}from"./chunk-LS7FJGPW.js";import"./chunk-A66AFZZU.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-
|
|
1
|
+
import{a as r,c as t}from"./chunk-LS7FJGPW.js";import"./chunk-A66AFZZU.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
|
|
@@ -109,11 +109,21 @@ export declare const FONT_FAMILY: {
|
|
|
109
109
|
"Lilita One": number;
|
|
110
110
|
"Comic Shanns": number;
|
|
111
111
|
"Liberation Sans": number;
|
|
112
|
+
Assistant: number;
|
|
113
|
+
};
|
|
114
|
+
export declare const SANS_SERIF_GENERIC_FONT = "sans-serif";
|
|
115
|
+
export declare const MONOSPACE_GENERIC_FONT = "monospace";
|
|
116
|
+
export declare const FONT_FAMILY_GENERIC_FALLBACKS: {
|
|
117
|
+
"sans-serif": number;
|
|
118
|
+
monospace: number;
|
|
112
119
|
};
|
|
113
120
|
export declare const FONT_FAMILY_FALLBACKS: {
|
|
114
|
-
Xiaolai: number;
|
|
115
121
|
"Segoe UI Emoji": number;
|
|
122
|
+
"sans-serif": number;
|
|
123
|
+
monospace: number;
|
|
124
|
+
Xiaolai: number;
|
|
116
125
|
};
|
|
126
|
+
export declare function getGenericFontFamilyFallback(fontFamily: number): keyof typeof FONT_FAMILY_GENERIC_FALLBACKS;
|
|
117
127
|
export declare const getFontFamilyFallbacks: (fontFamily: number) => Array<keyof typeof FONT_FAMILY_FALLBACKS>;
|
|
118
128
|
export declare const THEME: {
|
|
119
129
|
readonly LIGHT: "light";
|
|
@@ -195,7 +205,7 @@ export declare const EXPORT_DATA_TYPES: {
|
|
|
195
205
|
readonly excalidrawLibrary: "excalidrawlib";
|
|
196
206
|
readonly excalidrawClipboardWithAPI: "excalidraw-api/clipboard";
|
|
197
207
|
};
|
|
198
|
-
export declare const
|
|
208
|
+
export declare const getExportSource: () => string;
|
|
199
209
|
export declare const IMAGE_RENDER_TIMEOUT = 500;
|
|
200
210
|
export declare const TAP_TWICE_TIMEOUT = 300;
|
|
201
211
|
export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
|
|
@@ -279,7 +289,7 @@ export declare const DEFAULT_SIDEBAR: {
|
|
|
279
289
|
readonly name: "default";
|
|
280
290
|
readonly defaultTab: "library";
|
|
281
291
|
};
|
|
282
|
-
export declare const LIBRARY_DISABLED_TYPES: Set<"embeddable" | "
|
|
292
|
+
export declare const LIBRARY_DISABLED_TYPES: Set<"embeddable" | "iframe" | "image">;
|
|
283
293
|
export declare const TOOL_TYPE: {
|
|
284
294
|
readonly selection: "selection";
|
|
285
295
|
readonly lasso: "lasso";
|
|
@@ -325,3 +335,9 @@ export declare enum UserIdleState {
|
|
|
325
335
|
AWAY = "away",
|
|
326
336
|
IDLE = "idle"
|
|
327
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* distance at which we merge points instead of adding a new merge-point
|
|
340
|
+
* when converting a line to a polygon (merge currently means overlaping
|
|
341
|
+
* the start and end points)
|
|
342
|
+
*/
|
|
343
|
+
export declare const LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UnsubscribeCallback } from "
|
|
1
|
+
import type { UnsubscribeCallback } from "@excalidraw/excalidraw/types";
|
|
2
2
|
type Subscriber<T extends any[]> = (...payload: T) => void;
|
|
3
3
|
export declare class Emitter<T extends any[] = []> {
|
|
4
4
|
subscribers: Subscriber<T>[];
|
|
@@ -16,8 +16,10 @@ export interface FontMetadata {
|
|
|
16
16
|
};
|
|
17
17
|
/** flag to indicate a deprecated font */
|
|
18
18
|
deprecated?: true;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* whether this is a font that users can use (= shown in font picker)
|
|
21
|
+
*/
|
|
22
|
+
private?: true;
|
|
21
23
|
/** flag to indiccate a local-only font */
|
|
22
24
|
local?: true;
|
|
23
25
|
/** flag to indicate a fallback font */
|
|
@@ -31,3 +31,8 @@ export type MakeBrand<T extends string> = {
|
|
|
31
31
|
/** Maybe just promise or already fulfilled one! */
|
|
32
32
|
export type MaybePromise<T> = T | Promise<T>;
|
|
33
33
|
export type AllPossibleKeys<T> = T extends any ? keyof T : never;
|
|
34
|
+
/** Strip all the methods or functions from a type */
|
|
35
|
+
export type DTO<T> = {
|
|
36
|
+
[K in keyof T as T[K] extends Function ? never : K]: T[K];
|
|
37
|
+
};
|
|
38
|
+
export type MapEntry<M extends Map<any, any>> = M extends Map<infer K, infer V> ? [K, V] : never;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement } from "@excalidraw/element/types";
|
|
1
|
+
import type { ExcalidrawBindableElement, FontFamilyValues, FontString } from "@excalidraw/element/types";
|
|
3
2
|
import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "@excalidraw/excalidraw/types";
|
|
4
3
|
import type { MaybePromise } from "./utility-types";
|
|
5
4
|
import type { EVENT } from "./constants";
|
|
@@ -138,6 +137,8 @@ export declare const tupleToCoors: (xyTuple: readonly [number, number]) => {
|
|
|
138
137
|
export declare const muteFSAbortError: (error?: Error) => void;
|
|
139
138
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
140
139
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
140
|
+
/** returns the first non-null mapped value */
|
|
141
|
+
export declare const mapFind: <T, K>(collection: readonly T[], iteratee: (value: T, index: number) => K | null | undefined) => K | undefined;
|
|
141
142
|
export declare const isTransparent: (color: string) => boolean;
|
|
142
143
|
export declare const isBindingFallthroughEnabled: (el: ExcalidrawBindableElement) => boolean;
|
|
143
144
|
export type ResolvablePromise<T> = Promise<T> & {
|
|
@@ -178,6 +179,15 @@ export type Node<T> = T & {
|
|
|
178
179
|
* Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.
|
|
179
180
|
*/
|
|
180
181
|
export declare const arrayToList: <T>(array: readonly T[]) => Node<T>[];
|
|
182
|
+
/**
|
|
183
|
+
* Converts a readonly array or map into an iterable.
|
|
184
|
+
* Useful for avoiding entry allocations when iterating object / map on each iteration.
|
|
185
|
+
*/
|
|
186
|
+
export declare const toIterable: <T>(values: ReadonlyMap<string, T> | readonly T[]) => Iterable<T>;
|
|
187
|
+
/**
|
|
188
|
+
* Converts a readonly array or map into an array.
|
|
189
|
+
*/
|
|
190
|
+
export declare const toArray: <T>(values: ReadonlyMap<string, T> | readonly T[]) => T[];
|
|
181
191
|
export declare const isTestEnv: () => boolean;
|
|
182
192
|
export declare const isDevEnv: () => boolean;
|
|
183
193
|
export declare const isProdEnv: () => boolean;
|
|
@@ -187,7 +197,7 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
|
|
|
187
197
|
}>;
|
|
188
198
|
export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
|
|
189
199
|
export declare const isPrimitive: (val: any) => boolean;
|
|
190
|
-
export declare const getFrame: () => "
|
|
200
|
+
export declare const getFrame: () => "top" | "iframe";
|
|
191
201
|
export declare const isRunningInIframe: () => boolean;
|
|
192
202
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
193
203
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
@@ -250,8 +260,8 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
|
|
|
250
260
|
*/
|
|
251
261
|
export declare const escapeDoubleQuotes: (str: string) => string;
|
|
252
262
|
export declare const castArray: <T>(value: T | T[]) => T[];
|
|
253
|
-
export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
|
|
254
263
|
/** hack for Array.isArray type guard not working with readonly value[] */
|
|
255
264
|
export declare const isReadonlyArray: (value?: any) => value is readonly any[];
|
|
256
|
-
export declare const sizeOf: (value: readonly
|
|
265
|
+
export declare const sizeOf: (value: readonly unknown[] | Readonly<Map<string, unknown>> | Readonly<Record<string, unknown>> | ReadonlySet<unknown>) => number;
|
|
266
|
+
export declare const reduceToCommonValue: <T, R = T>(collection: ReadonlySet<T> | readonly T[], getValue?: ((item: T) => R) | undefined) => R | null;
|
|
257
267
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type ElementUpdate } from "@excalidraw/element
|
|
1
|
+
import { type ElementUpdate } from "@excalidraw/element";
|
|
2
2
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement, ElementsMapOrArray, OrderedExcalidrawElement, Ordered } from "@excalidraw/element/types";
|
|
3
3
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
4
4
|
import type { AppState } from "../../excalidraw/types";
|
|
5
5
|
type SceneStateCallback = () => void;
|
|
6
6
|
type SceneStateCallbackRemover = () => void;
|
|
7
7
|
export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
|
|
8
|
-
declare class Scene {
|
|
8
|
+
export declare class Scene {
|
|
9
9
|
private callbacks;
|
|
10
10
|
private nonDeletedElements;
|
|
11
11
|
private nonDeletedElementsMap;
|
|
@@ -66,11 +66,11 @@ declare class Scene {
|
|
|
66
66
|
getElementIndex(elementId: string): number;
|
|
67
67
|
getContainerElement: (element: (ExcalidrawElement & {
|
|
68
68
|
containerId: ExcalidrawElement["id"] | null;
|
|
69
|
-
}) | null) => import("@excalidraw/element/types").
|
|
69
|
+
}) | null) => import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawSelectionElement | 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 | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | null;
|
|
70
70
|
getElementsFromId: (id: string) => ExcalidrawElement[];
|
|
71
71
|
mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
|
|
72
72
|
informMutation: boolean;
|
|
73
73
|
isDragging: boolean;
|
|
74
74
|
}): TElement;
|
|
75
75
|
}
|
|
76
|
-
export
|
|
76
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
2
|
+
import type { Scene } from "./Scene";
|
|
2
3
|
import type { ExcalidrawElement } from "./types";
|
|
3
4
|
export interface Alignment {
|
|
4
5
|
position: "start" | "center" | "end";
|
|
5
6
|
axis: "x" | "y";
|
|
6
7
|
}
|
|
7
|
-
export declare const alignElements: (selectedElements: ExcalidrawElement[], alignment: Alignment, scene: Scene) => ExcalidrawElement[];
|
|
8
|
+
export declare const alignElements: (selectedElements: ExcalidrawElement[], alignment: Alignment, scene: Scene, appState: Readonly<AppState>) => ExcalidrawElement[];
|
|
@@ -2,7 +2,7 @@ import { type GlobalPoint } from "@excalidraw/math";
|
|
|
2
2
|
import type { LocalPoint } from "@excalidraw/math";
|
|
3
3
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
4
4
|
import { type Heading } from "./heading";
|
|
5
|
-
import type Scene from "./Scene";
|
|
5
|
+
import type { Scene } from "./Scene";
|
|
6
6
|
import type { Bounds } from "./bounds";
|
|
7
7
|
import type { ElementUpdate } from "./mutateElement";
|
|
8
8
|
import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, FixedPoint } from "./types";
|
|
@@ -16,10 +16,13 @@ export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEv
|
|
|
16
16
|
export declare const isBindingEnabled: (appState: AppState) => boolean;
|
|
17
17
|
export declare const FIXED_BINDING_DISTANCE = 5;
|
|
18
18
|
export declare const BINDING_HIGHLIGHT_THICKNESS = 10;
|
|
19
|
-
export declare const BINDING_HIGHLIGHT_OFFSET = 4;
|
|
20
19
|
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", scene: Scene) => void;
|
|
21
20
|
export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], isBindingEnabled: boolean, draggingPoints: readonly number[] | null, scene: Scene, zoom?: AppState["zoom"]) => void;
|
|
22
21
|
export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => SuggestedBinding[];
|
|
22
|
+
export declare const maybeSuggestBindingsForLinearElementAtCoords: (linearElement: NonDeleted<ExcalidrawLinearElement>, pointerCoords: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
}[], scene: Scene, zoom: AppState["zoom"], oppositeBindingBoundElement?: ExcalidrawBindableElement | null) => ExcalidrawBindableElement[];
|
|
23
26
|
export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
|
|
24
27
|
x: number;
|
|
25
28
|
y: number;
|
|
@@ -46,11 +49,11 @@ export declare const updateBindings: (latestElement: ExcalidrawElement, scene: S
|
|
|
46
49
|
};
|
|
47
50
|
zoom?: AppState["zoom"];
|
|
48
51
|
}) => void;
|
|
49
|
-
export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, zoom?: AppState["zoom"]) => Heading;
|
|
50
|
-
export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => GlobalPoint;
|
|
51
|
-
export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
|
|
52
|
-
export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
|
|
53
|
-
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => {
|
|
52
|
+
export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, elementsMap: ElementsMap, zoom?: AppState["zoom"]) => Heading;
|
|
53
|
+
export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => GlobalPoint;
|
|
54
|
+
export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
|
|
55
|
+
export declare const snapToMid: (element: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number) => GlobalPoint;
|
|
56
|
+
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
|
|
54
57
|
fixedPoint: FixedPoint;
|
|
55
58
|
};
|
|
56
59
|
export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
|
|
@@ -101,7 +104,7 @@ export declare class BindableElement {
|
|
|
101
104
|
*/
|
|
102
105
|
static rebindAffected: (elements: ElementsMap, bindableElement: ExcalidrawElement | undefined, updateElementWith: (affected: ExcalidrawElement, updates: ElementUpdate<ExcalidrawElement>) => void) => void;
|
|
103
106
|
}
|
|
104
|
-
export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement) => GlobalPoint;
|
|
107
|
+
export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: [number, number], element: ExcalidrawBindableElement, elementsMap: ElementsMap) => GlobalPoint;
|
|
105
108
|
export declare const getGlobalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
|
|
106
109
|
export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
|
|
107
110
|
export declare const normalizeFixedPoint: <T extends FixedPoint | null>(fixedPoint: T) => T extends null ? null : FixedPoint;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Degrees, GlobalPoint, LineSegment } from "@excalidraw/math";
|
|
1
|
+
import type { Degrees, GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
3
|
-
import type { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap, ElementsMapOrArray } from "./types";
|
|
4
3
|
import type { Drawable, Op } from "roughjs/bin/core";
|
|
4
|
+
import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawLinearElement, NonDeleted } from "./types";
|
|
5
5
|
export type RectangleBox = {
|
|
6
6
|
x: number;
|
|
7
7
|
y: number;
|
|
@@ -26,7 +26,8 @@ export type SceneBounds = readonly [
|
|
|
26
26
|
];
|
|
27
27
|
export declare class ElementBounds {
|
|
28
28
|
private static boundsCache;
|
|
29
|
-
static
|
|
29
|
+
private static nonRotatedBoundsCache;
|
|
30
|
+
static getBounds(element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean): Bounds;
|
|
30
31
|
private static calculateBounds;
|
|
31
32
|
}
|
|
32
33
|
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
@@ -43,6 +44,7 @@ export declare const getElementLineSegments: (element: ExcalidrawElement, elemen
|
|
|
43
44
|
*/
|
|
44
45
|
export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
|
|
45
46
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
47
|
+
export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
|
|
46
48
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((p: GlobalPoint) => GlobalPoint) | undefined) => Bounds;
|
|
47
49
|
export declare const getBoundsFromPoints: (points: ExcalidrawFreeDrawElement["points"]) => Bounds;
|
|
48
50
|
/** @returns number in pixels */
|
|
@@ -50,7 +52,7 @@ export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
|
|
|
50
52
|
/** @returns number in degrees */
|
|
51
53
|
export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
|
|
52
54
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
53
|
-
export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap) => Bounds;
|
|
55
|
+
export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
|
|
54
56
|
export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
|
|
55
57
|
export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
|
|
56
58
|
x: number;
|
|
@@ -78,4 +80,10 @@ export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | read
|
|
|
78
80
|
*/
|
|
79
81
|
export declare const getVisibleSceneBounds: ({ scrollX, scrollY, width, height, zoom, }: AppState) => SceneBounds;
|
|
80
82
|
export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
|
|
83
|
+
/**
|
|
84
|
+
* Get the axis-aligned bounding box for a given element
|
|
85
|
+
*/
|
|
86
|
+
export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
|
|
87
|
+
export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
|
|
81
88
|
export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
|
|
89
|
+
export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
|
|
1
|
+
import type { GlobalPoint, LineSegment } from "@excalidraw/math";
|
|
3
2
|
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
4
3
|
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
5
4
|
export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
|
|
6
|
-
export type HitTestArgs
|
|
7
|
-
|
|
8
|
-
y: number;
|
|
5
|
+
export type HitTestArgs = {
|
|
6
|
+
point: GlobalPoint;
|
|
9
7
|
element: ExcalidrawElement;
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
threshold: number;
|
|
9
|
+
elementsMap: ElementsMap;
|
|
12
10
|
frameNameBound?: FrameNameBounds | null;
|
|
13
11
|
};
|
|
14
|
-
export declare const hitElementItself:
|
|
15
|
-
export declare const hitElementBoundingBox: (
|
|
16
|
-
export declare const hitElementBoundingBoxOnly:
|
|
17
|
-
export declare const hitElementBoundText:
|
|
12
|
+
export declare const hitElementItself: ({ point, element, threshold, elementsMap, frameNameBound, }: HitTestArgs) => boolean;
|
|
13
|
+
export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
|
|
14
|
+
export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
|
|
15
|
+
export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
|
|
18
16
|
/**
|
|
19
17
|
* Intersect a line with an element for binding test
|
|
20
18
|
*
|
|
@@ -23,4 +21,12 @@ export declare const hitElementBoundText: <Point extends GlobalPoint | LocalPoin
|
|
|
23
21
|
* @param offset
|
|
24
22
|
* @returns
|
|
25
23
|
*/
|
|
26
|
-
export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, line: LineSegment<GlobalPoint>, offset?: number) => GlobalPoint[];
|
|
24
|
+
export declare const intersectElementWithLineSegment: (element: ExcalidrawElement, elementsMap: ElementsMap, line: LineSegment<GlobalPoint>, offset?: number, onlyFirst?: boolean) => GlobalPoint[];
|
|
25
|
+
/**
|
|
26
|
+
* Check if the given point is considered inside the element's border
|
|
27
|
+
*
|
|
28
|
+
* @param point
|
|
29
|
+
* @param element
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare const isPointInElement: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TransformHandleType } from "./transformHandles";
|
|
2
2
|
import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
|
|
3
3
|
export declare const MINIMAL_CROP_SIZE = 10;
|
|
4
|
-
export declare const cropElement: (element: ExcalidrawImageElement, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
|
|
4
|
+
export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
7
7
|
width: number;
|
|
@@ -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
|
*
|
|
@@ -56,13 +56,29 @@ declare class Delta<T> {
|
|
|
56
56
|
*/
|
|
57
57
|
static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Compares if shared properties of object1 and object2 contain any different value (aka inner join).
|
|
60
|
+
*/
|
|
61
|
+
static isInnerDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Compares if any properties of object1 and object2 contain any different value (aka full join).
|
|
64
|
+
*/
|
|
65
|
+
static isDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns sorted object1 keys that have distinct values.
|
|
60
68
|
*/
|
|
61
69
|
static getLeftDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
62
70
|
/**
|
|
63
|
-
* Returns
|
|
71
|
+
* Returns sorted object2 keys that have distinct values.
|
|
64
72
|
*/
|
|
65
73
|
static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Returns sorted keys of shared object1 and object2 properties that have distinct values (aka inner join).
|
|
76
|
+
*/
|
|
77
|
+
static getInnerDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
78
|
+
/**
|
|
79
|
+
* Returns sorted keys that have distinct values between object1 and object2 (aka full join).
|
|
80
|
+
*/
|
|
81
|
+
static getDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
66
82
|
/**
|
|
67
83
|
* Iterator comparing values of object properties based on the passed joining strategy.
|
|
68
84
|
*
|
|
@@ -73,37 +89,33 @@ declare class Delta<T> {
|
|
|
73
89
|
private static distinctKeysIterator;
|
|
74
90
|
}
|
|
75
91
|
/**
|
|
76
|
-
* Encapsulates
|
|
92
|
+
* Encapsulates a set of application-level `Delta`s.
|
|
77
93
|
*/
|
|
78
|
-
interface
|
|
94
|
+
export interface DeltaContainer<T> {
|
|
79
95
|
/**
|
|
80
|
-
* Inverses the `Delta`s
|
|
96
|
+
* Inverses the `Delta`s while creating a new `DeltaContainer` instance.
|
|
81
97
|
*/
|
|
82
|
-
inverse():
|
|
98
|
+
inverse(): DeltaContainer<T>;
|
|
83
99
|
/**
|
|
84
|
-
* Applies the `
|
|
100
|
+
* Applies the `Delta`s to the previous object.
|
|
85
101
|
*
|
|
86
|
-
* @returns a tuple of the next object `T` with applied
|
|
102
|
+
* @returns a tuple of the next object `T` with applied `Delta`s, and `boolean`, indicating whether the applied deltas resulted in a visible change.
|
|
87
103
|
*/
|
|
88
104
|
applyTo(previous: T, ...options: unknown[]): [T, boolean];
|
|
89
105
|
/**
|
|
90
|
-
* Checks whether
|
|
106
|
+
* Checks whether all `Delta`s are empty.
|
|
91
107
|
*/
|
|
92
108
|
isEmpty(): boolean;
|
|
93
109
|
}
|
|
94
|
-
export declare class
|
|
95
|
-
|
|
110
|
+
export declare class AppStateDelta implements DeltaContainer<AppState> {
|
|
111
|
+
readonly delta: Delta<ObservedAppState>;
|
|
96
112
|
private constructor();
|
|
97
|
-
static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T):
|
|
98
|
-
static
|
|
99
|
-
|
|
113
|
+
static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
|
|
114
|
+
static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
|
|
115
|
+
static empty(): AppStateDelta;
|
|
116
|
+
inverse(): AppStateDelta;
|
|
100
117
|
applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
|
|
101
118
|
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
119
|
/**
|
|
108
120
|
* Mutates `nextAppState` be filtering out state related to deleted elements.
|
|
109
121
|
*
|
|
@@ -115,23 +127,34 @@ export declare class AppStateChange implements Change<AppState> {
|
|
|
115
127
|
private static filterSelectedGroups;
|
|
116
128
|
private static stripElementsProps;
|
|
117
129
|
private static stripStandaloneProps;
|
|
130
|
+
/**
|
|
131
|
+
* It is necessary to post process the partials in case of reference values,
|
|
132
|
+
* for which we need to calculate the real diff between `deleted` and `inserted`.
|
|
133
|
+
*/
|
|
134
|
+
private static postProcess;
|
|
135
|
+
private static orderAppStateKeys;
|
|
118
136
|
}
|
|
119
|
-
type ElementPartial<
|
|
137
|
+
type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
|
|
138
|
+
export type ApplyToOptions = {
|
|
139
|
+
excludedProperties: Set<keyof ElementPartial>;
|
|
140
|
+
};
|
|
120
141
|
/**
|
|
121
142
|
* Elements change is a low level primitive to capture a change between two sets of elements.
|
|
122
143
|
* It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
|
|
123
144
|
*/
|
|
124
|
-
export declare class
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
146
|
+
readonly added: Record<string, Delta<ElementPartial>>;
|
|
147
|
+
readonly removed: Record<string, Delta<ElementPartial>>;
|
|
148
|
+
readonly updated: Record<string, Delta<ElementPartial>>;
|
|
128
149
|
private constructor();
|
|
129
|
-
static create(added:
|
|
150
|
+
static create(added: Record<string, Delta<ElementPartial>>, removed: Record<string, Delta<ElementPartial>>, updated: Record<string, Delta<ElementPartial>>, options?: {
|
|
130
151
|
shouldRedistribute: boolean;
|
|
131
|
-
}):
|
|
152
|
+
}): ElementsDelta;
|
|
153
|
+
static restore(elementsDeltaDTO: DTO<ElementsDelta>): ElementsDelta;
|
|
132
154
|
private static satisfiesAddition;
|
|
133
155
|
private static satisfiesRemoval;
|
|
134
156
|
private static satisfiesUpdate;
|
|
157
|
+
private static satisfiesCommmonInvariants;
|
|
135
158
|
private static validate;
|
|
136
159
|
/**
|
|
137
160
|
* Calculates the `Delta`s between the previous and next set of elements.
|
|
@@ -139,21 +162,21 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
139
162
|
* @param prevElements - Map representing the previous state of elements.
|
|
140
163
|
* @param nextElements - Map representing the next state of elements.
|
|
141
164
|
*
|
|
142
|
-
* @returns `
|
|
165
|
+
* @returns `ElementsDelta` instance representing the `Delta` changes between the two sets of elements.
|
|
143
166
|
*/
|
|
144
|
-
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>):
|
|
145
|
-
static empty():
|
|
146
|
-
inverse():
|
|
167
|
+
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsDelta;
|
|
168
|
+
static empty(): ElementsDelta;
|
|
169
|
+
inverse(): ElementsDelta;
|
|
147
170
|
isEmpty(): boolean;
|
|
148
171
|
/**
|
|
149
172
|
* Update delta/s based on the existing elements.
|
|
150
173
|
*
|
|
151
|
-
* @param
|
|
174
|
+
* @param nextElements current elements
|
|
152
175
|
* @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
|
|
153
176
|
* @returns new instance with modified delta/s
|
|
154
177
|
*/
|
|
155
|
-
applyLatestChanges(
|
|
156
|
-
applyTo(elements: SceneElementsMap, snapshot
|
|
178
|
+
applyLatestChanges(prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): ElementsDelta;
|
|
179
|
+
applyTo(elements: SceneElementsMap, snapshot?: StoreSnapshot["elements"], options?: ApplyToOptions): [SceneElementsMap, boolean];
|
|
157
180
|
private static createApplier;
|
|
158
181
|
private static createGetter;
|
|
159
182
|
private static applyDelta;
|
|
@@ -165,6 +188,8 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
165
188
|
* Resolves conflicts for all previously added, removed and updated elements.
|
|
166
189
|
* Updates the previous deltas with all the changes after conflict resolution.
|
|
167
190
|
*
|
|
191
|
+
* // TODO: revisit since some bound arrows seem to be often redrawn incorrectly
|
|
192
|
+
*
|
|
168
193
|
* @returns all elements affected by the conflict resolution
|
|
169
194
|
*/
|
|
170
195
|
private resolveConflicts;
|
|
@@ -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
2
|
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
|
-
import type Scene from "./Scene";
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
+
import type { Scene } from "./Scene";
|
|
4
4
|
type LinkDirection = "up" | "right" | "down" | "left";
|
|
5
5
|
export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
|
|
6
6
|
export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementsMap, 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
|
}
|
|
@@ -44,8 +44,14 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
|
|
|
44
44
|
*/
|
|
45
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;
|