@zsviczian/excalidraw 0.17.1-obsidian-20 → 0.17.1-obsidian-22

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 (197) hide show
  1. package/dist/excalidraw.development.js +217 -96
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/styles.development.css +88 -63
  4. package/dist/styles.production.css +6 -6
  5. package/package.json +2 -1
  6. package/types/excalidraw/actions/actionAddToLibrary.d.ts +4 -4
  7. package/types/excalidraw/actions/actionAlign.d.ts +22 -22
  8. package/types/excalidraw/actions/actionBoundText.d.ts +10 -10
  9. package/types/excalidraw/actions/actionCanvas.d.ts +68 -68
  10. package/types/excalidraw/actions/actionClipboard.d.ts +24 -24
  11. package/types/excalidraw/actions/actionDeleteSelected.d.ts +10 -10
  12. package/types/excalidraw/actions/actionDistribute.d.ts +10 -10
  13. package/types/excalidraw/actions/actionDuplicateSelection.d.ts +7 -8
  14. package/types/excalidraw/actions/actionElementLock.d.ts +9 -9
  15. package/types/excalidraw/actions/actionExport.d.ts +33 -33
  16. package/types/excalidraw/actions/actionFinalize.d.ts +9 -9
  17. package/types/excalidraw/actions/actionFlip.d.ts +10 -10
  18. package/types/excalidraw/actions/actionFrame.d.ts +16 -204
  19. package/types/excalidraw/actions/actionGroup.d.ts +12 -388
  20. package/types/excalidraw/actions/actionHistory.d.ts +4 -3
  21. package/types/excalidraw/actions/actionLinearEditor.d.ts +6 -4
  22. package/types/excalidraw/actions/actionLink.d.ts +5 -5
  23. package/types/excalidraw/actions/actionMenu.d.ts +8 -8
  24. package/types/excalidraw/actions/actionNavigate.d.ts +4 -4
  25. package/types/excalidraw/actions/actionProperties.d.ts +34 -34
  26. package/types/excalidraw/actions/actionSelectAll.d.ts +5 -5
  27. package/types/excalidraw/actions/actionStyles.d.ts +9 -12
  28. package/types/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
  29. package/types/excalidraw/actions/actionToggleGridMode.d.ts +7 -5
  30. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
  31. package/types/excalidraw/actions/actionToggleStats.d.ts +4 -4
  32. package/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
  33. package/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
  34. package/types/excalidraw/actions/actionZindex.d.ts +22 -19
  35. package/types/excalidraw/actions/manager.d.ts +5 -5
  36. package/types/excalidraw/actions/register.d.ts +1 -1
  37. package/types/excalidraw/actions/shortcuts.d.ts +2 -2
  38. package/types/excalidraw/actions/types.d.ts +8 -8
  39. package/types/excalidraw/align.d.ts +1 -1
  40. package/types/excalidraw/animated-trail.d.ts +2 -2
  41. package/types/excalidraw/appState.d.ts +5 -5
  42. package/types/excalidraw/change.d.ts +191 -0
  43. package/types/excalidraw/charts.d.ts +1 -1
  44. package/types/excalidraw/clients.d.ts +2 -2
  45. package/types/excalidraw/clipboard.d.ts +3 -3
  46. package/types/excalidraw/colors.d.ts +1 -1
  47. package/types/excalidraw/components/Actions.d.ts +3 -3
  48. package/types/excalidraw/components/App.d.ts +28 -14
  49. package/types/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -1
  50. package/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +4 -4
  51. package/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
  52. package/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -1
  53. package/types/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
  54. package/types/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -1
  55. package/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  56. package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
  57. package/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
  58. package/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
  59. package/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -1
  60. package/types/excalidraw/components/CommandPalette/types.d.ts +3 -3
  61. package/types/excalidraw/components/ConfirmDialog.d.ts +1 -1
  62. package/types/excalidraw/components/ContextMenu.d.ts +2 -2
  63. package/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  64. package/types/excalidraw/components/DefaultSidebar.d.ts +2 -2
  65. package/types/excalidraw/components/DialogActionButton.d.ts +1 -1
  66. package/types/excalidraw/components/EyeDropper.d.ts +2 -2
  67. package/types/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
  68. package/types/excalidraw/components/HintViewer.d.ts +1 -1
  69. package/types/excalidraw/components/ImageExportDialog.d.ts +1 -1
  70. package/types/excalidraw/components/InitializeApp.d.ts +2 -2
  71. package/types/excalidraw/components/JSONExportDialog.d.ts +3 -3
  72. package/types/excalidraw/components/LayerUI.d.ts +4 -4
  73. package/types/excalidraw/components/LibraryMenu.d.ts +2 -2
  74. package/types/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -1
  75. package/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
  76. package/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +2 -2
  77. package/types/excalidraw/components/LibraryMenuItems.d.ts +1 -1
  78. package/types/excalidraw/components/LibraryMenuSection.d.ts +5 -4
  79. package/types/excalidraw/components/LibraryUnit.d.ts +2 -2
  80. package/types/excalidraw/components/LoadingMessage.d.ts +1 -1
  81. package/types/excalidraw/components/MobileMenu.d.ts +3 -3
  82. package/types/excalidraw/components/Modal.d.ts +1 -1
  83. package/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  84. package/types/excalidraw/components/PasteChartDialog.d.ts +1 -1
  85. package/types/excalidraw/components/PublishLibrary.d.ts +1 -1
  86. package/types/excalidraw/components/RadioGroup.d.ts +2 -1
  87. package/types/excalidraw/components/SVGLayer.d.ts +1 -1
  88. package/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
  89. package/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
  90. package/types/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
  91. package/types/excalidraw/components/Sidebar/common.d.ts +1 -1
  92. package/types/excalidraw/components/Stats.d.ts +2 -2
  93. package/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -2
  94. package/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
  95. package/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
  96. package/types/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
  97. package/types/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
  98. package/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
  99. package/types/excalidraw/components/TTDDialog/common.d.ts +4 -4
  100. package/types/excalidraw/components/TextField.d.ts +1 -1
  101. package/types/excalidraw/components/Toast.d.ts +1 -1
  102. package/types/excalidraw/components/ToolButton.d.ts +4 -2
  103. package/types/excalidraw/components/Trans.d.ts +1 -1
  104. package/types/excalidraw/components/UserList.d.ts +1 -1
  105. package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  106. package/types/excalidraw/components/canvases/StaticCanvas.d.ts +2 -2
  107. package/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +17 -0
  108. package/types/excalidraw/components/footer/Footer.d.ts +2 -2
  109. package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +2 -2
  110. package/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
  111. package/types/excalidraw/components/icons.d.ts +6 -1
  112. package/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -2
  113. package/types/excalidraw/constants.d.ts +5 -2
  114. package/types/excalidraw/context/ui-appState.d.ts +1 -1
  115. package/types/excalidraw/cursor.d.ts +1 -1
  116. package/types/excalidraw/data/EditorLocalStorage.d.ts +2 -2
  117. package/types/excalidraw/data/blob.d.ts +5 -5
  118. package/types/excalidraw/data/filesystem.d.ts +2 -1
  119. package/types/excalidraw/data/index.d.ts +4 -4
  120. package/types/excalidraw/data/json.d.ts +3 -3
  121. package/types/excalidraw/data/library.d.ts +3 -3
  122. package/types/excalidraw/data/magic.d.ts +3 -3
  123. package/types/excalidraw/data/reconcile.d.ts +6 -0
  124. package/types/excalidraw/data/resave.d.ts +2 -2
  125. package/types/excalidraw/data/restore.d.ts +5 -5
  126. package/types/excalidraw/data/transform.d.ts +4 -4
  127. package/types/excalidraw/data/types.d.ts +3 -3
  128. package/types/excalidraw/data/url.d.ts +1 -0
  129. package/types/excalidraw/element/ElementCanvasButtons.d.ts +1 -1
  130. package/types/excalidraw/element/binding.d.ts +52 -9
  131. package/types/excalidraw/element/bounds.d.ts +3 -4
  132. package/types/excalidraw/element/collision.d.ts +14 -19
  133. package/types/excalidraw/element/containerCache.d.ts +1 -1
  134. package/types/excalidraw/element/dragElements.d.ts +3 -3
  135. package/types/excalidraw/element/embeddable.d.ts +9 -6
  136. package/types/excalidraw/element/image.d.ts +2 -2
  137. package/types/excalidraw/element/index.d.ts +2 -3
  138. package/types/excalidraw/element/linearElementEditor.d.ts +12 -12
  139. package/types/excalidraw/element/mutateElement.d.ts +4 -5
  140. package/types/excalidraw/element/newElement.d.ts +4 -11
  141. package/types/excalidraw/element/resizeElements.d.ts +4 -4
  142. package/types/excalidraw/element/resizeTest.d.ts +7 -7
  143. package/types/excalidraw/element/showSelectedShapeActions.d.ts +2 -2
  144. package/types/excalidraw/element/sizeHelpers.d.ts +2 -2
  145. package/types/excalidraw/element/sortElements.d.ts +1 -1
  146. package/types/excalidraw/element/textElement.d.ts +5 -6
  147. package/types/excalidraw/element/textWysiwyg.d.ts +10 -5
  148. package/types/excalidraw/element/transformHandles.d.ts +24 -6
  149. package/types/excalidraw/element/typeChecks.d.ts +4 -4
  150. package/types/excalidraw/element/types.d.ts +33 -10
  151. package/types/excalidraw/emitter.d.ts +1 -1
  152. package/types/excalidraw/errors.d.ts +3 -0
  153. package/types/excalidraw/fractionalIndex.d.ts +40 -0
  154. package/types/excalidraw/frame.d.ts +4 -4
  155. package/types/excalidraw/gatransforms.d.ts +1 -1
  156. package/types/excalidraw/gesture.d.ts +1 -1
  157. package/types/excalidraw/groups.d.ts +5 -3
  158. package/types/excalidraw/history.d.ts +35 -47
  159. package/types/excalidraw/hooks/useEmitter.d.ts +2 -0
  160. package/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  161. package/types/excalidraw/i18n.d.ts +1 -1
  162. package/types/excalidraw/index.d.ts +5 -1
  163. package/types/excalidraw/jotai.d.ts +1 -1
  164. package/types/excalidraw/laser-trails.d.ts +3 -2
  165. package/types/excalidraw/math.d.ts +2 -2
  166. package/types/excalidraw/points.d.ts +1 -1
  167. package/types/excalidraw/queue.d.ts +1 -1
  168. package/types/excalidraw/renderer/helpers.d.ts +2 -2
  169. package/types/excalidraw/renderer/interactiveScene.d.ts +2 -2
  170. package/types/excalidraw/renderer/renderElement.d.ts +3 -3
  171. package/types/excalidraw/renderer/renderSnaps.d.ts +1 -1
  172. package/types/excalidraw/renderer/staticScene.d.ts +1 -1
  173. package/types/excalidraw/renderer/staticSvgScene.d.ts +4 -4
  174. package/types/excalidraw/scene/Fonts.d.ts +2 -4
  175. package/types/excalidraw/scene/Renderer.d.ts +4 -4
  176. package/types/excalidraw/scene/Scene.d.ts +19 -12
  177. package/types/excalidraw/scene/Shape.d.ts +1 -1
  178. package/types/excalidraw/scene/ShapeCache.d.ts +4 -4
  179. package/types/excalidraw/scene/comparisons.d.ts +2 -2
  180. package/types/excalidraw/scene/export.d.ts +2 -2
  181. package/types/excalidraw/scene/scroll.d.ts +2 -2
  182. package/types/excalidraw/scene/scrollbars.d.ts +3 -3
  183. package/types/excalidraw/scene/selection.d.ts +2 -2
  184. package/types/excalidraw/scene/types.d.ts +5 -4
  185. package/types/excalidraw/scene/zoom.d.ts +1 -1
  186. package/types/excalidraw/snapping.d.ts +4 -4
  187. package/types/excalidraw/store.d.ts +99 -0
  188. package/types/excalidraw/types.d.ts +38 -20
  189. package/types/excalidraw/utils.d.ts +11 -4
  190. package/types/excalidraw/webpack.prod.config.d.ts +1 -1
  191. package/types/excalidraw/zindex.d.ts +4 -4
  192. package/types/utils/bbox.d.ts +2 -2
  193. package/types/utils/collision.d.ts +4 -0
  194. package/types/utils/export.d.ts +4 -4
  195. package/types/utils/geometry/geometry.d.ts +71 -0
  196. package/types/utils/geometry/shape.d.ts +56 -0
  197. package/types/utils/withinBounds.d.ts +1 -1
@@ -1,8 +1,8 @@
1
1
  import type { RoughCanvas } from "roughjs/bin/canvas";
2
- import { Drawable } from "roughjs/bin/core";
3
- import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "../element/types";
4
- import { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, UserIdleState } from "../types";
5
- import { MakeBrand } from "../utility-types";
2
+ import type { Drawable } from "roughjs/bin/core";
3
+ import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "../element/types";
4
+ import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, UserIdleState, Device } from "../types";
5
+ import type { MakeBrand } from "../utility-types";
6
6
  export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
7
7
  export type StaticCanvasRenderConfig = {
8
8
  canvasBackgroundColor: AppState["viewBackgroundColor"];
@@ -60,6 +60,7 @@ export type InteractiveSceneRenderConfig = {
60
60
  scale: number;
61
61
  appState: InteractiveCanvasAppState;
62
62
  renderConfig: InteractiveCanvasRenderConfig;
63
+ device: Device;
63
64
  callback: (data: RenderInteractiveSceneCallback) => void;
64
65
  };
65
66
  export type SceneScroll = {
@@ -1,4 +1,4 @@
1
- import { AppState, NormalizedZoomValue } from "../types";
1
+ import type { AppState, NormalizedZoomValue } from "../types";
2
2
  export declare const getNormalizedZoom: (zoom: number) => NormalizedZoomValue;
3
3
  export declare const getStateForZoom: ({ viewportX, viewportY, nextZoom, }: {
4
4
  viewportX: number;
@@ -1,7 +1,7 @@
1
- import { Bounds } from "./element/bounds";
2
- import { MaybeTransformHandleType } from "./element/transformHandles";
3
- import { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
4
- import { AppState, KeyboardModifiersObject, Point } from "./types";
1
+ import type { Bounds } from "./element/bounds";
2
+ import type { MaybeTransformHandleType } from "./element/transformHandles";
3
+ import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
4
+ import type { AppState, KeyboardModifiersObject, Point } from "./types";
5
5
  export declare const getSnapDistance: (zoomValue: number) => number;
6
6
  type Vector2D = {
7
7
  x: number;
@@ -0,0 +1,99 @@
1
+ import { AppStateChange, ElementsChange } from "./change";
2
+ import type { OrderedExcalidrawElement } from "./element/types";
3
+ import { Emitter } from "./emitter";
4
+ import type { AppState, ObservedAppState } from "./types";
5
+ export declare const getObservedAppState: (appState: AppState) => ObservedAppState;
6
+ export type StoreActionType = "capture" | "update" | "none";
7
+ export declare const StoreAction: {
8
+ [K in Uppercase<StoreActionType>]: StoreActionType;
9
+ };
10
+ /**
11
+ * Represent an increment to the Store.
12
+ */
13
+ declare class StoreIncrementEvent {
14
+ readonly elementsChange: ElementsChange;
15
+ readonly appStateChange: AppStateChange;
16
+ constructor(elementsChange: ElementsChange, appStateChange: AppStateChange);
17
+ }
18
+ /**
19
+ * Store which captures the observed changes and emits them as `StoreIncrementEvent` events.
20
+ *
21
+ * @experimental this interface is experimental and subject to change.
22
+ */
23
+ export interface IStore {
24
+ onStoreIncrementEmitter: Emitter<[StoreIncrementEvent]>;
25
+ get snapshot(): Snapshot;
26
+ set snapshot(snapshot: Snapshot);
27
+ /**
28
+ * Use to schedule update of the snapshot, useful on updates for which we don't need to calculate increments (i.e. remote updates).
29
+ */
30
+ shouldUpdateSnapshot(): void;
31
+ /**
32
+ * Use to schedule calculation of a store increment.
33
+ */
34
+ shouldCaptureIncrement(): void;
35
+ /**
36
+ * Based on the scheduled operation, either only updates store snapshot or also calculates increment and emits the result as a `StoreIncrementEvent`.
37
+ *
38
+ * @emits StoreIncrementEvent when increment is calculated.
39
+ */
40
+ commit(elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined): void;
41
+ /**
42
+ * Clears the store instance.
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * Filters out yet uncomitted elements from `nextElements`, which are part of in-progress local async actions (ephemerals) and thus were not yet commited to the snapshot.
47
+ *
48
+ * This is necessary in updates in which we receive reconciled elements, already containing elements which were not yet captured by the local store (i.e. collab).
49
+ */
50
+ filterUncomittedElements(prevElements: Map<string, OrderedExcalidrawElement>, nextElements: Map<string, OrderedExcalidrawElement>): Map<string, OrderedExcalidrawElement>;
51
+ }
52
+ export declare class Store implements IStore {
53
+ readonly onStoreIncrementEmitter: Emitter<[StoreIncrementEvent]>;
54
+ private scheduledActions;
55
+ private _snapshot;
56
+ get snapshot(): Snapshot;
57
+ set snapshot(snapshot: Snapshot);
58
+ shouldCaptureIncrement: () => void;
59
+ shouldUpdateSnapshot: () => void;
60
+ private scheduleAction;
61
+ commit: (elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined) => void;
62
+ captureIncrement: (elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined) => void;
63
+ updateSnapshot: (elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined) => void;
64
+ filterUncomittedElements: (prevElements: Map<string, OrderedExcalidrawElement>, nextElements: Map<string, OrderedExcalidrawElement>) => Map<string, OrderedExcalidrawElement>;
65
+ clear: () => void;
66
+ private satisfiesScheduledActionsInvariant;
67
+ }
68
+ export declare class Snapshot {
69
+ readonly elements: Map<string, OrderedExcalidrawElement>;
70
+ readonly appState: ObservedAppState;
71
+ readonly meta: {
72
+ didElementsChange: boolean;
73
+ didAppStateChange: boolean;
74
+ isEmpty?: boolean;
75
+ };
76
+ private constructor();
77
+ static empty(): Snapshot;
78
+ isEmpty(): boolean | undefined;
79
+ /**
80
+ * Efficiently clone the existing snapshot, only if we detected changes.
81
+ *
82
+ * @returns same instance if there are no changes detected, new instance otherwise.
83
+ */
84
+ maybeClone(elements: Map<string, OrderedExcalidrawElement> | undefined, appState: AppState | ObservedAppState | undefined): Snapshot;
85
+ private maybeCreateAppStateSnapshot;
86
+ private detectChangedAppState;
87
+ private maybeCreateElementsSnapshot;
88
+ /**
89
+ * Detect if there any changed elements.
90
+ *
91
+ * NOTE: we shouldn't just use `sceneVersionNonce` instead, as we need to call this before the scene updates.
92
+ */
93
+ private detectChangedElements;
94
+ /**
95
+ * Perform structural clone, cloning only elements that changed.
96
+ */
97
+ private createElementsSnapshot;
98
+ }
99
+ export {};
@@ -1,24 +1,25 @@
1
- import React from "react";
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement } from "./element/types";
3
- import { Action } from "./actions/types";
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";
1
+ import type React from "react";
2
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement } from "./element/types";
3
+ import type { Action } from "./actions/types";
4
+ import type { Point as RoughPoint } from "roughjs/bin/geometry";
5
+ import type { LinearElementEditor } from "./element/linearElementEditor";
6
+ import type { SuggestedBinding } from "./element/binding";
7
+ import type { ImportedDataState } from "./data/types";
8
8
  import type App from "./components/App";
9
9
  import type { throttleRAF } from "./utils";
10
- import { Spreadsheet } from "./charts";
11
- import { Language } from "./i18n";
12
- import { ClipboardData } from "./clipboard";
13
- import { isOverScrollBars } from "./scene/scrollbars";
14
- import { MaybeTransformHandleType } from "./element/transformHandles";
15
- import Library from "./data/library";
10
+ import type { Spreadsheet } from "./charts";
11
+ import type { Language } from "./i18n";
12
+ import type { ClipboardData } from "./clipboard";
13
+ import type { isOverScrollBars } from "./scene/scrollbars";
14
+ import type { MaybeTransformHandleType } from "./element/transformHandles";
15
+ import type Library from "./data/library";
16
16
  import type { FileSystemHandle } from "./data/filesystem";
17
17
  import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
18
- import { ContextMenuItems } from "./components/ContextMenu";
19
- import { SnapLine } from "./snapping";
20
- import { Merge, MaybePromise, ValueOf } from "./utility-types";
18
+ import type { ContextMenuItems } from "./components/ContextMenu";
19
+ import type { SnapLine } from "./snapping";
20
+ import type { Merge, MaybePromise, ValueOf } from "./utility-types";
21
21
  import { ColorPaletteCustom } from "./colors";
22
+ import type { StoreActionType } from "./store";
22
23
  export type Point = Readonly<RoughPoint>;
23
24
  export type SocketId = string & {
24
25
  _brand: "SocketId";
@@ -138,6 +139,18 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
138
139
  snapLines: AppState["snapLines"];
139
140
  zenModeEnabled: AppState["zenModeEnabled"];
140
141
  }>;
142
+ export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
143
+ export type ObservedStandaloneAppState = {
144
+ name: AppState["name"];
145
+ viewBackgroundColor: AppState["viewBackgroundColor"];
146
+ };
147
+ export type ObservedElementsAppState = {
148
+ editingGroupId: AppState["editingGroupId"];
149
+ selectedElementIds: AppState["selectedElementIds"];
150
+ selectedGroupIds: AppState["selectedGroupIds"];
151
+ editingLinearElementId: LinearElementEditor["elementId"] | null;
152
+ selectedLinearElementId: LinearElementEditor["elementId"] | null;
153
+ };
141
154
  export interface AppState {
142
155
  contextMenu: {
143
156
  items: ContextMenuItems;
@@ -368,7 +381,7 @@ export type OnUserFollowedPayload = {
368
381
  action: "FOLLOW" | "UNFOLLOW";
369
382
  };
370
383
  export interface ExcalidrawProps {
371
- onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
384
+ onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
372
385
  initialData?: MaybePromise<ExcalidrawInitialDataState | null>;
373
386
  excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
374
387
  isCollaborating?: boolean;
@@ -400,7 +413,11 @@ export interface ExcalidrawProps {
400
413
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
401
414
  autoFocus?: boolean;
402
415
  onBeforeTextEdit?: (textElement: ExcalidrawTextElement) => string;
403
- onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, textToSubmit: string, originalText: string, isDeleted: boolean) => [updatedText: string, updatedOriginalText: string, link: string];
416
+ onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, nextText: string, //wrapped
417
+ nextOriginalText: string, isDeleted: boolean) => {
418
+ updatedNextOriginalText: string;
419
+ nextLink: string;
420
+ };
404
421
  generateIdForFile?: (file: File) => string | Promise<string>;
405
422
  onThemeChange?: (newTheme: string) => void;
406
423
  onViewModeChange?: (isViewModeEnabled: boolean) => void;
@@ -426,7 +443,7 @@ export type SceneData = {
426
443
  elements?: ImportedDataState["elements"];
427
444
  appState?: ImportedDataState["appState"];
428
445
  collaborators?: Map<SocketId, Collaborator>;
429
- commitToHistory?: boolean;
446
+ storeAction?: StoreActionType;
430
447
  };
431
448
  export declare enum UserIdleState {
432
449
  ACTIVE = "active",
@@ -499,6 +516,7 @@ export type AppClassProperties = {
499
516
  setOpenDialog: App["setOpenDialog"];
500
517
  insertEmbeddableElement: App["insertEmbeddableElement"];
501
518
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
519
+ getElementShape: App["getElementShape"];
502
520
  getName: App["getName"];
503
521
  };
504
522
  export type PointerDownState = Readonly<{
@@ -611,7 +629,7 @@ export type Device = Readonly<{
611
629
  };
612
630
  isTouchScreen: boolean;
613
631
  }>;
614
- type FrameNameBounds = {
632
+ export type FrameNameBounds = {
615
633
  x: number;
616
634
  y: number;
617
635
  width: number;
@@ -1,7 +1,7 @@
1
- import { EVENT } from "./constants";
2
- import { FontFamilyValues, FontString } from "./element/types";
3
- import { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "./types";
4
- import { MaybePromise } from "./utility-types";
1
+ import type { EVENT } from "./constants";
2
+ import type { FontFamilyValues, FontString } from "./element/types";
3
+ import type { ActiveTool, AppState, ToolType, UnsubscribeCallback, Zoom } from "./types";
4
+ import type { MaybePromise } from "./utility-types";
5
5
  export declare const setDateTimeForTests: (dateTime: string) => void;
6
6
  export declare const getDateTime: () => string;
7
7
  export declare const capitalizeString: (str: string) => string;
@@ -160,7 +160,14 @@ export declare const arrayToMap: <T extends string | {
160
160
  export declare const arrayToMapWithIndex: <T extends {
161
161
  id: string;
162
162
  }>(elements: readonly T[]) => Map<string, [element: T, index: number]>;
163
+ /**
164
+ * Transform array into an object, use only when array order is irrelevant.
165
+ */
166
+ export declare const arrayToObject: <T>(array: readonly T[], groupBy?: ((value: T) => string) | undefined) => {
167
+ [key: string]: T;
168
+ };
163
169
  export declare const isTestEnv: () => boolean;
170
+ export declare const isDevEnv: () => boolean;
164
171
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
165
172
  nativeEvent: T;
166
173
  }>;
@@ -78,7 +78,7 @@ export namespace module {
78
78
  }
79
79
  export namespace optimization {
80
80
  const minimize: boolean;
81
- const minimizer: TerserPlugin<import("terser").MinifyOptions>[];
81
+ const minimizer: TerserPlugin<import("terser-webpack-plugin/node_modules/terser").MinifyOptions>[];
82
82
  }
83
83
  export const plugins: any[];
84
84
  export const externals: {
@@ -1,6 +1,6 @@
1
- import { ExcalidrawElement } from "./element/types";
2
- import { AppState } from "./types";
3
- export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
4
- export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
1
+ import type { ExcalidrawElement } from "./element/types";
2
+ import type { AppState } from "./types";
3
+ export declare const moveOneLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
4
+ export declare const moveOneRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[];
5
5
  export declare const moveAllLeft: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
6
6
  export declare const moveAllRight: (allElements: readonly ExcalidrawElement[], appState: AppState) => readonly ExcalidrawElement[] | ExcalidrawElement[];
@@ -1,5 +1,5 @@
1
- import { Bounds } from "../excalidraw/element/bounds";
2
- import { Point } from "../excalidraw/types";
1
+ import type { Bounds } from "../excalidraw/element/bounds";
2
+ import type { Point } from "../excalidraw/types";
3
3
  export type LineSegment = [Point, Point];
4
4
  export declare function getBBox(line: LineSegment): Bounds;
5
5
  export declare function crossProduct(a: Point, b: Point): number;
@@ -0,0 +1,4 @@
1
+ import type { Point, Polygon, GeometricShape } from "./geometry/shape";
2
+ export declare const isPointOnShape: (point: Point, shape: GeometricShape, tolerance?: number) => boolean;
3
+ export declare const isPointInShape: (point: Point, shape: GeometricShape) => boolean;
4
+ export declare const isPointInBounds: (point: Point, bounds: Polygon) => boolean;
@@ -1,5 +1,5 @@
1
- import { AppState, BinaryFiles } from "../excalidraw/types";
2
- import { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted } from "../excalidraw/element/types";
1
+ import type { AppState, BinaryFiles } from "../excalidraw/types";
2
+ import type { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted } from "../excalidraw/element/types";
3
3
  import { MIME_TYPES } from "../excalidraw/constants";
4
4
  export { MIME_TYPES };
5
5
  type ExportOpts = {
@@ -33,8 +33,8 @@ export declare const exportToClipboard: (opts: ExportOpts & {
33
33
  }) => Promise<void>;
34
34
  export { getCommonBoundingBox } from "../excalidraw/element/bounds";
35
35
  export { getMaximumGroups } from "../excalidraw/groups";
36
- export { intersectElementWithLine } from "../excalidraw/element/collision";
37
- export { determineFocusDistance } from "../excalidraw/element/collision";
36
+ export { intersectElementWithLine } from "../excalidraw/element/binding";
37
+ export { determineFocusDistance } from "../excalidraw/element/binding";
38
38
  export { measureText, wrapText, getDefaultLineHeight, } from "../excalidraw/element/textElement";
39
39
  export { getFontString } from "../excalidraw/utils";
40
40
  export { getBoundTextMaxWidth } from "../excalidraw/element/textElement";
@@ -0,0 +1,71 @@
1
+ import type { Point, Line, Polygon, Curve, Ellipse, Polycurve, Polyline } from "./shape";
2
+ /**
3
+ * utils
4
+ */
5
+ export declare const cross: (a: Point, b: Point, o: Point) => number;
6
+ export declare const isClosed: (polygon: Polygon) => boolean;
7
+ export declare const close: (polygon: Polygon) => Polygon;
8
+ /**
9
+ * angles
10
+ */
11
+ export declare const angleToDegrees: (angle: number) => number;
12
+ export declare const angleToRadians: (angle: number) => number;
13
+ export declare const angleReflect: (incidenceAngle: number, surfaceAngle: number) => number;
14
+ export declare const pointRotate: (point: Point, angle: number, origin?: Point) => Point;
15
+ export declare const pointTranslate: (point: Point, angle?: number, distance?: number) => Point;
16
+ export declare const pointInverse: (point: Point) => Point;
17
+ export declare const pointAdd: (pointA: Point, pointB: Point) => Point;
18
+ export declare const distanceToPoint: (p1: Point, p2: Point) => number;
19
+ /**
20
+ * lines
21
+ */
22
+ export declare const lineAngle: (line: Line) => number;
23
+ export declare const lineLength: (line: Line) => number;
24
+ export declare const lineMidpoint: (line: Line) => Point;
25
+ export declare const lineRotate: (line: Line, angle: number, origin?: Point) => Line;
26
+ export declare const lineTranslate: (line: Line, angle: number, distance: number) => Point[];
27
+ export declare const lineInterpolate: (line: Line, clamp?: boolean) => (t: number) => Point;
28
+ export declare const curveToBezier: (pointsIn: readonly Point[], curveTightness?: number) => Point[];
29
+ export declare const curveRotate: (curve: Curve, angle: number, origin: Point) => Point[];
30
+ export declare const cubicBezierPoint: (t: number, controlPoints: Curve) => Point;
31
+ export declare const cubicBezierDistance: (point: Point, controlPoints: Curve) => number;
32
+ /**
33
+ * polygons
34
+ */
35
+ export declare const polygonRotate: (polygon: Polygon, angle: number, origin: Point) => Point[];
36
+ export declare const polygonBounds: (polygon: Polygon) => [Point, Point];
37
+ export declare const polygonCentroid: (vertices: Point[]) => Point;
38
+ export declare const polygonScale: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
39
+ export declare const polygonScaleX: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
40
+ export declare const polygonScaleY: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
41
+ export declare const polygonReflectX: (polygon: Polygon, reflectFactor?: number) => Point[];
42
+ export declare const polygonReflectY: (polygon: Polygon, reflectFactor?: number) => Point[];
43
+ export declare const polygonTranslate: (polygon: Polygon, angle: number, distance: number) => Point[];
44
+ /**
45
+ * ellipses
46
+ */
47
+ export declare const ellipseAxes: (ellipse: Ellipse) => {
48
+ majorAxis: number;
49
+ minorAxis: number;
50
+ };
51
+ export declare const ellipseFocusToCenter: (ellipse: Ellipse) => number;
52
+ export declare const ellipseExtremes: (ellipse: Ellipse) => Point[];
53
+ export declare const pointRelativeToCenter: (point: Point, center: Point, angle: number) => Point;
54
+ export declare const pointLeftofLine: (point: Point, line: Line) => boolean;
55
+ export declare const pointRightofLine: (point: Point, line: Line) => boolean;
56
+ export declare const distanceToSegment: (point: Point, line: Line) => number;
57
+ export declare const pointOnLine: (point: Point, line: Line, threshold?: number) => boolean;
58
+ export declare const pointOnPolyline: (point: Point, polyline: Polyline, threshold?: number) => boolean;
59
+ export declare const lineIntersectsLine: (lineA: Line, lineB: Line) => boolean;
60
+ export declare const lineIntersectsPolygon: (line: Line, polygon: Polygon) => boolean;
61
+ export declare const pointInBezierEquation: (p0: Point, p1: Point, p2: Point, p3: Point, [mx, my]: Point, lineThreshold: number) => boolean;
62
+ export declare const cubicBezierEquation: (curve: Curve) => (t: number, idx: number) => number;
63
+ export declare const polyLineFromCurve: (curve: Curve, segments?: number) => Polyline;
64
+ export declare const pointOnCurve: (point: Point, curve: Curve, threshold?: number) => boolean;
65
+ export declare const pointOnPolycurve: (point: Point, polycurve: Polycurve, threshold?: number) => boolean;
66
+ export declare const pointInPolygon: (point: Point, polygon: Polygon) => boolean;
67
+ export declare const pointOnPolygon: (point: Point, polygon: Polygon, threshold?: number) => boolean;
68
+ export declare const polygonInPolygon: (polygonA: Polygon, polygonB: Polygon) => boolean;
69
+ export declare const polygonIntersectPolygon: (polygonA: Polygon, polygonB: Polygon) => boolean;
70
+ export declare const pointOnEllipse: (point: Point, ellipse: Ellipse, threshold?: number) => boolean;
71
+ export declare const pointInEllipse: (point: Point, ellipse: Ellipse) => boolean;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * this file defines pure geometric shapes
3
+ *
4
+ * for instance, a cubic bezier curve is specified by its four control points and
5
+ * an ellipse is defined by its center, angle, semi major axis and semi minor axis
6
+ * (but in semi-width and semi-height so it's more relevant to Excalidraw)
7
+ *
8
+ * the idea with pure shapes is so that we can provide collision and other geoemtric methods not depending on
9
+ * the specifics of roughjs or elements in Excalidraw; instead, we can focus on the pure shapes themselves
10
+ *
11
+ * also included in this file are methods for converting an Excalidraw element or a Drawable from roughjs
12
+ * to pure shapes
13
+ */
14
+ import type { ElementsMap, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "../../excalidraw/element/types";
15
+ import type { Drawable, Op } from "roughjs/bin/core";
16
+ export type Point = [number, number];
17
+ export type Vector = Point;
18
+ export type Line = [Point, Point];
19
+ export type Polyline = Line[];
20
+ export type Curve = [Point, Point, Point, Point];
21
+ export type Polycurve = Curve[];
22
+ export type Polygon = Point[];
23
+ export type Ellipse = {
24
+ center: Point;
25
+ angle: number;
26
+ halfWidth: number;
27
+ halfHeight: number;
28
+ };
29
+ export type GeometricShape = {
30
+ type: "line";
31
+ data: Line;
32
+ } | {
33
+ type: "polygon";
34
+ data: Polygon;
35
+ } | {
36
+ type: "curve";
37
+ data: Curve;
38
+ } | {
39
+ type: "ellipse";
40
+ data: Ellipse;
41
+ } | {
42
+ type: "polyline";
43
+ data: Polyline;
44
+ } | {
45
+ type: "polycurve";
46
+ data: Polycurve;
47
+ };
48
+ type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
49
+ export declare const getPolygonShape: (element: RectangularElement) => GeometricShape;
50
+ export declare const getSelectionBoxShape: (element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape;
51
+ export declare const getEllipseShape: (element: ExcalidrawEllipseElement) => GeometricShape;
52
+ export declare const getCurvePathOps: (shape: Drawable) => Op[];
53
+ export declare const getCurveShape: (roughShape: Drawable, startingPoint: Point | undefined, angleInRadian: number, center: Point) => GeometricShape;
54
+ export declare const getFreedrawShape: (element: ExcalidrawFreeDrawElement, center: Point, isClosed?: boolean) => GeometricShape;
55
+ export declare const getClosedCurveShape: (element: ExcalidrawLinearElement, roughShape: Drawable, startingPoint: Point | undefined, angleInRadian: number, center: Point) => GeometricShape;
56
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "../excalidraw/element/types";
2
- import { Bounds } from "../excalidraw/element/bounds";
2
+ import type { Bounds } from "../excalidraw/element/bounds";
3
3
  type Element = NonDeletedExcalidrawElement;
4
4
  type Elements = readonly NonDeletedExcalidrawElement[];
5
5
  export declare const isElementInsideBBox: (element: Element, bbox: Bounds, eitherDirection?: boolean) => boolean;