@excalidraw/excalidraw 0.14.2-cef6094 → 0.14.2-e4d8ba2
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 +2 -0
- package/dist/excalidraw.development.js +47 -37
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +2 -1
- package/types/actions/actionBoundText.d.ts +114 -10
- package/types/actions/actionCanvas.d.ts +115 -9
- package/types/actions/actionClipboard.d.ts +3 -3
- package/types/actions/actionDeleteSelected.d.ts +3 -3
- package/types/actions/actionDuplicateSelection.d.ts +1 -1
- package/types/actions/actionExport.d.ts +8 -8
- package/types/actions/actionFinalize.d.ts +2 -2
- package/types/actions/actionLinearEditor.d.ts +2 -1
- package/types/actions/actionMenu.d.ts +3 -3
- package/types/actions/actionProperties.d.ts +14 -14
- package/types/actions/actionStyles.d.ts +1 -1
- package/types/actions/actionToggleGridMode.d.ts +1 -1
- package/types/actions/actionToggleLock.d.ts +1 -1
- package/types/actions/actionToggleStats.d.ts +1 -1
- package/types/actions/actionToggleViewMode.d.ts +1 -1
- package/types/actions/actionToggleZenMode.d.ts +1 -1
- package/types/actions/shortcuts.d.ts +1 -0
- package/types/actions/types.d.ts +1 -0
- package/types/components/App.d.ts +12 -1
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/components/icons.d.ts +1 -0
- package/types/constants.d.ts +1 -0
- package/types/data/blob.d.ts +1 -0
- package/types/element/Hyperlink.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +1 -1
- package/types/element/mutateElement.d.ts +1 -0
- package/types/element/newElement.d.ts +4 -1
- package/types/element/textElement.d.ts +26 -6
- package/types/element/typeChecks.d.ts +1 -0
- package/types/element/types.d.ts +10 -1
- package/types/renderer/renderElement.d.ts +2 -2
- package/types/types.d.ts +3 -2
- package/types/utility-types.d.ts +22 -0
- package/types/utils.d.ts +20 -1
|
@@ -20,7 +20,7 @@ export declare const actionChangeBackgroundColor: {
|
|
|
20
20
|
export declare const actionChangeFillStyle: {
|
|
21
21
|
name: "changeFillStyle";
|
|
22
22
|
trackEvent: false;
|
|
23
|
-
perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any) => {
|
|
23
|
+
perform: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, value: any, app: import("../../src/types").AppClassProperties) => {
|
|
24
24
|
elements: ExcalidrawElement[];
|
|
25
25
|
appState: {
|
|
26
26
|
currentItemFillStyle: any;
|
|
@@ -31,7 +31,7 @@ export declare const actionChangeFillStyle: {
|
|
|
31
31
|
} | null;
|
|
32
32
|
showWelcomeScreen: boolean;
|
|
33
33
|
isLoading: boolean;
|
|
34
|
-
errorMessage:
|
|
34
|
+
errorMessage: import("react").ReactNode;
|
|
35
35
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
36
36
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
37
37
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -145,7 +145,7 @@ export declare const actionChangeStrokeWidth: {
|
|
|
145
145
|
} | null;
|
|
146
146
|
showWelcomeScreen: boolean;
|
|
147
147
|
isLoading: boolean;
|
|
148
|
-
errorMessage:
|
|
148
|
+
errorMessage: import("react").ReactNode;
|
|
149
149
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
150
150
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
151
151
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -259,7 +259,7 @@ export declare const actionChangeSloppiness: {
|
|
|
259
259
|
} | null;
|
|
260
260
|
showWelcomeScreen: boolean;
|
|
261
261
|
isLoading: boolean;
|
|
262
|
-
errorMessage:
|
|
262
|
+
errorMessage: import("react").ReactNode;
|
|
263
263
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
264
264
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
265
265
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -373,7 +373,7 @@ export declare const actionChangeStrokeStyle: {
|
|
|
373
373
|
} | null;
|
|
374
374
|
showWelcomeScreen: boolean;
|
|
375
375
|
isLoading: boolean;
|
|
376
|
-
errorMessage:
|
|
376
|
+
errorMessage: import("react").ReactNode;
|
|
377
377
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
378
378
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
379
379
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -487,7 +487,7 @@ export declare const actionChangeOpacity: {
|
|
|
487
487
|
} | null;
|
|
488
488
|
showWelcomeScreen: boolean;
|
|
489
489
|
isLoading: boolean;
|
|
490
|
-
errorMessage:
|
|
490
|
+
errorMessage: import("react").ReactNode;
|
|
491
491
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
492
492
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
493
493
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -601,7 +601,7 @@ export declare const actionChangeFontSize: {
|
|
|
601
601
|
} | null;
|
|
602
602
|
showWelcomeScreen: boolean;
|
|
603
603
|
isLoading: boolean;
|
|
604
|
-
errorMessage:
|
|
604
|
+
errorMessage: import("react").ReactNode;
|
|
605
605
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
606
606
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
607
607
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -715,7 +715,7 @@ export declare const actionDecreaseFontSize: {
|
|
|
715
715
|
} | null;
|
|
716
716
|
showWelcomeScreen: boolean;
|
|
717
717
|
isLoading: boolean;
|
|
718
|
-
errorMessage:
|
|
718
|
+
errorMessage: import("react").ReactNode;
|
|
719
719
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
720
720
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
721
721
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -829,7 +829,7 @@ export declare const actionIncreaseFontSize: {
|
|
|
829
829
|
} | null;
|
|
830
830
|
showWelcomeScreen: boolean;
|
|
831
831
|
isLoading: boolean;
|
|
832
|
-
errorMessage:
|
|
832
|
+
errorMessage: import("react").ReactNode;
|
|
833
833
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
834
834
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
835
835
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -943,7 +943,7 @@ export declare const actionChangeFontFamily: {
|
|
|
943
943
|
} | null;
|
|
944
944
|
showWelcomeScreen: boolean;
|
|
945
945
|
isLoading: boolean;
|
|
946
|
-
errorMessage:
|
|
946
|
+
errorMessage: import("react").ReactNode;
|
|
947
947
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
948
948
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
949
949
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -1057,7 +1057,7 @@ export declare const actionChangeTextAlign: {
|
|
|
1057
1057
|
} | null;
|
|
1058
1058
|
showWelcomeScreen: boolean;
|
|
1059
1059
|
isLoading: boolean;
|
|
1060
|
-
errorMessage:
|
|
1060
|
+
errorMessage: import("react").ReactNode;
|
|
1061
1061
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1062
1062
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1063
1063
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -1172,7 +1172,7 @@ export declare const actionChangeVerticalAlign: {
|
|
|
1172
1172
|
} | null;
|
|
1173
1173
|
showWelcomeScreen: boolean;
|
|
1174
1174
|
isLoading: boolean;
|
|
1175
|
-
errorMessage:
|
|
1175
|
+
errorMessage: import("react").ReactNode;
|
|
1176
1176
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1177
1177
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1178
1178
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -1287,7 +1287,7 @@ export declare const actionChangeRoundness: {
|
|
|
1287
1287
|
} | null;
|
|
1288
1288
|
showWelcomeScreen: boolean;
|
|
1289
1289
|
isLoading: boolean;
|
|
1290
|
-
errorMessage:
|
|
1290
|
+
errorMessage: import("react").ReactNode;
|
|
1291
1291
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1292
1292
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1293
1293
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -1403,7 +1403,7 @@ export declare const actionChangeArrowhead: {
|
|
|
1403
1403
|
} | null;
|
|
1404
1404
|
showWelcomeScreen: boolean;
|
|
1405
1405
|
isLoading: boolean;
|
|
1406
|
-
errorMessage:
|
|
1406
|
+
errorMessage: import("react").ReactNode;
|
|
1407
1407
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1408
1408
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
1409
1409
|
multiElement: import("../element/types").NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -17,7 +17,7 @@ export declare const actionCopyStyles: {
|
|
|
17
17
|
} | null;
|
|
18
18
|
showWelcomeScreen: boolean;
|
|
19
19
|
isLoading: boolean;
|
|
20
|
-
errorMessage:
|
|
20
|
+
errorMessage: import("react").ReactNode;
|
|
21
21
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
22
22
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
23
23
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -17,7 +17,7 @@ export declare const actionToggleGridMode: {
|
|
|
17
17
|
} | null;
|
|
18
18
|
showWelcomeScreen: boolean;
|
|
19
19
|
isLoading: boolean;
|
|
20
|
-
errorMessage:
|
|
20
|
+
errorMessage: import("react").ReactNode;
|
|
21
21
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
22
22
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
23
23
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -16,7 +16,7 @@ export declare const actionToggleLock: {
|
|
|
16
16
|
} | null;
|
|
17
17
|
showWelcomeScreen: boolean;
|
|
18
18
|
isLoading: boolean;
|
|
19
|
-
errorMessage:
|
|
19
|
+
errorMessage: import("react").ReactNode;
|
|
20
20
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
21
21
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
22
22
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -15,7 +15,7 @@ export declare const actionToggleStats: {
|
|
|
15
15
|
} | null;
|
|
16
16
|
showWelcomeScreen: boolean;
|
|
17
17
|
isLoading: boolean;
|
|
18
|
-
errorMessage:
|
|
18
|
+
errorMessage: import("react").ReactNode;
|
|
19
19
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
20
20
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
21
21
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -16,7 +16,7 @@ export declare const actionToggleViewMode: {
|
|
|
16
16
|
} | null;
|
|
17
17
|
showWelcomeScreen: boolean;
|
|
18
18
|
isLoading: boolean;
|
|
19
|
-
errorMessage:
|
|
19
|
+
errorMessage: import("react").ReactNode;
|
|
20
20
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
21
21
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
22
22
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -16,7 +16,7 @@ export declare const actionToggleZenMode: {
|
|
|
16
16
|
} | null;
|
|
17
17
|
showWelcomeScreen: boolean;
|
|
18
18
|
isLoading: boolean;
|
|
19
|
-
errorMessage:
|
|
19
|
+
errorMessage: import("react").ReactNode;
|
|
20
20
|
draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
21
21
|
resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
|
|
22
22
|
multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SubtypeOf } from "../utility-types";
|
|
1
2
|
import { ActionName } from "./types";
|
|
2
3
|
export declare type ShortcutName = SubtypeOf<ActionName, "toggleTheme" | "loadScene" | "clearCanvas" | "cut" | "copy" | "paste" | "copyStyles" | "pasteStyles" | "selectAll" | "deleteSelectedElements" | "duplicateSelection" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyAsPng" | "copyAsSvg" | "group" | "ungroup" | "gridMode" | "zenMode" | "stats" | "addToLibrary" | "viewMode" | "flipHorizontal" | "flipVertical" | "hyperlink" | "toggleLock"> | "saveScene" | "imageExport";
|
|
3
4
|
export declare const getShortcutFromShortcutName: (name: ShortcutName) => string;
|
package/types/actions/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ExcalidrawElement } from "../element/types";
|
|
3
3
|
import { AppClassProperties, AppState, ExcalidrawProps, BinaryFiles } from "../types";
|
|
4
|
+
import { MarkOptional } from "../utility-types";
|
|
4
5
|
export declare type ActionSource = "ui" | "keyboard" | "contextMenu" | "api";
|
|
5
6
|
/** if false, the action should be prevented */
|
|
6
7
|
export declare type ActionResult = {
|
|
@@ -93,7 +93,18 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
93
93
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
94
94
|
togglePenMode: () => void;
|
|
95
95
|
onHandToolToggle: () => void;
|
|
96
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Zooms on canvas viewport center
|
|
98
|
+
*/
|
|
99
|
+
zoomCanvas: (value: number) => void;
|
|
100
|
+
private cancelInProgresAnimation;
|
|
101
|
+
scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[], opts?: {
|
|
102
|
+
fitToContent?: boolean;
|
|
103
|
+
animate?: boolean;
|
|
104
|
+
duration?: number;
|
|
105
|
+
}) => void;
|
|
106
|
+
/** use when changing scrollX/scrollY/zoom based on user interaction */
|
|
107
|
+
private translateCanvas;
|
|
97
108
|
setToast: (toast: {
|
|
98
109
|
message: string;
|
|
99
110
|
closable?: boolean;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
export declare const ButtonIconSelect: <T extends Object>(
|
|
1
|
+
export declare const ButtonIconSelect: <T extends Object>(props: {
|
|
2
2
|
options: {
|
|
3
3
|
value: T;
|
|
4
4
|
text: string;
|
|
5
5
|
icon: JSX.Element;
|
|
6
6
|
testId?: string | undefined;
|
|
7
|
+
/** if not supplied, defaults to value identity check */
|
|
8
|
+
active?: boolean | undefined;
|
|
7
9
|
}[];
|
|
8
10
|
value: T | null;
|
|
9
|
-
|
|
11
|
+
type?: "button" | "radio" | undefined;
|
|
12
|
+
} & ({
|
|
13
|
+
type?: "radio" | undefined;
|
|
10
14
|
group: string;
|
|
11
|
-
|
|
15
|
+
onChange: (value: T) => void;
|
|
16
|
+
} | {
|
|
17
|
+
type: "button";
|
|
18
|
+
onClick: (value: T, event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
19
|
+
})) => JSX.Element;
|
|
@@ -87,6 +87,7 @@ export declare const GroupIcon: React.MemoExoticComponent<({ theme }: {
|
|
|
87
87
|
export declare const UngroupIcon: React.MemoExoticComponent<({ theme }: {
|
|
88
88
|
theme: Theme;
|
|
89
89
|
}) => JSX.Element>;
|
|
90
|
+
export declare const FillZigZagIcon: JSX.Element;
|
|
90
91
|
export declare const FillHachureIcon: JSX.Element;
|
|
91
92
|
export declare const FillCrossHatchIcon: JSX.Element;
|
|
92
93
|
export declare const FillSolidIcon: JSX.Element;
|
package/types/constants.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const isAndroid: boolean;
|
|
|
6
6
|
export declare const isFirefox: boolean;
|
|
7
7
|
export declare const isChrome: boolean;
|
|
8
8
|
export declare const isSafari: boolean;
|
|
9
|
+
export declare const isBrave: () => boolean;
|
|
9
10
|
export declare const APP_NAME = "Excalidraw";
|
|
10
11
|
export declare const DRAGGING_THRESHOLD = 10;
|
|
11
12
|
export declare const LINE_CONFIRM_THRESHOLD = 8;
|
package/types/data/blob.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
|
|
2
2
|
import { ExcalidrawElement, FileId } from "../element/types";
|
|
3
3
|
import { AppState, DataURL, LibraryItem } from "../types";
|
|
4
|
+
import { ValueOf } from "../utility-types";
|
|
4
5
|
import { FileSystemHandle } from "./filesystem";
|
|
5
6
|
import { ImportedLibraryData } from "./types";
|
|
6
7
|
export declare const getMimeType: (blob: Blob | string) => string;
|
|
@@ -25,7 +25,7 @@ export declare const actionLink: {
|
|
|
25
25
|
} | null;
|
|
26
26
|
showWelcomeScreen: boolean;
|
|
27
27
|
isLoading: boolean;
|
|
28
|
-
errorMessage:
|
|
28
|
+
errorMessage: import("react").ReactNode;
|
|
29
29
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
30
30
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
31
31
|
multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
|
|
@@ -130,7 +130,7 @@ export declare class LinearElementEditor {
|
|
|
130
130
|
} | null;
|
|
131
131
|
showWelcomeScreen: boolean;
|
|
132
132
|
isLoading: boolean;
|
|
133
|
-
errorMessage:
|
|
133
|
+
errorMessage: import("react").ReactNode;
|
|
134
134
|
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
135
135
|
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
136
136
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
|
+
import { Mutable } from "../utility-types";
|
|
2
3
|
declare type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce">;
|
|
3
4
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
4
5
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>) => TElement;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
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
|
+
import { MarkOptional, Mutable } from "../utility-types";
|
|
3
4
|
declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link">;
|
|
4
5
|
export declare const newElement: (opts: {
|
|
5
6
|
type: ExcalidrawGenericElement["type"];
|
|
@@ -11,14 +12,16 @@ export declare const newTextElement: (opts: {
|
|
|
11
12
|
textAlign: TextAlign;
|
|
12
13
|
verticalAlign: VerticalAlign;
|
|
13
14
|
containerId?: ExcalidrawTextContainer["id"];
|
|
15
|
+
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
14
16
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
15
17
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
16
18
|
x: number;
|
|
17
19
|
y: number;
|
|
18
20
|
width: number;
|
|
19
21
|
height: number;
|
|
22
|
+
baseline: number;
|
|
20
23
|
text: string;
|
|
21
|
-
};
|
|
24
|
+
} | undefined;
|
|
22
25
|
export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
|
|
23
26
|
text: string;
|
|
24
27
|
isDeleted?: boolean | undefined;
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
2
|
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
3
|
import { AppState } from "../types";
|
|
4
|
+
import { ExtractSetType } from "../utility-types";
|
|
4
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
|
+
export declare const splitIntoLines: (text: string) => string[];
|
|
5
7
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
|
|
6
8
|
export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
7
9
|
export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
|
|
8
|
-
export declare const measureText: (text: string, font: FontString) => {
|
|
10
|
+
export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
|
|
9
11
|
width: number;
|
|
10
12
|
height: number;
|
|
13
|
+
baseline: number;
|
|
11
14
|
};
|
|
12
|
-
export declare const
|
|
15
|
+
export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
|
|
16
|
+
/**
|
|
17
|
+
* To get unitless line-height (if unknown) we can calculate it by dividing
|
|
18
|
+
* height-per-line by fontSize.
|
|
19
|
+
*/
|
|
20
|
+
export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
|
|
21
|
+
_brand: "unitlessLineHeight";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* We calculate the line height from the font size and the unitless line height,
|
|
25
|
+
* aligning with the W3C spec.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
28
|
+
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
13
29
|
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
14
|
-
export declare const getTextHeight: (text: string,
|
|
30
|
+
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
15
31
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
16
32
|
export declare const charWidth: {
|
|
17
33
|
calculate: (char: string, font: FontString) => number;
|
|
18
34
|
getCache: (font: FontString) => number[];
|
|
19
35
|
};
|
|
20
|
-
export declare const getApproxMinLineWidth: (font: FontString) => number;
|
|
21
|
-
export declare const getApproxMinLineHeight: (font: FontString) => number;
|
|
36
|
+
export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
22
37
|
export declare const getMinCharWidth: (font: FontString) => number;
|
|
23
38
|
export declare const getMaxCharWidth: (font: FontString) => number;
|
|
24
39
|
export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
|
|
@@ -46,10 +61,15 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
46
61
|
y: number;
|
|
47
62
|
} | undefined;
|
|
48
63
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
64
|
+
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
49
65
|
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
50
66
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
51
67
|
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
52
68
|
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
53
69
|
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
54
70
|
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
71
|
+
export declare const isMeasureTextSupported: () => boolean;
|
|
72
|
+
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
73
|
+
_brand: "unitlessLineHeight";
|
|
74
|
+
};
|
|
55
75
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppState } from "../types";
|
|
2
|
+
import { MarkNonNullable } from "../utility-types";
|
|
2
3
|
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, RoundnessType } from "./types";
|
|
3
4
|
export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
|
|
4
5
|
export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
|
package/types/element/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Point } from "../types";
|
|
2
2
|
import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
|
+
import { MarkNonNullable, ValueOf } from "../utility-types";
|
|
3
4
|
export declare type ChartType = "bar" | "line";
|
|
4
|
-
export declare type FillStyle = "hachure" | "cross-hatch" | "solid";
|
|
5
|
+
export declare type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
|
|
5
6
|
export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
|
|
6
7
|
export declare type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
|
|
7
8
|
export declare type Theme = typeof THEME[keyof typeof THEME];
|
|
@@ -99,10 +100,18 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
99
100
|
fontSize: number;
|
|
100
101
|
fontFamily: FontFamilyValues;
|
|
101
102
|
text: string;
|
|
103
|
+
baseline: number;
|
|
102
104
|
textAlign: TextAlign;
|
|
103
105
|
verticalAlign: VerticalAlign;
|
|
104
106
|
containerId: ExcalidrawGenericElement["id"] | null;
|
|
105
107
|
originalText: string;
|
|
108
|
+
/**
|
|
109
|
+
* Unitless line height (aligned to W3C). To get line height in px, multiply
|
|
110
|
+
* with font size (using `getLineHeightInPx` helper).
|
|
111
|
+
*/
|
|
112
|
+
lineHeight: number & {
|
|
113
|
+
_brand: "unitlessLineHeight";
|
|
114
|
+
};
|
|
106
115
|
}>;
|
|
107
116
|
export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
|
|
108
117
|
export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
|
|
@@ -3,12 +3,12 @@ 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 { AppState, BinaryFiles
|
|
6
|
+
import { AppState, BinaryFiles } from "../types";
|
|
7
7
|
export interface ExcalidrawElementWithCanvas {
|
|
8
8
|
element: ExcalidrawElement | ExcalidrawTextElement;
|
|
9
9
|
canvas: HTMLCanvasElement;
|
|
10
10
|
theme: RenderConfig["theme"];
|
|
11
|
-
|
|
11
|
+
scale: number;
|
|
12
12
|
canvasOffsetX: number;
|
|
13
13
|
canvasOffsetY: number;
|
|
14
14
|
boundTextElementVersion: number | null;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
|
|
3
2
|
import { SHAPES } from "./shapes";
|
|
4
3
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
@@ -16,6 +15,8 @@ import Library from "./data/library";
|
|
|
16
15
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
16
|
import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
17
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
18
|
+
import { Merge, ForwardRef } from "./utility-types";
|
|
19
|
+
import React from "react";
|
|
19
20
|
export declare type Point = Readonly<RoughPoint>;
|
|
20
21
|
export declare type Collaborator = {
|
|
21
22
|
pointer?: {
|
|
@@ -70,7 +71,7 @@ export declare type AppState = {
|
|
|
70
71
|
} | null;
|
|
71
72
|
showWelcomeScreen: boolean;
|
|
72
73
|
isLoading: boolean;
|
|
73
|
-
errorMessage:
|
|
74
|
+
errorMessage: React.ReactNode;
|
|
74
75
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
75
76
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
76
77
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type Mutable<T> = {
|
|
3
|
+
-readonly [P in keyof T]: T[P];
|
|
4
|
+
};
|
|
5
|
+
export declare type ValueOf<T> = T[keyof T];
|
|
6
|
+
export declare type Merge<M, N> = Omit<M, keyof N> & N;
|
|
7
|
+
/** utility type to assert that the second type is a subtype of the first type.
|
|
8
|
+
* Returns the subtype. */
|
|
9
|
+
export declare type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
|
|
10
|
+
export declare type ResolutionType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
11
|
+
export declare type MarkOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
12
|
+
export declare type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
|
|
13
|
+
export declare type MarkNonNullable<T, K extends keyof T> = {
|
|
14
|
+
[P in K]-?: P extends K ? NonNullable<T[P]> : T[P];
|
|
15
|
+
} & {
|
|
16
|
+
[P in keyof T]: T[P];
|
|
17
|
+
};
|
|
18
|
+
export declare type NonOptional<T> = Exclude<T, undefined>;
|
|
19
|
+
export declare type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
|
|
20
|
+
export declare type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
|
|
21
|
+
export declare type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
|
|
22
|
+
export declare type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
|
package/types/utils.d.ts
CHANGED
|
@@ -28,6 +28,26 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
28
28
|
flush(): void;
|
|
29
29
|
cancel(): void;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Compute new values based on the same ease function and trigger the
|
|
33
|
+
* callback through a requestAnimationFrame call
|
|
34
|
+
*
|
|
35
|
+
* use `opts` to define a duration and/or an easeFn
|
|
36
|
+
*
|
|
37
|
+
* for example:
|
|
38
|
+
* ```ts
|
|
39
|
+
* easeToValuesRAF([10, 20, 10], [0, 0, 0], (a, b, c) => setState(a,b, c))
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param fromValues The initial values, must be numeric
|
|
43
|
+
* @param toValues The destination values, must also be numeric
|
|
44
|
+
* @param callback The callback receiving the values
|
|
45
|
+
* @param opts default to 250ms duration and the easeOut function
|
|
46
|
+
*/
|
|
47
|
+
export declare const easeToValuesRAF: (fromValues: number[], toValues: number[], callback: (...values: number[]) => void, opts?: {
|
|
48
|
+
duration?: number | undefined;
|
|
49
|
+
easeFn?: ((value: number) => number) | undefined;
|
|
50
|
+
} | undefined) => () => void;
|
|
31
51
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
32
52
|
export declare const selectNode: (node: Element) => void;
|
|
33
53
|
export declare const removeSelection: () => void;
|
|
@@ -128,7 +148,6 @@ export declare const arrayToMapWithIndex: <T extends {
|
|
|
128
148
|
id: string;
|
|
129
149
|
}>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
|
|
130
150
|
export declare const isTestEnv: () => boolean;
|
|
131
|
-
export declare const isProdEnv: () => boolean;
|
|
132
151
|
export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
|
|
133
152
|
nativeEvent: T;
|
|
134
153
|
}>;
|