@excalidraw/common 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 (91) hide show
  1. package/dist/dev/index.js +137 -19
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/appEventBus.d.ts +27 -0
  5. package/dist/types/common/src/colors.d.ts +13 -13
  6. package/dist/types/common/src/index.d.ts +2 -0
  7. package/dist/types/common/src/utils.d.ts +1 -3
  8. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  9. package/dist/types/element/src/Scene.d.ts +2 -0
  10. package/dist/types/element/src/arrowheads.d.ts +3 -0
  11. package/dist/types/element/src/binding.d.ts +3 -4
  12. package/dist/types/element/src/bounds.d.ts +1 -1
  13. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  14. package/dist/types/element/src/index.d.ts +1 -0
  15. package/dist/types/element/src/linearElementEditor.d.ts +3 -0
  16. package/dist/types/element/src/mutateElement.d.ts +2 -0
  17. package/dist/types/element/src/selection.d.ts +1 -1
  18. package/dist/types/element/src/types.d.ts +5 -2
  19. package/dist/types/element/src/utils.d.ts +1 -1
  20. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +23 -29
  21. package/dist/types/excalidraw/actions/actionBoundText.d.ts +16 -20
  22. package/dist/types/excalidraw/actions/actionCanvas.d.ts +161 -185
  23. package/dist/types/excalidraw/actions/actionClipboard.d.ts +16 -20
  24. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +8 -10
  25. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +25 -31
  26. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -10
  27. package/dist/types/excalidraw/actions/actionElementLock.d.ts +16 -20
  28. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +8 -10
  29. package/dist/types/excalidraw/actions/actionExport.d.ts +104 -388
  30. package/dist/types/excalidraw/actions/actionFrame.d.ts +32 -40
  31. package/dist/types/excalidraw/actions/actionGroup.d.ts +18 -22
  32. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -10
  33. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -10
  34. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -10
  35. package/dist/types/excalidraw/actions/actionProperties.d.ts +17 -21
  36. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +9 -11
  37. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -9
  38. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
  39. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -10
  40. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
  41. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -10
  42. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -10
  43. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +8 -10
  44. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -10
  45. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -10
  46. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  47. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  48. package/dist/types/excalidraw/appState.d.ts +29 -27
  49. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  50. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  51. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  52. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  53. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  54. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  55. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  56. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  57. package/dist/types/excalidraw/clipboard.d.ts +4 -7
  58. package/dist/types/excalidraw/components/App.d.ts +33 -11
  59. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  60. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  61. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  62. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  63. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  64. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  65. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  66. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  67. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  68. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  69. package/dist/types/excalidraw/components/icons.d.ts +17 -8
  70. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  71. package/dist/types/excalidraw/data/blob.d.ts +157 -162
  72. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  73. package/dist/types/excalidraw/data/index.d.ts +2 -3
  74. package/dist/types/excalidraw/data/json.d.ts +90 -84
  75. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  76. package/dist/types/excalidraw/types.d.ts +84 -13
  77. package/package.json +1 -1
  78. package/dist/types/excalidraw/charts.d.ts +0 -27
  79. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  80. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  81. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  82. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  83. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  84. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  85. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  86. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  87. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  88. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  89. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  90. package/dist/types/excalidraw/index.d.ts +0 -47
  91. package/dist/types/excalidraw/polyfill.d.ts +0 -2
@@ -1,87 +1,36 @@
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[];
12
20
  appState: {
13
- viewBackgroundColor: string;
21
+ viewModeEnabled: boolean;
22
+ zenModeEnabled: boolean;
23
+ gridModeEnabled: boolean;
24
+ objectsSnapModeEnabled: boolean;
14
25
  theme: import("@excalidraw/element/types").Theme;
15
- frameRendering: {
16
- enabled: boolean;
17
- name: boolean;
18
- outline: boolean;
19
- clip: boolean;
20
- };
21
26
  name: string | null;
22
- zoom: import("../types").Zoom;
23
- scrollX: number;
24
- scrollY: number;
25
- viewModeEnabled: boolean;
26
- openDialog: null | {
27
- name: "imageExport" | "help" | "jsonExport";
28
- } | {
29
- name: "ttd";
30
- tab: "text-to-diagram" | "mermaid";
31
- } | {
32
- name: "commandPalette";
33
- } | {
34
- name: "settings";
35
- } | {
36
- name: "elementLinkSelector";
37
- sourceElementId: ExcalidrawElement["id"];
38
- };
39
- editingGroupId: import("@excalidraw/element/types").GroupId | null;
40
- selectedElementIds: Readonly<{
41
- [id: string]: true;
42
- }>;
43
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
27
+ currentItemArrowType: "sharp" | "round" | "elbow";
28
+ gridSize: number;
44
29
  activeTool: {
45
30
  lastActiveTool: import("../types").ActiveTool | null;
46
31
  locked: boolean;
47
32
  fromSelection: boolean;
48
33
  } & import("../types").ActiveTool;
49
- activeEmbeddable: {
50
- element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
51
- state: "hover" | "active";
52
- } | null;
53
- selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
54
- selectedGroupIds: {
55
- [groupId: string]: boolean;
56
- };
57
- 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;
60
- isBindingEnabled: boolean;
61
- suggestedBinding: {
62
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
63
- midPoint?: import("@excalidraw/math").GlobalPoint;
64
- } | null;
65
- isRotating: boolean;
66
- elementsToHighlight: import("@excalidraw/element/types").NonDeleted<ExcalidrawElement>[] | null;
67
- collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
68
- snapLines: readonly import("../snapping").SnapLine[];
69
- zenModeEnabled: boolean;
70
- editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
71
- isCropping: boolean;
72
- croppingElementId: ExcalidrawElement["id"] | null;
73
- searchMatches: Readonly<{
74
- focusedId: ExcalidrawElement["id"] | null;
75
- matches: readonly import("../types").SearchMatch[];
76
- }> | null;
77
- activeLockedId: string | null;
78
- hoveredElementIds: Readonly<{
79
- [id: string]: true;
80
- }>;
81
- shouldCacheIgnoreZoom: boolean;
82
- exportScale: number;
83
- bindMode: import("@excalidraw/element/types").BindMode;
84
- gridSize: number;
85
34
  contextMenu: {
86
35
  items: import("../components/ContextMenu").ContextMenuItems;
87
36
  top: number;
@@ -90,9 +39,32 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
90
39
  showWelcomeScreen: boolean;
91
40
  isLoading: boolean;
92
41
  errorMessage: React.ReactNode;
42
+ activeEmbeddable: {
43
+ element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
44
+ state: "hover" | "active";
45
+ } | null;
46
+ newElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
93
47
  resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
94
- startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
48
+ multiElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
49
+ selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
50
+ isBindingEnabled: boolean;
51
+ bindingPreference: "enabled" | "disabled";
52
+ isMidpointSnappingEnabled: boolean;
53
+ startBoundElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
54
+ suggestedBinding: {
55
+ element: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
56
+ midPoint?: import("@excalidraw/math").GlobalPoint;
57
+ } | null;
58
+ frameToHighlight: NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
59
+ frameRendering: {
60
+ enabled: boolean;
61
+ name: boolean;
62
+ outline: boolean;
63
+ clip: boolean;
64
+ };
95
65
  editingFrame: string | null;
66
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
67
+ editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
96
68
  preferredSelectionTool: {
97
69
  type: "selection" | "lasso";
98
70
  initialized: boolean;
@@ -102,6 +74,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
102
74
  exportBackground: boolean;
103
75
  exportEmbedScene: boolean;
104
76
  exportWithDarkMode: boolean;
77
+ exportScale: number;
105
78
  currentItemStrokeColor: string;
106
79
  currentItemBackgroundColor: string;
107
80
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
@@ -116,53 +89,86 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
116
89
  currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
117
90
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
118
91
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
119
- currentItemArrowType: "sharp" | "round" | "elbow";
92
+ viewBackgroundColor: string;
93
+ scrollX: number;
94
+ scrollY: number;
120
95
  cursorButton: "up" | "down";
121
96
  scrolledOutside: boolean;
122
97
  isResizing: boolean;
98
+ isRotating: boolean;
99
+ zoom: import("../types").Zoom;
123
100
  openMenu: "canvas" | null;
124
101
  openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
125
102
  openSidebar: {
126
103
  name: import("../types").SidebarName;
127
104
  tab?: import("../types").SidebarTabName;
128
105
  } | null;
106
+ openDialog: null | {
107
+ name: "imageExport" | "help" | "jsonExport";
108
+ } | {
109
+ name: "ttd";
110
+ tab: "text-to-diagram" | "mermaid";
111
+ } | {
112
+ name: "commandPalette";
113
+ } | {
114
+ name: "settings";
115
+ } | {
116
+ name: "elementLinkSelector";
117
+ sourceElementId: ExcalidrawElement["id"];
118
+ } | {
119
+ name: "charts";
120
+ data: import("../charts").Spreadsheet;
121
+ rawText: string;
122
+ };
129
123
  defaultSidebarDockedPreference: boolean;
130
124
  lastPointerDownWith: import("@excalidraw/element/types").PointerType;
125
+ selectedElementIds: Readonly<{
126
+ [id: string]: true;
127
+ }>;
128
+ hoveredElementIds: Readonly<{
129
+ [id: string]: true;
130
+ }>;
131
131
  previousSelectedElementIds: {
132
132
  [id: string]: true;
133
133
  };
134
134
  selectedElementsAreBeingDragged: boolean;
135
+ shouldCacheIgnoreZoom: boolean;
135
136
  toast: {
136
- message: string;
137
+ message: React.ReactNode;
137
138
  closable?: boolean;
138
139
  duration?: number;
139
140
  } | null;
140
141
  gridStep: number;
141
- gridModeEnabled: boolean;
142
- fileHandle: import("browser-fs-access").FileSystemHandle | null;
142
+ selectedGroupIds: {
143
+ [groupId: string]: boolean;
144
+ };
145
+ editingGroupId: import("@excalidraw/element/types").GroupId | null;
146
+ fileHandle: FileSystemFileHandle | null;
147
+ collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
143
148
  stats: {
144
149
  open: boolean;
145
150
  panels: number;
146
151
  };
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
152
  showHyperlinkPopup: false | "info" | "editor";
153
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
154
+ snapLines: readonly import("../snapping").SnapLine[];
156
155
  originSnapOffset: {
157
156
  x: number;
158
157
  y: number;
159
158
  } | null;
160
- objectsSnapModeEnabled: boolean;
161
159
  userToFollow: import("../types").UserToFollow | null;
162
160
  followedBy: Set<import("../types").SocketId>;
161
+ isCropping: boolean;
162
+ croppingElementId: ExcalidrawElement["id"] | null;
163
+ searchMatches: Readonly<{
164
+ focusedId: ExcalidrawElement["id"] | null;
165
+ matches: readonly import("../types").SearchMatch[];
166
+ }> | null;
167
+ activeLockedId: string | null;
163
168
  lockedMultiSelections: {
164
169
  [groupId: string]: true;
165
170
  };
171
+ bindMode: import("@excalidraw/element/types").BindMode;
166
172
  };
167
173
  files: BinaryFiles;
168
174
  }>;
@@ -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/common",
3
- "version": "0.18.0-7ea3229",
3
+ "version": "0.18.0-816c81c",
4
4
  "type": "module",
5
5
  "types": "./dist/types/common/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -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
- };
@@ -1,24 +0,0 @@
1
- import type { LLMMessage, TTTDDialog } from "@excalidraw/excalidraw/components/TTDDialog/types";
2
- interface StreamingOptions {
3
- url: string;
4
- messages: readonly LLMMessage[];
5
- onChunk?: (chunk: string) => void;
6
- extractRateLimits?: boolean;
7
- signal?: AbortSignal;
8
- onStreamCreated?: () => void;
9
- }
10
- export type StreamChunk = {
11
- type: "content";
12
- delta: string;
13
- } | {
14
- type: "done";
15
- finishReason: "stop" | "length" | "content_filter" | "tool_calls" | null;
16
- } | {
17
- type: "error";
18
- error: {
19
- message: string;
20
- status?: number;
21
- };
22
- };
23
- export declare function TTDStreamFetch(options: StreamingOptions): Promise<TTTDDialog.OnTextSubmitRetValue>;
24
- export {};
@@ -1,8 +0,0 @@
1
- import "./FooterCenter.scss";
2
- declare const FooterCenter: {
3
- ({ children }: {
4
- children?: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- displayName: string;
7
- };
8
- export default FooterCenter;
@@ -1,11 +0,0 @@
1
- import { type EditorInterface } from "@excalidraw/common";
2
- import "./LiveCollaborationTrigger.scss";
3
- declare const LiveCollaborationTrigger: {
4
- ({ isCollaborating, onSelect, editorInterface, ...rest }: {
5
- isCollaborating: boolean;
6
- onSelect: () => void;
7
- editorInterface?: EditorInterface;
8
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
9
- displayName: string;
10
- };
11
- export default LiveCollaborationTrigger;
@@ -1,58 +0,0 @@
1
- import type { JSX } from "react";
2
- declare const Center: {
3
- ({ children }: {
4
- children?: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- displayName: string;
7
- Logo: {
8
- ({ children }: {
9
- children?: React.ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- displayName: string;
12
- };
13
- Heading: {
14
- ({ children }: {
15
- children: React.ReactNode;
16
- }): import("react/jsx-runtime").JSX.Element;
17
- displayName: string;
18
- };
19
- Menu: {
20
- ({ children }: {
21
- children?: React.ReactNode;
22
- }): import("react/jsx-runtime").JSX.Element;
23
- displayName: string;
24
- };
25
- MenuItem: {
26
- ({ onSelect, children, icon, shortcut, className, ...props }: {
27
- onSelect: () => void;
28
- children: React.ReactNode;
29
- icon?: JSX.Element;
30
- shortcut?: string | null;
31
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
32
- displayName: string;
33
- };
34
- MenuItemLink: {
35
- ({ children, href, icon, shortcut, className, ...props }: {
36
- children: React.ReactNode;
37
- href: string;
38
- icon?: JSX.Element;
39
- shortcut?: string | null;
40
- } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
41
- displayName: string;
42
- };
43
- MenuItemHelp: {
44
- (): import("react/jsx-runtime").JSX.Element;
45
- displayName: string;
46
- };
47
- MenuItemLoadScene: {
48
- (): import("react/jsx-runtime").JSX.Element | null;
49
- displayName: string;
50
- };
51
- MenuItemLiveCollaborationTrigger: {
52
- ({ onSelect, }: {
53
- onSelect: () => any;
54
- }): import("react/jsx-runtime").JSX.Element;
55
- displayName: string;
56
- };
57
- };
58
- export { Center };