@dwelle/excalidraw 0.4.0-d8d86cf → 0.4.0-e3bee83
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 +189 -0
- package/README.md +417 -19
- package/dist/excalidraw.development.js +427 -229
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +21 -9
- package/types/actions/actionAlign.d.ts +6 -18
- package/types/actions/actionBoundText.d.ts +9 -5
- package/types/actions/actionCanvas.d.ts +69 -45
- package/types/actions/actionClipboard.d.ts +54 -16
- package/types/actions/actionDeleteSelected.d.ts +22 -12
- package/types/actions/actionDistribute.d.ts +2 -6
- package/types/actions/actionDuplicateSelection.d.ts +1 -3
- package/types/actions/actionExport.d.ts +72 -51
- package/types/actions/actionFinalize.d.ts +15 -9
- package/types/actions/actionFlip.d.ts +2 -2
- package/types/actions/actionGroup.d.ts +4 -8
- package/types/actions/actionLinearEditor.d.ts +8 -4
- package/types/actions/actionMenu.d.ts +24 -17
- package/types/actions/actionNavigate.d.ts +2 -3
- package/types/actions/actionProperties.d.ts +106 -80
- package/types/actions/actionStyles.d.ts +7 -3
- package/types/actions/actionToggleGridMode.d.ts +9 -3
- package/types/actions/actionToggleLock.d.ts +7 -3
- package/types/actions/actionToggleStats.d.ts +8 -3
- package/types/actions/actionToggleViewMode.d.ts +9 -3
- package/types/actions/actionToggleZenMode.d.ts +9 -3
- package/types/actions/actionZindex.d.ts +4 -12
- package/types/actions/manager.d.ts +2 -1
- package/types/actions/types.d.ts +6 -5
- package/types/appState.d.ts +3 -4
- package/types/components/App.d.ts +7 -50
- package/types/components/Button.d.ts +15 -0
- package/types/components/Card.d.ts +7 -0
- package/types/components/ContextMenu.d.ts +8 -21
- package/types/components/JSONExportDialog.d.ts +3 -1
- package/types/components/LayerUI.d.ts +3 -5
- package/types/components/LibraryMenuHeaderContent.d.ts +23 -0
- package/types/components/MobileMenu.d.ts +5 -8
- package/types/components/UserList.d.ts +0 -2
- package/types/components/dropdownMenu/DropdownMenu.d.ts +64 -0
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +11 -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 +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +12 -0
- package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +9 -0
- package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/types/components/footer/Footer.d.ts +13 -0
- package/types/components/footer/FooterCenter.d.ts +8 -0
- package/types/components/icons.d.ts +1 -1
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +10 -0
- package/types/components/main-menu/DefaultItems.d.ts +47 -0
- package/types/components/main-menu/MainMenu.d.ts +55 -0
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -0
- package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/types/components/welcome-screen/WelcomeScreen.d.ts +85 -0
- package/types/constants.d.ts +11 -8
- package/types/data/index.d.ts +1 -1
- package/types/element/Hyperlink.d.ts +9 -7
- package/types/element/bounds.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +8 -4
- package/types/element/textElement.d.ts +7 -0
- package/types/element/textWysiwyg.d.ts +6 -1
- package/types/element/typeChecks.d.ts +9 -1
- package/types/element/types.d.ts +9 -5
- package/types/keys.d.ts +2 -0
- package/types/math.d.ts +2 -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/index.d.ts +12 -1
- package/types/packages/utils.d.ts +22 -25
- package/types/renderer/renderScene.d.ts +1 -3
- package/types/scene/comparisons.d.ts +1 -1
- package/types/scene/export.d.ts +143 -9
- package/types/scene/index.d.ts +1 -1
- package/types/scene/types.d.ts +9 -1
- package/types/types.d.ts +44 -24
- package/types/utils.d.ts +17 -0
- 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/Footer.d.ts +0 -10
- package/types/components/MenuItem.d.ts +0 -11
- package/types/components/MenuUtils.d.ts +0 -1
- package/types/components/WelcomeScreen.d.ts +0 -10
- package/types/components/WelcomeScreenDecor.d.ts +0 -6
package/types/math.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Point, Zoom } from "./types";
|
|
2
|
-
import { ExcalidrawLinearElement, NonDeleted } from "./element/types";
|
|
2
|
+
import { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./element/types";
|
|
3
3
|
export declare const rotate: (x1: number, y1: number, x2: number, y2: number, angle: number) => [number, number];
|
|
4
4
|
export declare const rotatePoint: (point: readonly [number, number], center: readonly [number, number], angle: number) => [number, number];
|
|
5
5
|
export declare const adjustXYWithRotation: (sides: {
|
|
@@ -18,6 +18,7 @@ export declare const centerPoint: (a: readonly [number, number], b: readonly [nu
|
|
|
18
18
|
export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
|
|
19
19
|
export declare const isPointInPolygon: (points: Point[], x: number, y: number) => boolean;
|
|
20
20
|
export declare const getGridPoint: (x: number, y: number, gridSize: number | null) => [number, number];
|
|
21
|
+
export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
|
|
21
22
|
export declare const getControlPointsForBezierCurve: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number]) => [number, number][] | null;
|
|
22
23
|
export declare const getBezierXY: (p0: readonly [number, number], p1: readonly [number, number], p2: readonly [number, number], p3: readonly [number, number], t: number) => number[];
|
|
23
24
|
export declare const getPointsInBezierCurve: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number]) => [number, number][];
|
|
@@ -2,18 +2,29 @@ import React from "react";
|
|
|
2
2
|
import "../../css/app.scss";
|
|
3
3
|
import "../../css/styles.scss";
|
|
4
4
|
import { ExcalidrawAPIRefValue, ExcalidrawProps } from "../../types";
|
|
5
|
+
import Footer from "../../components/footer/FooterCenter";
|
|
6
|
+
import MainMenu from "../../components/main-menu/MainMenu";
|
|
7
|
+
import WelcomeScreen from "../../components/welcome-screen/WelcomeScreen";
|
|
8
|
+
import LiveCollaborationTrigger from "../../components/live-collaboration/LiveCollaborationTrigger";
|
|
5
9
|
declare type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
|
|
6
10
|
export declare const Excalidraw: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
|
|
7
11
|
export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
|
|
8
12
|
export { defaultLang, languages } from "../../i18n";
|
|
9
13
|
export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "../../data/restore";
|
|
10
|
-
export {
|
|
14
|
+
export { exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, loadSceneOrLibraryFromBlob, getFreeDrawSvgPath, exportToClipboard, mergeLibraryItems, } from "../../packages/utils";
|
|
11
15
|
export { isLinearElement } from "../../element/typeChecks";
|
|
12
16
|
export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
|
|
13
17
|
export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
|
|
14
18
|
export { parseLibraryTokensFromUrl, useHandleLibrary, } from "../../data/library";
|
|
15
19
|
export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "../../utils";
|
|
16
20
|
export { Sidebar } from "../../components/Sidebar/Sidebar";
|
|
21
|
+
export { Button } from "../../components/Button";
|
|
22
|
+
export { Footer };
|
|
23
|
+
export { MainMenu };
|
|
24
|
+
export { useDevice } from "../../components/App";
|
|
25
|
+
export { WelcomeScreen };
|
|
26
|
+
export { LiveCollaborationTrigger };
|
|
17
27
|
export { getDefaultAppState, cleanAppStateForExport, clearAppStateForLocalStorage, } from "../../appState";
|
|
18
28
|
export { jotaiScope, jotaiStore } from "../../jotai";
|
|
19
29
|
export { libraryItemsAtom } from "../../data/library";
|
|
30
|
+
export { exportToCanvas } from "../../scene/export";
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExcalidrawElement, NonDeleted } from "../element/types";
|
|
1
|
+
import { ExportToCanvasConfig, ExportToCanvasData } from "../scene/export";
|
|
3
2
|
import { MIME_TYPES } from "../constants";
|
|
4
3
|
export { MIME_TYPES };
|
|
5
|
-
declare type
|
|
6
|
-
elements: readonly NonDeleted<ExcalidrawElement>[];
|
|
7
|
-
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
8
|
-
files: BinaryFiles | null;
|
|
9
|
-
maxWidthOrHeight?: number;
|
|
10
|
-
getDimensions?: (width: number, height: number) => {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
scale?: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const exportToCanvas: ({ elements, appState, files, maxWidthOrHeight, getDimensions, exportPadding, }: ExportOpts & {
|
|
17
|
-
exportPadding?: number | undefined;
|
|
18
|
-
}) => Promise<HTMLCanvasElement>;
|
|
19
|
-
export declare const exportToBlob: (opts: ExportOpts & {
|
|
4
|
+
declare type ExportToBlobConfig = ExportToCanvasConfig & {
|
|
20
5
|
mimeType?: string;
|
|
21
6
|
quality?: number;
|
|
22
|
-
|
|
7
|
+
};
|
|
8
|
+
declare type ExportToSvgConfig = Pick<ExportToCanvasConfig, "canvasBackgroundColor" | "padding" | "theme">;
|
|
9
|
+
export declare const exportToBlob: ({ data, config, }: {
|
|
10
|
+
data: ExportToCanvasData;
|
|
11
|
+
config?: ExportToBlobConfig | undefined;
|
|
23
12
|
}) => Promise<Blob>;
|
|
24
|
-
export declare const exportToSvg: ({
|
|
25
|
-
|
|
13
|
+
export declare const exportToSvg: ({ data, config, }: {
|
|
14
|
+
data: ExportToCanvasData;
|
|
15
|
+
config?: ExportToSvgConfig | undefined;
|
|
26
16
|
}) => Promise<SVGSVGElement>;
|
|
27
|
-
export declare const exportToClipboard: (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: "png"
|
|
31
|
-
|
|
17
|
+
export declare const exportToClipboard: ({ type, data, config, }: {
|
|
18
|
+
data: ExportToCanvasData;
|
|
19
|
+
} & ({
|
|
20
|
+
type: "png";
|
|
21
|
+
config?: ExportToBlobConfig | undefined;
|
|
22
|
+
} | {
|
|
23
|
+
type: "svg";
|
|
24
|
+
config?: ExportToSvgConfig | undefined;
|
|
25
|
+
} | {
|
|
26
|
+
type: "json";
|
|
27
|
+
config?: undefined;
|
|
28
|
+
})) => Promise<void>;
|
|
32
29
|
export { serializeAsJSON, serializeLibraryAsJSON } from "../data/json";
|
|
33
30
|
export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "../data/blob";
|
|
34
31
|
export { getFreeDrawSvgPath } from "../renderer/renderElement";
|
|
@@ -4,10 +4,9 @@ import { AppState, BinaryFiles } from "../types";
|
|
|
4
4
|
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
6
|
export declare const DEFAULT_SPACING = 2;
|
|
7
|
-
export declare const _renderScene: ({ elements, appState,
|
|
7
|
+
export declare const _renderScene: ({ elements, appState, rc, canvas, renderConfig, }: {
|
|
8
8
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
9
9
|
appState: AppState;
|
|
10
|
-
scale: number;
|
|
11
10
|
rc: RoughCanvas;
|
|
12
11
|
canvas: HTMLCanvasElement;
|
|
13
12
|
renderConfig: RenderConfig;
|
|
@@ -22,7 +21,6 @@ export declare const _renderScene: ({ elements, appState, scale, rc, canvas, ren
|
|
|
22
21
|
export declare const renderScene: <T extends boolean = false>(config: {
|
|
23
22
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
24
23
|
appState: AppState;
|
|
25
|
-
scale: number;
|
|
26
24
|
rc: RoughCanvas;
|
|
27
25
|
canvas: HTMLCanvasElement;
|
|
28
26
|
renderConfig: RenderConfig;
|
|
@@ -3,7 +3,7 @@ export declare const hasBackground: (type: string) => boolean;
|
|
|
3
3
|
export declare const hasStrokeColor: (type: string) => boolean;
|
|
4
4
|
export declare const hasStrokeWidth: (type: string) => boolean;
|
|
5
5
|
export declare const hasStrokeStyle: (type: string) => boolean;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const canChangeRoundness: (type: string) => boolean;
|
|
7
7
|
export declare const hasText: (type: string) => boolean;
|
|
8
8
|
export declare const canHaveArrowheads: (type: string) => boolean;
|
|
9
9
|
export declare const getElementAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement | null;
|
package/types/scene/export.d.ts
CHANGED
|
@@ -1,13 +1,147 @@
|
|
|
1
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
1
|
+
import { NonDeletedExcalidrawElement, Theme } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles } from "../types";
|
|
3
3
|
export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
|
|
4
|
-
export declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export declare type ExportToCanvasData = {
|
|
5
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
6
|
+
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
7
|
+
files: BinaryFiles | null;
|
|
8
|
+
};
|
|
9
|
+
export declare type ExportToCanvasConfig = {
|
|
10
|
+
theme?: Theme;
|
|
11
|
+
/**
|
|
12
|
+
* Canvas background. Valid values are:
|
|
13
|
+
*
|
|
14
|
+
* - `undefined` - the background of "appState.viewBackgroundColor" is used.
|
|
15
|
+
* - `false` - no background is used (set to "transparent").
|
|
16
|
+
* - `string` - should be a valid CSS color.
|
|
17
|
+
*
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
canvasBackgroundColor?: string | false;
|
|
21
|
+
/**
|
|
22
|
+
* Canvas padding in pixels. Affected by scale. Ignored if `fit` is set to
|
|
23
|
+
* `cover`.
|
|
24
|
+
*
|
|
25
|
+
* @default 10
|
|
26
|
+
*/
|
|
27
|
+
padding?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Makes sure the canvas content fits into a frame of width/height no larger
|
|
30
|
+
* than this value, while maintaining the aspect ratio.
|
|
31
|
+
*
|
|
32
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
33
|
+
* `scale`.
|
|
34
|
+
*/
|
|
35
|
+
maxWidthOrHeight?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Width of the frame. Supply `x` or `y` if you want to ofsset the canvas
|
|
38
|
+
* content.
|
|
39
|
+
*
|
|
40
|
+
* If `width` omitted but `height` supplied, `width` is calculated from the
|
|
41
|
+
* the content's bounding box to preserve the aspect ratio.
|
|
42
|
+
*
|
|
43
|
+
* Defaults to the content bounding box width when both `width` and `height`
|
|
44
|
+
* are omitted.
|
|
45
|
+
*/
|
|
46
|
+
width?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Height of the frame.
|
|
49
|
+
*
|
|
50
|
+
* If `height` omitted but `width` supplied, `height` is calculated from the
|
|
51
|
+
* content's bounding box to preserve the aspect ratio.
|
|
52
|
+
*
|
|
53
|
+
* Defaults to the content bounding box height when both `width` and `height`
|
|
54
|
+
* are omitted.
|
|
55
|
+
*/
|
|
56
|
+
height?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Left canvas offset. By default the coordinate is relative to the canvas.
|
|
59
|
+
* You can switch to content coordinates by setting `origin` to `content`.
|
|
60
|
+
*
|
|
61
|
+
* Defaults to the `x` postion of the content bounding box.
|
|
62
|
+
*/
|
|
63
|
+
x?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Top canvas offset. By default the coordinate is relative to the canvas.
|
|
66
|
+
* You can switch to content coordinates by setting `origin` to `content`.
|
|
67
|
+
*
|
|
68
|
+
* Defaults to the `y` postion of the content bounding box.
|
|
69
|
+
*/
|
|
70
|
+
y?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Indicates the coordinate system of the `x` and `y` values.
|
|
73
|
+
*
|
|
74
|
+
* - `canvas` - `x` and `y` are relative to the canvas [0, 0] position.
|
|
75
|
+
* - `content` - `x` and `y` are relative to the content bounding box.
|
|
76
|
+
*
|
|
77
|
+
* @default "canvas"
|
|
78
|
+
*/
|
|
79
|
+
origin?: "canvas" | "content";
|
|
80
|
+
/**
|
|
81
|
+
* If dimensions specified and `x` and `y` are not specified, this indicates
|
|
82
|
+
* how the canvas should be scaled.
|
|
83
|
+
*
|
|
84
|
+
* Behavior aligns with the `object-fit` CSS property.
|
|
85
|
+
*
|
|
86
|
+
* - `none` - no scaling.
|
|
87
|
+
* - `contain` - scale to fit the frame.
|
|
88
|
+
* - `cover` - scale to fill the frame while maintaining aspect ratio. If
|
|
89
|
+
* content overflows, it will be cropped.
|
|
90
|
+
*
|
|
91
|
+
* @default "contain" unless `x` or `y` are specified, in which case "none"
|
|
92
|
+
* is used (forced).
|
|
93
|
+
*/
|
|
94
|
+
fit?: "none" | "contain" | "cover";
|
|
95
|
+
/**
|
|
96
|
+
* When either `x` or `y` are not specified, indicates how the canvas should
|
|
97
|
+
* be aligned on the respective axis.
|
|
98
|
+
*
|
|
99
|
+
* - `none` - canvas aligned to top left.
|
|
100
|
+
* - `center` - canvas is centered on the axis which is not specified
|
|
101
|
+
* (or both).
|
|
102
|
+
*
|
|
103
|
+
* @default "center"
|
|
104
|
+
*/
|
|
105
|
+
position?: "center" | "none";
|
|
106
|
+
/**
|
|
107
|
+
* A multiplier to increase/decrease the frame dimensions
|
|
108
|
+
* (content resolution).
|
|
109
|
+
*
|
|
110
|
+
* For example, if your canvas is 300x150 and you set scale to 2, the
|
|
111
|
+
* resulting size will be 600x300.
|
|
112
|
+
*
|
|
113
|
+
* @default 1
|
|
114
|
+
*/
|
|
115
|
+
scale?: number;
|
|
116
|
+
/**
|
|
117
|
+
* If you need to suply your own canvas, e.g. in test environments or in
|
|
118
|
+
* Node.js.
|
|
119
|
+
*
|
|
120
|
+
* Do not set `canvas.width/height` or modify the canvas context as that's
|
|
121
|
+
* handled by Excalidraw.
|
|
122
|
+
*
|
|
123
|
+
* Defaults to `document.createElement("canvas")`.
|
|
124
|
+
*/
|
|
125
|
+
createCanvas?: () => HTMLCanvasElement;
|
|
126
|
+
/**
|
|
127
|
+
* If you want to supply `width`/`height` dynamically (or derive from the
|
|
128
|
+
* content bounding box), you can use this function.
|
|
129
|
+
*
|
|
130
|
+
* Ignored if `maxWidthOrHeight`, `width`, or `height` is set.
|
|
131
|
+
*/
|
|
132
|
+
getDimensions?: (width: number, height: number) => {
|
|
133
|
+
width: number;
|
|
134
|
+
height: number;
|
|
135
|
+
scale?: number;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* This API is usually used as a precursor to searializing to Blob or PNG,
|
|
140
|
+
* but can also be used to create a canvas for other purposes.
|
|
141
|
+
*/
|
|
142
|
+
export declare const exportToCanvas: ({ data, config, }: {
|
|
143
|
+
data: ExportToCanvasData;
|
|
144
|
+
config?: ExportToCanvasConfig | undefined;
|
|
11
145
|
}) => Promise<HTMLCanvasElement>;
|
|
12
146
|
export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElement[], appState: {
|
|
13
147
|
exportBackground: boolean;
|
|
@@ -17,4 +151,4 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
17
151
|
exportWithDarkMode?: boolean;
|
|
18
152
|
exportEmbedScene?: boolean;
|
|
19
153
|
}, files: BinaryFiles | null) => Promise<SVGSVGElement>;
|
|
20
|
-
export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[],
|
|
154
|
+
export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], padding: number, scale: number) => [number, number];
|
package/types/scene/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { isOverScrollBars } from "./scrollbars";
|
|
2
2
|
export { isSomeElementSelected, getElementsWithinSelection, getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, } from "./selection";
|
|
3
3
|
export { calculateScrollCenter } from "./scroll";
|
|
4
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads,
|
|
4
|
+
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, getElementAtPosition, hasText, getElementsAtPosition, } from "./comparisons";
|
|
5
5
|
export { getNormalizedZoom } from "./zoom";
|
package/types/scene/types.d.ts
CHANGED
|
@@ -4,10 +4,18 @@ export declare type RenderConfig = {
|
|
|
4
4
|
scrollX: AppState["scrollX"];
|
|
5
5
|
scrollY: AppState["scrollY"];
|
|
6
6
|
/** null indicates transparent bg */
|
|
7
|
-
|
|
7
|
+
canvasBackgroundColor: AppState["viewBackgroundColor"] | null;
|
|
8
8
|
zoom: AppState["zoom"];
|
|
9
9
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
10
10
|
theme: AppState["theme"];
|
|
11
|
+
/**
|
|
12
|
+
* canvas scale factor. Not related to zoom. In browsers, it's the
|
|
13
|
+
* devicePixelRatio. For export, it's the `appState.exportScale`
|
|
14
|
+
* (user setting) or whatever scale you want to use when exporting elsewhere.
|
|
15
|
+
*
|
|
16
|
+
* Bigger the scale, the more pixels (=quality).
|
|
17
|
+
*/
|
|
18
|
+
canvasScale: number;
|
|
11
19
|
remotePointerViewportCoords: {
|
|
12
20
|
[id: string]: {
|
|
13
21
|
x: number;
|
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme } from "./element/types";
|
|
2
|
+
import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
|
|
3
3
|
import { SHAPES } from "./shapes";
|
|
4
4
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
|
5
5
|
import { LinearElementEditor } from "./element/linearElementEditor";
|
|
@@ -15,6 +15,7 @@ import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
|
15
15
|
import Library from "./data/library";
|
|
16
16
|
import type { FileSystemHandle } from "./data/filesystem";
|
|
17
17
|
import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
|
|
18
|
+
import { ContextMenuItems } from "./components/ContextMenu";
|
|
18
19
|
export declare type Point = Readonly<RoughPoint>;
|
|
19
20
|
export declare type Collaborator = {
|
|
20
21
|
pointer?: {
|
|
@@ -62,6 +63,11 @@ export declare type LastActiveToolBeforeEraser = {
|
|
|
62
63
|
customType: string;
|
|
63
64
|
} | null;
|
|
64
65
|
export declare type AppState = {
|
|
66
|
+
contextMenu: {
|
|
67
|
+
items: ContextMenuItems;
|
|
68
|
+
top: number;
|
|
69
|
+
left: number;
|
|
70
|
+
} | null;
|
|
65
71
|
showWelcomeScreen: boolean;
|
|
66
72
|
isLoading: boolean;
|
|
67
73
|
errorMessage: string | null;
|
|
@@ -101,10 +107,9 @@ export declare type AppState = {
|
|
|
101
107
|
currentItemFontFamily: FontFamilyValues;
|
|
102
108
|
currentItemFontSize: number;
|
|
103
109
|
currentItemTextAlign: TextAlign;
|
|
104
|
-
currentItemStrokeSharpness: ExcalidrawElement["strokeSharpness"];
|
|
105
110
|
currentItemStartArrowhead: Arrowhead | null;
|
|
106
111
|
currentItemEndArrowhead: Arrowhead | null;
|
|
107
|
-
|
|
112
|
+
currentItemRoundness: StrokeRoundness;
|
|
108
113
|
viewBackgroundColor: string;
|
|
109
114
|
scrollX: number;
|
|
110
115
|
scrollY: number;
|
|
@@ -117,7 +122,7 @@ export declare type AppState = {
|
|
|
117
122
|
openMenu: "canvas" | "shape" | null;
|
|
118
123
|
openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
|
|
119
124
|
openSidebar: "library" | "customSidebar" | null;
|
|
120
|
-
openDialog: "imageExport" | "help" | null;
|
|
125
|
+
openDialog: "imageExport" | "help" | "jsonExport" | null;
|
|
121
126
|
isSidebarDocked: boolean;
|
|
122
127
|
lastPointerDownWith: PointerType;
|
|
123
128
|
selectedElementIds: {
|
|
@@ -216,13 +221,11 @@ export interface ExcalidrawProps {
|
|
|
216
221
|
id?: string | null;
|
|
217
222
|
onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, id?: string | null) => void;
|
|
218
223
|
initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
|
|
219
|
-
onHomeButtonClick
|
|
220
|
-
onThemeToggle: (theme: Theme) => void;
|
|
224
|
+
onHomeButtonClick?: () => void;
|
|
221
225
|
user?: {
|
|
222
226
|
name?: string | null;
|
|
223
227
|
};
|
|
224
228
|
excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
|
|
225
|
-
onCollabButtonClick?: () => void;
|
|
226
229
|
isCollaborating?: boolean;
|
|
227
230
|
onPointerUpdate?: (payload: {
|
|
228
231
|
pointer: {
|
|
@@ -234,7 +237,6 @@ export interface ExcalidrawProps {
|
|
|
234
237
|
}) => void;
|
|
235
238
|
onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
|
|
236
239
|
renderTopRightUI?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
237
|
-
renderFooter?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
238
240
|
langCode?: Language["code"];
|
|
239
241
|
viewModeEnabled?: boolean;
|
|
240
242
|
zenModeEnabled?: boolean;
|
|
@@ -243,10 +245,7 @@ export interface ExcalidrawProps {
|
|
|
243
245
|
theme?: Theme;
|
|
244
246
|
name?: string;
|
|
245
247
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => JSX.Element;
|
|
246
|
-
UIOptions?:
|
|
247
|
-
dockedSidebarBreakpoint?: number;
|
|
248
|
-
canvasActions?: CanvasActions;
|
|
249
|
-
};
|
|
248
|
+
UIOptions?: Partial<UIOptions>;
|
|
250
249
|
detectScroll?: boolean;
|
|
251
250
|
handleKeyboardGlobally?: boolean;
|
|
252
251
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -261,6 +260,7 @@ export interface ExcalidrawProps {
|
|
|
261
260
|
* Render function that renders custom <Sidebar /> component.
|
|
262
261
|
*/
|
|
263
262
|
renderSidebar?: () => JSX.Element | null;
|
|
263
|
+
children?: React.ReactNode;
|
|
264
264
|
}
|
|
265
265
|
export declare type SceneData = {
|
|
266
266
|
elements?: ImportedDataState["elements"];
|
|
@@ -278,22 +278,26 @@ export declare type ExportOpts = {
|
|
|
278
278
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
|
|
279
279
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
|
|
280
280
|
};
|
|
281
|
-
declare type CanvasActions = {
|
|
282
|
-
changeViewBackgroundColor
|
|
283
|
-
clearCanvas
|
|
284
|
-
export
|
|
285
|
-
loadScene
|
|
286
|
-
saveToActiveFile
|
|
287
|
-
toggleTheme
|
|
288
|
-
saveAsImage
|
|
289
|
-
}
|
|
281
|
+
declare type CanvasActions = Partial<{
|
|
282
|
+
changeViewBackgroundColor: boolean;
|
|
283
|
+
clearCanvas: boolean;
|
|
284
|
+
export: false | ExportOpts;
|
|
285
|
+
loadScene: boolean;
|
|
286
|
+
saveToActiveFile: boolean;
|
|
287
|
+
toggleTheme: boolean | null;
|
|
288
|
+
saveAsImage: boolean;
|
|
289
|
+
}>;
|
|
290
|
+
declare type UIOptions = Partial<{
|
|
291
|
+
dockedSidebarBreakpoint: number;
|
|
292
|
+
welcomeScreen: boolean;
|
|
293
|
+
canvasActions: CanvasActions;
|
|
294
|
+
}>;
|
|
290
295
|
export declare type AppProps = Merge<ExcalidrawProps, {
|
|
291
|
-
UIOptions: {
|
|
296
|
+
UIOptions: Merge<MarkRequired<UIOptions, "welcomeScreen">, {
|
|
292
297
|
canvasActions: Required<CanvasActions> & {
|
|
293
298
|
export: ExportOpts;
|
|
294
299
|
};
|
|
295
|
-
|
|
296
|
-
};
|
|
300
|
+
}>;
|
|
297
301
|
detectScroll: boolean;
|
|
298
302
|
handleKeyboardGlobally: boolean;
|
|
299
303
|
isCollaborating: boolean;
|
|
@@ -313,6 +317,7 @@ export declare type AppClassProperties = {
|
|
|
313
317
|
files: BinaryFiles;
|
|
314
318
|
device: App["device"];
|
|
315
319
|
scene: App["scene"];
|
|
320
|
+
pasteFromClipboard: App["pasteFromClipboard"];
|
|
316
321
|
};
|
|
317
322
|
export declare type PointerDownState = Readonly<{
|
|
318
323
|
origin: Readonly<{
|
|
@@ -407,4 +412,19 @@ export declare type Device = Readonly<{
|
|
|
407
412
|
isTouchScreen: boolean;
|
|
408
413
|
canDeviceFitSidebar: boolean;
|
|
409
414
|
}>;
|
|
415
|
+
export declare type UIChildrenComponents = {
|
|
416
|
+
[k in "FooterCenter" | "Menu" | "WelcomeScreen"]?: React.ReactElement<{
|
|
417
|
+
children?: React.ReactNode;
|
|
418
|
+
}, React.JSXElementConstructor<any>>;
|
|
419
|
+
};
|
|
420
|
+
export declare type UIWelcomeScreenComponents = {
|
|
421
|
+
[k in "Center" | "MenuHint" | "ToolbarHint" | "HelpHint"]?: React.ReactElement<{
|
|
422
|
+
children?: React.ReactNode;
|
|
423
|
+
}, React.JSXElementConstructor<any>>;
|
|
424
|
+
};
|
|
425
|
+
export declare type UIWelcomeScreenCenterComponents = {
|
|
426
|
+
[k in "Logo" | "Heading" | "Menu" | "MenuItemLoadScene" | "MenuItemHelp"]?: React.ReactElement<{
|
|
427
|
+
children?: React.ReactNode;
|
|
428
|
+
}, React.JSXElementConstructor<any>>;
|
|
429
|
+
};
|
|
410
430
|
export {};
|
package/types/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { EVENT } from "./constants";
|
|
|
2
2
|
import { FontFamilyValues, FontString } from "./element/types";
|
|
3
3
|
import { AppState, LastActiveToolBeforeEraser, Zoom } from "./types";
|
|
4
4
|
import { SHAPES } from "./shapes";
|
|
5
|
+
import React from "react";
|
|
5
6
|
export declare const setDateTimeForTests: (dateTime: string) => void;
|
|
6
7
|
export declare const getDateTime: () => string;
|
|
7
8
|
export declare const capitalizeString: (str: string) => string;
|
|
@@ -134,3 +135,19 @@ export declare const isPrimitive: (val: any) => boolean;
|
|
|
134
135
|
export declare const getFrame: () => "top" | "iframe";
|
|
135
136
|
export declare const isPromiseLike: (value: any) => value is Promise<any>;
|
|
136
137
|
export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
|
|
138
|
+
/**
|
|
139
|
+
* Partitions React children into named components and the rest of children.
|
|
140
|
+
*
|
|
141
|
+
* Returns known children as a dictionary of react children keyed by their
|
|
142
|
+
* displayName, and the rest children as an array.
|
|
143
|
+
*
|
|
144
|
+
* NOTE all named react components are included in the dictionary, irrespective
|
|
145
|
+
* of the supplied type parameter. This means you may be throwing away
|
|
146
|
+
* children that you aren't expecting, but should nonetheless be rendered.
|
|
147
|
+
* To guard against this (provided you care about the rest children at all),
|
|
148
|
+
* supply a second parameter with an object with keys of the expected children.
|
|
149
|
+
*/
|
|
150
|
+
export declare const getReactChildren: <KnownChildren extends {
|
|
151
|
+
[x: string]: React.ReactNode;
|
|
152
|
+
}>(children: React.ReactNode, expectedComponents?: Record<keyof KnownChildren, any> | undefined) => readonly [Partial<KnownChildren>, React.ReactNode[]];
|
|
153
|
+
export declare const isShallowEqual: <T extends Record<string, any>>(objA: T, objB: T) => boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ActionManager } from "../actions/manager";
|
|
2
|
-
import { AppState, ExcalidrawProps } from "../types";
|
|
3
|
-
declare const Footer: ({ appState, actionManager, renderCustomFooter, showExitZenModeBtn, renderWelcomeScreen, }: {
|
|
4
|
-
appState: AppState;
|
|
5
|
-
actionManager: ActionManager;
|
|
6
|
-
renderCustomFooter?: ExcalidrawProps["renderFooter"];
|
|
7
|
-
showExitZenModeBtn: boolean;
|
|
8
|
-
renderWelcomeScreen: boolean;
|
|
9
|
-
}) => JSX.Element;
|
|
10
|
-
export default Footer;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "./Menu.scss";
|
|
2
|
-
interface MenuProps {
|
|
3
|
-
icon: JSX.Element;
|
|
4
|
-
onClick: () => void;
|
|
5
|
-
label: string;
|
|
6
|
-
dataTestId: string;
|
|
7
|
-
shortcut?: string;
|
|
8
|
-
isCollaborating?: boolean;
|
|
9
|
-
}
|
|
10
|
-
declare const MenuItem: ({ icon, onClick, label, dataTestId, shortcut, isCollaborating, }: MenuProps) => JSX.Element;
|
|
11
|
-
export default MenuItem;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Separator: () => JSX.Element;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ActionManager } from "../actions/manager";
|
|
2
|
-
import { AppState } from "../types";
|
|
3
|
-
import { AppProps } from "../types";
|
|
4
|
-
import "./WelcomeScreen.scss";
|
|
5
|
-
declare const WelcomeScreen: ({ appState, actionManager, onCollabButtonClick, }: {
|
|
6
|
-
appState: AppState;
|
|
7
|
-
actionManager: ActionManager;
|
|
8
|
-
onCollabButtonClick: AppProps["onCollabButtonClick"];
|
|
9
|
-
}) => JSX.Element;
|
|
10
|
-
export default WelcomeScreen;
|