@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
package/types/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness } from "./element/types";
3
- import { SHAPES } from "./shapes";
1
+ import React from "react";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
4
3
  import { Point as RoughPoint } from "roughjs/bin/geometry";
5
4
  import { LinearElementEditor } from "./element/linearElementEditor";
6
5
  import { SuggestedBinding } from "./element/binding";
@@ -14,14 +13,13 @@ import { isOverScrollBars } from "./scene";
14
13
  import { MaybeTransformHandleType } from "./element/transformHandles";
15
14
  import Library from "./data/library";
16
15
  import type { FileSystemHandle } from "./data/filesystem";
17
- import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
16
+ import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
18
17
  import { ContextMenuItems } from "./components/ContextMenu";
19
- export declare type Point = Readonly<RoughPoint>;
20
- export declare type Collaborator = {
21
- pointer?: {
22
- x: number;
23
- y: number;
24
- };
18
+ import { SnapLine } from "./snapping";
19
+ import { Merge, ForwardRef, ValueOf } from "./utility-types";
20
+ export type Point = Readonly<RoughPoint>;
21
+ export type Collaborator = {
22
+ pointer?: CollaboratorPointer;
25
23
  button?: "up" | "down";
26
24
  selectedElementIds?: AppState["selectedElementIds"];
27
25
  username?: string | null;
@@ -33,11 +31,29 @@ export declare type Collaborator = {
33
31
  avatarUrl?: string;
34
32
  id?: string;
35
33
  };
36
- export declare type DataURL = string & {
34
+ export type CollaboratorPointer = {
35
+ x: number;
36
+ y: number;
37
+ tool: "pointer" | "laser";
38
+ /**
39
+ * Whether to render cursor + username. Useful when you only want to render
40
+ * laser trail.
41
+ *
42
+ * @default true
43
+ */
44
+ renderCursor?: boolean;
45
+ /**
46
+ * Explicit laser color.
47
+ *
48
+ * @default string collaborator's cursor color
49
+ */
50
+ laserColor?: string;
51
+ };
52
+ export type DataURL = string & {
37
53
  _brand: "DataURL";
38
54
  };
39
- export declare type BinaryFileData = {
40
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number] | typeof MIME_TYPES.binary;
55
+ export type BinaryFileData = {
56
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
41
57
  id: FileId;
42
58
  dataURL: DataURL;
43
59
  /**
@@ -53,16 +69,58 @@ export declare type BinaryFileData = {
53
69
  */
54
70
  lastRetrieved?: number;
55
71
  };
56
- export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
57
- export declare type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
58
- export declare type LastActiveToolBeforeEraser = {
59
- type: typeof SHAPES[number]["value"] | "eraser";
72
+ export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
73
+ export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
74
+ export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "laser";
75
+ export type ActiveTool = {
76
+ type: ToolType;
60
77
  customType: null;
61
78
  } | {
62
79
  type: "custom";
63
80
  customType: string;
64
- } | null;
65
- export declare type AppState = {
81
+ };
82
+ export type SidebarName = string;
83
+ export type SidebarTabName = string;
84
+ type _CommonCanvasAppState = {
85
+ zoom: AppState["zoom"];
86
+ scrollX: AppState["scrollX"];
87
+ scrollY: AppState["scrollY"];
88
+ width: AppState["width"];
89
+ height: AppState["height"];
90
+ viewModeEnabled: AppState["viewModeEnabled"];
91
+ editingGroupId: AppState["editingGroupId"];
92
+ selectedElementIds: AppState["selectedElementIds"];
93
+ frameToHighlight: AppState["frameToHighlight"];
94
+ offsetLeft: AppState["offsetLeft"];
95
+ offsetTop: AppState["offsetTop"];
96
+ theme: AppState["theme"];
97
+ pendingImageElementId: AppState["pendingImageElementId"];
98
+ };
99
+ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
100
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
101
+ exportScale: AppState["exportScale"];
102
+ selectedElementsAreBeingDragged: AppState["selectedElementsAreBeingDragged"];
103
+ gridSize: AppState["gridSize"];
104
+ frameRendering: AppState["frameRendering"];
105
+ }>;
106
+ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
107
+ activeEmbeddable: AppState["activeEmbeddable"];
108
+ editingLinearElement: AppState["editingLinearElement"];
109
+ selectionElement: AppState["selectionElement"];
110
+ selectedGroupIds: AppState["selectedGroupIds"];
111
+ selectedLinearElement: AppState["selectedLinearElement"];
112
+ multiElement: AppState["multiElement"];
113
+ isBindingEnabled: AppState["isBindingEnabled"];
114
+ suggestedBindings: AppState["suggestedBindings"];
115
+ isRotating: AppState["isRotating"];
116
+ elementsToHighlight: AppState["elementsToHighlight"];
117
+ openSidebar: AppState["openSidebar"];
118
+ showHyperlinkPopup: AppState["showHyperlinkPopup"];
119
+ collaborators: AppState["collaborators"];
120
+ snapLines: AppState["snapLines"];
121
+ zenModeEnabled: AppState["zenModeEnabled"];
122
+ }>;
123
+ export type AppState = {
66
124
  contextMenu: {
67
125
  items: ContextMenuItems;
68
126
  top: number;
@@ -70,7 +128,11 @@ export declare type AppState = {
70
128
  } | null;
71
129
  showWelcomeScreen: boolean;
72
130
  isLoading: boolean;
73
- errorMessage: string | null;
131
+ errorMessage: React.ReactNode;
132
+ activeEmbeddable: {
133
+ element: NonDeletedExcalidrawElement;
134
+ state: "hover" | "active";
135
+ } | null;
74
136
  draggingElement: NonDeletedExcalidrawElement | null;
75
137
  resizingElement: NonDeletedExcalidrawElement | null;
76
138
  multiElement: NonDeleted<ExcalidrawLinearElement> | null;
@@ -78,19 +140,25 @@ export declare type AppState = {
78
140
  isBindingEnabled: boolean;
79
141
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
80
142
  suggestedBindings: SuggestedBinding[];
143
+ frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
144
+ frameRendering: {
145
+ enabled: boolean;
146
+ name: boolean;
147
+ outline: boolean;
148
+ clip: boolean;
149
+ };
150
+ editingFrame: string | null;
151
+ elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
81
152
  editingElement: NonDeletedExcalidrawElement | null;
82
153
  editingLinearElement: LinearElementEditor | null;
83
154
  activeTool: {
84
- type: typeof SHAPES[number]["value"] | "eraser";
85
- lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
155
+ /**
156
+ * indicates a previous tool we should revert back to if we deselect the
157
+ * currently active tool. At the moment applies to `eraser` and `hand` tool.
158
+ */
159
+ lastActiveTool: ActiveTool | null;
86
160
  locked: boolean;
87
- customType: null;
88
- } | {
89
- type: "custom";
90
- customType: string;
91
- lastActiveToolBeforeEraser: LastActiveToolBeforeEraser;
92
- locked: boolean;
93
- };
161
+ } & ActiveTool;
94
162
  penMode: boolean;
95
163
  penDetected: boolean;
96
164
  exportBackground: boolean;
@@ -120,17 +188,28 @@ export declare type AppState = {
120
188
  isRotating: boolean;
121
189
  zoom: Zoom;
122
190
  openMenu: "canvas" | "shape" | null;
123
- openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
124
- openSidebar: "library" | "customSidebar" | null;
191
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
192
+ openSidebar: {
193
+ name: SidebarName;
194
+ tab?: SidebarTabName;
195
+ } | null;
125
196
  openDialog: "imageExport" | "help" | "jsonExport" | null;
126
- isSidebarDocked: boolean;
197
+ /**
198
+ * Reflects user preference for whether the default sidebar should be docked.
199
+ *
200
+ * NOTE this is only a user preference and does not reflect the actual docked
201
+ * state of the sidebar, because the host apps can override this through
202
+ * a DefaultSidebar prop, which is not reflected back to the appState.
203
+ */
204
+ defaultSidebarDockedPreference: boolean;
127
205
  lastPointerDownWith: PointerType;
128
- selectedElementIds: {
129
- [id: string]: boolean;
130
- };
206
+ selectedElementIds: Readonly<{
207
+ [id: string]: true;
208
+ }>;
131
209
  previousSelectedElementIds: {
132
- [id: string]: boolean;
210
+ [id: string]: true;
133
211
  };
212
+ selectedElementsAreBeingDragged: boolean;
134
213
  shouldCacheIgnoreZoom: boolean;
135
214
  toast: {
136
215
  message: string;
@@ -167,18 +246,25 @@ export declare type AppState = {
167
246
  pendingImageElementId: ExcalidrawImageElement["id"] | null;
168
247
  showHyperlinkPopup: false | "info" | "editor";
169
248
  selectedLinearElement: LinearElementEditor | null;
249
+ snapLines: readonly SnapLine[];
250
+ originSnapOffset: {
251
+ x: number;
252
+ y: number;
253
+ } | null;
254
+ objectsSnapModeEnabled: boolean;
170
255
  };
171
- export declare type NormalizedZoomValue = number & {
256
+ export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
257
+ export type NormalizedZoomValue = number & {
172
258
  _brand: "normalizedZoom";
173
259
  };
174
- export declare type Zoom = Readonly<{
260
+ export type Zoom = Readonly<{
175
261
  value: NormalizedZoomValue;
176
262
  }>;
177
- export declare type PointerCoords = Readonly<{
263
+ export type PointerCoords = Readonly<{
178
264
  x: number;
179
265
  y: number;
180
266
  }>;
181
- export declare type Gesture = {
267
+ export type Gesture = {
182
268
  pointers: Map<number, PointerCoords>;
183
269
  lastCenter: {
184
270
  x: number;
@@ -192,11 +278,11 @@ export declare class GestureEvent extends UIEvent {
192
278
  readonly scale: number;
193
279
  }
194
280
  /** @deprecated legacy: do not use outside of migration paths */
195
- export declare type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
281
+ export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[];
196
282
  /** @deprecated legacy: do not use outside of migration paths */
197
- declare type LibraryItems_v1 = readonly LibraryItem_v1[];
283
+ type LibraryItems_v1 = readonly LibraryItem_v1[];
198
284
  /** v2 library item */
199
- export declare type LibraryItem = {
285
+ export type LibraryItem = {
200
286
  id: string;
201
287
  status: "published" | "unpublished";
202
288
  elements: readonly NonDeleted<ExcalidrawElement>[];
@@ -205,14 +291,14 @@ export declare type LibraryItem = {
205
291
  name?: string;
206
292
  error?: string;
207
293
  };
208
- export declare type LibraryItems = readonly LibraryItem[];
209
- export declare type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
210
- export declare type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
211
- export declare type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
294
+ export type LibraryItems = readonly LibraryItem[];
295
+ export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1;
296
+ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>;
297
+ export type ExcalidrawAPIRefValue = ExcalidrawImperativeAPI | {
212
298
  readyPromise?: ResolvablePromise<ExcalidrawImperativeAPI>;
213
299
  ready?: false;
214
300
  };
215
- export declare type ExcalidrawInitialDataState = Merge<ImportedDataState, {
301
+ export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
216
302
  scrollX?: number;
217
303
  scrollY?: number;
218
304
  libraryItems?: Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>;
@@ -231,20 +317,22 @@ export interface ExcalidrawProps {
231
317
  pointer: {
232
318
  x: number;
233
319
  y: number;
320
+ tool: "pointer" | "laser";
234
321
  };
235
322
  button: "down" | "up";
236
323
  pointersMap: Gesture["pointers"];
237
324
  }) => void;
238
325
  onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
239
- renderTopRightUI?: (isMobile: boolean, appState: AppState) => JSX.Element | null;
326
+ renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
240
327
  langCode?: Language["code"];
241
328
  viewModeEnabled?: boolean;
242
329
  zenModeEnabled?: boolean;
243
330
  gridModeEnabled?: boolean;
331
+ objectsSnapModeEnabled?: boolean;
244
332
  libraryReturnUrl?: string;
245
333
  theme?: Theme;
246
334
  name?: string;
247
- renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => JSX.Element;
335
+ renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
248
336
  UIOptions?: Partial<UIOptions>;
249
337
  detectScroll?: boolean;
250
338
  handleKeyboardGlobally?: boolean;
@@ -256,13 +344,19 @@ export interface ExcalidrawProps {
256
344
  }>) => void;
257
345
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
258
346
  onScrollChange?: (scrollX: number, scrollY: number) => void;
259
- /**
260
- * Render function that renders custom <Sidebar /> component.
261
- */
262
- renderSidebar?: () => JSX.Element | null;
263
347
  children?: React.ReactNode;
348
+ validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
349
+ renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
350
+ interactive?: boolean;
351
+ ui?: boolean;
352
+ activeTool?: {
353
+ type: ToolType;
354
+ } | {
355
+ type: "custom";
356
+ customType: string;
357
+ };
264
358
  }
265
- export declare type SceneData = {
359
+ export type SceneData = {
266
360
  elements?: ImportedDataState["elements"];
267
361
  appState?: ImportedDataState["appState"];
268
362
  collaborators?: Map<string, Collaborator>;
@@ -273,12 +367,12 @@ export declare enum UserIdleState {
273
367
  AWAY = "away",
274
368
  IDLE = "idle"
275
369
  }
276
- export declare type ExportOpts = {
370
+ export type ExportOpts = {
277
371
  saveFileToDisk?: boolean;
278
- onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
279
- renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
372
+ onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => void;
373
+ renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
280
374
  };
281
- declare type CanvasActions = Partial<{
375
+ type CanvasActions = Partial<{
282
376
  changeViewBackgroundColor: boolean;
283
377
  clearCanvas: boolean;
284
378
  export: false | ExportOpts;
@@ -287,13 +381,14 @@ declare type CanvasActions = Partial<{
287
381
  toggleTheme: boolean | null;
288
382
  saveAsImage: boolean;
289
383
  }>;
290
- declare type UIOptions = Partial<{
384
+ type UIOptions = Partial<{
291
385
  dockedSidebarBreakpoint: number;
292
- welcomeScreen: boolean;
293
386
  canvasActions: CanvasActions;
387
+ /** @deprecated does nothing. Will be removed in 0.15 */
388
+ welcomeScreen?: boolean;
294
389
  }>;
295
- export declare type AppProps = Merge<ExcalidrawProps, {
296
- UIOptions: Merge<MarkRequired<UIOptions, "welcomeScreen">, {
390
+ export type AppProps = Merge<ExcalidrawProps, {
391
+ UIOptions: Merge<UIOptions, {
297
392
  canvasActions: Required<CanvasActions> & {
298
393
  export: ExportOpts;
299
394
  };
@@ -305,21 +400,29 @@ export declare type AppProps = Merge<ExcalidrawProps, {
305
400
  }>;
306
401
  /** A subset of App class properties that we need to use elsewhere
307
402
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
308
- export declare type AppClassProperties = {
403
+ export type AppClassProperties = {
309
404
  props: AppProps;
310
- canvas: HTMLCanvasElement | null;
405
+ interactiveCanvas: HTMLCanvasElement | null;
406
+ /** static canvas */
407
+ canvas: HTMLCanvasElement;
311
408
  focusContainer(): void;
312
409
  library: Library;
313
410
  imageCache: Map<FileId, {
314
411
  image: HTMLImageElement | Promise<HTMLImageElement>;
315
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
412
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
316
413
  }>;
317
414
  files: BinaryFiles;
318
415
  device: App["device"];
319
416
  scene: App["scene"];
320
417
  pasteFromClipboard: App["pasteFromClipboard"];
418
+ id: App["id"];
419
+ onInsertElements: App["onInsertElements"];
420
+ onExportImage: App["onExportImage"];
421
+ lastViewportPosition: App["lastViewportPosition"];
422
+ togglePenMode: App["togglePenMode"];
423
+ setActiveTool: App["setActiveTool"];
321
424
  };
322
- export declare type PointerDownState = Readonly<{
425
+ export type PointerDownState = Readonly<{
323
426
  origin: Readonly<{
324
427
  x: number;
325
428
  y: number;
@@ -378,8 +481,8 @@ export declare type PointerDownState = Readonly<{
378
481
  };
379
482
  };
380
483
  }>;
381
- declare type UnsubscribeCallback = () => void;
382
- export declare type ExcalidrawImperativeAPI = {
484
+ type UnsubscribeCallback = () => void;
485
+ export type ExcalidrawImperativeAPI = {
383
486
  updateScene: InstanceType<typeof App>["updateScene"];
384
487
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
385
488
  resetScene: InstanceType<typeof App>["resetScene"];
@@ -400,31 +503,44 @@ export declare type ExcalidrawImperativeAPI = {
400
503
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
401
504
  setCursor: InstanceType<typeof App>["setCursor"];
402
505
  resetCursor: InstanceType<typeof App>["resetCursor"];
403
- toggleMenu: InstanceType<typeof App>["toggleMenu"];
506
+ toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
507
+ /**
508
+ * Disables rendering of frames (including element clipping), but currently
509
+ * the frames are still interactive in edit mode. As such, this API should be
510
+ * used in conjunction with view mode (props.viewModeEnabled).
511
+ */
512
+ updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
404
513
  app: InstanceType<typeof App>;
405
514
  onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
406
- onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLCanvasElement>) => void) => UnsubscribeCallback;
515
+ onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
407
516
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
408
517
  };
409
- export declare type Device = Readonly<{
518
+ export type Device = Readonly<{
410
519
  isSmScreen: boolean;
411
520
  isMobile: boolean;
412
521
  isTouchScreen: boolean;
413
522
  canDeviceFitSidebar: boolean;
523
+ isLandscape: boolean;
414
524
  }>;
415
- export declare type UIChildrenComponents = {
416
- [k in "FooterCenter" | "Menu" | "WelcomeScreen"]?: React.ReactElement<{
417
- children?: React.ReactNode;
418
- }, React.JSXElementConstructor<any>>;
525
+ type FrameNameBounds = {
526
+ x: number;
527
+ y: number;
528
+ width: number;
529
+ height: number;
530
+ angle: number;
419
531
  };
420
- export declare type UIWelcomeScreenComponents = {
421
- [k in "Center" | "MenuHint" | "ToolbarHint" | "HelpHint"]?: React.ReactElement<{
422
- children?: React.ReactNode;
423
- }, React.JSXElementConstructor<any>>;
532
+ export type FrameNameBoundsCache = {
533
+ get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
534
+ _cache: Map<string, FrameNameBounds & {
535
+ zoom: AppState["zoom"]["value"];
536
+ versionNonce: ExcalidrawFrameElement["versionNonce"];
537
+ }>;
424
538
  };
425
- export declare type UIWelcomeScreenCenterComponents = {
426
- [k in "Logo" | "Heading" | "Menu" | "MenuItemLoadScene" | "MenuItemHelp"]?: React.ReactElement<{
427
- children?: React.ReactNode;
428
- }, React.JSXElementConstructor<any>>;
539
+ export type KeyboardModifiersObject = {
540
+ ctrlKey: boolean;
541
+ shiftKey: boolean;
542
+ altKey: boolean;
543
+ metaKey: boolean;
429
544
  };
545
+ export type Primitive = number | string | boolean | bigint | symbol | null | undefined;
430
546
  export {};
@@ -0,0 +1,24 @@
1
+ export type Mutable<T> = {
2
+ -readonly [P in keyof T]: T[P];
3
+ };
4
+ export type ValueOf<T> = T[keyof T];
5
+ export type Merge<M, N> = Omit<M, keyof N> & N;
6
+ /** utility type to assert that the second type is a subtype of the first type.
7
+ * Returns the subtype. */
8
+ export type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
9
+ export type ResolutionType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : any;
10
+ export type MarkOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
11
+ export type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>;
12
+ export type MarkNonNullable<T, K extends keyof T> = {
13
+ [P in K]-?: P extends K ? NonNullable<T[P]> : T[P];
14
+ } & {
15
+ [P in keyof T]: T[P];
16
+ };
17
+ export type NonOptional<T> = Exclude<T, undefined>;
18
+ export type SignatureType<T> = T extends (...args: infer R) => any ? R : never;
19
+ export type CallableType<T extends (...args: any[]) => any> = (...args: SignatureType<T>) => ReturnType<T>;
20
+ export type ForwardRef<T, P = any> = Parameters<CallableType<React.ForwardRefRenderFunction<T, P>>>[1];
21
+ export type ExtractSetType<T extends Set<any>> = T extends Set<infer U> ? U : never;
22
+ export type SameType<T, U> = T extends U ? (U extends T ? true : false) : false;
23
+ export type Assert<T extends true> = T;
24
+ export type NestedKeyOf<T, K = keyof T> = K extends keyof T & (string | number) ? `${K}` | (T[K] extends object ? `${K}.${NestedKeyOf<T[K]>}` : never) : never;
package/types/utils.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import { EVENT } from "./constants";
2
- import { FontFamilyValues, FontString } from "./element/types";
3
- import { AppState, LastActiveToolBeforeEraser, Zoom } from "./types";
4
- import { SHAPES } from "./shapes";
5
- import React from "react";
2
+ import { FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./element/types";
3
+ import { ActiveTool, AppState, ToolType, Zoom } from "./types";
6
4
  export declare const setDateTimeForTests: (dateTime: string) => void;
7
5
  export declare const getDateTime: () => string;
8
6
  export declare const capitalizeString: (str: string) => string;
9
7
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
10
- export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
11
- export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLTextAreaElement;
8
+ export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
9
+ export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
10
+ export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
12
11
  export declare const getFontFamilyString: ({ fontFamily, }: {
13
12
  fontFamily: FontFamilyValues;
14
13
  }) => string;
@@ -29,22 +28,67 @@ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, op
29
28
  flush(): void;
30
29
  cancel(): void;
31
30
  };
31
+ /**
32
+ * Exponential ease-out method
33
+ *
34
+ * @param {number} k - The value to be tweened.
35
+ * @returns {number} The tweened value.
36
+ */
37
+ export declare const easeOut: (k: number) => number;
38
+ /**
39
+ * Animates values from `fromValues` to `toValues` using the requestAnimationFrame API.
40
+ * Executes the `onStep` callback on each step with the interpolated values.
41
+ * Returns a function that can be called to cancel the animation.
42
+ *
43
+ * @example
44
+ * // Example usage:
45
+ * const fromValues = { x: 0, y: 0 };
46
+ * const toValues = { x: 100, y: 200 };
47
+ * const onStep = ({x, y}) => {
48
+ * setState(x, y)
49
+ * };
50
+ * const onCancel = () => {
51
+ * console.log("Animation canceled");
52
+ * };
53
+ *
54
+ * const cancelAnimation = easeToValuesRAF({
55
+ * fromValues,
56
+ * toValues,
57
+ * onStep,
58
+ * onCancel,
59
+ * });
60
+ *
61
+ * // To cancel the animation:
62
+ * cancelAnimation();
63
+ */
64
+ export declare const easeToValuesRAF: <T extends Record<keyof T, number>, K extends keyof T>({ fromValues, toValues, onStep, duration, interpolateValue, onStart, onEnd, onCancel, }: {
65
+ fromValues: T;
66
+ toValues: T;
67
+ /**
68
+ * Interpolate a single value.
69
+ * Return undefined to be handled by the default interpolator.
70
+ */
71
+ interpolateValue?: ((fromValue: number, toValue: number, progress: number, key: K) => number | undefined) | undefined;
72
+ onStep: (values: T) => void;
73
+ duration?: number | undefined;
74
+ onStart?: (() => void) | undefined;
75
+ onEnd?: (() => void) | undefined;
76
+ onCancel?: (() => void) | undefined;
77
+ }) => () => void;
32
78
  export declare const chunk: <T extends unknown>(array: readonly T[], size: number) => T[][];
33
79
  export declare const selectNode: (node: Element) => void;
34
80
  export declare const removeSelection: () => void;
35
81
  export declare const distance: (x: number, y: number) => number;
36
- export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
37
- type: (typeof SHAPES)[number]["value"] | "eraser";
82
+ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: (({
83
+ type: ToolType;
38
84
  } | {
39
85
  type: "custom";
40
86
  customType: string;
41
87
  }) & {
42
- lastActiveToolBeforeEraser?: LastActiveToolBeforeEraser;
88
+ locked?: boolean;
89
+ }) & {
90
+ lastActiveToolBeforeEraser?: ActiveTool | null;
43
91
  }) => AppState["activeTool"];
44
- export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
45
- export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
46
- export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
47
- export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
48
92
  export declare const isFullScreen: () => boolean;
49
93
  export declare const allowFullScreen: () => Promise<void>;
50
94
  export declare const exitFullScreen: () => Promise<void>;
@@ -92,7 +136,7 @@ export declare const muteFSAbortError: (error?: Error) => void;
92
136
  export declare const findIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
93
137
  export declare const findLastIndex: <T>(array: readonly T[], cb: (element: T, index: number, array: readonly T[]) => boolean, fromIndex?: number) => number;
94
138
  export declare const isTransparent: (color: string) => boolean;
95
- export declare type ResolvablePromise<T> = Promise<T> & {
139
+ export type ResolvablePromise<T> = Promise<T> & {
96
140
  resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
97
141
  reject: (error: Error) => void;
98
142
  };
@@ -125,29 +169,29 @@ export declare const getUpdatedTimestamp: () => number;
125
169
  export declare const arrayToMap: <T extends string | {
126
170
  id: string;
127
171
  }>(items: readonly T[]) => Map<string, T>;
172
+ export declare const arrayToMapWithIndex: <T extends {
173
+ id: string;
174
+ }>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
128
175
  export declare const isTestEnv: () => boolean;
129
- export declare const isProdEnv: () => boolean;
130
176
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
131
177
  nativeEvent: T;
132
178
  }>;
133
179
  export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
134
180
  export declare const isPrimitive: (val: any) => boolean;
135
181
  export declare const getFrame: () => "top" | "iframe";
182
+ export declare const isRunningInIframe: () => boolean;
136
183
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
137
184
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
185
+ export declare const isShallowEqual: <T extends Record<string, any>, I extends keyof T>(objA: T, objB: T, comparators?: Record<I, (a: T[I], b: T[I]) => boolean> | undefined, debug?: boolean) => boolean;
186
+ export declare const composeEventHandlers: <E>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
187
+ checkForDefaultPrevented?: boolean | undefined;
188
+ }) => (event: E) => void;
189
+ export declare const isOnlyExportingSingleFrame: (elements: readonly NonDeletedExcalidrawElement[]) => boolean;
190
+ export declare const assertNever: (value: never, message: string, softAssert?: boolean) => never;
138
191
  /**
139
- * Partitions React children into named components and the rest of children.
140
- *
141
- * Returns known children as a dictionary of react children keyed by their
142
- * displayName, and the rest children as an array.
143
- *
144
- * NOTE all named react components are included in the dictionary, irrespective
145
- * of the supplied type parameter. This means you may be throwing away
146
- * children that you aren't expecting, but should nonetheless be rendered.
147
- * To guard against this (provided you care about the rest children at all),
148
- * supply a second parameter with an object with keys of the expected children.
192
+ * Memoizes on values of `opts` object (strict equality).
149
193
  */
150
- export declare const getReactChildren: <KnownChildren extends {
151
- [x: string]: React.ReactNode;
152
- }>(children: React.ReactNode, expectedComponents?: Record<keyof KnownChildren, any> | undefined) => readonly [Partial<KnownChildren>, React.ReactNode[]];
153
- export declare const isShallowEqual: <T extends Record<string, any>>(objA: T, objB: T) => boolean;
194
+ export declare const memoize: <T extends Record<string, any>, R extends unknown>(func: (opts: T) => R) => ((opts: T) => R) & {
195
+ clear: () => void;
196
+ };
197
+ export declare const isRenderThrottlingEnabled: () => boolean;
package/types/zindex.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ExcalidrawElement } from "./element/types";
2
2
  import { AppState } from "./types";
3
- export declare const moveOneLeft: (elements: readonly ExcalidrawElement[], appState: AppState) => (import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawFreeDrawElement)[];
4
- export declare const moveOneRight: (elements: readonly ExcalidrawElement[], appState: AppState) => (import("./element/types").ExcalidrawLinearElement | import("./element/types").ExcalidrawSelectionElement | import("./element/types").ExcalidrawRectangleElement | import("./element/types").ExcalidrawDiamondElement | import("./element/types").ExcalidrawEllipseElement | import("./element/types").ExcalidrawImageElement | import("./element/types").ExcalidrawTextElement | import("./element/types").ExcalidrawFreeDrawElement)[];
5
- export declare const moveAllLeft: (elements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
6
- export declare const moveAllRight: (elements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
3
+ export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
4
+ export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
5
+ export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
6
+ export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];