@dwelle/excalidraw 0.4.0-e3bee83 → 0.4.0-e587816

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 (220) hide show
  1. package/CHANGELOG.md +525 -0
  2. package/README.md +18 -1820
  3. package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js → vendor-d415b28e9024dee4bb1b.js} +2 -2
  4. package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
  5. package/dist/excalidraw.development.js +3071 -1566
  6. package/dist/excalidraw.production.min.js +1 -1
  7. package/dist/excalidraw.production.min.js.LICENSE.txt +20 -0
  8. package/main.js +1 -8
  9. package/package.json +9 -4
  10. package/types/actions/actionAddToLibrary.d.ts +103 -55
  11. package/types/actions/actionAlign.d.ts +33 -28
  12. package/types/actions/actionBoundText.d.ts +175 -22
  13. package/types/actions/actionCanvas.d.ts +680 -170
  14. package/types/actions/actionClipboard.d.ts +174 -100
  15. package/types/actions/actionDeleteSelected.d.ts +102 -60
  16. package/types/actions/actionDistribute.d.ts +11 -12
  17. package/types/actions/actionDuplicateSelection.d.ts +3 -4
  18. package/types/actions/actionElementLock.d.ts +271 -0
  19. package/types/actions/actionExport.d.ts +363 -221
  20. package/types/actions/actionFinalize.d.ts +70 -42
  21. package/types/actions/actionFlip.d.ts +8 -11
  22. package/types/actions/actionFrame.d.ts +423 -0
  23. package/types/actions/actionGroup.d.ts +250 -13
  24. package/types/actions/actionHistory.d.ts +1 -1
  25. package/types/actions/actionLinearEditor.d.ts +37 -21
  26. package/types/actions/actionMenu.d.ts +108 -62
  27. package/types/actions/actionNavigate.d.ts +1 -1
  28. package/types/actions/actionProperties.d.ts +465 -256
  29. package/types/actions/actionSelectAll.d.ts +123 -4
  30. package/types/actions/actionStyles.d.ts +39 -24
  31. package/types/actions/actionToggleGridMode.d.ts +37 -22
  32. package/types/actions/{actionToggleLock.d.ts → actionToggleObjectsSnapMode.d.ts} +49 -32
  33. package/types/actions/actionToggleStats.d.ts +37 -22
  34. package/types/actions/actionToggleViewMode.d.ts +37 -22
  35. package/types/actions/actionToggleZenMode.d.ts +37 -22
  36. package/types/actions/actionZindex.d.ts +12 -12
  37. package/types/actions/index.d.ts +2 -1
  38. package/types/actions/manager.d.ts +1 -1
  39. package/types/actions/shortcuts.d.ts +2 -1
  40. package/types/actions/types.d.ts +11 -9
  41. package/types/appState.d.ts +18 -18
  42. package/types/charts.d.ts +2 -2
  43. package/types/clients.d.ts +5 -6
  44. package/types/clipboard.d.ts +8 -7
  45. package/types/colors.d.ts +60 -5
  46. package/types/components/Actions.d.ts +7 -12
  47. package/types/components/ActiveConfirmDialog.d.ts +4 -0
  48. package/types/components/App.d.ts +93 -35
  49. package/types/components/Avatar.d.ts +1 -2
  50. package/types/components/BraveMeasureTextError.d.ts +2 -0
  51. package/types/components/Button.d.ts +3 -2
  52. package/types/components/ButtonIconSelect.d.ts +11 -3
  53. package/types/components/Card.d.ts +0 -1
  54. package/types/components/ColorPicker/ColorInput.d.ts +9 -0
  55. package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
  56. package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
  57. package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
  58. package/types/components/ColorPicker/Picker.d.ts +18 -0
  59. package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
  60. package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
  61. package/types/components/ColorPicker/ShadeList.d.ts +8 -0
  62. package/types/components/ColorPicker/TopPicks.d.ts +9 -0
  63. package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
  64. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +20 -0
  65. package/types/components/ContextMenu.d.ts +3 -3
  66. package/types/components/DefaultSidebar.d.ts +29 -0
  67. package/types/components/Dialog.d.ts +3 -4
  68. package/types/components/ErrorDialog.d.ts +3 -2
  69. package/types/components/ExcalidrawLogo.d.ts +15 -0
  70. package/types/components/EyeDropper.d.ts +28 -0
  71. package/types/components/FilledButton.d.ts +17 -0
  72. package/types/components/FixedSideContainer.d.ts +1 -1
  73. package/types/components/HandButton.d.ts +10 -0
  74. package/types/components/HelpButton.d.ts +1 -2
  75. package/types/components/HintViewer.d.ts +4 -5
  76. package/types/components/HomeButton.d.ts +1 -1
  77. package/types/components/ImageExportDialog.d.ts +8 -13
  78. package/types/components/Island.d.ts +1 -1
  79. package/types/components/JSONExportDialog.d.ts +5 -5
  80. package/types/components/LaserTool/LaserPathManager.d.ts +28 -0
  81. package/types/components/LaserTool/LaserPointerButton.d.ts +10 -0
  82. package/types/components/LaserTool/LaserTool.d.ts +7 -0
  83. package/types/components/LayerUI.d.ts +9 -15
  84. package/types/components/LibraryMenu.d.ts +13 -14
  85. package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
  86. package/types/components/LibraryMenuControlButtons.d.ts +9 -0
  87. package/types/components/LibraryMenuHeaderContent.d.ts +10 -28
  88. package/types/components/LibraryMenuItems.d.ts +6 -7
  89. package/types/components/LibraryMenuSection.d.ts +22 -0
  90. package/types/components/LibraryUnit.d.ts +6 -3
  91. package/types/components/LoadingMessage.d.ts +0 -1
  92. package/types/components/LockButton.d.ts +1 -2
  93. package/types/components/MobileMenu.d.ts +8 -11
  94. package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
  95. package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
  96. package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
  97. package/types/components/PasteChartDialog.d.ts +4 -5
  98. package/types/components/PenModeButton.d.ts +1 -1
  99. package/types/components/Popover.d.ts +1 -1
  100. package/types/components/ProjectName.d.ts +2 -1
  101. package/types/components/PublishLibrary.d.ts +2 -2
  102. package/types/components/RadioGroup.d.ts +12 -0
  103. package/types/components/Section.d.ts +1 -1
  104. package/types/components/Sidebar/Sidebar.d.ts +66 -63
  105. package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
  106. package/types/components/Sidebar/SidebarTab.d.ts +8 -0
  107. package/types/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
  108. package/types/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
  109. package/types/components/Sidebar/SidebarTabs.d.ts +6 -0
  110. package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
  111. package/types/components/Sidebar/common.d.ts +24 -7
  112. package/types/components/Spinner.d.ts +2 -1
  113. package/types/components/Stack.d.ts +4 -3
  114. package/types/components/Stats.d.ts +3 -3
  115. package/types/components/Switch.d.ts +9 -0
  116. package/types/components/ToolButton.d.ts +6 -5
  117. package/types/components/Tooltip.d.ts +1 -1
  118. package/types/components/Trans.d.ts +9 -0
  119. package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
  120. package/types/components/canvases/StaticCanvas.d.ts +18 -0
  121. package/types/components/canvases/index.d.ts +3 -0
  122. package/types/components/dropdownMenu/DropdownMenu.d.ts +15 -9
  123. package/types/components/dropdownMenu/DropdownMenuContent.d.ts +7 -3
  124. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +4 -4
  125. package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -1
  126. package/types/components/dropdownMenu/DropdownMenuItemLink.d.ts +4 -2
  127. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -2
  128. package/types/components/dropdownMenu/common.d.ts +6 -0
  129. package/types/components/footer/Footer.d.ts +4 -5
  130. package/types/components/hoc/withInternalFallback.d.ts +4 -0
  131. package/types/components/icons.d.ts +16 -1
  132. package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
  133. package/types/components/main-menu/MainMenu.d.ts +22 -13
  134. package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
  135. package/types/components/welcome-screen/WelcomeScreen.d.ts +2 -3
  136. package/types/constants.d.ts +94 -10
  137. package/types/context/tunnels.d.ts +19 -0
  138. package/types/context/ui-appState.d.ts +4 -0
  139. package/types/cursor.d.ts +5 -0
  140. package/types/data/blob.d.ts +5 -3
  141. package/types/data/encode.d.ts +1 -1
  142. package/types/data/filesystem.d.ts +2 -1
  143. package/types/data/library.d.ts +3 -45
  144. package/types/data/restore.d.ts +10 -4
  145. package/types/data/transform.d.ts +73 -0
  146. package/types/data/types.d.ts +3 -5
  147. package/types/data/url.d.ts +7 -0
  148. package/types/element/Hyperlink.d.ts +48 -29
  149. package/types/element/binding.d.ts +4 -3
  150. package/types/element/bounds.d.ts +40 -10
  151. package/types/element/collision.d.ts +7 -7
  152. package/types/element/dragElements.d.ts +12 -2
  153. package/types/element/embeddable.d.ts +153 -0
  154. package/types/element/image.d.ts +11 -1
  155. package/types/element/index.d.ts +3 -2
  156. package/types/element/linearElementEditor.d.ts +43 -27
  157. package/types/element/mutateElement.d.ts +3 -2
  158. package/types/element/newElement.d.ts +48 -15
  159. package/types/element/resizeElements.d.ts +3 -2
  160. package/types/element/resizeTest.d.ts +2 -1
  161. package/types/element/showSelectedShapeActions.d.ts +2 -2
  162. package/types/element/sizeHelpers.d.ts +8 -1
  163. package/types/element/sortElements.d.ts +2 -0
  164. package/types/element/textElement.d.ts +43 -17
  165. package/types/element/textWysiwyg.d.ts +1 -1
  166. package/types/element/transformHandles.d.ts +16 -8
  167. package/types/element/typeChecks.d.ts +5 -2
  168. package/types/element/types.d.ts +59 -35
  169. package/types/emitter.d.ts +1 -2
  170. package/types/errors.d.ts +1 -1
  171. package/types/frame.d.ts +46 -0
  172. package/types/ga.d.ts +5 -5
  173. package/types/groups.d.ts +15 -11
  174. package/types/history.d.ts +3 -3
  175. package/types/hooks/useCreatePortalContainer.d.ts +4 -0
  176. package/types/hooks/useLibraryItemSvg.d.ts +11 -0
  177. package/types/hooks/useOutsideClick.d.ts +19 -2
  178. package/types/hooks/useScrollPosition.d.ts +1 -0
  179. package/types/hooks/useStable.d.ts +1 -0
  180. package/types/hooks/useTransition.d.ts +2 -0
  181. package/types/i18n.d.ts +11 -2
  182. package/types/jotai.d.ts +20 -108
  183. package/types/keys.d.ts +5 -4
  184. package/types/math.d.ts +5 -0
  185. package/types/packages/bbox.d.ts +11 -0
  186. package/types/packages/excalidraw/example/App.d.ts +7 -1
  187. package/types/packages/excalidraw/example/initialData.d.ts +182 -64
  188. package/types/packages/excalidraw/index.d.ts +11 -4
  189. package/types/packages/excalidraw/main.d.ts +3 -1
  190. package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
  191. package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
  192. package/types/packages/utils.d.ts +11 -2
  193. package/types/packages/withinBounds.d.ts +19 -0
  194. package/types/renderer/renderElement.d.ts +12 -22
  195. package/types/renderer/renderScene.d.ts +19 -27
  196. package/types/renderer/renderSnaps.d.ts +2 -0
  197. package/types/renderer/roundRect.d.ts +1 -1
  198. package/types/scene/Renderer.d.ts +25 -0
  199. package/types/scene/Scene.d.ts +27 -5
  200. package/types/scene/Shape.d.ts +12 -0
  201. package/types/scene/ShapeCache.d.ts +20 -0
  202. package/types/scene/comparisons.d.ts +0 -1
  203. package/types/scene/export.d.ts +50 -11
  204. package/types/scene/index.d.ts +1 -1
  205. package/types/scene/scroll.d.ts +1 -1
  206. package/types/scene/scrollbars.d.ts +2 -6
  207. package/types/scene/selection.d.ts +27 -6
  208. package/types/scene/types.d.ts +70 -34
  209. package/types/snapping.d.ts +108 -0
  210. package/types/types.d.ts +200 -84
  211. package/types/utility-types.d.ts +24 -0
  212. package/types/utils.d.ts +73 -29
  213. package/types/zindex.d.ts +4 -4
  214. package/types/components/ColorPicker.d.ts +0 -14
  215. package/types/components/LibraryButton.d.ts +0 -8
  216. package/types/components/SingleLibraryItem.d.ts +0 -10
  217. package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
  218. /package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js.LICENSE.txt → vendor-d415b28e9024dee4bb1b.js.LICENSE.txt} +0 -0
  219. /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.d.ts → vendor-d415b28e9024dee4bb1b.d.ts} +0 -0
  220. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
@@ -1,40 +1,50 @@
1
1
  import React from "react";
2
2
  import * as DefaultItems from "./DefaultItems";
3
- declare const MainMenu: {
4
- ({ children }: {
5
- children?: React.ReactNode;
6
- }): JSX.Element;
3
+ declare const MainMenu: React.FC<{
4
+ children?: React.ReactNode;
5
+ /**
6
+ * Called when any menu item is selected (clicked on).
7
+ */
8
+ onSelect?: ((event: Event) => void) | undefined;
9
+ } & {
10
+ __fallback?: boolean | undefined;
11
+ }> & {
7
12
  Trigger: {
8
- ({ className, children, onToggle, }: {
13
+ ({ className, children, onToggle, title, ...rest }: {
9
14
  className?: string | undefined;
10
15
  children: React.ReactNode;
11
16
  onToggle: () => void;
12
- }): JSX.Element;
17
+ title?: string | undefined;
18
+ } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): JSX.Element;
13
19
  displayName: string;
14
20
  };
15
21
  Item: {
16
- ({ icon, onSelect, children, shortcut, className, ...rest }: {
22
+ ({ icon, onSelect, children, shortcut, className, selected, ...rest }: {
17
23
  icon?: JSX.Element | undefined;
18
- onSelect: () => void;
24
+ onSelect: (event: Event) => void;
19
25
  children: React.ReactNode;
20
26
  shortcut?: string | undefined;
27
+ selected?: boolean | undefined;
21
28
  className?: string | undefined;
22
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): JSX.Element;
29
+ } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect">): JSX.Element;
23
30
  displayName: string;
24
31
  };
25
32
  ItemLink: {
26
- ({ icon, shortcut, href, children, className, ...rest }: {
33
+ ({ icon, shortcut, href, children, onSelect, className, selected, ...rest }: {
34
+ href: string;
27
35
  icon?: JSX.Element | undefined;
28
36
  children: React.ReactNode;
29
37
  shortcut?: string | undefined;
30
38
  className?: string | undefined;
31
- href: string;
39
+ selected?: boolean | undefined;
40
+ onSelect?: ((event: Event) => void) | undefined;
32
41
  } & React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element;
33
42
  displayName: string;
34
43
  };
35
- ItemCustom: ({ children, className, ...rest }: {
44
+ ItemCustom: ({ children, className, selected, ...rest }: {
36
45
  children: React.ReactNode;
37
46
  className?: string | undefined;
47
+ selected?: boolean | undefined;
38
48
  } & React.HTMLAttributes<HTMLDivElement>) => JSX.Element;
39
49
  Group: {
40
50
  ({ children, className, style, title, }: {
@@ -50,6 +60,5 @@ declare const MainMenu: {
50
60
  displayName: string;
51
61
  };
52
62
  DefaultItems: typeof DefaultItems;
53
- displayName: string;
54
63
  };
55
64
  export default MainMenu;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const Center: {
3
2
  ({ children }: {
4
3
  children?: React.ReactNode;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  import "./WelcomeScreen.scss";
3
2
  declare const WelcomeScreen: {
4
3
  (props: {
5
- children: React.ReactNode;
6
- }): null;
4
+ children?: React.ReactNode;
5
+ }): JSX.Element;
7
6
  displayName: string;
8
7
  Center: {
9
8
  ({ children }: {
@@ -1,5 +1,12 @@
1
1
  import { AppProps, NormalizedZoomValue } from "./types";
2
- import { FontFamilyValues } from "./element/types";
2
+ import { ExcalidrawElement, FontFamilyValues } from "./element/types";
3
+ export declare const isDarwin: boolean;
4
+ export declare const isWindows: boolean;
5
+ export declare const isAndroid: boolean;
6
+ export declare const isFirefox: boolean;
7
+ export declare const isChrome: boolean;
8
+ export declare const isSafari: boolean;
9
+ export declare const isBrave: () => boolean;
3
10
  export declare const APP_NAME = "Excalidraw";
4
11
  export declare const DRAGGING_THRESHOLD = 10;
5
12
  export declare const LINE_CONFIRM_THRESHOLD = 8;
@@ -7,6 +14,7 @@ export declare const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
7
14
  export declare const ELEMENT_TRANSLATE_AMOUNT = 1;
8
15
  export declare const TEXT_TO_CENTER_SNAP_THRESHOLD = 30;
9
16
  export declare const SHIFT_LOCKING_ANGLE: number;
17
+ export declare const DEFAULT_LASER_COLOR = "red";
10
18
  export declare const CURSOR_TYPE: {
11
19
  TEXT: string;
12
20
  CROSSHAIR: string;
@@ -22,6 +30,11 @@ export declare const POINTER_BUTTON: {
22
30
  readonly SECONDARY: 2;
23
31
  readonly TOUCH: -1;
24
32
  };
33
+ export declare const POINTER_EVENTS: {
34
+ readonly enabled: "all";
35
+ readonly disabled: "none";
36
+ readonly inheritFromUI: any;
37
+ };
25
38
  export declare enum EVENT {
26
39
  COPY = "copy",
27
40
  PASTE = "paste",
@@ -40,6 +53,7 @@ export declare enum EVENT {
40
53
  GESTURE_START = "gesturestart",
41
54
  GESTURE_CHANGE = "gesturechange",
42
55
  POINTER_MOVE = "pointermove",
56
+ POINTER_DOWN = "pointerdown",
43
57
  POINTER_UP = "pointerup",
44
58
  STATE_CHANGE = "statechange",
45
59
  WHEEL = "wheel",
@@ -48,8 +62,18 @@ export declare enum EVENT {
48
62
  HASHCHANGE = "hashchange",
49
63
  VISIBILITY_CHANGE = "visibilitychange",
50
64
  SCROLL = "scroll",
51
- EXCALIDRAW_LINK = "excalidraw-link"
65
+ EXCALIDRAW_LINK = "excalidraw-link",
66
+ MENU_ITEM_SELECT = "menu.itemSelect",
67
+ MESSAGE = "message"
52
68
  }
69
+ export declare const YOUTUBE_STATES: {
70
+ readonly UNSTARTED: -1;
71
+ readonly ENDED: 0;
72
+ readonly PLAYING: 1;
73
+ readonly PAUSED: 2;
74
+ readonly BUFFERING: 3;
75
+ readonly CUED: 5;
76
+ };
53
77
  export declare const ENV: {
54
78
  TEST: string;
55
79
  DEVELOPMENT: string;
@@ -64,10 +88,24 @@ export declare const FONT_FAMILY: {
64
88
  Cascadia: number;
65
89
  };
66
90
  export declare const THEME: {
67
- LIGHT: string;
68
- DARK: string;
91
+ readonly LIGHT: "light";
92
+ readonly DARK: "dark";
93
+ };
94
+ export declare const FRAME_STYLE: {
95
+ strokeColor: string;
96
+ strokeWidth: number;
97
+ strokeStyle: import("./element/types").StrokeStyle;
98
+ fillStyle: import("./element/types").FillStyle;
99
+ roughness: number;
100
+ roundness: {
101
+ type: import("./element/types").RoundnessType;
102
+ value?: number | undefined;
103
+ } | null;
104
+ backgroundColor: string;
105
+ radius: number;
69
106
  };
70
107
  export declare const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
108
+ export declare const MIN_FONT_SIZE = 1;
71
109
  export declare const DEFAULT_FONT_SIZE = 20;
72
110
  export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
73
111
  export declare const DEFAULT_TEXT_ALIGN = "left";
@@ -78,25 +116,44 @@ export declare const DEFAULT_STROKE_COLOR = "#000000";
78
116
  export declare const DEFAULT_ZOOM_VALUE: NormalizedZoomValue;
79
117
  export declare const CANVAS_ONLY_ACTIONS: string[];
80
118
  export declare const GRID_SIZE = 20;
119
+ export declare const IMAGE_MIME_TYPES: {
120
+ readonly svg: "image/svg+xml";
121
+ readonly png: "image/png";
122
+ readonly jpg: "image/jpeg";
123
+ readonly gif: "image/gif";
124
+ readonly webp: "image/webp";
125
+ readonly bmp: "image/bmp";
126
+ readonly ico: "image/x-icon";
127
+ readonly avif: "image/avif";
128
+ readonly jfif: "image/jfif";
129
+ };
81
130
  export declare const MIME_TYPES: {
82
- readonly excalidraw: "application/vnd.excalidraw+json";
83
- readonly excalidrawlib: "application/vnd.excalidrawlib+json";
84
- readonly json: "application/json";
85
131
  readonly svg: "image/svg+xml";
86
- readonly "excalidraw.svg": "image/svg+xml";
87
132
  readonly png: "image/png";
88
- readonly "excalidraw.png": "image/png";
89
133
  readonly jpg: "image/jpeg";
90
134
  readonly gif: "image/gif";
91
135
  readonly webp: "image/webp";
92
136
  readonly bmp: "image/bmp";
93
137
  readonly ico: "image/x-icon";
138
+ readonly avif: "image/avif";
139
+ readonly jfif: "image/jfif";
140
+ readonly json: "application/json";
141
+ readonly excalidraw: "application/vnd.excalidraw+json";
142
+ readonly excalidrawlib: "application/vnd.excalidrawlib+json";
143
+ readonly "excalidraw.svg": "image/svg+xml";
144
+ readonly "excalidraw.png": "image/png";
94
145
  readonly binary: "application/octet-stream";
95
146
  };
147
+ export declare const EXPORT_IMAGE_TYPES: {
148
+ readonly png: "png";
149
+ readonly svg: "svg";
150
+ readonly clipboard: "clipboard";
151
+ };
96
152
  export declare const EXPORT_DATA_TYPES: {
97
153
  readonly excalidraw: "excalidraw";
98
154
  readonly excalidrawClipboard: "excalidraw/clipboard";
99
155
  readonly excalidrawLibrary: "excalidrawlib";
156
+ readonly excalidrawClipboardWithAPI: "excalidraw-api/clipboard";
100
157
  };
101
158
  export declare const EXPORT_SOURCE: string;
102
159
  export declare const IMAGE_RENDER_TIMEOUT = 500;
@@ -128,7 +185,6 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
128
185
  export declare const EXPORT_SCALES: number[];
129
186
  export declare const DEFAULT_EXPORT_PADDING = 10;
130
187
  export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
131
- export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif", "image/webp", "image/bmp", "image/x-icon"];
132
188
  export declare const MAX_ALLOWED_FILE_BYTES: number;
133
189
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
134
190
  export declare const ENCRYPTION_KEY_BITS = 128;
@@ -137,6 +193,8 @@ export declare const VERSIONS: {
137
193
  readonly excalidrawLibrary: 2;
138
194
  };
139
195
  export declare const BOUND_TEXT_PADDING = 5;
196
+ export declare const ARROW_LABEL_WIDTH_FRACTION = 0.7;
197
+ export declare const ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11;
140
198
  export declare const VERTICAL_ALIGN: {
141
199
  TOP: string;
142
200
  MIDDLE: string;
@@ -158,3 +216,29 @@ export declare const ROUNDNESS: {
158
216
  /** key containt id of precedeing elemnt id we use in reconciliation during
159
217
  * collaboration */
160
218
  export declare const PRECEDING_ELEMENT_KEY = "__precedingElement__";
219
+ export declare const ROUGHNESS: {
220
+ readonly architect: 0;
221
+ readonly artist: 1;
222
+ readonly cartoonist: 2;
223
+ };
224
+ export declare const STROKE_WIDTH: {
225
+ readonly thin: 1;
226
+ readonly bold: 2;
227
+ readonly extraBold: 4;
228
+ };
229
+ export declare const DEFAULT_ELEMENT_PROPS: {
230
+ strokeColor: ExcalidrawElement["strokeColor"];
231
+ backgroundColor: ExcalidrawElement["backgroundColor"];
232
+ fillStyle: ExcalidrawElement["fillStyle"];
233
+ strokeWidth: ExcalidrawElement["strokeWidth"];
234
+ strokeStyle: ExcalidrawElement["strokeStyle"];
235
+ roughness: ExcalidrawElement["roughness"];
236
+ opacity: ExcalidrawElement["opacity"];
237
+ locked: ExcalidrawElement["locked"];
238
+ };
239
+ export declare const LIBRARY_SIDEBAR_TAB = "library";
240
+ export declare const DEFAULT_SIDEBAR: {
241
+ readonly name: "default";
242
+ readonly defaultTab: "library";
243
+ };
244
+ export declare const LIBRARY_DISABLED_TYPES: Set<"embeddable" | "image">;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import tunnel from "tunnel-rat";
3
+ export type Tunnel = ReturnType<typeof tunnel>;
4
+ type TunnelsContextValue = {
5
+ MainMenuTunnel: Tunnel;
6
+ WelcomeScreenMenuHintTunnel: Tunnel;
7
+ WelcomeScreenToolbarHintTunnel: Tunnel;
8
+ WelcomeScreenHelpHintTunnel: Tunnel;
9
+ WelcomeScreenCenterTunnel: Tunnel;
10
+ FooterCenterTunnel: Tunnel;
11
+ DefaultSidebarTriggerTunnel: Tunnel;
12
+ DefaultSidebarTabTriggersTunnel: Tunnel;
13
+ OverwriteConfirmDialogTunnel: Tunnel;
14
+ jotaiScope: symbol;
15
+ };
16
+ export declare const TunnelsContext: React.Context<TunnelsContextValue>;
17
+ export declare const useTunnels: () => TunnelsContextValue;
18
+ export declare const useInitializeTunnels: () => TunnelsContextValue;
19
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { UIAppState } from "../types";
3
+ export declare const UIAppStateContext: React.Context<UIAppState>;
4
+ export declare const useUIAppState: () => UIAppState;
@@ -0,0 +1,5 @@
1
+ import { AppState } from "./types";
2
+ export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
3
+ export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;
4
+ export declare const setEraserCursor: (interactiveCanvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
5
+ export declare const setCursorForShape: (interactiveCanvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
@@ -1,6 +1,7 @@
1
- import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
1
+ import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
2
2
  import { ExcalidrawElement, FileId } from "../element/types";
3
3
  import { AppState, DataURL, LibraryItem } from "../types";
4
+ import { ValueOf } from "../utility-types";
4
5
  import { FileSystemHandle } from "./filesystem";
5
6
  import { ImportedLibraryData } from "./types";
6
7
  export declare const getMimeType: (blob: Blob | string) => string;
@@ -8,7 +9,7 @@ export declare const getFileHandleType: (handle: FileSystemHandle | null) => str
8
9
  export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
9
10
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
10
11
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
11
- type: (typeof ALLOWED_IMAGE_MIME_TYPES)[number];
12
+ type: ValueOf<typeof IMAGE_MIME_TYPES>;
12
13
  };
13
14
  export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<{
14
15
  type: "application/vnd.excalidraw+json";
@@ -20,7 +21,7 @@ export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppSta
20
21
  export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<import("./restore").RestoredDataState>;
21
22
  export declare const parseLibraryJSON: (json: string, defaultStatus?: LibraryItem["status"]) => LibraryItem[];
22
23
  export declare const loadLibraryFromBlob: (blob: Blob, defaultStatus?: LibraryItem["status"]) => Promise<LibraryItem[]>;
23
- export declare const canvasToBlob: (canvas: HTMLCanvasElement) => Promise<Blob>;
24
+ export declare const canvasToBlob: (canvas: HTMLCanvasElement | Promise<HTMLCanvasElement>) => Promise<Blob>;
24
25
  /** generates SHA-1 digest from supplied file (if not supported, falls back
25
26
  to a 40-char base64 random id) */
26
27
  export declare const generateIdFromFile: (file: File) => Promise<FileId>;
@@ -34,6 +35,7 @@ export declare const resizeImageFile: (file: File, opts: {
34
35
  export declare const SVGStringToFile: (SVGString: string, filename?: string) => File & {
35
36
  type: typeof MIME_TYPES.svg;
36
37
  };
38
+ export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>;
37
39
  export declare const getFileFromEvent: (event: React.DragEvent<HTMLDivElement>) => Promise<{
38
40
  file: File | null;
39
41
  fileHandle: FileSystemHandle | null;
@@ -5,7 +5,7 @@ export declare const toByteString: (data: string | Uint8Array | ArrayBuffer) =>
5
5
  */
6
6
  export declare const stringToBase64: (str: string, isByteString?: boolean) => Promise<string>;
7
7
  export declare const base64ToString: (base64: string, isByteString?: boolean) => Promise<string>;
8
- declare type EncodedData = {
8
+ type EncodedData = {
9
9
  encoded: string;
10
10
  encoding: "bstring";
11
11
  /** whether text is compressed (zlib) */
@@ -1,5 +1,6 @@
1
1
  import { FileSystemHandle, supported as nativeFileSystemSupported } from "browser-fs-access";
2
- declare type FILE_EXTENSION = "gif" | "jpg" | "png" | "excalidraw.png" | "svg" | "excalidraw.svg" | "json" | "excalidraw" | "excalidrawlib";
2
+ import { MIME_TYPES } from "../constants";
3
+ type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
3
4
  export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
4
5
  extensions?: FILE_EXTENSION[] | undefined;
5
6
  description: string;
@@ -1,55 +1,11 @@
1
1
  import { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource } from "../types";
2
2
  import type App from "../components/App";
3
3
  import { ExcalidrawElement } from "../element/types";
4
- export declare const libraryItemsAtom: import("jotai").Atom<{
4
+ export declare const libraryItemsAtom: import("jotai").PrimitiveAtom<{
5
5
  status: "loading" | "loaded";
6
6
  isInitialized: boolean;
7
7
  libraryItems: LibraryItems;
8
8
  }> & {
9
- write: (get: {
10
- <Value>(atom: import("jotai").Atom<Value | Promise<Value>>): Value;
11
- <Value_1>(atom: import("jotai").Atom<Promise<Value_1>>): Value_1;
12
- <Value_2>(atom: import("jotai").Atom<Value_2>): Value_2 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_2;
13
- } & {
14
- <Value_3>(atom: import("jotai").Atom<Value_3 | Promise<Value_3>>, options: {
15
- unstable_promise: true;
16
- }): Value_3 | Promise<Value_3>;
17
- <Value_4>(atom: import("jotai").Atom<Promise<Value_4>>, options: {
18
- unstable_promise: true;
19
- }): Value_4 | Promise<Value_4>;
20
- <Value_5>(atom: import("jotai").Atom<Value_5>, options: {
21
- unstable_promise: true;
22
- }): (Value_5 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_5) | Promise<Value_5 extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? V extends Promise<infer V> ? any : V : V : V : V : V : V : V : V : V : V : Value_5>;
23
- }, set: {
24
- <Value_6, Result extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_6, undefined, Result>): Result;
25
- <Value_7, Update, Result_1 extends void | Promise<void>>(atom: import("jotai").WritableAtom<Value_7, Update, Result_1>, update: Update): Result_1;
26
- }, update: {
27
- status: "loading" | "loaded";
28
- isInitialized: boolean;
29
- libraryItems: LibraryItems;
30
- } | ((prev: {
31
- status: "loading" | "loaded";
32
- isInitialized: boolean;
33
- libraryItems: LibraryItems;
34
- }) => {
35
- status: "loading" | "loaded";
36
- isInitialized: boolean;
37
- libraryItems: LibraryItems;
38
- })) => void;
39
- onMount?: (<S extends (update: {
40
- status: "loading" | "loaded";
41
- isInitialized: boolean;
42
- libraryItems: LibraryItems;
43
- } | ((prev: {
44
- status: "loading" | "loaded";
45
- isInitialized: boolean;
46
- libraryItems: LibraryItems;
47
- }) => {
48
- status: "loading" | "loaded";
49
- isInitialized: boolean;
50
- libraryItems: LibraryItems;
51
- })) => void>(setAtom: S) => void | (() => void)) | undefined;
52
- } & {
53
9
  init: {
54
10
  status: "loading" | "loaded";
55
11
  isInitialized: boolean;
@@ -70,6 +26,8 @@ declare class Library {
70
26
  private updateQueue;
71
27
  private getLastUpdateTask;
72
28
  private notifyListeners;
29
+ /** call on excalidraw instance unmount */
30
+ destroy: () => void;
73
31
  resetLibrary: () => Promise<LibraryItems>;
74
32
  /**
75
33
  * @returns latest cloned libraryItems. Awaits all in-progress updates first.
@@ -1,15 +1,21 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles, LibraryItem } from "../types";
3
3
  import { ImportedDataState } from "./types";
4
- declare type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
4
+ type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
5
5
  export declare const AllowedExcalidrawActiveTools: Record<AppState["activeTool"]["type"], boolean>;
6
- export declare type RestoredDataState = {
6
+ export type RestoredDataState = {
7
7
  elements: ExcalidrawElement[];
8
8
  appState: RestoredAppState;
9
9
  files: BinaryFiles;
10
10
  };
11
- export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, refreshDimensions?: boolean) => ExcalidrawElement[];
11
+ export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined, opts?: {
12
+ refreshDimensions?: boolean;
13
+ repairBindings?: boolean;
14
+ } | undefined) => ExcalidrawElement[];
12
15
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
13
- export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined) => RestoredDataState;
16
+ export declare const restore: (data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, localAppState: Partial<AppState> | null | undefined, localElements: readonly ExcalidrawElement[] | null | undefined, elementsConfig?: {
17
+ refreshDimensions?: boolean;
18
+ repairBindings?: boolean;
19
+ }) => RestoredDataState;
14
20
  export declare const restoreLibraryItems: (libraryItems: ImportedDataState["libraryItems"], defaultStatus: LibraryItem["status"]) => LibraryItem[];
15
21
  export {};
@@ -0,0 +1,73 @@
1
+ import { ElementConstructorOpts } from "../element/newElement";
2
+ import { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawFrameElement, ExcalidrawFreeDrawElement, ExcalidrawGenericElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawSelectionElement, ExcalidrawTextElement, FileId, FontFamilyValues, TextAlign, VerticalAlign } from "../element/types";
3
+ import { MarkOptional } from "../utility-types";
4
+ export type ValidLinearElement = {
5
+ type: "arrow" | "line";
6
+ x: number;
7
+ y: number;
8
+ label?: {
9
+ text: string;
10
+ fontSize?: number;
11
+ fontFamily?: FontFamilyValues;
12
+ textAlign?: TextAlign;
13
+ verticalAlign?: VerticalAlign;
14
+ } & MarkOptional<ElementConstructorOpts, "x" | "y">;
15
+ end?: (({
16
+ type: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
17
+ id?: ExcalidrawGenericElement["id"];
18
+ } | {
19
+ id: ExcalidrawGenericElement["id"];
20
+ type?: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
21
+ }) | (({
22
+ type: "text";
23
+ text: string;
24
+ } | {
25
+ type?: "text";
26
+ id: ExcalidrawTextElement["id"];
27
+ text: string;
28
+ }) & Partial<ExcalidrawTextElement>)) & MarkOptional<ElementConstructorOpts, "x" | "y">;
29
+ start?: (({
30
+ type: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
31
+ id?: ExcalidrawGenericElement["id"];
32
+ } | {
33
+ id: ExcalidrawGenericElement["id"];
34
+ type?: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "embeddable">;
35
+ }) | (({
36
+ type: "text";
37
+ text: string;
38
+ } | {
39
+ type?: "text";
40
+ id: ExcalidrawTextElement["id"];
41
+ text: string;
42
+ }) & Partial<ExcalidrawTextElement>)) & MarkOptional<ElementConstructorOpts, "x" | "y">;
43
+ } & Partial<ExcalidrawLinearElement>;
44
+ export type ValidContainer = {
45
+ type: Exclude<ExcalidrawGenericElement["type"], "selection">;
46
+ id?: ExcalidrawGenericElement["id"];
47
+ label?: {
48
+ text: string;
49
+ fontSize?: number;
50
+ fontFamily?: FontFamilyValues;
51
+ textAlign?: TextAlign;
52
+ verticalAlign?: VerticalAlign;
53
+ } & MarkOptional<ElementConstructorOpts, "x" | "y">;
54
+ } & ElementConstructorOpts;
55
+ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, ExcalidrawEmbeddableElement | ExcalidrawFreeDrawElement | ExcalidrawFrameElement> | ({
56
+ type: Extract<ExcalidrawLinearElement["type"], "line">;
57
+ x: number;
58
+ y: number;
59
+ } & Partial<ExcalidrawLinearElement>) | ValidContainer | ValidLinearElement | ({
60
+ type: "text";
61
+ text: string;
62
+ x: number;
63
+ y: number;
64
+ id?: ExcalidrawTextElement["id"];
65
+ } & Partial<ExcalidrawTextElement>) | ({
66
+ type: Extract<ExcalidrawImageElement["type"], "image">;
67
+ x: number;
68
+ y: number;
69
+ fileId: FileId;
70
+ } & Partial<ExcalidrawImageElement>);
71
+ export declare const convertToExcalidrawElements: (elementsSkeleton: ExcalidrawElementSkeleton[] | null, opts?: {
72
+ regenerateIds: boolean;
73
+ }) => ExcalidrawElement[];
@@ -17,11 +17,9 @@ export interface ExportedDataState {
17
17
  * This is a helper type used in downstream abstractions.
18
18
  * Don't consume on its own.
19
19
  */
20
- export declare type LegacyAppState = {
21
- /** @deprecated #5663 TODO remove 22-12-15 */
22
- isLibraryOpen: [boolean, "openSidebar"];
23
- /** @deprecated #5663 TODO remove 22-12-15 */
24
- isLibraryMenuDocked: [boolean, "isSidebarDocked"];
20
+ export type LegacyAppState = {
21
+ /** @deprecated #6213 TODO remove 23-06-01 */
22
+ isSidebarDocked: [boolean, "defaultSidebarDockedPreference"];
25
23
  };
26
24
  export interface ImportedDataState {
27
25
  type?: string;
@@ -0,0 +1,7 @@
1
+ export declare const normalizeLink: (link: string) => string;
2
+ export declare const isLocalLink: (link: string | null) => boolean;
3
+ /**
4
+ * Returns URL sanitized and safe for usage in places such as
5
+ * iframe's src attribute or <a> href attributes.
6
+ */
7
+ export declare const toValidURL: (link: string) => string;