@dwelle/excalidraw 0.4.0-d8d86cf → 0.4.0-da7ef3e
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 +706 -0
- package/README.md +18 -1422
- package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js → vendor-d415b28e9024dee4bb1b.js} +2 -2
- package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
- package/dist/excalidraw.development.js +3035 -1464
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
- package/main.js +1 -8
- package/package.json +9 -4
- package/types/actions/actionAddToLibrary.d.ts +130 -52
- package/types/actions/actionAlign.d.ts +25 -32
- package/types/actions/actionBoundText.d.ts +191 -22
- package/types/actions/actionCanvas.d.ts +774 -174
- package/types/actions/actionClipboard.d.ts +232 -88
- package/types/actions/actionDeleteSelected.d.ts +129 -57
- package/types/actions/actionDistribute.d.ts +7 -12
- package/types/actions/actionDuplicateSelection.d.ts +2 -5
- package/types/actions/actionElementLock.d.ts +283 -0
- package/types/actions/actionExport.d.ts +448 -229
- package/types/actions/actionFinalize.d.ts +87 -41
- package/types/actions/actionFlip.d.ts +4 -7
- package/types/actions/actionFrame.d.ts +441 -0
- package/types/actions/actionGroup.d.ts +260 -15
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +46 -20
- package/types/actions/actionMenu.d.ts +136 -65
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +590 -277
- package/types/actions/actionSelectAll.d.ts +127 -2
- package/types/actions/actionStyles.d.ts +44 -19
- package/types/actions/actionToggleGridMode.d.ts +46 -19
- package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +58 -31
- package/types/actions/actionToggleStats.d.ts +45 -19
- package/types/actions/actionToggleViewMode.d.ts +46 -19
- package/types/actions/actionToggleZenMode.d.ts +46 -19
- package/types/actions/actionZindex.d.ts +8 -16
- package/types/actions/index.d.ts +2 -1
- package/types/actions/manager.d.ts +3 -2
- package/types/actions/shortcuts.d.ts +2 -1
- package/types/actions/types.d.ts +16 -13
- package/types/appState.d.ts +23 -18
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +3 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +7 -7
- package/types/components/ActiveConfirmDialog.d.ts +4 -0
- package/types/components/App.d.ts +88 -74
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/Button.d.ts +16 -0
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +6 -0
- package/types/components/ColorPicker/ColorInput.d.ts +9 -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 +20 -0
- package/types/components/ContextMenu.d.ts +9 -22
- package/types/components/DefaultSidebar.d.ts +29 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/ErrorDialog.d.ts +3 -2
- package/types/components/ExcalidrawLogo.d.ts +15 -0
- package/types/components/EyeDropper.d.ts +28 -0
- package/types/components/FilledButton.d.ts +17 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +10 -0
- package/types/components/HelpButton.d.ts +1 -2
- package/types/components/HintViewer.d.ts +4 -5
- 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 +7 -5
- package/types/components/LayerUI.d.ts +10 -16
- 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 +10 -5
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +6 -3
- package/types/components/LoadingMessage.d.ts +0 -1
- package/types/components/LockButton.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +10 -12
- 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/Section.d.ts +1 -1
- 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 +8 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +6 -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 +6 -5
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +9 -0
- package/types/components/UserList.d.ts +0 -2
- package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
- package/types/components/canvases/StaticCanvas.d.ts +18 -0
- package/types/components/canvases/index.d.ts +3 -0
- package/types/components/dropdownMenu/DropdownMenu.d.ts +67 -0
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +15 -0
- package/types/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
- package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -0
- package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +13 -0
- package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +10 -0
- package/types/components/dropdownMenu/common.d.ts +6 -0
- package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/types/components/footer/Footer.d.ts +12 -0
- package/types/components/footer/FooterCenter.d.ts +8 -0
- package/types/components/hoc/withInternalFallback.d.ts +4 -0
- package/types/components/icons.d.ts +15 -2
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +9 -0
- package/types/components/main-menu/DefaultItems.d.ts +47 -0
- package/types/components/main-menu/MainMenu.d.ts +61 -0
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +57 -0
- package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/types/components/welcome-screen/WelcomeScreen.d.ts +84 -0
- package/types/constants.d.ts +94 -18
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +3 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/index.d.ts +1 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +10 -4
- package/types/data/transform.d.ts +71 -0
- package/types/data/types.d.ts +3 -5
- package/types/data/url.d.ts +7 -0
- package/types/element/Hyperlink.d.ts +57 -30
- package/types/element/binding.d.ts +4 -3
- package/types/element/bounds.d.ts +31 -7
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +12 -2
- package/types/element/embeddable.d.ts +159 -0
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +49 -24
- package/types/element/mutateElement.d.ts +2 -1
- package/types/element/newElement.d.ts +48 -15
- package/types/element/resizeElements.d.ts +3 -2
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/sizeHelpers.d.ts +8 -1
- package/types/element/sortElements.d.ts +2 -0
- package/types/element/textElement.d.ts +44 -11
- package/types/element/textWysiwyg.d.ts +7 -2
- package/types/element/transformHandles.d.ts +15 -8
- package/types/element/typeChecks.d.ts +13 -2
- package/types/element/types.d.ts +64 -36
- 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 +15 -11
- package/types/history.d.ts +3 -3
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -2
- package/types/hooks/useScrollPosition.d.ts +1 -0
- package/types/hooks/useStable.d.ts +1 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +11 -2
- package/types/jotai.d.ts +20 -108
- package/types/keys.d.ts +7 -4
- package/types/math.d.ts +6 -1
- package/types/packages/excalidraw/example/App.d.ts +7 -1
- package/types/packages/excalidraw/example/CustomFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/MobileFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/initialData.d.ts +182 -64
- package/types/packages/excalidraw/index.d.ts +19 -3
- package/types/packages/excalidraw/main.d.ts +3 -1
- package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
- package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
- package/types/packages/utils.d.ts +28 -24
- package/types/renderer/renderElement.d.ts +12 -22
- package/types/renderer/renderScene.d.ts +19 -29
- package/types/renderer/renderSnaps.d.ts +2 -0
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Renderer.d.ts +25 -0
- package/types/scene/Scene.d.ts +27 -5
- package/types/scene/Shape.d.ts +12 -0
- package/types/scene/ShapeCache.d.ts +20 -0
- package/types/scene/comparisons.d.ts +1 -1
- package/types/scene/export.d.ts +182 -10
- package/types/scene/index.d.ts +1 -1
- package/types/scene/scroll.d.ts +1 -1
- package/types/scene/scrollbars.d.ts +2 -6
- package/types/scene/selection.d.ts +27 -6
- package/types/scene/types.d.ts +69 -26
- package/types/snapping.d.ts +108 -0
- package/types/types.d.ts +196 -81
- package/types/utility-types.d.ts +24 -0
- package/types/utils.d.ts +78 -12
- package/types/zindex.d.ts +4 -4
- package/types/components/ActiveFile.d.ts +0 -7
- package/types/components/ClearCanvas.d.ts +0 -4
- package/types/components/CollabButton.d.ts +0 -6
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/Footer.d.ts +0 -10
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/MenuItem.d.ts +0 -11
- package/types/components/MenuUtils.d.ts +0 -1
- package/types/components/SingleLibraryItem.d.ts +0 -10
- package/types/components/WelcomeScreen.d.ts +0 -10
- package/types/components/WelcomeScreenDecor.d.ts +0 -6
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
- /package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js.LICENSE.txt → vendor-d415b28e9024dee4bb1b.js.LICENSE.txt} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.d.ts → vendor-d415b28e9024dee4bb1b.d.ts} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme } from "./element/types";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
|
|
3
3
|
import { SHAPES } from "./shapes";
|
|
4
4
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
5
5
|
import { LinearElementEditor } from "./element/linearElementEditor";
|
|
@@ -14,9 +14,12 @@ import { isOverScrollBars } from "./scene";
|
|
|
14
14
|
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
15
15
|
import Library from "./data/library";
|
|
16
16
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
|
-
import type {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
|
+
import { ContextMenuItems } from "./components/ContextMenu";
|
|
19
|
+
import { SnapLine } from "./snapping";
|
|
20
|
+
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
|
21
|
+
export type Point = Readonly<RoughPoint>;
|
|
22
|
+
export type Collaborator = {
|
|
20
23
|
pointer?: {
|
|
21
24
|
x: number;
|
|
22
25
|
y: number;
|
|
@@ -32,11 +35,11 @@ export declare type Collaborator = {
|
|
|
32
35
|
avatarUrl?: string;
|
|
33
36
|
id?: string;
|
|
34
37
|
};
|
|
35
|
-
export
|
|
38
|
+
export type DataURL = string & {
|
|
36
39
|
_brand: "DataURL";
|
|
37
40
|
};
|
|
38
|
-
export
|
|
39
|
-
mimeType: typeof
|
|
41
|
+
export type BinaryFileData = {
|
|
42
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
40
43
|
id: FileId;
|
|
41
44
|
dataURL: DataURL;
|
|
42
45
|
/**
|
|
@@ -52,19 +55,69 @@ export declare type BinaryFileData = {
|
|
|
52
55
|
*/
|
|
53
56
|
lastRetrieved?: number;
|
|
54
57
|
};
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
type: typeof SHAPES[number]["value"] | "eraser";
|
|
58
|
+
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
59
|
+
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
60
|
+
export type LastActiveTool = {
|
|
61
|
+
type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
|
|
59
62
|
customType: null;
|
|
60
63
|
} | {
|
|
61
64
|
type: "custom";
|
|
62
65
|
customType: string;
|
|
63
66
|
} | null;
|
|
64
|
-
export
|
|
67
|
+
export type SidebarName = string;
|
|
68
|
+
export type SidebarTabName = string;
|
|
69
|
+
type _CommonCanvasAppState = {
|
|
70
|
+
zoom: AppState["zoom"];
|
|
71
|
+
scrollX: AppState["scrollX"];
|
|
72
|
+
scrollY: AppState["scrollY"];
|
|
73
|
+
width: AppState["width"];
|
|
74
|
+
height: AppState["height"];
|
|
75
|
+
viewModeEnabled: AppState["viewModeEnabled"];
|
|
76
|
+
editingGroupId: AppState["editingGroupId"];
|
|
77
|
+
selectedElementIds: AppState["selectedElementIds"];
|
|
78
|
+
frameToHighlight: AppState["frameToHighlight"];
|
|
79
|
+
offsetLeft: AppState["offsetLeft"];
|
|
80
|
+
offsetTop: AppState["offsetTop"];
|
|
81
|
+
theme: AppState["theme"];
|
|
82
|
+
pendingImageElementId: AppState["pendingImageElementId"];
|
|
83
|
+
};
|
|
84
|
+
export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
85
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
86
|
+
exportScale: AppState["exportScale"];
|
|
87
|
+
selectedElementsAreBeingDragged: AppState["selectedElementsAreBeingDragged"];
|
|
88
|
+
gridSize: AppState["gridSize"];
|
|
89
|
+
frameRendering: AppState["frameRendering"];
|
|
90
|
+
}>;
|
|
91
|
+
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
92
|
+
activeEmbeddable: AppState["activeEmbeddable"];
|
|
93
|
+
editingLinearElement: AppState["editingLinearElement"];
|
|
94
|
+
selectionElement: AppState["selectionElement"];
|
|
95
|
+
selectedGroupIds: AppState["selectedGroupIds"];
|
|
96
|
+
selectedLinearElement: AppState["selectedLinearElement"];
|
|
97
|
+
multiElement: AppState["multiElement"];
|
|
98
|
+
isBindingEnabled: AppState["isBindingEnabled"];
|
|
99
|
+
suggestedBindings: AppState["suggestedBindings"];
|
|
100
|
+
isRotating: AppState["isRotating"];
|
|
101
|
+
elementsToHighlight: AppState["elementsToHighlight"];
|
|
102
|
+
openSidebar: AppState["openSidebar"];
|
|
103
|
+
showHyperlinkPopup: AppState["showHyperlinkPopup"];
|
|
104
|
+
collaborators: AppState["collaborators"];
|
|
105
|
+
snapLines: AppState["snapLines"];
|
|
106
|
+
zenModeEnabled: AppState["zenModeEnabled"];
|
|
107
|
+
}>;
|
|
108
|
+
export type AppState = {
|
|
109
|
+
contextMenu: {
|
|
110
|
+
items: ContextMenuItems;
|
|
111
|
+
top: number;
|
|
112
|
+
left: number;
|
|
113
|
+
} | null;
|
|
65
114
|
showWelcomeScreen: boolean;
|
|
66
115
|
isLoading: boolean;
|
|
67
|
-
errorMessage:
|
|
116
|
+
errorMessage: React.ReactNode;
|
|
117
|
+
activeEmbeddable: {
|
|
118
|
+
element: NonDeletedExcalidrawElement;
|
|
119
|
+
state: "hover" | "active";
|
|
120
|
+
} | null;
|
|
68
121
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
69
122
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
70
123
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -72,19 +125,31 @@ export declare type AppState = {
|
|
|
72
125
|
isBindingEnabled: boolean;
|
|
73
126
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
74
127
|
suggestedBindings: SuggestedBinding[];
|
|
128
|
+
frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
|
|
129
|
+
frameRendering: {
|
|
130
|
+
enabled: boolean;
|
|
131
|
+
name: boolean;
|
|
132
|
+
outline: boolean;
|
|
133
|
+
clip: boolean;
|
|
134
|
+
};
|
|
135
|
+
editingFrame: string | null;
|
|
136
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
75
137
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
76
138
|
editingLinearElement: LinearElementEditor | null;
|
|
77
139
|
activeTool: {
|
|
78
|
-
|
|
79
|
-
|
|
140
|
+
/**
|
|
141
|
+
* indicates a previous tool we should revert back to if we deselect the
|
|
142
|
+
* currently active tool. At the moment applies to `eraser` and `hand` tool.
|
|
143
|
+
*/
|
|
144
|
+
lastActiveTool: LastActiveTool;
|
|
80
145
|
locked: boolean;
|
|
146
|
+
} & ({
|
|
147
|
+
type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
|
|
81
148
|
customType: null;
|
|
82
149
|
} | {
|
|
83
150
|
type: "custom";
|
|
84
151
|
customType: string;
|
|
85
|
-
|
|
86
|
-
locked: boolean;
|
|
87
|
-
};
|
|
152
|
+
});
|
|
88
153
|
penMode: boolean;
|
|
89
154
|
penDetected: boolean;
|
|
90
155
|
exportBackground: boolean;
|
|
@@ -101,10 +166,9 @@ export declare type AppState = {
|
|
|
101
166
|
currentItemFontFamily: FontFamilyValues;
|
|
102
167
|
currentItemFontSize: number;
|
|
103
168
|
currentItemTextAlign: TextAlign;
|
|
104
|
-
currentItemStrokeSharpness: ExcalidrawElement["strokeSharpness"];
|
|
105
169
|
currentItemStartArrowhead: Arrowhead | null;
|
|
106
170
|
currentItemEndArrowhead: Arrowhead | null;
|
|
107
|
-
|
|
171
|
+
currentItemRoundness: StrokeRoundness;
|
|
108
172
|
viewBackgroundColor: string;
|
|
109
173
|
scrollX: number;
|
|
110
174
|
scrollY: number;
|
|
@@ -115,17 +179,28 @@ export declare type AppState = {
|
|
|
115
179
|
isRotating: boolean;
|
|
116
180
|
zoom: Zoom;
|
|
117
181
|
openMenu: "canvas" | "shape" | null;
|
|
118
|
-
openPopup: "
|
|
119
|
-
openSidebar:
|
|
120
|
-
|
|
121
|
-
|
|
182
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
183
|
+
openSidebar: {
|
|
184
|
+
name: SidebarName;
|
|
185
|
+
tab?: SidebarTabName;
|
|
186
|
+
} | null;
|
|
187
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
188
|
+
/**
|
|
189
|
+
* Reflects user preference for whether the default sidebar should be docked.
|
|
190
|
+
*
|
|
191
|
+
* NOTE this is only a user preference and does not reflect the actual docked
|
|
192
|
+
* state of the sidebar, because the host apps can override this through
|
|
193
|
+
* a DefaultSidebar prop, which is not reflected back to the appState.
|
|
194
|
+
*/
|
|
195
|
+
defaultSidebarDockedPreference: boolean;
|
|
122
196
|
lastPointerDownWith: PointerType;
|
|
123
|
-
selectedElementIds: {
|
|
124
|
-
[id: string]:
|
|
125
|
-
}
|
|
197
|
+
selectedElementIds: Readonly<{
|
|
198
|
+
[id: string]: true;
|
|
199
|
+
}>;
|
|
126
200
|
previousSelectedElementIds: {
|
|
127
|
-
[id: string]:
|
|
201
|
+
[id: string]: true;
|
|
128
202
|
};
|
|
203
|
+
selectedElementsAreBeingDragged: boolean;
|
|
129
204
|
shouldCacheIgnoreZoom: boolean;
|
|
130
205
|
toast: {
|
|
131
206
|
message: string;
|
|
@@ -162,18 +237,25 @@ export declare type AppState = {
|
|
|
162
237
|
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
163
238
|
showHyperlinkPopup: false | "info" | "editor";
|
|
164
239
|
selectedLinearElement: LinearElementEditor | null;
|
|
240
|
+
snapLines: SnapLine[];
|
|
241
|
+
originSnapOffset: {
|
|
242
|
+
x: number;
|
|
243
|
+
y: number;
|
|
244
|
+
} | null;
|
|
245
|
+
objectsSnapModeEnabled: boolean;
|
|
165
246
|
};
|
|
166
|
-
export
|
|
247
|
+
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
248
|
+
export type NormalizedZoomValue = number & {
|
|
167
249
|
_brand: "normalizedZoom";
|
|
168
250
|
};
|
|
169
|
-
export
|
|
251
|
+
export type Zoom = Readonly<{
|
|
170
252
|
value: NormalizedZoomValue;
|
|
171
253
|
}>;
|
|
172
|
-
export
|
|
254
|
+
export type PointerCoords = Readonly<{
|
|
173
255
|
x: number;
|
|
174
256
|
y: number;
|
|
175
257
|
}>;
|
|
176
|
-
export
|
|
258
|
+
export type Gesture = {
|
|
177
259
|
pointers: Map<number, PointerCoords>;
|
|
178
260
|
lastCenter: {
|
|
179
261
|
x: number;
|
|
@@ -187,11 +269,11 @@ export declare class GestureEvent extends UIEvent {
|
|
|
187
269
|
readonly scale: number;
|
|
188
270
|
}
|
|
189
271
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
190
|
-
export
|
|
272
|
+
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
191
273
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
192
|
-
|
|
274
|
+
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
193
275
|
/** v2 library item */
|
|
194
|
-
export
|
|
276
|
+
export type LibraryItem = {
|
|
195
277
|
id: string;
|
|
196
278
|
status: "published" | "unpublished";
|
|
197
279
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
@@ -200,14 +282,14 @@ export declare type LibraryItem = {
|
|
|
200
282
|
name?: string;
|
|
201
283
|
error?: string;
|
|
202
284
|
};
|
|
203
|
-
export
|
|
204
|
-
export
|
|
205
|
-
export
|
|
206
|
-
export
|
|
285
|
+
export type LibraryItems = readonly LibraryItem[];
|
|
286
|
+
export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
|
287
|
+
export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
|
|
288
|
+
export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
|
|
207
289
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
208
290
|
ready?: false;
|
|
209
291
|
};
|
|
210
|
-
export
|
|
292
|
+
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
211
293
|
scrollX?: number;
|
|
212
294
|
scrollY?: number;
|
|
213
295
|
libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
|
|
@@ -216,13 +298,11 @@ export interface ExcalidrawProps {
|
|
|
216
298
|
id?: string | null;
|
|
217
299
|
onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, id?: string | null) => void;
|
|
218
300
|
initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
|
|
219
|
-
onHomeButtonClick
|
|
220
|
-
onThemeToggle: (theme: Theme) => void;
|
|
301
|
+
onHomeButtonClick?: () => void;
|
|
221
302
|
user?: {
|
|
222
303
|
name?: string | null;
|
|
223
304
|
};
|
|
224
305
|
excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
|
|
225
|
-
onCollabButtonClick?: () => void;
|
|
226
306
|
isCollaborating?: boolean;
|
|
227
307
|
onPointerUpdate?: (payload: {
|
|
228
308
|
pointer: {
|
|
@@ -233,20 +313,17 @@ export interface ExcalidrawProps {
|
|
|
233
313
|
pointersMap: Gesture["pointers"];
|
|
234
314
|
}) => void;
|
|
235
315
|
onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
|
|
236
|
-
renderTopRightUI?: (isMobile: boolean, appState:
|
|
237
|
-
renderFooter?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
316
|
+
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
238
317
|
langCode?: Language["code"];
|
|
239
318
|
viewModeEnabled?: boolean;
|
|
240
319
|
zenModeEnabled?: boolean;
|
|
241
320
|
gridModeEnabled?: boolean;
|
|
321
|
+
objectsSnapModeEnabled?: boolean;
|
|
242
322
|
libraryReturnUrl?: string;
|
|
243
323
|
theme?: Theme;
|
|
244
324
|
name?: string;
|
|
245
|
-
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState:
|
|
246
|
-
UIOptions?:
|
|
247
|
-
dockedSidebarBreakpoint?: number;
|
|
248
|
-
canvasActions?: CanvasActions;
|
|
249
|
-
};
|
|
325
|
+
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
326
|
+
UIOptions?: Partial<UIOptions>;
|
|
250
327
|
detectScroll?: boolean;
|
|
251
328
|
handleKeyboardGlobally?: boolean;
|
|
252
329
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -257,12 +334,11 @@ export interface ExcalidrawProps {
|
|
|
257
334
|
}>) => void;
|
|
258
335
|
onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
|
|
259
336
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
renderSidebar?: () => JSX.Element | null;
|
|
337
|
+
children?: React.ReactNode;
|
|
338
|
+
validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
|
|
339
|
+
renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
|
|
264
340
|
}
|
|
265
|
-
export
|
|
341
|
+
export type SceneData = {
|
|
266
342
|
elements?: ImportedDataState["elements"];
|
|
267
343
|
appState?: ImportedDataState["appState"];
|
|
268
344
|
collaborators?: Map<string, Collaborator>;
|
|
@@ -273,27 +349,32 @@ export declare enum UserIdleState {
|
|
|
273
349
|
AWAY = "away",
|
|
274
350
|
IDLE = "idle"
|
|
275
351
|
}
|
|
276
|
-
export
|
|
352
|
+
export type ExportOpts = {
|
|
277
353
|
saveFileToDisk?: boolean;
|
|
278
|
-
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
279
|
-
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
354
|
+
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
|
|
355
|
+
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
280
356
|
};
|
|
281
|
-
|
|
282
|
-
changeViewBackgroundColor
|
|
283
|
-
clearCanvas
|
|
284
|
-
export
|
|
285
|
-
loadScene
|
|
286
|
-
saveToActiveFile
|
|
287
|
-
toggleTheme
|
|
288
|
-
saveAsImage
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
357
|
+
type CanvasActions = Partial<{
|
|
358
|
+
changeViewBackgroundColor: boolean;
|
|
359
|
+
clearCanvas: boolean;
|
|
360
|
+
export: false | ExportOpts;
|
|
361
|
+
loadScene: boolean;
|
|
362
|
+
saveToActiveFile: boolean;
|
|
363
|
+
toggleTheme: boolean | null;
|
|
364
|
+
saveAsImage: boolean;
|
|
365
|
+
}>;
|
|
366
|
+
type UIOptions = Partial<{
|
|
367
|
+
dockedSidebarBreakpoint: number;
|
|
368
|
+
canvasActions: CanvasActions;
|
|
369
|
+
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
370
|
+
welcomeScreen?: boolean;
|
|
371
|
+
}>;
|
|
372
|
+
export type AppProps = Merge<ExcalidrawProps, {
|
|
373
|
+
UIOptions: Merge<UIOptions, {
|
|
292
374
|
canvasActions: Required<CanvasActions> & {
|
|
293
375
|
export: ExportOpts;
|
|
294
376
|
};
|
|
295
|
-
|
|
296
|
-
};
|
|
377
|
+
}>;
|
|
297
378
|
detectScroll: boolean;
|
|
298
379
|
handleKeyboardGlobally: boolean;
|
|
299
380
|
isCollaborating: boolean;
|
|
@@ -301,20 +382,27 @@ export declare type AppProps = Merge<ExcalidrawProps, {
|
|
|
301
382
|
}>;
|
|
302
383
|
/** A subset of App class properties that we need to use elsewhere
|
|
303
384
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
304
|
-
export
|
|
385
|
+
export type AppClassProperties = {
|
|
305
386
|
props: AppProps;
|
|
306
|
-
|
|
387
|
+
interactiveCanvas: HTMLCanvasElement | null;
|
|
388
|
+
/** static canvas */
|
|
389
|
+
canvas: HTMLCanvasElement;
|
|
307
390
|
focusContainer(): void;
|
|
308
391
|
library: Library;
|
|
309
392
|
imageCache: Map<FileId, {
|
|
310
393
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
311
|
-
mimeType: typeof
|
|
394
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
312
395
|
}>;
|
|
313
396
|
files: BinaryFiles;
|
|
314
397
|
device: App["device"];
|
|
315
398
|
scene: App["scene"];
|
|
399
|
+
pasteFromClipboard: App["pasteFromClipboard"];
|
|
400
|
+
id: App["id"];
|
|
401
|
+
onInsertElements: App["onInsertElements"];
|
|
402
|
+
onExportImage: App["onExportImage"];
|
|
403
|
+
lastViewportPosition: App["lastViewportPosition"];
|
|
316
404
|
};
|
|
317
|
-
export
|
|
405
|
+
export type PointerDownState = Readonly<{
|
|
318
406
|
origin: Readonly<{
|
|
319
407
|
x: number;
|
|
320
408
|
y: number;
|
|
@@ -373,8 +461,8 @@ export declare type PointerDownState = Readonly<{
|
|
|
373
461
|
};
|
|
374
462
|
};
|
|
375
463
|
}>;
|
|
376
|
-
|
|
377
|
-
export
|
|
464
|
+
type UnsubscribeCallback = () => void;
|
|
465
|
+
export type ExcalidrawImperativeAPI = {
|
|
378
466
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
379
467
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
380
468
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
@@ -395,16 +483,43 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
395
483
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
396
484
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
397
485
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
398
|
-
|
|
486
|
+
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
487
|
+
/**
|
|
488
|
+
* Disables rendering of frames (including element clipping), but currently
|
|
489
|
+
* the frames are still interactive in edit mode. As such, this API should be
|
|
490
|
+
* used in conjunction with view mode (props.viewModeEnabled).
|
|
491
|
+
*/
|
|
492
|
+
updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
|
|
399
493
|
app: InstanceType<typeof App>;
|
|
400
494
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
401
|
-
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<
|
|
495
|
+
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
402
496
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
403
497
|
};
|
|
404
|
-
export
|
|
498
|
+
export type Device = Readonly<{
|
|
405
499
|
isSmScreen: boolean;
|
|
406
500
|
isMobile: boolean;
|
|
407
501
|
isTouchScreen: boolean;
|
|
408
502
|
canDeviceFitSidebar: boolean;
|
|
503
|
+
isLandscape: boolean;
|
|
409
504
|
}>;
|
|
505
|
+
type FrameNameBounds = {
|
|
506
|
+
x: number;
|
|
507
|
+
y: number;
|
|
508
|
+
width: number;
|
|
509
|
+
height: number;
|
|
510
|
+
angle: number;
|
|
511
|
+
};
|
|
512
|
+
export type FrameNameBoundsCache = {
|
|
513
|
+
get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
|
|
514
|
+
_cache: Map<string, FrameNameBounds & {
|
|
515
|
+
zoom: AppState["zoom"]["value"];
|
|
516
|
+
versionNonce: ExcalidrawFrameElement["versionNonce"];
|
|
517
|
+
}>;
|
|
518
|
+
};
|
|
519
|
+
export type KeyboardModifiersObject = {
|
|
520
|
+
ctrlKey: boolean;
|
|
521
|
+
shiftKey: boolean;
|
|
522
|
+
altKey: boolean;
|
|
523
|
+
metaKey: boolean;
|
|
524
|
+
};
|
|
410
525
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type Mutable<T> = {
|
|
2
|
+
-readonly [P in keyof T]: T[P];
|
|
3
|
+
};
|
|
4
|
+
export type ValueOf<T> = T[keyof T];
|
|
5
|
+
export type Merge<M, N> = Omit<M, keyof N> & N;
|
|
6
|
+
/** utility type to assert that the second type is a subtype of the first type.
|
|
7
|
+
* Returns the subtype. */
|
|
8
|
+
export type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
|
|
9
|
+
export type ResolutionType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
10
|
+
export type MarkOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
11
|
+
export type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
|
|
12
|
+
export type MarkNonNullable<T, K extends keyof T> = {
|
|
13
|
+
[P in K]-?: P extends K ? NonNullable<T[P]> : T[P];
|
|
14
|
+
} & {
|
|
15
|
+
[P in keyof T]: T[P];
|
|
16
|
+
};
|
|
17
|
+
export type NonOptional<T> = Exclude<T, undefined>;
|
|
18
|
+
export type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
|
|
19
|
+
export type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
|
|
20
|
+
export type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
|
|
21
|
+
export type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
|
|
22
|
+
export type SameType<T, U> = T extends U ? (U extends T ? true : false) : false;
|
|
23
|
+
export type Assert<T extends true> = T;
|
|
24
|
+
export type NestedKeyOf<T, K = keyof T> = K extends keyof T & (string | number) ? `${K}` | (T[K] extends object ? `${K}.${NestedKeyOf<T[K]>}` : never) : never;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { EVENT } from "./constants";
|
|
2
|
-
import { FontFamilyValues, FontString } from "./element/types";
|
|
3
|
-
import { AppState,
|
|
2
|
+
import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
|
|
3
|
+
import { AppState, LastActiveTool, Zoom } from "./types";
|
|
4
4
|
import { SHAPES } from "./shapes";
|
|
5
5
|
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
|
|
9
|
+
export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
|
|
10
|
+
export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
|
|
11
|
+
export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
|
|
11
12
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
12
13
|
fontFamily: FontFamilyValues;
|
|
13
14
|
}) => string;
|
|
@@ -28,22 +29,71 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
28
29
|
flush(): void;
|
|
29
30
|
cancel(): void;
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Exponential ease-out method
|
|
34
|
+
*
|
|
35
|
+
* @param {number} k - The value to be tweened.
|
|
36
|
+
* @returns {number} The tweened value.
|
|
37
|
+
*/
|
|
38
|
+
export declare const easeOut: (k: number) => number;
|
|
39
|
+
/**
|
|
40
|
+
* Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.
|
|
41
|
+
* Executes the `onStep` callback on each step with the interpolated values.
|
|
42
|
+
* Returns a function that can be called to cancel the animation.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Example usage:
|
|
46
|
+
* const fromValues = { x: 0, y: 0 };
|
|
47
|
+
* const toValues = { x: 100, y: 200 };
|
|
48
|
+
* const onStep = ({x, y}) => {
|
|
49
|
+
* setState(x, y)
|
|
50
|
+
* };
|
|
51
|
+
* const onCancel = () => {
|
|
52
|
+
* console.log("Animation canceled");
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* const cancelAnimation = easeToValuesRAF({
|
|
56
|
+
* fromValues,
|
|
57
|
+
* toValues,
|
|
58
|
+
* onStep,
|
|
59
|
+
* onCancel,
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // To cancel the animation:
|
|
63
|
+
* cancelAnimation();
|
|
64
|
+
*/
|
|
65
|
+
export declare const easeToValuesRAF: <T extends Record<keyof T, number>, K extends keyof T>({ fromValues, toValues, onStep, duration, interpolateValue, onStart, onEnd, onCancel, }: {
|
|
66
|
+
fromValues: T;
|
|
67
|
+
toValues: T;
|
|
68
|
+
/**
|
|
69
|
+
* Interpolate a single value.
|
|
70
|
+
* Return undefined to be handled by the default interpolator.
|
|
71
|
+
*/
|
|
72
|
+
interpolateValue?: ((fromValue: number, toValue: number, progress: number, key: K) => number | undefined) | undefined;
|
|
73
|
+
onStep: (values: T) => void;
|
|
74
|
+
duration?: number | undefined;
|
|
75
|
+
onStart?: (() => void) | undefined;
|
|
76
|
+
onEnd?: (() => void) | undefined;
|
|
77
|
+
onCancel?: (() => void) | undefined;
|
|
78
|
+
}) => () => void;
|
|
31
79
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
32
80
|
export declare const selectNode: (node: Element) => void;
|
|
33
81
|
export declare const removeSelection: () => void;
|
|
34
82
|
export declare const distance: (x: number, y: number) => number;
|
|
35
83
|
export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
|
|
36
|
-
type: (typeof SHAPES)[number]["value"] | "eraser";
|
|
84
|
+
type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
|
|
85
|
+
locked?: boolean;
|
|
37
86
|
} | {
|
|
38
87
|
type: "custom";
|
|
39
88
|
customType: string;
|
|
89
|
+
locked?: boolean;
|
|
40
90
|
}) & {
|
|
41
|
-
lastActiveToolBeforeEraser?:
|
|
91
|
+
lastActiveToolBeforeEraser?: LastActiveTool;
|
|
42
92
|
}) => AppState["activeTool"];
|
|
43
|
-
export declare const resetCursor: (
|
|
44
|
-
export declare const setCursor: (
|
|
45
|
-
export declare const setEraserCursor: (
|
|
46
|
-
export declare const setCursorForShape: (
|
|
93
|
+
export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
|
|
94
|
+
export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;
|
|
95
|
+
export declare const setEraserCursor: (interactiveCanvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
|
|
96
|
+
export declare const setCursorForShape: (interactiveCanvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
|
|
47
97
|
export declare const isFullScreen: () => boolean;
|
|
48
98
|
export declare const allowFullScreen: () => Promise<void>;
|
|
49
99
|
export declare const exitFullScreen: () => Promise<void>;
|
|
@@ -91,7 +141,7 @@ export declare const muteFSAbortError: (error?: Error) => void;
|
|
|
91
141
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
92
142
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
93
143
|
export declare const isTransparent: (color: string) => boolean;
|
|
94
|
-
export
|
|
144
|
+
export type ResolvablePromise<T> = Promise<T> & {
|
|
95
145
|
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
|
96
146
|
reject: (error: Error) => void;
|
|
97
147
|
};
|
|
@@ -124,13 +174,29 @@ export declare const getUpdatedTimestamp: () => number;
|
|
|
124
174
|
export declare const arrayToMap: <T extends string | {
|
|
125
175
|
id: string;
|
|
126
176
|
}>(items: readonly T[]) => Map<string, T>;
|
|
177
|
+
export declare const arrayToMapWithIndex: <T extends {
|
|
178
|
+
id: string;
|
|
179
|
+
}>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
|
|
127
180
|
export declare const isTestEnv: () => boolean;
|
|
128
|
-
export declare const isProdEnv: () => boolean;
|
|
129
181
|
export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
|
|
130
182
|
nativeEvent: T;
|
|
131
183
|
}>;
|
|
132
184
|
export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
|
|
133
185
|
export declare const isPrimitive: (val: any) => boolean;
|
|
134
186
|
export declare const getFrame: () => "top" | "iframe";
|
|
187
|
+
export declare const isRunningInIframe: () => boolean;
|
|
135
188
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
136
189
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
190
|
+
export declare const isShallowEqual: <T extends Record<string, any>, I extends keyof T>(objA: T, objB: T, comparators?: Record<I, (a: T[I], b: T[I]) => boolean> | undefined, debug?: boolean) => boolean;
|
|
191
|
+
export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
|
|
192
|
+
checkForDefaultPrevented?: boolean | undefined;
|
|
193
|
+
}) => (event: E) => void;
|
|
194
|
+
export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
195
|
+
export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
|
|
196
|
+
/**
|
|
197
|
+
* Memoizes on values of `opts` object (strict equality).
|
|
198
|
+
*/
|
|
199
|
+
export declare const memoize: <T extends Record<string, any>, R extends unknown>(func: (opts: T) => R) => ((opts: T) => R) & {
|
|
200
|
+
clear: () => void;
|
|
201
|
+
};
|
|
202
|
+
export declare const isRenderThrottlingEnabled: () => boolean;
|
package/types/zindex.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./element/types";
|
|
2
2
|
import { AppState } from "./types";
|
|
3
|
-
export declare const moveOneLeft: (elements: readonly ExcalidrawElement[], appState: AppState
|
|
4
|
-
export declare const moveOneRight: (elements: readonly ExcalidrawElement[], appState: AppState
|
|
5
|
-
export declare const moveAllLeft: (elements: readonly ExcalidrawElement[], appState: AppState
|
|
6
|
-
export declare const moveAllRight: (elements: readonly ExcalidrawElement[], appState: AppState
|
|
3
|
+
export declare const moveOneLeft: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
4
|
+
export declare const moveOneRight: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
5
|
+
export declare const moveAllLeft: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|
|
6
|
+
export declare const moveAllRight: (elements: readonly ExcalidrawElement[], appState: AppState, elementsToBeMoved?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
|