@zsviczian/excalidraw 0.13.0-obsidian → 0.13.0-obsidian-1

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.
Files changed (83) hide show
  1. package/dist/excalidraw.development.js +1103 -142
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +104 -0
  4. package/package.json +1 -1
  5. package/types/actions/actionAddToLibrary.d.ts +6 -3
  6. package/types/actions/actionAlign.d.ts +18 -6
  7. package/types/actions/actionBoundText.d.ts +2 -1
  8. package/types/actions/actionCanvas.d.ts +41 -18
  9. package/types/actions/actionClipboard.d.ts +10 -5
  10. package/types/actions/actionDeleteSelected.d.ts +9 -4
  11. package/types/actions/actionDistribute.d.ts +6 -2
  12. package/types/actions/actionDuplicateSelection.d.ts +3 -1
  13. package/types/actions/actionExport.d.ts +44 -19
  14. package/types/actions/actionFinalize.d.ts +7 -3
  15. package/types/actions/actionGroup.d.ts +6 -2
  16. package/types/actions/actionLinearEditor.d.ts +2 -1
  17. package/types/actions/actionMenu.d.ts +15 -6
  18. package/types/actions/actionNavigate.d.ts +3 -1
  19. package/types/actions/actionProperties.d.ts +65 -26
  20. package/types/actions/actionStyles.d.ts +2 -1
  21. package/types/actions/actionToggleGridMode.d.ts +2 -1
  22. package/types/actions/actionToggleLock.d.ts +2 -1
  23. package/types/actions/actionToggleStats.d.ts +2 -1
  24. package/types/actions/actionToggleViewMode.d.ts +2 -1
  25. package/types/actions/actionToggleZenMode.d.ts +2 -1
  26. package/types/actions/actionZindex.d.ts +12 -4
  27. package/types/actions/manager.d.ts +1 -1
  28. package/types/actions/shortcuts.d.ts +1 -1
  29. package/types/actions/types.d.ts +3 -1
  30. package/types/appState.d.ts +3 -2
  31. package/types/bug-issue-template.d.ts +2 -0
  32. package/types/clients.d.ts +1 -1
  33. package/types/components/Actions.d.ts +1 -0
  34. package/types/components/App.d.ts +46 -0
  35. package/types/components/Avatar.d.ts +1 -1
  36. package/types/components/CollabButton.d.ts +2 -1
  37. package/types/components/DialogActionButton.d.ts +10 -0
  38. package/types/components/EncryptedIcon.d.ts +2 -0
  39. package/types/components/Footer.d.ts +2 -1
  40. package/types/components/HelpButton.d.ts +8 -0
  41. package/types/components/ImageExportDialog.d.ts +3 -1
  42. package/types/components/LayerUI.d.ts +2 -1
  43. package/types/components/LibraryButton.d.ts +1 -0
  44. package/types/components/LibraryMenuBrowseButton.d.ts +7 -0
  45. package/types/components/LibraryMenuItems.d.ts +5 -2
  46. package/types/components/MenuItem.d.ts +11 -0
  47. package/types/components/MenuUtils.d.ts +2 -0
  48. package/types/components/MobileMenu.d.ts +2 -1
  49. package/types/components/Sidebar/Sidebar.d.ts +1 -1
  50. package/types/components/Sidebar/common.d.ts +1 -0
  51. package/types/components/TopErrorBoundary.d.ts +15 -0
  52. package/types/components/WelcomeScreen.d.ts +8 -0
  53. package/types/components/WelcomeScreenDecor.d.ts +6 -0
  54. package/types/components/icons.d.ts +83 -124
  55. package/types/constants.d.ts +1 -0
  56. package/types/element/Hyperlink.d.ts +5 -2
  57. package/types/element/linearElementEditor.d.ts +2 -1
  58. package/types/element/transformHandles.d.ts +1 -1
  59. package/types/excalidraw-app/CustomStats.d.ts +9 -0
  60. package/types/excalidraw-app/app_constants.d.ts +32 -0
  61. package/types/excalidraw-app/collab/Collab.d.ts +163 -0
  62. package/types/excalidraw-app/collab/Portal.d.ts +28 -0
  63. package/types/excalidraw-app/collab/RoomDialog.d.ts +13 -0
  64. package/types/excalidraw-app/collab/reconciliation.d.ts +10 -0
  65. package/types/excalidraw-app/components/ExportToExcalidrawPlus.d.ts +9 -0
  66. package/types/excalidraw-app/components/LanguageList.d.ts +4 -0
  67. package/types/excalidraw-app/components/icons.d.ts +1 -0
  68. package/types/excalidraw-app/data/FileManager.d.ts +66 -0
  69. package/types/excalidraw-app/data/LocalData.d.ts +32 -0
  70. package/types/excalidraw-app/data/Locker.d.ts +8 -0
  71. package/types/excalidraw-app/data/firebase.d.ts +25 -0
  72. package/types/excalidraw-app/data/index.d.ts +186 -0
  73. package/types/excalidraw-app/data/localStorage.d.ts +112 -0
  74. package/types/excalidraw-app/data/tabSync.d.ts +9 -0
  75. package/types/excalidraw-app/index.d.ts +26 -0
  76. package/types/hooks/useOutsideClick.d.ts +2 -0
  77. package/types/keys.d.ts +10 -0
  78. package/types/packages/excalidraw/index.d.ts +3 -0
  79. package/types/packages/utils.d.ts +3 -1
  80. package/types/renderer/renderScene.d.ts +1 -1
  81. package/types/scene/types.d.ts +1 -0
  82. package/types/shapes.d.ts +27 -3
  83. package/types/types.d.ts +13 -1
@@ -0,0 +1,66 @@
1
+ import { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "../../element/types";
2
+ import { BinaryFileData, ExcalidrawImperativeAPI, BinaryFiles } from "../../types";
3
+ export declare class FileManager {
4
+ /** files being fetched */
5
+ private fetchingFiles;
6
+ /** files being saved */
7
+ private savingFiles;
8
+ private savedFiles;
9
+ private erroredFiles;
10
+ private _getFiles;
11
+ private _saveFiles;
12
+ constructor({ getFiles, saveFiles, }: {
13
+ getFiles: (fileIds: FileId[]) => Promise<{
14
+ loadedFiles: BinaryFileData[];
15
+ erroredFiles: Map<FileId, true>;
16
+ }>;
17
+ saveFiles: (data: {
18
+ addedFiles: Map<FileId, BinaryFileData>;
19
+ }) => Promise<{
20
+ savedFiles: Map<FileId, true>;
21
+ erroredFiles: Map<FileId, true>;
22
+ }>;
23
+ });
24
+ /**
25
+ * returns whether file is already saved or being processed
26
+ */
27
+ isFileHandled: (id: FileId) => boolean;
28
+ isFileSaved: (id: FileId) => boolean;
29
+ saveFiles: ({ elements, files, }: {
30
+ elements: readonly ExcalidrawElement[];
31
+ files: BinaryFiles;
32
+ }) => Promise<{
33
+ savedFiles: Map<FileId, true>;
34
+ erroredFiles: Map<FileId, true>;
35
+ }>;
36
+ getFiles: (ids: FileId[]) => Promise<{
37
+ loadedFiles: BinaryFileData[];
38
+ erroredFiles: Map<FileId, true>;
39
+ }>;
40
+ /** a file element prevents unload only if it's being saved regardless of
41
+ * its `status`. This ensures that elements who for any reason haven't
42
+ * beed set to `saved` status don't prevent unload in future sessions.
43
+ * Technically we should prevent unload when the origin client haven't
44
+ * yet saved the `status` update to storage, but that should be taken care
45
+ * of during regular beforeUnload unsaved files check.
46
+ */
47
+ shouldPreventUnload: (elements: readonly ExcalidrawElement[]) => boolean;
48
+ /**
49
+ * helper to determine if image element status needs updating
50
+ */
51
+ shouldUpdateImageElementStatus: (element: ExcalidrawElement) => element is InitializedExcalidrawImageElement;
52
+ reset(): void;
53
+ }
54
+ export declare const encodeFilesForUpload: ({ files, maxBytes, encryptionKey, }: {
55
+ files: Map<FileId, BinaryFileData>;
56
+ maxBytes: number;
57
+ encryptionKey: string;
58
+ }) => Promise<{
59
+ id: FileId;
60
+ buffer: Uint8Array;
61
+ }[]>;
62
+ export declare const updateStaleImageStatuses: (params: {
63
+ excalidrawAPI: ExcalidrawImperativeAPI;
64
+ erroredFiles: Map<FileId, true>;
65
+ elements: readonly ExcalidrawElement[];
66
+ }) => void;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * This file deals with saving data state (appState, elements, images, ...)
3
+ * locally to the browser.
4
+ *
5
+ * Notes:
6
+ *
7
+ * - DataState refers to full state of the app: appState, elements, images,
8
+ * though some state is saved separately (collab username, library) for one
9
+ * reason or another. We also save different data to different sotrage
10
+ * (localStorage, indexedDB).
11
+ */
12
+ import { ExcalidrawElement, FileId } from "../../element/types";
13
+ import { AppState, BinaryFiles } from "../../types";
14
+ import { FileManager } from "./FileManager";
15
+ declare class LocalFileManager extends FileManager {
16
+ clearObsoleteFiles: (opts: {
17
+ currentFileIds: FileId[];
18
+ }) => Promise<void>;
19
+ }
20
+ declare type SavingLockTypes = "collaboration";
21
+ export declare class LocalData {
22
+ private static _save;
23
+ /** Saves DataState, including files. Bails if saving is paused */
24
+ static save: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, onFilesSaved: () => void) => void;
25
+ static flushSave: () => void;
26
+ private static locker;
27
+ static pauseSave: (lockType: SavingLockTypes) => void;
28
+ static resumeSave: (lockType: SavingLockTypes) => void;
29
+ static isSavePaused: () => boolean;
30
+ static fileStorage: LocalFileManager;
31
+ }
32
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare class Locker<T extends string> {
2
+ private locks;
3
+ lock: (lockType: T) => void;
4
+ /** @returns whether no locks remaining */
5
+ unlock: (lockType: T) => boolean;
6
+ /** @returns whether some (or specific) locks are present */
7
+ isLocked(lockType?: T): boolean;
8
+ }
@@ -0,0 +1,25 @@
1
+ /// <reference types="socket.io-client" />
2
+ import { ExcalidrawElement, FileId } from "../../element/types";
3
+ import Portal from "../collab/Portal";
4
+ import { AppState, BinaryFileData } from "../../types";
5
+ import { SyncableExcalidrawElement } from ".";
6
+ export declare const loadFirebaseStorage: () => Promise<typeof import("firebase/app").default>;
7
+ export declare const isSavedToFirebase: (portal: Portal, elements: readonly ExcalidrawElement[]) => boolean;
8
+ export declare const saveFilesToFirebase: ({ prefix, files, }: {
9
+ prefix: string;
10
+ files: {
11
+ id: FileId;
12
+ buffer: Uint8Array;
13
+ }[];
14
+ }) => Promise<{
15
+ savedFiles: Map<FileId, true>;
16
+ erroredFiles: Map<FileId, true>;
17
+ }>;
18
+ export declare const saveToFirebase: (portal: Portal, elements: readonly SyncableExcalidrawElement[], appState: AppState) => Promise<false | {
19
+ reconciledElements: SyncableExcalidrawElement[] | null;
20
+ }>;
21
+ export declare const loadFromFirebase: (roomId: string, roomKey: string, socket: SocketIOClient.Socket | null) => Promise<readonly ExcalidrawElement[] | null>;
22
+ export declare const loadFilesFromFirebase: (prefix: string, decryptionKey: string, filesIds: readonly FileId[]) => Promise<{
23
+ loadedFiles: BinaryFileData[];
24
+ erroredFiles: Map<FileId, true>;
25
+ }>;
@@ -0,0 +1,186 @@
1
+ import { ImportedDataState } from "../../data/types";
2
+ import { ExcalidrawElement } from "../../element/types";
3
+ import { AppState, BinaryFiles, UserIdleState } from "../../types";
4
+ export declare type SyncableExcalidrawElement = ExcalidrawElement & {
5
+ _brand: "SyncableExcalidrawElement";
6
+ };
7
+ export declare const isSyncableElement: (element: ExcalidrawElement) => element is SyncableExcalidrawElement;
8
+ export declare const getSyncableElements: (elements: readonly ExcalidrawElement[]) => SyncableExcalidrawElement[];
9
+ /**
10
+ * Right now the reason why we resolve connection params (url, polling...)
11
+ * from upstream is to allow changing the params immediately when needed without
12
+ * having to wait for clients to update the SW.
13
+ *
14
+ * If REACT_APP_WS_SERVER_URL env is set, we use that instead (useful for forks)
15
+ */
16
+ export declare const getCollabServer: () => Promise<{
17
+ url: string;
18
+ polling: boolean;
19
+ }>;
20
+ export declare type EncryptedData = {
21
+ data: ArrayBuffer;
22
+ iv: Uint8Array;
23
+ };
24
+ export declare type SocketUpdateDataSource = {
25
+ SCENE_INIT: {
26
+ type: "SCENE_INIT";
27
+ payload: {
28
+ elements: readonly ExcalidrawElement[];
29
+ };
30
+ };
31
+ SCENE_UPDATE: {
32
+ type: "SCENE_UPDATE";
33
+ payload: {
34
+ elements: readonly ExcalidrawElement[];
35
+ };
36
+ };
37
+ MOUSE_LOCATION: {
38
+ type: "MOUSE_LOCATION";
39
+ payload: {
40
+ socketId: string;
41
+ pointer: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ button: "down" | "up";
46
+ selectedElementIds: AppState["selectedElementIds"];
47
+ username: string;
48
+ };
49
+ };
50
+ IDLE_STATUS: {
51
+ type: "IDLE_STATUS";
52
+ payload: {
53
+ socketId: string;
54
+ userState: UserIdleState;
55
+ username: string;
56
+ };
57
+ };
58
+ };
59
+ export declare type SocketUpdateDataIncoming = SocketUpdateDataSource[keyof SocketUpdateDataSource] | {
60
+ type: "INVALID_RESPONSE";
61
+ };
62
+ export declare type SocketUpdateData = SocketUpdateDataSource[keyof SocketUpdateDataSource] & {
63
+ _brand: "socketUpdateData";
64
+ };
65
+ export declare const isCollaborationLink: (link: string) => boolean;
66
+ export declare const getCollaborationLinkData: (link: string) => {
67
+ roomId: string;
68
+ roomKey: string;
69
+ } | null;
70
+ export declare const generateCollaborationLinkData: () => Promise<{
71
+ roomId: string;
72
+ roomKey: string;
73
+ }>;
74
+ export declare const getCollaborationLink: (data: {
75
+ roomId: string;
76
+ roomKey: string;
77
+ }) => string;
78
+ export declare const loadScene: (id: string | null, privateKey: string | null, localDataState: ImportedDataState | undefined | null) => Promise<{
79
+ elements: ExcalidrawElement[];
80
+ appState: {
81
+ theme: string;
82
+ name: string;
83
+ activeTool: {
84
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
85
+ lastActiveToolBeforeEraser: import("../../types").LastActiveToolBeforeEraser;
86
+ locked: boolean;
87
+ customType: null;
88
+ } | {
89
+ type: "custom";
90
+ customType: string;
91
+ lastActiveToolBeforeEraser: import("../../types").LastActiveToolBeforeEraser;
92
+ locked: boolean;
93
+ };
94
+ scrollX: number;
95
+ scrollY: number;
96
+ viewBackgroundColor: string;
97
+ zoom: Readonly<{
98
+ value: import("../../types").NormalizedZoomValue;
99
+ }>;
100
+ shouldCacheIgnoreZoom: boolean;
101
+ showWelcomeScreen: boolean;
102
+ isLoading: boolean;
103
+ errorMessage: string | null;
104
+ draggingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
105
+ resizingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
106
+ multiElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawLinearElement> | null;
107
+ selectionElement: import("../../element/types").NonDeletedExcalidrawElement | null;
108
+ isBindingEnabled: boolean;
109
+ startBoundElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawBindableElement> | null;
110
+ suggestedBindings: import("../../element/binding").SuggestedBinding[];
111
+ editingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
112
+ editingLinearElement: import("../../element/linearElementEditor").LinearElementEditor | null;
113
+ penMode: boolean;
114
+ penDetected: boolean;
115
+ exportBackground: boolean;
116
+ exportEmbedScene: boolean;
117
+ exportWithDarkMode: boolean;
118
+ exportScale: number;
119
+ currentItemStrokeColor: string;
120
+ currentItemBackgroundColor: string;
121
+ currentItemFillStyle: import("../../element/types").FillStyle;
122
+ currentItemStrokeWidth: number;
123
+ currentItemStrokeStyle: import("../../element/types").StrokeStyle;
124
+ currentItemRoughness: number;
125
+ currentItemOpacity: number;
126
+ currentItemFontFamily: number;
127
+ currentItemFontSize: number;
128
+ currentItemTextAlign: string;
129
+ currentItemStrokeSharpness: import("../../element/types").StrokeSharpness;
130
+ currentItemStartArrowhead: import("../../element/types").Arrowhead | null;
131
+ currentItemEndArrowhead: import("../../element/types").Arrowhead | null;
132
+ currentItemLinearStrokeSharpness: import("../../element/types").StrokeSharpness;
133
+ cursorButton: "up" | "down";
134
+ scrolledOutside: boolean;
135
+ isResizing: boolean;
136
+ isRotating: boolean;
137
+ openMenu: "canvas" | "shape" | null;
138
+ openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
139
+ openSidebar: "library" | "customSidebar" | null;
140
+ openDialog: "imageExport" | "help" | null;
141
+ isSidebarDocked: boolean;
142
+ lastPointerDownWith: import("../../element/types").PointerType;
143
+ selectedElementIds: {
144
+ [id: string]: boolean;
145
+ };
146
+ previousSelectedElementIds: {
147
+ [id: string]: boolean;
148
+ };
149
+ toast: {
150
+ message: string;
151
+ closable?: boolean | undefined;
152
+ duration?: number | undefined;
153
+ } | null;
154
+ zenModeEnabled: boolean;
155
+ gridSize: number | null;
156
+ viewModeEnabled: boolean;
157
+ selectedGroupIds: {
158
+ [groupId: string]: boolean;
159
+ };
160
+ editingGroupId: string | null;
161
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
162
+ collaborators: Map<string, import("../../types").Collaborator>;
163
+ showStats: boolean;
164
+ currentChartType: import("../../element/types").ChartType;
165
+ pasteDialog: {
166
+ shown: false;
167
+ data: null;
168
+ } | {
169
+ shown: true;
170
+ data: import("../../charts").Spreadsheet;
171
+ };
172
+ pendingImageElementId: string | null;
173
+ showHyperlinkPopup: false | "info" | "editor";
174
+ linkOpacity: number;
175
+ trayModeEnabled: boolean;
176
+ colorPalette: {
177
+ canvasBackground?: string[] | undefined;
178
+ elementBackground?: string[] | undefined;
179
+ elementStroke?: string[] | undefined;
180
+ };
181
+ selectedLinearElement: import("../../element/linearElementEditor").LinearElementEditor | null;
182
+ };
183
+ files: BinaryFiles;
184
+ commitToHistory: boolean;
185
+ }>;
186
+ export declare const exportToBackend: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<void>;
@@ -0,0 +1,112 @@
1
+ import { ExcalidrawElement } from "../../element/types";
2
+ export declare const saveUsernameToLocalStorage: (username: string) => void;
3
+ export declare const importUsernameFromLocalStorage: () => string | null;
4
+ export declare const importFromLocalStorage: () => {
5
+ elements: ExcalidrawElement[];
6
+ appState: {
7
+ theme: string;
8
+ name: string;
9
+ activeTool: {
10
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
11
+ lastActiveToolBeforeEraser: import("../../types").LastActiveToolBeforeEraser;
12
+ locked: boolean;
13
+ customType: null;
14
+ } | {
15
+ type: "custom";
16
+ customType: string;
17
+ lastActiveToolBeforeEraser: import("../../types").LastActiveToolBeforeEraser;
18
+ locked: boolean;
19
+ };
20
+ scrollX: number;
21
+ scrollY: number;
22
+ viewBackgroundColor: string;
23
+ zoom: Readonly<{
24
+ value: import("../../types").NormalizedZoomValue;
25
+ }>;
26
+ shouldCacheIgnoreZoom: boolean;
27
+ showWelcomeScreen: boolean;
28
+ penMode: boolean;
29
+ penDetected: boolean;
30
+ exportBackground: boolean;
31
+ exportEmbedScene: boolean;
32
+ exportWithDarkMode: boolean;
33
+ exportScale: number;
34
+ currentItemStrokeColor: string;
35
+ currentItemBackgroundColor: string;
36
+ currentItemFillStyle: import("../../element/types").FillStyle;
37
+ currentItemStrokeWidth: number;
38
+ currentItemStrokeStyle: import("../../element/types").StrokeStyle;
39
+ currentItemRoughness: number;
40
+ currentItemOpacity: number;
41
+ currentItemFontFamily: number;
42
+ currentItemFontSize: number;
43
+ currentItemTextAlign: string;
44
+ currentItemStrokeSharpness: import("../../element/types").StrokeSharpness;
45
+ currentItemStartArrowhead: import("../../element/types").Arrowhead | null;
46
+ currentItemEndArrowhead: import("../../element/types").Arrowhead | null;
47
+ currentItemLinearStrokeSharpness: import("../../element/types").StrokeSharpness;
48
+ cursorButton: "up" | "down";
49
+ scrolledOutside: boolean;
50
+ openMenu: "canvas" | "shape" | null;
51
+ openSidebar: "library" | "customSidebar" | null;
52
+ isSidebarDocked: boolean;
53
+ lastPointerDownWith: import("../../element/types").PointerType;
54
+ selectedElementIds: {
55
+ [id: string]: boolean;
56
+ };
57
+ previousSelectedElementIds: {
58
+ [id: string]: boolean;
59
+ };
60
+ zenModeEnabled: boolean;
61
+ gridSize: number | null;
62
+ selectedGroupIds: {
63
+ [groupId: string]: boolean;
64
+ };
65
+ editingGroupId: string | null;
66
+ showStats: boolean;
67
+ currentChartType: import("../../element/types").ChartType;
68
+ selectedLinearElement: import("../../element/linearElementEditor").LinearElementEditor | null;
69
+ isLoading: boolean;
70
+ errorMessage: string | null;
71
+ draggingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
72
+ resizingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
73
+ multiElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawLinearElement> | null;
74
+ selectionElement: import("../../element/types").NonDeletedExcalidrawElement | null;
75
+ isBindingEnabled: boolean;
76
+ startBoundElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawBindableElement> | null;
77
+ suggestedBindings: import("../../element/binding").SuggestedBinding[];
78
+ editingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
79
+ editingLinearElement: import("../../element/linearElementEditor").LinearElementEditor | null;
80
+ isResizing: boolean;
81
+ isRotating: boolean;
82
+ openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
83
+ openDialog: "imageExport" | "help" | null;
84
+ toast: {
85
+ message: string;
86
+ closable?: boolean | undefined;
87
+ duration?: number | undefined;
88
+ } | null;
89
+ viewModeEnabled: boolean;
90
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
91
+ collaborators: Map<string, import("../../types").Collaborator>;
92
+ pasteDialog: {
93
+ shown: false;
94
+ data: null;
95
+ } | {
96
+ shown: true;
97
+ data: import("../../charts").Spreadsheet;
98
+ };
99
+ pendingImageElementId: string | null;
100
+ showHyperlinkPopup: false | "info" | "editor";
101
+ linkOpacity: number;
102
+ trayModeEnabled: boolean;
103
+ colorPalette: {
104
+ canvasBackground?: string[] | undefined;
105
+ elementBackground?: string[] | undefined;
106
+ elementStroke?: string[] | undefined;
107
+ };
108
+ } | null;
109
+ };
110
+ export declare const getElementsStorageSize: () => number;
111
+ export declare const getTotalStorageSize: () => number;
112
+ export declare const getLibraryItemsFromStorage: () => import("../../types").LibraryItems_anyVersion;
@@ -0,0 +1,9 @@
1
+ declare const LOCAL_STATE_VERSIONS: {
2
+ "version-dataState": number;
3
+ "version-files": number;
4
+ };
5
+ declare type BrowserStateTypes = keyof typeof LOCAL_STATE_VERSIONS;
6
+ export declare const isBrowserStorageStateNewer: (type: BrowserStateTypes) => boolean;
7
+ export declare const updateBrowserStateVersion: (type: BrowserStateTypes) => void;
8
+ export declare const resetBrowserStateVersions: () => void;
9
+ export {};
@@ -0,0 +1,26 @@
1
+ import "./index.scss";
2
+ export declare const langCodeAtom: import("jotai").Atom<string> & {
3
+ write: (get: {
4
+ <Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
5
+ <Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
6
+ <Value_2>(atom: import("jotai").Atom<Value_2>): Value_2 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_2;
7
+ } & {
8
+ <Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
9
+ unstable_promise: true;
10
+ }): Value_3 | Promise<Value_3>;
11
+ <Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
12
+ unstable_promise: true;
13
+ }): Value_4 | Promise<Value_4>;
14
+ <Value_5>(atom: import("jotai").Atom<Value_5>, options: {
15
+ unstable_promise: true;
16
+ }): (Value_5 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_5) | Promise<Value_5 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_5>;
17
+ }, set: {
18
+ <Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
19
+ <Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
20
+ }, update: string | ((prev: string) => string)) => void;
21
+ onMount?: (<S extends (update: string | ((prev: string) => string)) => void>(setAtom: S) => void | (() => void)) | undefined;
22
+ } & {
23
+ init: string;
24
+ };
25
+ declare const ExcalidrawApp: () => JSX.Element;
26
+ export default ExcalidrawApp;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useOutsideClickHook: (handler: (event: Event) => void) => import("react").MutableRefObject<null>;
package/types/keys.d.ts CHANGED
@@ -60,6 +60,16 @@ export declare const KEYS: {
60
60
  readonly Y: "y";
61
61
  readonly Z: "z";
62
62
  readonly K: "k";
63
+ readonly 0: "0";
64
+ readonly 1: "1";
65
+ readonly 2: "2";
66
+ readonly 3: "3";
67
+ readonly 4: "4";
68
+ readonly 5: "5";
69
+ readonly 6: "6";
70
+ readonly 7: "7";
71
+ readonly 8: "8";
72
+ readonly 9: "9";
63
73
  };
64
74
  export declare type Key = keyof typeof KEYS;
65
75
  export declare const isArrowKey: (key: string) => boolean;
@@ -12,6 +12,9 @@ getMaximumGroups, //zsviczian
12
12
  intersectElementWithLine, //zsviczian
13
13
  determineFocusDistance, //zsviczian
14
14
  measureText, //zsviczian
15
+ wrapText, //zsviczian
16
+ getFontString, //zsviczian
17
+ getMaxContainerWidth, //zsviczian
15
18
  exportToClipboard, mergeLibraryItems, } from "../../packages/utils";
16
19
  export { isLinearElement } from "../../element/typeChecks";
17
20
  export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
@@ -36,5 +36,7 @@ export { getCommonBoundingBox } from "../element/bounds";
36
36
  export { getMaximumGroups } from "../groups";
37
37
  export { intersectElementWithLine } from "../element/collision";
38
38
  export { determineFocusDistance } from "../element/collision";
39
- export { measureText } from "../element/textElement";
39
+ export { measureText, wrapText } from "../element/textElement";
40
+ export { getFontString } from "../utils";
41
+ export { getMaxContainerWidth } from "../element/newElement";
40
42
  export { mergeLibraryItems } from "../data/library";
@@ -3,7 +3,7 @@ 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 DEFAULT_SPACING = 4;
6
+ export declare const DEFAULT_SPACING = 2;
7
7
  export declare const _renderScene: ({ elements, appState, scale, rc, canvas, renderConfig, }: {
8
8
  elements: readonly NonDeletedExcalidrawElement[];
9
9
  appState: AppState;
@@ -33,6 +33,7 @@ export declare type RenderConfig = {
33
33
  /** when exporting the behavior is slightly different (e.g. we can't use
34
34
  CSS filters), and we disable render optimizations for best output */
35
35
  isExporting: boolean;
36
+ selectionColor?: string;
36
37
  };
37
38
  export declare type SceneScroll = {
38
39
  scrollX: number;
package/types/shapes.d.ts CHANGED
@@ -2,37 +2,61 @@ export declare const SHAPES: readonly [{
2
2
  readonly icon: JSX.Element;
3
3
  readonly value: "selection";
4
4
  readonly key: "v";
5
+ readonly numericKey: "1";
6
+ readonly fillable: true;
5
7
  }, {
6
8
  readonly icon: JSX.Element;
7
9
  readonly value: "rectangle";
8
10
  readonly key: "r";
11
+ readonly numericKey: "2";
12
+ readonly fillable: true;
9
13
  }, {
10
14
  readonly icon: JSX.Element;
11
15
  readonly value: "diamond";
12
16
  readonly key: "d";
17
+ readonly numericKey: "3";
18
+ readonly fillable: true;
13
19
  }, {
14
20
  readonly icon: JSX.Element;
15
21
  readonly value: "ellipse";
16
22
  readonly key: "o";
23
+ readonly numericKey: "4";
24
+ readonly fillable: true;
17
25
  }, {
18
26
  readonly icon: JSX.Element;
19
27
  readonly value: "arrow";
20
28
  readonly key: "a";
29
+ readonly numericKey: "5";
30
+ readonly fillable: true;
21
31
  }, {
22
32
  readonly icon: JSX.Element;
23
33
  readonly value: "line";
24
- readonly key: readonly ["p", "l"];
34
+ readonly key: "l";
35
+ readonly numericKey: "6";
36
+ readonly fillable: true;
25
37
  }, {
26
38
  readonly icon: JSX.Element;
27
39
  readonly value: "freedraw";
28
- readonly key: readonly ["x", string];
40
+ readonly key: readonly ["p", "x"];
41
+ readonly numericKey: "7";
42
+ readonly fillable: false;
29
43
  }, {
30
44
  readonly icon: JSX.Element;
31
45
  readonly value: "text";
32
46
  readonly key: "t";
47
+ readonly numericKey: "8";
48
+ readonly fillable: false;
33
49
  }, {
34
50
  readonly icon: JSX.Element;
35
51
  readonly value: "image";
36
52
  readonly key: null;
53
+ readonly numericKey: "9";
54
+ readonly fillable: false;
55
+ }, {
56
+ readonly icon: JSX.Element;
57
+ readonly value: "eraser";
58
+ readonly key: "e";
59
+ readonly numericKey: "0";
60
+ readonly fillable: false;
37
61
  }];
38
- export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
62
+ export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | null;
package/types/types.d.ts CHANGED
@@ -39,7 +39,18 @@ export declare type BinaryFileData = {
39
39
  mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number] | typeof MIME_TYPES.binary;
40
40
  id: FileId;
41
41
  dataURL: DataURL;
42
+ /**
43
+ * Epoch timestamp in milliseconds
44
+ */
42
45
  created: number;
46
+ /**
47
+ * Indicates when the file was last retrieved from storage to be loaded
48
+ * onto the scene. We use this flag to determine whether to delete unused
49
+ * files from storage.
50
+ *
51
+ * Epoch timestamp in milliseconds.
52
+ */
53
+ lastRetrieved?: number;
43
54
  };
44
55
  export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
45
56
  export declare type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
@@ -51,6 +62,7 @@ export declare type LastActiveToolBeforeEraser = {
51
62
  customType: string;
52
63
  } | null;
53
64
  export declare type AppState = {
65
+ showWelcomeScreen: boolean;
54
66
  isLoading: boolean;
55
67
  errorMessage: string | null;
56
68
  draggingElement: NonDeletedExcalidrawElement | null;
@@ -105,6 +117,7 @@ export declare type AppState = {
105
117
  openMenu: "canvas" | "shape" | null;
106
118
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
107
119
  openSidebar: "library" | "customSidebar" | null;
120
+ openDialog: "imageExport" | "help" | null;
108
121
  isSidebarDocked: boolean;
109
122
  lastPointerDownWith: PointerType;
110
123
  selectedElementIds: {
@@ -114,7 +127,6 @@ export declare type AppState = {
114
127
  [id: string]: boolean;
115
128
  };
116
129
  shouldCacheIgnoreZoom: boolean;
117
- showHelpDialog: boolean;
118
130
  toast: {
119
131
  message: string;
120
132
  closable?: boolean;