@dwelle/excalidraw 0.4.0-d68dd48 → 0.4.0-e03b600
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 +30 -0
- package/README.md +4 -0
- package/dist/excalidraw.development.js +1314 -248
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +36 -12
- package/types/actions/actionAlign.d.ts +6 -0
- package/types/actions/actionBoundText.d.ts +24 -8
- package/types/actions/actionCanvas.d.ts +235 -41
- package/types/actions/actionClipboard.d.ts +60 -20
- package/types/actions/actionDeleteSelected.d.ts +36 -12
- package/types/actions/actionElementLock.d.ts +254 -0
- package/types/actions/actionExport.d.ts +109 -37
- package/types/actions/actionFinalize.d.ts +24 -8
- package/types/actions/actionFlip.d.ts +2 -4
- package/types/actions/actionFrame.d.ts +397 -0
- package/types/actions/actionGroup.d.ts +2 -2
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +12 -4
- package/types/actions/actionMenu.d.ts +37 -14
- package/types/actions/actionNavigate.d.ts +1 -1
- package/types/actions/actionProperties.d.ts +158 -54
- package/types/actions/actionStyles.d.ts +12 -4
- package/types/actions/actionToggleGridMode.d.ts +12 -4
- package/types/actions/actionToggleStats.d.ts +12 -4
- package/types/actions/actionToggleViewMode.d.ts +12 -4
- package/types/actions/actionToggleZenMode.d.ts +12 -4
- package/types/actions/actionZindex.d.ts +4 -4
- 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/appState.d.ts +6 -3
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +2 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +5 -5
- package/types/components/ActiveConfirmDialog.d.ts +1 -21
- package/types/components/App.d.ts +32 -9
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/Button.d.ts +3 -1
- package/types/components/ColorPicker/ColorInput.d.ts +7 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +19 -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 +18 -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 +21 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +21 -0
- package/types/components/ContextMenu.d.ts +3 -3
- package/types/components/DefaultSidebar.d.ts +30 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/EyeDropper.d.ts +18 -0
- package/types/components/FilledButton.d.ts +17 -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/HintViewer.d.ts +2 -2
- package/types/components/HomeButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +8 -13
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +4 -4
- package/types/components/LayerUI.d.ts +4 -10
- package/types/components/LibraryMenu.d.ts +13 -14
- package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +9 -0
- package/types/components/LibraryMenuHeaderContent.d.ts +11 -28
- package/types/components/LibraryMenuItems.d.ts +6 -7
- 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 +4 -4
- package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
- package/types/components/PasteChartDialog.d.ts +4 -5
- 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/PublishLibrary.d.ts +2 -2
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Sidebar/Sidebar.d.ts +66 -63
- package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
- package/types/components/Sidebar/SidebarTab.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
- package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/types/components/Sidebar/common.d.ts +24 -7
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Stats.d.ts +3 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +5 -4
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +8 -0
- package/types/components/dropdownMenu/DropdownMenu.d.ts +3 -2
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +4 -2
- package/types/components/footer/Footer.d.ts +2 -2
- package/types/components/icons.d.ts +11 -1
- package/types/components/main-menu/MainMenu.d.ts +3 -2
- package/types/constants.d.ts +42 -6
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +2 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +2 -2
- package/types/data/types.d.ts +3 -5
- package/types/element/Hyperlink.d.ts +14 -6
- package/types/element/binding.d.ts +3 -3
- package/types/element/bounds.d.ts +31 -6
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +2 -1
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +13 -5
- package/types/element/mutateElement.d.ts +1 -1
- package/types/element/newElement.d.ts +10 -3
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/textElement.d.ts +3 -2
- package/types/element/transformHandles.d.ts +12 -5
- package/types/element/typeChecks.d.ts +2 -1
- package/types/element/types.d.ts +40 -35
- package/types/emitter.d.ts +1 -1
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +40 -0
- package/types/ga.d.ts +5 -5
- package/types/groups.d.ts +4 -0
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -1
- 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/jotai.d.ts +16 -104
- package/types/keys.d.ts +2 -1
- package/types/math.d.ts +1 -0
- package/types/packages/excalidraw/example/initialData.d.ts +6 -0
- package/types/packages/excalidraw/index.d.ts +2 -1
- package/types/packages/utils.d.ts +2 -2
- package/types/renderer/renderElement.d.ts +4 -3
- package/types/renderer/renderScene.d.ts +12 -3
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Scene.d.ts +12 -5
- package/types/scene/export.d.ts +3 -2
- package/types/scene/selection.d.ts +15 -5
- package/types/scene/types.d.ts +4 -4
- package/types/types.d.ts +91 -52
- package/types/utility-types.d.ts +13 -13
- package/types/utils.d.ts +20 -25
- package/types/zindex.d.ts +4 -4
- package/types/actions/actionToggleLock.d.ts +0 -119
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/context/tunnels.d.ts +0 -16
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
package/types/constants.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare enum EVENT {
|
|
|
47
47
|
GESTURE_START = "gesturestart",
|
|
48
48
|
GESTURE_CHANGE = "gesturechange",
|
|
49
49
|
POINTER_MOVE = "pointermove",
|
|
50
|
+
POINTER_DOWN = "pointerdown",
|
|
50
51
|
POINTER_UP = "pointerup",
|
|
51
52
|
STATE_CHANGE = "statechange",
|
|
52
53
|
WHEEL = "wheel",
|
|
@@ -75,6 +76,19 @@ export declare const THEME: {
|
|
|
75
76
|
LIGHT: string;
|
|
76
77
|
DARK: string;
|
|
77
78
|
};
|
|
79
|
+
export declare const FRAME_STYLE: {
|
|
80
|
+
strokeColor: string;
|
|
81
|
+
strokeWidth: number;
|
|
82
|
+
strokeStyle: import("./element/types").StrokeStyle;
|
|
83
|
+
fillStyle: import("./element/types").FillStyle;
|
|
84
|
+
roughness: number;
|
|
85
|
+
roundness: {
|
|
86
|
+
type: import("./element/types").RoundnessType;
|
|
87
|
+
value?: number | undefined;
|
|
88
|
+
} | null;
|
|
89
|
+
backgroundColor: string;
|
|
90
|
+
radius: number;
|
|
91
|
+
};
|
|
78
92
|
export declare const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
79
93
|
export declare const DEFAULT_FONT_SIZE = 20;
|
|
80
94
|
export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
|
|
@@ -86,21 +100,39 @@ export declare const DEFAULT_STROKE_COLOR = "#000000";
|
|
|
86
100
|
export declare const DEFAULT_ZOOM_VALUE: NormalizedZoomValue;
|
|
87
101
|
export declare const CANVAS_ONLY_ACTIONS: string[];
|
|
88
102
|
export declare const GRID_SIZE = 20;
|
|
103
|
+
export declare const IMAGE_MIME_TYPES: {
|
|
104
|
+
readonly svg: "image/svg+xml";
|
|
105
|
+
readonly png: "image/png";
|
|
106
|
+
readonly jpg: "image/jpeg";
|
|
107
|
+
readonly gif: "image/gif";
|
|
108
|
+
readonly webp: "image/webp";
|
|
109
|
+
readonly bmp: "image/bmp";
|
|
110
|
+
readonly ico: "image/x-icon";
|
|
111
|
+
readonly avif: "image/avif";
|
|
112
|
+
readonly jfif: "image/jfif";
|
|
113
|
+
};
|
|
89
114
|
export declare const MIME_TYPES: {
|
|
90
|
-
readonly excalidraw: "application/vnd.excalidraw+json";
|
|
91
|
-
readonly excalidrawlib: "application/vnd.excalidrawlib+json";
|
|
92
|
-
readonly json: "application/json";
|
|
93
115
|
readonly svg: "image/svg+xml";
|
|
94
|
-
readonly "excalidraw.svg": "image/svg+xml";
|
|
95
116
|
readonly png: "image/png";
|
|
96
|
-
readonly "excalidraw.png": "image/png";
|
|
97
117
|
readonly jpg: "image/jpeg";
|
|
98
118
|
readonly gif: "image/gif";
|
|
99
119
|
readonly webp: "image/webp";
|
|
100
120
|
readonly bmp: "image/bmp";
|
|
101
121
|
readonly ico: "image/x-icon";
|
|
122
|
+
readonly avif: "image/avif";
|
|
123
|
+
readonly jfif: "image/jfif";
|
|
124
|
+
readonly json: "application/json";
|
|
125
|
+
readonly excalidraw: "application/vnd.excalidraw+json";
|
|
126
|
+
readonly excalidrawlib: "application/vnd.excalidrawlib+json";
|
|
127
|
+
readonly "excalidraw.svg": "image/svg+xml";
|
|
128
|
+
readonly "excalidraw.png": "image/png";
|
|
102
129
|
readonly binary: "application/octet-stream";
|
|
103
130
|
};
|
|
131
|
+
export declare const EXPORT_IMAGE_TYPES: {
|
|
132
|
+
readonly png: "png";
|
|
133
|
+
readonly svg: "svg";
|
|
134
|
+
readonly clipboard: "clipboard";
|
|
135
|
+
};
|
|
104
136
|
export declare const EXPORT_DATA_TYPES: {
|
|
105
137
|
readonly excalidraw: "excalidraw";
|
|
106
138
|
readonly excalidrawClipboard: "excalidraw/clipboard";
|
|
@@ -136,7 +168,6 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
|
136
168
|
export declare const EXPORT_SCALES: number[];
|
|
137
169
|
export declare const DEFAULT_EXPORT_PADDING = 10;
|
|
138
170
|
export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
|
|
139
|
-
export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif", "image/webp", "image/bmp", "image/x-icon"];
|
|
140
171
|
export declare const MAX_ALLOWED_FILE_BYTES: number;
|
|
141
172
|
export declare const SVG_NS = "http://www.w3.org/2000/svg";
|
|
142
173
|
export declare const ENCRYPTION_KEY_BITS = 128;
|
|
@@ -176,3 +207,8 @@ export declare const DEFAULT_ELEMENT_PROPS: {
|
|
|
176
207
|
opacity: ExcalidrawElement["opacity"];
|
|
177
208
|
locked: ExcalidrawElement["locked"];
|
|
178
209
|
};
|
|
210
|
+
export declare const LIBRARY_SIDEBAR_TAB = "library";
|
|
211
|
+
export declare const DEFAULT_SIDEBAR: {
|
|
212
|
+
readonly name: "default";
|
|
213
|
+
readonly defaultTab: "library";
|
|
214
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import tunnel from "tunnel-rat";
|
|
3
|
+
export type Tunnel = ReturnType<typeof tunnel>;
|
|
4
|
+
type TunnelsContextValue = {
|
|
5
|
+
MainMenuTunnel: Tunnel;
|
|
6
|
+
WelcomeScreenMenuHintTunnel: Tunnel;
|
|
7
|
+
WelcomeScreenToolbarHintTunnel: Tunnel;
|
|
8
|
+
WelcomeScreenHelpHintTunnel: Tunnel;
|
|
9
|
+
WelcomeScreenCenterTunnel: Tunnel;
|
|
10
|
+
FooterCenterTunnel: Tunnel;
|
|
11
|
+
DefaultSidebarTriggerTunnel: Tunnel;
|
|
12
|
+
DefaultSidebarTabTriggersTunnel: Tunnel;
|
|
13
|
+
OverwriteConfirmDialogTunnel: Tunnel;
|
|
14
|
+
jotaiScope: symbol;
|
|
15
|
+
};
|
|
16
|
+
export declare const TunnelsContext: React.Context<TunnelsContextValue>;
|
|
17
|
+
export declare const useTunnels: () => TunnelsContextValue;
|
|
18
|
+
export declare const useInitializeTunnels: () => TunnelsContextValue;
|
|
19
|
+
export {};
|
package/types/data/blob.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
|
|
2
2
|
import { ExcalidrawElement, FileId } from "../element/types";
|
|
3
3
|
import { AppState, DataURL, LibraryItem } from "../types";
|
|
4
4
|
import { ValueOf } from "../utility-types";
|
|
@@ -9,7 +9,7 @@ export declare const getFileHandleType: (handle: FileSystemHandle | null) => str
|
|
|
9
9
|
export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
|
|
10
10
|
export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
|
|
11
11
|
export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
|
|
12
|
-
type:
|
|
12
|
+
type: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
13
13
|
};
|
|
14
14
|
export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<{
|
|
15
15
|
type: "application/vnd.excalidraw+json";
|
package/types/data/encode.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const toByteString: (data: string | Uint8Array | ArrayBuffer) =>
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const stringToBase64: (str: string, isByteString?: boolean) => Promise<string>;
|
|
7
7
|
export declare const base64ToString: (base64: string, isByteString?: boolean) => Promise<string>;
|
|
8
|
-
|
|
8
|
+
type EncodedData = {
|
|
9
9
|
encoded: string;
|
|
10
10
|
encoding: "bstring";
|
|
11
11
|
/** whether text is compressed (zlib) */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FileSystemHandle, supported as nativeFileSystemSupported } from "browser-fs-access";
|
|
2
|
-
|
|
2
|
+
import { MIME_TYPES } from "../constants";
|
|
3
|
+
type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
|
|
3
4
|
export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
|
|
4
5
|
extensions?: FILE_EXTENSION[] | undefined;
|
|
5
6
|
description: string;
|
package/types/data/library.d.ts
CHANGED
|
@@ -1,55 +1,11 @@
|
|
|
1
1
|
import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource } from "../types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
3
|
import { ExcalidrawElement } from "../element/types";
|
|
4
|
-
export declare const libraryItemsAtom: import("jotai").
|
|
4
|
+
export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
|
|
5
5
|
status: "loading" | "loaded";
|
|
6
6
|
isInitialized: boolean;
|
|
7
7
|
libraryItems: LibraryItems;
|
|
8
8
|
}> & {
|
|
9
|
-
write: (get: {
|
|
10
|
-
<Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
|
|
11
|
-
<Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
|
|
12
|
-
<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;
|
|
13
|
-
} & {
|
|
14
|
-
<Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
|
|
15
|
-
unstable_promise: true;
|
|
16
|
-
}): Value_3 | Promise<Value_3>;
|
|
17
|
-
<Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
|
|
18
|
-
unstable_promise: true;
|
|
19
|
-
}): Value_4 | Promise<Value_4>;
|
|
20
|
-
<Value_5>(atom: import("jotai").Atom<Value_5>, options: {
|
|
21
|
-
unstable_promise: true;
|
|
22
|
-
}): (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>;
|
|
23
|
-
}, set: {
|
|
24
|
-
<Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
|
|
25
|
-
<Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
|
|
26
|
-
}, update: {
|
|
27
|
-
status: "loading" | "loaded";
|
|
28
|
-
isInitialized: boolean;
|
|
29
|
-
libraryItems: LibraryItems;
|
|
30
|
-
} | ((prev: {
|
|
31
|
-
status: "loading" | "loaded";
|
|
32
|
-
isInitialized: boolean;
|
|
33
|
-
libraryItems: LibraryItems;
|
|
34
|
-
}) => {
|
|
35
|
-
status: "loading" | "loaded";
|
|
36
|
-
isInitialized: boolean;
|
|
37
|
-
libraryItems: LibraryItems;
|
|
38
|
-
})) => void;
|
|
39
|
-
onMount?: (<S extends (update: {
|
|
40
|
-
status: "loading" | "loaded";
|
|
41
|
-
isInitialized: boolean;
|
|
42
|
-
libraryItems: LibraryItems;
|
|
43
|
-
} | ((prev: {
|
|
44
|
-
status: "loading" | "loaded";
|
|
45
|
-
isInitialized: boolean;
|
|
46
|
-
libraryItems: LibraryItems;
|
|
47
|
-
}) => {
|
|
48
|
-
status: "loading" | "loaded";
|
|
49
|
-
isInitialized: boolean;
|
|
50
|
-
libraryItems: LibraryItems;
|
|
51
|
-
})) => void>(setAtom: S) => void | (() => void)) | undefined;
|
|
52
|
-
} & {
|
|
53
9
|
init: {
|
|
54
10
|
status: "loading" | "loaded";
|
|
55
11
|
isInitialized: boolean;
|
|
@@ -70,6 +26,8 @@ declare class Library {
|
|
|
70
26
|
private updateQueue;
|
|
71
27
|
private getLastUpdateTask;
|
|
72
28
|
private notifyListeners;
|
|
29
|
+
/** call on excalidraw instance unmount */
|
|
30
|
+
destroy: () => void;
|
|
73
31
|
resetLibrary: () => Promise<LibraryItems>;
|
|
74
32
|
/**
|
|
75
33
|
* @returns latest cloned libraryItems. Awaits all in-progress updates first.
|
package/types/data/restore.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles, LibraryItem } from "../types";
|
|
3
3
|
import { ImportedDataState } from "./types";
|
|
4
|
-
|
|
4
|
+
type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
|
|
5
5
|
export declare const AllowedExcalidrawActiveTools: Record<AppState["activeTool"]["type"], boolean>;
|
|
6
|
-
export
|
|
6
|
+
export type RestoredDataState = {
|
|
7
7
|
elements: ExcalidrawElement[];
|
|
8
8
|
appState: RestoredAppState;
|
|
9
9
|
files: BinaryFiles;
|
package/types/data/types.d.ts
CHANGED
|
@@ -17,11 +17,9 @@ export interface ExportedDataState {
|
|
|
17
17
|
* This is a helper type used in downstream abstractions.
|
|
18
18
|
* Don't consume on its own.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
21
|
-
/** @deprecated #
|
|
22
|
-
|
|
23
|
-
/** @deprecated #5663 TODO remove 22-12-15 */
|
|
24
|
-
isLibraryMenuDocked: [boolean, "isSidebarDocked"];
|
|
20
|
+
export type LegacyAppState = {
|
|
21
|
+
/** @deprecated #6213 TODO remove 23-06-01 */
|
|
22
|
+
isSidebarDocked: [boolean, "defaultSidebarDockedPreference"];
|
|
25
23
|
};
|
|
26
24
|
export interface ImportedDataState {
|
|
27
25
|
type?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AppState, ExcalidrawProps } from "../types";
|
|
2
|
+
import { AppState, ExcalidrawProps, UIAppState } from "../types";
|
|
3
3
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
4
4
|
import { Bounds } from "./bounds";
|
|
5
5
|
import "./Hyperlink.scss";
|
|
@@ -33,13 +33,17 @@ export declare const actionLink: {
|
|
|
33
33
|
isBindingEnabled: boolean;
|
|
34
34
|
startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
|
|
35
35
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
36
|
+
frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
37
|
+
shouldRenderFrames: boolean;
|
|
38
|
+
editingFrame: string | null;
|
|
39
|
+
elementsToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawElement>[] | null;
|
|
36
40
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
37
41
|
editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
|
|
38
42
|
activeTool: {
|
|
39
43
|
lastActiveTool: import("../types").LastActiveTool;
|
|
40
44
|
locked: boolean;
|
|
41
45
|
} & ({
|
|
42
|
-
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | "hand";
|
|
46
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
43
47
|
customType: null;
|
|
44
48
|
} | {
|
|
45
49
|
type: "custom";
|
|
@@ -75,10 +79,13 @@ export declare const actionLink: {
|
|
|
75
79
|
zoom: Readonly<{
|
|
76
80
|
value: import("../types").NormalizedZoomValue;
|
|
77
81
|
}>;
|
|
78
|
-
openPopup: "
|
|
79
|
-
openSidebar:
|
|
82
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
83
|
+
openSidebar: {
|
|
84
|
+
name: string;
|
|
85
|
+
tab?: string | undefined;
|
|
86
|
+
} | null;
|
|
80
87
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
81
|
-
|
|
88
|
+
defaultSidebarDockedPreference: boolean;
|
|
82
89
|
lastPointerDownWith: import("./types").PointerType;
|
|
83
90
|
selectedElementIds: {
|
|
84
91
|
[id: string]: boolean;
|
|
@@ -86,6 +93,7 @@ export declare const actionLink: {
|
|
|
86
93
|
previousSelectedElementIds: {
|
|
87
94
|
[id: string]: boolean;
|
|
88
95
|
};
|
|
96
|
+
selectedElementsAreBeingDragged: boolean;
|
|
89
97
|
shouldCacheIgnoreZoom: boolean;
|
|
90
98
|
toast: {
|
|
91
99
|
message: string;
|
|
@@ -132,7 +140,7 @@ export declare const actionLink: {
|
|
|
132
140
|
keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
|
|
133
141
|
};
|
|
134
142
|
export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.edit" | "labels.link.create";
|
|
135
|
-
export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState:
|
|
143
|
+
export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: UIAppState) => [x: number, y: number, width: number, height: number];
|
|
136
144
|
export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
|
|
137
145
|
export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
|
|
138
146
|
export declare const hideHyperlinkToolip: () => void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ExcalidrawLinearElement, ExcalidrawBindableElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawElement } from "./types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
3
|
import Scene from "../scene/Scene";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type SuggestedBinding = NonDeleted<ExcalidrawBindableElement> | SuggestedPointBinding;
|
|
5
|
+
export type SuggestedPointBinding = [
|
|
6
6
|
NonDeleted<ExcalidrawLinearElement>,
|
|
7
7
|
"start" | "end" | "both",
|
|
8
8
|
NonDeleted<ExcalidrawBindableElement>
|
|
9
9
|
];
|
|
10
|
-
export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<
|
|
10
|
+
export declare const shouldEnableBindingForPointerEvent: (event: React.PointerEvent<HTMLElement>) => boolean;
|
|
11
11
|
export declare const isBindingEnabled: (appState: AppState) => boolean;
|
|
12
12
|
export declare const bindOrUnbindLinearElement: (linearElement: NonDeleted<ExcalidrawLinearElement>, startBindingElement: ExcalidrawBindableElement | null | "keep", endBindingElement: ExcalidrawBindableElement | null | "keep") => void;
|
|
13
13
|
export declare const bindOrUnbindSelectedElements: (elements: NonDeleted<ExcalidrawElement>[]) => void;
|
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead, NonDeleted } from "./types";
|
|
2
2
|
import { Drawable, Op } from "roughjs/bin/core";
|
|
3
|
-
|
|
3
|
+
import { Point } from "../types";
|
|
4
|
+
export type RectangleBox = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
angle: number;
|
|
10
|
+
};
|
|
11
|
+
export type Bounds = readonly [x1: number, y1: number, x2: number, y2: number];
|
|
12
|
+
export declare class ElementBounds {
|
|
13
|
+
private static boundsCache;
|
|
14
|
+
static getBounds(element: ExcalidrawElement): Bounds;
|
|
15
|
+
private static calculateBounds;
|
|
16
|
+
}
|
|
4
17
|
export declare const getElementAbsoluteCoords: (element: ExcalidrawElement, includeBoundText?: boolean) => [number, number, number, number, number, number];
|
|
18
|
+
/**
|
|
19
|
+
* for a given element, `getElementLineSegments` returns line segments
|
|
20
|
+
* that can be used for visual collision detection (useful for frames)
|
|
21
|
+
* as opposed to bounding box collision detection
|
|
22
|
+
*/
|
|
23
|
+
export declare const getElementLineSegments: (element: ExcalidrawElement) => [Point, Point][];
|
|
24
|
+
/**
|
|
25
|
+
* Scene -> Scene coords, but in x1,x2,y1,y2 format.
|
|
26
|
+
*
|
|
27
|
+
* Rectangle here means any rectangular frame, not an excalidraw element.
|
|
28
|
+
*/
|
|
29
|
+
export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBox) => number[];
|
|
5
30
|
export declare const pointRelativeTo: (element: ExcalidrawElement, absoluteCoords: readonly [number, number]) => readonly [number, number];
|
|
6
31
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
7
32
|
export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
8
33
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: ((x: number, y: number) => [number, number]) | undefined) => [number, number, number, number];
|
|
9
34
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
10
|
-
export declare const getElementBounds: (element: ExcalidrawElement) =>
|
|
11
|
-
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) =>
|
|
35
|
+
export declare const getElementBounds: (element: ExcalidrawElement) => Bounds;
|
|
36
|
+
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => Bounds;
|
|
12
37
|
export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => [number, number, number, number];
|
|
13
38
|
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => [number, number, number, number];
|
|
14
39
|
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
15
40
|
x: number;
|
|
16
41
|
y: number;
|
|
17
|
-
}) =>
|
|
18
|
-
export interface
|
|
42
|
+
}) => Bounds;
|
|
43
|
+
export interface BoundingBox {
|
|
19
44
|
minX: number;
|
|
20
45
|
minY: number;
|
|
21
46
|
maxX: number;
|
|
@@ -25,4 +50,4 @@ export interface Box {
|
|
|
25
50
|
width: number;
|
|
26
51
|
height: number;
|
|
27
52
|
}
|
|
28
|
-
export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) =>
|
|
53
|
+
export declare const getCommonBoundingBox: (elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[]) => BoundingBox;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as GA from "../ga";
|
|
2
|
-
import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement } from "./types";
|
|
3
|
-
import { Point } from "../types";
|
|
2
|
+
import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameElement } from "./types";
|
|
3
|
+
import { FrameNameBoundsCache, Point } from "../types";
|
|
4
4
|
import { AppState } from "../types";
|
|
5
|
-
export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
|
|
6
|
-
export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
|
|
7
|
-
export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, point: readonly [number, number]) => boolean;
|
|
8
|
-
export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number) => boolean;
|
|
5
|
+
export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
|
|
6
|
+
export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
|
|
7
|
+
export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache | null, point: readonly [number, number]) => boolean;
|
|
8
|
+
export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number, frameNameBoundsCache: FrameNameBoundsCache | null) => boolean;
|
|
9
9
|
export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
@@ -18,4 +18,4 @@ export declare const determineFocusPoint: (element: ExcalidrawBindableElement, f
|
|
|
18
18
|
export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap?: number) => Point[];
|
|
19
19
|
export declare const getCircleIntersections: (center: readonly [number, number, number, number, number, number, number, number], radius: number, line: readonly [number, number, number, number, number, number, number, number]) => GA.Point[];
|
|
20
20
|
export declare const findFocusPointForEllipse: (ellipse: ExcalidrawEllipseElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
21
|
-
export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
21
|
+
export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawFrameElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
2
2
|
import { AppState, PointerDownState } from "../types";
|
|
3
|
-
|
|
3
|
+
import Scene from "../scene/Scene";
|
|
4
|
+
export declare const dragSelectedElements: (pointerDownState: PointerDownState, selectedElements: NonDeletedExcalidrawElement[], pointerX: number, pointerY: number, lockDirection: boolean | undefined, distanceX: number | undefined, distanceY: number | undefined, appState: AppState, scene: Scene) => void;
|
|
4
5
|
export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
5
6
|
export declare const dragNewElement: (draggingElement: NonDeletedExcalidrawElement, elementType: AppState["activeTool"]["type"], originX: number, originY: number, x: number, y: number, width: number, height: number, shouldMaintainAspectRatio: boolean, shouldResizeFromCenter: boolean, widthAspectRatio?: number | null) => void;
|
package/types/element/image.d.ts
CHANGED
|
@@ -10,7 +10,17 @@ export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
|
|
|
10
10
|
}) => Promise<{
|
|
11
11
|
imageCache: Map<FileId, {
|
|
12
12
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
13
|
-
mimeType: "
|
|
13
|
+
mimeType: import("../utility-types").ValueOf<{
|
|
14
|
+
readonly svg: "image/svg+xml";
|
|
15
|
+
readonly png: "image/png";
|
|
16
|
+
readonly jpg: "image/jpeg";
|
|
17
|
+
readonly gif: "image/gif";
|
|
18
|
+
readonly webp: "image/webp";
|
|
19
|
+
readonly bmp: "image/bmp";
|
|
20
|
+
readonly ico: "image/x-icon";
|
|
21
|
+
readonly avif: "image/avif";
|
|
22
|
+
readonly jfif: "image/jfif";
|
|
23
|
+
}>;
|
|
14
24
|
}>;
|
|
15
25
|
/** includes errored files because they cache was updated nonetheless */
|
|
16
26
|
updatedFiles: Map<FileId, true>;
|
package/types/element/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
1
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "./types";
|
|
2
2
|
export { newElement, newTextElement, updateTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
|
|
3
3
|
export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
|
|
4
4
|
export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
|
|
@@ -6,7 +6,7 @@ export { hitTest, isHittingElementBoundingBoxWithoutHittingElement, } from "./co
|
|
|
6
6
|
export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
|
|
7
7
|
export { transformElements, getResizeOffsetXY, getResizeArrowDirection, } from "./resizeElements";
|
|
8
8
|
export { dragSelectedElements, getDragOffsetXY, dragNewElement, } from "./dragElements";
|
|
9
|
-
export { isTextElement, isExcalidrawElement } from "./typeChecks";
|
|
9
|
+
export { isTextElement, isExcalidrawElement, isFrameElement, } from "./typeChecks";
|
|
10
10
|
export { textWysiwyg } from "./textWysiwyg";
|
|
11
11
|
export { redrawTextBoundingBox } from "./textElement";
|
|
12
12
|
export { getPerfectElementSize, getLockedLinearCursorAlignSize, isInvisiblySmallElement, resizePerfectLineForNWHandler, getNormalizedDimensions, } from "./sizeHelpers";
|
|
@@ -14,6 +14,7 @@ export { showSelectedShapeActions } from "./showSelectedShapeActions";
|
|
|
14
14
|
export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) => number;
|
|
15
15
|
export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
16
16
|
export declare const getNonDeletedElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
|
|
17
|
+
export declare const getNonDeletedFrames: (frames: readonly ExcalidrawFrameElement[]) => readonly NonDeleted<ExcalidrawFrameElement>[];
|
|
17
18
|
export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
|
|
18
19
|
export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
19
20
|
export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
@@ -62,7 +62,7 @@ export declare class LinearElementEditor {
|
|
|
62
62
|
static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
|
|
63
63
|
static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number): readonly [number, number];
|
|
64
64
|
static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point): number;
|
|
65
|
-
static handlePointerDown(event: React.PointerEvent<
|
|
65
|
+
static handlePointerDown(event: React.PointerEvent<HTMLElement>, appState: AppState, history: History, scenePointer: {
|
|
66
66
|
x: number;
|
|
67
67
|
y: number;
|
|
68
68
|
}, linearElementEditor: LinearElementEditor): {
|
|
@@ -138,12 +138,16 @@ export declare class LinearElementEditor {
|
|
|
138
138
|
isBindingEnabled: boolean;
|
|
139
139
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
140
140
|
suggestedBindings: import("./binding").SuggestedBinding[];
|
|
141
|
+
frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameElement> | null;
|
|
142
|
+
shouldRenderFrames: boolean;
|
|
143
|
+
editingFrame: string | null;
|
|
144
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
141
145
|
editingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
142
146
|
activeTool: {
|
|
143
147
|
lastActiveTool: import("../types").LastActiveTool;
|
|
144
148
|
locked: boolean;
|
|
145
149
|
} & ({
|
|
146
|
-
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | "hand";
|
|
150
|
+
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
|
|
147
151
|
customType: null;
|
|
148
152
|
} | {
|
|
149
153
|
type: "custom";
|
|
@@ -180,10 +184,13 @@ export declare class LinearElementEditor {
|
|
|
180
184
|
value: import("../types").NormalizedZoomValue;
|
|
181
185
|
}>;
|
|
182
186
|
openMenu: "canvas" | "shape" | null;
|
|
183
|
-
openPopup: "
|
|
184
|
-
openSidebar:
|
|
187
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
188
|
+
openSidebar: {
|
|
189
|
+
name: string;
|
|
190
|
+
tab?: string | undefined;
|
|
191
|
+
} | null;
|
|
185
192
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
186
|
-
|
|
193
|
+
defaultSidebarDockedPreference: boolean;
|
|
187
194
|
lastPointerDownWith: import("./types").PointerType;
|
|
188
195
|
selectedElementIds: {
|
|
189
196
|
[id: string]: boolean;
|
|
@@ -191,6 +198,7 @@ export declare class LinearElementEditor {
|
|
|
191
198
|
previousSelectedElementIds: {
|
|
192
199
|
[id: string]: boolean;
|
|
193
200
|
};
|
|
201
|
+
selectedElementsAreBeingDragged: boolean;
|
|
194
202
|
shouldCacheIgnoreZoom: boolean;
|
|
195
203
|
toast: {
|
|
196
204
|
message: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
2
|
import { Mutable } from "../utility-types";
|
|
3
|
-
|
|
3
|
+
type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce">;
|
|
4
4
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
5
5
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>) => TElement;
|
|
6
6
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer } from "../element/types";
|
|
1
|
+
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
3
|
import { MarkOptional, Mutable } from "../utility-types";
|
|
4
|
-
|
|
4
|
+
type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
|
|
5
5
|
export declare const newElement: (opts: {
|
|
6
6
|
type: ExcalidrawGenericElement["type"];
|
|
7
7
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
|
|
8
|
+
export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
|
|
8
9
|
export declare const newTextElement: (opts: {
|
|
9
10
|
text: string;
|
|
10
11
|
fontSize?: number;
|
|
@@ -14,6 +15,7 @@ export declare const newTextElement: (opts: {
|
|
|
14
15
|
containerId?: ExcalidrawTextContainer["id"];
|
|
15
16
|
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
16
17
|
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
18
|
+
isFrameName?: boolean;
|
|
17
19
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
18
20
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
|
|
19
21
|
x: number;
|
|
@@ -77,6 +79,11 @@ export declare const duplicateElement: <TElement extends ExcalidrawElement>(edit
|
|
|
77
79
|
* it's advised to supply the whole elements array, or sets of elements that
|
|
78
80
|
* are encapsulated (such as library items), if the purpose is to retain
|
|
79
81
|
* bindings to the cloned elements intact.
|
|
82
|
+
*
|
|
83
|
+
* NOTE by default does not randomize or regenerate anything except the id.
|
|
80
84
|
*/
|
|
81
|
-
export declare const duplicateElements: (elements: readonly ExcalidrawElement[]
|
|
85
|
+
export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
|
|
86
|
+
/** NOTE also updates version flags and `updated` */
|
|
87
|
+
randomizeSeed: boolean;
|
|
88
|
+
}) => ExcalidrawElement[];
|
|
82
89
|
export {};
|
|
@@ -4,5 +4,6 @@ import { PointerDownState } from "../types";
|
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
5
5
|
export declare const transformElements: (pointerDownState: PointerDownState, transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], resizeArrowDirection: "origin" | "end", shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
|
|
6
6
|
export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
7
|
+
export declare const resizeMultipleElements: (pointerDownState: PointerDownState, selectedElements: readonly NonDeletedExcalidrawElement[], transformHandleType: "nw" | "ne" | "sw" | "se", shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
7
8
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
8
9
|
export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AppState } from "../types";
|
|
2
1
|
import { NonDeletedExcalidrawElement } from "./types";
|
|
3
|
-
|
|
2
|
+
import { UIAppState } from "../types";
|
|
3
|
+
export declare const showSelectedShapeActions: (appState: UIAppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
@@ -32,6 +32,7 @@ export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSi
|
|
|
32
32
|
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
33
33
|
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
34
34
|
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
35
|
+
export declare const parseTokens: (text: string) => string[];
|
|
35
36
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
36
37
|
export declare const charWidth: {
|
|
37
38
|
calculate: (char: string, font: FontString) => number;
|
|
@@ -70,8 +71,8 @@ export declare const getTextBindableContainerAtPosition: (elements: readonly Exc
|
|
|
70
71
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
71
72
|
export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
|
|
72
73
|
export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
|
|
73
|
-
export declare const
|
|
74
|
-
export declare const
|
|
74
|
+
export declare const getBoundTextMaxWidth: (container: ExcalidrawElement) => number;
|
|
75
|
+
export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
|
|
75
76
|
export declare const isMeasureTextSupported: () => boolean;
|
|
76
77
|
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
77
78
|
_brand: "unitlessLineHeight";
|