@zsviczian/excalidraw 0.18.0-5 → 0.18.0-51

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 (191) hide show
  1. package/dist/excalidraw.development.js +746 -504
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/dist/excalidraw.production.min.js.LICENSE.txt +0 -2
  4. package/dist/styles.development.css +1080 -437
  5. package/dist/styles.production.css +26 -22
  6. package/package.json +14 -3
  7. package/types/common/src/commonObsidianUtils.d.ts +13 -0
  8. package/types/common/src/constants.d.ts +42 -18
  9. package/types/common/src/editorInterface.d.ts +35 -0
  10. package/types/{excalidraw → common/src}/emitter.d.ts +1 -1
  11. package/types/common/src/font-metadata.d.ts +4 -2
  12. package/types/common/src/index.d.ts +2 -0
  13. package/types/common/src/utility-types.d.ts +5 -0
  14. package/types/common/src/utils.d.ts +20 -5
  15. package/types/{excalidraw/scene → element/src}/Scene.d.ts +16 -15
  16. package/types/element/src/align.d.ts +4 -3
  17. package/types/element/src/binding.d.ts +27 -17
  18. package/types/element/src/bounds.d.ts +14 -6
  19. package/types/element/src/collision.d.ts +18 -12
  20. package/types/element/src/cropElement.d.ts +1 -1
  21. package/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +77 -40
  22. package/types/element/src/distance.d.ts +2 -2
  23. package/types/element/src/distribute.d.ts +2 -1
  24. package/types/element/src/dragElements.d.ts +3 -2
  25. package/types/element/src/duplicate.d.ts +10 -13
  26. package/types/element/src/elbowArrow.d.ts +1 -1
  27. package/types/element/src/flowchart.d.ts +3 -2
  28. package/types/element/src/fractionalIndex.d.ts +9 -3
  29. package/types/element/src/frame.d.ts +5 -4
  30. package/types/element/src/groups.d.ts +1 -0
  31. package/types/element/src/index.d.ts +44 -2
  32. package/types/element/src/linearElementEditor.d.ts +23 -36
  33. package/types/element/src/mutateElement.d.ts +11 -3
  34. package/types/element/src/newElement.d.ts +6 -4
  35. package/types/element/src/positionElementsOnGrid.d.ts +2 -0
  36. package/types/element/src/renderElement.d.ts +4 -1
  37. package/types/element/src/resizeElements.d.ts +6 -5
  38. package/types/element/src/resizeTest.d.ts +5 -4
  39. package/types/element/src/selection.d.ts +11 -5
  40. package/types/element/src/shape.d.ts +42 -0
  41. package/types/element/src/sizeHelpers.d.ts +2 -2
  42. package/types/element/src/store.d.ts +237 -0
  43. package/types/element/src/textElement.d.ts +5 -3
  44. package/types/element/src/transformHandles.d.ts +5 -4
  45. package/types/element/src/typeChecks.d.ts +19 -1
  46. package/types/element/src/types.d.ts +25 -2
  47. package/types/element/src/utils.d.ts +16 -6
  48. package/types/element/src/zindex.d.ts +1 -1
  49. package/types/excalidraw/actions/actionAddToLibrary.d.ts +75 -54
  50. package/types/excalidraw/actions/actionBoundText.d.ts +50 -36
  51. package/types/excalidraw/actions/actionCanvas.d.ts +388 -282
  52. package/types/excalidraw/actions/actionClipboard.d.ts +151 -107
  53. package/types/excalidraw/actions/actionCropEditor.d.ts +25 -18
  54. package/types/excalidraw/actions/actionDeleteSelected.d.ts +77 -55
  55. package/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
  56. package/types/excalidraw/actions/actionElementLink.d.ts +25 -18
  57. package/types/excalidraw/actions/actionElementLock.d.ts +65 -52
  58. package/types/excalidraw/actions/actionEmbeddable.d.ts +25 -18
  59. package/types/excalidraw/actions/actionExport.d.ts +237 -174
  60. package/types/excalidraw/actions/actionFinalize.d.ts +307 -43
  61. package/types/excalidraw/actions/actionFrame.d.ts +157 -120
  62. package/types/excalidraw/actions/actionGroup.d.ts +50 -36
  63. package/types/excalidraw/actions/actionHistory.d.ts +1 -2
  64. package/types/excalidraw/actions/actionLinearEditor.d.ts +563 -20
  65. package/types/excalidraw/actions/actionLink.d.ts +23 -16
  66. package/types/excalidraw/actions/actionMenu.d.ts +25 -456
  67. package/types/excalidraw/actions/actionNavigate.d.ts +49 -35
  68. package/types/excalidraw/actions/actionProperties.d.ts +629 -273
  69. package/types/excalidraw/actions/actionSelectAll.d.ts +25 -18
  70. package/types/excalidraw/actions/actionStyles.d.ts +25 -18
  71. package/types/excalidraw/actions/actionToggleGridMode.d.ts +25 -18
  72. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +25 -18
  73. package/types/excalidraw/actions/actionToggleSearchMenu.d.ts +25 -223
  74. package/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  75. package/types/excalidraw/actions/actionToggleStats.d.ts +25 -18
  76. package/types/excalidraw/actions/actionToggleViewMode.d.ts +25 -18
  77. package/types/excalidraw/actions/actionToggleZenMode.d.ts +26 -19
  78. package/types/excalidraw/actions/actionTrayMenu.d.ts +226 -0
  79. package/types/excalidraw/actions/index.d.ts +4 -2
  80. package/types/excalidraw/actions/types.d.ts +4 -3
  81. package/types/excalidraw/appState.d.ts +24 -10
  82. package/types/excalidraw/clipboard.d.ts +68 -5
  83. package/types/excalidraw/components/Actions.d.ts +20 -7
  84. package/types/excalidraw/components/App.d.ts +63 -38
  85. package/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  86. package/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  87. package/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  88. package/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  89. package/types/excalidraw/components/ColorPicker/Picker.d.ts +4 -3
  90. package/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +3 -3
  91. package/types/excalidraw/components/ColorPicker/ShadeList.d.ts +3 -2
  92. package/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  93. package/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  94. package/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  95. package/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
  96. package/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  97. package/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
  98. package/types/excalidraw/components/Ellipsify.d.ts +3 -0
  99. package/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  100. package/types/excalidraw/components/FilledButton.d.ts +1 -1
  101. package/types/excalidraw/components/FixedSideContainer.d.ts +2 -1
  102. package/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  103. package/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
  104. package/types/excalidraw/components/HintViewer.d.ts +4 -3
  105. package/types/excalidraw/components/InlineIcon.d.ts +3 -1
  106. package/types/excalidraw/components/LayerUI.d.ts +2 -1
  107. package/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
  108. package/types/excalidraw/components/LinkButton.d.ts +4 -0
  109. package/types/excalidraw/components/MobileMenu.d.ts +4 -5
  110. package/types/excalidraw/components/MobileToolBar.d.ts +10 -0
  111. package/types/excalidraw/components/Popover.d.ts +2 -1
  112. package/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  113. package/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  114. package/types/excalidraw/components/Range.d.ts +3 -3
  115. package/types/excalidraw/components/Section.d.ts +1 -0
  116. package/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  117. package/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  118. package/types/excalidraw/components/Stats/CanvasGridSize.d.ts +1 -1
  119. package/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  120. package/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  121. package/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
  122. package/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  123. package/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  124. package/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  125. package/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  126. package/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  127. package/types/excalidraw/components/Stats/Position.d.ts +1 -1
  128. package/types/excalidraw/components/Stats/utils.d.ts +4 -11
  129. package/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  130. package/types/excalidraw/components/TextField.d.ts +1 -0
  131. package/types/excalidraw/components/ToolPopover.d.ts +25 -0
  132. package/types/excalidraw/components/TrayMenu.d.ts +26 -0
  133. package/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  134. package/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -2
  135. package/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  136. package/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  137. package/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  138. package/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  139. package/types/excalidraw/components/icons.d.ts +17 -0
  140. package/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +14 -1
  141. package/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
  142. package/types/excalidraw/components/shapes.d.ts +115 -5
  143. package/types/excalidraw/data/blob.d.ts +3 -7
  144. package/types/excalidraw/data/reconcile.d.ts +1 -0
  145. package/types/excalidraw/data/restore.d.ts +6 -1
  146. package/types/excalidraw/data/transform.d.ts +1 -1
  147. package/types/excalidraw/data/types.d.ts +4 -1
  148. package/types/excalidraw/editor-jotai.d.ts +6 -6
  149. package/types/excalidraw/eraser/index.d.ts +12 -0
  150. package/types/excalidraw/fonts/Fonts.d.ts +1 -1
  151. package/types/excalidraw/history.d.ts +30 -22
  152. package/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  153. package/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  154. package/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
  155. package/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  156. package/types/excalidraw/index.d.ts +15 -14
  157. package/types/excalidraw/lasso/index.d.ts +1 -0
  158. package/types/excalidraw/lasso/utils.d.ts +3 -3
  159. package/types/excalidraw/obsidianUtils.d.ts +22 -4
  160. package/types/excalidraw/renderer/helpers.d.ts +7 -2
  161. package/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  162. package/types/excalidraw/renderer/staticScene.d.ts +4 -1
  163. package/types/excalidraw/scene/Renderer.d.ts +1 -2
  164. package/types/excalidraw/scene/index.d.ts +2 -2
  165. package/types/excalidraw/scene/scrollbars.d.ts +2 -3
  166. package/types/excalidraw/scene/types.d.ts +5 -3
  167. package/types/excalidraw/shortcut.d.ts +1 -0
  168. package/types/excalidraw/snapping.d.ts +2 -2
  169. package/types/excalidraw/types.d.ts +68 -30
  170. package/types/excalidraw/webpack.dev.config.d.ts +2 -0
  171. package/types/excalidraw/webpack.prod.config.d.ts +2 -0
  172. package/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
  173. package/types/math/src/angle.d.ts +2 -0
  174. package/types/math/src/constants.d.ts +3 -0
  175. package/types/math/src/curve.d.ts +34 -0
  176. package/types/math/src/index.d.ts +1 -0
  177. package/types/math/src/point.d.ts +1 -1
  178. package/types/math/src/rectangle.d.ts +2 -0
  179. package/types/math/src/segment.d.ts +1 -0
  180. package/types/math/src/types.d.ts +1 -0
  181. package/types/math/src/vector.d.ts +8 -2
  182. package/types/utils/src/bbox.d.ts +1 -1
  183. package/types/utils/src/index.d.ts +1 -1
  184. package/types/utils/src/withinBounds.d.ts +1 -1
  185. package/types/element/src/Shape.d.ts +0 -17
  186. package/types/element/src/ShapeCache.d.ts +0 -25
  187. package/types/element/src/shapes.d.ts +0 -23
  188. package/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  189. package/types/excalidraw/store.d.ts +0 -129
  190. package/types/excalidraw/visualdebug.d.ts +0 -41
  191. package/types/utils/src/collision.d.ts +0 -8
@@ -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, FixedSegment, 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, OrderedExcalidrawElement } 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"];
@@ -12,7 +12,8 @@ export declare const newIframeElement: (opts: {
12
12
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawIframeElement>;
13
13
  export declare const newFrameElement: (opts: {
14
14
  name?: string;
15
- } & ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
15
+ frameRole?: ExcalidrawFrameElement["frameRole"];
16
+ } & ElementConstructorOpts, elements?: readonly OrderedExcalidrawElement[]) => NonDeleted<ExcalidrawFrameElement>;
16
17
  export declare const newMagicFrameElement: (opts: {
17
18
  name?: string;
18
19
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawMagicFrameElement>;
@@ -44,6 +45,7 @@ export declare const newFreeDrawElement: (opts: {
44
45
  export declare const newLinearElement: (opts: {
45
46
  type: ExcalidrawLinearElement["type"];
46
47
  points?: ExcalidrawLinearElement["points"];
48
+ polygon?: ExcalidrawLineElement["polygon"];
47
49
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
48
50
  export declare const newArrowElement: <T extends boolean>(opts: {
49
51
  type: ExcalidrawArrowElement["type"];
@@ -51,8 +53,8 @@ export declare const newArrowElement: <T extends boolean>(opts: {
51
53
  endArrowhead?: Arrowhead | null | undefined;
52
54
  points?: readonly import("@excalidraw/math").LocalPoint[] | undefined;
53
55
  elbowed?: T | undefined;
54
- fixedSegments?: FixedSegment[] | null | undefined;
55
- } & 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>;
56
+ fixedSegments?: readonly import("./types").FixedSegment[] | null | undefined;
57
+ } & 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>;
56
58
  export declare const newImageElement: (opts: {
57
59
  type: ExcalidrawImageElement["type"];
58
60
  status?: ExcalidrawImageElement["status"];
@@ -0,0 +1,2 @@
1
+ import type { ExcalidrawElement } from "./types";
2
+ export declare const positionElementsOnGrid: <TElement extends ExcalidrawElement>(elements: TElement[] | TElement[][], centerX: number, centerY: number, padding?: number) => TElement[];
@@ -1,6 +1,7 @@
1
+ import { type GlobalPoint } from "@excalidraw/math";
1
2
  import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
3
  import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "@excalidraw/excalidraw/scene/types";
3
- import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "./types";
4
+ import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap, ElementsMap } from "./types";
4
5
  import type { RoughCanvas } from "roughjs/bin/canvas";
5
6
  export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
6
7
  export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure, pendingNodes: Readonly<PendingExcalidrawElements> | null, globalAlpha?: number) => number;
@@ -26,3 +27,5 @@ export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
26
27
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
27
28
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
28
29
  export declare function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement): string;
30
+ export declare function getFreedrawOutlineAsSegments(element: ExcalidrawFreeDrawElement, points: [number, number][], elementsMap: ElementsMap): import("@excalidraw/math").LineSegment<GlobalPoint>[];
31
+ export declare function getFreedrawOutlinePoints(element: ExcalidrawFreeDrawElement): [number, number][];
@@ -1,10 +1,10 @@
1
1
  import { type LocalPoint } from "@excalidraw/math";
2
- import type Scene from "@excalidraw/excalidraw/scene/Scene";
3
2
  import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
+ import type { Scene } from "./Scene";
4
4
  import type { BoundingBox } from "./bounds";
5
5
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
6
- import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap, SceneElementsMap } from "./types";
7
- export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: SceneElementsMap, scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
6
+ import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
7
+ export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], scene: Scene, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
8
8
  export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
9
9
  points: LocalPoint[];
10
10
  } | {
@@ -13,14 +13,15 @@ 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
- export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, elementsMap: ElementsMap, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
+ export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
20
  shouldMaintainAspectRatio?: boolean | undefined;
20
21
  shouldResizeFromCenter?: boolean | undefined;
21
22
  shouldInformMutation?: boolean | undefined;
22
23
  }) => void;
23
- export declare const getNextSingleWidthAndHeightFromPointer: (latestElement: ExcalidrawElement, origElement: ExcalidrawElement, elementsMap: ElementsMap, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
24
+ export declare const getNextSingleWidthAndHeightFromPointer: (latestElement: ExcalidrawElement, origElement: ExcalidrawElement, handleDirection: TransformHandleDirection, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
24
25
  shouldMaintainAspectRatio?: boolean | undefined;
25
26
  shouldResizeFromCenter?: boolean | undefined;
26
27
  }) => {
@@ -1,14 +1,15 @@
1
+ import { type EditorInterface } from "@excalidraw/common";
1
2
  import type { GlobalPoint, LocalPoint } from "@excalidraw/math";
2
- import type { AppState, Device, Zoom } from "@excalidraw/excalidraw/types";
3
+ import type { AppState, Zoom } from "@excalidraw/excalidraw/types";
3
4
  import type { Bounds } from "./bounds";
4
5
  import type { MaybeTransformHandleType } from "./transformHandles";
5
6
  import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
6
- export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
7
- export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
7
+ export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, editorInterface: EditorInterface) => MaybeTransformHandleType;
8
+ export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, editorInterface: EditorInterface) => {
8
9
  element: NonDeletedExcalidrawElement;
9
10
  transformHandleType: MaybeTransformHandleType;
10
11
  } | null;
11
- export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
12
+ export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, editorInterface: EditorInterface) => MaybeTransformHandleType;
12
13
  export declare const getCursorForResizingElement: (resizingElement: {
13
14
  element?: ExcalidrawElement;
14
15
  transformHandleType: MaybeTransformHandleType;
@@ -1,4 +1,5 @@
1
1
  import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
+ import { LinearElementEditor } from "./linearElementEditor";
2
3
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "./types";
3
4
  /**
4
5
  * Frames and their containing elements are not to be selected at the same time.
@@ -13,11 +14,6 @@ export declare const isSomeElementSelected: {
13
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
14
15
  clearCache(): void;
15
16
  };
16
- /**
17
- * Returns common attribute (picked by `getAttribute` callback) of selected
18
- * elements. If elements don't share the same value, returns `null`.
19
- */
20
- export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
21
17
  export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
22
18
  includeBoundTextElement?: boolean;
23
19
  includeElementsInFrames?: boolean;
@@ -30,3 +26,13 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
30
26
  export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
31
27
  [id: string]: true;
32
28
  }>;
29
+ export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
30
+ editingGroupId: string | null;
31
+ selectedElementIds: Readonly<{
32
+ [id: string]: true;
33
+ }>;
34
+ selectedGroupIds: {
35
+ [groupId: string]: boolean;
36
+ };
37
+ selectedLinearElement: LinearElementEditor | null;
38
+ };
@@ -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,11 +23,10 @@ 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
  };
29
- export declare const resizePerfectLineForNWHandler: (element: ExcalidrawElement, x: number, y: number) => void;
30
30
  export declare const getNormalizedDimensions: (element: Pick<ExcalidrawElement, "width" | "height" | "x" | "y">) => {
31
31
  width: ExcalidrawElement["width"];
32
32
  height: ExcalidrawElement["height"];
@@ -0,0 +1,237 @@
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 }, appState: { delta: appStateDelta }, }: DTO<StoreDelta>): StoreDelta;
173
+ /**
174
+ * Squash the passed deltas into the aggregated delta instance.
175
+ */
176
+ static squash(...deltas: StoreDelta[]): StoreDelta;
177
+ /**
178
+ * Inverse store delta, creates new instance of `StoreDelta`.
179
+ */
180
+ static inverse(delta: StoreDelta): StoreDelta;
181
+ /**
182
+ * Apply the delta to the passed elements and appState, does not modify the snapshot.
183
+ */
184
+ static applyTo(delta: StoreDelta, elements: SceneElementsMap, appState: AppState, options?: ApplyToOptions): [SceneElementsMap, AppState, boolean];
185
+ /**
186
+ * Apply latest (remote) changes to the delta, creates new instance of `StoreDelta`.
187
+ */
188
+ static applyLatestChanges(delta: StoreDelta, prevElements: SceneElementsMap, nextElements: SceneElementsMap, modifierOptions?: "deleted" | "inserted"): StoreDelta;
189
+ static empty(): StoreDelta;
190
+ isEmpty(): boolean;
191
+ }
192
+ /**
193
+ * Represents a snapshot of the captured or updated changes in the store,
194
+ * used for producing deltas and emitting `DurableStoreIncrement`s.
195
+ */
196
+ export declare class StoreSnapshot {
197
+ readonly elements: SceneElementsMap;
198
+ readonly appState: ObservedAppState;
199
+ readonly metadata: {
200
+ didElementsChange: boolean;
201
+ didAppStateChange: boolean;
202
+ isEmpty?: boolean;
203
+ };
204
+ private _lastChangedElementsHash;
205
+ private _lastChangedAppStateHash;
206
+ private constructor();
207
+ static create(elements: SceneElementsMap, appState: AppState | ObservedAppState, metadata?: {
208
+ didElementsChange: boolean;
209
+ didAppStateChange: boolean;
210
+ }): StoreSnapshot;
211
+ static empty(): StoreSnapshot;
212
+ getChangedElements(prevSnapshot: StoreSnapshot): Record<string, OrderedExcalidrawElement>;
213
+ getChangedAppState(prevSnapshot: StoreSnapshot): Partial<ObservedAppState>;
214
+ isEmpty(): boolean | undefined;
215
+ /**
216
+ * Apply the change and return a new snapshot instance.
217
+ */
218
+ applyChange(change: StoreChange): StoreSnapshot;
219
+ /**
220
+ * Efficiently clone the existing snapshot, only if we detected changes.
221
+ *
222
+ * @returns same instance if there are no changes detected, new instance otherwise.
223
+ */
224
+ maybeClone(action: CaptureUpdateActionType, elements: SceneElementsMap | undefined, appState: AppState | ObservedAppState | undefined): StoreSnapshot;
225
+ private maybeCreateAppStateSnapshot;
226
+ private maybeCreateElementsSnapshot;
227
+ private detectChangedAppState;
228
+ /**
229
+ * Detect if there are any changed elements.
230
+ */
231
+ private detectChangedElements;
232
+ /**
233
+ * Perform structural clone, deep cloning only elements that changed.
234
+ */
235
+ private createElementsSnapshot;
236
+ }
237
+ export declare const getObservedAppState: (appState: AppState | ObservedAppState) => ObservedAppState;
@@ -1,9 +1,11 @@
1
+ import { type Radians } from "@excalidraw/math";
1
2
  import type { AppState } from "@excalidraw/excalidraw/types";
2
3
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
4
+ import type { Scene } from "./Scene";
3
5
  import type { MaybeTransformHandleType } from "./transformHandles";
4
6
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeletedExcalidrawElement } from "./types";
5
- export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
6
- export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
7
+ export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
8
+ export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
7
9
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
8
10
  x: number;
9
11
  y: number;
@@ -19,7 +21,7 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
19
21
  x: number;
20
22
  y: number;
21
23
  };
22
- export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => import("../../math/src").Radians;
24
+ export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => 0 | Radians;
23
25
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
24
26
  x: number;
25
27
  y: number;
@@ -1,5 +1,6 @@
1
+ import { type EditorInterface } from "@excalidraw/common";
1
2
  import type { Radians } from "@excalidraw/math";
2
- import type { Device, InteractiveCanvasAppState, Zoom } from "@excalidraw/excalidraw/types";
3
+ import type { InteractiveCanvasAppState, Zoom } from "@excalidraw/excalidraw/types";
3
4
  import type { Bounds } from "./bounds";
4
5
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
5
6
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
@@ -28,8 +29,8 @@ export declare const OMIT_SIDES_FOR_FRAME: {
28
29
  w: boolean;
29
30
  rotation: boolean;
30
31
  };
31
- export declare const canResizeFromSides: (device: Device) => boolean;
32
- export declare const getOmitSidesForDevice: (device: Device) => {};
32
+ export declare const canResizeFromSides: (editorInterface: EditorInterface) => boolean;
33
+ export declare const getOmitSidesForEditorInterface: (editorInterface: EditorInterface) => {};
33
34
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: Radians, zoom: Zoom, pointerType: PointerType, omitSides?: {
34
35
  s?: boolean | undefined;
35
36
  n?: boolean | undefined;
@@ -52,4 +53,4 @@ export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoo
52
53
  se?: boolean | undefined;
53
54
  rotation?: boolean | undefined;
54
55
  }) => TransformHandles;
55
- export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
56
+ export declare const hasBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState, editorInterface: EditorInterface) => boolean;
@@ -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,15 @@ 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;
24
+ export declare const isSharpArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
25
+ export declare const isCurvedArrow: (element?: ExcalidrawElement) => element is ExcalidrawArrowElement;
19
26
  export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
20
27
  export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
21
28
  export declare const isBindingElementType: (elementType: ElementOrToolType) => boolean;
@@ -27,6 +34,7 @@ export declare const isExcalidrawElement: (element: any) => element is Excalidra
27
34
  export declare const isFlowchartNodeElement: (element: ExcalidrawElement) => element is ExcalidrawFlowchartNodeElement;
28
35
  export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
29
36
  export declare const isBoundToContainer: (element: ExcalidrawElement | null) => element is ExcalidrawTextElementWithContainer;
37
+ export declare const isArrowBoundToElement: (element: ExcalidrawArrowElement) => boolean;
30
38
  export declare const isUsingAdaptiveRadius: (type: string) => boolean;
31
39
  export declare const isUsingProportionalRadius: (type: string) => boolean;
32
40
  export declare const canApplyRoundnessTypeToElement: (roundnessType: RoundnessType, element: ExcalidrawElement) => boolean;
@@ -37,3 +45,13 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
37
45
  } | null;
38
46
  export declare const isFixedPointBinding: (binding: PointBinding | FixedPointBinding) => binding is FixedPointBinding;
39
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;
@@ -139,13 +139,23 @@ export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
139
139
  crop: ImageCrop | null;
140
140
  }>;
141
141
  export type InitializedExcalidrawImageElement = MarkNonNullable<ExcalidrawImageElement, "fileId">;
142
+ type FrameRole = null | "marker";
142
143
  export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
143
144
  type: "frame";
144
145
  name: string | null;
146
+ frameRole?: FrameRole;
147
+ customData?: {
148
+ frameColor?: {
149
+ fill: string;
150
+ stroke: string;
151
+ nameColor: string;
152
+ };
153
+ };
145
154
  };
146
155
  export type ExcalidrawMagicFrameElement = _ExcalidrawElementBase & {
147
156
  type: "magicframe";
148
157
  name: string | null;
158
+ frameRole?: FrameRole;
149
159
  };
150
160
  export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagicFrameElement;
151
161
  /**
@@ -153,7 +163,7 @@ export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagi
153
163
  */
154
164
  export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
155
165
  export type ExcalidrawFlowchartNodeElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
156
- export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement;
166
+ export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawSelectionElement;
157
167
  /**
158
168
  * ExcalidrawElement should be JSON serializable and (eventually) contain
159
169
  * no computed data. The list of all ExcalidrawElements should be shareable
@@ -208,6 +218,11 @@ export type PointBinding = {
208
218
  export type FixedPointBinding = Merge<PointBinding, {
209
219
  fixedPoint: FixedPoint;
210
220
  }>;
221
+ type Index = number;
222
+ export type PointsPositionUpdates = Map<Index, {
223
+ point: LocalPoint;
224
+ isDragging?: boolean;
225
+ }>;
211
226
  export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | "crowfoot_one" | "crowfoot_many" | "crowfoot_one_or_many";
212
227
  export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
213
228
  type: "line" | "arrow";
@@ -218,10 +233,14 @@ export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
218
233
  startArrowhead: Arrowhead | null;
219
234
  endArrowhead: Arrowhead | null;
220
235
  }>;
236
+ export type ExcalidrawLineElement = ExcalidrawLinearElement & Readonly<{
237
+ type: "line";
238
+ polygon: boolean;
239
+ }>;
221
240
  export type FixedSegment = {
222
241
  start: LocalPoint;
223
242
  end: LocalPoint;
224
- index: number;
243
+ index: Index;
225
244
  };
226
245
  export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
227
246
  type: "arrow";
@@ -282,4 +301,8 @@ export type SceneElementsMap = Map<ExcalidrawElement["id"], Ordered<ExcalidrawEl
282
301
  */
283
302
  export type NonDeletedSceneElementsMap = Map<ExcalidrawElement["id"], Ordered<NonDeletedExcalidrawElement>> & MakeBrand<"NonDeletedSceneElementsMap">;
284
303
  export type ElementsMapOrArray = readonly ExcalidrawElement[] | Readonly<ElementsMap>;
304
+ export type ExcalidrawLinearElementSubType = "line" | "sharpArrow" | "curvedArrow" | "elbowArrow";
305
+ export type ConvertibleGenericTypes = "rectangle" | "diamond" | "ellipse";
306
+ export type ConvertibleLinearTypes = ExcalidrawLinearElementSubType;
307
+ export type ConvertibleTypes = ConvertibleGenericTypes | ConvertibleLinearTypes;
285
308
  export {};