@excalidraw/excalidraw 0.18.0-195a743 → 0.18.0-200a6bd94

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 (166) hide show
  1. package/dist/dev/chunk-CP5DND7P.js +7 -0
  2. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  3. package/dist/dev/{chunk-T3M44BFV.js → chunk-QF5FRM6O.js} +12 -4
  4. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  5. package/dist/dev/chunk-VISTIWDQ.js +5668 -0
  6. package/dist/dev/chunk-VISTIWDQ.js.map +7 -0
  7. package/dist/dev/data/{image-TTQKTTOH.js → image-XM2PNARE.js} +3 -3
  8. package/dist/dev/index.css +89 -22
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +7634 -9487
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-I23TB6DJ.js → en-SMAPCEOQ.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-A66AFZZU.js +7 -0
  16. package/dist/prod/chunk-I4UNSFV6.js +12 -0
  17. package/dist/prod/chunk-YZO7PSYQ.js +4 -0
  18. package/dist/prod/data/image-53OPA26C.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +26 -19
  21. package/dist/prod/locales/{en-TC3OFDA6.js → en-TYY6KWIJ.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/common/src/constants.d.ts +20 -3
  25. package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  26. package/dist/types/common/src/font-metadata.d.ts +4 -2
  27. package/dist/types/common/src/index.d.ts +1 -0
  28. package/dist/types/common/src/utility-types.d.ts +5 -0
  29. package/dist/types/common/src/utils.d.ts +15 -5
  30. package/dist/types/element/src/Scene.d.ts +4 -4
  31. package/dist/types/element/src/align.d.ts +3 -2
  32. package/dist/types/element/src/binding.d.ts +11 -8
  33. package/dist/types/element/src/bounds.d.ts +12 -4
  34. package/dist/types/element/src/collision.d.ts +18 -12
  35. package/dist/types/element/src/cropElement.d.ts +1 -1
  36. package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +73 -38
  37. package/dist/types/element/src/distance.d.ts +2 -2
  38. package/dist/types/element/src/distribute.d.ts +2 -1
  39. package/dist/types/element/src/dragElements.d.ts +1 -1
  40. package/dist/types/element/src/flowchart.d.ts +1 -1
  41. package/dist/types/element/src/fractionalIndex.d.ts +8 -2
  42. package/dist/types/element/src/frame.d.ts +3 -2
  43. package/dist/types/element/src/groups.d.ts +1 -0
  44. package/dist/types/element/src/index.d.ts +43 -2
  45. package/dist/types/element/src/linearElementEditor.d.ts +17 -30
  46. package/dist/types/element/src/mutateElement.d.ts +1 -1
  47. package/dist/types/element/src/newElement.d.ts +3 -2
  48. package/dist/types/element/src/resizeElements.d.ts +2 -1
  49. package/dist/types/element/src/selection.d.ts +0 -5
  50. package/dist/types/element/src/shape.d.ts +42 -0
  51. package/dist/types/element/src/sizeHelpers.d.ts +2 -1
  52. package/dist/types/element/src/store.d.ts +232 -0
  53. package/dist/types/element/src/textElement.d.ts +1 -1
  54. package/dist/types/element/src/typeChecks.d.ts +16 -1
  55. package/dist/types/element/src/types.d.ts +13 -3
  56. package/dist/types/element/src/utils.d.ts +16 -6
  57. package/dist/types/element/src/zindex.d.ts +3 -3
  58. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +36 -48
  59. package/dist/types/excalidraw/actions/actionBoundText.d.ts +24 -32
  60. package/dist/types/excalidraw/actions/actionCanvas.d.ts +160 -212
  61. package/dist/types/excalidraw/actions/actionClipboard.d.ts +72 -94
  62. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -16
  63. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +36 -47
  64. package/dist/types/excalidraw/actions/actionElementLink.d.ts +11 -15
  65. package/dist/types/excalidraw/actions/actionElementLock.d.ts +39 -48
  66. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -16
  67. package/dist/types/excalidraw/actions/actionExport.d.ts +118 -154
  68. package/dist/types/excalidraw/actions/actionFinalize.d.ts +71 -38
  69. package/dist/types/excalidraw/actions/actionFrame.d.ts +95 -111
  70. package/dist/types/excalidraw/actions/actionGroup.d.ts +24 -32
  71. package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
  72. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +537 -17
  73. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -16
  74. package/dist/types/excalidraw/actions/actionMenu.d.ts +35 -47
  75. package/dist/types/excalidraw/actions/actionNavigate.d.ts +24 -32
  76. package/dist/types/excalidraw/actions/actionProperties.d.ts +186 -238
  77. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -16
  78. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -16
  79. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +12 -16
  80. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +12 -16
  81. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +11 -188
  82. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +12 -16
  83. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +12 -16
  84. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -16
  85. package/dist/types/excalidraw/actions/actionZindex.d.ts +2 -2
  86. package/dist/types/excalidraw/actions/types.d.ts +3 -2
  87. package/dist/types/excalidraw/appState.d.ts +16 -7
  88. package/dist/types/excalidraw/components/Actions.d.ts +0 -4
  89. package/dist/types/excalidraw/components/App.d.ts +18 -20
  90. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  91. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  92. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  93. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  94. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  95. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  96. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  97. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  98. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  99. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  100. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -28
  101. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
  102. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  103. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  104. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  105. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  106. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  107. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  108. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  109. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
  110. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  111. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  112. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  113. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  114. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
  116. package/dist/types/excalidraw/components/Stats/utils.d.ts +2 -1
  117. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  118. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
  119. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  120. package/dist/types/excalidraw/components/icons.d.ts +3 -0
  121. package/dist/types/excalidraw/components/shapes.d.ts +1 -1
  122. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  123. package/dist/types/excalidraw/data/transform.d.ts +1 -1
  124. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  125. package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
  126. package/dist/types/excalidraw/history.d.ts +30 -22
  127. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  128. package/dist/types/excalidraw/index.d.ts +10 -9
  129. package/dist/types/excalidraw/lasso/index.d.ts +1 -0
  130. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  131. package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
  132. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  133. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
  134. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  135. package/dist/types/excalidraw/snapping.d.ts +2 -2
  136. package/dist/types/excalidraw/types.d.ts +27 -14
  137. package/dist/types/math/src/angle.d.ts +2 -0
  138. package/dist/types/math/src/constants.d.ts +3 -0
  139. package/dist/types/math/src/curve.d.ts +34 -0
  140. package/dist/types/math/src/index.d.ts +1 -0
  141. package/dist/types/math/src/point.d.ts +1 -1
  142. package/dist/types/math/src/rectangle.d.ts +2 -0
  143. package/dist/types/math/src/vector.d.ts +8 -2
  144. package/dist/types/utils/src/bbox.d.ts +1 -1
  145. package/dist/types/utils/src/index.d.ts +1 -1
  146. package/dist/types/utils/src/withinBounds.d.ts +1 -1
  147. package/history.ts +147 -110
  148. package/package.json +12 -9
  149. package/dist/dev/chunk-H3EW23X2.js +0 -18294
  150. package/dist/dev/chunk-H3EW23X2.js.map +0 -7
  151. package/dist/dev/chunk-T3M44BFV.js.map +0 -7
  152. package/dist/dev/chunk-WMGEUIQQ.js +0 -7
  153. package/dist/dev/chunk-WMGEUIQQ.js.map +0 -7
  154. package/dist/prod/chunk-2Z7RPVPO.js +0 -12
  155. package/dist/prod/chunk-7M43VNIB.js +0 -33
  156. package/dist/prod/chunk-GK4XUKZB.js +0 -7
  157. package/dist/prod/data/image-7YYIWLVQ.js +0 -1
  158. package/dist/types/element/src/Shape.d.ts +0 -17
  159. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  160. package/dist/types/element/src/shapes.d.ts +0 -23
  161. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  162. package/dist/types/excalidraw/store.d.ts +0 -129
  163. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  164. package/dist/types/utils/src/collision.d.ts +0 -8
  165. /package/dist/dev/data/{image-TTQKTTOH.js.map → image-XM2PNARE.js.map} +0 -0
  166. /package/dist/dev/locales/{en-I23TB6DJ.js.map → en-SMAPCEOQ.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -44,8 +44,14 @@ export declare const orderByFractionalIndex: (elements: OrderedExcalidrawElement
44
44
  */
45
45
  export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[], movedElements: ElementsMap) => OrderedExcalidrawElement[];
46
46
  /**
47
- * Synchronizes all invalid fractional indices with the array order by mutating passed elements.
47
+ * Synchronizes all invalid fractional indices within the array order by mutating elements in the passed array.
48
48
  *
49
49
  * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
50
50
  */
51
51
  export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
52
+ /**
53
+ * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
+ *
55
+ * WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
56
+ */
57
+ export declare const syncInvalidIndicesImmutable: (elements: readonly ExcalidrawElement[]) => SceneElementsMap | undefined;
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
31
31
  */
32
32
  export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
- export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement)[];
35
- export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawFreeDrawElement)[];
34
+ export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
+ export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
37
  /** */
38
38
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
@@ -64,6 +64,7 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
64
64
  checkedGroups?: Map<string, boolean>;
65
65
  }) => boolean;
66
66
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
67
+ export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
67
68
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
68
69
  export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => NonDeletedExcalidrawElement[];
69
70
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
@@ -31,3 +31,4 @@ export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<strin
31
31
  export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
32
32
  export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
33
33
  export declare const getNewGroupIdsForDuplication: (groupIds: ExcalidrawElement["groupIds"], editingGroupId: AppState["editingGroupId"], mapper: (groupId: GroupId) => GroupId) => string[];
34
+ export declare const getSelectedElementsByGroup: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<AppState>) => ExcalidrawElement[][];
@@ -1,4 +1,4 @@
1
- import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
1
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMapOrArray } from "./types";
2
2
  /**
3
3
  * @deprecated unsafe, use hashElementsVersion instead
4
4
  */
@@ -6,7 +6,7 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
6
6
  /**
7
7
  * Hashes elements' versionNonce (using djb2 algo). Order of elements matters.
8
8
  */
9
- export declare const hashElementsVersion: (elements: readonly ExcalidrawElement[]) => number;
9
+ export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
10
10
  export declare const hashString: (s: string) => number;
11
11
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
12
12
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
@@ -14,3 +14,44 @@ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element:
14
14
  export declare const clearElementsForDatabase: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
15
15
  export declare const clearElementsForExport: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
16
16
  export declare const clearElementsForLocalStorage: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
17
+ export * from "./align";
18
+ export * from "./binding";
19
+ export * from "./bounds";
20
+ export * from "./collision";
21
+ export * from "./comparisons";
22
+ export * from "./containerCache";
23
+ export * from "./cropElement";
24
+ export * from "./delta";
25
+ export * from "./distance";
26
+ export * from "./distribute";
27
+ export * from "./dragElements";
28
+ export * from "./duplicate";
29
+ export * from "./elbowArrow";
30
+ export * from "./elementLink";
31
+ export * from "./embeddable";
32
+ export * from "./flowchart";
33
+ export * from "./fractionalIndex";
34
+ export * from "./frame";
35
+ export * from "./groups";
36
+ export * from "./heading";
37
+ export * from "./image";
38
+ export * from "./linearElementEditor";
39
+ export * from "./mutateElement";
40
+ export * from "./newElement";
41
+ export * from "./renderElement";
42
+ export * from "./resizeElements";
43
+ export * from "./resizeTest";
44
+ export * from "./Scene";
45
+ export * from "./selection";
46
+ export * from "./shape";
47
+ export * from "./showSelectedShapeActions";
48
+ export * from "./sizeHelpers";
49
+ export * from "./sortElements";
50
+ export * from "./store";
51
+ export * from "./textElement";
52
+ export * from "./textMeasurements";
53
+ export * from "./textWrapping";
54
+ export * from "./transformHandles";
55
+ export * from "./typeChecks";
56
+ export * from "./utils";
57
+ export * from "./zindex";
@@ -1,15 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { type GlobalPoint, type LocalPoint } from "@excalidraw/math";
3
- import type { Store } from "@excalidraw/excalidraw/store";
3
+ import { type Store } from "@excalidraw/element";
4
4
  import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize, Zoom } from "@excalidraw/excalidraw/types";
5
- import type Scene from "./Scene";
5
+ import type { Scene } from "./Scene";
6
6
  import type { Bounds } from "./bounds";
7
- import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement } from "./types";
8
- declare const editorMidPointsCache: {
9
- version: number | null;
10
- points: (GlobalPoint | null)[];
11
- zoom: number | null;
12
- };
7
+ import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, ExcalidrawElbowArrowElement, PointsPositionUpdates } from "./types";
13
8
  export declare class LinearElementEditor {
14
9
  readonly elementId: ExcalidrawElement["id"] & {
15
10
  _brand: "excalidrawLinearElementId";
@@ -43,7 +38,9 @@ export declare class LinearElementEditor {
43
38
  readonly hoverPointIndex: number;
44
39
  readonly segmentMidPointHoveredCoords: GlobalPoint | null;
45
40
  readonly elbowed: boolean;
46
- constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap);
41
+ readonly customLineAngle: number | null;
42
+ readonly isEditing: boolean;
43
+ constructor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, isEditing?: boolean);
47
44
  static POINT_HANDLE_SIZE: number;
48
45
  /**
49
46
  * @param id the `elementId` from the instance of this class (so that we can
@@ -54,19 +51,15 @@ export declare class LinearElementEditor {
54
51
  /**
55
52
  * @returns whether point was dragged
56
53
  */
57
- static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, maybeSuggestBinding: (element: NonDeleted<ExcalidrawLinearElement>, pointSceneCoords: {
58
- x: number;
59
- y: number;
60
- }[]) => void, linearElementEditor: LinearElementEditor, scene: Scene): LinearElementEditor | null;
54
+ static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, keyof AppState> | null;
61
55
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
62
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
63
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => void;
56
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
64
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
65
58
  x: number;
66
59
  y: number;
67
60
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
68
61
  static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom): boolean;
69
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
62
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number): GlobalPoint;
70
63
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
71
64
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
72
65
  x: number;
@@ -89,25 +82,20 @@ export declare class LinearElementEditor {
89
82
  static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
90
83
  /**
91
84
  * Normalizes line points so that the start point is at [0,0]. This is
92
- * expected in various parts of the codebase. Also returns new x/y to account
93
- * for the potential normalization.
85
+ * expected in various parts of the codebase.
86
+ *
87
+ * Also returns normalized x and y coords to account for the normalization
88
+ * of the points.
94
89
  */
95
- static getNormalizedPoints(element: ExcalidrawLinearElement): {
90
+ static getNormalizeElementPointsAndCoords(element: ExcalidrawLinearElement): {
96
91
  points: LocalPoint[];
97
92
  x: number;
98
93
  y: number;
99
94
  };
100
- static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): void;
101
95
  static duplicateSelectedPoints(appState: AppState, scene: Scene): AppState;
102
- static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointIndices: readonly number[]): void;
103
- static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, targetPoints: {
104
- point: LocalPoint;
105
- }[]): void;
106
- static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, targetPoints: {
107
- index: number;
108
- point: LocalPoint;
109
- isDragging?: boolean;
110
- }[], otherUpdates?: {
96
+ static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, app: AppClassProperties, pointIndices: readonly number[]): void;
97
+ static addPoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, addedPoints: LocalPoint[]): void;
98
+ static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
111
99
  startBinding?: PointBinding | null;
112
100
  endBinding?: PointBinding | null;
113
101
  }): void;
@@ -127,4 +115,3 @@ export declare class LinearElementEditor {
127
115
  static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): LinearElementEditor;
128
116
  static deleteFixedSegment(element: ExcalidrawElbowArrowElement, scene: Scene, index: number): void;
129
117
  }
130
- export {};
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
- export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
4
4
  /**
5
5
  * This function tracks updates of text elements for the purposes for collaboration.
6
6
  * The version is used to compare updates when more than one user is working in
@@ -1,5 +1,5 @@
1
1
  import type { MarkOptional } from "@excalidraw/common/utility-types";
2
- import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement } from "./types";
2
+ import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement } from "./types";
3
3
  export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
4
4
  export declare const newElement: (opts: {
5
5
  type: ExcalidrawGenericElement["type"];
@@ -43,6 +43,7 @@ export declare const newFreeDrawElement: (opts: {
43
43
  export declare const newLinearElement: (opts: {
44
44
  type: ExcalidrawLinearElement["type"];
45
45
  points?: ExcalidrawLinearElement["points"];
46
+ polygon?: ExcalidrawLineElement["polygon"];
46
47
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
47
48
  export declare const newArrowElement: <T extends boolean>(opts: {
48
49
  type: ExcalidrawArrowElement["type"];
@@ -51,7 +52,7 @@ export declare const newArrowElement: <T extends boolean>(opts: {
51
52
  points?: readonly import("@excalidraw/math").LocalPoint[] | undefined;
52
53
  elbowed?: T | undefined;
53
54
  fixedSegments?: readonly import("./types").FixedSegment[] | null | undefined;
54
- } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "angle" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "angle" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
55
+ } & Omit<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData"> & Partial<Pick<Omit<ExcalidrawGenericElement, "id" | "isDeleted" | "updated" | "type">, "link" | "strokeColor" | "backgroundColor" | "fillStyle" | "strokeWidth" | "strokeStyle" | "roundness" | "roughness" | "opacity" | "width" | "height" | "angle" | "seed" | "version" | "versionNonce" | "index" | "groupIds" | "frameId" | "boundElements" | "locked" | "customData">>) => T extends true ? NonDeleted<ExcalidrawElbowArrowElement> : NonDeleted<ExcalidrawArrowElement>;
55
56
  export declare const newImageElement: (opts: {
56
57
  type: ExcalidrawImageElement["type"];
57
58
  status?: ExcalidrawImageElement["status"];
@@ -1,6 +1,6 @@
1
1
  import { type LocalPoint } from "@excalidraw/math";
2
2
  import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
- import type Scene from "./Scene";
3
+ import type { Scene } from "./Scene";
4
4
  import type { BoundingBox } from "./bounds";
5
5
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
6
6
  import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
@@ -13,6 +13,7 @@ export declare const rescalePointsInElement: (element: NonDeletedExcalidrawEleme
13
13
  export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
14
14
  size: number;
15
15
  } | null;
16
+ export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number) => void;
16
17
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
17
18
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
18
19
  export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
@@ -14,11 +14,6 @@ export declare const isSomeElementSelected: {
14
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
15
15
  clearCache(): void;
16
16
  };
17
- /**
18
- * Returns common attribute (picked by `getAttribute` callback) of selected
19
- * elements. If elements don't share the same value, returns `null`.
20
- */
21
- export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
22
17
  export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
23
18
  includeBoundTextElement?: boolean;
24
19
  includeElementsInFrames?: boolean;
@@ -0,0 +1,42 @@
1
+ import { type GeometricShape } from "@excalidraw/utils/shape";
2
+ import { type LocalPoint } from "@excalidraw/math";
3
+ import type { GlobalPoint } from "@excalidraw/math";
4
+ import type { AppState, EmbedsValidationStatus } from "@excalidraw/excalidraw/types";
5
+ import type { ElementShape, ElementShapes } from "@excalidraw/excalidraw/scene/types";
6
+ import type { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawFreeDrawElement, ElementsMap, ExcalidrawLineElement } from "./types";
7
+ import type { Drawable, Options } from "roughjs/bin/core";
8
+ export declare class ShapeCache {
9
+ private static rg;
10
+ private static cache;
11
+ /**
12
+ * Retrieves shape from cache if available. Use this only if shape
13
+ * is optional and you have a fallback in case it's not cached.
14
+ */
15
+ static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
16
+ static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
17
+ static delete: (element: ExcalidrawElement) => boolean;
18
+ static destroy: () => void;
19
+ /**
20
+ * Generates & caches shape for element if not already cached, otherwise
21
+ * returns cached shape.
22
+ */
23
+ static generateElementShape: <T extends ExcalidrawLinearElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | ExcalidrawFreeDrawElement | import("./types").ExcalidrawArrowElement>(element: T, renderConfig: {
24
+ isExporting: boolean;
25
+ canvasBackgroundColor: AppState["viewBackgroundColor"];
26
+ embedsValidationStatus: EmbedsValidationStatus;
27
+ } | null) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
28
+ }
29
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
30
+ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearElement | ExcalidrawFreeDrawElement) => {
31
+ op: string;
32
+ data: number[];
33
+ }[];
34
+ /**
35
+ * get the pure geometric shape of an excalidraw elementw
36
+ * which is then used for hit detection
37
+ */
38
+ export declare const getElementShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
39
+ export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, nextPolygonState: boolean) => {
40
+ polygon: ExcalidrawLineElement["polygon"];
41
+ points: ExcalidrawLineElement["points"];
42
+ } | null;
@@ -1,5 +1,6 @@
1
1
  import type { AppState, Offsets, Zoom } from "@excalidraw/excalidraw/types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export declare const INVISIBLY_SMALL_ELEMENT_SIZE = 0.1;
3
4
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
5
  export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
6
  zoom: Zoom;
@@ -22,7 +23,7 @@ export declare const getPerfectElementSize: (elementType: AppState["activeTool"]
22
23
  width: number;
23
24
  height: number;
24
25
  };
25
- export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number) => {
26
+ export declare const getLockedLinearCursorAlignSize: (originX: number, originY: number, x: number, y: number, customAngle?: number) => {
26
27
  width: number;
27
28
  height: number;
28
29
  };
@@ -0,0 +1,232 @@
1
+ import { Emitter } from "@excalidraw/common";
2
+ import type App from "@excalidraw/excalidraw/components/App";
3
+ import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
4
+ import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
5
+ import { ElementsDelta, AppStateDelta } from "./delta";
6
+ import type { ApplyToOptions } from "./delta";
7
+ import type { ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
8
+ export declare const CaptureUpdateAction: {
9
+ /**
10
+ * Immediately undoable.
11
+ *
12
+ * Use for updates which should be captured.
13
+ * Should be used for most of the local updates, except ephemerals such as dragging or resizing.
14
+ *
15
+ * These updates will _immediately_ make it to the local undo / redo stacks.
16
+ */
17
+ readonly IMMEDIATELY: "IMMEDIATELY";
18
+ /**
19
+ * Never undoable.
20
+ *
21
+ * Use for updates which should never be recorded, such as remote updates
22
+ * or scene initialization.
23
+ *
24
+ * These updates will _never_ make it to the local undo / redo stacks.
25
+ */
26
+ readonly NEVER: "NEVER";
27
+ /**
28
+ * Eventually undoable.
29
+ *
30
+ * Use for updates which should not be captured immediately - likely
31
+ * exceptions which are part of some async multi-step process. Otherwise, all
32
+ * such updates would end up being captured with the next
33
+ * `CaptureUpdateAction.IMMEDIATELY` - triggered either by the next `updateScene`
34
+ * or internally by the editor.
35
+ *
36
+ * These updates will _eventually_ make it to the local undo / redo stacks.
37
+ */
38
+ readonly EVENTUALLY: "EVENTUALLY";
39
+ };
40
+ export type CaptureUpdateActionType = ValueOf<typeof CaptureUpdateAction>;
41
+ /**
42
+ * Store which captures the observed changes and emits them as `StoreIncrement` events.
43
+ */
44
+ export declare class Store {
45
+ private readonly app;
46
+ readonly onDurableIncrementEmitter: Emitter<[DurableIncrement]>;
47
+ readonly onStoreIncrementEmitter: Emitter<[DurableIncrement | EphemeralIncrement]>;
48
+ private scheduledMacroActions;
49
+ private scheduledMicroActions;
50
+ private _snapshot;
51
+ get snapshot(): StoreSnapshot;
52
+ set snapshot(snapshot: StoreSnapshot);
53
+ constructor(app: App);
54
+ scheduleAction(action: CaptureUpdateActionType): void;
55
+ /**
56
+ * Use to schedule a delta calculation, which will consquentially be emitted as `DurableStoreIncrement` and pushed in the undo stack.
57
+ */
58
+ scheduleCapture(): void;
59
+ /**
60
+ * Schedule special "micro" actions, to-be executed before the next commit, before it executes a scheduled "macro" action.
61
+ */
62
+ scheduleMicroAction(params: {
63
+ action: CaptureUpdateActionType;
64
+ elements: readonly ExcalidrawElement[] | undefined;
65
+ appState: AppState | ObservedAppState | undefined;
66
+ } | {
67
+ action: typeof CaptureUpdateAction.IMMEDIATELY;
68
+ change: StoreChange;
69
+ delta: StoreDelta;
70
+ } | {
71
+ action: typeof CaptureUpdateAction.NEVER | typeof CaptureUpdateAction.EVENTUALLY;
72
+ change: StoreChange;
73
+ }): void;
74
+ /**
75
+ * Performs the incoming `CaptureUpdateAction` and emits the corresponding `StoreIncrement`.
76
+ * Emits `DurableStoreIncrement` when action is "capture", emits `EphemeralStoreIncrement` otherwise.
77
+ *
78
+ * @emits StoreIncrement
79
+ */
80
+ commit(elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): void;
81
+ /**
82
+ * Clears the store instance.
83
+ */
84
+ clear(): void;
85
+ /**
86
+ * Performs delta & change calculation and emits a durable increment.
87
+ *
88
+ * @emits StoreIncrement.
89
+ */
90
+ private emitDurableIncrement;
91
+ /**
92
+ * Performs change calculation and emits an ephemeral increment.
93
+ *
94
+ * @emits EphemeralStoreIncrement
95
+ */
96
+ private emitEphemeralIncrement;
97
+ private applyChangeToSnapshot;
98
+ /**
99
+ * Clones the snapshot if there are changes detected.
100
+ */
101
+ private maybeCloneSnapshot;
102
+ private flushMicroActions;
103
+ private processAction;
104
+ /**
105
+ * Returns the scheduled macro action.
106
+ */
107
+ private getScheduledMacroAction;
108
+ /**
109
+ * Ensures that the scheduled actions invariant is satisfied.
110
+ */
111
+ private satisfiesScheduledActionsInvariant;
112
+ }
113
+ /**
114
+ * Repsents a change to the store containing changed elements and appState.
115
+ */
116
+ export declare class StoreChange {
117
+ readonly elements: Record<string, OrderedExcalidrawElement>;
118
+ readonly appState: Partial<ObservedAppState>;
119
+ private constructor();
120
+ static create(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreChange;
121
+ }
122
+ /**
123
+ * Encpasulates any change to the store (durable or ephemeral).
124
+ */
125
+ export declare abstract class StoreIncrement {
126
+ readonly type: "durable" | "ephemeral";
127
+ readonly change: StoreChange;
128
+ protected constructor(type: "durable" | "ephemeral", change: StoreChange);
129
+ static isDurable(increment: StoreIncrement): increment is DurableIncrement;
130
+ static isEphemeral(increment: StoreIncrement): increment is EphemeralIncrement;
131
+ }
132
+ /**
133
+ * Represents a durable change to the store.
134
+ */
135
+ export declare class DurableIncrement extends StoreIncrement {
136
+ readonly change: StoreChange;
137
+ readonly delta: StoreDelta;
138
+ constructor(change: StoreChange, delta: StoreDelta);
139
+ }
140
+ /**
141
+ * Represents an ephemeral change to the store.
142
+ */
143
+ export declare class EphemeralIncrement extends StoreIncrement {
144
+ readonly change: StoreChange;
145
+ constructor(change: StoreChange);
146
+ }
147
+ /**
148
+ * Represents a captured delta by the Store.
149
+ */
150
+ export declare class StoreDelta {
151
+ readonly id: string;
152
+ readonly elements: ElementsDelta;
153
+ readonly appState: AppStateDelta;
154
+ protected constructor(id: string, elements: ElementsDelta, appState: AppStateDelta);
155
+ /**
156
+ * Create a new instance of `StoreDelta`.
157
+ */
158
+ static create(elements: ElementsDelta, appState: AppStateDelta, opts?: {
159
+ id: string;
160
+ }): StoreDelta;
161
+ /**
162
+ * Calculate the delta between the previous and next snapshot.
163
+ */
164
+ static calculate(prevSnapshot: StoreSnapshot, nextSnapshot: StoreSnapshot): StoreDelta;
165
+ /**
166
+ * Restore a store delta instance from a DTO.
167
+ */
168
+ static restore(storeDeltaDTO: DTO<StoreDelta>): StoreDelta;
169
+ /**
170
+ * Parse and load the delta from the remote payload.
171
+ */
172
+ static load({ id, elements: { added, removed, updated }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Inverse store delta, creates new instance of `StoreDelta`.
175
+ */
176
+ static inverse(delta: StoreDelta): StoreDelta;
177
+ /**
178
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
179
+ */
180
+ static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, options?: ApplyToOptions): [SceneElementsMap, AppState, boolean];
181
+ /**
182
+ * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
183
+ */
184
+ static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
185
+ isEmpty(): boolean;
186
+ }
187
+ /**
188
+ * Represents a snapshot of the captured or updated changes in the store,
189
+ * used for producing deltas and emitting `DurableStoreIncrement`s.
190
+ */
191
+ export declare class StoreSnapshot {
192
+ readonly elements: SceneElementsMap;
193
+ readonly appState: ObservedAppState;
194
+ readonly metadata: {
195
+ didElementsChange: boolean;
196
+ didAppStateChange: boolean;
197
+ isEmpty?: boolean;
198
+ };
199
+ private _lastChangedElementsHash;
200
+ private _lastChangedAppStateHash;
201
+ private constructor();
202
+ static create(elements: SceneElementsMap, appState: AppState | ObservedAppState, metadata?: {
203
+ didElementsChange: boolean;
204
+ didAppStateChange: boolean;
205
+ }): StoreSnapshot;
206
+ static empty(): StoreSnapshot;
207
+ getChangedElements(prevSnapshot: StoreSnapshot): Record<string, OrderedExcalidrawElement>;
208
+ getChangedAppState(prevSnapshot: StoreSnapshot): Partial<ObservedAppState>;
209
+ isEmpty(): boolean | undefined;
210
+ /**
211
+ * Apply the change and return a new snapshot instance.
212
+ */
213
+ applyChange(change: StoreChange): StoreSnapshot;
214
+ /**
215
+ * Efficiently clone the existing snapshot, only if we detected changes.
216
+ *
217
+ * @returns same instance if there are no changes detected, new instance otherwise.
218
+ */
219
+ maybeClone(action: CaptureUpdateActionType, elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): StoreSnapshot;
220
+ private maybeCreateAppStateSnapshot;
221
+ private maybeCreateElementsSnapshot;
222
+ private detectChangedAppState;
223
+ /**
224
+ * Detect if there are any changed elements.
225
+ */
226
+ private detectChangedElements;
227
+ /**
228
+ * Perform structural clone, deep cloning only elements that changed.
229
+ */
230
+ private createElementsSnapshot;
231
+ }
232
+ export declare const getObservedAppState: (appState: AppState | ObservedAppState) => ObservedAppState;
@@ -1,7 +1,7 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
3
  import type { Radians } from "@excalidraw/math";
4
- import type Scene from "./Scene";
4
+ import type { Scene } from "./Scene";
5
5
  import type { MaybeTransformHandleType } from "./transformHandles";
6
6
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
7
7
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
@@ -1,7 +1,7 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkNonNullable } from "@excalidraw/common/utility-types";
3
3
  import type { Bounds } from "./bounds";
4
- import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, PointBinding, FixedPointBinding, ExcalidrawFlowchartNodeElement } from "./types";
4
+ import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement, PointBinding, FixedPointBinding, ExcalidrawFlowchartNodeElement, ExcalidrawLinearElementSubType } from "./types";
5
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
6
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
7
  export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
@@ -14,8 +14,13 @@ export declare const isFrameLikeElement: (element: ExcalidrawElement | null) =>
14
14
  export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
15
15
  export declare const isFreeDrawElementType: (elementType: ExcalidrawElementType) => boolean;
16
16
  export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
17
+ export declare const isLineElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLineElement;
17
18
  export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawArrowElement;
18
19
  export declare const isElbowArrow: (element?: ExcalidrawElement) => element is ExcalidrawElbowArrowElement;
20
+ /**
21
+ * sharp or curved arrow, but not elbow
22
+ */
23
+ export declare const isSimpleArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
19
24
  export declare const isSharpArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
20
25
  export declare const isCurvedArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
21
26
  export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
@@ -40,3 +45,13 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
40
45
  } | null;
41
46
  export declare const isFixedPointBinding: (binding: PointBinding | FixedPointBinding) => binding is FixedPointBinding;
42
47
  export declare const isBounds: (box: unknown) => box is Bounds;
48
+ export declare const getLinearElementSubType: (element: ExcalidrawLinearElement) => ExcalidrawLinearElementSubType;
49
+ /**
50
+ * Checks if current element points meet all the conditions for polygon=true
51
+ * (this isn't a element type check, for that use isLineElement).
52
+ *
53
+ * If you want to check if points *can* be turned into a polygon, use
54
+ * canBecomePolygon(points).
55
+ */
56
+ export declare const isValidPolygon: (points: ExcalidrawLineElement["points"]) => boolean;
57
+ export declare const canBecomePolygon: (points: ExcalidrawLineElement["points"]) => boolean;