@dwelle/excalidraw 0.4.0-e1bdbb6 → 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 +714 -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 +3257 -1444
- 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 +124 -64
- package/types/actions/actionAlign.d.ts +33 -40
- package/types/actions/actionBoundText.d.ts +182 -25
- package/types/actions/actionCanvas.d.ts +754 -220
- package/types/actions/actionClipboard.d.ts +236 -115
- package/types/actions/actionDeleteSelected.d.ts +133 -72
- package/types/actions/actionDistribute.d.ts +11 -16
- package/types/actions/actionDuplicateSelection.d.ts +4 -7
- package/types/actions/actionElementLock.d.ts +271 -0
- package/types/actions/actionExport.d.ts +440 -277
- package/types/actions/actionFinalize.d.ts +85 -51
- package/types/actions/actionFlip.d.ts +8 -11
- package/types/actions/actionFrame.d.ts +423 -0
- package/types/actions/actionGroup.d.ts +252 -19
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +44 -24
- package/types/actions/actionMenu.d.ts +132 -79
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +569 -334
- package/types/actions/actionSelectAll.d.ts +123 -4
- package/types/actions/actionStyles.d.ts +46 -27
- package/types/actions/actionToggleGridMode.d.ts +46 -25
- package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +56 -35
- package/types/actions/actionToggleStats.d.ts +45 -25
- package/types/actions/actionToggleViewMode.d.ts +46 -25
- package/types/actions/actionToggleZenMode.d.ts +46 -25
- package/types/actions/actionZindex.d.ts +16 -24
- 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 +27 -28
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +9 -3
- 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 +102 -86
- 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/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 +11 -19
- 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 +9 -15
- 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 +70 -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 +13 -0
- package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +7 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +14 -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 +17 -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 +64 -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 +105 -18
- 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/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 +73 -0
- package/types/data/types.d.ts +3 -5
- package/types/data/url.d.ts +7 -0
- package/types/element/Hyperlink.d.ts +57 -36
- package/types/element/binding.d.ts +4 -3
- package/types/element/bounds.d.ts +41 -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 +77 -30
- package/types/element/mutateElement.d.ts +3 -2
- package/types/element/newElement.d.ts +48 -15
- package/types/element/resizeElements.d.ts +3 -3
- 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 +57 -9
- package/types/element/textWysiwyg.d.ts +7 -2
- package/types/element/transformHandles.d.ts +15 -8
- package/types/element/typeChecks.d.ts +14 -2
- package/types/element/types.d.ts +66 -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 +7 -4
- package/types/math.d.ts +7 -1
- package/types/packages/bbox.d.ts +11 -0
- 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 +22 -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 +30 -24
- package/types/packages/withinBounds.d.ts +19 -0
- package/types/renderer/renderElement.d.ts +13 -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/Fonts.d.ts +21 -0
- package/types/scene/Renderer.d.ts +25 -0
- package/types/scene/Scene.d.ts +42 -5
- package/types/scene/Shape.d.ts +12 -0
- package/types/scene/ShapeCache.d.ts +20 -0
- package/types/scene/comparisons.d.ts +2 -4
- package/types/scene/export.d.ts +183 -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 +70 -26
- package/types/snapping.d.ts +108 -0
- package/types/types.d.ts +227 -91
- package/types/utility-types.d.ts +24 -0
- package/types/utils.d.ts +75 -14
- 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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Bounds } from "./element/bounds";
|
|
2
|
+
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
3
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
|
|
4
|
+
import { AppState, KeyboardModifiersObject, Point } from "./types";
|
|
5
|
+
export declare const getSnapDistance: (zoomValue: number) => number;
|
|
6
|
+
type Vector2D = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
type PointPair = [Point, Point];
|
|
11
|
+
export type PointSnap = {
|
|
12
|
+
type: "point";
|
|
13
|
+
points: PointPair;
|
|
14
|
+
offset: number;
|
|
15
|
+
};
|
|
16
|
+
export type Gap = {
|
|
17
|
+
startBounds: Bounds;
|
|
18
|
+
endBounds: Bounds;
|
|
19
|
+
startSide: [Point, Point];
|
|
20
|
+
endSide: [Point, Point];
|
|
21
|
+
overlap: [number, number];
|
|
22
|
+
length: number;
|
|
23
|
+
};
|
|
24
|
+
export type GapSnap = {
|
|
25
|
+
type: "gap";
|
|
26
|
+
direction: "center_horizontal" | "center_vertical" | "side_left" | "side_right" | "side_top" | "side_bottom";
|
|
27
|
+
gap: Gap;
|
|
28
|
+
offset: number;
|
|
29
|
+
};
|
|
30
|
+
export type GapSnaps = GapSnap[];
|
|
31
|
+
export type Snap = GapSnap | PointSnap;
|
|
32
|
+
export type Snaps = Snap[];
|
|
33
|
+
export type PointSnapLine = {
|
|
34
|
+
type: "points";
|
|
35
|
+
points: Point[];
|
|
36
|
+
};
|
|
37
|
+
export type PointerSnapLine = {
|
|
38
|
+
type: "pointer";
|
|
39
|
+
points: PointPair;
|
|
40
|
+
direction: "horizontal" | "vertical";
|
|
41
|
+
};
|
|
42
|
+
export type GapSnapLine = {
|
|
43
|
+
type: "gap";
|
|
44
|
+
direction: "horizontal" | "vertical";
|
|
45
|
+
points: PointPair;
|
|
46
|
+
};
|
|
47
|
+
export type SnapLine = PointSnapLine | GapSnapLine | PointerSnapLine;
|
|
48
|
+
export declare class SnapCache {
|
|
49
|
+
private static referenceSnapPoints;
|
|
50
|
+
private static visibleGaps;
|
|
51
|
+
static setReferenceSnapPoints: (snapPoints: Point[] | null) => void;
|
|
52
|
+
static getReferenceSnapPoints: () => (readonly [number, number])[] | null;
|
|
53
|
+
static setVisibleGaps: (gaps: {
|
|
54
|
+
verticalGaps: Gap[];
|
|
55
|
+
horizontalGaps: Gap[];
|
|
56
|
+
} | null) => void;
|
|
57
|
+
static getVisibleGaps: () => {
|
|
58
|
+
verticalGaps: Gap[];
|
|
59
|
+
horizontalGaps: Gap[];
|
|
60
|
+
} | null;
|
|
61
|
+
static destroy: () => void;
|
|
62
|
+
}
|
|
63
|
+
export declare const isSnappingEnabled: ({ event, appState, selectedElements, }: {
|
|
64
|
+
appState: AppState;
|
|
65
|
+
event: KeyboardModifiersObject;
|
|
66
|
+
selectedElements: NonDeletedExcalidrawElement[];
|
|
67
|
+
}) => boolean;
|
|
68
|
+
export declare const areRoughlyEqual: (a: number, b: number, precision?: number) => boolean;
|
|
69
|
+
export declare const getElementsCorners: (elements: ExcalidrawElement[], { omitCenter, boundingBoxCorners, dragOffset, }?: {
|
|
70
|
+
omitCenter?: boolean | undefined;
|
|
71
|
+
boundingBoxCorners?: boolean | undefined;
|
|
72
|
+
dragOffset?: Vector2D | undefined;
|
|
73
|
+
}) => Point[];
|
|
74
|
+
export declare const getVisibleGaps: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState) => {
|
|
75
|
+
horizontalGaps: Gap[];
|
|
76
|
+
verticalGaps: Gap[];
|
|
77
|
+
};
|
|
78
|
+
export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState) => (readonly [number, number])[];
|
|
79
|
+
export declare const snapDraggedElements: (selectedElements: ExcalidrawElement[], dragOffset: Vector2D, appState: AppState, event: KeyboardModifiersObject) => {
|
|
80
|
+
snapOffset: {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
};
|
|
84
|
+
snapLines: (PointSnapLine | GapSnapLine)[];
|
|
85
|
+
};
|
|
86
|
+
export declare const snapResizingElements: (selectedElements: ExcalidrawElement[], selectedOriginalElements: ExcalidrawElement[], appState: AppState, event: KeyboardModifiersObject, dragOffset: Vector2D, transformHandle: MaybeTransformHandleType) => {
|
|
87
|
+
snapOffset: {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
91
|
+
snapLines: PointSnapLine[];
|
|
92
|
+
};
|
|
93
|
+
export declare const snapNewElement: (draggingElement: ExcalidrawElement, appState: AppState, event: KeyboardModifiersObject, origin: Vector2D, dragOffset: Vector2D) => {
|
|
94
|
+
snapOffset: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
};
|
|
98
|
+
snapLines: PointSnapLine[];
|
|
99
|
+
};
|
|
100
|
+
export declare const getSnapLinesAtPointer: (elements: readonly ExcalidrawElement[], appState: AppState, pointer: Vector2D, event: KeyboardModifiersObject) => {
|
|
101
|
+
originOffset: {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
};
|
|
105
|
+
snapLines: PointerSnapLine[];
|
|
106
|
+
};
|
|
107
|
+
export declare const isActiveToolNonLinearSnappable: (activeToolType: AppState["activeTool"]["type"]) => boolean;
|
|
108
|
+
export {};
|
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 } 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,13 +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 {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
17
|
+
import { ContextMenuItems } from "./components/ContextMenu";
|
|
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;
|
|
24
23
|
button?: "up" | "down";
|
|
25
24
|
selectedElementIds?: AppState["selectedElementIds"];
|
|
26
25
|
username?: string | null;
|
|
@@ -32,11 +31,29 @@ export declare type Collaborator = {
|
|
|
32
31
|
avatarUrl?: string;
|
|
33
32
|
id?: string;
|
|
34
33
|
};
|
|
35
|
-
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 & {
|
|
36
53
|
_brand: "DataURL";
|
|
37
54
|
};
|
|
38
|
-
export
|
|
39
|
-
mimeType: typeof
|
|
55
|
+
export type BinaryFileData = {
|
|
56
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
40
57
|
id: FileId;
|
|
41
58
|
dataURL: DataURL;
|
|
42
59
|
/**
|
|
@@ -52,19 +69,70 @@ export declare type BinaryFileData = {
|
|
|
52
69
|
*/
|
|
53
70
|
lastRetrieved?: number;
|
|
54
71
|
};
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
|
|
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;
|
|
59
77
|
customType: null;
|
|
60
78
|
} | {
|
|
61
79
|
type: "custom";
|
|
62
80
|
customType: string;
|
|
63
|
-
}
|
|
64
|
-
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 = {
|
|
124
|
+
contextMenu: {
|
|
125
|
+
items: ContextMenuItems;
|
|
126
|
+
top: number;
|
|
127
|
+
left: number;
|
|
128
|
+
} | null;
|
|
65
129
|
showWelcomeScreen: boolean;
|
|
66
130
|
isLoading: boolean;
|
|
67
|
-
errorMessage:
|
|
131
|
+
errorMessage: React.ReactNode;
|
|
132
|
+
activeEmbeddable: {
|
|
133
|
+
element: NonDeletedExcalidrawElement;
|
|
134
|
+
state: "hover" | "active";
|
|
135
|
+
} | null;
|
|
68
136
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
69
137
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
70
138
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
@@ -72,19 +140,25 @@ export declare type AppState = {
|
|
|
72
140
|
isBindingEnabled: boolean;
|
|
73
141
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
74
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;
|
|
75
152
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
76
153
|
editingLinearElement: LinearElementEditor | null;
|
|
77
154
|
activeTool: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type: "custom";
|
|
84
|
-
customType: string;
|
|
85
|
-
lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
|
|
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
|
-
};
|
|
161
|
+
} & ActiveTool;
|
|
88
162
|
penMode: boolean;
|
|
89
163
|
penDetected: boolean;
|
|
90
164
|
exportBackground: boolean;
|
|
@@ -101,10 +175,9 @@ export declare type AppState = {
|
|
|
101
175
|
currentItemFontFamily: FontFamilyValues;
|
|
102
176
|
currentItemFontSize: number;
|
|
103
177
|
currentItemTextAlign: TextAlign;
|
|
104
|
-
currentItemStrokeSharpness: ExcalidrawElement["strokeSharpness"];
|
|
105
178
|
currentItemStartArrowhead: Arrowhead | null;
|
|
106
179
|
currentItemEndArrowhead: Arrowhead | null;
|
|
107
|
-
|
|
180
|
+
currentItemRoundness: StrokeRoundness;
|
|
108
181
|
viewBackgroundColor: string;
|
|
109
182
|
scrollX: number;
|
|
110
183
|
scrollY: number;
|
|
@@ -115,17 +188,28 @@ export declare type AppState = {
|
|
|
115
188
|
isRotating: boolean;
|
|
116
189
|
zoom: Zoom;
|
|
117
190
|
openMenu: "canvas" | "shape" | null;
|
|
118
|
-
openPopup: "
|
|
119
|
-
openSidebar:
|
|
120
|
-
|
|
121
|
-
|
|
191
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
192
|
+
openSidebar: {
|
|
193
|
+
name: SidebarName;
|
|
194
|
+
tab?: SidebarTabName;
|
|
195
|
+
} | null;
|
|
196
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
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;
|
|
122
205
|
lastPointerDownWith: PointerType;
|
|
123
|
-
selectedElementIds: {
|
|
124
|
-
[id: string]:
|
|
125
|
-
}
|
|
206
|
+
selectedElementIds: Readonly<{
|
|
207
|
+
[id: string]: true;
|
|
208
|
+
}>;
|
|
126
209
|
previousSelectedElementIds: {
|
|
127
|
-
[id: string]:
|
|
210
|
+
[id: string]: true;
|
|
128
211
|
};
|
|
212
|
+
selectedElementsAreBeingDragged: boolean;
|
|
129
213
|
shouldCacheIgnoreZoom: boolean;
|
|
130
214
|
toast: {
|
|
131
215
|
message: string;
|
|
@@ -162,18 +246,25 @@ export declare type AppState = {
|
|
|
162
246
|
pendingImageElementId: ExcalidrawImageElement["id"] | null;
|
|
163
247
|
showHyperlinkPopup: false | "info" | "editor";
|
|
164
248
|
selectedLinearElement: LinearElementEditor | null;
|
|
249
|
+
snapLines: readonly SnapLine[];
|
|
250
|
+
originSnapOffset: {
|
|
251
|
+
x: number;
|
|
252
|
+
y: number;
|
|
253
|
+
} | null;
|
|
254
|
+
objectsSnapModeEnabled: boolean;
|
|
165
255
|
};
|
|
166
|
-
export
|
|
256
|
+
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
257
|
+
export type NormalizedZoomValue = number & {
|
|
167
258
|
_brand: "normalizedZoom";
|
|
168
259
|
};
|
|
169
|
-
export
|
|
260
|
+
export type Zoom = Readonly<{
|
|
170
261
|
value: NormalizedZoomValue;
|
|
171
262
|
}>;
|
|
172
|
-
export
|
|
263
|
+
export type PointerCoords = Readonly<{
|
|
173
264
|
x: number;
|
|
174
265
|
y: number;
|
|
175
266
|
}>;
|
|
176
|
-
export
|
|
267
|
+
export type Gesture = {
|
|
177
268
|
pointers: Map<number, PointerCoords>;
|
|
178
269
|
lastCenter: {
|
|
179
270
|
x: number;
|
|
@@ -187,11 +278,11 @@ export declare class GestureEvent extends UIEvent {
|
|
|
187
278
|
readonly scale: number;
|
|
188
279
|
}
|
|
189
280
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
190
|
-
export
|
|
281
|
+
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
191
282
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
192
|
-
|
|
283
|
+
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
193
284
|
/** v2 library item */
|
|
194
|
-
export
|
|
285
|
+
export type LibraryItem = {
|
|
195
286
|
id: string;
|
|
196
287
|
status: "published" | "unpublished";
|
|
197
288
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
@@ -200,14 +291,14 @@ export declare type LibraryItem = {
|
|
|
200
291
|
name?: string;
|
|
201
292
|
error?: string;
|
|
202
293
|
};
|
|
203
|
-
export
|
|
204
|
-
export
|
|
205
|
-
export
|
|
206
|
-
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 | {
|
|
207
298
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
208
299
|
ready?: false;
|
|
209
300
|
};
|
|
210
|
-
export
|
|
301
|
+
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
211
302
|
scrollX?: number;
|
|
212
303
|
scrollY?: number;
|
|
213
304
|
libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
|
|
@@ -216,37 +307,33 @@ export interface ExcalidrawProps {
|
|
|
216
307
|
id?: string | null;
|
|
217
308
|
onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, id?: string | null) => void;
|
|
218
309
|
initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
|
|
219
|
-
onHomeButtonClick
|
|
220
|
-
onThemeToggle: (theme: Theme) => void;
|
|
310
|
+
onHomeButtonClick?: () => void;
|
|
221
311
|
user?: {
|
|
222
312
|
name?: string | null;
|
|
223
313
|
};
|
|
224
314
|
excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
|
|
225
|
-
onCollabButtonClick?: () => void;
|
|
226
315
|
isCollaborating?: boolean;
|
|
227
316
|
onPointerUpdate?: (payload: {
|
|
228
317
|
pointer: {
|
|
229
318
|
x: number;
|
|
230
319
|
y: number;
|
|
320
|
+
tool: "pointer" | "laser";
|
|
231
321
|
};
|
|
232
322
|
button: "down" | "up";
|
|
233
323
|
pointersMap: Gesture["pointers"];
|
|
234
324
|
}) => void;
|
|
235
325
|
onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
|
|
236
|
-
renderTopRightUI?: (isMobile: boolean, appState:
|
|
237
|
-
renderFooter?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
326
|
+
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
238
327
|
langCode?: Language["code"];
|
|
239
328
|
viewModeEnabled?: boolean;
|
|
240
329
|
zenModeEnabled?: boolean;
|
|
241
330
|
gridModeEnabled?: boolean;
|
|
331
|
+
objectsSnapModeEnabled?: boolean;
|
|
242
332
|
libraryReturnUrl?: string;
|
|
243
333
|
theme?: Theme;
|
|
244
334
|
name?: string;
|
|
245
|
-
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState:
|
|
246
|
-
UIOptions?:
|
|
247
|
-
dockedSidebarBreakpoint?: number;
|
|
248
|
-
canvasActions?: CanvasActions;
|
|
249
|
-
};
|
|
335
|
+
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
336
|
+
UIOptions?: Partial<UIOptions>;
|
|
250
337
|
detectScroll?: boolean;
|
|
251
338
|
handleKeyboardGlobally?: boolean;
|
|
252
339
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -257,12 +344,19 @@ export interface ExcalidrawProps {
|
|
|
257
344
|
}>) => void;
|
|
258
345
|
onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
|
|
259
346
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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,27 +367,32 @@ 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:
|
|
280
|
-
};
|
|
281
|
-
declare type CanvasActions = {
|
|
282
|
-
changeViewBackgroundColor?: boolean;
|
|
283
|
-
clearCanvas?: boolean;
|
|
284
|
-
export?: false | ExportOpts;
|
|
285
|
-
loadScene?: boolean;
|
|
286
|
-
saveToActiveFile?: boolean;
|
|
287
|
-
toggleTheme?: boolean | null;
|
|
288
|
-
saveAsImage?: boolean;
|
|
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;
|
|
289
374
|
};
|
|
290
|
-
|
|
291
|
-
|
|
375
|
+
type CanvasActions = Partial<{
|
|
376
|
+
changeViewBackgroundColor: boolean;
|
|
377
|
+
clearCanvas: boolean;
|
|
378
|
+
export: false | ExportOpts;
|
|
379
|
+
loadScene: boolean;
|
|
380
|
+
saveToActiveFile: boolean;
|
|
381
|
+
toggleTheme: boolean | null;
|
|
382
|
+
saveAsImage: boolean;
|
|
383
|
+
}>;
|
|
384
|
+
type UIOptions = Partial<{
|
|
385
|
+
dockedSidebarBreakpoint: number;
|
|
386
|
+
canvasActions: CanvasActions;
|
|
387
|
+
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
388
|
+
welcomeScreen?: boolean;
|
|
389
|
+
}>;
|
|
390
|
+
export type AppProps = Merge<ExcalidrawProps, {
|
|
391
|
+
UIOptions: Merge<UIOptions, {
|
|
292
392
|
canvasActions: Required<CanvasActions> & {
|
|
293
393
|
export: ExportOpts;
|
|
294
394
|
};
|
|
295
|
-
|
|
296
|
-
};
|
|
395
|
+
}>;
|
|
297
396
|
detectScroll: boolean;
|
|
298
397
|
handleKeyboardGlobally: boolean;
|
|
299
398
|
isCollaborating: boolean;
|
|
@@ -301,20 +400,29 @@ export declare type AppProps = Merge<ExcalidrawProps, {
|
|
|
301
400
|
}>;
|
|
302
401
|
/** A subset of App class properties that we need to use elsewhere
|
|
303
402
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
304
|
-
export
|
|
403
|
+
export type AppClassProperties = {
|
|
305
404
|
props: AppProps;
|
|
306
|
-
|
|
405
|
+
interactiveCanvas: HTMLCanvasElement | null;
|
|
406
|
+
/** static canvas */
|
|
407
|
+
canvas: HTMLCanvasElement;
|
|
307
408
|
focusContainer(): void;
|
|
308
409
|
library: Library;
|
|
309
410
|
imageCache: Map<FileId, {
|
|
310
411
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
311
|
-
mimeType: typeof
|
|
412
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
312
413
|
}>;
|
|
313
414
|
files: BinaryFiles;
|
|
314
415
|
device: App["device"];
|
|
315
416
|
scene: App["scene"];
|
|
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"];
|
|
316
424
|
};
|
|
317
|
-
export
|
|
425
|
+
export type PointerDownState = Readonly<{
|
|
318
426
|
origin: Readonly<{
|
|
319
427
|
x: number;
|
|
320
428
|
y: number;
|
|
@@ -373,8 +481,8 @@ export declare type PointerDownState = Readonly<{
|
|
|
373
481
|
};
|
|
374
482
|
};
|
|
375
483
|
}>;
|
|
376
|
-
|
|
377
|
-
export
|
|
484
|
+
type UnsubscribeCallback = () => void;
|
|
485
|
+
export type ExcalidrawImperativeAPI = {
|
|
378
486
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
379
487
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
380
488
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
@@ -395,16 +503,44 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
395
503
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
396
504
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
397
505
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
398
|
-
|
|
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"];
|
|
399
513
|
app: InstanceType<typeof App>;
|
|
400
514
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
401
|
-
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<
|
|
515
|
+
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
402
516
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
403
517
|
};
|
|
404
|
-
export
|
|
518
|
+
export type Device = Readonly<{
|
|
405
519
|
isSmScreen: boolean;
|
|
406
520
|
isMobile: boolean;
|
|
407
521
|
isTouchScreen: boolean;
|
|
408
522
|
canDeviceFitSidebar: boolean;
|
|
523
|
+
isLandscape: boolean;
|
|
409
524
|
}>;
|
|
525
|
+
type FrameNameBounds = {
|
|
526
|
+
x: number;
|
|
527
|
+
y: number;
|
|
528
|
+
width: number;
|
|
529
|
+
height: number;
|
|
530
|
+
angle: number;
|
|
531
|
+
};
|
|
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
|
+
}>;
|
|
538
|
+
};
|
|
539
|
+
export type KeyboardModifiersObject = {
|
|
540
|
+
ctrlKey: boolean;
|
|
541
|
+
shiftKey: boolean;
|
|
542
|
+
altKey: boolean;
|
|
543
|
+
metaKey: boolean;
|
|
544
|
+
};
|
|
545
|
+
export type Primitive = number | string | boolean | bigint | symbol | null | undefined;
|
|
410
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;
|