@zsviczian/excalidraw 0.15.2-obsidian-9 → 0.15.2-obsidian-10

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 (281) hide show
  1. package/dist/excalidraw.development.js +1147 -1007
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +9 -0
  4. package/package.json +6 -2
  5. package/types/.DS_Store +0 -0
  6. package/types/actions/actionAddToLibrary.d.ts +441 -441
  7. package/types/actions/actionAlign.d.ts +97 -97
  8. package/types/actions/actionBoundText.d.ts +331 -331
  9. package/types/actions/actionCanvas.d.ts +1845 -1845
  10. package/types/actions/actionClipboard.d.ts +829 -829
  11. package/types/actions/actionDeleteSelected.d.ts +475 -475
  12. package/types/actions/actionDistribute.d.ts +33 -33
  13. package/types/actions/actionDuplicateSelection.d.ts +22 -22
  14. package/types/actions/actionElementLock.d.ts +316 -316
  15. package/types/actions/actionExport.d.ts +1389 -1389
  16. package/types/actions/actionFinalize.d.ts +299 -299
  17. package/types/actions/actionFlip.d.ts +33 -33
  18. package/types/actions/actionFrame.d.ts +490 -490
  19. package/types/actions/actionGroup.d.ts +45 -45
  20. package/types/actions/actionHistory.d.ts +6 -6
  21. package/types/actions/actionLinearEditor.d.ts +158 -158
  22. package/types/actions/actionMenu.d.ts +479 -479
  23. package/types/actions/actionNavigate.d.ts +14 -14
  24. package/types/actions/actionProperties.d.ts +2013 -2013
  25. package/types/actions/actionSelectAll.d.ts +16 -16
  26. package/types/actions/actionStyles.d.ts +172 -172
  27. package/types/actions/actionToggleGridMode.d.ts +161 -161
  28. package/types/actions/actionToggleLock.d.ts +135 -139
  29. package/types/actions/actionToggleStats.d.ts +158 -158
  30. package/types/actions/actionToggleViewMode.d.ts +160 -160
  31. package/types/actions/actionToggleZenMode.d.ts +160 -160
  32. package/types/actions/actionZindex.d.ts +67 -67
  33. package/types/actions/index.d.ts +24 -24
  34. package/types/actions/manager.d.ts +21 -21
  35. package/types/actions/register.d.ts +5 -5
  36. package/types/actions/shortcuts.d.ts +4 -4
  37. package/types/actions/types.d.ts +45 -45
  38. package/types/align.d.ts +6 -6
  39. package/types/analytics.d.ts +1 -1
  40. package/types/appState.d.ts +81 -81
  41. package/types/charts.d.ts +27 -27
  42. package/types/clients.d.ts +5 -5
  43. package/types/clipboard.d.ts +25 -25
  44. package/types/colors.d.ts +61 -61
  45. package/types/components/Actions.d.ts +36 -36
  46. package/types/components/ActiveConfirmDialog.d.ts +4 -4
  47. package/types/components/App.d.ts +288 -291
  48. package/types/components/Avatar.d.ts +10 -10
  49. package/types/components/BraveMeasureTextError.d.ts +2 -2
  50. package/types/components/Button.d.ts +17 -17
  51. package/types/components/ButtonIconSelect.d.ts +19 -19
  52. package/types/components/Card.d.ts +7 -7
  53. package/types/components/CheckboxItem.d.ts +8 -8
  54. package/types/components/ColorPicker/ColorInput.d.ts +7 -7
  55. package/types/components/ColorPicker/ColorPicker.d.ts +19 -19
  56. package/types/components/ColorPicker/CustomColorList.d.ts +8 -8
  57. package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -8
  58. package/types/components/ColorPicker/Picker.d.ts +18 -18
  59. package/types/components/ColorPicker/PickerColorList.d.ts +10 -10
  60. package/types/components/ColorPicker/PickerHeading.d.ts +5 -5
  61. package/types/components/ColorPicker/ShadeList.d.ts +8 -8
  62. package/types/components/ColorPicker/TopPicks.d.ts +9 -9
  63. package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -21
  64. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +21 -21
  65. package/types/components/ColorPicker.d.ts +19 -19
  66. package/types/components/ConfirmDialog.d.ts +10 -10
  67. package/types/components/ContextMenu.d.ts +15 -15
  68. package/types/components/DarkModeToggle.d.ts +7 -7
  69. package/types/components/DefaultSidebar.d.ts +30 -30
  70. package/types/components/Dialog.d.ts +13 -13
  71. package/types/components/DialogActionButton.d.ts +10 -10
  72. package/types/components/ErrorDialog.d.ts +5 -5
  73. package/types/components/EyeDropper.d.ts +18 -18
  74. package/types/components/FilledButton.d.ts +17 -17
  75. package/types/components/FixedSideContainer.d.ts +9 -9
  76. package/types/components/HandButton.d.ts +10 -10
  77. package/types/components/HelpButton.d.ts +7 -7
  78. package/types/components/HelpDialog.d.ts +4 -4
  79. package/types/components/HintViewer.d.ts +10 -10
  80. package/types/components/IconPicker.d.ts +13 -13
  81. package/types/components/ImageExportDialog.d.ts +13 -13
  82. package/types/components/InitializeApp.d.ts +10 -10
  83. package/types/components/Island.d.ts +10 -10
  84. package/types/components/JSONExportDialog.d.ts +15 -15
  85. package/types/components/LayerUI.d.ts +32 -32
  86. package/types/components/LibraryButton.d.ts +8 -8
  87. package/types/components/LibraryMenu.d.ts +24 -24
  88. package/types/components/LibraryMenuBrowseButton.d.ts +7 -7
  89. package/types/components/LibraryMenuControlButtons.d.ts +9 -9
  90. package/types/components/LibraryMenuHeaderContent.d.ts +18 -18
  91. package/types/components/LibraryMenuItems.d.ts +14 -14
  92. package/types/components/LibraryMenuSection.d.ts +22 -22
  93. package/types/components/LibraryUnit.d.ts +15 -15
  94. package/types/components/LoadingMessage.d.ts +6 -6
  95. package/types/components/LockButton.d.ts +10 -10
  96. package/types/components/MobileMenu.d.ts +27 -27
  97. package/types/components/Modal.d.ts +13 -13
  98. package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -17
  99. package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -17
  100. package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -22
  101. package/types/components/PasteChartDialog.d.ts +8 -8
  102. package/types/components/PenModeButton.d.ts +12 -12
  103. package/types/components/Popover.d.ts +15 -15
  104. package/types/components/ProjectName.d.ts +11 -11
  105. package/types/components/PublishLibrary.d.ts +16 -16
  106. package/types/components/RadioGroup.d.ts +12 -12
  107. package/types/components/Section.d.ts +6 -6
  108. package/types/components/Sidebar/Sidebar.d.ts +76 -76
  109. package/types/components/Sidebar/SidebarHeader.d.ts +7 -7
  110. package/types/components/Sidebar/SidebarTab.d.ts +9 -9
  111. package/types/components/Sidebar/SidebarTabTrigger.d.ts +10 -10
  112. package/types/components/Sidebar/SidebarTabTriggers.d.ts +7 -7
  113. package/types/components/Sidebar/SidebarTabs.d.ts +7 -7
  114. package/types/components/Sidebar/SidebarTrigger.d.ts +6 -6
  115. package/types/components/Sidebar/common.d.ts +33 -33
  116. package/types/components/SingleLibraryItem.d.ts +10 -10
  117. package/types/components/Spinner.d.ts +7 -7
  118. package/types/components/Stack.d.ts +16 -16
  119. package/types/components/Stats.d.ts +11 -11
  120. package/types/components/Switch.d.ts +9 -9
  121. package/types/components/Toast.d.ts +7 -7
  122. package/types/components/ToolButton.d.ts +47 -47
  123. package/types/components/Tooltip.d.ts +17 -17
  124. package/types/components/Trans.d.ts +9 -8
  125. package/types/components/UserList.d.ts +8 -8
  126. package/types/components/context/tunnels.d.ts +16 -16
  127. package/types/components/dropdownMenu/DropdownMenu.d.ts +67 -67
  128. package/types/components/dropdownMenu/DropdownMenuContent.d.ts +15 -15
  129. package/types/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -11
  130. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -12
  131. package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -6
  132. package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +6 -6
  133. package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +13 -13
  134. package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -5
  135. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +11 -11
  136. package/types/components/dropdownMenu/common.d.ts +6 -6
  137. package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -3
  138. package/types/components/footer/Footer.d.ts +12 -12
  139. package/types/components/footer/FooterCenter.d.ts +8 -8
  140. package/types/components/hoc/withInternalFallback.d.ts +4 -4
  141. package/types/components/hoc/withUpstreamOverride.d.ts +10 -10
  142. package/types/components/icons.d.ts +154 -154
  143. package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +10 -10
  144. package/types/components/main-menu/DefaultItems.d.ts +44 -44
  145. package/types/components/main-menu/MainMenu.d.ts +61 -61
  146. package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -58
  147. package/types/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -19
  148. package/types/components/welcome-screen/WelcomeScreen.d.ts +85 -85
  149. package/types/constants.d.ts +226 -225
  150. package/types/context/tunnels.d.ts +19 -19
  151. package/types/context/ui-appState.d.ts +4 -4
  152. package/types/data/blob.d.ts +48 -48
  153. package/types/data/encode.d.ts +53 -53
  154. package/types/data/encryption.d.ts +9 -9
  155. package/types/data/filesystem.d.ts +19 -19
  156. package/types/data/image.d.ts +15 -15
  157. package/types/data/index.d.ts +13 -13
  158. package/types/data/json.d.ts +16 -16
  159. package/types/data/library.d.ts +54 -54
  160. package/types/data/resave.d.ts +5 -5
  161. package/types/data/restore.d.ts +21 -21
  162. package/types/data/types.d.ts +45 -45
  163. package/types/data/url.d.ts +7 -7
  164. package/types/distribute.d.ts +6 -6
  165. package/types/element/Hyperlink.d.ts +182 -182
  166. package/types/element/binding.d.ts +33 -33
  167. package/types/element/bounds.d.ts +53 -53
  168. package/types/element/collision.d.ts +21 -21
  169. package/types/element/dragElements.d.ts +6 -6
  170. package/types/element/embeddable.d.ts +176 -176
  171. package/types/element/image.d.ts +32 -32
  172. package/types/element/index.d.ts +21 -21
  173. package/types/element/linearElementEditor.d.ts +293 -293
  174. package/types/element/mutateElement.d.ts +12 -12
  175. package/types/element/newElement.d.ts +95 -95
  176. package/types/element/resizeElements.d.ts +9 -9
  177. package/types/element/resizeTest.d.ts +13 -13
  178. package/types/element/showSelectedShapeActions.d.ts +3 -3
  179. package/types/element/sizeHelpers.d.ts +21 -21
  180. package/types/element/sortElements.d.ts +2 -2
  181. package/types/element/textElement.d.ts +80 -80
  182. package/types/element/textWysiwyg.d.ts +21 -21
  183. package/types/element/transformHandles.d.ts +35 -35
  184. package/types/element/typeChecks.d.ts +29 -29
  185. package/types/element/types.d.ts +166 -166
  186. package/types/errors.d.ts +8 -8
  187. package/types/frame.d.ts +40 -40
  188. package/types/ga.d.ts +63 -63
  189. package/types/gadirections.d.ts +8 -8
  190. package/types/galines.d.ts +22 -22
  191. package/types/gapoints.d.ts +7 -7
  192. package/types/gatransforms.d.ts +10 -10
  193. package/types/gesture.d.ts +6 -6
  194. package/types/groups.d.ts +31 -31
  195. package/types/history.d.ts +52 -52
  196. package/types/hooks/useCallbackRefState.d.ts +1 -1
  197. package/types/hooks/useCreatePortalContainer.d.ts +5 -5
  198. package/types/hooks/useLibraryItemSvg.d.ts +11 -11
  199. package/types/hooks/useOutsideClick.d.ts +20 -20
  200. package/types/hooks/useScrollPosition.d.ts +2 -2
  201. package/types/hooks/useTransition.d.ts +2 -2
  202. package/types/i18n.d.ts +24 -21
  203. package/types/jotai.d.ts +34 -34
  204. package/types/keys.d.ts +80 -80
  205. package/types/math.d.ts +30 -30
  206. package/types/packages/common.webpack.dev.config.d.ts +72 -72
  207. package/types/packages/common.webpack.prod.config.d.ts +84 -84
  208. package/types/packages/excalidraw/dist/excalidraw.development.d.ts +4 -4
  209. package/types/packages/excalidraw/dist/excalidraw.production.min.d.ts +1 -1
  210. package/types/packages/excalidraw/entry.d.ts +1 -1
  211. package/types/packages/excalidraw/env.d.ts +1 -1
  212. package/types/packages/excalidraw/example/App.d.ts +14 -14
  213. package/types/packages/excalidraw/example/CustomFooter.d.ts +5 -5
  214. package/types/packages/excalidraw/example/MobileFooter.d.ts +5 -5
  215. package/types/packages/excalidraw/example/index.d.ts +1 -1
  216. package/types/packages/excalidraw/example/initialData.d.ts +178 -178
  217. package/types/packages/excalidraw/example/sidebar/ExampleSidebar.d.ts +5 -5
  218. package/types/packages/excalidraw/index.d.ts +37 -37
  219. package/types/packages/excalidraw/main.d.ts +2 -2
  220. package/types/packages/excalidraw/publicPath.d.ts +1 -1
  221. package/types/packages/excalidraw/webpack.dev-server.config.d.ts +19 -19
  222. package/types/packages/excalidraw/webpack.dev.config.d.ts +69 -69
  223. package/types/packages/excalidraw/webpack.prod.config.d.ts +78 -78
  224. package/types/packages/utils.d.ts +43 -42
  225. package/types/points.d.ts +7 -7
  226. package/types/polyfill.d.ts +2 -2
  227. package/types/random.d.ts +4 -4
  228. package/types/renderer/easingFunctions.d.ts +6 -6
  229. package/types/renderer/renderElement.d.ts +37 -37
  230. package/types/renderer/renderScene.d.ts +51 -50
  231. package/types/renderer/roundRect.d.ts +11 -11
  232. package/types/scene/Fonts.d.ts +21 -21
  233. package/types/scene/Scene.d.ts +60 -60
  234. package/types/scene/comparisons.d.ts +10 -10
  235. package/types/scene/export.d.ts +25 -24
  236. package/types/scene/index.d.ts +5 -5
  237. package/types/scene/scroll.d.ts +17 -17
  238. package/types/scene/scrollbars.d.ts +16 -16
  239. package/types/scene/selection.d.ts +31 -31
  240. package/types/scene/types.d.ts +59 -59
  241. package/types/scene/zoom.d.ts +13 -13
  242. package/types/shapes.d.ts +62 -62
  243. package/types/types.d.ts +501 -503
  244. package/types/utility-types.d.ts +25 -24
  245. package/types/utils.d.ts +192 -192
  246. package/types/zindex.d.ts +6 -6
  247. package/types/bug-issue-template.d.ts +0 -2
  248. package/types/components/ActiveFile.d.ts +0 -7
  249. package/types/components/BackgroundPickerAndDarkModeToggle.d.ts +0 -4
  250. package/types/components/ClearCanvas.d.ts +0 -4
  251. package/types/components/CollabButton.d.ts +0 -7
  252. package/types/components/EncryptedIcon.d.ts +0 -2
  253. package/types/components/Footer.d.ts +0 -10
  254. package/types/components/HelpIcon.d.ts +0 -8
  255. package/types/components/MenuItem.d.ts +0 -11
  256. package/types/components/MenuUtils.d.ts +0 -2
  257. package/types/components/SidebarLockButton.d.ts +0 -8
  258. package/types/components/TopErrorBoundary.d.ts +0 -15
  259. package/types/components/WelcomeScreen.d.ts +0 -8
  260. package/types/components/WelcomeScreenDecor.d.ts +0 -6
  261. package/types/components/mainMenu/DefaultItems.d.ts +0 -44
  262. package/types/components/mainMenu/MainMenu.d.ts +0 -63
  263. package/types/element/iframe.d.ts +0 -167
  264. package/types/excalidraw-app/CustomStats.d.ts +0 -9
  265. package/types/excalidraw-app/app_constants.d.ts +0 -32
  266. package/types/excalidraw-app/collab/Collab.d.ts +0 -163
  267. package/types/excalidraw-app/collab/Portal.d.ts +0 -28
  268. package/types/excalidraw-app/collab/RoomDialog.d.ts +0 -13
  269. package/types/excalidraw-app/collab/reconciliation.d.ts +0 -10
  270. package/types/excalidraw-app/components/ExportToExcalidrawPlus.d.ts +0 -9
  271. package/types/excalidraw-app/components/LanguageList.d.ts +0 -4
  272. package/types/excalidraw-app/components/icons.d.ts +0 -1
  273. package/types/excalidraw-app/data/FileManager.d.ts +0 -66
  274. package/types/excalidraw-app/data/LocalData.d.ts +0 -32
  275. package/types/excalidraw-app/data/Locker.d.ts +0 -8
  276. package/types/excalidraw-app/data/firebase.d.ts +0 -25
  277. package/types/excalidraw-app/data/index.d.ts +0 -190
  278. package/types/excalidraw-app/data/localStorage.d.ts +0 -116
  279. package/types/excalidraw-app/data/tabSync.d.ts +0 -9
  280. package/types/excalidraw-app/index.d.ts +0 -26
  281. package/types/packages/excalidraw/example/sidebar/Sidebar.d.ts +0 -5
package/types/types.d.ts CHANGED
@@ -1,503 +1,501 @@
1
- import React from "react";
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
3
- import { SHAPES } from "./shapes";
4
- import { Point as RoughPoint } from "roughjs/bin/geometry";
5
- import { LinearElementEditor } from "./element/linearElementEditor";
6
- import { SuggestedBinding } from "./element/binding";
7
- import { ImportedDataState } from "./data/types";
8
- import type App from "./components/App";
9
- import type { ResolvablePromise, throttleRAF } from "./utils";
10
- import { Spreadsheet } from "./charts";
11
- import { Language } from "./i18n";
12
- import { ClipboardData } from "./clipboard";
13
- import { isOverScrollBars } from "./scene";
14
- import { MaybeTransformHandleType } from "./element/transformHandles";
15
- import Library from "./data/library";
16
- import type { FileSystemHandle } from "./data/filesystem";
17
- import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
18
- import { ContextMenuItems } from "./components/ContextMenu";
19
- import { Merge, ForwardRef, ValueOf } from "./utility-types";
20
- import { ColorPaletteCustom } from "./colors";
21
- export type Point = Readonly<RoughPoint>;
22
- export type Collaborator = {
23
- pointer?: {
24
- x: number;
25
- y: number;
26
- };
27
- button?: "up" | "down";
28
- selectedElementIds?: AppState["selectedElementIds"];
29
- username?: string | null;
30
- userState?: UserIdleState;
31
- color?: {
32
- background: string;
33
- stroke: string;
34
- };
35
- avatarUrl?: string;
36
- id?: string;
37
- };
38
- export type DataURL = string & {
39
- _brand: "DataURL";
40
- };
41
- export type BinaryFileData = {
42
- mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
43
- id: FileId;
44
- dataURL: DataURL;
45
- /**
46
- * Epoch timestamp in milliseconds
47
- */
48
- created: number;
49
- /**
50
- * Indicates when the file was last retrieved from storage to be loaded
51
- * onto the scene. We use this flag to determine whether to delete unused
52
- * files from storage.
53
- *
54
- * Epoch timestamp in milliseconds.
55
- */
56
- lastRetrieved?: number;
57
- };
58
- export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
59
- export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
60
- export type LastActiveTool = {
61
- type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
62
- customType: null;
63
- } | {
64
- type: "custom";
65
- customType: string;
66
- } | null;
67
- export type SidebarName = string;
68
- export type SidebarTabName = string;
69
- export type AppState = {
70
- contextMenu: {
71
- items: ContextMenuItems;
72
- top: number;
73
- left: number;
74
- } | null;
75
- showWelcomeScreen: boolean;
76
- isLoading: boolean;
77
- errorMessage: React.ReactNode;
78
- activeEmbeddable: {
79
- element: NonDeletedExcalidrawElement;
80
- state: "hover" | "active";
81
- } | null;
82
- draggingElement: NonDeletedExcalidrawElement | null;
83
- resizingElement: NonDeletedExcalidrawElement | null;
84
- multiElement: NonDeleted<ExcalidrawLinearElement> | null;
85
- selectionElement: NonDeletedExcalidrawElement | null;
86
- isBindingEnabled: boolean;
87
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
88
- suggestedBindings: SuggestedBinding[];
89
- frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
90
- frameRendering: {
91
- enabled: boolean;
92
- name: boolean;
93
- outline: boolean;
94
- clip: boolean;
95
- };
96
- editingFrame: string | null;
97
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
98
- editingElement: NonDeletedExcalidrawElement | null;
99
- editingLinearElement: LinearElementEditor | null;
100
- activeTool: {
101
- /**
102
- * indicates a previous tool we should revert back to if we deselect the
103
- * currently active tool. At the moment applies to `eraser` and `hand` tool.
104
- */
105
- lastActiveTool: LastActiveTool;
106
- locked: boolean;
107
- } & ({
108
- type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
109
- customType: null;
110
- } | {
111
- type: "custom";
112
- customType: string;
113
- });
114
- penMode: boolean;
115
- penDetected: boolean;
116
- exportBackground: boolean;
117
- exportEmbedScene: boolean;
118
- exportWithDarkMode: boolean;
119
- exportScale: number;
120
- currentItemStrokeColor: string;
121
- currentItemBackgroundColor: string;
122
- currentItemFillStyle: ExcalidrawElement["fillStyle"];
123
- currentItemStrokeWidth: number;
124
- currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
125
- currentItemRoughness: number;
126
- currentItemOpacity: number;
127
- currentItemFontFamily: FontFamilyValues;
128
- currentItemFontSize: number;
129
- currentItemTextAlign: TextAlign;
130
- currentItemStartArrowhead: Arrowhead | null;
131
- currentItemEndArrowhead: Arrowhead | null;
132
- currentItemRoundness: StrokeRoundness;
133
- viewBackgroundColor: string;
134
- scrollX: number;
135
- scrollY: number;
136
- cursorButton: "up" | "down";
137
- scrolledOutside: boolean;
138
- name: string;
139
- isResizing: boolean;
140
- isRotating: boolean;
141
- zoom: Zoom;
142
- openMenu: "canvas" | "shape" | null;
143
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
144
- openSidebar: {
145
- name: SidebarName;
146
- tab?: SidebarTabName;
147
- } | null;
148
- openDialog: "imageExport" | "help" | "jsonExport" | null;
149
- /**
150
- * Reflects user preference for whether the default sidebar should be docked.
151
- *
152
- * NOTE this is only a user preference and does not reflect the actual docked
153
- * state of the sidebar, because the host apps can override this through
154
- * a DefaultSidebar prop, which is not reflected back to the appState.
155
- */
156
- defaultSidebarDockedPreference: boolean;
157
- lastPointerDownWith: PointerType;
158
- selectedElementIds: Readonly<{
159
- [id: string]: true;
160
- }>;
161
- previousSelectedElementIds: {
162
- [id: string]: true;
163
- };
164
- selectedElementsAreBeingDragged: boolean;
165
- shouldCacheIgnoreZoom: boolean;
166
- toast: {
167
- message: string;
168
- closable?: boolean;
169
- duration?: number;
170
- } | null;
171
- zenModeEnabled: boolean;
172
- theme: Theme;
173
- gridSize: number | null;
174
- previousGridSize: number | null;
175
- viewModeEnabled: boolean;
176
- /** top-most selected groups (i.e. does not include nested groups) */
177
- selectedGroupIds: {
178
- [groupId: string]: boolean;
179
- };
180
- /** group being edited when you drill down to its constituent element
181
- (e.g. when you double-click on a group's element) */
182
- editingGroupId: GroupId | null;
183
- width: number;
184
- height: number;
185
- offsetTop: number;
186
- offsetLeft: number;
187
- fileHandle: FileSystemHandle | null;
188
- collaborators: Map<string, Collaborator>;
189
- showStats: boolean;
190
- currentChartType: ChartType;
191
- pasteDialog: {
192
- shown: false;
193
- data: null;
194
- } | {
195
- shown: true;
196
- data: Spreadsheet;
197
- };
198
- /** imageElement waiting to be placed on canvas */
199
- pendingImageElementId: ExcalidrawImageElement["id"] | null;
200
- showHyperlinkPopup: false | "info" | "editor";
201
- linkOpacity: number;
202
- trayModeEnabled: boolean;
203
- colorPalette?: {
204
- canvasBackground: ColorPaletteCustom;
205
- elementBackground: ColorPaletteCustom;
206
- elementStroke: ColorPaletteCustom;
207
- topPicks: {
208
- canvasBackground: [string, string, string, string, string];
209
- elementStroke: [string, string, string, string, string];
210
- elementBackground: [string, string, string, string, string];
211
- };
212
- };
213
- allowWheelZoom?: boolean;
214
- allowPinchZoom?: boolean;
215
- pinnedScripts?: string[];
216
- customPens?: any[];
217
- currentStrokeOptions?: any;
218
- resetCustomPen?: any;
219
- gridColor: string;
220
- dynamicStyle: string;
221
- invertBindingBehaviour: boolean;
222
- selectedLinearElement: LinearElementEditor | null;
223
- };
224
- export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
225
- export type NormalizedZoomValue = number & {
226
- _brand: "normalizedZoom";
227
- };
228
- export type Zoom = Readonly<{
229
- value: NormalizedZoomValue;
230
- }>;
231
- export type PointerCoords = Readonly<{
232
- x: number;
233
- y: number;
234
- }>;
235
- export type Gesture = {
236
- pointers: Map<number, PointerCoords>;
237
- lastCenter: {
238
- x: number;
239
- y: number;
240
- } | null;
241
- initialDistance: number | null;
242
- initialScale: number | null;
243
- };
244
- export declare class GestureEvent extends UIEvent {
245
- readonly rotation: number;
246
- readonly scale: number;
247
- }
248
- /** @deprecated legacy: do not use outside of migration paths */
249
- export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
250
- /** @deprecated legacy: do not use outside of migration paths */
251
- type LibraryItems_v1 = readonly LibraryItem_v1[];
252
- /** v2 library item */
253
- export type LibraryItem = {
254
- id: string;
255
- status: "published" | "unpublished";
256
- elements: readonly NonDeleted<ExcalidrawElement>[];
257
- /** timestamp in epoch (ms) */
258
- created: number;
259
- name?: string;
260
- error?: string;
261
- };
262
- export type LibraryItems = readonly LibraryItem[];
263
- export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
264
- export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
265
- export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
266
- readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
267
- ready?: false;
268
- };
269
- export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
270
- libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
271
- }>;
272
- export interface ExcalidrawProps {
273
- onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
274
- initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
275
- excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
276
- isCollaborating?: boolean;
277
- onPointerUpdate?: (payload: {
278
- pointer: {
279
- x: number;
280
- y: number;
281
- };
282
- button: "down" | "up";
283
- pointersMap: Gesture["pointers"];
284
- }) => void;
285
- onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
286
- onDrop?: (event: React.DragEvent<HTMLDivElement>) => Promise<boolean> | boolean;
287
- renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
288
- langCode?: Language["code"];
289
- viewModeEnabled?: boolean;
290
- zenModeEnabled?: boolean;
291
- gridModeEnabled?: boolean;
292
- libraryReturnUrl?: string;
293
- initState?: AppState;
294
- theme?: Theme;
295
- name?: string;
296
- renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
297
- UIOptions?: Partial<UIOptions>;
298
- detectScroll?: boolean;
299
- handleKeyboardGlobally?: boolean;
300
- onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
301
- autoFocus?: boolean;
302
- onBeforeTextEdit?: (textElement: ExcalidrawTextElement) => string;
303
- onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, textToSubmit: string, originalText: string, isDeleted: boolean) => [string, string, string];
304
- generateIdForFile?: (file: File) => string | Promise<string>;
305
- onThemeChange?: (newTheme: string) => void;
306
- onViewModeChange?: (isViewModeEnabled: boolean) => void;
307
- onLinkOpen?: (element: NonDeletedExcalidrawElement, event: CustomEvent<{
308
- nativeEvent: MouseEvent | React.PointerEvent<HTMLCanvasElement>;
309
- }>) => void;
310
- onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
311
- onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
312
- onScrollChange?: (scrollX: number, scrollY: number) => void;
313
- children?: React.ReactNode;
314
- validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
315
- renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
316
- renderWebview?: boolean;
317
- renderEmbeddableMenu?: (//zsivzian
318
- appState: AppState) => JSX.Element | null;
319
- }
320
- export type SceneData = {
321
- elements?: ImportedDataState["elements"];
322
- appState?: ImportedDataState["appState"];
323
- collaborators?: Map<string, Collaborator>;
324
- commitToHistory?: boolean;
325
- };
326
- export declare enum UserIdleState {
327
- ACTIVE = "active",
328
- AWAY = "away",
329
- IDLE = "idle"
330
- }
331
- export type ExportOpts = {
332
- saveFileToDisk?: boolean;
333
- onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
334
- renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
335
- };
336
- type CanvasActions = Partial<{
337
- changeViewBackgroundColor: boolean;
338
- clearCanvas: boolean;
339
- export: false | ExportOpts;
340
- loadScene: boolean;
341
- saveToActiveFile: boolean;
342
- toggleTheme: boolean | null;
343
- saveAsImage: boolean;
344
- }>;
345
- type UIOptions = Partial<{
346
- dockedSidebarBreakpoint: number;
347
- canvasActions: CanvasActions;
348
- /** @deprecated does nothing. Will be removed in 0.15 */
349
- welcomeScreen?: boolean;
350
- }>;
351
- export type AppProps = Merge<ExcalidrawProps, {
352
- UIOptions: Merge<UIOptions, {
353
- canvasActions: Required<CanvasActions> & {
354
- export: ExportOpts;
355
- };
356
- }>;
357
- detectScroll: boolean;
358
- handleKeyboardGlobally: boolean;
359
- isCollaborating: boolean;
360
- children?: React.ReactNode;
361
- }>;
362
- /** A subset of App class properties that we need to use elsewhere
363
- * in the app, eg Manager. Factored out into a separate type to keep DRY. */
364
- export type AppClassProperties = {
365
- props: AppProps;
366
- canvas: HTMLCanvasElement | null;
367
- focusContainer(): void;
368
- library: Library;
369
- imageCache: Map<FileId, {
370
- image: HTMLImageElement | Promise<HTMLImageElement>;
371
- mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
372
- }>;
373
- files: BinaryFiles;
374
- device: App["device"];
375
- scene: App["scene"];
376
- pasteFromClipboard: App["pasteFromClipboard"];
377
- id: App["id"];
378
- onInsertElements: App["onInsertElements"];
379
- onExportImage: App["onExportImage"];
380
- lastViewportPosition: App["lastViewportPosition"];
381
- };
382
- export type PointerDownState = Readonly<{
383
- origin: Readonly<{
384
- x: number;
385
- y: number;
386
- }>;
387
- originInGrid: Readonly<{
388
- x: number;
389
- y: number;
390
- }>;
391
- scrollbars: ReturnType<typeof isOverScrollBars>;
392
- lastCoords: {
393
- x: number;
394
- y: number;
395
- };
396
- originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
397
- resize: {
398
- handleType: MaybeTransformHandleType;
399
- isResizing: boolean;
400
- offset: {
401
- x: number;
402
- y: number;
403
- };
404
- arrowDirection: "origin" | "end";
405
- center: {
406
- x: number;
407
- y: number;
408
- };
409
- };
410
- hit: {
411
- element: NonDeleted<ExcalidrawElement> | null;
412
- allHitElements: NonDeleted<ExcalidrawElement>[];
413
- wasAddedToSelection: boolean;
414
- hasBeenDuplicated: boolean;
415
- hasHitCommonBoundingBoxOfSelectedElements: boolean;
416
- };
417
- withCmdOrCtrl: boolean;
418
- drag: {
419
- hasOccurred: boolean;
420
- offset: {
421
- x: number;
422
- y: number;
423
- } | null;
424
- };
425
- eventListeners: {
426
- onMove: null | ReturnType<typeof throttleRAF>;
427
- onUp: null | ((event: PointerEvent) => void);
428
- onKeyDown: null | ((event: KeyboardEvent) => void);
429
- onKeyUp: null | ((event: KeyboardEvent) => void);
430
- };
431
- boxSelection: {
432
- hasOccurred: boolean;
433
- };
434
- elementIdsToErase: {
435
- [key: ExcalidrawElement["id"]]: {
436
- opacity: ExcalidrawElement["opacity"];
437
- erase: boolean;
438
- };
439
- };
440
- }>;
441
- export type ExcalidrawImperativeAPI = {
442
- updateScene: InstanceType<typeof App>["updateScene"];
443
- updateLibrary: InstanceType<typeof Library>["updateLibrary"];
444
- resetScene: InstanceType<typeof App>["resetScene"];
445
- getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
446
- history: {
447
- clear: InstanceType<typeof App>["resetHistory"];
448
- };
449
- scrollToContent: InstanceType<typeof App>["scrollToContent"];
450
- zoomToFit: InstanceType<typeof App>["zoomToFit"];
451
- startLineEditor: InstanceType<typeof App>["startLineEditor"];
452
- getSceneElements: InstanceType<typeof App>["getSceneElements"];
453
- getAppState: () => InstanceType<typeof App>["state"];
454
- getFiles: () => InstanceType<typeof App>["files"];
455
- refresh: InstanceType<typeof App>["refresh"];
456
- setToast: InstanceType<typeof App>["setToast"];
457
- addFiles: (data: BinaryFileData[]) => void;
458
- updateContainerSize: InstanceType<typeof App>["updateContainerSize"];
459
- readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
460
- ready: true;
461
- id: string;
462
- setLocalFont: (showOnPanel: boolean) => void;
463
- selectElements: (elements: readonly ExcalidrawElement[]) => void;
464
- sendBackward: (elements: readonly ExcalidrawElement[]) => void;
465
- bringForward: (elements: readonly ExcalidrawElement[]) => void;
466
- sendToBack: (elements: readonly ExcalidrawElement[]) => void;
467
- bringToFront: (elements: readonly ExcalidrawElement[]) => void;
468
- restore: InstanceType<typeof App>["restore"];
469
- setMobileModeAllowed: (allow: boolean) => void;
470
- setActiveTool: InstanceType<typeof App>["setActiveTool"];
471
- setCursor: InstanceType<typeof App>["setCursor"];
472
- resetCursor: InstanceType<typeof App>["resetCursor"];
473
- toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
474
- getHTMLIFrameElement: InstanceType<typeof App>["getHTMLIFrameElement"];
475
- /**
476
- * Disables rendering of frames (including element clipping), but currently
477
- * the frames are still interactive in edit mode. As such, this API should be
478
- * used in conjunction with view mode (props.viewModeEnabled).
479
- */
480
- updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
481
- };
482
- export type Device = Readonly<{
483
- isSmScreen: boolean;
484
- isMobile: boolean;
485
- isTouchScreen: boolean;
486
- canDeviceFitSidebar: boolean;
487
- isLandscape: boolean;
488
- }>;
489
- type FrameNameBounds = {
490
- x: number;
491
- y: number;
492
- width: number;
493
- height: number;
494
- angle: number;
495
- };
496
- export type FrameNameBoundsCache = {
497
- get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
498
- _cache: Map<string, FrameNameBounds & {
499
- zoom: AppState["zoom"]["value"];
500
- versionNonce: ExcalidrawFrameElement["versionNonce"];
501
- }>;
502
- };
503
- export {};
1
+ import React from "react";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
3
+ import { SHAPES } from "./shapes";
4
+ import { Point as RoughPoint } from "roughjs/bin/geometry";
5
+ import { LinearElementEditor } from "./element/linearElementEditor";
6
+ import { SuggestedBinding } from "./element/binding";
7
+ import { ImportedDataState } from "./data/types";
8
+ import type App from "./components/App";
9
+ import type { ResolvablePromise, throttleRAF } from "./utils";
10
+ import { Spreadsheet } from "./charts";
11
+ import { Language } from "./i18n";
12
+ import { ClipboardData } from "./clipboard";
13
+ import { isOverScrollBars } from "./scene";
14
+ import { MaybeTransformHandleType } from "./element/transformHandles";
15
+ import Library from "./data/library";
16
+ import type { FileSystemHandle } from "./data/filesystem";
17
+ import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
18
+ import { ContextMenuItems } from "./components/ContextMenu";
19
+ import { Merge, ForwardRef, ValueOf } from "./utility-types";
20
+ import { ColorPaletteCustom } from "./colors";
21
+ export type Point = Readonly<RoughPoint>;
22
+ export type Collaborator = {
23
+ pointer?: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ button?: "up" | "down";
28
+ selectedElementIds?: AppState["selectedElementIds"];
29
+ username?: string | null;
30
+ userState?: UserIdleState;
31
+ color?: {
32
+ background: string;
33
+ stroke: string;
34
+ };
35
+ avatarUrl?: string;
36
+ id?: string;
37
+ };
38
+ export type DataURL = string & {
39
+ _brand: "DataURL";
40
+ };
41
+ export type BinaryFileData = {
42
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
43
+ id: FileId;
44
+ dataURL: DataURL;
45
+ /**
46
+ * Epoch timestamp in milliseconds
47
+ */
48
+ created: number;
49
+ /**
50
+ * Indicates when the file was last retrieved from storage to be loaded
51
+ * onto the scene. We use this flag to determine whether to delete unused
52
+ * files from storage.
53
+ *
54
+ * Epoch timestamp in milliseconds.
55
+ */
56
+ lastRetrieved?: number;
57
+ };
58
+ export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
59
+ export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
60
+ export type LastActiveTool = {
61
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
62
+ customType: null;
63
+ } | {
64
+ type: "custom";
65
+ customType: string;
66
+ } | null;
67
+ export type SidebarName = string;
68
+ export type SidebarTabName = string;
69
+ export type AppState = {
70
+ contextMenu: {
71
+ items: ContextMenuItems;
72
+ top: number;
73
+ left: number;
74
+ } | null;
75
+ showWelcomeScreen: boolean;
76
+ isLoading: boolean;
77
+ errorMessage: React.ReactNode;
78
+ activeEmbeddable: {
79
+ element: NonDeletedExcalidrawElement;
80
+ state: "hover" | "active";
81
+ } | null;
82
+ draggingElement: NonDeletedExcalidrawElement | null;
83
+ resizingElement: NonDeletedExcalidrawElement | null;
84
+ multiElement: NonDeleted<ExcalidrawLinearElement> | null;
85
+ selectionElement: NonDeletedExcalidrawElement | null;
86
+ isBindingEnabled: boolean;
87
+ startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
88
+ suggestedBindings: SuggestedBinding[];
89
+ frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
90
+ frameRendering: {
91
+ enabled: boolean;
92
+ name: boolean;
93
+ outline: boolean;
94
+ clip: boolean;
95
+ };
96
+ editingFrame: string | null;
97
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
98
+ editingElement: NonDeletedExcalidrawElement | null;
99
+ editingLinearElement: LinearElementEditor | null;
100
+ activeTool: {
101
+ /**
102
+ * indicates a previous tool we should revert back to if we deselect the
103
+ * currently active tool. At the moment applies to `eraser` and `hand` tool.
104
+ */
105
+ lastActiveTool: LastActiveTool;
106
+ locked: boolean;
107
+ } & ({
108
+ type: typeof SHAPES[number]["value"] | "eraser" | "hand" | "frame" | "embeddable";
109
+ customType: null;
110
+ } | {
111
+ type: "custom";
112
+ customType: string;
113
+ });
114
+ penMode: boolean;
115
+ penDetected: boolean;
116
+ exportBackground: boolean;
117
+ exportEmbedScene: boolean;
118
+ exportWithDarkMode: boolean;
119
+ exportScale: number;
120
+ currentItemStrokeColor: string;
121
+ currentItemBackgroundColor: string;
122
+ currentItemFillStyle: ExcalidrawElement["fillStyle"];
123
+ currentItemStrokeWidth: number;
124
+ currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
125
+ currentItemRoughness: number;
126
+ currentItemOpacity: number;
127
+ currentItemFontFamily: FontFamilyValues;
128
+ currentItemFontSize: number;
129
+ currentItemTextAlign: TextAlign;
130
+ currentItemStartArrowhead: Arrowhead | null;
131
+ currentItemEndArrowhead: Arrowhead | null;
132
+ currentItemRoundness: StrokeRoundness;
133
+ viewBackgroundColor: string;
134
+ scrollX: number;
135
+ scrollY: number;
136
+ cursorButton: "up" | "down";
137
+ scrolledOutside: boolean;
138
+ name: string;
139
+ isResizing: boolean;
140
+ isRotating: boolean;
141
+ zoom: Zoom;
142
+ openMenu: "canvas" | "shape" | null;
143
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
144
+ openSidebar: {
145
+ name: SidebarName;
146
+ tab?: SidebarTabName;
147
+ } | null;
148
+ openDialog: "imageExport" | "help" | "jsonExport" | null;
149
+ /**
150
+ * Reflects user preference for whether the default sidebar should be docked.
151
+ *
152
+ * NOTE this is only a user preference and does not reflect the actual docked
153
+ * state of the sidebar, because the host apps can override this through
154
+ * a DefaultSidebar prop, which is not reflected back to the appState.
155
+ */
156
+ defaultSidebarDockedPreference: boolean;
157
+ lastPointerDownWith: PointerType;
158
+ selectedElementIds: Readonly<{
159
+ [id: string]: true;
160
+ }>;
161
+ previousSelectedElementIds: {
162
+ [id: string]: true;
163
+ };
164
+ selectedElementsAreBeingDragged: boolean;
165
+ shouldCacheIgnoreZoom: boolean;
166
+ toast: {
167
+ message: string;
168
+ closable?: boolean;
169
+ duration?: number;
170
+ } | null;
171
+ zenModeEnabled: boolean;
172
+ theme: Theme;
173
+ gridSize: number | null;
174
+ previousGridSize: number | null;
175
+ viewModeEnabled: boolean;
176
+ /** top-most selected groups (i.e. does not include nested groups) */
177
+ selectedGroupIds: {
178
+ [groupId: string]: boolean;
179
+ };
180
+ /** group being edited when you drill down to its constituent element
181
+ (e.g. when you double-click on a group's element) */
182
+ editingGroupId: GroupId | null;
183
+ width: number;
184
+ height: number;
185
+ offsetTop: number;
186
+ offsetLeft: number;
187
+ fileHandle: FileSystemHandle | null;
188
+ collaborators: Map<string, Collaborator>;
189
+ showStats: boolean;
190
+ currentChartType: ChartType;
191
+ pasteDialog: {
192
+ shown: false;
193
+ data: null;
194
+ } | {
195
+ shown: true;
196
+ data: Spreadsheet;
197
+ };
198
+ /** imageElement waiting to be placed on canvas */
199
+ pendingImageElementId: ExcalidrawImageElement["id"] | null;
200
+ showHyperlinkPopup: false | "info" | "editor";
201
+ linkOpacity: number;
202
+ trayModeEnabled: boolean;
203
+ colorPalette?: {
204
+ canvasBackground: ColorPaletteCustom;
205
+ elementBackground: ColorPaletteCustom;
206
+ elementStroke: ColorPaletteCustom;
207
+ topPicks: {
208
+ canvasBackground: [string, string, string, string, string];
209
+ elementStroke: [string, string, string, string, string];
210
+ elementBackground: [string, string, string, string, string];
211
+ };
212
+ };
213
+ allowWheelZoom?: boolean;
214
+ allowPinchZoom?: boolean;
215
+ pinnedScripts?: string[];
216
+ customPens?: any[];
217
+ currentStrokeOptions?: any;
218
+ resetCustomPen?: any;
219
+ gridColor: string;
220
+ dynamicStyle: string;
221
+ invertBindingBehaviour: boolean;
222
+ selectedLinearElement: LinearElementEditor | null;
223
+ };
224
+ export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
225
+ export type NormalizedZoomValue = number & {
226
+ _brand: "normalizedZoom";
227
+ };
228
+ export type Zoom = Readonly<{
229
+ value: NormalizedZoomValue;
230
+ }>;
231
+ export type PointerCoords = Readonly<{
232
+ x: number;
233
+ y: number;
234
+ }>;
235
+ export type Gesture = {
236
+ pointers: Map<number, PointerCoords>;
237
+ lastCenter: {
238
+ x: number;
239
+ y: number;
240
+ } | null;
241
+ initialDistance: number | null;
242
+ initialScale: number | null;
243
+ };
244
+ export declare class GestureEvent extends UIEvent {
245
+ readonly rotation: number;
246
+ readonly scale: number;
247
+ }
248
+ /** @deprecated legacy: do not use outside of migration paths */
249
+ export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
250
+ /** @deprecated legacy: do not use outside of migration paths */
251
+ type LibraryItems_v1 = readonly LibraryItem_v1[];
252
+ /** v2 library item */
253
+ export type LibraryItem = {
254
+ id: string;
255
+ status: "published" | "unpublished";
256
+ elements: readonly NonDeleted<ExcalidrawElement>[];
257
+ /** timestamp in epoch (ms) */
258
+ created: number;
259
+ name?: string;
260
+ error?: string;
261
+ };
262
+ export type LibraryItems = readonly LibraryItem[];
263
+ export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
264
+ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
265
+ export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
266
+ readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
267
+ ready?: false;
268
+ };
269
+ export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
270
+ libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
271
+ }>;
272
+ export interface ExcalidrawProps {
273
+ onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
274
+ initialData?: ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
275
+ excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>;
276
+ isCollaborating?: boolean;
277
+ onPointerUpdate?: (payload: {
278
+ pointer: {
279
+ x: number;
280
+ y: number;
281
+ };
282
+ button: "down" | "up";
283
+ pointersMap: Gesture["pointers"];
284
+ }) => void;
285
+ onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
286
+ onDrop?: (event: React.DragEvent<HTMLDivElement>) => Promise<boolean> | boolean;
287
+ renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
288
+ langCode?: Language["code"];
289
+ viewModeEnabled?: boolean;
290
+ zenModeEnabled?: boolean;
291
+ gridModeEnabled?: boolean;
292
+ libraryReturnUrl?: string;
293
+ initState?: AppState;
294
+ theme?: Theme;
295
+ name?: string;
296
+ renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
297
+ UIOptions?: Partial<UIOptions>;
298
+ detectScroll?: boolean;
299
+ handleKeyboardGlobally?: boolean;
300
+ onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
301
+ autoFocus?: boolean;
302
+ onBeforeTextEdit?: (textElement: ExcalidrawTextElement) => string;
303
+ onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, textToSubmit: string, originalText: string, isDeleted: boolean) => [string, string, string];
304
+ generateIdForFile?: (file: File) => string | Promise<string>;
305
+ onThemeChange?: (newTheme: string) => void;
306
+ onViewModeChange?: (isViewModeEnabled: boolean) => void;
307
+ onLinkOpen?: (element: NonDeletedExcalidrawElement, event: CustomEvent<{
308
+ nativeEvent: MouseEvent | React.PointerEvent<HTMLCanvasElement>;
309
+ }>) => void;
310
+ onLinkHover?: (element: NonDeletedExcalidrawElement, event: React.PointerEvent<HTMLCanvasElement>) => void;
311
+ onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
312
+ onScrollChange?: (scrollX: number, scrollY: number) => void;
313
+ children?: React.ReactNode;
314
+ validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
315
+ renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
316
+ renderWebview?: boolean;
317
+ renderEmbeddableMenu?: (appState: AppState) => JSX.Element | null;
318
+ }
319
+ export type SceneData = {
320
+ elements?: ImportedDataState["elements"];
321
+ appState?: ImportedDataState["appState"];
322
+ collaborators?: Map<string, Collaborator>;
323
+ commitToHistory?: boolean;
324
+ };
325
+ export declare enum UserIdleState {
326
+ ACTIVE = "active",
327
+ AWAY = "away",
328
+ IDLE = "idle"
329
+ }
330
+ export type ExportOpts = {
331
+ saveFileToDisk?: boolean;
332
+ onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
333
+ renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
334
+ };
335
+ type CanvasActions = Partial<{
336
+ changeViewBackgroundColor: boolean;
337
+ clearCanvas: boolean;
338
+ export: false | ExportOpts;
339
+ loadScene: boolean;
340
+ saveToActiveFile: boolean;
341
+ toggleTheme: boolean | null;
342
+ saveAsImage: boolean;
343
+ }>;
344
+ type UIOptions = Partial<{
345
+ dockedSidebarBreakpoint: number;
346
+ canvasActions: CanvasActions;
347
+ /** @deprecated does nothing. Will be removed in 0.15 */
348
+ welcomeScreen?: boolean;
349
+ }>;
350
+ export type AppProps = Merge<ExcalidrawProps, {
351
+ UIOptions: Merge<UIOptions, {
352
+ canvasActions: Required<CanvasActions> & {
353
+ export: ExportOpts;
354
+ };
355
+ }>;
356
+ detectScroll: boolean;
357
+ handleKeyboardGlobally: boolean;
358
+ isCollaborating: boolean;
359
+ children?: React.ReactNode;
360
+ }>;
361
+ /** A subset of App class properties that we need to use elsewhere
362
+ * in the app, eg Manager. Factored out into a separate type to keep DRY. */
363
+ export type AppClassProperties = {
364
+ props: AppProps;
365
+ canvas: HTMLCanvasElement | null;
366
+ focusContainer(): void;
367
+ library: Library;
368
+ imageCache: Map<FileId, {
369
+ image: HTMLImageElement | Promise<HTMLImageElement>;
370
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
371
+ }>;
372
+ files: BinaryFiles;
373
+ device: App["device"];
374
+ scene: App["scene"];
375
+ pasteFromClipboard: App["pasteFromClipboard"];
376
+ id: App["id"];
377
+ onInsertElements: App["onInsertElements"];
378
+ onExportImage: App["onExportImage"];
379
+ lastViewportPosition: App["lastViewportPosition"];
380
+ };
381
+ export type PointerDownState = Readonly<{
382
+ origin: Readonly<{
383
+ x: number;
384
+ y: number;
385
+ }>;
386
+ originInGrid: Readonly<{
387
+ x: number;
388
+ y: number;
389
+ }>;
390
+ scrollbars: ReturnType<typeof isOverScrollBars>;
391
+ lastCoords: {
392
+ x: number;
393
+ y: number;
394
+ };
395
+ originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
396
+ resize: {
397
+ handleType: MaybeTransformHandleType;
398
+ isResizing: boolean;
399
+ offset: {
400
+ x: number;
401
+ y: number;
402
+ };
403
+ arrowDirection: "origin" | "end";
404
+ center: {
405
+ x: number;
406
+ y: number;
407
+ };
408
+ };
409
+ hit: {
410
+ element: NonDeleted<ExcalidrawElement> | null;
411
+ allHitElements: NonDeleted<ExcalidrawElement>[];
412
+ wasAddedToSelection: boolean;
413
+ hasBeenDuplicated: boolean;
414
+ hasHitCommonBoundingBoxOfSelectedElements: boolean;
415
+ };
416
+ withCmdOrCtrl: boolean;
417
+ drag: {
418
+ hasOccurred: boolean;
419
+ offset: {
420
+ x: number;
421
+ y: number;
422
+ } | null;
423
+ };
424
+ eventListeners: {
425
+ onMove: null | ReturnType<typeof throttleRAF>;
426
+ onUp: null | ((event: PointerEvent) => void);
427
+ onKeyDown: null | ((event: KeyboardEvent) => void);
428
+ onKeyUp: null | ((event: KeyboardEvent) => void);
429
+ };
430
+ boxSelection: {
431
+ hasOccurred: boolean;
432
+ };
433
+ elementIdsToErase: {
434
+ [key: ExcalidrawElement["id"]]: {
435
+ opacity: ExcalidrawElement["opacity"];
436
+ erase: boolean;
437
+ };
438
+ };
439
+ }>;
440
+ export type ExcalidrawImperativeAPI = {
441
+ updateScene: InstanceType<typeof App>["updateScene"];
442
+ updateLibrary: InstanceType<typeof Library>["updateLibrary"];
443
+ resetScene: InstanceType<typeof App>["resetScene"];
444
+ getSceneElementsIncludingDeleted: InstanceType<typeof App>["getSceneElementsIncludingDeleted"];
445
+ history: {
446
+ clear: InstanceType<typeof App>["resetHistory"];
447
+ };
448
+ scrollToContent: InstanceType<typeof App>["scrollToContent"];
449
+ zoomToFit: InstanceType<typeof App>["zoomToFit"];
450
+ startLineEditor: InstanceType<typeof App>["startLineEditor"];
451
+ getSceneElements: InstanceType<typeof App>["getSceneElements"];
452
+ getAppState: () => InstanceType<typeof App>["state"];
453
+ getFiles: () => InstanceType<typeof App>["files"];
454
+ refresh: InstanceType<typeof App>["refresh"];
455
+ setToast: InstanceType<typeof App>["setToast"];
456
+ addFiles: (data: BinaryFileData[]) => void;
457
+ updateContainerSize: InstanceType<typeof App>["updateContainerSize"];
458
+ readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
459
+ ready: true;
460
+ id: string;
461
+ setLocalFont: (showOnPanel: boolean) => void;
462
+ selectElements: (elements: readonly ExcalidrawElement[]) => void;
463
+ sendBackward: (elements: readonly ExcalidrawElement[]) => void;
464
+ bringForward: (elements: readonly ExcalidrawElement[]) => void;
465
+ sendToBack: (elements: readonly ExcalidrawElement[]) => void;
466
+ bringToFront: (elements: readonly ExcalidrawElement[]) => void;
467
+ setMobileModeAllowed: (allow: boolean) => void;
468
+ setActiveTool: InstanceType<typeof App>["setActiveTool"];
469
+ setCursor: InstanceType<typeof App>["setCursor"];
470
+ resetCursor: InstanceType<typeof App>["resetCursor"];
471
+ toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
472
+ getHTMLIFrameElement: InstanceType<typeof App>["getHTMLIFrameElement"];
473
+ /**
474
+ * Disables rendering of frames (including element clipping), but currently
475
+ * the frames are still interactive in edit mode. As such, this API should be
476
+ * used in conjunction with view mode (props.viewModeEnabled).
477
+ */
478
+ updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
479
+ };
480
+ export type Device = Readonly<{
481
+ isSmScreen: boolean;
482
+ isMobile: boolean;
483
+ isTouchScreen: boolean;
484
+ canDeviceFitSidebar: boolean;
485
+ isLandscape: boolean;
486
+ }>;
487
+ type FrameNameBounds = {
488
+ x: number;
489
+ y: number;
490
+ width: number;
491
+ height: number;
492
+ angle: number;
493
+ };
494
+ export type FrameNameBoundsCache = {
495
+ get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
496
+ _cache: Map<string, FrameNameBounds & {
497
+ zoom: AppState["zoom"]["value"];
498
+ versionNonce: ExcalidrawFrameElement["versionNonce"];
499
+ }>;
500
+ };
501
+ export {};