@excalidraw/math 0.18.0-7ea3229 → 0.18.0-816c81c

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 (87) hide show
  1. package/dist/types/common/src/appEventBus.d.ts +27 -0
  2. package/dist/types/common/src/colors.d.ts +1 -1
  3. package/dist/types/common/src/index.d.ts +2 -0
  4. package/dist/types/common/src/utils.d.ts +1 -3
  5. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  6. package/dist/types/element/src/Scene.d.ts +2 -0
  7. package/dist/types/element/src/arrowheads.d.ts +3 -0
  8. package/dist/types/element/src/binding.d.ts +3 -4
  9. package/dist/types/element/src/bounds.d.ts +1 -1
  10. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  11. package/dist/types/element/src/index.d.ts +1 -0
  12. package/dist/types/element/src/linearElementEditor.d.ts +3 -0
  13. package/dist/types/element/src/mutateElement.d.ts +2 -0
  14. package/dist/types/element/src/types.d.ts +5 -2
  15. package/dist/types/element/src/utils.d.ts +1 -1
  16. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +23 -29
  17. package/dist/types/excalidraw/actions/actionBoundText.d.ts +16 -20
  18. package/dist/types/excalidraw/actions/actionCanvas.d.ts +97 -121
  19. package/dist/types/excalidraw/actions/actionClipboard.d.ts +16 -20
  20. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +8 -10
  21. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +24 -30
  22. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -10
  23. package/dist/types/excalidraw/actions/actionElementLock.d.ts +16 -20
  24. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +8 -10
  25. package/dist/types/excalidraw/actions/actionExport.d.ts +60 -344
  26. package/dist/types/excalidraw/actions/actionFrame.d.ts +32 -40
  27. package/dist/types/excalidraw/actions/actionGroup.d.ts +16 -20
  28. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -10
  29. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -10
  30. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -10
  31. package/dist/types/excalidraw/actions/actionProperties.d.ts +16 -20
  32. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +8 -10
  33. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -9
  34. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
  35. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -10
  36. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
  37. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -10
  38. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -10
  39. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +8 -10
  40. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -10
  41. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -10
  42. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  43. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  44. package/dist/types/excalidraw/appState.d.ts +4 -2
  45. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  46. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  47. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  48. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  49. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  50. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  51. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  52. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  53. package/dist/types/excalidraw/clipboard.d.ts +2 -5
  54. package/dist/types/excalidraw/components/App.d.ts +33 -11
  55. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  56. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  57. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  58. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  59. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  60. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  61. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  62. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  63. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  64. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  65. package/dist/types/excalidraw/components/icons.d.ts +17 -8
  66. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  67. package/dist/types/excalidraw/data/blob.d.ts +25 -30
  68. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  69. package/dist/types/excalidraw/data/index.d.ts +2 -3
  70. package/dist/types/excalidraw/data/json.d.ts +28 -22
  71. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  72. package/dist/types/excalidraw/types.d.ts +84 -13
  73. package/package.json +2 -2
  74. package/dist/types/excalidraw/charts.d.ts +0 -27
  75. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  76. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  77. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  78. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  79. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  80. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  81. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  82. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  83. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  84. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  85. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  86. package/dist/types/excalidraw/index.d.ts +0 -47
  87. package/dist/types/excalidraw/polyfill.d.ts +0 -2
@@ -2,12 +2,11 @@ import { IMAGE_MIME_TYPES, MIME_TYPES } from "@excalidraw/common";
2
2
  import type { ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { ExcalidrawElement, FileId } from "@excalidraw/element/types";
4
4
  import type { AppState, DataURL, LibraryItem } from "../types";
5
- import type { FileSystemHandle } from "browser-fs-access";
6
5
  import type { ImportedLibraryData } from "./types";
7
6
  export declare const getMimeType: (blob: Blob | string) => string;
8
- export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null;
7
+ export declare const getFileHandleType: (handle: FileSystemFileHandle | null) => string | null;
9
8
  export declare const isImageFileHandleType: (type: string | null) => type is "png" | "svg";
10
- export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
9
+ export declare const isImageFileHandle: (handle: FileSystemFileHandle | null) => handle is FileSystemFileHandle;
11
10
  export declare const isSupportedImageFileType: (type: string | null | undefined) => boolean;
12
11
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
13
12
  type: ValueOf<typeof IMAGE_MIME_TYPES>;
@@ -15,8 +14,8 @@ export declare const isSupportedImageFile: (blob: Blob | null | undefined) => bl
15
14
  export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File,
16
15
  /** @see restore.localAppState */
17
16
  localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null,
18
- /** FileSystemHandle. Defaults to `blob.handle` if defined, otherwise null. */
19
- fileHandle?: FileSystemHandle | null) => Promise<{
17
+ /** FileSystemFileHandle. Defaults to `blob.handle` if defined, otherwise null. */
18
+ fileHandle?: FileSystemFileHandle | null) => Promise<{
20
19
  type: "application/vnd.excalidraw+json";
21
20
  data: {
22
21
  elements: import("@excalidraw/element/types").OrderedExcalidrawElement[];
@@ -46,6 +45,10 @@ fileHandle?: FileSystemHandle | null) => Promise<{
46
45
  } | {
47
46
  name: "elementLinkSelector";
48
47
  sourceElementId: ExcalidrawElement["id"];
48
+ } | {
49
+ name: "charts";
50
+ data: import("../charts").Spreadsheet;
51
+ rawText: string;
49
52
  };
50
53
  editingGroupId: import("@excalidraw/element/types").GroupId | null;
51
54
  selectedElementIds: Readonly<{
@@ -69,6 +72,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
69
72
  multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
70
73
  newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
71
74
  isBindingEnabled: boolean;
75
+ isMidpointSnappingEnabled: boolean;
72
76
  suggestedBinding: {
73
77
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
74
78
  midPoint?: import("@excalidraw/math").GlobalPoint;
@@ -91,6 +95,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
91
95
  }>;
92
96
  shouldCacheIgnoreZoom: boolean;
93
97
  exportScale: number;
98
+ currentItemArrowType: "sharp" | "round" | "elbow";
94
99
  bindMode: import("@excalidraw/element/types").BindMode;
95
100
  gridSize: number;
96
101
  contextMenu: {
@@ -102,6 +107,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
102
107
  isLoading: boolean;
103
108
  errorMessage: React.ReactNode;
104
109
  resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
110
+ bindingPreference: "enabled" | "disabled";
105
111
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
106
112
  editingFrame: string | null;
107
113
  preferredSelectionTool: {
@@ -127,7 +133,6 @@ fileHandle?: FileSystemHandle | null) => Promise<{
127
133
  currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
128
134
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
129
135
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
130
- currentItemArrowType: "sharp" | "round" | "elbow";
131
136
  cursorButton: "up" | "down";
132
137
  scrolledOutside: boolean;
133
138
  isResizing: boolean;
@@ -144,25 +149,17 @@ fileHandle?: FileSystemHandle | null) => Promise<{
144
149
  };
145
150
  selectedElementsAreBeingDragged: boolean;
146
151
  toast: {
147
- message: string;
152
+ message: React.ReactNode;
148
153
  closable?: boolean;
149
154
  duration?: number;
150
155
  } | null;
151
156
  gridStep: number;
152
157
  gridModeEnabled: boolean;
153
- fileHandle: FileSystemHandle | null;
158
+ fileHandle: FileSystemFileHandle | null;
154
159
  stats: {
155
160
  open: boolean;
156
161
  panels: number;
157
162
  };
158
- currentChartType: import("@excalidraw/element/types").ChartType;
159
- pasteDialog: {
160
- shown: false;
161
- data: null;
162
- } | {
163
- shown: true;
164
- data: import("../charts").Spreadsheet;
165
- };
166
163
  showHyperlinkPopup: false | "info" | "editor";
167
164
  originSnapOffset: {
168
165
  x: number;
@@ -184,8 +181,8 @@ fileHandle?: FileSystemHandle | null) => Promise<{
184
181
  export declare const loadFromBlob: (blob: Blob,
185
182
  /** @see restore.localAppState */
186
183
  localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null,
187
- /** FileSystemHandle. Defaults to `blob.handle` if defined, otherwise null. */
188
- fileHandle?: FileSystemHandle | null) => Promise<{
184
+ /** FileSystemFileHandle. Defaults to `blob.handle` if defined, otherwise null. */
185
+ fileHandle?: FileSystemFileHandle | null) => Promise<{
189
186
  elements: import("@excalidraw/element/types").OrderedExcalidrawElement[];
190
187
  appState: {
191
188
  viewBackgroundColor: string;
@@ -213,6 +210,10 @@ fileHandle?: FileSystemHandle | null) => Promise<{
213
210
  } | {
214
211
  name: "elementLinkSelector";
215
212
  sourceElementId: ExcalidrawElement["id"];
213
+ } | {
214
+ name: "charts";
215
+ data: import("../charts").Spreadsheet;
216
+ rawText: string;
216
217
  };
217
218
  editingGroupId: import("@excalidraw/element/types").GroupId | null;
218
219
  selectedElementIds: Readonly<{
@@ -236,6 +237,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
236
237
  multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
237
238
  newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
238
239
  isBindingEnabled: boolean;
240
+ isMidpointSnappingEnabled: boolean;
239
241
  suggestedBinding: {
240
242
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
241
243
  midPoint?: import("@excalidraw/math").GlobalPoint;
@@ -258,6 +260,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
258
260
  }>;
259
261
  shouldCacheIgnoreZoom: boolean;
260
262
  exportScale: number;
263
+ currentItemArrowType: "sharp" | "round" | "elbow";
261
264
  bindMode: import("@excalidraw/element/types").BindMode;
262
265
  gridSize: number;
263
266
  contextMenu: {
@@ -269,6 +272,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
269
272
  isLoading: boolean;
270
273
  errorMessage: React.ReactNode;
271
274
  resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
275
+ bindingPreference: "enabled" | "disabled";
272
276
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
273
277
  editingFrame: string | null;
274
278
  preferredSelectionTool: {
@@ -294,7 +298,6 @@ fileHandle?: FileSystemHandle | null) => Promise<{
294
298
  currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
295
299
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
296
300
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
297
- currentItemArrowType: "sharp" | "round" | "elbow";
298
301
  cursorButton: "up" | "down";
299
302
  scrolledOutside: boolean;
300
303
  isResizing: boolean;
@@ -311,25 +314,17 @@ fileHandle?: FileSystemHandle | null) => Promise<{
311
314
  };
312
315
  selectedElementsAreBeingDragged: boolean;
313
316
  toast: {
314
- message: string;
317
+ message: React.ReactNode;
315
318
  closable?: boolean;
316
319
  duration?: number;
317
320
  } | null;
318
321
  gridStep: number;
319
322
  gridModeEnabled: boolean;
320
- fileHandle: FileSystemHandle | null;
323
+ fileHandle: FileSystemFileHandle | null;
321
324
  stats: {
322
325
  open: boolean;
323
326
  panels: number;
324
327
  };
325
- currentChartType: import("@excalidraw/element/types").ChartType;
326
- pasteDialog: {
327
- shown: false;
328
- data: null;
329
- } | {
330
- shown: true;
331
- data: import("../charts").Spreadsheet;
332
- };
333
328
  showHyperlinkPopup: false | "info" | "editor";
334
329
  originSnapOffset: {
335
330
  x: number;
@@ -364,7 +359,7 @@ export declare const SVGStringToFile: (SVGString: string, filename?: string) =>
364
359
  type: typeof MIME_TYPES.svg;
365
360
  };
366
361
  export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>;
367
- export declare const getFileHandle: (event: DragEvent | React.DragEvent | DataTransferItem) => Promise<FileSystemHandle | null>;
362
+ export declare const getFileHandle: (event: DragEvent | React.DragEvent | DataTransferItem) => Promise<FileSystemFileHandle | null>;
368
363
  export declare const createFile: (blob: File | Blob | ArrayBuffer, mimeType: string, name: string | undefined) => File;
369
364
  /** attempts to detect correct mimeType if none is set, or if an image
370
365
  * has an incorrect extension.
@@ -1,6 +1,5 @@
1
1
  import { supported as nativeFileSystemSupported } from "browser-fs-access";
2
2
  import { MIME_TYPES } from "@excalidraw/common";
3
- import type { FileSystemHandle } from "browser-fs-access";
4
3
  type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
5
4
  export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
6
5
  extensions?: FILE_EXTENSION[];
@@ -14,8 +13,7 @@ export declare const fileSave: (blob: Blob | Promise<Blob>, opts: {
14
13
  extension: FILE_EXTENSION;
15
14
  mimeTypes?: string[];
16
15
  description: string;
17
- /** existing FileSystemHandle */
18
- fileHandle?: FileSystemHandle | null;
19
- }) => Promise<FileSystemHandle | null>;
16
+ /** existing FileSystemFileHandle */
17
+ fileHandle?: FileSystemFileHandle | null;
18
+ }) => Promise<FileSystemFileHandle | null>;
20
19
  export { nativeFileSystemSupported };
21
- export type { FileSystemHandle };
@@ -1,5 +1,4 @@
1
1
  import type { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
- import type { FileSystemHandle } from "./filesystem";
3
2
  import type { ExportType } from "../scene/types";
4
3
  import type { AppState, BinaryFiles } from "../types";
5
4
  export { loadFromBlob } from "./blob";
@@ -17,6 +16,6 @@ export declare const exportCanvas: (type: Omit<ExportType, "backend">, elements:
17
16
  viewBackgroundColor: string;
18
17
  /** filename, if applicable */
19
18
  name?: string;
20
- fileHandle?: FileSystemHandle | null;
19
+ fileHandle?: FileSystemFileHandle | null;
21
20
  exportingFrame: ExcalidrawFrameLikeElement | null;
22
- }) => Promise<FileSystemHandle | null | undefined>;
21
+ }) => Promise<FileSystemFileHandle | null | undefined>;
@@ -1,11 +1,19 @@
1
- import type { ExcalidrawElement } from "@excalidraw/element/types";
1
+ import type { ExcalidrawElement, NonDeleted } from "@excalidraw/element/types";
2
+ import type { MaybePromise } from "@excalidraw/common/utility-types";
2
3
  import type { AppState, BinaryFiles, LibraryItems } from "../types";
3
4
  import type { ImportedDataState, ImportedLibraryData } from "./types";
5
+ export type JSONExportData = {
6
+ elements: readonly NonDeleted<ExcalidrawElement>[];
7
+ appState: AppState;
8
+ files: BinaryFiles;
9
+ };
4
10
  export declare const serializeAsJSON: (elements: readonly ExcalidrawElement[], appState: Partial<AppState>, files: BinaryFiles, type: "local" | "database") => string;
5
- export declare const saveAsJSON: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles,
6
- /** filename */
7
- name?: string) => Promise<{
8
- fileHandle: import("browser-fs-access").FileSystemHandle | null;
11
+ export declare const saveAsJSON: ({ data, filename, fileHandle, }: {
12
+ data: MaybePromise<JSONExportData>;
13
+ filename: string;
14
+ fileHandle: AppState["fileHandle"];
15
+ }) => Promise<{
16
+ fileHandle: FileSystemFileHandle | null;
9
17
  }>;
10
18
  export declare const loadFromJSON: (localAppState: AppState, localElements: readonly ExcalidrawElement[] | null) => Promise<{
11
19
  elements: import("@excalidraw/element/types").OrderedExcalidrawElement[];
@@ -35,12 +43,16 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
35
43
  } | {
36
44
  name: "elementLinkSelector";
37
45
  sourceElementId: ExcalidrawElement["id"];
46
+ } | {
47
+ name: "charts";
48
+ data: import("../charts").Spreadsheet;
49
+ rawText: string;
38
50
  };
39
51
  editingGroupId: import("@excalidraw/element/types").GroupId | null;
40
52
  selectedElementIds: Readonly<{
41
53
  [id: string]: true;
42
54
  }>;
43
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
55
+ frameToHighlight: NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
44
56
  activeTool: {
45
57
  lastActiveTool: import("../types").ActiveTool | null;
46
58
  locked: boolean;
@@ -55,15 +67,16 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
55
67
  [groupId: string]: boolean;
56
68
  };
57
69
  selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
58
- multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
59
- newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
70
+ multiElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
71
+ newElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
60
72
  isBindingEnabled: boolean;
73
+ isMidpointSnappingEnabled: boolean;
61
74
  suggestedBinding: {
62
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
75
+ element: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
63
76
  midPoint?: import("@excalidraw/math").GlobalPoint;
64
77
  } | null;
65
78
  isRotating: boolean;
66
- elementsToHighlight: import("@excalidraw/element/types").NonDeleted<ExcalidrawElement>[] | null;
79
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
67
80
  collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
68
81
  snapLines: readonly import("../snapping").SnapLine[];
69
82
  zenModeEnabled: boolean;
@@ -80,6 +93,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
80
93
  }>;
81
94
  shouldCacheIgnoreZoom: boolean;
82
95
  exportScale: number;
96
+ currentItemArrowType: "sharp" | "round" | "elbow";
83
97
  bindMode: import("@excalidraw/element/types").BindMode;
84
98
  gridSize: number;
85
99
  contextMenu: {
@@ -91,7 +105,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
91
105
  isLoading: boolean;
92
106
  errorMessage: React.ReactNode;
93
107
  resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
94
- startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
108
+ bindingPreference: "enabled" | "disabled";
109
+ startBoundElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
95
110
  editingFrame: string | null;
96
111
  preferredSelectionTool: {
97
112
  type: "selection" | "lasso";
@@ -116,7 +131,6 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
116
131
  currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
117
132
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
118
133
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
119
- currentItemArrowType: "sharp" | "round" | "elbow";
120
134
  cursorButton: "up" | "down";
121
135
  scrolledOutside: boolean;
122
136
  isResizing: boolean;
@@ -133,25 +147,17 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
133
147
  };
134
148
  selectedElementsAreBeingDragged: boolean;
135
149
  toast: {
136
- message: string;
150
+ message: React.ReactNode;
137
151
  closable?: boolean;
138
152
  duration?: number;
139
153
  } | null;
140
154
  gridStep: number;
141
155
  gridModeEnabled: boolean;
142
- fileHandle: import("browser-fs-access").FileSystemHandle | null;
156
+ fileHandle: FileSystemFileHandle | null;
143
157
  stats: {
144
158
  open: boolean;
145
159
  panels: number;
146
160
  };
147
- currentChartType: import("@excalidraw/element/types").ChartType;
148
- pasteDialog: {
149
- shown: false;
150
- data: null;
151
- } | {
152
- shown: true;
153
- data: import("../charts").Spreadsheet;
154
- };
155
161
  showHyperlinkPopup: false | "info" | "editor";
156
162
  originSnapOffset: {
157
163
  x: number;
@@ -1,5 +1,10 @@
1
+ import type { MaybePromise } from "@excalidraw/common/utility-types";
1
2
  import type { ExcalidrawElement } from "@excalidraw/element/types";
2
3
  import type { AppState, BinaryFiles } from "../types";
3
- export declare const resaveAsImageWithScene: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, name: string) => Promise<{
4
- fileHandle: import("browser-fs-access").FileSystemHandle;
4
+ export declare const resaveAsImageWithScene: (data: MaybePromise<{
5
+ elements: readonly ExcalidrawElement[];
6
+ appState: AppState;
7
+ files: BinaryFiles;
8
+ }>, fileHandle: FileSystemFileHandle, filename: string) => Promise<{
9
+ fileHandle: FileSystemFileHandle;
5
10
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
2
2
  import type { LinearElementEditor } from "@excalidraw/element";
3
3
  import type { MaybeTransformHandleType } from "@excalidraw/element";
4
- import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode } from "@excalidraw/element/types";
4
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode } from "@excalidraw/element/types";
5
5
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
6
6
  import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
7
7
  import type { GlobalPoint } from "@excalidraw/math";
@@ -10,7 +10,6 @@ import type { Spreadsheet } from "./charts";
10
10
  import type { ClipboardData } from "./clipboard";
11
11
  import type App from "./components/App";
12
12
  import type Library from "./data/library";
13
- import type { FileSystemHandle } from "./data/filesystem";
14
13
  import type { ContextMenuItems } from "./components/ContextMenu";
15
14
  import type { SnapLine } from "./snapping";
16
15
  import type { ImportedDataState } from "./data/types";
@@ -138,6 +137,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
138
137
  multiElement: AppState["multiElement"];
139
138
  newElement: AppState["newElement"];
140
139
  isBindingEnabled: AppState["isBindingEnabled"];
140
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
141
141
  suggestedBinding: AppState["suggestedBinding"];
142
142
  isRotating: AppState["isRotating"];
143
143
  elementsToHighlight: AppState["elementsToHighlight"];
@@ -153,6 +153,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
153
153
  frameRendering: AppState["frameRendering"];
154
154
  shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
155
155
  exportScale: AppState["exportScale"];
156
+ currentItemArrowType: AppState["currentItemArrowType"];
156
157
  }>;
157
158
  export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
158
159
  export type ObservedStandaloneAppState = {
@@ -204,7 +205,15 @@ export interface AppState {
204
205
  * - set on pointer down, updated during pointer move
205
206
  */
206
207
  selectionElement: NonDeletedExcalidrawElement | null;
208
+ /**
209
+ * tracking current arrow binding editor state (takes into account
210
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
211
+ */
207
212
  isBindingEnabled: boolean;
213
+ /** user arrow binding preference */
214
+ bindingPreference: "enabled" | "disabled";
215
+ /** user preference whether arrow snap to midpoints while binding */
216
+ isMidpointSnappingEnabled: boolean;
208
217
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
209
218
  suggestedBinding: {
210
219
  element: NonDeleted<ExcalidrawBindableElement>;
@@ -284,6 +293,10 @@ export interface AppState {
284
293
  } | {
285
294
  name: "elementLinkSelector";
286
295
  sourceElementId: ExcalidrawElement["id"];
296
+ } | {
297
+ name: "charts";
298
+ data: Spreadsheet;
299
+ rawText: string;
287
300
  };
288
301
  /**
289
302
  * Reflects user preference for whether the default sidebar should be docked.
@@ -306,7 +319,7 @@ export interface AppState {
306
319
  selectedElementsAreBeingDragged: boolean;
307
320
  shouldCacheIgnoreZoom: boolean;
308
321
  toast: {
309
- message: string;
322
+ message: React.ReactNode;
310
323
  closable?: boolean;
311
324
  duration?: number;
312
325
  } | null;
@@ -328,21 +341,13 @@ export interface AppState {
328
341
  height: number;
329
342
  offsetTop: number;
330
343
  offsetLeft: number;
331
- fileHandle: FileSystemHandle | null;
344
+ fileHandle: FileSystemFileHandle | null;
332
345
  collaborators: Map<SocketId, Collaborator>;
333
346
  stats: {
334
347
  open: boolean;
335
348
  /** bitmap. Use `STATS_PANELS` bit values */
336
349
  panels: number;
337
350
  };
338
- currentChartType: ChartType;
339
- pasteDialog: {
340
- shown: false;
341
- data: null;
342
- } | {
343
- shown: true;
344
- data: Spreadsheet;
345
- };
346
351
  showHyperlinkPopup: false | "info" | "editor";
347
352
  selectedLinearElement: LinearElementEditor | null;
348
353
  snapLines: readonly SnapLine[];
@@ -429,11 +434,36 @@ export type OnUserFollowedPayload = {
429
434
  userToFollow: UserToFollow;
430
435
  action: "FOLLOW" | "UNFOLLOW";
431
436
  };
437
+ export type OnExportProgress = {
438
+ type: "progress";
439
+ message?: React.ReactNode;
440
+ /** 0-1 range */
441
+ progress?: number;
442
+ };
432
443
  export interface ExcalidrawProps {
433
444
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
445
+ /**
446
+ * note: only subscribes if the props.onIncrement is defined on initial render
447
+ */
434
448
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
435
449
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
436
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
450
+ /**
451
+ * Invoked as soon as the Excalidraw API is available
452
+ * NOTE editor is not yet mounted, and state is not yet initialized
453
+ */
454
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
455
+ /**
456
+ * Invoked once the editor root is mounted.
457
+ */
458
+ onMount?: (payload: ExcalidrawMountPayload) => void;
459
+ /**
460
+ * Invoked when the editor root is unmounted.
461
+ */
462
+ onUnmount?: () => void;
463
+ /**
464
+ * Invoked once the initial scene is loaded.
465
+ */
466
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
437
467
  isCollaborating?: boolean;
438
468
  onPointerUpdate?: (payload: {
439
469
  pointer: {
@@ -490,6 +520,29 @@ export interface ExcalidrawProps {
490
520
  aiEnabled?: boolean;
491
521
  showDeprecatedFonts?: boolean;
492
522
  renderScrollbars?: boolean;
523
+ /**
524
+ * Called before exporting to a file.
525
+ *
526
+ * Allows the host app to intercept and delay saving until async operations
527
+ * (e.g., images are loaded) complete.
528
+ *
529
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
530
+ * until the operation completes. Generator can yield progress updates.
531
+ */
532
+ onExport?: (
533
+ /** type of export. Currently we only call for JSON exports or
534
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
535
+ type: "json", data: {
536
+ elements: readonly ExcalidrawElement[];
537
+ appState: AppState;
538
+ files: BinaryFiles;
539
+ }, options: {
540
+ /** signal that gets aborted if user cancels the export (e.g. closes
541
+ * the native file picker dialog). In that case, you can either
542
+ * return immediately, or throw AbortError.
543
+ */
544
+ signal: AbortSignal;
545
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
493
546
  }
494
547
  export type SceneData = {
495
548
  elements?: ImportedDataState["elements"];
@@ -542,6 +595,8 @@ export type AppProps = Merge<ExcalidrawProps, {
542
595
  export type AppClassProperties = {
543
596
  props: AppProps;
544
597
  state: AppState;
598
+ api: App["api"];
599
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
545
600
  interactiveCanvas: HTMLCanvasElement | null;
546
601
  /** static canvas */
547
602
  canvas: HTMLCanvasElement;
@@ -582,8 +637,11 @@ export type AppClassProperties = {
582
637
  onPointerUpEmitter: App["onPointerUpEmitter"];
583
638
  updateEditorAtom: App["updateEditorAtom"];
584
639
  onPointerDownEmitter: App["onPointerDownEmitter"];
640
+ onEvent: App["onEvent"];
641
+ onStateChange: App["onStateChange"];
585
642
  lastPointerMoveCoords: App["lastPointerMoveCoords"];
586
643
  bindModeHandler: App["bindModeHandler"];
644
+ setAppState: App["setAppState"];
587
645
  };
588
646
  export type PointerDownState = Readonly<{
589
647
  origin: Readonly<{
@@ -644,7 +702,18 @@ export type PointerDownState = Readonly<{
644
702
  };
645
703
  }>;
646
704
  export type UnsubscribeCallback = () => void;
705
+ export type ExcalidrawMountPayload = {
706
+ excalidrawAPI: ExcalidrawImperativeAPI;
707
+ container: HTMLDivElement | null;
708
+ };
709
+ export type ExcalidrawImperativeAPIEventMap = {
710
+ "editor:mount": [payload: ExcalidrawMountPayload];
711
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
712
+ "editor:unmount": [];
713
+ };
647
714
  export interface ExcalidrawImperativeAPI {
715
+ /** Whether the editor has been unmounted and the API is no longer usable. */
716
+ isDestroyed: boolean;
648
717
  updateScene: InstanceType<typeof App>["updateScene"];
649
718
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
650
719
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -682,6 +751,8 @@ export interface ExcalidrawImperativeAPI {
682
751
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
683
752
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
684
753
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
754
+ onStateChange: InstanceType<typeof App>["onStateChange"];
755
+ onEvent: InstanceType<typeof App>["onEvent"];
685
756
  }
686
757
  export type FrameNameBounds = {
687
758
  x: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/math",
3
- "version": "0.18.0-7ea3229",
3
+ "version": "0.18.0-816c81c",
4
4
  "type": "module",
5
5
  "types": "./dist/types/math/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -61,6 +61,6 @@
61
61
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
62
62
  },
63
63
  "dependencies": {
64
- "@excalidraw/common": "0.18.0-7ea3229"
64
+ "@excalidraw/common": "0.18.0-816c81c"
65
65
  }
66
66
  }
@@ -1,27 +0,0 @@
1
- import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
- export type ChartElements = readonly NonDeletedExcalidrawElement[];
3
- export interface Spreadsheet {
4
- title: string | null;
5
- labels: string[] | null;
6
- values: number[];
7
- }
8
- export declare const NOT_SPREADSHEET = "NOT_SPREADSHEET";
9
- export declare const VALID_SPREADSHEET = "VALID_SPREADSHEET";
10
- type ParseSpreadsheetResult = {
11
- type: typeof NOT_SPREADSHEET;
12
- reason: string;
13
- } | {
14
- type: typeof VALID_SPREADSHEET;
15
- spreadsheet: Spreadsheet;
16
- };
17
- /**
18
- * @private exported for testing
19
- */
20
- export declare const tryParseNumber: (s: string) => number | null;
21
- /**
22
- * @private exported for testing
23
- */
24
- export declare const tryParseCells: (cells: string[][]) => ParseSpreadsheetResult;
25
- export declare const tryParseSpreadsheet: (text: string) => ParseSpreadsheetResult;
26
- export declare const renderSpreadsheet: (chartType: string, spreadsheet: Spreadsheet, x: number, y: number) => ChartElements;
27
- export {};
@@ -1,4 +0,0 @@
1
- import type { GenerateDiagramToCode } from "../../types";
2
- export declare const DiagramToCodePlugin: (props: {
3
- generate: GenerateDiagramToCode;
4
- }) => null;
@@ -1,15 +0,0 @@
1
- import "./ExcalidrawLogo.scss";
2
- type LogoSize = "xs" | "small" | "normal" | "large" | "custom" | "mobile";
3
- interface LogoProps {
4
- size?: LogoSize;
5
- withText?: boolean;
6
- style?: React.CSSProperties;
7
- /**
8
- * If true, the logo will not be wrapped in a Link component.
9
- * The link prop will be ignored as well.
10
- * It will merely be a plain div.
11
- */
12
- isNotLink?: boolean;
13
- }
14
- export declare const ExcalidrawLogo: ({ style, size, withText, }: LogoProps) => import("react/jsx-runtime").JSX.Element;
15
- export {};
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import type { Theme } from "@excalidraw/element/types";
3
- import type { Language } from "../i18n";
4
- interface Props {
5
- langCode: Language["code"];
6
- children: React.ReactElement;
7
- theme?: Theme;
8
- }
9
- export declare const InitializeApp: (props: Props) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,8 +0,0 @@
1
- import type { JSX, ReactNode } from "react";
2
- export declare const TTDDialogTrigger: {
3
- ({ children, icon, }: {
4
- children?: ReactNode;
5
- icon?: JSX.Element;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- displayName: string;
8
- };