@dwelle/excalidraw 0.4.0-e3bee83 → 0.4.0-e587816
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 +525 -0
- package/README.md +18 -1820
- 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 +3071 -1566
- 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 +103 -55
- package/types/actions/actionAlign.d.ts +33 -28
- package/types/actions/actionBoundText.d.ts +175 -22
- package/types/actions/actionCanvas.d.ts +680 -170
- package/types/actions/actionClipboard.d.ts +174 -100
- package/types/actions/actionDeleteSelected.d.ts +102 -60
- package/types/actions/actionDistribute.d.ts +11 -12
- package/types/actions/actionDuplicateSelection.d.ts +3 -4
- package/types/actions/actionElementLock.d.ts +271 -0
- package/types/actions/actionExport.d.ts +363 -221
- package/types/actions/actionFinalize.d.ts +70 -42
- package/types/actions/actionFlip.d.ts +8 -11
- package/types/actions/actionFrame.d.ts +423 -0
- package/types/actions/actionGroup.d.ts +250 -13
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +37 -21
- package/types/actions/actionMenu.d.ts +108 -62
- package/types/actions/actionNavigate.d.ts +1 -1
- package/types/actions/actionProperties.d.ts +465 -256
- package/types/actions/actionSelectAll.d.ts +123 -4
- package/types/actions/actionStyles.d.ts +39 -24
- package/types/actions/actionToggleGridMode.d.ts +37 -22
- package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +49 -32
- package/types/actions/actionToggleStats.d.ts +37 -22
- package/types/actions/actionToggleViewMode.d.ts +37 -22
- package/types/actions/actionToggleZenMode.d.ts +37 -22
- package/types/actions/actionZindex.d.ts +12 -12
- package/types/actions/index.d.ts +2 -1
- package/types/actions/manager.d.ts +1 -1
- package/types/actions/shortcuts.d.ts +2 -1
- package/types/actions/types.d.ts +11 -9
- package/types/appState.d.ts +18 -18
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +8 -7
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +7 -12
- package/types/components/ActiveConfirmDialog.d.ts +4 -0
- package/types/components/App.d.ts +93 -35
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/BraveMeasureTextError.d.ts +2 -0
- package/types/components/Button.d.ts +3 -2
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +0 -1
- 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 +3 -3
- 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 +5 -5
- package/types/components/LaserTool/LaserPathManager.d.ts +28 -0
- package/types/components/LaserTool/LaserPointerButton.d.ts +10 -0
- package/types/components/LaserTool/LaserTool.d.ts +7 -0
- package/types/components/LayerUI.d.ts +9 -15
- 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 -28
- 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 +8 -11
- 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/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 +15 -9
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +7 -3
- package/types/components/dropdownMenu/DropdownMenuItem.d.ts +4 -4
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -1
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +4 -2
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -2
- package/types/components/dropdownMenu/common.d.ts +6 -0
- package/types/components/footer/Footer.d.ts +4 -5
- package/types/components/hoc/withInternalFallback.d.ts +4 -0
- package/types/components/icons.d.ts +16 -1
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
- package/types/components/main-menu/MainMenu.d.ts +22 -13
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
- package/types/components/welcome-screen/WelcomeScreen.d.ts +2 -3
- package/types/constants.d.ts +94 -10
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/cursor.d.ts +5 -0
- package/types/data/blob.d.ts +5 -3
- 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 +10 -4
- package/types/data/transform.d.ts +73 -0
- package/types/data/types.d.ts +3 -5
- package/types/data/url.d.ts +7 -0
- package/types/element/Hyperlink.d.ts +48 -29
- package/types/element/binding.d.ts +4 -3
- package/types/element/bounds.d.ts +40 -10
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +12 -2
- package/types/element/embeddable.d.ts +153 -0
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +43 -27
- package/types/element/mutateElement.d.ts +3 -2
- package/types/element/newElement.d.ts +48 -15
- package/types/element/resizeElements.d.ts +3 -2
- package/types/element/resizeTest.d.ts +2 -1
- 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 +43 -17
- package/types/element/textWysiwyg.d.ts +1 -1
- package/types/element/transformHandles.d.ts +16 -8
- package/types/element/typeChecks.d.ts +5 -2
- package/types/element/types.d.ts +59 -35
- package/types/emitter.d.ts +1 -2
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +46 -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 +5 -4
- package/types/math.d.ts +5 -0
- package/types/packages/bbox.d.ts +11 -0
- package/types/packages/excalidraw/example/App.d.ts +7 -1
- package/types/packages/excalidraw/example/initialData.d.ts +182 -64
- package/types/packages/excalidraw/index.d.ts +11 -4
- 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 +11 -2
- package/types/packages/withinBounds.d.ts +19 -0
- package/types/renderer/renderElement.d.ts +12 -22
- package/types/renderer/renderScene.d.ts +19 -27
- 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 +0 -1
- package/types/scene/export.d.ts +50 -11
- 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 +70 -34
- package/types/snapping.d.ts +108 -0
- package/types/types.d.ts +200 -84
- package/types/utility-types.d.ts +24 -0
- package/types/utils.d.ts +73 -29
- package/types/zindex.d.ts +4 -4
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/SingleLibraryItem.d.ts +0 -10
- 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,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
|
|
3
|
-
import { SHAPES } from "./shapes";
|
|
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";
|
|
4
3
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
5
4
|
import { LinearElementEditor } from "./element/linearElementEditor";
|
|
6
5
|
import { SuggestedBinding } from "./element/binding";
|
|
@@ -14,14 +13,13 @@ import { isOverScrollBars } from "./scene";
|
|
|
14
13
|
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
15
14
|
import Library from "./data/library";
|
|
16
15
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
|
-
import type {
|
|
16
|
+
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
17
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
import { SnapLine } from "./snapping";
|
|
19
|
+
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
|
20
|
+
export type Point = Readonly<RoughPoint>;
|
|
21
|
+
export type Collaborator = {
|
|
22
|
+
pointer?: CollaboratorPointer;
|
|
25
23
|
button?: "up" | "down";
|
|
26
24
|
selectedElementIds?: AppState["selectedElementIds"];
|
|
27
25
|
username?: string | null;
|
|
@@ -33,11 +31,29 @@ export declare type Collaborator = {
|
|
|
33
31
|
avatarUrl?: string;
|
|
34
32
|
id?: string;
|
|
35
33
|
};
|
|
36
|
-
export
|
|
34
|
+
export type CollaboratorPointer = {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
tool: "pointer" | "laser";
|
|
38
|
+
/**
|
|
39
|
+
* Whether to render cursor + username. Useful when you only want to render
|
|
40
|
+
* laser trail.
|
|
41
|
+
*
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
renderCursor?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Explicit laser color.
|
|
47
|
+
*
|
|
48
|
+
* @default string collaborator's cursor color
|
|
49
|
+
*/
|
|
50
|
+
laserColor?: string;
|
|
51
|
+
};
|
|
52
|
+
export type DataURL = string & {
|
|
37
53
|
_brand: "DataURL";
|
|
38
54
|
};
|
|
39
|
-
export
|
|
40
|
-
mimeType: typeof
|
|
55
|
+
export type BinaryFileData = {
|
|
56
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
41
57
|
id: FileId;
|
|
42
58
|
dataURL: DataURL;
|
|
43
59
|
/**
|
|
@@ -53,16 +69,58 @@ export declare type BinaryFileData = {
|
|
|
53
69
|
*/
|
|
54
70
|
lastRetrieved?: number;
|
|
55
71
|
};
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
|
|
72
|
+
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
73
|
+
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
74
|
+
export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "laser";
|
|
75
|
+
export type ActiveTool = {
|
|
76
|
+
type: ToolType;
|
|
60
77
|
customType: null;
|
|
61
78
|
} | {
|
|
62
79
|
type: "custom";
|
|
63
80
|
customType: string;
|
|
64
|
-
}
|
|
65
|
-
export
|
|
81
|
+
};
|
|
82
|
+
export type SidebarName = string;
|
|
83
|
+
export type SidebarTabName = string;
|
|
84
|
+
type _CommonCanvasAppState = {
|
|
85
|
+
zoom: AppState["zoom"];
|
|
86
|
+
scrollX: AppState["scrollX"];
|
|
87
|
+
scrollY: AppState["scrollY"];
|
|
88
|
+
width: AppState["width"];
|
|
89
|
+
height: AppState["height"];
|
|
90
|
+
viewModeEnabled: AppState["viewModeEnabled"];
|
|
91
|
+
editingGroupId: AppState["editingGroupId"];
|
|
92
|
+
selectedElementIds: AppState["selectedElementIds"];
|
|
93
|
+
frameToHighlight: AppState["frameToHighlight"];
|
|
94
|
+
offsetLeft: AppState["offsetLeft"];
|
|
95
|
+
offsetTop: AppState["offsetTop"];
|
|
96
|
+
theme: AppState["theme"];
|
|
97
|
+
pendingImageElementId: AppState["pendingImageElementId"];
|
|
98
|
+
};
|
|
99
|
+
export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
100
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
101
|
+
exportScale: AppState["exportScale"];
|
|
102
|
+
selectedElementsAreBeingDragged: AppState["selectedElementsAreBeingDragged"];
|
|
103
|
+
gridSize: AppState["gridSize"];
|
|
104
|
+
frameRendering: AppState["frameRendering"];
|
|
105
|
+
}>;
|
|
106
|
+
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
107
|
+
activeEmbeddable: AppState["activeEmbeddable"];
|
|
108
|
+
editingLinearElement: AppState["editingLinearElement"];
|
|
109
|
+
selectionElement: AppState["selectionElement"];
|
|
110
|
+
selectedGroupIds: AppState["selectedGroupIds"];
|
|
111
|
+
selectedLinearElement: AppState["selectedLinearElement"];
|
|
112
|
+
multiElement: AppState["multiElement"];
|
|
113
|
+
isBindingEnabled: AppState["isBindingEnabled"];
|
|
114
|
+
suggestedBindings: AppState["suggestedBindings"];
|
|
115
|
+
isRotating: AppState["isRotating"];
|
|
116
|
+
elementsToHighlight: AppState["elementsToHighlight"];
|
|
117
|
+
openSidebar: AppState["openSidebar"];
|
|
118
|
+
showHyperlinkPopup: AppState["showHyperlinkPopup"];
|
|
119
|
+
collaborators: AppState["collaborators"];
|
|
120
|
+
snapLines: AppState["snapLines"];
|
|
121
|
+
zenModeEnabled: AppState["zenModeEnabled"];
|
|
122
|
+
}>;
|
|
123
|
+
export type AppState = {
|
|
66
124
|
contextMenu: {
|
|
67
125
|
items: ContextMenuItems;
|
|
68
126
|
top: number;
|
|
@@ -70,7 +128,11 @@ export declare type AppState = {
|
|
|
70
128
|
} | null;
|
|
71
129
|
showWelcomeScreen: boolean;
|
|
72
130
|
isLoading: boolean;
|
|
73
|
-
errorMessage:
|
|
131
|
+
errorMessage: React.ReactNode;
|
|
132
|
+
activeEmbeddable: {
|
|
133
|
+
element: NonDeletedExcalidrawElement;
|
|
134
|
+
state: "hover" | "active";
|
|
135
|
+
} | null;
|
|
74
136
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
75
137
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
76
138
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -78,19 +140,25 @@ export declare type AppState = {
|
|
|
78
140
|
isBindingEnabled: boolean;
|
|
79
141
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
80
142
|
suggestedBindings: SuggestedBinding[];
|
|
143
|
+
frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
|
|
144
|
+
frameRendering: {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
name: boolean;
|
|
147
|
+
outline: boolean;
|
|
148
|
+
clip: boolean;
|
|
149
|
+
};
|
|
150
|
+
editingFrame: string | null;
|
|
151
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
81
152
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
82
153
|
editingLinearElement: LinearElementEditor | null;
|
|
83
154
|
activeTool: {
|
|
84
|
-
|
|
85
|
-
|
|
155
|
+
/**
|
|
156
|
+
* indicates a previous tool we should revert back to if we deselect the
|
|
157
|
+
* currently active tool. At the moment applies to `eraser` and `hand` tool.
|
|
158
|
+
*/
|
|
159
|
+
lastActiveTool: ActiveTool | null;
|
|
86
160
|
locked: boolean;
|
|
87
|
-
|
|
88
|
-
} | {
|
|
89
|
-
type: "custom";
|
|
90
|
-
customType: string;
|
|
91
|
-
lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
|
|
92
|
-
locked: boolean;
|
|
93
|
-
};
|
|
161
|
+
} & ActiveTool;
|
|
94
162
|
penMode: boolean;
|
|
95
163
|
penDetected: boolean;
|
|
96
164
|
exportBackground: boolean;
|
|
@@ -120,17 +188,28 @@ export declare type AppState = {
|
|
|
120
188
|
isRotating: boolean;
|
|
121
189
|
zoom: Zoom;
|
|
122
190
|
openMenu: "canvas" | "shape" | null;
|
|
123
|
-
openPopup: "
|
|
124
|
-
openSidebar:
|
|
191
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
192
|
+
openSidebar: {
|
|
193
|
+
name: SidebarName;
|
|
194
|
+
tab?: SidebarTabName;
|
|
195
|
+
} | null;
|
|
125
196
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
126
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Reflects user preference for whether the default sidebar should be docked.
|
|
199
|
+
*
|
|
200
|
+
* NOTE this is only a user preference and does not reflect the actual docked
|
|
201
|
+
* state of the sidebar, because the host apps can override this through
|
|
202
|
+
* a DefaultSidebar prop, which is not reflected back to the appState.
|
|
203
|
+
*/
|
|
204
|
+
defaultSidebarDockedPreference: boolean;
|
|
127
205
|
lastPointerDownWith: PointerType;
|
|
128
|
-
selectedElementIds: {
|
|
129
|
-
[id: string]:
|
|
130
|
-
}
|
|
206
|
+
selectedElementIds: Readonly<{
|
|
207
|
+
[id: string]: true;
|
|
208
|
+
}>;
|
|
131
209
|
previousSelectedElementIds: {
|
|
132
|
-
[id: string]:
|
|
210
|
+
[id: string]: true;
|
|
133
211
|
};
|
|
212
|
+
selectedElementsAreBeingDragged: boolean;
|
|
134
213
|
shouldCacheIgnoreZoom: boolean;
|
|
135
214
|
toast: {
|
|
136
215
|
message: string;
|
|
@@ -167,18 +246,25 @@ export declare type AppState = {
|
|
|
167
246
|
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
168
247
|
showHyperlinkPopup: false | "info" | "editor";
|
|
169
248
|
selectedLinearElement: LinearElementEditor | null;
|
|
249
|
+
snapLines: readonly SnapLine[];
|
|
250
|
+
originSnapOffset: {
|
|
251
|
+
x: number;
|
|
252
|
+
y: number;
|
|
253
|
+
} | null;
|
|
254
|
+
objectsSnapModeEnabled: boolean;
|
|
170
255
|
};
|
|
171
|
-
export
|
|
256
|
+
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
257
|
+
export type NormalizedZoomValue = number & {
|
|
172
258
|
_brand: "normalizedZoom";
|
|
173
259
|
};
|
|
174
|
-
export
|
|
260
|
+
export type Zoom = Readonly<{
|
|
175
261
|
value: NormalizedZoomValue;
|
|
176
262
|
}>;
|
|
177
|
-
export
|
|
263
|
+
export type PointerCoords = Readonly<{
|
|
178
264
|
x: number;
|
|
179
265
|
y: number;
|
|
180
266
|
}>;
|
|
181
|
-
export
|
|
267
|
+
export type Gesture = {
|
|
182
268
|
pointers: Map<number, PointerCoords>;
|
|
183
269
|
lastCenter: {
|
|
184
270
|
x: number;
|
|
@@ -192,11 +278,11 @@ export declare class GestureEvent extends UIEvent {
|
|
|
192
278
|
readonly scale: number;
|
|
193
279
|
}
|
|
194
280
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
195
|
-
export
|
|
281
|
+
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
196
282
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
197
|
-
|
|
283
|
+
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
198
284
|
/** v2 library item */
|
|
199
|
-
export
|
|
285
|
+
export type LibraryItem = {
|
|
200
286
|
id: string;
|
|
201
287
|
status: "published" | "unpublished";
|
|
202
288
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
@@ -205,14 +291,14 @@ export declare type LibraryItem = {
|
|
|
205
291
|
name?: string;
|
|
206
292
|
error?: string;
|
|
207
293
|
};
|
|
208
|
-
export
|
|
209
|
-
export
|
|
210
|
-
export
|
|
211
|
-
export
|
|
294
|
+
export type LibraryItems = readonly LibraryItem[];
|
|
295
|
+
export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
|
296
|
+
export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
|
|
297
|
+
export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
|
|
212
298
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
213
299
|
ready?: false;
|
|
214
300
|
};
|
|
215
|
-
export
|
|
301
|
+
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
216
302
|
scrollX?: number;
|
|
217
303
|
scrollY?: number;
|
|
218
304
|
libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
|
|
@@ -231,20 +317,22 @@ export interface ExcalidrawProps {
|
|
|
231
317
|
pointer: {
|
|
232
318
|
x: number;
|
|
233
319
|
y: number;
|
|
320
|
+
tool: "pointer" | "laser";
|
|
234
321
|
};
|
|
235
322
|
button: "down" | "up";
|
|
236
323
|
pointersMap: Gesture["pointers"];
|
|
237
324
|
}) => void;
|
|
238
325
|
onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
|
|
239
|
-
renderTopRightUI?: (isMobile: boolean, appState:
|
|
326
|
+
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
240
327
|
langCode?: Language["code"];
|
|
241
328
|
viewModeEnabled?: boolean;
|
|
242
329
|
zenModeEnabled?: boolean;
|
|
243
330
|
gridModeEnabled?: boolean;
|
|
331
|
+
objectsSnapModeEnabled?: boolean;
|
|
244
332
|
libraryReturnUrl?: string;
|
|
245
333
|
theme?: Theme;
|
|
246
334
|
name?: string;
|
|
247
|
-
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState:
|
|
335
|
+
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
248
336
|
UIOptions?: Partial<UIOptions>;
|
|
249
337
|
detectScroll?: boolean;
|
|
250
338
|
handleKeyboardGlobally?: boolean;
|
|
@@ -256,13 +344,19 @@ export interface ExcalidrawProps {
|
|
|
256
344
|
}>) => void;
|
|
257
345
|
onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
|
|
258
346
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
259
|
-
/**
|
|
260
|
-
* Render function that renders custom <Sidebar /> component.
|
|
261
|
-
*/
|
|
262
|
-
renderSidebar?: () => JSX.Element | null;
|
|
263
347
|
children?: React.ReactNode;
|
|
348
|
+
validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
|
|
349
|
+
renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
|
|
350
|
+
interactive?: boolean;
|
|
351
|
+
ui?: boolean;
|
|
352
|
+
activeTool?: {
|
|
353
|
+
type: ToolType;
|
|
354
|
+
} | {
|
|
355
|
+
type: "custom";
|
|
356
|
+
customType: string;
|
|
357
|
+
};
|
|
264
358
|
}
|
|
265
|
-
export
|
|
359
|
+
export type SceneData = {
|
|
266
360
|
elements?: ImportedDataState["elements"];
|
|
267
361
|
appState?: ImportedDataState["appState"];
|
|
268
362
|
collaborators?: Map<string, Collaborator>;
|
|
@@ -273,12 +367,12 @@ export declare enum UserIdleState {
|
|
|
273
367
|
AWAY = "away",
|
|
274
368
|
IDLE = "idle"
|
|
275
369
|
}
|
|
276
|
-
export
|
|
370
|
+
export type ExportOpts = {
|
|
277
371
|
saveFileToDisk?: boolean;
|
|
278
|
-
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
279
|
-
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
372
|
+
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
|
|
373
|
+
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
280
374
|
};
|
|
281
|
-
|
|
375
|
+
type CanvasActions = Partial<{
|
|
282
376
|
changeViewBackgroundColor: boolean;
|
|
283
377
|
clearCanvas: boolean;
|
|
284
378
|
export: false | ExportOpts;
|
|
@@ -287,13 +381,14 @@ declare type CanvasActions = Partial<{
|
|
|
287
381
|
toggleTheme: boolean | null;
|
|
288
382
|
saveAsImage: boolean;
|
|
289
383
|
}>;
|
|
290
|
-
|
|
384
|
+
type UIOptions = Partial<{
|
|
291
385
|
dockedSidebarBreakpoint: number;
|
|
292
|
-
welcomeScreen: boolean;
|
|
293
386
|
canvasActions: CanvasActions;
|
|
387
|
+
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
388
|
+
welcomeScreen?: boolean;
|
|
294
389
|
}>;
|
|
295
|
-
export
|
|
296
|
-
UIOptions: Merge<
|
|
390
|
+
export type AppProps = Merge<ExcalidrawProps, {
|
|
391
|
+
UIOptions: Merge<UIOptions, {
|
|
297
392
|
canvasActions: Required<CanvasActions> & {
|
|
298
393
|
export: ExportOpts;
|
|
299
394
|
};
|
|
@@ -305,21 +400,29 @@ export declare type AppProps = Merge<ExcalidrawProps, {
|
|
|
305
400
|
}>;
|
|
306
401
|
/** A subset of App class properties that we need to use elsewhere
|
|
307
402
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
308
|
-
export
|
|
403
|
+
export type AppClassProperties = {
|
|
309
404
|
props: AppProps;
|
|
310
|
-
|
|
405
|
+
interactiveCanvas: HTMLCanvasElement | null;
|
|
406
|
+
/** static canvas */
|
|
407
|
+
canvas: HTMLCanvasElement;
|
|
311
408
|
focusContainer(): void;
|
|
312
409
|
library: Library;
|
|
313
410
|
imageCache: Map<FileId, {
|
|
314
411
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
315
|
-
mimeType: typeof
|
|
412
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
316
413
|
}>;
|
|
317
414
|
files: BinaryFiles;
|
|
318
415
|
device: App["device"];
|
|
319
416
|
scene: App["scene"];
|
|
320
417
|
pasteFromClipboard: App["pasteFromClipboard"];
|
|
418
|
+
id: App["id"];
|
|
419
|
+
onInsertElements: App["onInsertElements"];
|
|
420
|
+
onExportImage: App["onExportImage"];
|
|
421
|
+
lastViewportPosition: App["lastViewportPosition"];
|
|
422
|
+
togglePenMode: App["togglePenMode"];
|
|
423
|
+
setActiveTool: App["setActiveTool"];
|
|
321
424
|
};
|
|
322
|
-
export
|
|
425
|
+
export type PointerDownState = Readonly<{
|
|
323
426
|
origin: Readonly<{
|
|
324
427
|
x: number;
|
|
325
428
|
y: number;
|
|
@@ -378,8 +481,8 @@ export declare type PointerDownState = Readonly<{
|
|
|
378
481
|
};
|
|
379
482
|
};
|
|
380
483
|
}>;
|
|
381
|
-
|
|
382
|
-
export
|
|
484
|
+
type UnsubscribeCallback = () => void;
|
|
485
|
+
export type ExcalidrawImperativeAPI = {
|
|
383
486
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
384
487
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
385
488
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
@@ -400,31 +503,44 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
400
503
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
401
504
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
402
505
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
403
|
-
|
|
506
|
+
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
507
|
+
/**
|
|
508
|
+
* Disables rendering of frames (including element clipping), but currently
|
|
509
|
+
* the frames are still interactive in edit mode. As such, this API should be
|
|
510
|
+
* used in conjunction with view mode (props.viewModeEnabled).
|
|
511
|
+
*/
|
|
512
|
+
updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
|
|
404
513
|
app: InstanceType<typeof App>;
|
|
405
514
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
406
|
-
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<
|
|
515
|
+
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
407
516
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
408
517
|
};
|
|
409
|
-
export
|
|
518
|
+
export type Device = Readonly<{
|
|
410
519
|
isSmScreen: boolean;
|
|
411
520
|
isMobile: boolean;
|
|
412
521
|
isTouchScreen: boolean;
|
|
413
522
|
canDeviceFitSidebar: boolean;
|
|
523
|
+
isLandscape: boolean;
|
|
414
524
|
}>;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
525
|
+
type FrameNameBounds = {
|
|
526
|
+
x: number;
|
|
527
|
+
y: number;
|
|
528
|
+
width: number;
|
|
529
|
+
height: number;
|
|
530
|
+
angle: number;
|
|
419
531
|
};
|
|
420
|
-
export
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
532
|
+
export type FrameNameBoundsCache = {
|
|
533
|
+
get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
|
|
534
|
+
_cache: Map<string, FrameNameBounds & {
|
|
535
|
+
zoom: AppState["zoom"]["value"];
|
|
536
|
+
versionNonce: ExcalidrawFrameElement["versionNonce"];
|
|
537
|
+
}>;
|
|
424
538
|
};
|
|
425
|
-
export
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
539
|
+
export type KeyboardModifiersObject = {
|
|
540
|
+
ctrlKey: boolean;
|
|
541
|
+
shiftKey: boolean;
|
|
542
|
+
altKey: boolean;
|
|
543
|
+
metaKey: boolean;
|
|
429
544
|
};
|
|
545
|
+
export type Primitive = number | string | boolean | bigint | symbol | null | undefined;
|
|
430
546
|
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,14 +1,13 @@
|
|
|
1
1
|
import { EVENT } from "./constants";
|
|
2
|
-
import { FontFamilyValues, FontString } from "./element/types";
|
|
3
|
-
import { AppState,
|
|
4
|
-
import { SHAPES } from "./shapes";
|
|
5
|
-
import React from "react";
|
|
2
|
+
import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
|
|
3
|
+
import { ActiveTool, AppState, ToolType, Zoom } from "./types";
|
|
6
4
|
export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
7
5
|
export declare const getDateTime: () => string;
|
|
8
6
|
export declare const capitalizeString: (str: string) => string;
|
|
9
7
|
export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
|
|
10
|
-
export declare const isInputLike: (target: Element | EventTarget | null) => target is
|
|
11
|
-
export declare const
|
|
8
|
+
export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
|
|
9
|
+
export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
|
|
10
|
+
export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
|
|
12
11
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
13
12
|
fontFamily: FontFamilyValues;
|
|
14
13
|
}) => string;
|
|
@@ -29,22 +28,67 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
29
28
|
flush(): void;
|
|
30
29
|
cancel(): void;
|
|
31
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Exponential ease-out method
|
|
33
|
+
*
|
|
34
|
+
* @param {number} k - The value to be tweened.
|
|
35
|
+
* @returns {number} The tweened value.
|
|
36
|
+
*/
|
|
37
|
+
export declare const easeOut: (k: number) => number;
|
|
38
|
+
/**
|
|
39
|
+
* Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.
|
|
40
|
+
* Executes the `onStep` callback on each step with the interpolated values.
|
|
41
|
+
* Returns a function that can be called to cancel the animation.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Example usage:
|
|
45
|
+
* const fromValues = { x: 0, y: 0 };
|
|
46
|
+
* const toValues = { x: 100, y: 200 };
|
|
47
|
+
* const onStep = ({x, y}) => {
|
|
48
|
+
* setState(x, y)
|
|
49
|
+
* };
|
|
50
|
+
* const onCancel = () => {
|
|
51
|
+
* console.log("Animation canceled");
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* const cancelAnimation = easeToValuesRAF({
|
|
55
|
+
* fromValues,
|
|
56
|
+
* toValues,
|
|
57
|
+
* onStep,
|
|
58
|
+
* onCancel,
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // To cancel the animation:
|
|
62
|
+
* cancelAnimation();
|
|
63
|
+
*/
|
|
64
|
+
export declare const easeToValuesRAF: <T extends Record<keyof T, number>, K extends keyof T>({ fromValues, toValues, onStep, duration, interpolateValue, onStart, onEnd, onCancel, }: {
|
|
65
|
+
fromValues: T;
|
|
66
|
+
toValues: T;
|
|
67
|
+
/**
|
|
68
|
+
* Interpolate a single value.
|
|
69
|
+
* Return undefined to be handled by the default interpolator.
|
|
70
|
+
*/
|
|
71
|
+
interpolateValue?: ((fromValue: number, toValue: number, progress: number, key: K) => number | undefined) | undefined;
|
|
72
|
+
onStep: (values: T) => void;
|
|
73
|
+
duration?: number | undefined;
|
|
74
|
+
onStart?: (() => void) | undefined;
|
|
75
|
+
onEnd?: (() => void) | undefined;
|
|
76
|
+
onCancel?: (() => void) | undefined;
|
|
77
|
+
}) => () => void;
|
|
32
78
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
33
79
|
export declare const selectNode: (node: Element) => void;
|
|
34
80
|
export declare const removeSelection: () => void;
|
|
35
81
|
export declare const distance: (x: number, y: number) => number;
|
|
36
|
-
export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
|
|
37
|
-
type:
|
|
82
|
+
export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: (({
|
|
83
|
+
type: ToolType;
|
|
38
84
|
} | {
|
|
39
85
|
type: "custom";
|
|
40
86
|
customType: string;
|
|
41
87
|
}) & {
|
|
42
|
-
|
|
88
|
+
locked?: boolean;
|
|
89
|
+
}) & {
|
|
90
|
+
lastActiveToolBeforeEraser?: ActiveTool | null;
|
|
43
91
|
}) => AppState["activeTool"];
|
|
44
|
-
export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
|
|
45
|
-
export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
|
|
46
|
-
export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
|
|
47
|
-
export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
|
|
48
92
|
export declare const isFullScreen: () => boolean;
|
|
49
93
|
export declare const allowFullScreen: () => Promise<void>;
|
|
50
94
|
export declare const exitFullScreen: () => Promise<void>;
|
|
@@ -92,7 +136,7 @@ export declare const muteFSAbortError: (error?: Error) => void;
|
|
|
92
136
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
93
137
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
94
138
|
export declare const isTransparent: (color: string) => boolean;
|
|
95
|
-
export
|
|
139
|
+
export type ResolvablePromise<T> = Promise<T> & {
|
|
96
140
|
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
|
97
141
|
reject: (error: Error) => void;
|
|
98
142
|
};
|
|
@@ -125,29 +169,29 @@ export declare const getUpdatedTimestamp: () => number;
|
|
|
125
169
|
export declare const arrayToMap: <T extends string | {
|
|
126
170
|
id: string;
|
|
127
171
|
}>(items: readonly T[]) => Map<string, T>;
|
|
172
|
+
export declare const arrayToMapWithIndex: <T extends {
|
|
173
|
+
id: string;
|
|
174
|
+
}>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
|
|
128
175
|
export declare const isTestEnv: () => boolean;
|
|
129
|
-
export declare const isProdEnv: () => boolean;
|
|
130
176
|
export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
|
|
131
177
|
nativeEvent: T;
|
|
132
178
|
}>;
|
|
133
179
|
export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
|
|
134
180
|
export declare const isPrimitive: (val: any) => boolean;
|
|
135
181
|
export declare const getFrame: () => "top" | "iframe";
|
|
182
|
+
export declare const isRunningInIframe: () => boolean;
|
|
136
183
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
137
184
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
185
|
+
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;
|
|
186
|
+
export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
|
|
187
|
+
checkForDefaultPrevented?: boolean | undefined;
|
|
188
|
+
}) => (event: E) => void;
|
|
189
|
+
export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
190
|
+
export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
|
|
138
191
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* Returns known children as a dictionary of react children keyed by their
|
|
142
|
-
* displayName, and the rest children as an array.
|
|
143
|
-
*
|
|
144
|
-
* NOTE all named react components are included in the dictionary, irrespective
|
|
145
|
-
* of the supplied type parameter. This means you may be throwing away
|
|
146
|
-
* children that you aren't expecting, but should nonetheless be rendered.
|
|
147
|
-
* To guard against this (provided you care about the rest children at all),
|
|
148
|
-
* supply a second parameter with an object with keys of the expected children.
|
|
192
|
+
* Memoizes on values of `opts` object (strict equality).
|
|
149
193
|
*/
|
|
150
|
-
export declare const
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
export declare const
|
|
194
|
+
export declare const memoize: <T extends Record<string, any>, R extends unknown>(func: (opts: T) => R) => ((opts: T) => R) & {
|
|
195
|
+
clear: () => void;
|
|
196
|
+
};
|
|
197
|
+
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: (
|
|
4
|
-
export declare const moveOneRight: (
|
|
5
|
-
export declare const moveAllLeft: (
|
|
6
|
-
export declare const moveAllRight: (
|
|
3
|
+
export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
|
|
4
|
+
export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
|
|
5
|
+
export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
|
|
6
|
+
export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
|