@zsviczian/excalidraw 0.12.0-obsidian-4 → 0.12.0-obsidian-7
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/README.md +16 -8
- package/dist/excalidraw.development.js +54 -32
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionClipboard.d.ts +1 -0
- package/types/actions/actionDeleteSelected.d.ts +1 -0
- package/types/components/Actions.d.ts +15 -3
- package/types/components/App.d.ts +3 -0
- package/types/components/Footer.d.ts +9 -0
- package/types/components/LayerUI.d.ts +1 -1
- package/types/components/LibraryMenu.d.ts +1 -2
- package/types/components/MobileMenu.d.ts +3 -3
- package/types/components/Stats.d.ts +1 -1
- package/types/constants.d.ts +1 -1
- package/types/element/Hyperlink.d.ts +1 -2
- package/types/element/bounds.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +20 -12
- package/types/element/transformHandles.d.ts +5 -4
- package/types/element/types.d.ts +1 -0
- package/types/points.d.ts +2 -1
- package/types/polyfill.d.ts +2 -0
- package/types/renderer/renderScene.d.ts +18 -2
- package/types/types.d.ts +0 -1
package/package.json
CHANGED
|
@@ -2,11 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { ActionManager } from "../actions/manager";
|
|
3
3
|
import { ExcalidrawElement, PointerType } from "../element/types";
|
|
4
4
|
import { AppState, Zoom } from "../types";
|
|
5
|
-
export declare const SelectedShapeActions: ({ appState, elements, renderAction,
|
|
5
|
+
export declare const SelectedShapeActions: ({ appState, elements, renderAction, }: {
|
|
6
6
|
appState: AppState;
|
|
7
7
|
elements: readonly ExcalidrawElement[];
|
|
8
8
|
renderAction: ActionManager["renderAction"];
|
|
9
|
-
activeTool: AppState["activeTool"]["type"];
|
|
10
9
|
}) => JSX.Element;
|
|
11
10
|
export declare const ShapesSwitcher: ({ canvas, activeTool, setAppState, onImageAction, appState, }: {
|
|
12
11
|
canvas: HTMLCanvasElement | null;
|
|
@@ -17,7 +16,20 @@ export declare const ShapesSwitcher: ({ canvas, activeTool, setAppState, onImage
|
|
|
17
16
|
}) => void;
|
|
18
17
|
appState: AppState;
|
|
19
18
|
}) => JSX.Element;
|
|
20
|
-
export declare const ZoomActions: ({ renderAction, zoom, }: {
|
|
19
|
+
export declare const ZoomActions: ({ renderAction, zoom, trayMode, }: {
|
|
21
20
|
renderAction: ActionManager["renderAction"];
|
|
22
21
|
zoom: Zoom;
|
|
22
|
+
trayMode?: boolean | undefined;
|
|
23
|
+
}) => JSX.Element;
|
|
24
|
+
export declare const UndoRedoActions: ({ renderAction, className, }: {
|
|
25
|
+
renderAction: ActionManager["renderAction"];
|
|
26
|
+
className?: string | undefined;
|
|
27
|
+
}) => JSX.Element;
|
|
28
|
+
export declare const ExitZenModeAction: ({ executeAction, showExitZenModeBtn, }: {
|
|
29
|
+
executeAction: ActionManager["executeAction"];
|
|
30
|
+
showExitZenModeBtn: boolean;
|
|
31
|
+
}) => JSX.Element;
|
|
32
|
+
export declare const FinalizeAction: ({ renderAction, className, }: {
|
|
33
|
+
renderAction: ActionManager["renderAction"];
|
|
34
|
+
className?: string | undefined;
|
|
23
35
|
}) => JSX.Element;
|
|
@@ -20,6 +20,8 @@ export declare const useExcalidrawContainer: () => {
|
|
|
20
20
|
container: HTMLDivElement | null;
|
|
21
21
|
id: string | null;
|
|
22
22
|
};
|
|
23
|
+
export declare const useExcalidrawElements: () => readonly NonDeletedExcalidrawElement[];
|
|
24
|
+
export declare const useExcalidrawAppState: () => AppState;
|
|
23
25
|
declare class App extends React.Component<AppProps, AppState> {
|
|
24
26
|
canvas: AppClassProperties["canvas"];
|
|
25
27
|
rc: RoughCanvas | null;
|
|
@@ -73,6 +75,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
73
75
|
private removeEventListeners;
|
|
74
76
|
private addEventListeners;
|
|
75
77
|
componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
|
|
78
|
+
private renderScene;
|
|
76
79
|
private onScroll;
|
|
77
80
|
private onCut;
|
|
78
81
|
private onCopy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionManager } from "../actions/manager";
|
|
2
|
+
import { AppState, ExcalidrawProps } from "../types";
|
|
3
|
+
declare const Footer: ({ appState, actionManager, renderCustomFooter, showExitZenModeBtn, }: {
|
|
4
|
+
appState: AppState;
|
|
5
|
+
actionManager: ActionManager;
|
|
6
|
+
renderCustomFooter?: ExcalidrawProps["renderFooter"];
|
|
7
|
+
showExitZenModeBtn: boolean;
|
|
8
|
+
}) => JSX.Element;
|
|
9
|
+
export default Footer;
|
|
@@ -33,5 +33,5 @@ interface LayerUIProps {
|
|
|
33
33
|
insertOnCanvasDirectly: boolean;
|
|
34
34
|
}) => void;
|
|
35
35
|
}
|
|
36
|
-
declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState,
|
|
36
|
+
declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, onCollabButtonClick, onLockToggle, onPenModeToggle, onInsertElements, showExitZenModeBtn, showThemeBtn, isCollaborating, renderTopRightUI, renderCustomFooter, renderCustomStats, libraryReturnUrl, UIOptions, focusContainer, library, id, onImageAction, }: LayerUIProps) => JSX.Element>;
|
|
37
37
|
export default _default;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import Library from "../data/library";
|
|
2
2
|
import { LibraryItems, LibraryItem, AppState, BinaryFiles, ExcalidrawProps } from "../types";
|
|
3
3
|
import "./LibraryMenu.scss";
|
|
4
|
-
export declare const LibraryMenu: ({ onClose, onInsertLibraryItems, pendingElements, onAddToLibrary,
|
|
4
|
+
export declare const LibraryMenu: ({ onClose, onInsertLibraryItems, pendingElements, onAddToLibrary, setAppState, files, libraryReturnUrl, focusContainer, library, id, appState, }: {
|
|
5
5
|
pendingElements: LibraryItem["elements"];
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
onInsertLibraryItems: (libraryItems: LibraryItems) => void;
|
|
8
8
|
onAddToLibrary: () => void;
|
|
9
|
-
theme: AppState["theme"];
|
|
10
9
|
files: BinaryFiles;
|
|
11
10
|
setAppState: React.Component<any, AppState>["setState"];
|
|
12
11
|
libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { AppState } from "../types";
|
|
2
|
+
import { AppState, ExcalidrawProps } from "../types";
|
|
3
3
|
import { ActionManager } from "../actions/manager";
|
|
4
4
|
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
5
5
|
declare type MobileMenuProps = {
|
|
@@ -21,7 +21,7 @@ declare type MobileMenuProps = {
|
|
|
21
21
|
insertOnCanvasDirectly: boolean;
|
|
22
22
|
}) => void;
|
|
23
23
|
renderTopRightUI?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
24
|
-
|
|
24
|
+
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
|
25
25
|
};
|
|
26
|
-
export declare const MobileMenu: ({ appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, onPenModeToggle, canvas, isCollaborating, renderCustomFooter, showThemeBtn, onImageAction, renderTopRightUI,
|
|
26
|
+
export declare const MobileMenu: ({ appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, onPenModeToggle, canvas, isCollaborating, renderCustomFooter, showThemeBtn, onImageAction, renderTopRightUI, renderCustomStats, }: MobileMenuProps) => JSX.Element;
|
|
27
27
|
export {};
|
package/types/constants.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
|
|
|
101
101
|
export declare const TITLE_TIMEOUT = 10000;
|
|
102
102
|
export declare const VERSION_TIMEOUT = 30000;
|
|
103
103
|
export declare const SCROLL_TIMEOUT = 100;
|
|
104
|
-
export declare const ZOOM_STEP = 0.
|
|
104
|
+
export declare const ZOOM_STEP = 0.05;
|
|
105
105
|
export declare const HYPERLINK_TOOLTIP_DELAY = 300;
|
|
106
106
|
export declare const IDLE_THRESHOLD = 60000;
|
|
107
107
|
export declare const ACTIVE_THRESHOLD = 3000;
|
|
@@ -4,9 +4,8 @@ import { NonDeletedExcalidrawElement } from "./types";
|
|
|
4
4
|
import { Bounds } from "./bounds";
|
|
5
5
|
import "./Hyperlink.scss";
|
|
6
6
|
export declare const EXTERNAL_LINK_IMG: HTMLImageElement;
|
|
7
|
-
export declare const Hyperlink: ({ element,
|
|
7
|
+
export declare const Hyperlink: ({ element, setAppState, onLinkOpen, }: {
|
|
8
8
|
element: NonDeletedExcalidrawElement;
|
|
9
|
-
appState: AppState;
|
|
10
9
|
setAppState: React.Component<any, AppState>["setState"];
|
|
11
10
|
onLinkOpen: ExcalidrawProps["onLinkOpen"];
|
|
12
11
|
}) => JSX.Element | null;
|
|
@@ -8,7 +8,7 @@ export declare const getCurvePathOps: (shape: Drawable) => Op[];
|
|
|
8
8
|
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
9
9
|
export declare const getElementBounds: (element: ExcalidrawElement) => [number, number, number, number];
|
|
10
10
|
export declare const getCommonBounds: (elements: readonly ExcalidrawElement[]) => [number, number, number, number];
|
|
11
|
-
export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number) => [number, number, number, number];
|
|
11
|
+
export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => [number, number, number, number];
|
|
12
12
|
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[], sharpness: ExcalidrawElement["strokeSharpness"]) => [number, number, number, number];
|
|
13
13
|
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
14
14
|
x: number;
|
|
@@ -4,26 +4,27 @@ import { Point, AppState } from "../types";
|
|
|
4
4
|
import History from "../history";
|
|
5
5
|
import Scene from "../scene/Scene";
|
|
6
6
|
export declare class LinearElementEditor {
|
|
7
|
-
elementId: ExcalidrawElement["id"] & {
|
|
7
|
+
readonly elementId: ExcalidrawElement["id"] & {
|
|
8
8
|
_brand: "excalidrawLinearElementId";
|
|
9
9
|
};
|
|
10
10
|
/** indices */
|
|
11
|
-
selectedPointsIndices: readonly number[] | null;
|
|
12
|
-
pointerDownState: Readonly<{
|
|
11
|
+
readonly selectedPointsIndices: readonly number[] | null;
|
|
12
|
+
readonly pointerDownState: Readonly<{
|
|
13
13
|
prevSelectedPointsIndices: readonly number[] | null;
|
|
14
14
|
/** index */
|
|
15
15
|
lastClickedPoint: number;
|
|
16
16
|
}>;
|
|
17
17
|
/** whether you're dragging a point */
|
|
18
|
-
isDragging: boolean;
|
|
19
|
-
lastUncommittedPoint: Point | null;
|
|
20
|
-
pointerOffset: Readonly<{
|
|
18
|
+
readonly isDragging: boolean;
|
|
19
|
+
readonly lastUncommittedPoint: Point | null;
|
|
20
|
+
readonly pointerOffset: Readonly<{
|
|
21
21
|
x: number;
|
|
22
22
|
y: number;
|
|
23
23
|
}>;
|
|
24
|
-
startBindingElement: ExcalidrawBindableElement | null | "keep";
|
|
25
|
-
endBindingElement: ExcalidrawBindableElement | null | "keep";
|
|
26
|
-
hoverPointIndex: number;
|
|
24
|
+
readonly startBindingElement: ExcalidrawBindableElement | null | "keep";
|
|
25
|
+
readonly endBindingElement: ExcalidrawBindableElement | null | "keep";
|
|
26
|
+
readonly hoverPointIndex: number;
|
|
27
|
+
readonly midPointHovered: boolean;
|
|
27
28
|
constructor(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene);
|
|
28
29
|
static POINT_HANDLE_SIZE: number;
|
|
29
30
|
/**
|
|
@@ -33,11 +34,16 @@ export declare class LinearElementEditor {
|
|
|
33
34
|
static getElement(id: InstanceType<typeof LinearElementEditor>["elementId"]): NonDeleted<ExcalidrawLinearElement> | null;
|
|
34
35
|
static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"]): false | undefined;
|
|
35
36
|
/** @returns whether point was dragged */
|
|
36
|
-
static handlePointDragging(appState: AppState, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
|
|
37
|
+
static handlePointDragging(event: PointerEvent, appState: AppState, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
|
|
37
38
|
x: number;
|
|
38
39
|
y: number;
|
|
39
40
|
}[]) => void, linearElementEditor: LinearElementEditor): boolean;
|
|
40
41
|
static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
|
|
42
|
+
static isHittingMidPoint: (linearElementEditor: LinearElementEditor, scenePointer: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}, appState: AppState) => boolean;
|
|
46
|
+
static getMidPoint(linearElementEditor: LinearElementEditor): readonly [number, number] | null;
|
|
41
47
|
static handlePointerDown(event: React.PointerEvent<HTMLCanvasElement>, appState: AppState, history: History, scenePointer: {
|
|
42
48
|
x: number;
|
|
43
49
|
y: number;
|
|
@@ -45,12 +51,13 @@ export declare class LinearElementEditor {
|
|
|
45
51
|
didAddPoint: boolean;
|
|
46
52
|
hitElement: NonDeleted<ExcalidrawElement> | null;
|
|
47
53
|
linearElementEditor: LinearElementEditor | null;
|
|
54
|
+
isMidPoint: boolean;
|
|
48
55
|
};
|
|
49
56
|
static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor, gridSize: number | null): LinearElementEditor;
|
|
50
57
|
/** scene coords */
|
|
51
58
|
static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, point: Point): readonly [number, number];
|
|
52
59
|
/** scene coords */
|
|
53
|
-
static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>):
|
|
60
|
+
static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>): Point[];
|
|
54
61
|
static getPointAtIndexGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, indexMaybeFromEnd: number): Point;
|
|
55
62
|
static pointFromAbsoluteCoords(element: NonDeleted<ExcalidrawLinearElement>, absoluteCoords: Point): Point;
|
|
56
63
|
static getPointIndexUnderCursor(element: NonDeleted<ExcalidrawLinearElement>, zoom: AppState["zoom"], x: number, y: number): number;
|
|
@@ -78,7 +85,6 @@ export declare class LinearElementEditor {
|
|
|
78
85
|
/** index */
|
|
79
86
|
lastClickedPoint: number;
|
|
80
87
|
}>;
|
|
81
|
-
/** whether you're dragging a point */
|
|
82
88
|
isDragging: boolean;
|
|
83
89
|
lastUncommittedPoint: readonly [number, number] | null;
|
|
84
90
|
pointerOffset: Readonly<{
|
|
@@ -88,6 +94,7 @@ export declare class LinearElementEditor {
|
|
|
88
94
|
startBindingElement: ExcalidrawBindableElement | "keep" | null;
|
|
89
95
|
endBindingElement: ExcalidrawBindableElement | "keep" | null;
|
|
90
96
|
hoverPointIndex: number;
|
|
97
|
+
midPointHovered: boolean;
|
|
91
98
|
};
|
|
92
99
|
isLoading: boolean;
|
|
93
100
|
errorMessage: string | null;
|
|
@@ -207,4 +214,5 @@ export declare class LinearElementEditor {
|
|
|
207
214
|
endBinding?: PointBinding;
|
|
208
215
|
}): void;
|
|
209
216
|
private static _updatePoints;
|
|
217
|
+
private static _getShiftLockedDelta;
|
|
210
218
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExcalidrawElement, PointerType } from "./types";
|
|
1
|
+
import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
2
|
import { Bounds } from "./bounds";
|
|
3
|
-
import { Zoom } from "../types";
|
|
3
|
+
import { AppState, Zoom } from "../types";
|
|
4
4
|
export declare type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
5
5
|
export declare type TransformHandleType = TransformHandleDirection | "rotation";
|
|
6
6
|
export declare type TransformHandle = [number, number, number, number];
|
|
@@ -17,12 +17,13 @@ export declare const OMIT_SIDES_FOR_MULTIPLE_ELEMENTS: {
|
|
|
17
17
|
export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
|
|
18
18
|
e?: boolean | undefined;
|
|
19
19
|
s?: boolean | undefined;
|
|
20
|
-
n?: boolean | undefined;
|
|
21
20
|
w?: boolean | undefined;
|
|
21
|
+
n?: boolean | undefined;
|
|
22
22
|
nw?: boolean | undefined;
|
|
23
23
|
ne?: boolean | undefined;
|
|
24
24
|
sw?: boolean | undefined;
|
|
25
25
|
se?: boolean | undefined;
|
|
26
26
|
rotation?: boolean | undefined;
|
|
27
|
-
}) => TransformHandles;
|
|
27
|
+
}, margin?: number) => TransformHandles;
|
|
28
28
|
export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
|
|
29
|
+
export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState: AppState) => boolean;
|
package/types/element/types.d.ts
CHANGED
package/types/points.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export declare const getSizeFromPoints: (points: readonly Point[]) => {
|
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
/** @arg dimension, 0 for rescaling only x, 1 for y */
|
|
7
|
+
export declare const rescalePoints: (dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
|
|
@@ -3,7 +3,15 @@ import { RoughSVG } from "roughjs/bin/svg";
|
|
|
3
3
|
import { AppState, BinaryFiles } from "../types";
|
|
4
4
|
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
5
5
|
import { RenderConfig } from "../scene/types";
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const DEFAULT_SPACING = 4;
|
|
7
|
+
export declare const _renderScene: ({ elements, appState, scale, rc, canvas, renderConfig, }: {
|
|
8
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
9
|
+
appState: AppState;
|
|
10
|
+
scale: number;
|
|
11
|
+
rc: RoughCanvas;
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
renderConfig: RenderConfig;
|
|
14
|
+
}) => {
|
|
7
15
|
atLeastOneVisibleElement: boolean;
|
|
8
16
|
scrollBars?: undefined;
|
|
9
17
|
} | {
|
|
@@ -11,7 +19,15 @@ export declare const _renderScene: (elements: readonly NonDeletedExcalidrawEleme
|
|
|
11
19
|
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
12
20
|
};
|
|
13
21
|
/** renderScene throttled to animation framerate */
|
|
14
|
-
export declare const renderScene: <T extends boolean = false>(
|
|
22
|
+
export declare const renderScene: <T extends boolean = false>(config: {
|
|
23
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
24
|
+
appState: AppState;
|
|
25
|
+
scale: number;
|
|
26
|
+
rc: RoughCanvas;
|
|
27
|
+
canvas: HTMLCanvasElement;
|
|
28
|
+
renderConfig: RenderConfig;
|
|
29
|
+
callback?: ((data: ReturnType<typeof _renderScene>) => void) | undefined;
|
|
30
|
+
}, throttle?: T | undefined) => T extends true ? void : {
|
|
15
31
|
atLeastOneVisibleElement: boolean;
|
|
16
32
|
scrollBars?: undefined;
|
|
17
33
|
} | {
|
package/types/types.d.ts
CHANGED