@dwelle/excalidraw 0.4.0-e7ba198 → 0.4.0-e80989b
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/README.md +1 -1
- package/dist/excalidraw.development.js +276 -166
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionCanvas.d.ts +7 -7
- package/types/actions/actionClipboard.d.ts +9 -0
- package/types/actions/actionDeleteSelected.d.ts +9 -0
- package/types/actions/actionExport.d.ts +7 -7
- package/types/appState.d.ts +7 -7
- package/types/clipboard.d.ts +6 -1
- package/types/components/App.d.ts +2 -1
- package/types/element/bounds.d.ts +2 -1
- package/types/element/linearElementEditor.d.ts +31 -4
- package/types/element/newElement.d.ts +2 -2
- package/types/element/resizeElements.d.ts +0 -1
- package/types/element/textElement.d.ts +17 -2
- package/types/element/transformHandles.d.ts +2 -3
- package/types/element/typeChecks.d.ts +1 -0
- package/types/element/types.d.ts +4 -1
- package/types/renderer/renderElement.d.ts +4 -3
- package/types/scene/Fonts.d.ts +21 -0
- package/types/scene/Scene.d.ts +15 -0
- package/types/scene/comparisons.d.ts +1 -2
- package/types/scene/index.d.ts +1 -1
- package/types/shapes.d.ts +1 -1
package/package.json
CHANGED
|
@@ -49,13 +49,6 @@ export declare const actionClearCanvas: {
|
|
|
49
49
|
locked: boolean;
|
|
50
50
|
};
|
|
51
51
|
name: string;
|
|
52
|
-
scrollX: number;
|
|
53
|
-
scrollY: number;
|
|
54
|
-
viewBackgroundColor: string;
|
|
55
|
-
zoom: Readonly<{
|
|
56
|
-
value: NormalizedZoomValue;
|
|
57
|
-
}>;
|
|
58
|
-
shouldCacheIgnoreZoom: boolean;
|
|
59
52
|
showWelcomeScreen: boolean;
|
|
60
53
|
isLoading: boolean;
|
|
61
54
|
errorMessage: string | null;
|
|
@@ -84,10 +77,16 @@ export declare const actionClearCanvas: {
|
|
|
84
77
|
currentItemStartArrowhead: import("../element/types").Arrowhead | null;
|
|
85
78
|
currentItemEndArrowhead: import("../element/types").Arrowhead | null;
|
|
86
79
|
currentItemLinearStrokeSharpness: import("../element/types").StrokeSharpness;
|
|
80
|
+
viewBackgroundColor: string;
|
|
81
|
+
scrollX: number;
|
|
82
|
+
scrollY: number;
|
|
87
83
|
cursorButton: "up" | "down";
|
|
88
84
|
scrolledOutside: boolean;
|
|
89
85
|
isResizing: boolean;
|
|
90
86
|
isRotating: boolean;
|
|
87
|
+
zoom: Readonly<{
|
|
88
|
+
value: NormalizedZoomValue;
|
|
89
|
+
}>;
|
|
91
90
|
openMenu: "canvas" | "shape" | null;
|
|
92
91
|
openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
|
|
93
92
|
openSidebar: "library" | "customSidebar" | null;
|
|
@@ -100,6 +99,7 @@ export declare const actionClearCanvas: {
|
|
|
100
99
|
previousSelectedElementIds: {
|
|
101
100
|
[id: string]: boolean;
|
|
102
101
|
};
|
|
102
|
+
shouldCacheIgnoreZoom: boolean;
|
|
103
103
|
toast: {
|
|
104
104
|
message: string;
|
|
105
105
|
closable?: boolean | undefined;
|
|
@@ -133,6 +133,15 @@ export declare const actionCut: {
|
|
|
133
133
|
pointerDownState: Readonly<{
|
|
134
134
|
prevSelectedPointsIndices: readonly number[] | null;
|
|
135
135
|
lastClickedPoint: number;
|
|
136
|
+
origin: Readonly<{
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
}> | null;
|
|
140
|
+
segmentMidpoint: {
|
|
141
|
+
value: readonly [number, number] | null;
|
|
142
|
+
index: number | null;
|
|
143
|
+
added: boolean;
|
|
144
|
+
};
|
|
136
145
|
}>;
|
|
137
146
|
isDragging: boolean;
|
|
138
147
|
lastUncommittedPoint: readonly [number, number] | null;
|
|
@@ -124,6 +124,15 @@ export declare const actionDeleteSelected: {
|
|
|
124
124
|
pointerDownState: Readonly<{
|
|
125
125
|
prevSelectedPointsIndices: readonly number[] | null;
|
|
126
126
|
lastClickedPoint: number;
|
|
127
|
+
origin: Readonly<{
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
}> | null;
|
|
131
|
+
segmentMidpoint: {
|
|
132
|
+
value: readonly [number, number] | null;
|
|
133
|
+
index: number | null;
|
|
134
|
+
added: boolean;
|
|
135
|
+
};
|
|
127
136
|
}>;
|
|
128
137
|
isDragging: boolean;
|
|
129
138
|
lastUncommittedPoint: readonly [number, number] | null;
|
|
@@ -712,13 +712,6 @@ export declare const actionLoadScene: {
|
|
|
712
712
|
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
713
713
|
locked: boolean;
|
|
714
714
|
};
|
|
715
|
-
scrollX: number;
|
|
716
|
-
scrollY: number;
|
|
717
|
-
viewBackgroundColor: string;
|
|
718
|
-
zoom: Readonly<{
|
|
719
|
-
value: import("../types").NormalizedZoomValue;
|
|
720
|
-
}>;
|
|
721
|
-
shouldCacheIgnoreZoom: boolean;
|
|
722
715
|
showWelcomeScreen: boolean;
|
|
723
716
|
isLoading: boolean;
|
|
724
717
|
errorMessage: string | null;
|
|
@@ -751,10 +744,16 @@ export declare const actionLoadScene: {
|
|
|
751
744
|
currentItemStartArrowhead: import("../element/types").Arrowhead | null;
|
|
752
745
|
currentItemEndArrowhead: import("../element/types").Arrowhead | null;
|
|
753
746
|
currentItemLinearStrokeSharpness: import("../element/types").StrokeSharpness;
|
|
747
|
+
viewBackgroundColor: string;
|
|
748
|
+
scrollX: number;
|
|
749
|
+
scrollY: number;
|
|
754
750
|
cursorButton: "up" | "down";
|
|
755
751
|
scrolledOutside: boolean;
|
|
756
752
|
isResizing: boolean;
|
|
757
753
|
isRotating: boolean;
|
|
754
|
+
zoom: Readonly<{
|
|
755
|
+
value: import("../types").NormalizedZoomValue;
|
|
756
|
+
}>;
|
|
758
757
|
openMenu: "canvas" | "shape" | null;
|
|
759
758
|
openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
|
|
760
759
|
openSidebar: "library" | "customSidebar" | null;
|
|
@@ -767,6 +766,7 @@ export declare const actionLoadScene: {
|
|
|
767
766
|
previousSelectedElementIds: {
|
|
768
767
|
[id: string]: boolean;
|
|
769
768
|
};
|
|
769
|
+
shouldCacheIgnoreZoom: boolean;
|
|
770
770
|
toast: {
|
|
771
771
|
message: string;
|
|
772
772
|
closable?: boolean | undefined;
|
package/types/appState.d.ts
CHANGED
|
@@ -14,13 +14,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
|
|
|
14
14
|
lastActiveToolBeforeEraser: import("./types").LastActiveToolBeforeEraser;
|
|
15
15
|
locked: boolean;
|
|
16
16
|
} | undefined;
|
|
17
|
-
scrollX?: number | undefined;
|
|
18
|
-
scrollY?: number | undefined;
|
|
19
|
-
viewBackgroundColor?: string | undefined;
|
|
20
|
-
zoom?: Readonly<{
|
|
21
|
-
value: NormalizedZoomValue;
|
|
22
|
-
}> | undefined;
|
|
23
|
-
shouldCacheIgnoreZoom?: boolean | undefined;
|
|
24
17
|
showWelcomeScreen?: boolean | undefined;
|
|
25
18
|
penMode?: boolean | undefined;
|
|
26
19
|
penDetected?: boolean | undefined;
|
|
@@ -42,8 +35,14 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
|
|
|
42
35
|
currentItemStartArrowhead?: import("./element/types").Arrowhead | null | undefined;
|
|
43
36
|
currentItemEndArrowhead?: import("./element/types").Arrowhead | null | undefined;
|
|
44
37
|
currentItemLinearStrokeSharpness?: import("./element/types").StrokeSharpness | undefined;
|
|
38
|
+
viewBackgroundColor?: string | undefined;
|
|
39
|
+
scrollX?: number | undefined;
|
|
40
|
+
scrollY?: number | undefined;
|
|
45
41
|
cursorButton?: "up" | "down" | undefined;
|
|
46
42
|
scrolledOutside?: boolean | undefined;
|
|
43
|
+
zoom?: Readonly<{
|
|
44
|
+
value: NormalizedZoomValue;
|
|
45
|
+
}> | undefined;
|
|
47
46
|
openMenu?: "canvas" | "shape" | null | undefined;
|
|
48
47
|
openSidebar?: "library" | "customSidebar" | null | undefined;
|
|
49
48
|
isSidebarDocked?: boolean | undefined;
|
|
@@ -54,6 +53,7 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
|
|
|
54
53
|
previousSelectedElementIds?: {
|
|
55
54
|
[id: string]: boolean;
|
|
56
55
|
} | undefined;
|
|
56
|
+
shouldCacheIgnoreZoom?: boolean | undefined;
|
|
57
57
|
zenModeEnabled?: boolean | undefined;
|
|
58
58
|
gridSize?: number | null | undefined;
|
|
59
59
|
selectedGroupIds?: {
|
package/types/clipboard.d.ts
CHANGED
|
@@ -12,9 +12,14 @@ export declare const probablySupportsClipboardReadText: boolean;
|
|
|
12
12
|
export declare const probablySupportsClipboardWriteText: boolean;
|
|
13
13
|
export declare const probablySupportsClipboardBlob: boolean;
|
|
14
14
|
export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles | null) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves content from system clipboard (either from ClipboardEvent or
|
|
17
|
+
* via async clipboard API if supported)
|
|
18
|
+
*/
|
|
19
|
+
export declare const getSystemClipboard: (event: ClipboardEvent | null) => Promise<string>;
|
|
15
20
|
/**
|
|
16
21
|
* Attempts to parse clipboard. Prefers system clipboard.
|
|
17
22
|
*/
|
|
18
|
-
export declare const parseClipboard: (event: ClipboardEvent | null) => Promise<ClipboardData>;
|
|
23
|
+
export declare const parseClipboard: (event: ClipboardEvent | null, isPlainPaste?: boolean) => Promise<ClipboardData>;
|
|
19
24
|
export declare const copyBlobToClipboardAsPng: (blob: Blob | Promise<Blob>) => Promise<void>;
|
|
20
25
|
export declare const copyTextToSystemClipboard: (text: string | null) => Promise<void>;
|
|
@@ -77,6 +77,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
77
77
|
private excalidrawContainerRef;
|
|
78
78
|
static defaultProps: Partial<AppProps>;
|
|
79
79
|
scene: Scene;
|
|
80
|
+
private fonts;
|
|
80
81
|
private resizeObserver;
|
|
81
82
|
private nearestScrollableContainer;
|
|
82
83
|
library: AppClassProperties["library"];
|
|
@@ -259,7 +260,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
259
260
|
private onBlur;
|
|
260
261
|
private onUnload;
|
|
261
262
|
private disableEvent;
|
|
262
|
-
private onFontLoaded;
|
|
263
263
|
private resetHistory;
|
|
264
264
|
/**
|
|
265
265
|
* Resets scene & history.
|
|
@@ -272,6 +272,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
272
272
|
componentWillUnmount(): void;
|
|
273
273
|
private onResize;
|
|
274
274
|
private removeEventListeners;
|
|
275
|
+
private onFontsLoadingDone;
|
|
275
276
|
private addEventListeners;
|
|
276
277
|
componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
|
|
277
278
|
private renderScene;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, NonDeleted } from "./types";
|
|
2
2
|
import { Drawable, Op } from "roughjs/bin/core";
|
|
3
3
|
export declare type Bounds = readonly [number, number, number, number];
|
|
4
|
-
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement) =>
|
|
4
|
+
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
5
5
|
export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number];
|
|
6
6
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
7
7
|
export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
8
|
+
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => [number, number, number, number];
|
|
8
9
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
9
10
|
export declare const getElementBounds: (element: ExcalidrawElement) => [number, number, number, number];
|
|
10
11
|
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => [number, number, number, number];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement } from "./types";
|
|
3
|
-
import { Point, AppState } from "../types";
|
|
2
|
+
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
|
|
3
|
+
import { Point, AppState, PointerCoords } from "../types";
|
|
4
4
|
import History from "../history";
|
|
5
5
|
import Scene from "../scene/Scene";
|
|
6
6
|
declare const editorMidPointsCache: {
|
|
@@ -18,6 +18,15 @@ export declare class LinearElementEditor {
|
|
|
18
18
|
prevSelectedPointsIndices: readonly number[] | null;
|
|
19
19
|
/** index */
|
|
20
20
|
lastClickedPoint: number;
|
|
21
|
+
origin: Readonly<{
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}> | null;
|
|
25
|
+
segmentMidpoint: {
|
|
26
|
+
value: Point | null;
|
|
27
|
+
index: number | null;
|
|
28
|
+
added: boolean;
|
|
29
|
+
};
|
|
21
30
|
}>;
|
|
22
31
|
/** whether you're dragging a point */
|
|
23
32
|
readonly isDragging: boolean;
|
|
@@ -60,7 +69,6 @@ export declare class LinearElementEditor {
|
|
|
60
69
|
didAddPoint: boolean;
|
|
61
70
|
hitElement: NonDeleted<ExcalidrawElement> | null;
|
|
62
71
|
linearElementEditor: LinearElementEditor | null;
|
|
63
|
-
isMidPoint: boolean;
|
|
64
72
|
};
|
|
65
73
|
static arePointsEqual(point1: Point | null, point2: Point | null): boolean;
|
|
66
74
|
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, appState: AppState): LinearElementEditor | null;
|
|
@@ -94,6 +102,15 @@ export declare class LinearElementEditor {
|
|
|
94
102
|
prevSelectedPointsIndices: readonly number[] | null;
|
|
95
103
|
/** index */
|
|
96
104
|
lastClickedPoint: number;
|
|
105
|
+
origin: Readonly<{
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
}> | null;
|
|
109
|
+
segmentMidpoint: {
|
|
110
|
+
value: readonly [number, number] | null;
|
|
111
|
+
index: number | null;
|
|
112
|
+
added: boolean;
|
|
113
|
+
};
|
|
97
114
|
}>;
|
|
98
115
|
isDragging: boolean;
|
|
99
116
|
lastUncommittedPoint: readonly [number, number] | null;
|
|
@@ -160,7 +177,6 @@ export declare class LinearElementEditor {
|
|
|
160
177
|
value: import("../types").NormalizedZoomValue;
|
|
161
178
|
}>;
|
|
162
179
|
openMenu: "canvas" | "shape" | null;
|
|
163
|
-
/** @returns whether point was dragged */
|
|
164
180
|
openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
|
|
165
181
|
openSidebar: "library" | "customSidebar" | null;
|
|
166
182
|
openDialog: "imageExport" | "help" | null;
|
|
@@ -218,7 +234,18 @@ export declare class LinearElementEditor {
|
|
|
218
234
|
startBinding?: PointBinding;
|
|
219
235
|
endBinding?: PointBinding;
|
|
220
236
|
}): void;
|
|
237
|
+
static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState): boolean;
|
|
238
|
+
static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState): {
|
|
239
|
+
pointerDownState: LinearElementEditor["pointerDownState"];
|
|
240
|
+
selectedPointsIndices: LinearElementEditor["selectedPointsIndices"];
|
|
241
|
+
} | undefined;
|
|
221
242
|
private static _updatePoints;
|
|
222
243
|
private static _getShiftLockedDelta;
|
|
244
|
+
static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
245
|
+
x: number;
|
|
246
|
+
y: number;
|
|
247
|
+
};
|
|
248
|
+
static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementBounds: [number, number, number, number], boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
|
|
249
|
+
static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
223
250
|
}
|
|
224
251
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues,
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
3
|
declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link">;
|
|
4
4
|
export declare const newElement: (opts: {
|
|
@@ -10,7 +10,7 @@ export declare const newTextElement: (opts: {
|
|
|
10
10
|
fontFamily: FontFamilyValues;
|
|
11
11
|
textAlign: TextAlign;
|
|
12
12
|
verticalAlign: VerticalAlign;
|
|
13
|
-
containerId?:
|
|
13
|
+
containerId?: ExcalidrawTextContainer["id"];
|
|
14
14
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
15
15
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
16
16
|
x: number;
|
|
@@ -3,7 +3,6 @@ import { MaybeTransformHandleType, TransformHandleDirection } from "./transformH
|
|
|
3
3
|
import { PointerDownState } from "../types";
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
5
5
|
export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
|
|
6
|
-
export declare const reshapeSingleTwoPointElement: (element: NonDeleted<ExcalidrawLinearElement>, resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, pointerX: number, pointerY: number) => void;
|
|
7
6
|
export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
8
7
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
9
8
|
export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
2
|
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
+
import { AppState } from "../types";
|
|
4
|
+
export declare const normalizeText: (text: string) => string;
|
|
3
5
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
|
|
4
6
|
export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
5
|
-
export declare const handleBindTextResize: (
|
|
7
|
+
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
|
|
6
8
|
export declare const measureText: (text: string, font: FontString, maxWidth?: number | null) => {
|
|
7
9
|
width: number;
|
|
8
10
|
height: number;
|
|
@@ -28,3 +30,16 @@ export declare const getContainerDims: (element: ExcalidrawElement) => {
|
|
|
28
30
|
width: number;
|
|
29
31
|
height: number;
|
|
30
32
|
};
|
|
33
|
+
export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState) => {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
|
|
38
|
+
export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
|
|
39
|
+
export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
} | undefined;
|
|
43
|
+
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
44
|
+
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
45
|
+
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
|
-
import { Bounds } from "./bounds";
|
|
3
2
|
import { AppState, Zoom } from "../types";
|
|
4
3
|
export declare type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
5
4
|
export declare type TransformHandleType = TransformHandleDirection | "rotation";
|
|
@@ -14,11 +13,11 @@ export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
|
|
|
14
13
|
n: boolean;
|
|
15
14
|
w: boolean;
|
|
16
15
|
};
|
|
17
|
-
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2]:
|
|
16
|
+
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
|
|
18
17
|
s?: boolean | undefined;
|
|
19
18
|
e?: boolean | undefined;
|
|
20
|
-
w?: boolean | undefined;
|
|
21
19
|
n?: boolean | undefined;
|
|
20
|
+
w?: boolean | undefined;
|
|
22
21
|
nw?: boolean | undefined;
|
|
23
22
|
ne?: boolean | undefined;
|
|
24
23
|
sw?: boolean | undefined;
|
|
@@ -7,6 +7,7 @@ export declare const isTextElement: (element: ExcalidrawElement | null) => eleme
|
|
|
7
7
|
export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
|
|
8
8
|
export declare const isFreeDrawElementType: (elementType: ExcalidrawElement["type"]) => boolean;
|
|
9
9
|
export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
10
|
+
export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
10
11
|
export declare const isLinearElementType: (elementType: AppState["activeTool"]["type"]) => boolean;
|
|
11
12
|
export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
|
|
12
13
|
export declare const isBindingElementType: (elementType: AppState["activeTool"]["type"]) => boolean;
|
package/types/element/types.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
102
102
|
originalText: string;
|
|
103
103
|
}>;
|
|
104
104
|
export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
|
|
105
|
-
export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement;
|
|
105
|
+
export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowEleement;
|
|
106
106
|
export declare type ExcalidrawTextElementWithContainer = {
|
|
107
107
|
containerId: ExcalidrawTextContainer["id"];
|
|
108
108
|
} & ExcalidrawTextElement;
|
|
@@ -121,6 +121,9 @@ export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<
|
|
|
121
121
|
startArrowhead: Arrowhead | null;
|
|
122
122
|
endArrowhead: Arrowhead | null;
|
|
123
123
|
}>;
|
|
124
|
+
export declare type ExcalidrawArrowEleement = ExcalidrawLinearElement & Readonly<{
|
|
125
|
+
type: "arrow";
|
|
126
|
+
}>;
|
|
124
127
|
export declare type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
|
125
128
|
type: "freedraw";
|
|
126
129
|
points: readonly Point[];
|
|
@@ -3,7 +3,7 @@ import { RoughCanvas } from "roughjs/bin/canvas";
|
|
|
3
3
|
import { Drawable, Options } from "roughjs/bin/core";
|
|
4
4
|
import { RoughSVG } from "roughjs/bin/svg";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
|
-
import { BinaryFiles, Zoom } from "../types";
|
|
6
|
+
import { AppState, BinaryFiles, Zoom } from "../types";
|
|
7
7
|
export interface ExcalidrawElementWithCanvas {
|
|
8
8
|
element: ExcalidrawElement | ExcalidrawTextElement;
|
|
9
9
|
canvas: HTMLCanvasElement;
|
|
@@ -11,6 +11,7 @@ export interface ExcalidrawElementWithCanvas {
|
|
|
11
11
|
canvasZoom: Zoom["value"];
|
|
12
12
|
canvasOffsetX: number;
|
|
13
13
|
canvasOffsetY: number;
|
|
14
|
+
boundTextElementVersion: number | null;
|
|
14
15
|
}
|
|
15
16
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
16
17
|
declare type ElementShape = Drawable | Drawable[] | null;
|
|
@@ -26,8 +27,8 @@ export declare const setShapeForElement: <T extends ExcalidrawElement>(element:
|
|
|
26
27
|
export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
|
|
27
28
|
export declare const clearRenderCache: () => void;
|
|
28
29
|
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
29
|
-
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig) => void;
|
|
30
|
-
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX
|
|
30
|
+
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
|
|
31
|
+
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean) => void;
|
|
31
32
|
export declare let pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
|
|
32
33
|
export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
|
|
33
34
|
export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExcalidrawElement } from "../element/types";
|
|
2
|
+
import type Scene from "./Scene";
|
|
3
|
+
export declare class Fonts {
|
|
4
|
+
private scene;
|
|
5
|
+
private onSceneUpdated;
|
|
6
|
+
constructor({ scene, onSceneUpdated, }: {
|
|
7
|
+
scene: Scene;
|
|
8
|
+
onSceneUpdated: () => void;
|
|
9
|
+
});
|
|
10
|
+
private static loadedFontFaces;
|
|
11
|
+
/**
|
|
12
|
+
* if we load a (new) font, it's likely that text elements using it have
|
|
13
|
+
* already been rendered using a fallback font. Thus, we want invalidate
|
|
14
|
+
* their shapes and rerender. See #637.
|
|
15
|
+
*
|
|
16
|
+
* Invalidates text elements and rerenders scene, provided that at least one
|
|
17
|
+
* of the supplied fontFaces has not already been processed.
|
|
18
|
+
*/
|
|
19
|
+
onFontsLoaded: (fontFaces: readonly FontFace[]) => false | undefined;
|
|
20
|
+
loadFontsForElements: (elements: readonly ExcalidrawElement[]) => Promise<void>;
|
|
21
|
+
}
|
package/types/scene/Scene.d.ts
CHANGED
|
@@ -17,9 +17,24 @@ declare class Scene {
|
|
|
17
17
|
getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
|
|
18
18
|
getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
|
|
19
19
|
getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
|
|
20
|
+
/**
|
|
21
|
+
* A utility method to help with updating all scene elements, with the added
|
|
22
|
+
* performance optimization of not renewing the array if no change is made.
|
|
23
|
+
*
|
|
24
|
+
* Maps all current excalidraw elements, invoking the callback for each
|
|
25
|
+
* element. The callback should either return a new mapped element, or the
|
|
26
|
+
* original element if no changes are made. If no changes are made to any
|
|
27
|
+
* element, this results in a no-op. Otherwise, the newly mapped elements
|
|
28
|
+
* are set as the next scene's elements.
|
|
29
|
+
*
|
|
30
|
+
* @returns whether a change was made
|
|
31
|
+
*/
|
|
32
|
+
mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
|
|
20
33
|
replaceAllElements(nextElements: readonly ExcalidrawElement[]): void;
|
|
21
34
|
informMutation(): void;
|
|
22
35
|
addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
|
|
23
36
|
destroy(): void;
|
|
37
|
+
insertElementAtIndex(element: ExcalidrawElement, index: number): void;
|
|
38
|
+
getElementIndex(elementId: string): number;
|
|
24
39
|
}
|
|
25
40
|
export default Scene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
2
|
export declare const hasBackground: (type: string) => boolean;
|
|
3
3
|
export declare const hasStrokeColor: (type: string) => boolean;
|
|
4
4
|
export declare const hasStrokeWidth: (type: string) => boolean;
|
|
@@ -8,4 +8,3 @@ export declare const hasText: (type: string) => boolean;
|
|
|
8
8
|
export declare const canHaveArrowheads: (type: string) => boolean;
|
|
9
9
|
export declare const getElementAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement | null;
|
|
10
10
|
export declare const getElementsAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement[];
|
|
11
|
-
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], x: number, y: number) => ExcalidrawTextContainer | null;
|
package/types/scene/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isOverScrollBars } from "./scrollbars";
|
|
2
2
|
export { isSomeElementSelected, getElementsWithinSelection, getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, } from "./selection";
|
|
3
3
|
export { calculateScrollCenter } from "./scroll";
|
|
4
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeSharpness, getElementAtPosition,
|
|
4
|
+
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeSharpness, getElementAtPosition, hasText, getElementsAtPosition, } from "./comparisons";
|
|
5
5
|
export { getNormalizedZoom } from "./zoom";
|
package/types/shapes.d.ts
CHANGED