@dwelle/excalidraw 0.4.0-d68dd48 → 0.4.0-e03b600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +4 -0
- package/dist/excalidraw.development.js +1314 -248
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +2 -2
- package/types/actions/actionAddToLibrary.d.ts +36 -12
- package/types/actions/actionAlign.d.ts +6 -0
- package/types/actions/actionBoundText.d.ts +24 -8
- package/types/actions/actionCanvas.d.ts +235 -41
- package/types/actions/actionClipboard.d.ts +60 -20
- package/types/actions/actionDeleteSelected.d.ts +36 -12
- package/types/actions/actionElementLock.d.ts +254 -0
- package/types/actions/actionExport.d.ts +109 -37
- package/types/actions/actionFinalize.d.ts +24 -8
- package/types/actions/actionFlip.d.ts +2 -4
- package/types/actions/actionFrame.d.ts +397 -0
- package/types/actions/actionGroup.d.ts +2 -2
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +12 -4
- package/types/actions/actionMenu.d.ts +37 -14
- package/types/actions/actionNavigate.d.ts +1 -1
- package/types/actions/actionProperties.d.ts +158 -54
- package/types/actions/actionStyles.d.ts +12 -4
- package/types/actions/actionToggleGridMode.d.ts +12 -4
- package/types/actions/actionToggleStats.d.ts +12 -4
- package/types/actions/actionToggleViewMode.d.ts +12 -4
- package/types/actions/actionToggleZenMode.d.ts +12 -4
- package/types/actions/actionZindex.d.ts +4 -4
- package/types/actions/index.d.ts +1 -1
- package/types/actions/manager.d.ts +1 -1
- package/types/actions/shortcuts.d.ts +1 -1
- package/types/actions/types.d.ts +7 -7
- package/types/appState.d.ts +6 -3
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +2 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +5 -5
- package/types/components/ActiveConfirmDialog.d.ts +1 -21
- package/types/components/App.d.ts +32 -9
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/Button.d.ts +3 -1
- package/types/components/ColorPicker/ColorInput.d.ts +7 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
- package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
- package/types/components/ColorPicker/Picker.d.ts +18 -0
- package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
- package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/types/components/ColorPicker/ShadeList.d.ts +8 -0
- package/types/components/ColorPicker/TopPicks.d.ts +9 -0
- package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +21 -0
- package/types/components/ContextMenu.d.ts +3 -3
- package/types/components/DefaultSidebar.d.ts +30 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/EyeDropper.d.ts +18 -0
- package/types/components/FilledButton.d.ts +17 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +1 -1
- package/types/components/HelpButton.d.ts +1 -1
- package/types/components/HintViewer.d.ts +2 -2
- package/types/components/HomeButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +8 -13
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +4 -4
- package/types/components/LayerUI.d.ts +4 -10
- package/types/components/LibraryMenu.d.ts +13 -14
- package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +9 -0
- package/types/components/LibraryMenuHeaderContent.d.ts +11 -28
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +7 -3
- package/types/components/LockButton.d.ts +1 -1
- package/types/components/MobileMenu.d.ts +4 -4
- package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
- package/types/components/PasteChartDialog.d.ts +4 -5
- package/types/components/PenModeButton.d.ts +1 -1
- package/types/components/Popover.d.ts +1 -1
- package/types/components/ProjectName.d.ts +2 -1
- package/types/components/PublishLibrary.d.ts +2 -2
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Sidebar/Sidebar.d.ts +66 -63
- package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
- package/types/components/Sidebar/SidebarTab.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +7 -0
- package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/types/components/Sidebar/common.d.ts +24 -7
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Stats.d.ts +3 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +5 -4
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +8 -0
- package/types/components/dropdownMenu/DropdownMenu.d.ts +3 -2
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +4 -2
- package/types/components/footer/Footer.d.ts +2 -2
- package/types/components/icons.d.ts +11 -1
- package/types/components/main-menu/MainMenu.d.ts +3 -2
- package/types/constants.d.ts +42 -6
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +2 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +2 -2
- package/types/data/types.d.ts +3 -5
- package/types/element/Hyperlink.d.ts +14 -6
- package/types/element/binding.d.ts +3 -3
- package/types/element/bounds.d.ts +31 -6
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +2 -1
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +13 -5
- package/types/element/mutateElement.d.ts +1 -1
- package/types/element/newElement.d.ts +10 -3
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/textElement.d.ts +3 -2
- package/types/element/transformHandles.d.ts +12 -5
- package/types/element/typeChecks.d.ts +2 -1
- package/types/element/types.d.ts +40 -35
- package/types/emitter.d.ts +1 -1
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +40 -0
- package/types/ga.d.ts +5 -5
- package/types/groups.d.ts +4 -0
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -1
- package/types/hooks/useScrollPosition.d.ts +2 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +2 -2
- package/types/jotai.d.ts +16 -104
- package/types/keys.d.ts +2 -1
- package/types/math.d.ts +1 -0
- package/types/packages/excalidraw/example/initialData.d.ts +6 -0
- package/types/packages/excalidraw/index.d.ts +2 -1
- package/types/packages/utils.d.ts +2 -2
- package/types/renderer/renderElement.d.ts +4 -3
- package/types/renderer/renderScene.d.ts +12 -3
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Scene.d.ts +12 -5
- package/types/scene/export.d.ts +3 -2
- package/types/scene/selection.d.ts +15 -5
- package/types/scene/types.d.ts +4 -4
- package/types/types.d.ts +91 -52
- package/types/utility-types.d.ts +13 -13
- package/types/utils.d.ts +20 -25
- package/types/zindex.d.ts +4 -4
- package/types/actions/actionToggleLock.d.ts +0 -119
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/context/tunnels.d.ts +0 -16
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
|
@@ -13,10 +13,11 @@ export interface ExcalidrawElementWithCanvas {
|
|
|
13
13
|
canvasOffsetX: number;
|
|
14
14
|
canvasOffsetY: number;
|
|
15
15
|
boundTextElementVersion: number | null;
|
|
16
|
+
containingFrameOpacity: number;
|
|
16
17
|
}
|
|
17
18
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
type ElementShape = Drawable | Drawable[] | null;
|
|
20
|
+
type ElementShapes = {
|
|
20
21
|
freedraw: Drawable | null;
|
|
21
22
|
arrow: Drawable[];
|
|
22
23
|
line: Drawable[];
|
|
@@ -29,7 +30,7 @@ export declare const invalidateShapeForElement: (element: ExcalidrawElement) =>
|
|
|
29
30
|
export declare const clearRenderCache: () => void;
|
|
30
31
|
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
31
32
|
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
|
|
32
|
-
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean) => void;
|
|
33
|
+
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null) => void;
|
|
33
34
|
export declare let pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
|
|
34
35
|
export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
|
|
35
36
|
export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
2
|
import { RoughSVG } from "roughjs/bin/svg";
|
|
3
|
-
import { AppState, BinaryFiles } from "../types";
|
|
4
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
3
|
+
import { AppState, BinaryFiles, Zoom } from "../types";
|
|
4
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
|
+
import "canvas-roundrect-polyfill";
|
|
6
7
|
export declare const DEFAULT_SPACING = 2;
|
|
7
8
|
export declare const _renderScene: ({ elements, appState, rc, canvas, renderConfig, }: {
|
|
8
9
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
@@ -32,8 +33,16 @@ export declare const renderScene: <T extends boolean = false>(config: {
|
|
|
32
33
|
atLeastOneVisibleElement: boolean;
|
|
33
34
|
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
34
35
|
};
|
|
35
|
-
export declare const
|
|
36
|
+
export declare const isVisibleElement: (element: ExcalidrawElement, canvasWidth: number, canvasHeight: number, viewTransformations: {
|
|
37
|
+
zoom: Zoom;
|
|
38
|
+
offsetLeft: number;
|
|
39
|
+
offsetTop: number;
|
|
40
|
+
scrollX: number;
|
|
41
|
+
scrollY: number;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, }?: {
|
|
36
44
|
offsetX?: number | undefined;
|
|
37
45
|
offsetY?: number | undefined;
|
|
38
46
|
exportWithDarkMode?: boolean | undefined;
|
|
47
|
+
exportingFrameId?: string | null | undefined;
|
|
39
48
|
}) => void;
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* @param {Number} height The height of the rectangle
|
|
9
9
|
* @param {Number} radius The corner radius
|
|
10
10
|
*/
|
|
11
|
-
export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number) => void;
|
|
11
|
+
export declare const roundRect: (context: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, strokeColor?: string) => void;
|
package/types/scene/Scene.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "../element/types";
|
|
1
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
|
|
2
2
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
|
|
4
|
+
type ElementKey = ExcalidrawElement | ElementIdKey;
|
|
5
|
+
type SceneStateCallback = () => void;
|
|
6
|
+
type SceneStateCallbackRemover = () => void;
|
|
7
|
+
export type ExcalidrawElementsIncludingDeleted = readonly ExcalidrawElement[];
|
|
7
8
|
declare class Scene {
|
|
8
9
|
private static sceneMapByElement;
|
|
9
10
|
private static sceneMapById;
|
|
@@ -12,9 +13,13 @@ declare class Scene {
|
|
|
12
13
|
private callbacks;
|
|
13
14
|
private nonDeletedElements;
|
|
14
15
|
private elements;
|
|
16
|
+
private nonDeletedFrames;
|
|
17
|
+
private frames;
|
|
15
18
|
private elementsMap;
|
|
16
19
|
getElementsIncludingDeleted(): readonly ExcalidrawElement[];
|
|
17
20
|
getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
|
|
21
|
+
getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
|
|
22
|
+
getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
|
|
18
23
|
getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
|
|
19
24
|
getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
|
|
20
25
|
/**
|
|
@@ -35,6 +40,8 @@ declare class Scene {
|
|
|
35
40
|
addCallback(cb: SceneStateCallback): SceneStateCallbackRemover;
|
|
36
41
|
destroy(): void;
|
|
37
42
|
insertElementAtIndex(element: ExcalidrawElement, index: number): void;
|
|
43
|
+
insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
|
|
44
|
+
addNewElement: (element: ExcalidrawElement) => void;
|
|
38
45
|
getElementIndex(elementId: string): number;
|
|
39
46
|
}
|
|
40
47
|
export default Scene;
|
package/types/scene/export.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { NonDeletedExcalidrawElement, Theme } from "../element/types";
|
|
|
2
2
|
import { AppState, BinaryFiles } from "../types";
|
|
3
3
|
import { serializeAsJSON } from "../data/json";
|
|
4
4
|
export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
|
|
5
|
-
export
|
|
5
|
+
export type ExportToCanvasData = {
|
|
6
6
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
7
7
|
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
8
|
files: BinaryFiles | null;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type ExportToCanvasConfig = {
|
|
11
11
|
theme?: Theme;
|
|
12
12
|
/**
|
|
13
13
|
* Canvas background. Valid values are:
|
|
@@ -160,6 +160,7 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
160
160
|
viewBackgroundColor: string;
|
|
161
161
|
exportWithDarkMode?: boolean;
|
|
162
162
|
exportEmbedScene?: boolean;
|
|
163
|
+
renderFrame?: boolean;
|
|
163
164
|
}, files: BinaryFiles | null, opts?: {
|
|
164
165
|
serializeAsJSON?: () => string;
|
|
165
166
|
}) => Promise<SVGSVGElement>;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
2
|
import { AppState } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Frames and their containing elements are not to be selected at the same time.
|
|
5
|
+
* Given an array of selected elements, if there are frames and their containing elements
|
|
6
|
+
* we only keep the frames.
|
|
7
|
+
* @param selectedElements
|
|
8
|
+
*/
|
|
9
|
+
export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
|
|
10
|
+
export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
|
|
11
|
+
export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">) => boolean;
|
|
5
12
|
/**
|
|
6
13
|
* Returns common attribute (picked by `getAttribute` callback) of selected
|
|
7
14
|
* elements. If elements don't share the same value, returns `null`.
|
|
8
15
|
*/
|
|
9
|
-
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: AppState, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
10
|
-
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState,
|
|
11
|
-
|
|
16
|
+
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
17
|
+
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, opts?: {
|
|
18
|
+
includeBoundTextElement?: boolean;
|
|
19
|
+
includeElementsInFrames?: boolean;
|
|
20
|
+
}) => ExcalidrawElement[];
|
|
21
|
+
export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
|
package/types/scene/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawTextElement } from "../element/types";
|
|
2
2
|
import { AppClassProperties, AppState } from "../types";
|
|
3
|
-
export
|
|
3
|
+
export type RenderConfig = {
|
|
4
4
|
scrollX: AppState["scrollX"];
|
|
5
5
|
scrollY: AppState["scrollY"];
|
|
6
6
|
/** null indicates transparent bg */
|
|
@@ -43,15 +43,15 @@ export declare type RenderConfig = {
|
|
|
43
43
|
isExporting: boolean;
|
|
44
44
|
selectionColor?: string;
|
|
45
45
|
};
|
|
46
|
-
export
|
|
46
|
+
export type SceneScroll = {
|
|
47
47
|
scrollX: number;
|
|
48
48
|
scrollY: number;
|
|
49
49
|
};
|
|
50
50
|
export interface Scene {
|
|
51
51
|
elements: ExcalidrawTextElement[];
|
|
52
52
|
}
|
|
53
|
-
export
|
|
54
|
-
export
|
|
53
|
+
export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
|
|
54
|
+
export type ScrollBars = {
|
|
55
55
|
horizontal: {
|
|
56
56
|
x: number;
|
|
57
57
|
y: number;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement } from "./element/types";
|
|
2
3
|
import { SHAPES } from "./shapes";
|
|
3
4
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
4
5
|
import { LinearElementEditor } from "./element/linearElementEditor";
|
|
@@ -13,12 +14,11 @@ import { isOverScrollBars } from "./scene";
|
|
|
13
14
|
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
14
15
|
import Library from "./data/library";
|
|
15
16
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
16
|
-
import type {
|
|
17
|
+
import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
17
18
|
import { ContextMenuItems } from "./components/ContextMenu";
|
|
18
|
-
import { Merge, ForwardRef } from "./utility-types";
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
export declare type Collaborator = {
|
|
19
|
+
import { Merge, ForwardRef, ValueOf } from "./utility-types";
|
|
20
|
+
export type Point = Readonly<RoughPoint>;
|
|
21
|
+
export type Collaborator = {
|
|
22
22
|
pointer?: {
|
|
23
23
|
x: number;
|
|
24
24
|
y: number;
|
|
@@ -34,11 +34,11 @@ export declare type Collaborator = {
|
|
|
34
34
|
avatarUrl?: string;
|
|
35
35
|
id?: string;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
37
|
+
export type DataURL = string & {
|
|
38
38
|
_brand: "DataURL";
|
|
39
39
|
};
|
|
40
|
-
export
|
|
41
|
-
mimeType: typeof
|
|
40
|
+
export type BinaryFileData = {
|
|
41
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
|
|
42
42
|
id: FileId;
|
|
43
43
|
dataURL: DataURL;
|
|
44
44
|
/**
|
|
@@ -54,16 +54,18 @@ export declare type BinaryFileData = {
|
|
|
54
54
|
*/
|
|
55
55
|
lastRetrieved?: number;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
type: typeof SHAPES[number]["value"] | "eraser" | "hand";
|
|
57
|
+
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
58
|
+
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
59
|
+
export type LastActiveTool = {
|
|
60
|
+
type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame";
|
|
61
61
|
customType: null;
|
|
62
62
|
} | {
|
|
63
63
|
type: "custom";
|
|
64
64
|
customType: string;
|
|
65
65
|
} | null;
|
|
66
|
-
export
|
|
66
|
+
export type SidebarName = string;
|
|
67
|
+
export type SidebarTabName = string;
|
|
68
|
+
export type AppState = {
|
|
67
69
|
contextMenu: {
|
|
68
70
|
items: ContextMenuItems;
|
|
69
71
|
top: number;
|
|
@@ -79,6 +81,10 @@ export declare type AppState = {
|
|
|
79
81
|
isBindingEnabled: boolean;
|
|
80
82
|
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
|
81
83
|
suggestedBindings: SuggestedBinding[];
|
|
84
|
+
frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
|
|
85
|
+
shouldRenderFrames: boolean;
|
|
86
|
+
editingFrame: string | null;
|
|
87
|
+
elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
|
|
82
88
|
editingElement: NonDeletedExcalidrawElement | null;
|
|
83
89
|
editingLinearElement: LinearElementEditor | null;
|
|
84
90
|
activeTool: {
|
|
@@ -89,7 +95,7 @@ export declare type AppState = {
|
|
|
89
95
|
lastActiveTool: LastActiveTool;
|
|
90
96
|
locked: boolean;
|
|
91
97
|
} & ({
|
|
92
|
-
type: typeof SHAPES[number]["value"] | "eraser" | "hand";
|
|
98
|
+
type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame";
|
|
93
99
|
customType: null;
|
|
94
100
|
} | {
|
|
95
101
|
type: "custom";
|
|
@@ -124,10 +130,20 @@ export declare type AppState = {
|
|
|
124
130
|
isRotating: boolean;
|
|
125
131
|
zoom: Zoom;
|
|
126
132
|
openMenu: "canvas" | "shape" | null;
|
|
127
|
-
openPopup: "
|
|
128
|
-
openSidebar:
|
|
133
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
|
|
134
|
+
openSidebar: {
|
|
135
|
+
name: SidebarName;
|
|
136
|
+
tab?: SidebarTabName;
|
|
137
|
+
} | null;
|
|
129
138
|
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
130
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Reflects user preference for whether the default sidebar should be docked.
|
|
141
|
+
*
|
|
142
|
+
* NOTE this is only a user preference and does not reflect the actual docked
|
|
143
|
+
* state of the sidebar, because the host apps can override this through
|
|
144
|
+
* a DefaultSidebar prop, which is not reflected back to the appState.
|
|
145
|
+
*/
|
|
146
|
+
defaultSidebarDockedPreference: boolean;
|
|
131
147
|
lastPointerDownWith: PointerType;
|
|
132
148
|
selectedElementIds: {
|
|
133
149
|
[id: string]: boolean;
|
|
@@ -135,6 +151,7 @@ export declare type AppState = {
|
|
|
135
151
|
previousSelectedElementIds: {
|
|
136
152
|
[id: string]: boolean;
|
|
137
153
|
};
|
|
154
|
+
selectedElementsAreBeingDragged: boolean;
|
|
138
155
|
shouldCacheIgnoreZoom: boolean;
|
|
139
156
|
toast: {
|
|
140
157
|
message: string;
|
|
@@ -172,17 +189,18 @@ export declare type AppState = {
|
|
|
172
189
|
showHyperlinkPopup: false | "info" | "editor";
|
|
173
190
|
selectedLinearElement: LinearElementEditor | null;
|
|
174
191
|
};
|
|
175
|
-
export
|
|
192
|
+
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
|
193
|
+
export type NormalizedZoomValue = number & {
|
|
176
194
|
_brand: "normalizedZoom";
|
|
177
195
|
};
|
|
178
|
-
export
|
|
196
|
+
export type Zoom = Readonly<{
|
|
179
197
|
value: NormalizedZoomValue;
|
|
180
198
|
}>;
|
|
181
|
-
export
|
|
199
|
+
export type PointerCoords = Readonly<{
|
|
182
200
|
x: number;
|
|
183
201
|
y: number;
|
|
184
202
|
}>;
|
|
185
|
-
export
|
|
203
|
+
export type Gesture = {
|
|
186
204
|
pointers: Map<number, PointerCoords>;
|
|
187
205
|
lastCenter: {
|
|
188
206
|
x: number;
|
|
@@ -196,11 +214,11 @@ export declare class GestureEvent extends UIEvent {
|
|
|
196
214
|
readonly scale: number;
|
|
197
215
|
}
|
|
198
216
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
199
|
-
export
|
|
217
|
+
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
200
218
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
201
|
-
|
|
219
|
+
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
202
220
|
/** v2 library item */
|
|
203
|
-
export
|
|
221
|
+
export type LibraryItem = {
|
|
204
222
|
id: string;
|
|
205
223
|
status: "published" | "unpublished";
|
|
206
224
|
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
@@ -209,14 +227,14 @@ export declare type LibraryItem = {
|
|
|
209
227
|
name?: string;
|
|
210
228
|
error?: string;
|
|
211
229
|
};
|
|
212
|
-
export
|
|
213
|
-
export
|
|
214
|
-
export
|
|
215
|
-
export
|
|
230
|
+
export type LibraryItems = readonly LibraryItem[];
|
|
231
|
+
export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
|
232
|
+
export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
|
|
233
|
+
export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
|
|
216
234
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
217
235
|
ready?: false;
|
|
218
236
|
};
|
|
219
|
-
export
|
|
237
|
+
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
220
238
|
scrollX?: number;
|
|
221
239
|
scrollY?: number;
|
|
222
240
|
libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
|
|
@@ -240,7 +258,7 @@ export interface ExcalidrawProps {
|
|
|
240
258
|
pointersMap: Gesture["pointers"];
|
|
241
259
|
}) => void;
|
|
242
260
|
onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
|
|
243
|
-
renderTopRightUI?: (isMobile: boolean, appState:
|
|
261
|
+
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
244
262
|
langCode?: Language["code"];
|
|
245
263
|
viewModeEnabled?: boolean;
|
|
246
264
|
zenModeEnabled?: boolean;
|
|
@@ -248,7 +266,7 @@ export interface ExcalidrawProps {
|
|
|
248
266
|
libraryReturnUrl?: string;
|
|
249
267
|
theme?: Theme;
|
|
250
268
|
name?: string;
|
|
251
|
-
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState:
|
|
269
|
+
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
252
270
|
UIOptions?: Partial<UIOptions>;
|
|
253
271
|
detectScroll?: boolean;
|
|
254
272
|
handleKeyboardGlobally?: boolean;
|
|
@@ -256,17 +274,13 @@ export interface ExcalidrawProps {
|
|
|
256
274
|
autoFocus?: boolean;
|
|
257
275
|
generateIdForFile?: (file: File) => string | Promise<string>;
|
|
258
276
|
onLinkOpen?: (element: NonDeletedExcalidrawElement, event: CustomEvent<{
|
|
259
|
-
nativeEvent: MouseEvent | React.PointerEvent<
|
|
277
|
+
nativeEvent: MouseEvent | React.PointerEvent<HTMLElement>;
|
|
260
278
|
}>) => void;
|
|
261
279
|
onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
|
|
262
280
|
onScrollChange?: (scrollX: number, scrollY: number) => void;
|
|
263
|
-
/**
|
|
264
|
-
* Render function that renders custom <Sidebar /> component.
|
|
265
|
-
*/
|
|
266
|
-
renderSidebar?: () => JSX.Element | null;
|
|
267
281
|
children?: React.ReactNode;
|
|
268
282
|
}
|
|
269
|
-
export
|
|
283
|
+
export type SceneData = {
|
|
270
284
|
elements?: ImportedDataState["elements"];
|
|
271
285
|
appState?: ImportedDataState["appState"];
|
|
272
286
|
collaborators?: Map<string, Collaborator>;
|
|
@@ -277,12 +291,12 @@ export declare enum UserIdleState {
|
|
|
277
291
|
AWAY = "away",
|
|
278
292
|
IDLE = "idle"
|
|
279
293
|
}
|
|
280
|
-
export
|
|
294
|
+
export type ExportOpts = {
|
|
281
295
|
saveFileToDisk?: boolean;
|
|
282
|
-
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
283
|
-
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState:
|
|
296
|
+
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
|
|
297
|
+
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
|
|
284
298
|
};
|
|
285
|
-
|
|
299
|
+
type CanvasActions = Partial<{
|
|
286
300
|
changeViewBackgroundColor: boolean;
|
|
287
301
|
clearCanvas: boolean;
|
|
288
302
|
export: false | ExportOpts;
|
|
@@ -291,13 +305,13 @@ declare type CanvasActions = Partial<{
|
|
|
291
305
|
toggleTheme: boolean | null;
|
|
292
306
|
saveAsImage: boolean;
|
|
293
307
|
}>;
|
|
294
|
-
|
|
308
|
+
type UIOptions = Partial<{
|
|
295
309
|
dockedSidebarBreakpoint: number;
|
|
296
310
|
canvasActions: CanvasActions;
|
|
297
311
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
298
312
|
welcomeScreen?: boolean;
|
|
299
313
|
}>;
|
|
300
|
-
export
|
|
314
|
+
export type AppProps = Merge<ExcalidrawProps, {
|
|
301
315
|
UIOptions: Merge<UIOptions, {
|
|
302
316
|
canvasActions: Required<CanvasActions> & {
|
|
303
317
|
export: ExportOpts;
|
|
@@ -310,21 +324,25 @@ export declare type AppProps = Merge<ExcalidrawProps, {
|
|
|
310
324
|
}>;
|
|
311
325
|
/** A subset of App class properties that we need to use elsewhere
|
|
312
326
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
313
|
-
export
|
|
327
|
+
export type AppClassProperties = {
|
|
314
328
|
props: AppProps;
|
|
315
329
|
canvas: HTMLCanvasElement | null;
|
|
316
330
|
focusContainer(): void;
|
|
317
331
|
library: Library;
|
|
318
332
|
imageCache: Map<FileId, {
|
|
319
333
|
image: HTMLImageElement | Promise<HTMLImageElement>;
|
|
320
|
-
mimeType: typeof
|
|
334
|
+
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
321
335
|
}>;
|
|
322
336
|
files: BinaryFiles;
|
|
323
337
|
device: App["device"];
|
|
324
338
|
scene: App["scene"];
|
|
325
339
|
pasteFromClipboard: App["pasteFromClipboard"];
|
|
340
|
+
id: App["id"];
|
|
341
|
+
onInsertElements: App["onInsertElements"];
|
|
342
|
+
onExportImage: App["onExportImage"];
|
|
343
|
+
lastViewportPosition: App["lastViewportPosition"];
|
|
326
344
|
};
|
|
327
|
-
export
|
|
345
|
+
export type PointerDownState = Readonly<{
|
|
328
346
|
origin: Readonly<{
|
|
329
347
|
x: number;
|
|
330
348
|
y: number;
|
|
@@ -383,8 +401,8 @@ export declare type PointerDownState = Readonly<{
|
|
|
383
401
|
};
|
|
384
402
|
};
|
|
385
403
|
}>;
|
|
386
|
-
|
|
387
|
-
export
|
|
404
|
+
type UnsubscribeCallback = () => void;
|
|
405
|
+
export type ExcalidrawImperativeAPI = {
|
|
388
406
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
389
407
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
390
408
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
@@ -405,16 +423,37 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
405
423
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
406
424
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
407
425
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
408
|
-
|
|
426
|
+
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
409
427
|
app: InstanceType<typeof App>;
|
|
410
428
|
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
411
|
-
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<
|
|
429
|
+
onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
|
|
412
430
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
431
|
+
/**
|
|
432
|
+
* Disables rendering of frames (including element clipping), but currently
|
|
433
|
+
* the frames are still interactive in edit mode. As such, this API should be
|
|
434
|
+
* used in conjunction with view mode (props.viewModeEnabled).
|
|
435
|
+
*/
|
|
436
|
+
toggleFrameRendering: InstanceType<typeof App>["toggleFrameRendering"];
|
|
413
437
|
};
|
|
414
|
-
export
|
|
438
|
+
export type Device = Readonly<{
|
|
415
439
|
isSmScreen: boolean;
|
|
416
440
|
isMobile: boolean;
|
|
417
441
|
isTouchScreen: boolean;
|
|
418
442
|
canDeviceFitSidebar: boolean;
|
|
443
|
+
isLandscape: boolean;
|
|
419
444
|
}>;
|
|
445
|
+
type FrameNameBounds = {
|
|
446
|
+
x: number;
|
|
447
|
+
y: number;
|
|
448
|
+
width: number;
|
|
449
|
+
height: number;
|
|
450
|
+
angle: number;
|
|
451
|
+
};
|
|
452
|
+
export type FrameNameBoundsCache = {
|
|
453
|
+
get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
|
|
454
|
+
_cache: Map<string, FrameNameBounds & {
|
|
455
|
+
zoom: AppState["zoom"]["value"];
|
|
456
|
+
versionNonce: ExcalidrawFrameElement["versionNonce"];
|
|
457
|
+
}>;
|
|
458
|
+
};
|
|
420
459
|
export {};
|
package/types/utility-types.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export type Mutable<T> = {
|
|
3
3
|
-readonly [P in keyof T]: T[P];
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type ValueOf<T> = T[keyof T];
|
|
6
|
+
export type Merge<M, N> = Omit<M, keyof N> & N;
|
|
7
7
|
/** utility type to assert that the second type is a subtype of the first type.
|
|
8
8
|
* Returns the subtype. */
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
9
|
+
export type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
|
|
10
|
+
export type ResolutionType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
11
|
+
export type MarkOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
12
|
+
export type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
|
|
13
|
+
export type MarkNonNullable<T, K extends keyof T> = {
|
|
14
14
|
[P in K]-?: P extends K ? NonNullable<T[P]> : T[P];
|
|
15
15
|
} & {
|
|
16
16
|
[P in keyof T]: T[P];
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
18
|
+
export type NonOptional<T> = Exclude<T, undefined>;
|
|
19
|
+
export type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
|
|
20
|
+
export type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
|
|
21
|
+
export type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
|
|
22
|
+
export type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { EVENT } from "./constants";
|
|
2
|
-
import { FontFamilyValues, FontString } from "./element/types";
|
|
2
|
+
import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
|
|
3
3
|
import { AppState, LastActiveTool, Zoom } from "./types";
|
|
4
4
|
import { SHAPES } from "./shapes";
|
|
5
5
|
export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
6
6
|
export declare const getDateTime: () => string;
|
|
7
7
|
export declare const capitalizeString: (str: string) => string;
|
|
8
8
|
export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
|
|
9
|
-
export declare const isInputLike: (target: Element | EventTarget | null) => target is
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
|
|
10
|
+
export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
|
|
11
|
+
export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
|
|
11
12
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
12
13
|
fontFamily: FontFamilyValues;
|
|
13
14
|
}) => string;
|
|
@@ -28,42 +29,34 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
|
|
|
28
29
|
flush(): void;
|
|
29
30
|
cancel(): void;
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* use `opts` to define a duration and/or an easeFn
|
|
36
|
-
*
|
|
37
|
-
* for example:
|
|
38
|
-
* ```ts
|
|
39
|
-
* easeToValuesRAF([10, 20, 10], [0, 0, 0], (a, b, c) => setState(a,b, c))
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param fromValues The initial values, must be numeric
|
|
43
|
-
* @param toValues The destination values, must also be numeric
|
|
44
|
-
* @param callback The callback receiving the values
|
|
45
|
-
* @param opts default to 250ms duration and the easeOut function
|
|
46
|
-
*/
|
|
47
|
-
export declare const easeToValuesRAF: (fromValues: number[], toValues: number[], callback: (...values: number[]) => void, opts?: {
|
|
32
|
+
export declare const easeToValuesRAF: <T extends Record<keyof T, number>>({ fromValues, toValues, onStep, duration, easeFn, onStart, onEnd, onCancel, }: {
|
|
33
|
+
fromValues: T;
|
|
34
|
+
toValues: T;
|
|
35
|
+
onStep: (values: T) => void;
|
|
48
36
|
duration?: number | undefined;
|
|
49
37
|
easeFn?: ((value: number) => number) | undefined;
|
|
50
|
-
|
|
38
|
+
onStart?: (() => void) | undefined;
|
|
39
|
+
onEnd?: (() => void) | undefined;
|
|
40
|
+
onCancel?: (() => void) | undefined;
|
|
41
|
+
}) => () => void;
|
|
51
42
|
export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
|
|
52
43
|
export declare const selectNode: (node: Element) => void;
|
|
53
44
|
export declare const removeSelection: () => void;
|
|
54
45
|
export declare const distance: (x: number, y: number) => number;
|
|
55
46
|
export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
|
|
56
|
-
type: (typeof SHAPES)[number]["value"] | "eraser" | "hand";
|
|
47
|
+
type: (typeof SHAPES)[number]["value"] | "eraser" | "hand" | "frame";
|
|
48
|
+
locked?: boolean;
|
|
57
49
|
} | {
|
|
58
50
|
type: "custom";
|
|
59
51
|
customType: string;
|
|
52
|
+
locked?: boolean;
|
|
60
53
|
}) & {
|
|
61
54
|
lastActiveToolBeforeEraser?: LastActiveTool;
|
|
62
55
|
}) => AppState["activeTool"];
|
|
63
56
|
export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
|
|
64
57
|
export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
|
|
65
58
|
export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
|
|
66
|
-
export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
|
|
59
|
+
export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
|
|
67
60
|
export declare const isFullScreen: () => boolean;
|
|
68
61
|
export declare const allowFullScreen: () => Promise<void>;
|
|
69
62
|
export declare const exitFullScreen: () => Promise<void>;
|
|
@@ -111,7 +104,7 @@ export declare const muteFSAbortError: (error?: Error) => void;
|
|
|
111
104
|
export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
112
105
|
export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
|
|
113
106
|
export declare const isTransparent: (color: string) => boolean;
|
|
114
|
-
export
|
|
107
|
+
export type ResolvablePromise<T> = Promise<T> & {
|
|
115
108
|
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
|
116
109
|
reject: (error: Error) => void;
|
|
117
110
|
};
|
|
@@ -154,9 +147,11 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
|
|
|
154
147
|
export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
|
|
155
148
|
export declare const isPrimitive: (val: any) => boolean;
|
|
156
149
|
export declare const getFrame: () => "top" | "iframe";
|
|
150
|
+
export declare const isRunningInIframe: () => boolean;
|
|
157
151
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
158
152
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
159
|
-
export declare const isShallowEqual: <T extends Record<string, any
|
|
153
|
+
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;
|
|
160
154
|
export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
|
|
161
155
|
checkForDefaultPrevented?: boolean | undefined;
|
|
162
156
|
}) => (event: E) => void;
|
|
157
|
+
export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|