@dwelle/excalidraw 0.5.0-ff7b5f2db → 0.5.0-ffade30
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/CHANGELOG.md +2385 -0
- package/dist/dev/{chunk-56C7N44U.js → chunk-CB6O5JO7.js} +16177 -10984
- package/dist/dev/chunk-CB6O5JO7.js.map +7 -0
- package/dist/dev/{chunk-DGCWVQGA.js → chunk-JB4JDZ66.js} +15 -4
- package/dist/dev/chunk-JB4JDZ66.js.map +7 -0
- package/dist/dev/chunk-QXVP5PAI.js +7 -0
- package/dist/dev/chunk-QXVP5PAI.js.map +7 -0
- package/dist/dev/data/{image-BLSI3C2P.js → image-JTJWA4BG.js} +3 -3
- package/dist/dev/index.css +143 -68
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +3978 -6519
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-AAITTNRF.js → en-PIB5PD3P.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-JEM5OQGK.js +33 -0
- package/dist/prod/chunk-JH36RZFS.js +7 -0
- package/dist/prod/{chunk-OV23WS6X.js → chunk-KC3NX2DX.js} +4 -4
- package/dist/prod/data/image-UJJWHTZ6.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +22 -21
- package/dist/prod/locales/{en-YOZMX4VX.js → en-RKTHI3YA.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/colors.d.ts +1 -0
- package/dist/types/common/src/constants.d.ts +11 -1
- 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 +22 -5
- package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
- package/dist/types/element/src/ShapeCache.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +3 -3
- package/dist/types/element/src/binding.d.ts +19 -11
- package/dist/types/element/src/bounds.d.ts +7 -2
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +40 -35
- 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 +2 -2
- package/dist/types/element/src/frame.d.ts +5 -4
- package/dist/types/element/src/heading.d.ts +0 -1
- package/dist/types/element/src/index.d.ts +45 -2
- package/dist/types/element/src/linearElementEditor.d.ts +19 -31
- package/dist/types/element/src/mutateElement.d.ts +10 -2
- package/dist/types/element/src/newElement.d.ts +4 -3
- package/dist/types/element/src/resizeElements.d.ts +4 -4
- package/dist/types/element/src/selection.d.ts +11 -5
- package/dist/types/element/src/shapes.d.ts +5 -1
- package/dist/types/element/src/sizeHelpers.d.ts +1 -1
- package/dist/types/element/src/store.d.ts +227 -0
- package/dist/types/element/src/textElement.d.ts +5 -3
- package/dist/types/element/src/transformHandles.d.ts +4 -4
- package/dist/types/element/src/typeChecks.d.ts +15 -1
- package/dist/types/element/src/types.d.ts +14 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +28 -30
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +438 -275
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +86 -92
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +40 -43
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +43 -47
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionExport.d.ts +219 -228
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -36
- package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +100 -104
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -36
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +506 -14
- package/dist/types/excalidraw/actions/actionLink.d.ts +14 -15
- package/dist/types/excalidraw/actions/actionMenu.d.ts +42 -45
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +27 -29
- package/dist/types/excalidraw/actions/actionProperties.d.ts +207 -214
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionStyles.d.ts +18 -19
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -189
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -18
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/animated-trail.d.ts +7 -1
- package/dist/types/excalidraw/appState.d.ts +40 -30
- package/dist/types/excalidraw/components/App.d.ts +30 -12
- 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/HotkeyLabel.d.ts +1 -2
- 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 +2 -2
- 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/{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 +1 -1
- 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 +4 -0
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/data/blob.d.ts +1 -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 +14 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +14 -22
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +9 -9
- package/dist/types/excalidraw/lasso/index.d.ts +16 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +12 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
- package/dist/types/excalidraw/scene/export.d.ts +1 -1
- 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 +30 -7
- package/dist/types/excalidraw/visualdebug.d.ts +1 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/curve.d.ts +2 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/polygon.d.ts +1 -0
- package/dist/types/math/src/segment.d.ts +1 -1
- package/dist/types/math/src/types.d.ts +1 -0
- package/dist/types/math/src/vector.d.ts +4 -0
- 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 +186 -0
- package/package.json +9 -4
- package/dist/dev/chunk-56C7N44U.js.map +0 -7
- package/dist/dev/chunk-DGCWVQGA.js.map +0 -7
- package/dist/dev/chunk-HQHB2BE4.js +0 -7
- package/dist/dev/chunk-HQHB2BE4.js.map +0 -7
- package/dist/prod/chunk-BUJ2ENHZ.js +0 -31
- package/dist/prod/chunk-C3FOHAIA.js +0 -7
- package/dist/prod/data/image-MI7OQWUS.js +0 -1
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/store.d.ts +0 -129
- /package/dist/dev/data/{image-BLSI3C2P.js.map → image-JTJWA4BG.js.map} +0 -0
- /package/dist/dev/locales/{en-AAITTNRF.js.map → en-PIB5PD3P.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-KC3NX2DX.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-JH36RZFS.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-JH36RZFS.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};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import oc from "open-color";
|
|
2
2
|
import { COLOR_WHITE, COLOR_CHARCOAL_BLACK, COLOR_TRANSPARENT } from "./constants";
|
|
3
3
|
import type { Merge } from "./utility-types";
|
|
4
|
+
export declare const COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;
|
|
4
5
|
export type ColorPickerColor = Exclude<keyof oc, "indigo" | "lime" | "black"> | "transparent" | "charcoal" | "bronze";
|
|
5
6
|
export type ColorTuple = readonly [string, string, string, string, string];
|
|
6
7
|
export type ColorPalette = Merge<Record<ColorPickerColor, ColorTuple>, {
|
|
@@ -88,6 +88,7 @@ export declare const CLASSES: {
|
|
|
88
88
|
SHAPE_ACTIONS_MENU: string;
|
|
89
89
|
ZOOM_ACTIONS: string;
|
|
90
90
|
SEARCH_MENU_INPUT_WRAPPER: string;
|
|
91
|
+
CONVERT_ELEMENT_TYPE_POPUP: string;
|
|
91
92
|
};
|
|
92
93
|
export declare const CJK_HAND_DRAWN_FALLBACK_FONT = "Xiaolai";
|
|
93
94
|
export declare const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
@@ -108,6 +109,7 @@ export declare const FONT_FAMILY: {
|
|
|
108
109
|
"Lilita One": number;
|
|
109
110
|
"Comic Shanns": number;
|
|
110
111
|
"Liberation Sans": number;
|
|
112
|
+
Assistant: number;
|
|
111
113
|
};
|
|
112
114
|
export declare const FONT_FAMILY_FALLBACKS: {
|
|
113
115
|
Xiaolai: number;
|
|
@@ -196,7 +198,7 @@ export declare const EXPORT_DATA_TYPES: {
|
|
|
196
198
|
readonly excalidrawLibrary: "excalidrawlib";
|
|
197
199
|
readonly excalidrawClipboardWithAPI: "excalidraw-api/clipboard";
|
|
198
200
|
};
|
|
199
|
-
export declare const
|
|
201
|
+
export declare const getExportSource: () => string;
|
|
200
202
|
export declare const IMAGE_RENDER_TIMEOUT = 500;
|
|
201
203
|
export declare const TAP_TWICE_TIMEOUT = 300;
|
|
202
204
|
export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
|
|
@@ -228,6 +230,7 @@ export declare const DEFAULT_EXPORT_PADDING = 10;
|
|
|
228
230
|
export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
|
|
229
231
|
export declare const MAX_ALLOWED_FILE_BYTES: number;
|
|
230
232
|
export declare const SVG_NS = "http://www.w3.org/2000/svg";
|
|
233
|
+
export declare const SVG_DOCUMENT_PREAMBLE = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
|
231
234
|
export declare const ENCRYPTION_KEY_BITS = 128;
|
|
232
235
|
export declare const VERSIONS: {
|
|
233
236
|
readonly excalidraw: 2;
|
|
@@ -283,6 +286,7 @@ export declare const DEFAULT_SIDEBAR: {
|
|
|
283
286
|
export declare const LIBRARY_DISABLED_TYPES: Set<"embeddable" | "image" | "iframe">;
|
|
284
287
|
export declare const TOOL_TYPE: {
|
|
285
288
|
readonly selection: "selection";
|
|
289
|
+
readonly lasso: "lasso";
|
|
286
290
|
readonly rectangle: "rectangle";
|
|
287
291
|
readonly diamond: "diamond";
|
|
288
292
|
readonly ellipse: "ellipse";
|
|
@@ -325,3 +329,9 @@ export declare enum UserIdleState {
|
|
|
325
329
|
AWAY = "away",
|
|
326
330
|
IDLE = "idle"
|
|
327
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* distance at which we merge points instead of adding a new merge-point
|
|
334
|
+
* when converting a line to a polygon (merge currently means overlaping
|
|
335
|
+
* the start and end points)
|
|
336
|
+
*/
|
|
337
|
+
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,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
|
+
import type { ExcalidrawBindableElement, FontFamilyValues, FontString, ExcalidrawElement } from "@excalidraw/element/types";
|
|
2
3
|
import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "@excalidraw/excalidraw/types";
|
|
3
4
|
import type { MaybePromise } from "./utility-types";
|
|
4
5
|
import type { EVENT } from "./constants";
|
|
@@ -6,9 +7,9 @@ export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
|
6
7
|
export declare const getDateTime: () => string;
|
|
7
8
|
export declare const capitalizeString: (str: string) => string;
|
|
8
9
|
export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
|
|
9
|
-
export declare const isInputLike: (target: Element | EventTarget | null) => target is
|
|
10
|
+
export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement | HTMLTextAreaElement;
|
|
10
11
|
export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
|
|
11
|
-
export declare const isWritableElement: (target: Element | EventTarget | null) => target is
|
|
12
|
+
export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLBRElement | HTMLDivElement | HTMLTextAreaElement;
|
|
12
13
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
13
14
|
fontFamily: FontFamilyValues;
|
|
14
15
|
}) => string;
|
|
@@ -87,6 +88,7 @@ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">,
|
|
|
87
88
|
customType: string;
|
|
88
89
|
}) & {
|
|
89
90
|
locked?: boolean;
|
|
91
|
+
fromSelection?: boolean;
|
|
90
92
|
}) & {
|
|
91
93
|
lastActiveToolBeforeEraser?: ActiveTool | null;
|
|
92
94
|
}) => AppState["activeTool"];
|
|
@@ -136,6 +138,8 @@ export declare const tupleToCoors: (xyTuple: readonly [number, number]) => {
|
|
|
136
138
|
export declare const muteFSAbortError: (error?: Error) => void;
|
|
137
139
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
138
140
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
141
|
+
/** returns the first non-null mapped value */
|
|
142
|
+
export declare const mapFind: <T, K>(collection: readonly T[], iteratee: (value: T, index: number) => K | null | undefined) => K | undefined;
|
|
139
143
|
export declare const isTransparent: (color: string) => boolean;
|
|
140
144
|
export declare const isBindingFallthroughEnabled: (el: ExcalidrawBindableElement) => boolean;
|
|
141
145
|
export type ResolvablePromise<T> = Promise<T> & {
|
|
@@ -176,6 +180,15 @@ export type Node<T> = T & {
|
|
|
176
180
|
* Creates a circular doubly linked list by adding `prev` and `next` props to the existing array nodes.
|
|
177
181
|
*/
|
|
178
182
|
export declare const arrayToList: <T>(array: readonly T[]) => Node<T>[];
|
|
183
|
+
/**
|
|
184
|
+
* Converts a readonly array or map into an iterable.
|
|
185
|
+
* Useful for avoiding entry allocations when iterating object / map on each iteration.
|
|
186
|
+
*/
|
|
187
|
+
export declare const toIterable: <T>(values: ReadonlyMap<string, T> | readonly T[]) => Iterable<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Converts a readonly array or map into an array.
|
|
190
|
+
*/
|
|
191
|
+
export declare const toArray: <T>(values: ReadonlyMap<string, T> | readonly T[]) => T[];
|
|
179
192
|
export declare const isTestEnv: () => boolean;
|
|
180
193
|
export declare const isDevEnv: () => boolean;
|
|
181
194
|
export declare const isProdEnv: () => boolean;
|
|
@@ -185,7 +198,7 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
|
|
|
185
198
|
}>;
|
|
186
199
|
export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
|
|
187
200
|
export declare const isPrimitive: (val: any) => boolean;
|
|
188
|
-
export declare const getFrame: () => "
|
|
201
|
+
export declare const getFrame: () => "top" | "iframe";
|
|
189
202
|
export declare const isRunningInIframe: () => boolean;
|
|
190
203
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
191
204
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
@@ -248,5 +261,9 @@ export declare const safelyParseJSON: (json: string) => Record<string, any> | nu
|
|
|
248
261
|
*/
|
|
249
262
|
export declare const escapeDoubleQuotes: (str: string) => string;
|
|
250
263
|
export declare const castArray: <T>(value: T | T[]) => T[];
|
|
251
|
-
export declare const
|
|
264
|
+
export declare const elementCenterPoint: (element: ExcalidrawElement, xOffset?: number, yOffset?: number) => GlobalPoint;
|
|
265
|
+
/** hack for Array.isArray type guard not working with readonly value[] */
|
|
266
|
+
export declare const isReadonlyArray: (value?: any) => value is readonly any[];
|
|
267
|
+
export declare const sizeOf: (value: readonly unknown[] | Readonly<Map<string, unknown>> | Readonly<Record<string, unknown>> | ReadonlySet<unknown>) => number;
|
|
268
|
+
export declare const reduceToCommonValue: <T, R = T>(collection: ReadonlySet<T> | readonly T[], getValue?: ((item: T) => R) | undefined) => R | null;
|
|
252
269
|
export {};
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ElementUpdate } from "@excalidraw/element";
|
|
2
2
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement, ElementsMapOrArray, OrderedExcalidrawElement, Ordered } from "@excalidraw/element/types";
|
|
3
|
-
import type {
|
|
4
|
-
type
|
|
5
|
-
type ElementKey = ExcalidrawElement | ElementIdKey;
|
|
3
|
+
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
4
|
+
import type { AppState } from "../../excalidraw/types";
|
|
6
5
|
type SceneStateCallback = () => void;
|
|
7
6
|
type SceneStateCallbackRemover = () => void;
|
|
8
7
|
export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
|
|
9
|
-
declare class Scene {
|
|
10
|
-
private static sceneMapByElement;
|
|
11
|
-
private static sceneMapById;
|
|
12
|
-
static mapElementToScene(elementKey: ElementKey, scene: Scene): void;
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated pass down `app.scene` and use it directly
|
|
15
|
-
*/
|
|
16
|
-
static getScene(elementKey: ElementKey): Scene | null;
|
|
8
|
+
export declare class Scene {
|
|
17
9
|
private callbacks;
|
|
18
10
|
private nonDeletedElements;
|
|
19
11
|
private nonDeletedElementsMap;
|
|
@@ -35,6 +27,7 @@ declare class Scene {
|
|
|
35
27
|
getElementsMapIncludingDeleted(): Map<string, Ordered<ExcalidrawElement>> & import("@excalidraw/common/utility-types").MakeBrand<"SceneElementsMap">;
|
|
36
28
|
getNonDeletedElements(): readonly Ordered<NonDeletedExcalidrawElement>[];
|
|
37
29
|
getFramesIncludingDeleted(): readonly ExcalidrawFrameLikeElement[];
|
|
30
|
+
constructor(elements?: ElementsMapOrArray | null);
|
|
38
31
|
getSelectedElements(opts: {
|
|
39
32
|
selectedElementIds: AppState["selectedElementIds"];
|
|
40
33
|
/**
|
|
@@ -73,7 +66,11 @@ declare class Scene {
|
|
|
73
66
|
getElementIndex(elementId: string): number;
|
|
74
67
|
getContainerElement: (element: (ExcalidrawElement & {
|
|
75
68
|
containerId: ExcalidrawElement["id"] | null;
|
|
76
|
-
}) | null) => import("@excalidraw/element/types").
|
|
69
|
+
}) | null) => import("@excalidraw/element/types").ExcalidrawSelectionElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | null;
|
|
77
70
|
getElementsFromId: (id: string) => ExcalidrawElement[];
|
|
71
|
+
mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
|
|
72
|
+
informMutation: boolean;
|
|
73
|
+
isDragging: boolean;
|
|
74
|
+
}): TElement;
|
|
78
75
|
}
|
|
79
|
-
export
|
|
76
|
+
export {};
|
|
@@ -17,7 +17,7 @@ export declare class ShapeCache {
|
|
|
17
17
|
* Generates & caches shape for element if not already cached, otherwise
|
|
18
18
|
* returns cached shape.
|
|
19
19
|
*/
|
|
20
|
-
static generateElementShape: <T extends import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").
|
|
20
|
+
static generateElementShape: <T extends import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawArrowElement | import("./types").ExcalidrawFreeDrawElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawEmbeddableElement>(element: T, renderConfig: {
|
|
21
21
|
isExporting: boolean;
|
|
22
22
|
canvasBackgroundColor: StaticCanvasRenderConfig["canvasBackgroundColor"];
|
|
23
23
|
embedsValidationStatus: EmbedsValidationStatus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type Scene from "
|
|
2
|
-
import type {
|
|
1
|
+
import type { Scene } from "./Scene";
|
|
2
|
+
import type { ExcalidrawElement } from "./types";
|
|
3
3
|
export interface Alignment {
|
|
4
4
|
position: "start" | "center" | "end";
|
|
5
5
|
axis: "x" | "y";
|
|
6
6
|
}
|
|
7
|
-
export declare const alignElements: (selectedElements: ExcalidrawElement[],
|
|
7
|
+
export declare const alignElements: (selectedElements: ExcalidrawElement[], alignment: Alignment, scene: Scene) => ExcalidrawElement[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { LocalPoint } from "@excalidraw/math";
|
|
3
|
-
import type Scene from "@excalidraw/excalidraw/scene/Scene";
|
|
4
3
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
5
4
|
import { type Heading } from "./heading";
|
|
5
|
+
import type { Scene } from "./Scene";
|
|
6
6
|
import type { Bounds } from "./bounds";
|
|
7
7
|
import type { ElementUpdate } from "./mutateElement";
|
|
8
|
-
import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap,
|
|
8
|
+
import type { ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, ExcalidrawLinearElement, NonDeletedExcalidrawElement, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, FixedPoint } from "./types";
|
|
9
9
|
export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
|
|
10
10
|
export type SuggestedPointBinding = [
|
|
11
11
|
NonDeleted<ExcalidrawLinearElement>,
|
|
@@ -17,35 +17,43 @@ 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
19
|
export declare const BINDING_HIGHLIGHT_OFFSET = 4;
|
|
20
|
-
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep",
|
|
21
|
-
export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[],
|
|
20
|
+
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep", scene: Scene) => void;
|
|
21
|
+
export declare const bindOrUnbindLinearElements: (selectedElements: NonDeleted<ExcalidrawLinearElement>[], isBindingEnabled: boolean, draggingPoints: readonly number[] | null, scene: Scene, zoom?: AppState["zoom"]) => void;
|
|
22
22
|
export declare const getSuggestedBindingsForArrows: (selectedElements: NonDeleted<ExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => SuggestedBinding[];
|
|
23
23
|
export declare const maybeBindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, appState: AppState, pointerCoords: {
|
|
24
24
|
x: number;
|
|
25
25
|
y: number;
|
|
26
|
-
},
|
|
27
|
-
export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end",
|
|
26
|
+
}, scene: Scene) => void;
|
|
27
|
+
export declare const bindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", scene: Scene) => void;
|
|
28
28
|
export declare const isLinearElementSimpleAndAlreadyBound: (linearElement: NonDeleted<ExcalidrawLinearElement>, alreadyBoundToId: ExcalidrawBindableElement["id"] | undefined, bindableElement: ExcalidrawBindableElement) => boolean;
|
|
29
29
|
export declare const getHoveredElementForBinding: (pointerCoords: {
|
|
30
30
|
x: number;
|
|
31
31
|
y: number;
|
|
32
32
|
}, elements: readonly NonDeletedExcalidrawElement[], elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], fullShape?: boolean, considerAllElements?: boolean) => NonDeleted<ExcalidrawBindableElement> | null;
|
|
33
|
-
export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement,
|
|
33
|
+
export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
|
|
34
34
|
simultaneouslyUpdated?: readonly ExcalidrawElement[];
|
|
35
35
|
newSize?: {
|
|
36
36
|
width: number;
|
|
37
37
|
height: number;
|
|
38
38
|
};
|
|
39
|
-
changedElements?: Map<string,
|
|
39
|
+
changedElements?: Map<string, ExcalidrawElement>;
|
|
40
40
|
}) => void;
|
|
41
|
-
export declare const
|
|
41
|
+
export declare const updateBindings: (latestElement: ExcalidrawElement, scene: Scene, options?: {
|
|
42
|
+
simultaneouslyUpdated?: readonly ExcalidrawElement[];
|
|
43
|
+
newSize?: {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
zoom?: AppState["zoom"];
|
|
48
|
+
}) => 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;
|
|
42
50
|
export declare const bindPointToSnapToElementOutline: (arrow: ExcalidrawElbowArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => GlobalPoint;
|
|
43
51
|
export declare const avoidRectangularCorner: (element: ExcalidrawBindableElement, p: GlobalPoint) => GlobalPoint;
|
|
44
52
|
export declare const snapToMid: (element: ExcalidrawBindableElement, p: GlobalPoint, tolerance?: number) => GlobalPoint;
|
|
45
|
-
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end"
|
|
53
|
+
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end") => {
|
|
46
54
|
fixedPoint: FixedPoint;
|
|
47
55
|
};
|
|
48
|
-
export declare const
|
|
56
|
+
export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
|
|
49
57
|
export declare const fixBindingsAfterDeletion: (sceneElements: readonly ExcalidrawElement[], deletedElements: readonly ExcalidrawElement[]) => void;
|
|
50
58
|
export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
|
|
51
59
|
x: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Degrees, GlobalPoint, LineSegment } from "@excalidraw/math";
|
|
2
2
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
3
|
-
import type { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, ExcalidrawFreeDrawElement, NonDeleted, ElementsMap } 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;
|
|
@@ -30,6 +30,11 @@ export declare class ElementBounds {
|
|
|
30
30
|
private static calculateBounds;
|
|
31
31
|
}
|
|
32
32
|
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
33
|
+
/**
|
|
34
|
+
* Given an element, return the line segments that make up the element.
|
|
35
|
+
*
|
|
36
|
+
* Uses helpers from /math
|
|
37
|
+
*/
|
|
33
38
|
export declare const getElementLineSegments: (element: ExcalidrawElement, elementsMap: ElementsMap) => LineSegment<GlobalPoint>[];
|
|
34
39
|
/**
|
|
35
40
|
* Scene -> Scene coords, but in x1,x2,y1,y2 format.
|
|
@@ -46,7 +51,7 @@ export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
|
|
|
46
51
|
export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
|
|
47
52
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
48
53
|
export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap) => Bounds;
|
|
49
|
-
export declare const getCommonBounds: (elements:
|
|
54
|
+
export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
|
|
50
55
|
export declare const getDraggedElementsBounds: (elements: ExcalidrawElement[], dragOffset: {
|
|
51
56
|
x: number;
|
|
52
57
|
y: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type GeometricShape } from "@excalidraw/utils/shape";
|
|
1
2
|
import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
|
|
2
|
-
import type { GeometricShape } from "@excalidraw/utils/shape";
|
|
3
3
|
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
4
4
|
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
5
5
|
export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
|
|
@@ -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 type { ElementUpdate } from "./mutateElement";
|
|
5
5
|
/**
|
|
6
6
|
* Represents the difference between two objects of the same type.
|
|
7
7
|
*
|
|
@@ -11,7 +11,7 @@ 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();
|
|
@@ -56,11 +56,11 @@ declare class Delta<T> {
|
|
|
56
56
|
*/
|
|
57
57
|
static isRightDifferent<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): boolean;
|
|
58
58
|
/**
|
|
59
|
-
* Returns
|
|
59
|
+
* Returns sorted object1 keys that have distinct values.
|
|
60
60
|
*/
|
|
61
61
|
static getLeftDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
62
62
|
/**
|
|
63
|
-
* Returns
|
|
63
|
+
* Returns sorted object2 keys that have distinct values.
|
|
64
64
|
*/
|
|
65
65
|
static getRightDifferences<T extends {}>(object1: T, object2: T, skipShallowCompare?: boolean): string[];
|
|
66
66
|
/**
|
|
@@ -73,37 +73,33 @@ declare class Delta<T> {
|
|
|
73
73
|
private static distinctKeysIterator;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* Encapsulates
|
|
76
|
+
* Encapsulates a set of application-level `Delta`s.
|
|
77
77
|
*/
|
|
78
|
-
interface
|
|
78
|
+
export interface DeltaContainer<T> {
|
|
79
79
|
/**
|
|
80
|
-
* Inverses the `Delta`s
|
|
80
|
+
* Inverses the `Delta`s while creating a new `DeltaContainer` instance.
|
|
81
81
|
*/
|
|
82
|
-
inverse():
|
|
82
|
+
inverse(): DeltaContainer<T>;
|
|
83
83
|
/**
|
|
84
|
-
* Applies the `
|
|
84
|
+
* Applies the `Delta`s to the previous object.
|
|
85
85
|
*
|
|
86
|
-
* @returns a tuple of the next object `T` with applied
|
|
86
|
+
* @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
87
|
*/
|
|
88
88
|
applyTo(previous: T, ...options: unknown[]): [T, boolean];
|
|
89
89
|
/**
|
|
90
|
-
* Checks whether
|
|
90
|
+
* Checks whether all `Delta`s are empty.
|
|
91
91
|
*/
|
|
92
92
|
isEmpty(): boolean;
|
|
93
93
|
}
|
|
94
|
-
export declare class
|
|
95
|
-
|
|
94
|
+
export declare class AppStateDelta implements DeltaContainer<AppState> {
|
|
95
|
+
readonly delta: Delta<ObservedAppState>;
|
|
96
96
|
private constructor();
|
|
97
|
-
static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T):
|
|
98
|
-
static
|
|
99
|
-
|
|
97
|
+
static calculate<T extends ObservedAppState>(prevAppState: T, nextAppState: T): AppStateDelta;
|
|
98
|
+
static restore(appStateDeltaDTO: DTO<AppStateDelta>): AppStateDelta;
|
|
99
|
+
static empty(): AppStateDelta;
|
|
100
|
+
inverse(): AppStateDelta;
|
|
100
101
|
applyTo(appState: AppState, nextElements: SceneElementsMap): [AppState, boolean];
|
|
101
102
|
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
103
|
/**
|
|
108
104
|
* Mutates `nextAppState` be filtering out state related to deleted elements.
|
|
109
105
|
*
|
|
@@ -115,20 +111,27 @@ export declare class AppStateChange implements Change<AppState> {
|
|
|
115
111
|
private static filterSelectedGroups;
|
|
116
112
|
private static stripElementsProps;
|
|
117
113
|
private static stripStandaloneProps;
|
|
114
|
+
/**
|
|
115
|
+
* It is necessary to post process the partials in case of reference values,
|
|
116
|
+
* for which we need to calculate the real diff between `deleted` and `inserted`.
|
|
117
|
+
*/
|
|
118
|
+
private static postProcess;
|
|
119
|
+
private static orderAppStateKeys;
|
|
118
120
|
}
|
|
119
121
|
type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> = Omit<ElementUpdate<Ordered<T>>, "seed">;
|
|
120
122
|
/**
|
|
121
123
|
* Elements change is a low level primitive to capture a change between two sets of elements.
|
|
122
124
|
* It does so by encapsulating forward and backward `Delta`s, allowing to time-travel in both directions.
|
|
123
125
|
*/
|
|
124
|
-
export declare class
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
127
|
+
readonly added: Record<string, Delta<ElementPartial>>;
|
|
128
|
+
readonly removed: Record<string, Delta<ElementPartial>>;
|
|
129
|
+
readonly updated: Record<string, Delta<ElementPartial>>;
|
|
128
130
|
private constructor();
|
|
129
|
-
static create(added:
|
|
131
|
+
static create(added: Record<string, Delta<ElementPartial>>, removed: Record<string, Delta<ElementPartial>>, updated: Record<string, Delta<ElementPartial>>, options?: {
|
|
130
132
|
shouldRedistribute: boolean;
|
|
131
|
-
}):
|
|
133
|
+
}): ElementsDelta;
|
|
134
|
+
static restore(elementsDeltaDTO: DTO<ElementsDelta>): ElementsDelta;
|
|
132
135
|
private static satisfiesAddition;
|
|
133
136
|
private static satisfiesRemoval;
|
|
134
137
|
private static satisfiesUpdate;
|
|
@@ -139,11 +142,11 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
139
142
|
* @param prevElements - Map representing the previous state of elements.
|
|
140
143
|
* @param nextElements - Map representing the next state of elements.
|
|
141
144
|
*
|
|
142
|
-
* @returns `
|
|
145
|
+
* @returns `ElementsDelta` instance representing the `Delta` changes between the two sets of elements.
|
|
143
146
|
*/
|
|
144
|
-
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>):
|
|
145
|
-
static empty():
|
|
146
|
-
inverse():
|
|
147
|
+
static calculate<T extends OrderedExcalidrawElement>(prevElements: Map<string, T>, nextElements: Map<string, T>): ElementsDelta;
|
|
148
|
+
static empty(): ElementsDelta;
|
|
149
|
+
inverse(): ElementsDelta;
|
|
147
150
|
isEmpty(): boolean;
|
|
148
151
|
/**
|
|
149
152
|
* Update delta/s based on the existing elements.
|
|
@@ -152,8 +155,8 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
152
155
|
* @param modifierOptions defines which of the delta (`deleted` or `inserted`) will be updated
|
|
153
156
|
* @returns new instance with modified delta/s
|
|
154
157
|
*/
|
|
155
|
-
applyLatestChanges(elements: SceneElementsMap):
|
|
156
|
-
applyTo(elements: SceneElementsMap,
|
|
158
|
+
applyLatestChanges(elements: SceneElementsMap, modifierOptions: "deleted" | "inserted"): ElementsDelta;
|
|
159
|
+
applyTo(elements: SceneElementsMap, elementsSnapshot: Map<string, OrderedExcalidrawElement>): [SceneElementsMap, boolean];
|
|
157
160
|
private static createApplier;
|
|
158
161
|
private static createGetter;
|
|
159
162
|
private static applyDelta;
|
|
@@ -165,6 +168,8 @@ export declare class ElementsChange implements Change<SceneElementsMap> {
|
|
|
165
168
|
* Resolves conflicts for all previously added, removed and updated elements.
|
|
166
169
|
* Updates the previous deltas with all the changes after conflict resolution.
|
|
167
170
|
*
|
|
171
|
+
* // TODO: revisit since some bound arrows seem to be often redrawn incorrectly
|
|
172
|
+
*
|
|
168
173
|
* @returns all elements affected by the conflict resolution
|
|
169
174
|
*/
|
|
170
175
|
private resolveConflicts;
|
|
@@ -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;
|