mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: factor out url library init & switch to updateLibrary
API (#5115)
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
2537b225ac
commit
cad6097d60
11 changed files with 394 additions and 235 deletions
17
src/types.ts
17
src/types.ts
|
@ -206,7 +206,7 @@ export declare class GestureEvent extends UIEvent {
|
|||
/** @deprecated legacy: do not use outside of migration paths */
|
||||
export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
|
||||
/** @deprecated legacy: do not use outside of migration paths */
|
||||
export type LibraryItems_v1 = readonly LibraryItem_v1[];
|
||||
type LibraryItems_v1 = readonly LibraryItem_v1[];
|
||||
|
||||
/** v2 library item */
|
||||
export type LibraryItem = {
|
||||
|
@ -219,6 +219,18 @@ export type LibraryItem = {
|
|||
error?: string;
|
||||
};
|
||||
export type LibraryItems = readonly LibraryItem[];
|
||||
export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
|
||||
|
||||
export type LibraryItemsSource =
|
||||
| ((
|
||||
currentLibraryItems: LibraryItems,
|
||||
) =>
|
||||
| Blob
|
||||
| LibraryItems_anyVersion
|
||||
| Promise<LibraryItems_anyVersion | Blob>)
|
||||
| Blob
|
||||
| LibraryItems_anyVersion
|
||||
| Promise<LibraryItems_anyVersion | Blob>;
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// NOTE ready/readyPromise props are optional for host apps' sake (our own
|
||||
|
@ -301,7 +313,6 @@ export type SceneData = {
|
|||
appState?: ImportedDataState["appState"];
|
||||
collaborators?: Map<string, Collaborator>;
|
||||
commitToHistory?: boolean;
|
||||
libraryItems?: LibraryItems | LibraryItems_v1;
|
||||
};
|
||||
|
||||
export enum UserIdleState {
|
||||
|
@ -436,6 +447,7 @@ export type PointerDownState = Readonly<{
|
|||
|
||||
export type ExcalidrawImperativeAPI = {
|
||||
updateScene: InstanceType<typeof App>["updateScene"];
|
||||
updateLibrary: InstanceType<typeof Library>["updateLibrary"];
|
||||
resetScene: InstanceType<typeof App>["resetScene"];
|
||||
getSceneElementsIncludingDeleted: InstanceType<
|
||||
typeof App
|
||||
|
@ -448,7 +460,6 @@ export type ExcalidrawImperativeAPI = {
|
|||
getAppState: () => InstanceType<typeof App>["state"];
|
||||
getFiles: () => InstanceType<typeof App>["files"];
|
||||
refresh: InstanceType<typeof App>["refresh"];
|
||||
importLibrary: InstanceType<typeof App>["importLibraryFromUrl"];
|
||||
setToastMessage: InstanceType<typeof App>["setToastMessage"];
|
||||
addFiles: (data: BinaryFileData[]) => void;
|
||||
readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue