@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
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
3
3
|
import { ActionManager } from "../actions/manager";
|
|
4
|
+
import { EXPORT_IMAGE_TYPES } from "../constants";
|
|
4
5
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
5
6
|
import { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "../element/types";
|
|
6
7
|
import History from "../history";
|
|
7
8
|
import Scene from "../scene/Scene";
|
|
8
|
-
import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device } from "../types";
|
|
9
|
+
import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType } from "../types";
|
|
9
10
|
import { FileSystemHandle } from "../data/filesystem";
|
|
11
|
+
import { Renderer } from "../scene/Renderer";
|
|
12
|
+
import { LaserPathManager } from "./LaserTool/LaserPathManager";
|
|
10
13
|
import { Emitter } from "../emitter";
|
|
11
14
|
export declare const ExcalidrawContainerContext: React.Context<{
|
|
12
15
|
container: HTMLDivElement | null;
|
|
13
16
|
id?: string | null | undefined;
|
|
14
17
|
}>;
|
|
18
|
+
export declare const useApp: () => AppClassProperties;
|
|
19
|
+
export declare const useAppProps: () => AppProps;
|
|
15
20
|
export declare const useDevice: () => Readonly<{
|
|
16
21
|
isSmScreen: boolean;
|
|
17
22
|
isMobile: boolean;
|
|
18
23
|
isTouchScreen: boolean;
|
|
19
24
|
canDeviceFitSidebar: boolean;
|
|
25
|
+
isLandscape: boolean;
|
|
20
26
|
}>;
|
|
21
27
|
export declare const useExcalidrawContainer: () => {
|
|
22
28
|
container: HTMLDivElement | null;
|
|
@@ -28,7 +34,8 @@ export declare const useExcalidrawSetAppState: () => <K extends keyof AppState>(
|
|
|
28
34
|
export declare const useExcalidrawActionManager: () => ActionManager;
|
|
29
35
|
declare class App extends React.Component<AppProps, AppState> {
|
|
30
36
|
canvas: AppClassProperties["canvas"];
|
|
31
|
-
|
|
37
|
+
interactiveCanvas: AppClassProperties["interactiveCanvas"];
|
|
38
|
+
rc: RoughCanvas;
|
|
32
39
|
unmounted: boolean;
|
|
33
40
|
actionManager: ActionManager;
|
|
34
41
|
device: Device;
|
|
@@ -36,35 +43,31 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
36
43
|
private excalidrawContainerRef;
|
|
37
44
|
static defaultProps: Partial<AppProps>;
|
|
38
45
|
scene: Scene;
|
|
46
|
+
renderer: Renderer;
|
|
39
47
|
private fonts;
|
|
40
48
|
private resizeObserver;
|
|
41
49
|
private nearestScrollableContainer;
|
|
42
50
|
library: AppClassProperties["library"];
|
|
43
51
|
libraryItemsFromStorage: LibraryItems | undefined;
|
|
44
|
-
|
|
52
|
+
id: string;
|
|
45
53
|
private history;
|
|
46
54
|
private excalidrawContainerValue;
|
|
47
55
|
files: BinaryFiles;
|
|
48
56
|
imageCache: AppClassProperties["imageCache"];
|
|
57
|
+
private iFrameRefs;
|
|
49
58
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
|
60
|
+
lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
|
61
|
+
lastViewportPosition: {
|
|
53
62
|
x: number;
|
|
54
63
|
y: number;
|
|
55
|
-
}
|
|
64
|
+
};
|
|
65
|
+
laserPathManager: LaserPathManager;
|
|
56
66
|
onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
|
|
57
67
|
onPointerDownEmitter: Emitter<[activeTool: {
|
|
58
|
-
|
|
59
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
68
|
+
lastActiveTool: import("../types").ActiveTool | null;
|
|
60
69
|
locked: boolean;
|
|
61
|
-
|
|
62
|
-
} | {
|
|
63
|
-
type: "custom";
|
|
64
|
-
customType: string;
|
|
65
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
66
|
-
locked: boolean;
|
|
67
|
-
}, pointerDownState: Readonly<{
|
|
70
|
+
} & import("../types").ActiveTool, pointerDownState: Readonly<{
|
|
68
71
|
origin: Readonly<{
|
|
69
72
|
x: number;
|
|
70
73
|
y: number;
|
|
@@ -130,18 +133,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
130
133
|
erase: boolean;
|
|
131
134
|
};
|
|
132
135
|
};
|
|
133
|
-
}>, event: React.PointerEvent<
|
|
136
|
+
}>, event: React.PointerEvent<HTMLElement>]>;
|
|
134
137
|
onPointerUpEmitter: Emitter<[activeTool: {
|
|
135
|
-
|
|
136
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
138
|
+
lastActiveTool: import("../types").ActiveTool | null;
|
|
137
139
|
locked: boolean;
|
|
138
|
-
|
|
139
|
-
} | {
|
|
140
|
-
type: "custom";
|
|
141
|
-
customType: string;
|
|
142
|
-
lastActiveToolBeforeEraser: import("../types").LastActiveToolBeforeEraser;
|
|
143
|
-
locked: boolean;
|
|
144
|
-
}, pointerDownState: Readonly<{
|
|
140
|
+
} & import("../types").ActiveTool, pointerDownState: Readonly<{
|
|
145
141
|
origin: Readonly<{
|
|
146
142
|
x: number;
|
|
147
143
|
y: number;
|
|
@@ -209,11 +205,23 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
209
205
|
};
|
|
210
206
|
}>, event: PointerEvent]>;
|
|
211
207
|
constructor(props: AppProps);
|
|
212
|
-
private
|
|
208
|
+
private onWindowMessage;
|
|
209
|
+
private updateEmbeddableRef;
|
|
210
|
+
private getHTMLIFrameElement;
|
|
211
|
+
private handleEmbeddableCenterClick;
|
|
212
|
+
private isEmbeddableCenter;
|
|
213
|
+
private updateEmbeddables;
|
|
214
|
+
private renderEmbeddables;
|
|
215
|
+
private getFrameNameDOMId;
|
|
216
|
+
frameNameBoundsCache: FrameNameBoundsCache;
|
|
217
|
+
private renderFrameNames;
|
|
213
218
|
render(): JSX.Element;
|
|
214
219
|
focusContainer: AppClassProperties["focusContainer"];
|
|
215
220
|
getSceneElementsIncludingDeleted: () => readonly ExcalidrawElement[];
|
|
216
221
|
getSceneElements: () => readonly NonDeletedExcalidrawElement[];
|
|
222
|
+
onInsertElements: (elements: readonly ExcalidrawElement[]) => void;
|
|
223
|
+
onExportImage: (type: keyof typeof EXPORT_IMAGE_TYPES, elements: readonly NonDeletedExcalidrawElement[]) => Promise<void>;
|
|
224
|
+
private openEyeDropper;
|
|
217
225
|
private syncActionResult;
|
|
218
226
|
private onBlur;
|
|
219
227
|
private onUnload;
|
|
@@ -233,23 +241,53 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
233
241
|
private onFontsLoadingDone;
|
|
234
242
|
private addEventListeners;
|
|
235
243
|
componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
|
|
236
|
-
private
|
|
244
|
+
private renderInteractiveSceneCallback;
|
|
237
245
|
private onScroll;
|
|
238
246
|
private onCut;
|
|
239
247
|
private onCopy;
|
|
240
248
|
private cutAll;
|
|
241
249
|
private copyAll;
|
|
242
250
|
private static resetTapTwice;
|
|
243
|
-
private
|
|
244
|
-
private
|
|
251
|
+
private onTouchStart;
|
|
252
|
+
private onTouchEnd;
|
|
245
253
|
pasteFromClipboard: (event: ClipboardEvent | null) => Promise<void>;
|
|
246
254
|
private addElementsFromPasteOrLibrary;
|
|
255
|
+
private addElementsFromMixedContentPaste;
|
|
247
256
|
private addTextFromPaste;
|
|
248
257
|
setAppState: React.Component<any, AppState>["setState"];
|
|
249
258
|
removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
|
|
250
259
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
251
|
-
|
|
252
|
-
|
|
260
|
+
updateFrameRendering: (opts: Partial<{
|
|
261
|
+
enabled: boolean;
|
|
262
|
+
name: boolean;
|
|
263
|
+
outline: boolean;
|
|
264
|
+
clip: boolean;
|
|
265
|
+
}> | ((prevState: AppState["frameRendering"]) => Partial<AppState["frameRendering"]>)) => void;
|
|
266
|
+
togglePenMode: (force?: boolean) => void;
|
|
267
|
+
onHandToolToggle: () => void;
|
|
268
|
+
/**
|
|
269
|
+
* Zooms on canvas viewport center
|
|
270
|
+
*/
|
|
271
|
+
zoomCanvas: (value: number) => void;
|
|
272
|
+
private cancelInProgresAnimation;
|
|
273
|
+
scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[], opts?: {
|
|
274
|
+
fitToContent?: boolean;
|
|
275
|
+
fitToViewport?: never;
|
|
276
|
+
viewportZoomFactor?: never;
|
|
277
|
+
animate?: boolean;
|
|
278
|
+
duration?: number;
|
|
279
|
+
} | {
|
|
280
|
+
fitToContent?: never;
|
|
281
|
+
fitToViewport?: boolean;
|
|
282
|
+
/** when fitToViewport=true, how much screen should the content cover,
|
|
283
|
+
* between 0.1 (10%) and 1 (100%)
|
|
284
|
+
*/
|
|
285
|
+
viewportZoomFactor?: number;
|
|
286
|
+
animate?: boolean;
|
|
287
|
+
duration?: number;
|
|
288
|
+
}) => void;
|
|
289
|
+
/** use when changing scrollX/scrollY/zoom based on user interaction */
|
|
290
|
+
private translateCanvas;
|
|
253
291
|
setToast: (toast: {
|
|
254
292
|
message: string;
|
|
255
293
|
closable?: boolean;
|
|
@@ -268,12 +306,26 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
268
306
|
/**
|
|
269
307
|
* @returns whether the menu was toggled on or off
|
|
270
308
|
*/
|
|
271
|
-
|
|
309
|
+
toggleSidebar: ({ name, tab, force, }: {
|
|
310
|
+
name: SidebarName;
|
|
311
|
+
tab?: string | undefined;
|
|
312
|
+
force?: boolean | undefined;
|
|
313
|
+
}) => boolean;
|
|
272
314
|
private updateCurrentCursorPosition;
|
|
273
315
|
private onKeyDown;
|
|
274
316
|
private onWheel;
|
|
275
317
|
private onKeyUp;
|
|
276
|
-
|
|
318
|
+
setActiveTool: (tool: (({
|
|
319
|
+
type: Exclude<ToolType, "image">;
|
|
320
|
+
} | {
|
|
321
|
+
type: Extract<ToolType, "image">;
|
|
322
|
+
insertOnCanvasDirectly?: boolean;
|
|
323
|
+
}) | {
|
|
324
|
+
type: "custom";
|
|
325
|
+
customType: string;
|
|
326
|
+
}) & {
|
|
327
|
+
locked?: boolean;
|
|
328
|
+
}) => void;
|
|
277
329
|
private setCursor;
|
|
278
330
|
private resetCursor;
|
|
279
331
|
/**
|
|
@@ -295,6 +347,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
295
347
|
private handleCanvasDoubleClick;
|
|
296
348
|
private getElementLinkAtPosition;
|
|
297
349
|
private redirectToLink;
|
|
350
|
+
private getTopLayerFrameAtSceneCoords;
|
|
298
351
|
private handleCanvasPointerMove;
|
|
299
352
|
private handleEraser;
|
|
300
353
|
private handleTouchMove;
|
|
@@ -317,9 +370,14 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
317
370
|
private isHittingCommonBoundingBoxOfSelectedElements;
|
|
318
371
|
private handleTextOnPointerDown;
|
|
319
372
|
private handleFreeDrawElementOnPointerDown;
|
|
373
|
+
private insertEmbeddableElement;
|
|
320
374
|
private createImageElement;
|
|
321
375
|
private handleLinearElementOnPointerDown;
|
|
376
|
+
private getCurrentItemRoundness;
|
|
322
377
|
private createGenericElementOnPointerDown;
|
|
378
|
+
private createFrameElementOnPointerDown;
|
|
379
|
+
private maybeCacheReferenceSnapPoints;
|
|
380
|
+
private maybeCacheVisibleGaps;
|
|
323
381
|
private onKeyDownFromPointerDownHandler;
|
|
324
382
|
private onKeyUpFromPointerDownHandler;
|
|
325
383
|
private onPointerMoveFromPointerDownHandler;
|
|
@@ -348,7 +406,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
348
406
|
private maybeSuggestBindingsForLinearElementAtCoords;
|
|
349
407
|
private maybeSuggestBindingForAll;
|
|
350
408
|
private clearSelection;
|
|
351
|
-
private
|
|
409
|
+
private handleInteractiveCanvasRef;
|
|
352
410
|
private handleAppOnDrop;
|
|
353
411
|
loadFileToCanvas: (file: File, fileHandle: FileSystemHandle | null) => Promise<void>;
|
|
354
412
|
private handleCanvasContextMenu;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import "./Button.scss";
|
|
3
2
|
interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
4
3
|
type?: "button" | "submit" | "reset";
|
|
5
4
|
onSelect: () => any;
|
|
5
|
+
/** whether button is in active state */
|
|
6
|
+
selected?: boolean;
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
className?: string;
|
|
8
9
|
}
|
|
@@ -11,5 +12,5 @@ interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
|
11
12
|
* Style can be customised using `className` or `style` prop.
|
|
12
13
|
* Accepts all props that a regular `button` element accepts.
|
|
13
14
|
*/
|
|
14
|
-
export declare const Button: ({ type, onSelect, children, className, ...rest }: ButtonProps) => JSX.Element;
|
|
15
|
+
export declare const Button: ({ type, onSelect, selected, children, className, ...rest }: ButtonProps) => JSX.Element;
|
|
15
16
|
export {};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
export declare const ButtonIconSelect: <T extends Object>(
|
|
1
|
+
export declare const ButtonIconSelect: <T extends Object>(props: {
|
|
2
2
|
options: {
|
|
3
3
|
value: T;
|
|
4
4
|
text: string;
|
|
5
5
|
icon: JSX.Element;
|
|
6
6
|
testId?: string | undefined;
|
|
7
|
+
/** if not supplied, defaults to value identity check */
|
|
8
|
+
active?: boolean | undefined;
|
|
7
9
|
}[];
|
|
8
10
|
value: T | null;
|
|
9
|
-
|
|
11
|
+
type?: "button" | "radio" | undefined;
|
|
12
|
+
} & ({
|
|
13
|
+
type?: "radio" | undefined;
|
|
10
14
|
group: string;
|
|
11
|
-
|
|
15
|
+
onChange: (value: T) => void;
|
|
16
|
+
} | {
|
|
17
|
+
type: "button";
|
|
18
|
+
onClick: (value: T, event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
19
|
+
})) => JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColorPickerType } from "./colorPickerUtils";
|
|
2
|
+
interface ColorInputProps {
|
|
3
|
+
color: string;
|
|
4
|
+
onChange: (color: string) => void;
|
|
5
|
+
label: string;
|
|
6
|
+
colorPickerType: ColorPickerType;
|
|
7
|
+
}
|
|
8
|
+
export declare const ColorInput: ({ color, onChange, label, colorPickerType, }: ColorInputProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ExcalidrawElement } from "../../element/types";
|
|
2
|
+
import { AppState } from "../../types";
|
|
3
|
+
import { ColorPickerType } from "./colorPickerUtils";
|
|
4
|
+
import { ColorTuple, ColorPaletteCustom } from "../../colors";
|
|
5
|
+
import "./ColorPicker.scss";
|
|
6
|
+
export declare const getColor: (color: string) => string | null;
|
|
7
|
+
interface ColorPickerProps {
|
|
8
|
+
type: ColorPickerType;
|
|
9
|
+
color: string;
|
|
10
|
+
onChange: (color: string) => void;
|
|
11
|
+
label: string;
|
|
12
|
+
elements: readonly ExcalidrawElement[];
|
|
13
|
+
appState: AppState;
|
|
14
|
+
palette?: ColorPaletteCustom | null;
|
|
15
|
+
topPicks?: ColorTuple;
|
|
16
|
+
updateData: (formData?: any) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const ColorPicker: ({ type, color, onChange, label, elements, palette, topPicks, updateData, appState, }: ColorPickerProps) => JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface HotkeyLabelProps {
|
|
2
|
+
color: string;
|
|
3
|
+
keyLabel: string | number;
|
|
4
|
+
isCustomColor?: boolean;
|
|
5
|
+
isShade?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const HotkeyLabel: ({ color, keyLabel, isCustomColor, isShade, }: HotkeyLabelProps) => JSX.Element;
|
|
8
|
+
export default HotkeyLabel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import { ColorPickerType } from "./colorPickerUtils";
|
|
4
|
+
import { ColorPaletteCustom } from "../../colors";
|
|
5
|
+
interface PickerProps {
|
|
6
|
+
color: string;
|
|
7
|
+
onChange: (color: string) => void;
|
|
8
|
+
label: string;
|
|
9
|
+
type: ColorPickerType;
|
|
10
|
+
elements: readonly ExcalidrawElement[];
|
|
11
|
+
palette: ColorPaletteCustom;
|
|
12
|
+
updateData: (formData?: any) => void;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
onEyeDropperToggle: (force?: boolean) => void;
|
|
15
|
+
onEscape: (event: React.KeyboardEvent | KeyboardEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const Picker: ({ color, onChange, label, type, elements, palette, updateData, children, onEyeDropperToggle, onEscape, }: PickerProps) => JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColorPaletteCustom } from "../../colors";
|
|
2
|
+
interface PickerColorListProps {
|
|
3
|
+
palette: ColorPaletteCustom;
|
|
4
|
+
color: string;
|
|
5
|
+
onChange: (color: string) => void;
|
|
6
|
+
label: string;
|
|
7
|
+
activeShade: number;
|
|
8
|
+
}
|
|
9
|
+
declare const PickerColorList: ({ palette, color, onChange, label, activeShade, }: PickerColorListProps) => JSX.Element;
|
|
10
|
+
export default PickerColorList;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColorPaletteCustom } from "../../colors";
|
|
2
|
+
interface ShadeListProps {
|
|
3
|
+
hex: string;
|
|
4
|
+
onChange: (color: string) => void;
|
|
5
|
+
palette: ColorPaletteCustom;
|
|
6
|
+
}
|
|
7
|
+
export declare const ShadeList: ({ hex, onChange, palette }: ShadeListProps) => JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColorPickerType } from "./colorPickerUtils";
|
|
2
|
+
interface TopPicksProps {
|
|
3
|
+
onChange: (color: string) => void;
|
|
4
|
+
type: ColorPickerType;
|
|
5
|
+
activeColor: string;
|
|
6
|
+
topPicks?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const TopPicks: ({ onChange, type, activeColor, topPicks, }: TopPicksProps) => JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ExcalidrawElement } from "../../element/types";
|
|
2
|
+
import { ColorPickerColor, ColorPaletteCustom } from "../../colors";
|
|
3
|
+
export declare const getColorNameAndShadeFromColor: ({ palette, color, }: {
|
|
4
|
+
palette: ColorPaletteCustom;
|
|
5
|
+
color: string;
|
|
6
|
+
}) => {
|
|
7
|
+
colorName: ColorPickerColor;
|
|
8
|
+
shade: number | null;
|
|
9
|
+
} | null;
|
|
10
|
+
export declare const colorPickerHotkeyBindings: string[];
|
|
11
|
+
export declare const isCustomColor: ({ color, palette, }: {
|
|
12
|
+
color: string;
|
|
13
|
+
palette: ColorPaletteCustom;
|
|
14
|
+
}) => boolean;
|
|
15
|
+
export declare const getMostUsedCustomColors: (elements: readonly ExcalidrawElement[], type: "elementBackground" | "elementStroke", palette: ColorPaletteCustom) => string[];
|
|
16
|
+
export type ActiveColorPickerSectionAtomType = "custom" | "baseColors" | "shades" | "hex" | null;
|
|
17
|
+
export declare const activeColorPickerSectionAtom: import("jotai").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
|
|
18
|
+
init: ActiveColorPickerSectionAtomType;
|
|
19
|
+
};
|
|
20
|
+
export declare const getContrastYIQ: (bgHex: string, isCustomColor: boolean) => "white" | "black";
|
|
21
|
+
export type ColorPickerType = "canvasBackground" | "elementBackground" | "elementStroke";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColorPaletteCustom } from "../../colors";
|
|
2
|
+
import { ActiveColorPickerSectionAtomType } from "./colorPickerUtils";
|
|
3
|
+
interface ColorPickerKeyNavHandlerProps {
|
|
4
|
+
event: React.KeyboardEvent;
|
|
5
|
+
activeColorPickerSection: ActiveColorPickerSectionAtomType;
|
|
6
|
+
palette: ColorPaletteCustom;
|
|
7
|
+
color: string;
|
|
8
|
+
onChange: (color: string) => void;
|
|
9
|
+
customColors: string[];
|
|
10
|
+
setActiveColorPickerSection: (update: React.SetStateAction<ActiveColorPickerSectionAtomType>) => void;
|
|
11
|
+
updateData: (formData?: any) => void;
|
|
12
|
+
activeShade: number;
|
|
13
|
+
onEyeDropperToggle: (force?: boolean) => void;
|
|
14
|
+
onEscape: (event: React.KeyboardEvent | KeyboardEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @returns true if the event was handled
|
|
18
|
+
*/
|
|
19
|
+
export declare const colorPickerKeyNavHandler: ({ event, activeColorPickerSection, palette, color, onChange, customColors, setActiveColorPickerSection, updateData, activeShade, onEyeDropperToggle, onEscape, }: ColorPickerKeyNavHandlerProps) => boolean;
|
|
20
|
+
export {};
|
|
@@ -2,9 +2,9 @@ import "./ContextMenu.scss";
|
|
|
2
2
|
import { Action } from "../actions/types";
|
|
3
3
|
import { ActionManager } from "../actions/manager";
|
|
4
4
|
import React from "react";
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
|
|
5
|
+
export type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action;
|
|
6
|
+
export type ContextMenuItems = (ContextMenuItem | false | null | undefined)[];
|
|
7
|
+
type ContextMenuProps = {
|
|
8
8
|
actionManager: ActionManager;
|
|
9
9
|
items: ContextMenuItems;
|
|
10
10
|
top: number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MarkOptional } from "../utility-types";
|
|
2
|
+
import { SidebarProps, SidebarTriggerProps } from "./Sidebar/common";
|
|
3
|
+
export declare const DefaultSidebar: import("react").FC<Omit<MarkOptional<Omit<{
|
|
4
|
+
name: string;
|
|
5
|
+
children: import("react").ReactNode;
|
|
6
|
+
onStateChange?: ((state: {
|
|
7
|
+
name: string;
|
|
8
|
+
tab?: string | undefined;
|
|
9
|
+
} | null) => void) | undefined;
|
|
10
|
+
onDock?: ((docked: boolean) => void) | undefined;
|
|
11
|
+
docked?: boolean | undefined;
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
__fallback?: boolean | undefined;
|
|
14
|
+
}, "name">, "children">, "onDock"> & {
|
|
15
|
+
/** pass `false` to disable docking */
|
|
16
|
+
onDock?: SidebarProps["onDock"] | false;
|
|
17
|
+
} & {
|
|
18
|
+
__fallback?: boolean | undefined;
|
|
19
|
+
}> & {
|
|
20
|
+
Trigger: import("react").FC<Omit<SidebarTriggerProps, "name"> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
21
|
+
__fallback?: boolean | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
TabTriggers: {
|
|
24
|
+
({ children, ...rest }: {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
} & import("react").HTMLAttributes<HTMLDivElement>): JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./Dialog.scss";
|
|
3
|
-
|
|
3
|
+
export type DialogSize = number | "small" | "regular" | "wide" | undefined;
|
|
4
4
|
export interface DialogProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
className?: string;
|
|
7
|
-
|
|
7
|
+
size?: DialogSize;
|
|
8
8
|
onCloseRequest(): void;
|
|
9
|
-
title: React.ReactNode;
|
|
9
|
+
title: React.ReactNode | false;
|
|
10
10
|
autofocus?: boolean;
|
|
11
|
-
theme?: AppState["theme"];
|
|
12
11
|
closeOnClickOutside?: boolean;
|
|
13
12
|
}
|
|
14
13
|
export declare const Dialog: (props: DialogProps) => JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./ExcalidrawLogo.scss";
|
|
2
|
+
type LogoSize = "xs" | "small" | "normal" | "large" | "custom";
|
|
3
|
+
interface LogoProps {
|
|
4
|
+
size?: LogoSize;
|
|
5
|
+
withText?: boolean;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
/**
|
|
8
|
+
* If true, the logo will not be wrapped in a Link component.
|
|
9
|
+
* The link prop will be ignored as well.
|
|
10
|
+
* It will merely be a plain div.
|
|
11
|
+
*/
|
|
12
|
+
isNotLink?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const ExcalidrawLogo: ({ style, size, withText, }: LogoProps) => JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./EyeDropper.scss";
|
|
3
|
+
import { ColorPickerType } from "./ColorPicker/colorPickerUtils";
|
|
4
|
+
import { ExcalidrawElement } from "../element/types";
|
|
5
|
+
export type EyeDropperProperties = {
|
|
6
|
+
keepOpenOnAlt: boolean;
|
|
7
|
+
swapPreviewOnAlt?: boolean;
|
|
8
|
+
/** called when user picks color (on pointerup) */
|
|
9
|
+
onSelect: (color: string, event: PointerEvent) => void;
|
|
10
|
+
/**
|
|
11
|
+
* property of selected elements to update live when alt-dragging.
|
|
12
|
+
* Supply `null` if not applicable (e.g. updating the canvas bg instead of
|
|
13
|
+
* elements)
|
|
14
|
+
**/
|
|
15
|
+
colorPickerType: ColorPickerType;
|
|
16
|
+
};
|
|
17
|
+
export declare const activeEyeDropperAtom: import("jotai").PrimitiveAtom<EyeDropperProperties | null> & {
|
|
18
|
+
init: EyeDropperProperties | null;
|
|
19
|
+
};
|
|
20
|
+
export declare const EyeDropper: React.FC<{
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
onSelect: EyeDropperProperties["onSelect"];
|
|
23
|
+
/** called when color changes, on pointerdown for preview */
|
|
24
|
+
onChange: (type: ColorPickerType, color: string, selectedElements: ExcalidrawElement[], event: {
|
|
25
|
+
altKey: boolean;
|
|
26
|
+
}) => void;
|
|
27
|
+
colorPickerType: EyeDropperProperties["colorPickerType"];
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./FilledButton.scss";
|
|
3
|
+
export type ButtonVariant = "filled" | "outlined" | "icon";
|
|
4
|
+
export type ButtonColor = "primary" | "danger" | "warning" | "muted";
|
|
5
|
+
export type ButtonSize = "medium" | "large";
|
|
6
|
+
export type FilledButtonProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
variant?: ButtonVariant;
|
|
11
|
+
color?: ButtonColor;
|
|
12
|
+
size?: ButtonSize;
|
|
13
|
+
className?: string;
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
startIcon?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const FilledButton: React.ForwardRefExoticComponent<FilledButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppClassProperties, Device, UIAppState } from "../types";
|
|
2
2
|
import "./HintViewer.scss";
|
|
3
|
-
import { AppState, Device } from "../types";
|
|
4
3
|
interface HintViewerProps {
|
|
5
|
-
appState:
|
|
6
|
-
elements: readonly NonDeletedExcalidrawElement[];
|
|
4
|
+
appState: UIAppState;
|
|
7
5
|
isMobile: boolean;
|
|
8
6
|
device: Device;
|
|
7
|
+
app: AppClassProperties;
|
|
9
8
|
}
|
|
10
|
-
export declare const HintViewer: ({ appState,
|
|
9
|
+
export declare const HintViewer: ({ appState, isMobile, device, app, }: HintViewerProps) => JSX.Element | null;
|
|
11
10
|
export {};
|