@dwelle/excalidraw 0.3.72 → 0.3.74
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 +246 -4
- package/README.md +352 -42
- package/dist/excalidraw.development.js +35 -35
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +3 -3
- package/types/actions/actionAddToLibrary.d.ts +13 -3
- package/types/actions/actionBoundText.d.ts +5 -1
- package/types/actions/actionCanvas.d.ts +40 -8
- package/types/actions/actionClipboard.d.ts +25 -5
- package/types/actions/actionDeleteSelected.d.ts +15 -3
- package/types/actions/actionExport.d.ts +43 -9
- package/types/actions/actionFinalize.d.ts +10 -2
- package/types/actions/actionMenu.d.ts +15 -3
- package/types/actions/actionProperties.d.ts +65 -13
- package/types/actions/actionStyles.d.ts +3 -1
- package/types/actions/actionToggleGridMode.d.ts +5 -1
- package/types/actions/actionToggleStats.d.ts +5 -1
- package/types/actions/actionToggleViewMode.d.ts +5 -1
- package/types/actions/actionToggleZenMode.d.ts +5 -1
- package/types/components/App.d.ts +9 -3
- package/types/components/LayerUI.d.ts +1 -4
- package/types/components/MobileMenu.d.ts +1 -2
- package/types/components/Toast.d.ts +4 -2
- package/types/constants.d.ts +0 -1
- package/types/data/filesystem.d.ts +2 -2
- package/types/element/Hyperlink.d.ts +5 -1
- package/types/element/linearElementEditor.d.ts +5 -1
- package/types/emitter.d.ts +21 -0
- package/types/jotai.d.ts +5 -3
- package/types/renderer/renderScene.d.ts +9 -1
- package/types/types.d.ts +8 -2
- package/types/utils.d.ts +3 -1
- package/README_NEXT.md +0 -1345
|
@@ -72,7 +72,11 @@ export declare const actionToggleZenMode: {
|
|
|
72
72
|
};
|
|
73
73
|
shouldCacheIgnoreZoom: boolean;
|
|
74
74
|
showHelpDialog: boolean;
|
|
75
|
-
|
|
75
|
+
toast: {
|
|
76
|
+
message: string;
|
|
77
|
+
closable?: boolean | undefined;
|
|
78
|
+
duration?: number | undefined;
|
|
79
|
+
} | null;
|
|
76
80
|
theme: string;
|
|
77
81
|
gridSize: number | null;
|
|
78
82
|
viewModeEnabled: boolean;
|
|
@@ -6,6 +6,7 @@ import History from "../history";
|
|
|
6
6
|
import Scene from "../scene/Scene";
|
|
7
7
|
import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device } from "../types";
|
|
8
8
|
import { FileSystemHandle } from "../data/filesystem";
|
|
9
|
+
import { Emitter } from "../emitter";
|
|
9
10
|
export declare const useDevice: () => Readonly<{
|
|
10
11
|
isSmScreen: boolean;
|
|
11
12
|
isMobile: boolean;
|
|
@@ -43,6 +44,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
43
44
|
x: number;
|
|
44
45
|
y: number;
|
|
45
46
|
} | null;
|
|
47
|
+
onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
|
|
46
48
|
constructor(props: AppProps);
|
|
47
49
|
private renderCanvas;
|
|
48
50
|
render(): JSX.Element;
|
|
@@ -64,6 +66,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
64
66
|
private refreshDeviceState;
|
|
65
67
|
componentDidMount(): Promise<void>;
|
|
66
68
|
componentWillUnmount(): void;
|
|
69
|
+
private checkIfBrowserZoomed;
|
|
67
70
|
private onResize;
|
|
68
71
|
private removeEventListeners;
|
|
69
72
|
private addEventListeners;
|
|
@@ -83,10 +86,12 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
83
86
|
removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
|
|
84
87
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
85
88
|
togglePenMode: () => void;
|
|
86
|
-
toggleZenMode: () => void;
|
|
87
89
|
scrollToContent: (target?: ExcalidrawElement | readonly ExcalidrawElement[]) => void;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
setToast: (toast: {
|
|
91
|
+
message: string;
|
|
92
|
+
closable?: boolean;
|
|
93
|
+
duration?: number;
|
|
94
|
+
} | null) => void;
|
|
90
95
|
restoreFileFromShare: () => Promise<void>;
|
|
91
96
|
/** adds supplied files to existing files in the appState */
|
|
92
97
|
addFiles: ExcalidrawImperativeAPI["addFiles"];
|
|
@@ -99,6 +104,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
99
104
|
private onSceneUpdated;
|
|
100
105
|
private updateCurrentCursorPosition;
|
|
101
106
|
private onKeyDown;
|
|
107
|
+
private onWheel;
|
|
102
108
|
private onKeyUp;
|
|
103
109
|
private setActiveTool;
|
|
104
110
|
private setCursor;
|
|
@@ -18,16 +18,13 @@ interface LayerUIProps {
|
|
|
18
18
|
onLockToggle: () => void;
|
|
19
19
|
onPenModeToggle: () => void;
|
|
20
20
|
onInsertElements: (elements: readonly NonDeletedExcalidrawElement[]) => void;
|
|
21
|
-
zenModeEnabled: boolean;
|
|
22
21
|
showExitZenModeBtn: boolean;
|
|
23
22
|
showThemeBtn: boolean;
|
|
24
|
-
toggleZenMode: () => void;
|
|
25
23
|
langCode: Language["code"];
|
|
26
24
|
isCollaborating: boolean;
|
|
27
25
|
renderTopRightUI?: ExcalidrawProps["renderTopRightUI"];
|
|
28
26
|
renderCustomFooter?: ExcalidrawProps["renderFooter"];
|
|
29
27
|
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
|
30
|
-
viewModeEnabled: boolean;
|
|
31
28
|
libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
|
|
32
29
|
UIOptions: AppProps["UIOptions"];
|
|
33
30
|
focusContainer: () => void;
|
|
@@ -37,5 +34,5 @@ interface LayerUIProps {
|
|
|
37
34
|
insertOnCanvasDirectly: boolean;
|
|
38
35
|
}) => void;
|
|
39
36
|
}
|
|
40
|
-
declare const _default: React.MemoExoticComponent<({ onHomeButtonClick, actionManager, appState, files, setAppState, canvas, elements, onCollabButtonClick, onLockToggle, onPenModeToggle, onInsertElements,
|
|
37
|
+
declare const _default: React.MemoExoticComponent<({ onHomeButtonClick, actionManager, appState, files, setAppState, canvas, elements, onCollabButtonClick, onLockToggle, onPenModeToggle, onInsertElements, showExitZenModeBtn, showThemeBtn, isCollaborating, renderTopRightUI, renderCustomFooter, renderCustomStats, libraryReturnUrl, UIOptions, focusContainer, library, id, onImageAction, }: LayerUIProps) => JSX.Element>;
|
|
41
38
|
export default _default;
|
|
@@ -17,7 +17,6 @@ declare type MobileMenuProps = {
|
|
|
17
17
|
canvas: HTMLCanvasElement | null;
|
|
18
18
|
isCollaborating: boolean;
|
|
19
19
|
renderCustomFooter?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
|
|
20
|
-
viewModeEnabled: boolean;
|
|
21
20
|
showThemeBtn: boolean;
|
|
22
21
|
onImageAction: (data: {
|
|
23
22
|
insertOnCanvasDirectly: boolean;
|
|
@@ -26,5 +25,5 @@ declare type MobileMenuProps = {
|
|
|
26
25
|
renderStats: () => JSX.Element | null;
|
|
27
26
|
UIOptions: AppProps["UIOptions"];
|
|
28
27
|
};
|
|
29
|
-
export declare const MobileMenu: ({ onHomeButtonClick, appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, onPenModeToggle, canvas, isCollaborating, renderCustomFooter,
|
|
28
|
+
export declare const MobileMenu: ({ onHomeButtonClick, appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, onPenModeToggle, canvas, isCollaborating, renderCustomFooter, showThemeBtn, onImageAction, renderTopRightUI, renderStats, UIOptions, }: MobileMenuProps) => JSX.Element;
|
|
30
29
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./Toast.scss";
|
|
3
|
-
export declare const Toast: ({ message,
|
|
3
|
+
export declare const Toast: ({ message, onClose, closable, duration, }: {
|
|
4
4
|
message: string;
|
|
5
|
-
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
closable?: boolean | undefined;
|
|
7
|
+
duration?: number | undefined;
|
|
6
8
|
}) => JSX.Element;
|
package/types/constants.d.ts
CHANGED
|
@@ -96,7 +96,6 @@ export declare const IMAGE_RENDER_TIMEOUT = 500;
|
|
|
96
96
|
export declare const TAP_TWICE_TIMEOUT = 300;
|
|
97
97
|
export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
|
|
98
98
|
export declare const TITLE_TIMEOUT = 10000;
|
|
99
|
-
export declare const TOAST_TIMEOUT = 5000;
|
|
100
99
|
export declare const VERSION_TIMEOUT = 30000;
|
|
101
100
|
export declare const SCROLL_TIMEOUT = 100;
|
|
102
101
|
export declare const ZOOM_STEP = 0.1;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSystemHandle, supported as nativeFileSystemSupported } from "browser-fs-access";
|
|
2
2
|
declare type FILE_EXTENSION = "gif" | "jpg" | "png" | "excalidraw.png" | "svg" | "excalidraw.svg" | "json" | "excalidraw" | "excalidrawlib";
|
|
3
3
|
export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
|
|
4
4
|
extensions?: FILE_EXTENSION[] | undefined;
|
|
5
5
|
description: string;
|
|
6
6
|
multiple?: M | undefined;
|
|
7
|
-
}) => Promise<M extends false | undefined ?
|
|
7
|
+
}) => Promise<M extends false | undefined ? File : File[]>;
|
|
8
8
|
export declare const fileSave: (blob: Blob, opts: {
|
|
9
9
|
/** supply without the extension */
|
|
10
10
|
name: string;
|
|
@@ -82,7 +82,11 @@ export declare const actionLink: {
|
|
|
82
82
|
};
|
|
83
83
|
shouldCacheIgnoreZoom: boolean;
|
|
84
84
|
showHelpDialog: boolean;
|
|
85
|
-
|
|
85
|
+
toast: {
|
|
86
|
+
message: string;
|
|
87
|
+
closable?: boolean | undefined;
|
|
88
|
+
duration?: number | undefined;
|
|
89
|
+
} | null;
|
|
86
90
|
zenModeEnabled: boolean;
|
|
87
91
|
theme: string;
|
|
88
92
|
gridSize: number | null;
|
|
@@ -149,7 +149,11 @@ export declare class LinearElementEditor {
|
|
|
149
149
|
};
|
|
150
150
|
shouldCacheIgnoreZoom: boolean;
|
|
151
151
|
showHelpDialog: boolean;
|
|
152
|
-
|
|
152
|
+
toast: {
|
|
153
|
+
message: string;
|
|
154
|
+
closable?: boolean | undefined;
|
|
155
|
+
duration?: number | undefined;
|
|
156
|
+
} | null;
|
|
153
157
|
zenModeEnabled: boolean;
|
|
154
158
|
theme: string;
|
|
155
159
|
gridSize: number | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare type Subscriber<T extends any[]> = (...payload: T) => void;
|
|
2
|
+
export declare class Emitter<T extends any[] = []> {
|
|
3
|
+
subscribers: Subscriber<T>[];
|
|
4
|
+
value: T | undefined;
|
|
5
|
+
private updateOnChangeOnly;
|
|
6
|
+
constructor(opts?: {
|
|
7
|
+
initialState?: T;
|
|
8
|
+
updateOnChangeOnly?: boolean;
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Attaches subscriber
|
|
12
|
+
*
|
|
13
|
+
* @returns unsubscribe function
|
|
14
|
+
*/
|
|
15
|
+
on(...handlers: Subscriber<T>[] | Subscriber<T>[][]): () => void;
|
|
16
|
+
once(...handlers: Subscriber<T>[] | Subscriber<T>[][]): () => void;
|
|
17
|
+
off(...handlers: Subscriber<T>[] | Subscriber<T>[][]): void;
|
|
18
|
+
trigger(...payload: T): any[];
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/types/jotai.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { WritableAtom } from "jotai";
|
|
1
2
|
export declare const jotaiScope: unique symbol;
|
|
2
3
|
export declare const jotaiStore: {
|
|
3
4
|
get: <Value>(atom: import("jotai").Atom<Value>) => (Value extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value) | undefined;
|
|
4
5
|
asyncGet: <Value_1>(atom: import("jotai").Atom<Value_1>) => Promise<Value_1 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_1>;
|
|
5
|
-
set: <Value_2, Update, Result extends void | Promise<void>>(atom:
|
|
6
|
+
set: <Value_2, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value_2, Update, Result>, update: Update) => Result;
|
|
6
7
|
sub: (atom: {
|
|
7
8
|
toString: () => string;
|
|
8
9
|
debugLabel?: string | undefined;
|
|
@@ -14,7 +15,7 @@ export declare const jotaiStore: {
|
|
|
14
15
|
}, callback: () => void) => () => void;
|
|
15
16
|
SECRET_INTERNAL_store: {
|
|
16
17
|
r: <Value_6>(readingAtom: import("jotai").Atom<Value_6>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_6>;
|
|
17
|
-
w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom:
|
|
18
|
+
w: <Value_1_1, Update_1, Result_1 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_1, Update_1, Result_1>, update: Update_1, version?: import("jotai/core/store").VersionObject | undefined) => Result_1;
|
|
18
19
|
c: (_atom: {
|
|
19
20
|
toString: () => string;
|
|
20
21
|
debugLabel?: string | undefined;
|
|
@@ -84,7 +85,7 @@ export declare const jotaiStore: {
|
|
|
84
85
|
} | undefined;
|
|
85
86
|
} | {
|
|
86
87
|
r: <Value_7>(readingAtom: import("jotai").Atom<Value_7>, version?: import("jotai/core/store").VersionObject | undefined) => import("jotai/core/store").AtomState<Value_7>;
|
|
87
|
-
w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom:
|
|
88
|
+
w: <Value_1_2, Update_2, Result_2 extends void | Promise<void>>(writingAtom: WritableAtom<Value_1_2, Update_2, Result_2>, update: Update_2, version?: import("jotai/core/store").VersionObject | undefined) => Result_2;
|
|
88
89
|
c: (_atom: {
|
|
89
90
|
toString: () => string;
|
|
90
91
|
debugLabel?: string | undefined;
|
|
@@ -118,3 +119,4 @@ export declare const jotaiStore: {
|
|
|
118
119
|
m?: undefined;
|
|
119
120
|
};
|
|
120
121
|
};
|
|
122
|
+
export declare const useAtomWithInitialValue: <T extends unknown, A extends WritableAtom<T, T, void>>(atom: A, initialValue: T | (() => T)) => readonly [T extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : T, import("jotai/core/atom").SetAtom<T, void>];
|
|
@@ -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 _renderScene: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, selectionElement: NonDeletedExcalidrawElement | null, scale: number, rc: RoughCanvas, canvas: HTMLCanvasElement, renderConfig: RenderConfig) => {
|
|
7
|
+
atLeastOneVisibleElement: boolean;
|
|
8
|
+
scrollBars?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
atLeastOneVisibleElement: boolean;
|
|
11
|
+
scrollBars: import("../scene/types").ScrollBars | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** renderScene throttled to animation framerate */
|
|
14
|
+
export declare const renderScene: <T extends boolean = false>(elements: readonly NonDeletedExcalidrawElement[], appState: AppState, selectionElement: NonDeletedExcalidrawElement | null, scale: number, rc: RoughCanvas, canvas: HTMLCanvasElement, renderConfig: RenderConfig, callback?: ((data: ReturnType<typeof _renderScene>) => void) | undefined, throttle?: T | undefined) => T extends true ? void : {
|
|
7
15
|
atLeastOneVisibleElement: boolean;
|
|
8
16
|
scrollBars?: undefined;
|
|
9
17
|
} | {
|
package/types/types.d.ts
CHANGED
|
@@ -113,7 +113,11 @@ export declare type AppState = {
|
|
|
113
113
|
};
|
|
114
114
|
shouldCacheIgnoreZoom: boolean;
|
|
115
115
|
showHelpDialog: boolean;
|
|
116
|
-
|
|
116
|
+
toast: {
|
|
117
|
+
message: string;
|
|
118
|
+
closable?: boolean;
|
|
119
|
+
duration?: number;
|
|
120
|
+
} | null;
|
|
117
121
|
zenModeEnabled: boolean;
|
|
118
122
|
theme: Theme;
|
|
119
123
|
gridSize: number | null;
|
|
@@ -352,6 +356,7 @@ export declare type PointerDownState = Readonly<{
|
|
|
352
356
|
};
|
|
353
357
|
};
|
|
354
358
|
}>;
|
|
359
|
+
declare type UnsubscribeCallback = () => void;
|
|
355
360
|
export declare type ExcalidrawImperativeAPI = {
|
|
356
361
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
357
362
|
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
@@ -365,7 +370,7 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
365
370
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
366
371
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
367
372
|
refresh: InstanceType<typeof App>["refresh"];
|
|
368
|
-
|
|
373
|
+
setToast: InstanceType<typeof App>["setToast"];
|
|
369
374
|
addFiles: (data: BinaryFileData[]) => void;
|
|
370
375
|
readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
371
376
|
ready: true;
|
|
@@ -374,6 +379,7 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
374
379
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
375
380
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
376
381
|
app: InstanceType<typeof App>;
|
|
382
|
+
onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
|
|
377
383
|
};
|
|
378
384
|
export declare type Device = Readonly<{
|
|
379
385
|
isSmScreen: boolean;
|
package/types/utils.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ export declare const debounce: <T extends any[]>(fn: (...args: T) => void, timeo
|
|
|
21
21
|
flush(): void;
|
|
22
22
|
cancel(): void;
|
|
23
23
|
};
|
|
24
|
-
export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void
|
|
24
|
+
export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, opts?: {
|
|
25
|
+
trailing?: boolean | undefined;
|
|
26
|
+
} | undefined) => {
|
|
25
27
|
(...args: T): void;
|
|
26
28
|
flush(): void;
|
|
27
29
|
cancel(): void;
|