@dwelle/excalidraw 0.4.0-83d46fe → 0.4.0-8a7de60
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 +248 -1
- package/README.md +16 -1822
- package/dist/excalidraw.development.js +196 -109
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +2 -1
- package/types/actions/actionBoundText.d.ts +129 -9
- package/types/actions/actionCanvas.d.ts +115 -9
- package/types/actions/actionClipboard.d.ts +3 -3
- package/types/actions/actionDeleteSelected.d.ts +5 -5
- 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 +2 -1
- package/types/actions/types.d.ts +2 -1
- package/types/clipboard.d.ts +2 -2
- 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/HelpButton.d.ts +0 -1
- package/types/components/LayerUI.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +3 -4
- package/types/components/context/tunnels.d.ts +16 -0
- package/types/components/dropdownMenu/common.d.ts +1 -1
- package/types/components/footer/Footer.d.ts +3 -4
- package/types/components/hoc/withInternalFallback.d.ts +4 -0
- package/types/components/icons.d.ts +1 -0
- package/types/components/main-menu/MainMenu.d.ts +9 -9
- package/types/components/welcome-screen/WelcomeScreen.d.ts +2 -2
- package/types/constants.d.ts +32 -7
- package/types/data/blob.d.ts +3 -2
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/restore.d.ts +8 -2
- package/types/element/Hyperlink.d.ts +1 -1
- package/types/element/image.d.ts +11 -1
- package/types/element/linearElementEditor.d.ts +1 -1
- package/types/element/mutateElement.d.ts +1 -0
- package/types/element/newElement.d.ts +34 -10
- package/types/element/sortElements.d.ts +2 -0
- package/types/element/textElement.d.ts +39 -11
- package/types/element/typeChecks.d.ts +2 -1
- package/types/element/types.d.ts +9 -1
- package/types/i18n.d.ts +6 -0
- package/types/jotai.d.ts +5 -5
- package/types/math.d.ts +1 -0
- package/types/packages/excalidraw/example/App.d.ts +7 -1
- package/types/packages/excalidraw/index.d.ts +2 -1
- package/types/packages/utils.d.ts +4 -0
- package/types/renderer/renderElement.d.ts +3 -2
- package/types/scene/export.d.ts +13 -1
- package/types/types.d.ts +9 -22
- package/types/utility-types.d.ts +22 -0
- package/types/utils.d.ts +23 -17
- package/types/components/SingleLibraryItem.d.ts +0 -10
|
@@ -1,16 +1,19 @@
|
|
|
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
|
-
|
|
3
|
+
import { MarkOptional, Mutable } from "../utility-types";
|
|
4
|
+
declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
|
|
4
5
|
export declare const newElement: (opts: {
|
|
5
6
|
type: ExcalidrawGenericElement["type"];
|
|
6
7
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
|
|
7
8
|
export declare const newTextElement: (opts: {
|
|
8
9
|
text: string;
|
|
9
|
-
fontSize
|
|
10
|
-
fontFamily
|
|
11
|
-
textAlign
|
|
12
|
-
verticalAlign
|
|
10
|
+
fontSize?: number;
|
|
11
|
+
fontFamily?: FontFamilyValues;
|
|
12
|
+
textAlign?: TextAlign;
|
|
13
|
+
verticalAlign?: VerticalAlign;
|
|
13
14
|
containerId?: ExcalidrawTextContainer["id"];
|
|
15
|
+
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
16
|
+
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
14
17
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
15
18
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
16
19
|
x: number;
|
|
@@ -19,9 +22,7 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
|
|
|
19
22
|
height: number;
|
|
20
23
|
baseline: number;
|
|
21
24
|
text: string;
|
|
22
|
-
};
|
|
23
|
-
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
24
|
-
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
25
|
+
} | undefined;
|
|
25
26
|
export declare const updateTextElement: (textElement: ExcalidrawTextElement, { text, isDeleted, originalText, }: {
|
|
26
27
|
text: string;
|
|
27
28
|
isDeleted?: boolean | undefined;
|
|
@@ -44,7 +45,16 @@ export declare const newImageElement: (opts: {
|
|
|
44
45
|
fileId?: ExcalidrawImageElement["fileId"];
|
|
45
46
|
scale?: ExcalidrawImageElement["scale"];
|
|
46
47
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
|
|
47
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
50
|
+
* any value. The purpose is to to break object references for immutability
|
|
51
|
+
* reasons, whenever we want to keep the original element, but ensure it's not
|
|
52
|
+
* mutated.
|
|
53
|
+
*
|
|
54
|
+
* Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
55
|
+
* Typed arrays and other non-null objects.
|
|
56
|
+
*/
|
|
57
|
+
export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
|
|
48
58
|
/**
|
|
49
59
|
* Duplicate an element, often used in the alt-drag operation.
|
|
50
60
|
* Note that this method has gotten a bit complicated since the
|
|
@@ -59,5 +69,19 @@ export declare const deepCopyElement: (val: any, depth?: number) => any;
|
|
|
59
69
|
* @param element Element to duplicate
|
|
60
70
|
* @param overrides Any element properties to override
|
|
61
71
|
*/
|
|
62
|
-
export declare const duplicateElement: <TElement extends
|
|
72
|
+
export declare const duplicateElement: <TElement extends ExcalidrawElement>(editingGroupId: AppState["editingGroupId"], groupIdMapForOperation: Map<GroupId, GroupId>, element: TElement, overrides?: Partial<TElement> | undefined) => Readonly<TElement>;
|
|
73
|
+
/**
|
|
74
|
+
* Clones elements, regenerating their ids (including bindings) and group ids.
|
|
75
|
+
*
|
|
76
|
+
* If bindings don't exist in the elements array, they are removed. Therefore,
|
|
77
|
+
* it's advised to supply the whole elements array, or sets of elements that
|
|
78
|
+
* are encapsulated (such as library items), if the purpose is to retain
|
|
79
|
+
* bindings to the cloned elements intact.
|
|
80
|
+
*
|
|
81
|
+
* NOTE by default does not randomize or regenerate anything except the id.
|
|
82
|
+
*/
|
|
83
|
+
export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
|
|
84
|
+
/** NOTE also updates version flags and `updated` */
|
|
85
|
+
randomizeSeed: boolean;
|
|
86
|
+
}) => ExcalidrawElement[];
|
|
63
87
|
export {};
|
|
@@ -1,30 +1,44 @@
|
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} | {
|
|
10
|
+
export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
|
|
14
15
|
width: number;
|
|
15
16
|
height: number;
|
|
16
17
|
baseline: number;
|
|
17
|
-
container?: undefined;
|
|
18
18
|
};
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const measureBaseline: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], wrapInContainer?: boolean) => number;
|
|
20
|
+
/**
|
|
21
|
+
* To get unitless line-height (if unknown) we can calculate it by dividing
|
|
22
|
+
* height-per-line by fontSize.
|
|
23
|
+
*/
|
|
24
|
+
export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => number & {
|
|
25
|
+
_brand: "unitlessLineHeight";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* We calculate the line height from the font size and the unitless line height,
|
|
29
|
+
* aligning with the W3C spec.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
32
|
+
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
20
33
|
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
34
|
+
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
35
|
+
export declare const parseTokens: (text: string) => string[];
|
|
21
36
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
22
37
|
export declare const charWidth: {
|
|
23
38
|
calculate: (char: string, font: FontString) => number;
|
|
24
39
|
getCache: (font: FontString) => number[];
|
|
25
40
|
};
|
|
26
|
-
export declare const getApproxMinLineWidth: (font: FontString) => number;
|
|
27
|
-
export declare const getApproxMinLineHeight: (font: FontString) => number;
|
|
41
|
+
export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
28
42
|
export declare const getMinCharWidth: (font: FontString) => number;
|
|
29
43
|
export declare const getMaxCharWidth: (font: FontString) => number;
|
|
30
44
|
export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
|
|
@@ -41,6 +55,10 @@ export declare const getContainerCenter: (container: ExcalidrawElement, appState
|
|
|
41
55
|
x: number;
|
|
42
56
|
y: number;
|
|
43
57
|
};
|
|
58
|
+
export declare const getContainerCoords: (container: NonDeletedExcalidrawElement) => {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
};
|
|
44
62
|
export declare const getTextElementAngle: (textElement: ExcalidrawTextElement) => number;
|
|
45
63
|
export declare const getBoundTextElementOffset: (boundTextElement: ExcalidrawTextElement | null) => number;
|
|
46
64
|
export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
|
|
@@ -48,5 +66,15 @@ export declare const getBoundTextElementPosition: (container: ExcalidrawElement,
|
|
|
48
66
|
y: number;
|
|
49
67
|
} | undefined;
|
|
50
68
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
69
|
+
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
|
|
51
70
|
export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
|
|
71
|
+
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
52
72
|
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
73
|
+
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
74
|
+
export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
|
|
75
|
+
export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
|
|
76
|
+
export declare const isMeasureTextSupported: () => boolean;
|
|
77
|
+
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
78
|
+
_brand: "unitlessLineHeight";
|
|
79
|
+
};
|
|
80
|
+
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;
|
|
@@ -14,7 +15,7 @@ export declare const isBindingElementType: (elementType: AppState["activeTool"][
|
|
|
14
15
|
export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
15
16
|
export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
|
|
16
17
|
export declare const isExcalidrawElement: (element: any) => boolean;
|
|
17
|
-
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawBindableElement
|
|
18
|
+
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
|
|
18
19
|
export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
|
|
19
20
|
export declare const isUsingAdaptiveRadius: (type: string) => boolean;
|
|
20
21
|
export declare const isUsingProportionalRadius: (type: string) => boolean;
|
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];
|
|
@@ -104,6 +105,13 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
104
105
|
verticalAlign: VerticalAlign;
|
|
105
106
|
containerId: ExcalidrawGenericElement["id"] | null;
|
|
106
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
|
+
};
|
|
107
115
|
}>;
|
|
108
116
|
export declare type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
|
|
109
117
|
export declare type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
|
package/types/i18n.d.ts
CHANGED
|
@@ -13,3 +13,9 @@ export declare const getLanguage: () => Language;
|
|
|
13
13
|
export declare const t: (path: string, replacement?: {
|
|
14
14
|
[key: string]: string | number;
|
|
15
15
|
} | undefined) => string;
|
|
16
|
+
export declare const useI18n: () => {
|
|
17
|
+
t: (path: string, replacement?: {
|
|
18
|
+
[key: string]: string | number;
|
|
19
|
+
} | undefined) => string;
|
|
20
|
+
langCode: string;
|
|
21
|
+
};
|
package/types/jotai.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimitiveAtom } from "jotai";
|
|
2
2
|
export declare const jotaiScope: unique symbol;
|
|
3
3
|
export declare const jotaiStore: {
|
|
4
4
|
get: <Value>(atom: import("jotai").Atom<Value>) => (Value extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value) | undefined;
|
|
5
5
|
asyncGet: <Value_1>(atom: import("jotai").Atom<Value_1>) => Promise<Value_1 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_1>;
|
|
6
|
-
set: <Value_2, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value_2, Update, Result>, update: Update) => Result;
|
|
6
|
+
set: <Value_2, Update, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_2, Update, Result>, update: Update) => Result;
|
|
7
7
|
sub: (atom: {
|
|
8
8
|
toString: () => string;
|
|
9
9
|
debugLabel?: string | undefined;
|
|
@@ -15,7 +15,7 @@ export declare const jotaiStore: {
|
|
|
15
15
|
}, callback: () => void) => () => void;
|
|
16
16
|
SECRET_INTERNAL_store: {
|
|
17
17
|
r: <Value_6>(readingAtom: import("jotai").Atom<Value_6>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_6>;
|
|
18
|
-
w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_1, Update_1, Result_1>, update: Update_1, version?: import("jotai/core/store").VersionObject | undefined) => Result_1;
|
|
18
|
+
w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom: import("jotai").WritableAtom<Value_1_1, Update_1, Result_1>, update: Update_1, version?: import("jotai/core/store").VersionObject | undefined) => Result_1;
|
|
19
19
|
c: (_atom: {
|
|
20
20
|
toString: () => string;
|
|
21
21
|
debugLabel?: string | undefined;
|
|
@@ -85,7 +85,7 @@ export declare const jotaiStore: {
|
|
|
85
85
|
} | undefined;
|
|
86
86
|
} | {
|
|
87
87
|
r: <Value_7>(readingAtom: import("jotai").Atom<Value_7>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_7>;
|
|
88
|
-
w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_2, Update_2, Result_2>, update: Update_2, version?: import("jotai/core/store").VersionObject | undefined) => Result_2;
|
|
88
|
+
w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom: import("jotai").WritableAtom<Value_1_2, Update_2, Result_2>, update: Update_2, version?: import("jotai/core/store").VersionObject | undefined) => Result_2;
|
|
89
89
|
c: (_atom: {
|
|
90
90
|
toString: () => string;
|
|
91
91
|
debugLabel?: string | undefined;
|
|
@@ -119,4 +119,4 @@ export declare const jotaiStore: {
|
|
|
119
119
|
m?: undefined;
|
|
120
120
|
};
|
|
121
121
|
};
|
|
122
|
-
export declare const useAtomWithInitialValue: <T extends unknown, A extends
|
|
122
|
+
export declare const useAtomWithInitialValue: <T extends unknown, A extends PrimitiveAtom<T>>(atom: A, initialValue: T | (() => T)) => readonly [T extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : T, import("jotai/core/atom").SetAtom<T | ((prev: T) => T), void>];
|
package/types/math.d.ts
CHANGED
|
@@ -26,3 +26,4 @@ export declare const getBezierCurveArcLengths: (element: NonDeleted<ExcalidrawLi
|
|
|
26
26
|
export declare const getBezierCurveLength: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number]) => number;
|
|
27
27
|
export declare const mapIntervalToBezierT: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number], interval: number) => number;
|
|
28
28
|
export declare const arePointsEqual: (p1: readonly [number, number], p2: readonly [number, number]) => boolean;
|
|
29
|
+
export declare const isRightAngle: (angle: number) => boolean;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type * as TExcalidraw from "../index";
|
|
2
2
|
import "./App.scss";
|
|
3
|
+
import { ExcalidrawImperativeAPI } from "../../../types";
|
|
3
4
|
declare global {
|
|
4
5
|
interface Window {
|
|
5
6
|
ExcalidrawLib: typeof TExcalidraw;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
+
export interface AppProps {
|
|
10
|
+
appTitle: string;
|
|
11
|
+
useCustom: (api: ExcalidrawImperativeAPI | null, customArgs?: any[]) => void;
|
|
12
|
+
customArgs?: any[];
|
|
13
|
+
}
|
|
14
|
+
export default function App({ appTitle, useCustom, customArgs }: AppProps): JSX.Element;
|
|
@@ -9,7 +9,7 @@ import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCo
|
|
|
9
9
|
declare type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
|
|
10
10
|
export declare const Excalidraw: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
|
|
11
11
|
export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
|
|
12
|
-
export { defaultLang, languages } from "../../i18n";
|
|
12
|
+
export { defaultLang, useI18n, languages } from "../../i18n";
|
|
13
13
|
export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "../../data/restore";
|
|
14
14
|
export { exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, loadSceneOrLibraryFromBlob, getFreeDrawSvgPath, exportToClipboard, mergeLibraryItems, } from "../../packages/utils";
|
|
15
15
|
export { isLinearElement } from "../../element/typeChecks";
|
|
@@ -29,3 +29,4 @@ export { jotaiScope, jotaiStore } from "../../jotai";
|
|
|
29
29
|
export { libraryItemsAtom } from "../../data/library";
|
|
30
30
|
export { exportToCanvas } from "../../scene/export";
|
|
31
31
|
export * as icons from "../../components/icons";
|
|
32
|
+
export * as actions from "../../actions/index";
|
|
@@ -14,6 +14,10 @@ export declare const exportToSvg: ({ data, config, }: {
|
|
|
14
14
|
data: ExportToCanvasData;
|
|
15
15
|
config?: ExportToSvgConfig | undefined;
|
|
16
16
|
}) => Promise<SVGSVGElement>;
|
|
17
|
+
export declare const exportToCanvas: ({ data, config, }: {
|
|
18
|
+
data: ExportToCanvasData;
|
|
19
|
+
config?: ExportToCanvasConfig | undefined;
|
|
20
|
+
}) => Promise<HTMLCanvasElement>;
|
|
17
21
|
export declare const exportToClipboard: ({ type, data, config, }: {
|
|
18
22
|
data: ExportToCanvasData;
|
|
19
23
|
} & ({
|
|
@@ -3,12 +3,13 @@ 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
|
+
zoomValue: RenderConfig["zoom"]["value"];
|
|
12
13
|
canvasOffsetX: number;
|
|
13
14
|
canvasOffsetY: number;
|
|
14
15
|
boundTextElementVersion: number | null;
|
package/types/scene/export.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NonDeletedExcalidrawElement, Theme } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles } from "../types";
|
|
3
|
+
import { serializeAsJSON } from "../data/json";
|
|
3
4
|
export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
|
|
4
5
|
export declare type ExportToCanvasData = {
|
|
5
6
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
@@ -33,6 +34,15 @@ export declare type ExportToCanvasConfig = {
|
|
|
33
34
|
* `scale`.
|
|
34
35
|
*/
|
|
35
36
|
maxWidthOrHeight?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Scale the canvas content to be excatly this many pixels wide/tall.
|
|
39
|
+
*
|
|
40
|
+
* Cannot be used in conjunction with `maxWidthOrHeight`.
|
|
41
|
+
*
|
|
42
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
43
|
+
* `scale`.
|
|
44
|
+
*/
|
|
45
|
+
widthOrHeight?: number;
|
|
36
46
|
/**
|
|
37
47
|
* Width of the frame. Supply `x` or `y` if you want to ofsset the canvas
|
|
38
48
|
* content.
|
|
@@ -150,5 +160,7 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
150
160
|
viewBackgroundColor: string;
|
|
151
161
|
exportWithDarkMode?: boolean;
|
|
152
162
|
exportEmbedScene?: boolean;
|
|
153
|
-
}, files: BinaryFiles | null
|
|
163
|
+
}, files: BinaryFiles | null, opts?: {
|
|
164
|
+
serializeAsJSON?: () => string;
|
|
165
|
+
}) => Promise<SVGSVGElement>;
|
|
154
166
|
export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], padding: number, scale: number) => [number, number];
|
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";
|
|
@@ -14,8 +13,10 @@ import { isOverScrollBars } from "./scene";
|
|
|
14
13
|
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
15
14
|
import Library from "./data/library";
|
|
16
15
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
|
-
import type {
|
|
16
|
+
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
17
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
18
|
+
import { Merge, ForwardRef, ValueOf } 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?: {
|
|
@@ -37,7 +38,7 @@ export declare type DataURL = string & {
|
|
|
37
38
|
_brand: "DataURL";
|
|
38
39
|
};
|
|
39
40
|
export declare type BinaryFileData = {
|
|
40
|
-
mimeType: typeof
|
|
41
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
41
42
|
id: FileId;
|
|
42
43
|
dataURL: DataURL;
|
|
43
44
|
/**
|
|
@@ -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;
|
|
@@ -292,11 +293,12 @@ declare type CanvasActions = Partial<{
|
|
|
292
293
|
}>;
|
|
293
294
|
declare type UIOptions = Partial<{
|
|
294
295
|
dockedSidebarBreakpoint: number;
|
|
295
|
-
welcomeScreen: boolean;
|
|
296
296
|
canvasActions: CanvasActions;
|
|
297
|
+
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
298
|
+
welcomeScreen?: boolean;
|
|
297
299
|
}>;
|
|
298
300
|
export declare type AppProps = Merge<ExcalidrawProps, {
|
|
299
|
-
UIOptions: Merge<
|
|
301
|
+
UIOptions: Merge<UIOptions, {
|
|
300
302
|
canvasActions: Required<CanvasActions> & {
|
|
301
303
|
export: ExportOpts;
|
|
302
304
|
};
|
|
@@ -315,7 +317,7 @@ export declare type AppClassProperties = {
|
|
|
315
317
|
library: Library;
|
|
316
318
|
imageCache: Map<FileId, {
|
|
317
319
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
318
|
-
mimeType: typeof
|
|
320
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
319
321
|
}>;
|
|
320
322
|
files: BinaryFiles;
|
|
321
323
|
device: App["device"];
|
|
@@ -415,19 +417,4 @@ export declare type Device = Readonly<{
|
|
|
415
417
|
isTouchScreen: boolean;
|
|
416
418
|
canDeviceFitSidebar: boolean;
|
|
417
419
|
}>;
|
|
418
|
-
export declare type UIChildrenComponents = {
|
|
419
|
-
[k in "FooterCenter" | "Menu" | "WelcomeScreen"]?: React.ReactElement<{
|
|
420
|
-
children?: React.ReactNode;
|
|
421
|
-
}, React.JSXElementConstructor<any>>;
|
|
422
|
-
};
|
|
423
|
-
export declare type UIWelcomeScreenComponents = {
|
|
424
|
-
[k in "Center" | "MenuHint" | "ToolbarHint" | "HelpHint"]?: React.ReactElement<{
|
|
425
|
-
children?: React.ReactNode;
|
|
426
|
-
}, React.JSXElementConstructor<any>>;
|
|
427
|
-
};
|
|
428
|
-
export declare type UIWelcomeScreenCenterComponents = {
|
|
429
|
-
[k in "Logo" | "Heading" | "Menu" | "MenuItemLoadScene" | "MenuItemHelp"]?: React.ReactElement<{
|
|
430
|
-
children?: React.ReactNode;
|
|
431
|
-
}, React.JSXElementConstructor<any>>;
|
|
432
|
-
};
|
|
433
420
|
export {};
|
|
@@ -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
|
@@ -2,7 +2,6 @@ import { EVENT } from "./constants";
|
|
|
2
2
|
import { FontFamilyValues, FontString } from "./element/types";
|
|
3
3
|
import { AppState, LastActiveTool, Zoom } from "./types";
|
|
4
4
|
import { SHAPES } from "./shapes";
|
|
5
|
-
import React from "react";
|
|
6
5
|
export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
7
6
|
export declare const getDateTime: () => string;
|
|
8
7
|
export declare const capitalizeString: (str: string) => string;
|
|
@@ -29,6 +28,26 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
29
28
|
flush(): void;
|
|
30
29
|
cancel(): void;
|
|
31
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;
|
|
32
51
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
33
52
|
export declare const selectNode: (node: Element) => void;
|
|
34
53
|
export declare const removeSelection: () => void;
|
|
@@ -125,8 +144,10 @@ export declare const getUpdatedTimestamp: () => number;
|
|
|
125
144
|
export declare const arrayToMap: <T extends string | {
|
|
126
145
|
id: string;
|
|
127
146
|
}>(items: readonly T[]) => Map<string, T>;
|
|
147
|
+
export declare const arrayToMapWithIndex: <T extends {
|
|
148
|
+
id: string;
|
|
149
|
+
}>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
|
|
128
150
|
export declare const isTestEnv: () => boolean;
|
|
129
|
-
export declare const isProdEnv: () => boolean;
|
|
130
151
|
export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
|
|
131
152
|
nativeEvent: T;
|
|
132
153
|
}>;
|
|
@@ -135,21 +156,6 @@ export declare const isPrimitive: (val: any) => boolean;
|
|
|
135
156
|
export declare const getFrame: () => "top" | "iframe";
|
|
136
157
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
137
158
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
138
|
-
/**
|
|
139
|
-
* Partitions React children into named components and the rest of children.
|
|
140
|
-
*
|
|
141
|
-
* Returns known children as a dictionary of react children keyed by their
|
|
142
|
-
* displayName, and the rest children as an array.
|
|
143
|
-
*
|
|
144
|
-
* NOTE all named react components are included in the dictionary, irrespective
|
|
145
|
-
* of the supplied type parameter. This means you may be throwing away
|
|
146
|
-
* children that you aren't expecting, but should nonetheless be rendered.
|
|
147
|
-
* To guard against this (provided you care about the rest children at all),
|
|
148
|
-
* supply a second parameter with an object with keys of the expected children.
|
|
149
|
-
*/
|
|
150
|
-
export declare const getReactChildren: <KnownChildren extends {
|
|
151
|
-
[x: string]: React.ReactNode;
|
|
152
|
-
}>(children: React.ReactNode, expectedComponents?: Record<keyof KnownChildren, any> | undefined) => readonly [Partial<KnownChildren>, React.ReactNode[]];
|
|
153
159
|
export declare const isShallowEqual: <T extends Record<string, any>>(objA: T, objB: T) => boolean;
|
|
154
160
|
export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
|
|
155
161
|
checkForDefaultPrevented?: boolean | undefined;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AppState, LibraryItem } from "../types";
|
|
2
|
-
import "./SingleLibraryItem.scss";
|
|
3
|
-
declare const SingleLibraryItem: ({ libItem, appState, index, onChange, onRemove, }: {
|
|
4
|
-
libItem: LibraryItem;
|
|
5
|
-
appState: AppState;
|
|
6
|
-
index: number;
|
|
7
|
-
onChange: (val: string, index: number) => void;
|
|
8
|
-
onRemove: (id: string) => void;
|
|
9
|
-
}) => JSX.Element;
|
|
10
|
-
export default SingleLibraryItem;
|