@dwelle/excalidraw 0.3.64 → 0.3.65
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 +17 -1
- package/README_NEXT.md +120 -26
- package/dist/excalidraw.development.js +29 -29
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/appState.d.ts +1 -1
- package/types/components/App.d.ts +7 -2
- package/types/components/LibraryMenu.d.ts +3 -3
- package/types/components/LibraryMenuItems.d.ts +2 -2
- package/types/components/LibraryUnit.d.ts +2 -1
- package/types/data/blob.d.ts +1 -0
- package/types/data/json.d.ts +0 -2
- package/types/data/library.d.ts +18 -7
- package/types/data/types.d.ts +2 -2
- package/types/distribute.d.ts +6 -0
- package/types/element/linearElementEditor.d.ts +4 -1
- package/types/packages/excalidraw/index.d.ts +3 -2
- package/types/types.d.ts +6 -4
package/package.json
CHANGED
package/types/appState.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "off
|
|
|
3
3
|
export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
|
|
4
4
|
activeTool?: {
|
|
5
5
|
type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
|
|
6
|
-
lastActiveToolBeforeEraser: import("./types").LastActiveToolBeforeEraser;
|
|
6
|
+
lastActiveToolBeforeEraser: import("./types").LastActiveToolBeforeEraser;
|
|
7
7
|
locked: boolean;
|
|
8
8
|
customType: null;
|
|
9
9
|
} | {
|
|
@@ -48,7 +48,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
48
48
|
private onUnload;
|
|
49
49
|
private disableEvent;
|
|
50
50
|
private onFontLoaded;
|
|
51
|
-
private importLibraryFromUrl;
|
|
52
51
|
private resetHistory;
|
|
53
52
|
/**
|
|
54
53
|
* Resets scene & history.
|
|
@@ -90,13 +89,19 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
90
89
|
appState?: Pick<AppState, K> | null | undefined;
|
|
91
90
|
collaborators?: SceneData["collaborators"];
|
|
92
91
|
commitToHistory?: SceneData["commitToHistory"];
|
|
93
|
-
libraryItems?: LibraryItems | import("../types").LibraryItems_v1 | Promise<LibraryItems | import("../types").LibraryItems_v1> | ((currentLibraryItems: LibraryItems) => Required<SceneData>["libraryItems"] | Promise<Required<SceneData>["libraryItems"]>) | undefined;
|
|
94
92
|
}) => void;
|
|
95
93
|
private onSceneUpdated;
|
|
96
94
|
private updateCurrentCursorPosition;
|
|
97
95
|
private onKeyDown;
|
|
98
96
|
private onKeyUp;
|
|
99
97
|
private setActiveTool;
|
|
98
|
+
/**
|
|
99
|
+
* returns whether user is making a gesture with >= 2 fingers (points)
|
|
100
|
+
* on o touch screen (not on a trackpad). Currently only relates to Darwin
|
|
101
|
+
* (iOS/iPadOS,MacOS), but may work on other devices in the future if
|
|
102
|
+
* GestureEvent is standardized.
|
|
103
|
+
*/
|
|
104
|
+
private isTouchScreenMultiTouchGesture;
|
|
100
105
|
private onGestureStart;
|
|
101
106
|
private onGestureChange;
|
|
102
107
|
private onGestureEnd;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import Library from "../data/library";
|
|
3
|
-
import { LibraryItem, AppState, BinaryFiles, ExcalidrawProps } from "../types";
|
|
3
|
+
import { LibraryItems, LibraryItem, AppState, BinaryFiles, ExcalidrawProps } from "../types";
|
|
4
4
|
import "./LibraryMenu.scss";
|
|
5
|
-
export declare const LibraryMenu: ({ onClose,
|
|
5
|
+
export declare const LibraryMenu: ({ onClose, onInsertLibraryItems, pendingElements, onAddToLibrary, theme, setAppState, files, libraryReturnUrl, focusContainer, library, id, appState, }: {
|
|
6
6
|
pendingElements: LibraryItem["elements"];
|
|
7
7
|
onClose: () => void;
|
|
8
|
-
|
|
8
|
+
onInsertLibraryItems: (libraryItems: LibraryItems) => void;
|
|
9
9
|
onAddToLibrary: () => void;
|
|
10
10
|
theme: AppState["theme"];
|
|
11
11
|
files: BinaryFiles;
|
|
@@ -2,12 +2,12 @@ import React from "react";
|
|
|
2
2
|
import Library from "../data/library";
|
|
3
3
|
import { AppState, BinaryFiles, ExcalidrawProps, LibraryItem, LibraryItems } from "../types";
|
|
4
4
|
import "./LibraryMenuItems.scss";
|
|
5
|
-
declare const LibraryMenuItems: ({ isLoading, libraryItems, onRemoveFromLibrary, onAddToLibrary,
|
|
5
|
+
declare const LibraryMenuItems: ({ isLoading, libraryItems, onRemoveFromLibrary, onAddToLibrary, onInsertLibraryItems, pendingElements, theme, setAppState, libraryReturnUrl, library, files, id, selectedItems, onSelectItems, onPublish, resetLibrary, }: {
|
|
6
6
|
isLoading: boolean;
|
|
7
7
|
libraryItems: LibraryItems;
|
|
8
8
|
pendingElements: LibraryItem["elements"];
|
|
9
9
|
onRemoveFromLibrary: () => void;
|
|
10
|
-
|
|
10
|
+
onInsertLibraryItems: (libraryItems: LibraryItems) => void;
|
|
11
11
|
onAddToLibrary: (elements: LibraryItem["elements"]) => void;
|
|
12
12
|
theme: AppState["theme"];
|
|
13
13
|
files: BinaryFiles;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BinaryFiles, LibraryItem } from "../types";
|
|
3
3
|
import "./LibraryUnit.scss";
|
|
4
|
-
export declare const LibraryUnit: ({ id, elements, files, isPending, onClick, selected, onToggle, }: {
|
|
4
|
+
export declare const LibraryUnit: ({ id, elements, files, isPending, onClick, selected, onToggle, onDrag, }: {
|
|
5
5
|
id: LibraryItem["id"] | /** for pending item */ null;
|
|
6
6
|
elements?: readonly import("../element/types").NonDeleted<import("../element/types").ExcalidrawElement>[] | undefined;
|
|
7
7
|
files: BinaryFiles;
|
|
@@ -9,4 +9,5 @@ export declare const LibraryUnit: ({ id, elements, files, isPending, onClick, se
|
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
selected: boolean;
|
|
11
11
|
onToggle: (id: string, event: React.MouseEvent) => void;
|
|
12
|
+
onDrag: (id: string, event: React.DragEvent) => void;
|
|
12
13
|
}) => JSX.Element;
|
package/types/data/blob.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppSta
|
|
|
18
18
|
data: ImportedLibraryData;
|
|
19
19
|
}>;
|
|
20
20
|
export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null | undefined) => Promise<import("./restore").RestoredDataState>;
|
|
21
|
+
export declare const parseLibraryJSON: (json: string, defaultStatus?: LibraryItem["status"]) => LibraryItem[];
|
|
21
22
|
export declare const loadLibraryFromBlob: (blob: Blob, defaultStatus?: LibraryItem["status"]) => Promise<LibraryItem[]>;
|
|
22
23
|
export declare const canvasToBlob: (canvas: HTMLCanvasElement) => Promise<Blob>;
|
|
23
24
|
/** generates SHA-1 digest from supplied file (if not supported, falls back
|
package/types/data/json.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles, LibraryItems } from "../types";
|
|
3
3
|
import { ImportedDataState, ImportedLibraryData } from "./types";
|
|
4
|
-
import Library from "./library";
|
|
5
4
|
export declare const serializeAsJSON: (elements: readonly ExcalidrawElement[], appState: Partial<AppState>, files: BinaryFiles, type: "local" | "database") => string;
|
|
6
5
|
export declare const saveAsJSON: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<{
|
|
7
6
|
fileHandle: import("browser-fs-access").FileSystemHandle | null;
|
|
@@ -15,4 +14,3 @@ export declare const isValidExcalidrawData: (data?: {
|
|
|
15
14
|
export declare const isValidLibrary: (json: any) => json is ImportedLibraryData;
|
|
16
15
|
export declare const serializeLibraryAsJSON: (libraryItems: LibraryItems) => string;
|
|
17
16
|
export declare const saveLibraryAsJSON: (libraryItems: LibraryItems) => Promise<void>;
|
|
18
|
-
export declare const importLibraryFromJSON: (library: Library) => Promise<void>;
|
package/types/data/library.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LibraryItems,
|
|
1
|
+
import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource } from "../types";
|
|
2
2
|
import type App from "../components/App";
|
|
3
|
-
import {
|
|
3
|
+
import { ExcalidrawElement } from "../element/types";
|
|
4
4
|
export declare const libraryItemsAtom: import("jotai").Atom<{
|
|
5
5
|
status: "loading" | "loaded";
|
|
6
6
|
isInitialized: boolean;
|
|
@@ -71,15 +71,26 @@ declare class Library {
|
|
|
71
71
|
private getLastUpdateTask;
|
|
72
72
|
private notifyListeners;
|
|
73
73
|
resetLibrary: () => Promise<LibraryItems>;
|
|
74
|
-
/**
|
|
75
|
-
* imports library (from blob or libraryItems), merging with current library
|
|
76
|
-
* (attempting to remove duplicates)
|
|
77
|
-
*/
|
|
78
|
-
importLibrary(library: Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, defaultStatus?: LibraryItem["status"]): Promise<LibraryItems>;
|
|
79
74
|
/**
|
|
80
75
|
* @returns latest cloned libraryItems. Awaits all in-progress updates first.
|
|
81
76
|
*/
|
|
82
77
|
getLatestLibrary: () => Promise<LibraryItems>;
|
|
78
|
+
updateLibrary: ({ libraryItems, prompt, merge, openLibraryMenu, defaultStatus, }: {
|
|
79
|
+
libraryItems: LibraryItemsSource;
|
|
80
|
+
merge?: boolean | undefined;
|
|
81
|
+
prompt?: boolean | undefined;
|
|
82
|
+
openLibraryMenu?: boolean | undefined;
|
|
83
|
+
defaultStatus?: "published" | "unpublished" | undefined;
|
|
84
|
+
}) => Promise<LibraryItems>;
|
|
83
85
|
setLibrary: (libraryItems: LibraryItems | Promise<LibraryItems> | ((latestLibraryItems: LibraryItems) => LibraryItems | Promise<LibraryItems>)) => Promise<LibraryItems>;
|
|
84
86
|
}
|
|
85
87
|
export default Library;
|
|
88
|
+
export declare const distributeLibraryItemsOnSquareGrid: (libraryItems: LibraryItems) => ExcalidrawElement[];
|
|
89
|
+
export declare const parseLibraryTokensFromUrl: () => {
|
|
90
|
+
libraryUrl: string;
|
|
91
|
+
idToken: string | null;
|
|
92
|
+
} | null;
|
|
93
|
+
export declare const useHandleLibrary: ({ excalidrawAPI, getInitialLibraryItems, }: {
|
|
94
|
+
excalidrawAPI: ExcalidrawImperativeAPI | null;
|
|
95
|
+
getInitialLibraryItems?: (() => LibraryItemsSource) | undefined;
|
|
96
|
+
}) => void;
|
package/types/data/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState, BinaryFiles, LibraryItems,
|
|
2
|
+
import { AppState, BinaryFiles, LibraryItems, LibraryItems_anyVersion } from "../types";
|
|
3
3
|
import type { cleanAppStateForExport } from "../appState";
|
|
4
4
|
import { VERSIONS } from "../constants";
|
|
5
5
|
export interface ExportedDataState {
|
|
@@ -17,7 +17,7 @@ export interface ImportedDataState {
|
|
|
17
17
|
elements?: readonly ExcalidrawElement[] | null;
|
|
18
18
|
appState?: Readonly<Partial<AppState>> | null;
|
|
19
19
|
scrollToContent?: boolean;
|
|
20
|
-
libraryItems?:
|
|
20
|
+
libraryItems?: LibraryItems_anyVersion;
|
|
21
21
|
files?: BinaryFiles;
|
|
22
22
|
}
|
|
23
23
|
export interface ExportedLibraryData {
|
|
@@ -86,7 +86,10 @@ export declare class LinearElementEditor {
|
|
|
86
86
|
startBindingElement: ExcalidrawBindableElement | "keep" | null;
|
|
87
87
|
endBindingElement: ExcalidrawBindableElement | "keep" | null;
|
|
88
88
|
};
|
|
89
|
-
isLoading: boolean;
|
|
89
|
+
isLoading: boolean; /**
|
|
90
|
+
* @param id the `elementId` from the instance of this class (so that we can
|
|
91
|
+
* statically guarantee this method returns an ExcalidrawLinearElement)
|
|
92
|
+
*/
|
|
90
93
|
errorMessage: string | null;
|
|
91
94
|
draggingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
92
95
|
resizingElement: import("./types").NonDeletedExcalidrawElement | null;
|
|
@@ -11,7 +11,8 @@ export { exportToBlob, exportToCanvas, exportToSvg, serializeAsJSON, serializeLi
|
|
|
11
11
|
export { isLinearElement } from "../../element/typeChecks";
|
|
12
12
|
export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
|
|
13
13
|
export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
14
|
+
export { parseLibraryTokensFromUrl, useHandleLibrary, } from "../../data/library";
|
|
15
|
+
export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "../../utils";
|
|
16
|
+
export { getDefaultAppState, cleanAppStateForExport, clearAppStateForLocalStorage, } from "../../appState";
|
|
16
17
|
export { jotaiScope, jotaiStore } from "../../jotai";
|
|
17
18
|
export { libraryItemsAtom } from "../../data/library";
|
package/types/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare type Collaborator = {
|
|
|
29
29
|
background: string;
|
|
30
30
|
stroke: string;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
avatarUrl?: string;
|
|
33
33
|
};
|
|
34
34
|
export declare type DataURL = string & {
|
|
35
35
|
_brand: "DataURL";
|
|
@@ -170,7 +170,7 @@ export declare class GestureEvent extends UIEvent {
|
|
|
170
170
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
171
171
|
export declare type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
|
172
172
|
/** @deprecated legacy: do not use outside of migration paths */
|
|
173
|
-
|
|
173
|
+
declare type LibraryItems_v1 = readonly LibraryItem_v1[];
|
|
174
174
|
/** v2 library item */
|
|
175
175
|
export declare type LibraryItem = {
|
|
176
176
|
id: string;
|
|
@@ -182,6 +182,8 @@ export declare type LibraryItem = {
|
|
|
182
182
|
error?: string;
|
|
183
183
|
};
|
|
184
184
|
export declare type LibraryItems = readonly LibraryItem[];
|
|
185
|
+
export declare type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
|
186
|
+
export declare type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
|
|
185
187
|
export declare type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
|
|
186
188
|
readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
187
189
|
ready?: false;
|
|
@@ -238,7 +240,6 @@ export declare type SceneData = {
|
|
|
238
240
|
appState?: ImportedDataState["appState"];
|
|
239
241
|
collaborators?: Map<string, Collaborator>;
|
|
240
242
|
commitToHistory?: boolean;
|
|
241
|
-
libraryItems?: LibraryItems | LibraryItems_v1;
|
|
242
243
|
};
|
|
243
244
|
export declare enum UserIdleState {
|
|
244
245
|
ACTIVE = "active",
|
|
@@ -346,6 +347,7 @@ export declare type PointerDownState = Readonly<{
|
|
|
346
347
|
}>;
|
|
347
348
|
export declare type ExcalidrawImperativeAPI = {
|
|
348
349
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
350
|
+
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
|
349
351
|
resetScene: InstanceType<typeof App>["resetScene"];
|
|
350
352
|
getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
|
|
351
353
|
history: {
|
|
@@ -356,7 +358,6 @@ export declare type ExcalidrawImperativeAPI = {
|
|
|
356
358
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
357
359
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
358
360
|
refresh: InstanceType<typeof App>["refresh"];
|
|
359
|
-
importLibrary: InstanceType<typeof App>["importLibraryFromUrl"];
|
|
360
361
|
setToastMessage: InstanceType<typeof App>["setToastMessage"];
|
|
361
362
|
addFiles: (data: BinaryFileData[]) => void;
|
|
362
363
|
readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
|
|
@@ -369,3 +370,4 @@ export declare type DeviceType = {
|
|
|
369
370
|
isMobile: boolean;
|
|
370
371
|
isTouchScreen: boolean;
|
|
371
372
|
};
|
|
373
|
+
export {};
|