@excalidraw/excalidraw 0.15.2-6546-3398d86 → 0.15.2-6690-6186765
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/dist/excalidraw.development.js +213 -191
- package/dist/excalidraw.production.min.js +1 -1
- package/dist/excalidraw.production.min.js.LICENSE.txt +0 -25
- package/package.json +1 -1
- package/types/actions/actionFinalize.d.ts +1 -1
- package/types/actions/actionGroup.d.ts +241 -3
- package/types/actions/actionSelectAll.d.ts +121 -1
- package/types/components/Actions.d.ts +2 -2
- package/types/components/App.d.ts +8 -6
- package/types/components/JSONExportDialog.d.ts +1 -1
- package/types/components/LayerUI.d.ts +3 -2
- package/types/components/MobileMenu.d.ts +2 -2
- package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
- package/types/components/canvases/StaticCanvas.d.ts +18 -0
- package/types/components/canvases/index.d.ts +3 -0
- package/types/element/Hyperlink.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +4 -4
- package/types/element/sizeHelpers.d.ts +8 -1
- package/types/element/textWysiwyg.d.ts +1 -1
- package/types/element/transformHandles.d.ts +2 -2
- package/types/frame.d.ts +3 -3
- package/types/groups.d.ts +11 -11
- package/types/packages/excalidraw/dist/excalidraw.development.d.ts +2 -2
- package/types/packages/excalidraw/webpack.dev.config.d.ts +12 -0
- package/types/packages/excalidraw/webpack.prod.config.d.ts +12 -0
- package/types/renderer/renderElement.d.ts +9 -21
- package/types/renderer/renderScene.d.ts +16 -36
- package/types/scene/Renderer.d.ts +25 -0
- package/types/scene/Scene.d.ts +2 -0
- package/types/scene/Shape.d.ts +12 -0
- package/types/scene/ShapeCache.d.ts +20 -0
- package/types/scene/scroll.d.ts +1 -1
- package/types/scene/scrollbars.d.ts +2 -6
- package/types/scene/selection.d.ts +2 -2
- package/types/scene/types.d.ts +57 -24
- package/types/types.d.ts +43 -3
- package/types/utils.d.ts +11 -4
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "./types";
|
|
2
|
-
import { AppState } from "../types";
|
|
2
|
+
import { AppState, Zoom } from "../types";
|
|
3
3
|
export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
|
|
4
|
+
export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
|
|
5
|
+
zoom: Zoom;
|
|
6
|
+
offsetLeft: number;
|
|
7
|
+
offsetTop: number;
|
|
8
|
+
scrollX: number;
|
|
9
|
+
scrollY: number;
|
|
10
|
+
}) => boolean;
|
|
4
11
|
/**
|
|
5
12
|
* Makes a perfect shape or diagonal/horizontal/vertical line
|
|
6
13
|
*/
|
|
@@ -15,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
|
|
|
15
15
|
}) => void;
|
|
16
16
|
getViewportCoords: (x: number, y: number) => [number, number];
|
|
17
17
|
element: ExcalidrawTextElement;
|
|
18
|
-
canvas: HTMLCanvasElement
|
|
18
|
+
canvas: HTMLCanvasElement;
|
|
19
19
|
excalidrawContainer: HTMLDivElement | null;
|
|
20
20
|
app: App;
|
|
21
21
|
}) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
|
-
import {
|
|
2
|
+
import { InteractiveCanvasAppState, Zoom } from "../types";
|
|
3
3
|
export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
4
4
|
export type TransformHandleType = TransformHandleDirection | "rotation";
|
|
5
5
|
export type TransformHandle = [number, number, number, number];
|
|
@@ -32,4 +32,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
|
|
|
32
32
|
rotation?: boolean | undefined;
|
|
33
33
|
}, margin?: number) => TransformHandles;
|
|
34
34
|
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
|
|
35
|
-
export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState:
|
|
35
|
+
export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
|
package/types/frame.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
-
import { AppClassProperties, AppState } from "./types";
|
|
2
|
+
import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
|
|
3
3
|
import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
|
|
4
4
|
export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
5
5
|
export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
|
|
@@ -36,5 +36,5 @@ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElement
|
|
|
36
36
|
* depending on the appState, return target frame, which is the frame the given element
|
|
37
37
|
* is going to be added to or remove from
|
|
38
38
|
*/
|
|
39
|
-
export declare const getTargetFrame: (element: ExcalidrawElement, appState:
|
|
40
|
-
export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState:
|
|
39
|
+
export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
|
|
40
|
+
export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
|
package/types/groups.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
-
import { AppClassProperties, AppState } from "./types";
|
|
3
|
-
|
|
2
|
+
import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
|
|
3
|
+
import { Mutable } from "./utility-types";
|
|
4
|
+
export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
|
|
5
|
+
export declare const selectGroupsForSelectedElements: {
|
|
6
|
+
(appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
|
|
7
|
+
clearCache(): void;
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* If the element's group is selected, don't render an individual
|
|
6
11
|
* selection border around it.
|
|
7
12
|
*/
|
|
8
|
-
export declare const isSelectedViaGroup: (appState:
|
|
9
|
-
export declare const getSelectedGroupForElement: (appState:
|
|
10
|
-
export declare const getSelectedGroupIds: (appState:
|
|
11
|
-
|
|
12
|
-
* When you select an element, you often want to actually select the whole group it's in, unless
|
|
13
|
-
* you're currently editing that group.
|
|
14
|
-
*/
|
|
15
|
-
export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[], prevAppState: AppState, app: AppClassProperties | null) => AppState;
|
|
16
|
-
export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
|
|
13
|
+
export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
|
|
14
|
+
export declare const getSelectedGroupForElement: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => string | undefined;
|
|
15
|
+
export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
|
|
16
|
+
export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
|
|
17
17
|
[groupId: string]: boolean;
|
|
18
18
|
};
|
|
19
19
|
export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export =
|
|
2
|
-
export =
|
|
1
|
+
export = __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__;
|
|
2
|
+
export = __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__;
|
|
@@ -79,4 +79,16 @@ export const externals: {
|
|
|
79
79
|
commonjs: string;
|
|
80
80
|
amd: string;
|
|
81
81
|
};
|
|
82
|
+
"react-dom/client": {
|
|
83
|
+
root: string;
|
|
84
|
+
commonjs2: string;
|
|
85
|
+
commonjs: string;
|
|
86
|
+
amd: string;
|
|
87
|
+
};
|
|
88
|
+
"react/jsx-runtime": {
|
|
89
|
+
root: string;
|
|
90
|
+
commonjs2: string;
|
|
91
|
+
commonjs: string;
|
|
92
|
+
amd: string;
|
|
93
|
+
};
|
|
82
94
|
};
|
|
@@ -92,4 +92,16 @@ export const externals: {
|
|
|
92
92
|
commonjs: string;
|
|
93
93
|
amd: string;
|
|
94
94
|
};
|
|
95
|
+
"react-dom/client": {
|
|
96
|
+
root: string;
|
|
97
|
+
commonjs2: string;
|
|
98
|
+
commonjs: string;
|
|
99
|
+
amd: string;
|
|
100
|
+
};
|
|
101
|
+
"react/jsx-runtime": {
|
|
102
|
+
root: string;
|
|
103
|
+
commonjs2: string;
|
|
104
|
+
commonjs: string;
|
|
105
|
+
amd: string;
|
|
106
|
+
};
|
|
95
107
|
};
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement } from "../element/types";
|
|
2
|
-
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { AppState, BinaryFiles } from "../types";
|
|
2
|
+
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
3
|
+
import type { RoughSVG } from "roughjs/bin/svg";
|
|
4
|
+
import { StaticCanvasRenderConfig } from "../scene/types";
|
|
5
|
+
import { AppState, StaticCanvasAppState, BinaryFiles, InteractiveCanvasAppState } from "../types";
|
|
7
6
|
export interface ExcalidrawElementWithCanvas {
|
|
8
7
|
element: ExcalidrawElement | ExcalidrawTextElement;
|
|
9
8
|
canvas: HTMLCanvasElement;
|
|
10
|
-
theme:
|
|
9
|
+
theme: AppState["theme"];
|
|
11
10
|
scale: number;
|
|
12
|
-
zoomValue:
|
|
11
|
+
zoomValue: AppState["zoom"]["value"];
|
|
13
12
|
canvasOffsetX: number;
|
|
14
13
|
canvasOffsetY: number;
|
|
15
14
|
boundTextElementVersion: number | null;
|
|
16
15
|
containingFrameOpacity: number;
|
|
17
16
|
}
|
|
18
17
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
arrow: Drawable[];
|
|
23
|
-
line: Drawable[];
|
|
24
|
-
text: null;
|
|
25
|
-
image: null;
|
|
26
|
-
};
|
|
27
|
-
export declare const getShapeForElement: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : Drawable | null | undefined;
|
|
28
|
-
export declare const setShapeForElement: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
|
|
29
|
-
export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
|
|
30
|
-
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
31
|
-
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
|
|
18
|
+
export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
|
|
19
|
+
export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
|
|
20
|
+
export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
|
|
32
21
|
export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null, renderEmbeddables?: boolean) => void;
|
|
33
22
|
export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
|
|
34
23
|
export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
|
|
35
24
|
export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
|
|
36
25
|
export declare function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement): string;
|
|
37
|
-
export {};
|
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
import { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
1
|
import { RoughSVG } from "roughjs/bin/svg";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { BinaryFiles } from "../types";
|
|
3
|
+
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
4
|
+
import { InteractiveSceneRenderConfig, StaticSceneRenderConfig } from "../scene/types";
|
|
6
5
|
import "canvas-roundrect-polyfill";
|
|
7
6
|
export declare const DEFAULT_SPACING = 2;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
canvas: HTMLCanvasElement;
|
|
14
|
-
renderConfig: RenderConfig;
|
|
15
|
-
}) => {
|
|
7
|
+
/**
|
|
8
|
+
* Interactive scene is the ui-canvas where we render boundinb boxes, selections
|
|
9
|
+
* and other ui stuff.
|
|
10
|
+
*/
|
|
11
|
+
export declare const renderInteractiveScene: <U extends ({ canvas, elements, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
|
|
16
12
|
atLeastOneVisibleElement: boolean;
|
|
17
|
-
scrollBars?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
atLeastOneVisibleElement: boolean;
|
|
20
|
-
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
21
|
-
};
|
|
22
|
-
/** renderScene throttled to animation framerate */
|
|
23
|
-
export declare const renderScene: <T extends boolean = false>(config: {
|
|
24
13
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
25
|
-
appState: AppState;
|
|
26
|
-
scale: number;
|
|
27
|
-
rc: RoughCanvas;
|
|
28
|
-
canvas: HTMLCanvasElement;
|
|
29
|
-
renderConfig: RenderConfig;
|
|
30
|
-
callback?: ((data: ReturnType<typeof _renderScene>) => void) | undefined;
|
|
31
|
-
}, throttle?: T | undefined) => T extends true ? void : {
|
|
32
|
-
atLeastOneVisibleElement: boolean;
|
|
33
14
|
scrollBars?: undefined;
|
|
34
15
|
} | {
|
|
35
|
-
atLeastOneVisibleElement: boolean;
|
|
36
16
|
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
atLeastOneVisibleElement: boolean;
|
|
18
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
19
|
+
}, T extends boolean = false>(renderConfig: InteractiveSceneRenderConfig, throttle?: T | undefined) => T extends true ? void : ReturnType<U>;
|
|
20
|
+
/**
|
|
21
|
+
* Static scene is the non-ui canvas where we render elements.
|
|
22
|
+
*/
|
|
23
|
+
export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
|
|
24
|
+
export declare const cancelRender: () => void;
|
|
45
25
|
export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, renderEmbeddables, }?: {
|
|
46
26
|
offsetX?: number | undefined;
|
|
47
27
|
offsetY?: number | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
+
import { AppState } from "../types";
|
|
3
|
+
import Scene from "./Scene";
|
|
4
|
+
export declare class Renderer {
|
|
5
|
+
private scene;
|
|
6
|
+
constructor(scene: Scene);
|
|
7
|
+
getRenderableElements: ((opts: {
|
|
8
|
+
zoom: AppState["zoom"];
|
|
9
|
+
offsetLeft: AppState["offsetLeft"];
|
|
10
|
+
offsetTop: AppState["offsetTop"];
|
|
11
|
+
scrollX: AppState["scrollX"];
|
|
12
|
+
scrollY: AppState["scrollY"];
|
|
13
|
+
height: AppState["height"];
|
|
14
|
+
width: AppState["width"];
|
|
15
|
+
editingElement: AppState["editingElement"];
|
|
16
|
+
pendingImageElementId: AppState["pendingImageElementId"];
|
|
17
|
+
versionNonce: ReturnType<InstanceType<typeof Scene>["getVersionNonce"]>;
|
|
18
|
+
}) => {
|
|
19
|
+
canvasElements: NonDeletedExcalidrawElement[];
|
|
20
|
+
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
21
|
+
}) & {
|
|
22
|
+
clear: () => void;
|
|
23
|
+
};
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
package/types/scene/Scene.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare class Scene {
|
|
|
18
18
|
private frames;
|
|
19
19
|
private elementsMap;
|
|
20
20
|
private selectedElementsCache;
|
|
21
|
+
private versionNonce;
|
|
21
22
|
getElementsIncludingDeleted(): readonly ExcalidrawElement[];
|
|
22
23
|
getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
|
|
23
24
|
getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
|
|
@@ -34,6 +35,7 @@ declare class Scene {
|
|
|
34
35
|
}): NonDeleted<ExcalidrawElement>[];
|
|
35
36
|
getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
|
|
36
37
|
getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
|
|
38
|
+
getVersionNonce(): number | undefined;
|
|
37
39
|
getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
|
|
38
40
|
/**
|
|
39
41
|
* A utility method to help with updating all scene elements, with the added
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Drawable, Options } from "roughjs/bin/core";
|
|
2
|
+
import type { RoughGenerator } from "roughjs/bin/generator";
|
|
3
|
+
import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "../element/types";
|
|
4
|
+
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
5
|
+
/**
|
|
6
|
+
* Generates the roughjs shape for given element.
|
|
7
|
+
*
|
|
8
|
+
* Low-level. Use `ShapeCache.generateElementShape` instead.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare const _generateElementShape: (element: Exclude<NonDeletedExcalidrawElement, ExcalidrawSelectionElement>, generator: RoughGenerator, isExporting?: boolean) => Drawable | Drawable[] | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Drawable } from "roughjs/bin/core";
|
|
2
|
+
import { ExcalidrawElement } from "../element/types";
|
|
3
|
+
import { ElementShape, ElementShapes } from "./types";
|
|
4
|
+
export declare class ShapeCache {
|
|
5
|
+
private static rg;
|
|
6
|
+
private static cache;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves shape from cache if available. Use this only if shape
|
|
9
|
+
* is optional and you have a fallback in case it's not cached.
|
|
10
|
+
*/
|
|
11
|
+
static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
|
|
12
|
+
static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
|
|
13
|
+
static delete: (element: ExcalidrawElement) => boolean;
|
|
14
|
+
static destroy: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Generates & caches shape for element if not already cached, otherwise
|
|
17
|
+
* returns cached shape.
|
|
18
|
+
*/
|
|
19
|
+
static generateElementShape: <T extends import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawEmbeddableElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawFrameElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement>(element: T, isExporting?: boolean) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
|
|
20
|
+
}
|
package/types/scene/scroll.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, }:
|
|
|
11
11
|
scrollX: number;
|
|
12
12
|
scrollY: number;
|
|
13
13
|
};
|
|
14
|
-
export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState
|
|
14
|
+
export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState) => {
|
|
15
15
|
scrollX: number;
|
|
16
16
|
scrollY: number;
|
|
17
17
|
};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "../element/types";
|
|
2
|
-
import {
|
|
2
|
+
import { InteractiveCanvasAppState } from "../types";
|
|
3
3
|
import { ScrollBars } from "./types";
|
|
4
4
|
export declare const SCROLLBAR_MARGIN = 4;
|
|
5
5
|
export declare const SCROLLBAR_WIDTH = 6;
|
|
6
6
|
export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
|
|
7
|
-
export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number,
|
|
8
|
-
scrollX: number;
|
|
9
|
-
scrollY: number;
|
|
10
|
-
zoom: Zoom;
|
|
11
|
-
}) => ScrollBars;
|
|
7
|
+
export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
|
|
12
8
|
export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
|
|
13
9
|
isOverEither: boolean;
|
|
14
10
|
isOverHorizontal: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState } from "../types";
|
|
2
|
+
import { AppState, InteractiveCanvasAppState } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Frames and their containing elements are not to be selected at the same time.
|
|
5
5
|
* Given an array of selected elements, if there are frames and their containing elements
|
|
@@ -17,7 +17,7 @@ export declare const isSomeElementSelected: {
|
|
|
17
17
|
* elements. If elements don't share the same value, returns `null`.
|
|
18
18
|
*/
|
|
19
19
|
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
20
|
-
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<
|
|
20
|
+
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
|
|
21
21
|
includeBoundTextElement?: boolean;
|
|
22
22
|
includeElementsInFrames?: boolean;
|
|
23
23
|
}) => ExcalidrawElement[];
|
package/types/scene/types.d.ts
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
|
+
import { Drawable } from "roughjs/bin/core";
|
|
3
|
+
import { ExcalidrawTextElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
4
|
+
import { AppClassProperties, InteractiveCanvasAppState, StaticCanvasAppState } from "../types";
|
|
5
|
+
export type StaticCanvasRenderConfig = {
|
|
6
|
+
imageCache: AppClassProperties["imageCache"];
|
|
7
|
+
renderGrid: boolean;
|
|
8
|
+
/** when exporting the behavior is slightly different (e.g. we can't use
|
|
9
|
+
CSS filters), and we disable render optimizations for best output */
|
|
10
|
+
isExporting: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type InteractiveCanvasRenderConfig = {
|
|
13
|
+
remoteSelectedElementIds: {
|
|
14
|
+
[elementId: string]: string[];
|
|
15
|
+
};
|
|
11
16
|
remotePointerViewportCoords: {
|
|
12
17
|
[id: string]: {
|
|
13
18
|
x: number;
|
|
14
19
|
y: number;
|
|
15
20
|
};
|
|
16
21
|
};
|
|
17
|
-
|
|
18
|
-
[id: string]: string
|
|
19
|
-
};
|
|
20
|
-
remoteSelectedElementIds: {
|
|
21
|
-
[elementId: string]: string[];
|
|
22
|
+
remotePointerUserStates: {
|
|
23
|
+
[id: string]: string;
|
|
22
24
|
};
|
|
23
25
|
remotePointerUsernames: {
|
|
24
26
|
[id: string]: string;
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
[id: string]: string;
|
|
28
|
+
remotePointerButton?: {
|
|
29
|
+
[id: string]: string | undefined;
|
|
28
30
|
};
|
|
29
|
-
imageCache: AppClassProperties["imageCache"];
|
|
30
|
-
renderScrollbars?: boolean;
|
|
31
|
-
renderSelection?: boolean;
|
|
32
|
-
renderGrid?: boolean;
|
|
33
|
-
/** when exporting the behavior is slightly different (e.g. we can't use
|
|
34
|
-
CSS filters), and we disable render optimizations for best output */
|
|
35
|
-
isExporting: boolean;
|
|
36
31
|
selectionColor?: string;
|
|
32
|
+
renderScrollbars?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type RenderInteractiveSceneCallback = {
|
|
35
|
+
atLeastOneVisibleElement: boolean;
|
|
36
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
37
|
+
scrollBars?: ScrollBars;
|
|
38
|
+
};
|
|
39
|
+
export type StaticSceneRenderConfig = {
|
|
40
|
+
canvas: HTMLCanvasElement;
|
|
41
|
+
rc: RoughCanvas;
|
|
42
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
43
|
+
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
44
|
+
scale: number;
|
|
45
|
+
appState: StaticCanvasAppState;
|
|
46
|
+
renderConfig: StaticCanvasRenderConfig;
|
|
47
|
+
};
|
|
48
|
+
export type InteractiveSceneRenderConfig = {
|
|
49
|
+
canvas: HTMLCanvasElement | null;
|
|
50
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
51
|
+
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
52
|
+
selectedElements: readonly NonDeletedExcalidrawElement[];
|
|
53
|
+
scale: number;
|
|
54
|
+
appState: InteractiveCanvasAppState;
|
|
55
|
+
renderConfig: InteractiveCanvasRenderConfig;
|
|
56
|
+
callback: (data: RenderInteractiveSceneCallback) => void;
|
|
37
57
|
};
|
|
38
58
|
export type SceneScroll = {
|
|
39
59
|
scrollX: number;
|
|
@@ -57,3 +77,16 @@ export type ScrollBars = {
|
|
|
57
77
|
height: number;
|
|
58
78
|
} | null;
|
|
59
79
|
};
|
|
80
|
+
export type ElementShape = Drawable | Drawable[] | null;
|
|
81
|
+
export type ElementShapes = {
|
|
82
|
+
rectangle: Drawable;
|
|
83
|
+
ellipse: Drawable;
|
|
84
|
+
diamond: Drawable;
|
|
85
|
+
embeddable: Drawable;
|
|
86
|
+
freedraw: Drawable | null;
|
|
87
|
+
arrow: Drawable[];
|
|
88
|
+
line: Drawable[];
|
|
89
|
+
text: null;
|
|
90
|
+
image: null;
|
|
91
|
+
frame: null;
|
|
92
|
+
};
|
package/types/types.d.ts
CHANGED
|
@@ -65,6 +65,45 @@ export type LastActiveTool = {
|
|
|
65
65
|
} | null;
|
|
66
66
|
export type SidebarName = string;
|
|
67
67
|
export type SidebarTabName = string;
|
|
68
|
+
type _CommonCanvasAppState = {
|
|
69
|
+
zoom: AppState["zoom"];
|
|
70
|
+
scrollX: AppState["scrollX"];
|
|
71
|
+
scrollY: AppState["scrollY"];
|
|
72
|
+
width: AppState["width"];
|
|
73
|
+
height: AppState["height"];
|
|
74
|
+
viewModeEnabled: AppState["viewModeEnabled"];
|
|
75
|
+
editingGroupId: AppState["editingGroupId"];
|
|
76
|
+
selectedElementIds: AppState["selectedElementIds"];
|
|
77
|
+
frameToHighlight: AppState["frameToHighlight"];
|
|
78
|
+
offsetLeft: AppState["offsetLeft"];
|
|
79
|
+
offsetTop: AppState["offsetTop"];
|
|
80
|
+
theme: AppState["theme"];
|
|
81
|
+
pendingImageElementId: AppState["pendingImageElementId"];
|
|
82
|
+
};
|
|
83
|
+
export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
84
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
85
|
+
/** null indicates transparent bg */
|
|
86
|
+
viewBackgroundColor: AppState["viewBackgroundColor"] | null;
|
|
87
|
+
exportScale: AppState["exportScale"];
|
|
88
|
+
selectedElementsAreBeingDragged: AppState["selectedElementsAreBeingDragged"];
|
|
89
|
+
gridSize: AppState["gridSize"];
|
|
90
|
+
frameRendering: AppState["frameRendering"];
|
|
91
|
+
}>;
|
|
92
|
+
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
93
|
+
activeEmbeddable: AppState["activeEmbeddable"];
|
|
94
|
+
editingLinearElement: AppState["editingLinearElement"];
|
|
95
|
+
selectionElement: AppState["selectionElement"];
|
|
96
|
+
selectedGroupIds: AppState["selectedGroupIds"];
|
|
97
|
+
selectedLinearElement: AppState["selectedLinearElement"];
|
|
98
|
+
multiElement: AppState["multiElement"];
|
|
99
|
+
isBindingEnabled: AppState["isBindingEnabled"];
|
|
100
|
+
suggestedBindings: AppState["suggestedBindings"];
|
|
101
|
+
isRotating: AppState["isRotating"];
|
|
102
|
+
elementsToHighlight: AppState["elementsToHighlight"];
|
|
103
|
+
openSidebar: AppState["openSidebar"];
|
|
104
|
+
showHyperlinkPopup: AppState["showHyperlinkPopup"];
|
|
105
|
+
collaborators: AppState["collaborators"];
|
|
106
|
+
}>;
|
|
68
107
|
export type AppState = {
|
|
69
108
|
contextMenu: {
|
|
70
109
|
items: ContextMenuItems;
|
|
@@ -297,8 +336,8 @@ export declare enum UserIdleState {
|
|
|
297
336
|
}
|
|
298
337
|
export type ExportOpts = {
|
|
299
338
|
saveFileToDisk?: boolean;
|
|
300
|
-
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement
|
|
301
|
-
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement
|
|
339
|
+
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
|
|
340
|
+
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
302
341
|
};
|
|
303
342
|
type CanvasActions = Partial<{
|
|
304
343
|
changeViewBackgroundColor: boolean;
|
|
@@ -330,7 +369,8 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
330
369
|
* in the app, eg Manager. Factored out into a separate type to keep DRY. */
|
|
331
370
|
export type AppClassProperties = {
|
|
332
371
|
props: AppProps;
|
|
333
|
-
canvas: HTMLCanvasElement
|
|
372
|
+
canvas: HTMLCanvasElement;
|
|
373
|
+
interactiveCanvas: HTMLCanvasElement | null;
|
|
334
374
|
focusContainer(): void;
|
|
335
375
|
library: Library;
|
|
336
376
|
imageCache: Map<FileId, {
|
package/types/utils.d.ts
CHANGED
|
@@ -88,10 +88,10 @@ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">,
|
|
|
88
88
|
}) & {
|
|
89
89
|
lastActiveToolBeforeEraser?: LastActiveTool;
|
|
90
90
|
}) => AppState["activeTool"];
|
|
91
|
-
export declare const resetCursor: (
|
|
92
|
-
export declare const setCursor: (
|
|
93
|
-
export declare const setEraserCursor: (
|
|
94
|
-
export declare const setCursorForShape: (
|
|
91
|
+
export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
|
|
92
|
+
export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;
|
|
93
|
+
export declare const setEraserCursor: (interactiveCanvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
|
|
94
|
+
export declare const setCursorForShape: (interactiveCanvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
|
|
95
95
|
export declare const isFullScreen: () => boolean;
|
|
96
96
|
export declare const allowFullScreen: () => Promise<void>;
|
|
97
97
|
export declare const exitFullScreen: () => Promise<void>;
|
|
@@ -191,3 +191,10 @@ export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E
|
|
|
191
191
|
}) => (event: E) => void;
|
|
192
192
|
export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
193
193
|
export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
|
|
194
|
+
/**
|
|
195
|
+
* Memoizes on values of `opts` object (strict equality).
|
|
196
|
+
*/
|
|
197
|
+
export declare const memoize: <T extends Record<string, any>, R extends unknown>(func: (opts: T) => R) => ((opts: T) => R) & {
|
|
198
|
+
clear: () => void;
|
|
199
|
+
};
|
|
200
|
+
export declare const isRenderThrottlingEnabled: () => boolean;
|