@zsviczian/excalidraw 0.15.2-obsidian-2 → 0.15.2-obsidian-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/excalidraw.development.js +980 -170
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +33 -18
- package/types/actions/actionBoundText.d.ts +22 -12
- package/types/actions/actionCanvas.d.ts +110 -60
- package/types/actions/actionClipboard.d.ts +55 -30
- package/types/actions/actionDeleteSelected.d.ts +33 -18
- package/types/actions/actionElementLock.d.ts +287 -0
- package/types/actions/actionExport.d.ts +100 -55
- package/types/actions/actionFinalize.d.ts +22 -12
- package/types/actions/actionFlip.d.ts +2 -4
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +11 -6
- package/types/actions/actionMenu.d.ts +33 -18
- package/types/actions/actionProperties.d.ts +145 -80
- package/types/actions/actionStyles.d.ts +11 -6
- package/types/actions/actionToggleGridMode.d.ts +11 -6
- package/types/actions/actionToggleStats.d.ts +11 -6
- package/types/actions/actionToggleViewMode.d.ts +11 -6
- package/types/actions/actionToggleZenMode.d.ts +11 -6
- package/types/actions/index.d.ts +1 -1
- package/types/actions/manager.d.ts +1 -1
- package/types/actions/shortcuts.d.ts +1 -1
- package/types/actions/types.d.ts +7 -7
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +4 -1
- package/types/colors.d.ts +59 -5
- package/types/components/App.d.ts +3 -0
- package/types/components/Avatar.d.ts +1 -1
- package/types/components/ColorPicker/ColorInput.d.ts +7 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +18 -0
- package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
- package/types/components/ColorPicker/Picker.d.ts +16 -0
- package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
- package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/types/components/ColorPicker/ShadeList.d.ts +8 -0
- package/types/components/ColorPicker/TopPicks.d.ts +9 -0
- package/types/components/ColorPicker/colorPickerUtils.d.ts +41 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +16 -0
- package/types/components/ContextMenu.d.ts +3 -3
- package/types/components/Dialog.d.ts +2 -2
- package/types/components/FilledButton.d.ts +16 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +1 -1
- package/types/components/HelpButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +7 -12
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +1 -1
- package/types/components/LayerUI.d.ts +3 -2
- package/types/components/LibraryMenu.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +4 -4
- package/types/components/LibraryMenuHeaderContent.d.ts +3 -1
- package/types/components/LibraryMenuItems.d.ts +4 -5
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +7 -3
- package/types/components/LockButton.d.ts +1 -1
- package/types/components/MobileMenu.d.ts +1 -1
- package/types/components/PenModeButton.d.ts +1 -1
- package/types/components/Popover.d.ts +1 -1
- package/types/components/ProjectName.d.ts +2 -1
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Sidebar/common.d.ts +3 -3
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +3 -3
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/icons.d.ts +7 -1
- package/types/constants.d.ts +5 -0
- package/types/context/tunnels.d.ts +2 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +1 -1
- package/types/data/library.d.ts +2 -0
- package/types/data/restore.d.ts +2 -2
- package/types/data/types.d.ts +1 -1
- package/types/element/Hyperlink.d.ts +11 -6
- package/types/element/binding.d.ts +2 -2
- package/types/element/bounds.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +11 -6
- package/types/element/mutateElement.d.ts +1 -1
- package/types/element/newElement.d.ts +1 -1
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/transformHandles.d.ts +5 -5
- package/types/element/types.d.ts +35 -35
- package/types/errors.d.ts +1 -1
- package/types/ga.d.ts +5 -5
- package/types/hooks/useLibraryItemSvg.d.ts +31 -0
- package/types/hooks/useScrollPosition.d.ts +2 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +2 -2
- package/types/keys.d.ts +1 -1
- package/types/packages/excalidraw/index.d.ts +1 -1
- package/types/packages/utils.d.ts +2 -2
- package/types/renderer/easingFunctions.d.ts +1 -1
- package/types/renderer/renderElement.d.ts +2 -2
- package/types/scene/Scene.d.ts +4 -4
- package/types/scene/types.d.ts +4 -4
- package/types/types.d.ts +45 -37
- package/types/utility-types.d.ts +13 -13
- package/types/utils.d.ts +3 -3
package/types/element/types.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Point } from "../types";
|
|
2
2
|
import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
3
|
import { MarkNonNullable, ValueOf } from "../utility-types";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
4
|
+
export type ChartType = "bar" | "line";
|
|
5
|
+
export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
|
|
6
|
+
export type FontFamilyKeys = keyof typeof FONT_FAMILY;
|
|
7
|
+
export type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
|
|
8
|
+
export type Theme = typeof THEME[keyof typeof THEME];
|
|
9
|
+
export type FontString = string & {
|
|
10
10
|
_brand: "fontString";
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
12
|
+
export type GroupId = string;
|
|
13
|
+
export type PointerType = "mouse" | "pen" | "touch";
|
|
14
|
+
export type StrokeRoundness = "round" | "sharp";
|
|
15
|
+
export type RoundnessType = ValueOf<typeof ROUNDNESS>;
|
|
16
|
+
export type StrokeStyle = "solid" | "dashed" | "dotted";
|
|
17
|
+
export type TextAlign = typeof TEXT_ALIGN[keyof typeof TEXT_ALIGN];
|
|
18
|
+
type VerticalAlignKeys = keyof typeof VERTICAL_ALIGN;
|
|
19
|
+
export type VerticalAlign = typeof VERTICAL_ALIGN[VerticalAlignKeys];
|
|
20
|
+
type _ExcalidrawElementBase = Readonly<{
|
|
21
21
|
id: string;
|
|
22
22
|
x: number;
|
|
23
23
|
y: number;
|
|
@@ -60,19 +60,19 @@ declare type _ExcalidrawElementBase = Readonly<{
|
|
|
60
60
|
locked: boolean;
|
|
61
61
|
customData?: Record<string, any>;
|
|
62
62
|
}>;
|
|
63
|
-
export
|
|
63
|
+
export type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
|
|
64
64
|
type: "selection";
|
|
65
65
|
};
|
|
66
|
-
export
|
|
66
|
+
export type ExcalidrawRectangleElement = _ExcalidrawElementBase & {
|
|
67
67
|
type: "rectangle";
|
|
68
68
|
};
|
|
69
|
-
export
|
|
69
|
+
export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
|
|
70
70
|
type: "diamond";
|
|
71
71
|
};
|
|
72
|
-
export
|
|
72
|
+
export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
|
|
73
73
|
type: "ellipse";
|
|
74
74
|
};
|
|
75
|
-
export
|
|
75
|
+
export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
|
|
76
76
|
type: "image";
|
|
77
77
|
fileId: FileId | null;
|
|
78
78
|
/** whether respective file is persisted */
|
|
@@ -80,22 +80,22 @@ export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
|
|
|
80
80
|
/** X and Y scale factors <-1, 1>, used for image axis flipping */
|
|
81
81
|
scale: [number, number];
|
|
82
82
|
}>;
|
|
83
|
-
export
|
|
83
|
+
export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
|
|
84
84
|
/**
|
|
85
85
|
* These are elements that don't have any additional properties.
|
|
86
86
|
*/
|
|
87
|
-
export
|
|
87
|
+
export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
|
|
88
88
|
/**
|
|
89
89
|
* ExcalidrawElement should be JSON serializable and (eventually) contain
|
|
90
90
|
* no computed data. The list of all ExcalidrawElements should be shareable
|
|
91
91
|
* between peers and contain no state local to the peer.
|
|
92
92
|
*/
|
|
93
|
-
export
|
|
94
|
-
export
|
|
93
|
+
export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement;
|
|
94
|
+
export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
|
|
95
95
|
isDeleted: boolean;
|
|
96
96
|
};
|
|
97
|
-
export
|
|
98
|
-
export
|
|
97
|
+
export type NonDeletedExcalidrawElement = NonDeleted<ExcalidrawElement>;
|
|
98
|
+
export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
99
99
|
type: "text";
|
|
100
100
|
fontSize: number;
|
|
101
101
|
fontFamily: FontFamilyValues;
|
|
@@ -114,18 +114,18 @@ export declare type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
114
114
|
_brand: "unitlessLineHeight";
|
|
115
115
|
};
|
|
116
116
|
}>;
|
|
117
|
-
export
|
|
118
|
-
export
|
|
119
|
-
export
|
|
117
|
+
export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement;
|
|
118
|
+
export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawImageElement | ExcalidrawArrowElement;
|
|
119
|
+
export type ExcalidrawTextElementWithContainer = {
|
|
120
120
|
containerId: ExcalidrawTextContainer["id"];
|
|
121
121
|
} & ExcalidrawTextElement;
|
|
122
|
-
export
|
|
122
|
+
export type PointBinding = {
|
|
123
123
|
elementId: ExcalidrawBindableElement["id"];
|
|
124
124
|
focus: number;
|
|
125
125
|
gap: number;
|
|
126
126
|
};
|
|
127
|
-
export
|
|
128
|
-
export
|
|
127
|
+
export type Arrowhead = "arrow" | "bar" | "dot" | "triangle";
|
|
128
|
+
export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
|
129
129
|
type: "line" | "arrow";
|
|
130
130
|
points: readonly Point[];
|
|
131
131
|
lastCommittedPoint: Point | null;
|
|
@@ -134,17 +134,17 @@ export declare type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<
|
|
|
134
134
|
startArrowhead: Arrowhead | null;
|
|
135
135
|
endArrowhead: Arrowhead | null;
|
|
136
136
|
}>;
|
|
137
|
-
export
|
|
137
|
+
export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
|
|
138
138
|
type: "arrow";
|
|
139
139
|
}>;
|
|
140
|
-
export
|
|
140
|
+
export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
|
141
141
|
type: "freedraw";
|
|
142
142
|
points: readonly Point[];
|
|
143
143
|
pressures: readonly number[];
|
|
144
144
|
simulatePressure: boolean;
|
|
145
145
|
lastCommittedPoint: Point | null;
|
|
146
146
|
}>;
|
|
147
|
-
export
|
|
147
|
+
export type FileId = string & {
|
|
148
148
|
_brand: "FileId";
|
|
149
149
|
};
|
|
150
150
|
export {};
|
package/types/errors.d.ts
CHANGED
package/types/ga.d.ts
CHANGED
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
* See GAPoint, GALine, GADirection and GATransform modules for common
|
|
17
17
|
* operations.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
19
|
+
export type Point = NVector;
|
|
20
|
+
export type Direction = NVector;
|
|
21
|
+
export type Line = NVector;
|
|
22
|
+
export type Transform = NVector;
|
|
23
23
|
export declare const point: (x: number, y: number) => NVector;
|
|
24
24
|
export declare const origin: () => NVector;
|
|
25
25
|
export declare const direction: (x: number, y: number) => NVector;
|
|
26
26
|
export declare const offset: (x: number, y: number) => NVector;
|
|
27
|
-
|
|
27
|
+
type NVector = readonly [
|
|
28
28
|
number,
|
|
29
29
|
number,
|
|
30
30
|
number,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LibraryItem } from "../types";
|
|
2
|
+
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;
|
|
3
|
+
export declare const libraryItemSvgsCache: import("jotai").Atom<SvgCache> & {
|
|
4
|
+
write: (get: {
|
|
5
|
+
<Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
|
|
6
|
+
<Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
|
|
7
|
+
<Value_2>(atom: import("jotai").Atom<Value_2>): Value_2 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_2;
|
|
8
|
+
} & {
|
|
9
|
+
<Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
|
|
10
|
+
unstable_promise: true;
|
|
11
|
+
}): Value_3 | Promise<Value_3>;
|
|
12
|
+
<Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
|
|
13
|
+
unstable_promise: true;
|
|
14
|
+
}): Value_4 | Promise<Value_4>;
|
|
15
|
+
<Value_5>(atom: import("jotai").Atom<Value_5>, options: {
|
|
16
|
+
unstable_promise: true;
|
|
17
|
+
}): (Value_5 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_5) | Promise<Value_5 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_5>;
|
|
18
|
+
}, set: {
|
|
19
|
+
<Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
|
|
20
|
+
<Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
|
|
21
|
+
}, update: SvgCache | ((prev: SvgCache) => SvgCache)) => void;
|
|
22
|
+
onMount?: (<S extends (update: SvgCache | ((prev: SvgCache) => SvgCache)) => void>(setAtom: S) => void | (() => void)) | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
init: SvgCache;
|
|
25
|
+
};
|
|
26
|
+
export declare const useLibraryItemSvg: (id: LibraryItem["id"] | null, elements: LibraryItem["elements"] | undefined, svgCache: SvgCache) => SVGSVGElement | undefined;
|
|
27
|
+
export declare const useLibraryCache: () => {
|
|
28
|
+
clearLibraryCache: () => void;
|
|
29
|
+
deleteItemsFromLibraryCache: (items: LibraryItem["id"][]) => void;
|
|
30
|
+
svgCache: SvgCache;
|
|
31
|
+
};
|
package/types/i18n.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ export declare const setLanguage: (lang: Language) => Promise<void>;
|
|
|
12
12
|
export declare const getLanguage: () => Language;
|
|
13
13
|
export declare const t: (path: string, replacement?: {
|
|
14
14
|
[key: string]: string | number;
|
|
15
|
-
} | undefined) => string;
|
|
15
|
+
} | null | undefined, fallback?: string) => string;
|
|
16
16
|
export declare const useI18n: () => {
|
|
17
17
|
t: (path: string, replacement?: {
|
|
18
18
|
[key: string]: string | number;
|
|
19
|
-
} | undefined) => string;
|
|
19
|
+
} | null | undefined, fallback?: string) => string;
|
|
20
20
|
langCode: string;
|
|
21
21
|
};
|
package/types/keys.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export declare const KEYS: {
|
|
|
70
70
|
readonly 8: "8";
|
|
71
71
|
readonly 9: "9";
|
|
72
72
|
};
|
|
73
|
-
export
|
|
73
|
+
export type Key = keyof typeof KEYS;
|
|
74
74
|
export declare const isArrowKey: (key: string) => boolean;
|
|
75
75
|
export declare const shouldResizeFromCenter: (event: MouseEvent | KeyboardEvent) => boolean;
|
|
76
76
|
export declare const shouldMaintainAspectRatio: (event: MouseEvent | KeyboardEvent) => boolean;
|
|
@@ -6,7 +6,7 @@ import Footer from "../../components/footer/FooterCenter";
|
|
|
6
6
|
import MainMenu from "../../components/main-menu/MainMenu";
|
|
7
7
|
import WelcomeScreen from "../../components/welcome-screen/WelcomeScreen";
|
|
8
8
|
import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCollaborationTrigger";
|
|
9
|
-
|
|
9
|
+
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
12
|
export { defaultLang, useI18n, languages } from "../../i18n";
|
|
@@ -2,7 +2,7 @@ import { AppState, BinaryFiles } from "../types";
|
|
|
2
2
|
import { ExcalidrawElement, NonDeleted } from "../element/types";
|
|
3
3
|
import { MIME_TYPES } from "../constants";
|
|
4
4
|
export { MIME_TYPES };
|
|
5
|
-
|
|
5
|
+
type ExportOpts = {
|
|
6
6
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
7
7
|
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
8
|
files: BinaryFiles | null;
|
|
@@ -36,7 +36,7 @@ export { getCommonBoundingBox } from "../element/bounds";
|
|
|
36
36
|
export { getMaximumGroups } from "../groups";
|
|
37
37
|
export { intersectElementWithLine } from "../element/collision";
|
|
38
38
|
export { determineFocusDistance } from "../element/collision";
|
|
39
|
-
export { measureText, wrapText, getDefaultLineHeight } from "../element/textElement";
|
|
39
|
+
export { measureText, wrapText, getDefaultLineHeight, } from "../element/textElement";
|
|
40
40
|
export { getFontString } from "../utils";
|
|
41
41
|
export { getBoundTextMaxWidth } from "../element/textElement";
|
|
42
42
|
export { mergeLibraryItems } from "../data/library";
|
|
@@ -15,8 +15,8 @@ export interface ExcalidrawElementWithCanvas {
|
|
|
15
15
|
boundTextElementVersion: number | null;
|
|
16
16
|
}
|
|
17
17
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
type ElementShape = Drawable | Drawable[] | null;
|
|
19
|
+
type ElementShapes = {
|
|
20
20
|
freedraw: Drawable | null;
|
|
21
21
|
arrow: Drawable[];
|
|
22
22
|
line: Drawable[];
|
package/types/scene/Scene.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "../element/types";
|
|
2
2
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
|
|
4
|
+
type ElementKey = ExcalidrawElement | ElementIdKey;
|
|
5
|
+
type SceneStateCallback = () => void;
|
|
6
|
+
type SceneStateCallbackRemover = () => void;
|
|
7
7
|
declare class Scene {
|
|
8
8
|
private static sceneMapByElement;
|
|
9
9
|
private static sceneMapById;
|
package/types/scene/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawTextElement } from "../element/types";
|
|
2
2
|
import { AppClassProperties, AppState } from "../types";
|
|
3
|
-
export
|
|
3
|
+
export type RenderConfig = {
|
|
4
4
|
scrollX: AppState["scrollX"];
|
|
5
5
|
scrollY: AppState["scrollY"];
|
|
6
6
|
/** null indicates transparent bg */
|
|
@@ -35,15 +35,15 @@ export declare type RenderConfig = {
|
|
|
35
35
|
isExporting: boolean;
|
|
36
36
|
selectionColor?: string;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type SceneScroll = {
|
|
39
39
|
scrollX: number;
|
|
40
40
|
scrollY: number;
|
|
41
41
|
};
|
|
42
42
|
export interface Scene {
|
|
43
43
|
elements: ExcalidrawTextElement[];
|
|
44
44
|
}
|
|
45
|
-
export
|
|
46
|
-
export
|
|
45
|
+
export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
|
|
46
|
+
export type ScrollBars = {
|
|
47
47
|
horizontal: {
|
|
48
48
|
x: number;
|
|
49
49
|
y: number;
|
package/types/types.d.ts
CHANGED
|
@@ -17,8 +17,9 @@ import type { FileSystemHandle } from "./data/filesystem";
|
|
|
17
17
|
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
18
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
19
19
|
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
|
20
|
-
|
|
21
|
-
export
|
|
20
|
+
import { ColorPaletteCustom } from "./colors";
|
|
21
|
+
export type Point = Readonly<RoughPoint>;
|
|
22
|
+
export type Collaborator = {
|
|
22
23
|
pointer?: {
|
|
23
24
|
x: number;
|
|
24
25
|
y: number;
|
|
@@ -34,10 +35,10 @@ export declare type Collaborator = {
|
|
|
34
35
|
avatarUrl?: string;
|
|
35
36
|
id?: string;
|
|
36
37
|
};
|
|
37
|
-
export
|
|
38
|
+
export type DataURL = string & {
|
|
38
39
|
_brand: "DataURL";
|
|
39
40
|
};
|
|
40
|
-
export
|
|
41
|
+
export type BinaryFileData = {
|
|
41
42
|
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
42
43
|
id: FileId;
|
|
43
44
|
dataURL: DataURL;
|
|
@@ -54,18 +55,18 @@ export declare type BinaryFileData = {
|
|
|
54
55
|
*/
|
|
55
56
|
lastRetrieved?: number;
|
|
56
57
|
};
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
58
|
+
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
59
|
+
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
60
|
+
export type LastActiveTool = {
|
|
60
61
|
type: typeof SHAPES[number]["value"] | "eraser" | "hand";
|
|
61
62
|
customType: null;
|
|
62
63
|
} | {
|
|
63
64
|
type: "custom";
|
|
64
65
|
customType: string;
|
|
65
66
|
} | null;
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
67
|
+
export type SidebarName = string;
|
|
68
|
+
export type SidebarTabName = string;
|
|
69
|
+
export type AppState = {
|
|
69
70
|
contextMenu: {
|
|
70
71
|
items: ContextMenuItems;
|
|
71
72
|
top: number;
|
|
@@ -126,7 +127,7 @@ export declare type AppState = {
|
|
|
126
127
|
isRotating: boolean;
|
|
127
128
|
zoom: Zoom;
|
|
128
129
|
openMenu: "canvas" | "shape" | null;
|
|
129
|
-
openPopup: "
|
|
130
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
130
131
|
openSidebar: {
|
|
131
132
|
name: SidebarName;
|
|
132
133
|
tab?: SidebarTabName;
|
|
@@ -185,10 +186,15 @@ export declare type AppState = {
|
|
|
185
186
|
showHyperlinkPopup: false | "info" | "editor";
|
|
186
187
|
linkOpacity: number;
|
|
187
188
|
trayModeEnabled: boolean;
|
|
188
|
-
colorPalette
|
|
189
|
-
canvasBackground
|
|
190
|
-
elementBackground
|
|
191
|
-
elementStroke
|
|
189
|
+
colorPalette?: {
|
|
190
|
+
canvasBackground: ColorPaletteCustom;
|
|
191
|
+
elementBackground: ColorPaletteCustom;
|
|
192
|
+
elementStroke: ColorPaletteCustom;
|
|
193
|
+
topPicks: {
|
|
194
|
+
canvasBackground: [string, string, string, string, string];
|
|
195
|
+
elementStroke: [string, string, string, string, string];
|
|
196
|
+
elementBackground: [string, string, string, string, string];
|
|
197
|
+
};
|
|
192
198
|
};
|
|
193
199
|
allowWheelZoom?: boolean;
|
|
194
200
|
allowPinchZoom?: boolean;
|
|
@@ -201,18 +207,18 @@ export declare type AppState = {
|
|
|
201
207
|
invertBindingBehaviour: boolean;
|
|
202
208
|
selectedLinearElement: LinearElementEditor | null;
|
|
203
209
|
};
|
|
204
|
-
export
|
|
205
|
-
export
|
|
210
|
+
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
211
|
+
export type NormalizedZoomValue = number & {
|
|
206
212
|
_brand: "normalizedZoom";
|
|
207
213
|
};
|
|
208
|
-
export
|
|
214
|
+
export type Zoom = Readonly<{
|
|
209
215
|
value: NormalizedZoomValue;
|
|
210
216
|
}>;
|
|
211
|
-
export
|
|
217
|
+
export type PointerCoords = Readonly<{
|
|
212
218
|
x: number;
|
|
213
219
|
y: number;
|
|
214
220
|
}>;
|
|
215
|
-
export
|
|
221
|
+
export type Gesture = {
|
|
216
222
|
pointers: Map<number, PointerCoords>;
|
|
217
223
|
lastCenter: {
|
|
218
224
|
x: number;
|
|
@@ -226,11 +232,11 @@ export declare class GestureEvent extends UIEvent {
|
|
|
226
232
|
readonly scale: number;
|
|
227
233
|
}
|
|
228
234
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
229
|
-
export
|
|
235
|
+
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
230
236
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
231
|
-
|
|
237
|
+
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
232
238
|
/** v2 library item */
|
|
233
|
-
export
|
|
239
|
+
export type LibraryItem = {
|
|
234
240
|
id: string;
|
|
235
241
|
status: "published" | "unpublished";
|
|
236
242
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
@@ -239,14 +245,14 @@ export declare type LibraryItem = {
|
|
|
239
245
|
name?: string;
|
|
240
246
|
error?: string;
|
|
241
247
|
};
|
|
242
|
-
export
|
|
243
|
-
export
|
|
244
|
-
export
|
|
245
|
-
export
|
|
248
|
+
export type LibraryItems = readonly LibraryItem[];
|
|
249
|
+
export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
|
250
|
+
export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
|
|
251
|
+
export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
|
|
246
252
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
247
253
|
ready?: false;
|
|
248
254
|
};
|
|
249
|
-
export
|
|
255
|
+
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
250
256
|
libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
|
|
251
257
|
}>;
|
|
252
258
|
export interface ExcalidrawProps {
|
|
@@ -292,7 +298,7 @@ export interface ExcalidrawProps {
|
|
|
292
298
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
293
299
|
children?: React.ReactNode;
|
|
294
300
|
}
|
|
295
|
-
export
|
|
301
|
+
export type SceneData = {
|
|
296
302
|
elements?: ImportedDataState["elements"];
|
|
297
303
|
appState?: ImportedDataState["appState"];
|
|
298
304
|
collaborators?: Map<string, Collaborator>;
|
|
@@ -303,12 +309,12 @@ export declare enum UserIdleState {
|
|
|
303
309
|
AWAY = "away",
|
|
304
310
|
IDLE = "idle"
|
|
305
311
|
}
|
|
306
|
-
export
|
|
312
|
+
export type ExportOpts = {
|
|
307
313
|
saveFileToDisk?: boolean;
|
|
308
314
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
|
|
309
315
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
|
|
310
316
|
};
|
|
311
|
-
|
|
317
|
+
type CanvasActions = Partial<{
|
|
312
318
|
changeViewBackgroundColor: boolean;
|
|
313
319
|
clearCanvas: boolean;
|
|
314
320
|
export: false | ExportOpts;
|
|
@@ -317,13 +323,13 @@ declare type CanvasActions = Partial<{
|
|
|
317
323
|
toggleTheme: boolean | null;
|
|
318
324
|
saveAsImage: boolean;
|
|
319
325
|
}>;
|
|
320
|
-
|
|
326
|
+
type UIOptions = Partial<{
|
|
321
327
|
dockedSidebarBreakpoint: number;
|
|
322
328
|
canvasActions: CanvasActions;
|
|
323
329
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
324
330
|
welcomeScreen?: boolean;
|
|
325
331
|
}>;
|
|
326
|
-
export
|
|
332
|
+
export type AppProps = Merge<ExcalidrawProps, {
|
|
327
333
|
UIOptions: Merge<UIOptions, {
|
|
328
334
|
canvasActions: Required<CanvasActions> & {
|
|
329
335
|
export: ExportOpts;
|
|
@@ -336,7 +342,7 @@ export declare type AppProps = Merge<ExcalidrawProps, {
|
|
|
336
342
|
}>;
|
|
337
343
|
/** A subset of App class properties that we need to use elsewhere
|
|
338
344
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
339
|
-
export
|
|
345
|
+
export type AppClassProperties = {
|
|
340
346
|
props: AppProps;
|
|
341
347
|
canvas: HTMLCanvasElement | null;
|
|
342
348
|
focusContainer(): void;
|
|
@@ -351,8 +357,9 @@ export declare type AppClassProperties = {
|
|
|
351
357
|
pasteFromClipboard: App["pasteFromClipboard"];
|
|
352
358
|
id: App["id"];
|
|
353
359
|
onInsertElements: App["onInsertElements"];
|
|
360
|
+
onExportImage: App["onExportImage"];
|
|
354
361
|
};
|
|
355
|
-
export
|
|
362
|
+
export type PointerDownState = Readonly<{
|
|
356
363
|
origin: Readonly<{
|
|
357
364
|
x: number;
|
|
358
365
|
y: number;
|
|
@@ -411,7 +418,7 @@ export declare type PointerDownState = Readonly<{
|
|
|
411
418
|
};
|
|
412
419
|
};
|
|
413
420
|
}>;
|
|
414
|
-
export
|
|
421
|
+
export type ExcalidrawImperativeAPI = {
|
|
415
422
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
416
423
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
417
424
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
@@ -445,10 +452,11 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
445
452
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
446
453
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
447
454
|
};
|
|
448
|
-
export
|
|
455
|
+
export type Device = Readonly<{
|
|
449
456
|
isSmScreen: boolean;
|
|
450
457
|
isMobile: boolean;
|
|
451
458
|
isTouchScreen: boolean;
|
|
452
459
|
canDeviceFitSidebar: boolean;
|
|
460
|
+
isLandscape: boolean;
|
|
453
461
|
}>;
|
|
454
462
|
export {};
|
package/types/utility-types.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export type Mutable<T> = {
|
|
3
3
|
-readonly [P in keyof T]: T[P];
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type ValueOf<T> = T[keyof T];
|
|
6
|
+
export type Merge<M, N> = Omit<M, keyof N> & N;
|
|
7
7
|
/** utility type to assert that the second type is a subtype of the first type.
|
|
8
8
|
* Returns the subtype. */
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
9
|
+
export type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
|
|
10
|
+
export type ResolutionType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
11
|
+
export type MarkOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
12
|
+
export type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
|
|
13
|
+
export type MarkNonNullable<T, K extends keyof T> = {
|
|
14
14
|
[P in K]-?: P extends K ? NonNullable<T[P]> : T[P];
|
|
15
15
|
} & {
|
|
16
16
|
[P in keyof T]: T[P];
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
18
|
+
export type NonOptional<T> = Exclude<T, undefined>;
|
|
19
|
+
export type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
|
|
20
|
+
export type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
|
|
21
|
+
export type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
|
|
22
|
+
export type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
|
package/types/utils.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
|
6
6
|
export declare const getDateTime: () => string;
|
|
7
7
|
export declare const capitalizeString: (str: string) => string;
|
|
8
8
|
export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
|
|
9
|
-
export declare const isInputLike: (target: Element | EventTarget | null) => target is
|
|
10
|
-
export declare const isWritableElement: (target: Element | EventTarget | null) => target is
|
|
9
|
+
export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
|
|
10
|
+
export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
|
|
11
11
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
12
12
|
fontFamily: FontFamilyValues;
|
|
13
13
|
}) => string;
|
|
@@ -111,7 +111,7 @@ export declare const muteFSAbortError: (error?: Error) => void;
|
|
|
111
111
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
112
112
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
113
113
|
export declare const isTransparent: (color: string) => boolean;
|
|
114
|
-
export
|
|
114
|
+
export type ResolvablePromise<T> = Promise<T> & {
|
|
115
115
|
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
|
116
116
|
reject: (error: Error) => void;
|
|
117
117
|
};
|