@myoc/common 0.19.520 → 0.19.522

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 (154) hide show
  1. package/dist/dev/index.js +62 -7
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/colors.d.ts +14 -0
  5. package/dist/types/common/src/constants.d.ts +3 -0
  6. package/dist/types/common/src/keys.d.ts +2 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/utils.d.ts +1 -1
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/align.d.ts +2 -2
  11. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  12. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  13. package/dist/types/element/src/binding.d.ts +17 -8
  14. package/dist/types/element/src/bounds.d.ts +5 -9
  15. package/dist/types/element/src/bucketFill.d.ts +110 -0
  16. package/dist/types/element/src/collision.d.ts +1 -1
  17. package/dist/types/element/src/comparisons.d.ts +4 -4
  18. package/dist/types/element/src/convertToShape.d.ts +23 -0
  19. package/dist/types/element/src/distribute.d.ts +2 -2
  20. package/dist/types/element/src/dragElements.d.ts +27 -0
  21. package/dist/types/element/src/duplicate.d.ts +3 -3
  22. package/dist/types/element/src/embeddable.d.ts +2 -2
  23. package/dist/types/element/src/flowchart.d.ts +7 -7
  24. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  25. package/dist/types/element/src/frame.d.ts +4 -4
  26. package/dist/types/element/src/groups.d.ts +9 -9
  27. package/dist/types/element/src/index.d.ts +4 -1
  28. package/dist/types/element/src/linearElementEditor.d.ts +17 -10
  29. package/dist/types/element/src/newElement.d.ts +13 -0
  30. package/dist/types/element/src/renderElement.d.ts +0 -3
  31. package/dist/types/element/src/resizeElements.d.ts +2 -2
  32. package/dist/types/element/src/selection.d.ts +5 -5
  33. package/dist/types/element/src/shape.d.ts +12 -0
  34. package/dist/types/element/src/sortElements.d.ts +10 -0
  35. package/dist/types/element/src/textElement.d.ts +12 -9
  36. package/dist/types/element/src/transform.d.ts +2 -2
  37. package/dist/types/element/src/typeChecks.d.ts +25 -25
  38. package/dist/types/element/src/types.d.ts +2 -1
  39. package/dist/types/element/src/zindex.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  41. package/dist/types/excalidraw/actions/actionBoundText.d.ts +24 -8
  42. package/dist/types/excalidraw/actions/actionCanvas.d.ts +128 -961
  43. package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -8
  44. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -4
  45. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -13
  46. package/dist/types/excalidraw/actions/actionDeselect.d.ts +9 -4
  47. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  48. package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -4
  49. package/dist/types/excalidraw/actions/actionElementLock.d.ts +25 -9
  50. package/dist/types/excalidraw/actions/actionExport.d.ts +29 -13
  51. package/dist/types/excalidraw/actions/actionFrame.d.ts +47 -205
  52. package/dist/types/excalidraw/actions/actionGroup.d.ts +39 -23
  53. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -6
  54. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -5
  55. package/dist/types/excalidraw/actions/actionMenu.d.ts +12 -4
  56. package/dist/types/excalidraw/actions/actionProperties.d.ts +43 -24
  57. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -9
  58. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -4
  59. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  60. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +14 -6
  61. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -9
  62. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +13 -5
  63. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -5
  64. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -9
  65. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -5
  66. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -6
  67. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -5
  68. package/dist/types/excalidraw/actions/index.d.ts +1 -2
  69. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  70. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  71. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  72. package/dist/types/excalidraw/appState.d.ts +11 -6
  73. package/dist/types/excalidraw/clipboard.d.ts +34 -0
  74. package/dist/types/excalidraw/components/Actions.d.ts +17 -12
  75. package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
  76. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  77. package/dist/types/excalidraw/components/App.cursor.d.ts +30 -0
  78. package/dist/types/excalidraw/components/App.d.ts +384 -60
  79. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  80. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  81. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  82. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  83. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  84. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
  85. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  86. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  87. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  88. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  89. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
  90. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  91. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  92. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  93. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  94. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  95. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  96. package/dist/types/excalidraw/components/LockButton.d.ts +9 -0
  97. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  98. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  99. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  100. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  101. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  102. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  103. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  104. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  105. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  106. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  107. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  108. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  109. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  110. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  111. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  112. package/dist/types/excalidraw/components/Tools.d.ts +146 -0
  113. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  114. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  115. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -0
  116. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  117. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  118. package/dist/types/excalidraw/components/icons.d.ts +4 -1
  119. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  120. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  121. package/dist/types/excalidraw/context/tunnels.d.ts +0 -1
  122. package/dist/types/excalidraw/data/blob.d.ts +17 -9
  123. package/dist/types/excalidraw/data/index.d.ts +4 -4
  124. package/dist/types/excalidraw/data/json.d.ts +23 -15
  125. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  126. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  127. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  128. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +10 -3
  129. package/dist/types/excalidraw/scene/Renderer.d.ts +11 -11
  130. package/dist/types/excalidraw/scene/export.d.ts +3 -3
  131. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  132. package/dist/types/excalidraw/scene/types.d.ts +4 -3
  133. package/dist/types/excalidraw/snapping.d.ts +7 -7
  134. package/dist/types/excalidraw/types.d.ts +425 -27
  135. package/dist/types/excalidraw/viewport.d.ts +283 -0
  136. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
  137. package/dist/types/laser-pointer/src/state.d.ts +1 -0
  138. package/dist/types/math/src/index.d.ts +1 -0
  139. package/dist/types/math/src/pca.d.ts +79 -0
  140. package/dist/types/math/src/polygon.d.ts +25 -1
  141. package/dist/types/utils/src/export.d.ts +3 -3
  142. package/package.json +1 -1
  143. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -180
  144. package/dist/types/excalidraw/actions/actionSmartZoom.d.ts +0 -16
  145. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +0 -27
  146. package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +0 -7
  147. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  148. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  149. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -10
  150. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -12
  151. package/dist/types/excalidraw/cursor.d.ts +0 -5
  152. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  153. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  154. package/dist/types/excalidraw/scroll.d.ts +0 -46
@@ -0,0 +1,110 @@
1
+ import type { GlobalPoint } from "@excalidraw/math";
2
+ import type { ElementsMap, ExcalidrawElement, ExcalidrawLineElement, NonDeletedExcalidrawElement } from "./types";
3
+ export type BucketFillOptions = {
4
+ /**
5
+ * geometric fidelity: vertices closer than this collapse to the same graph
6
+ * node, and a node this close to a stroke splits it (T-junction). Keep
7
+ * SMALL — every merge can relocate a vertex by up to this distance, so
8
+ * this value is the upper bound on how far the filled shape may deviate
9
+ * from the actual strokes.
10
+ */
11
+ snapEpsilon: number;
12
+ /**
13
+ * connectivity: loose stroke ends within this distance of another stroke
14
+ * are bridged with a connector edge so the region reads as closed. Also
15
+ * used as broad-phase padding around the owner bounds. Unlike
16
+ * `snapEpsilon` this does not affect the shape's fidelity (bridges add
17
+ * edges; they never move existing vertices).
18
+ */
19
+ gapTolerance: number;
20
+ /** discard faces / polygons smaller than this absolute area */
21
+ minArea: number;
22
+ /** bail out with `too_complex` above this many input segments */
23
+ maxBoundarySegments: number;
24
+ /** cap on the number of generated polygon points */
25
+ maxGeneratedPoints: number;
26
+ /**
27
+ * initial half-extent of the owner-less search box around the click
28
+ * (doubles up to 3 times while the found face touches the box frontier)
29
+ */
30
+ fallbackSearchRadius: number;
31
+ };
32
+ export declare const DEFAULT_BUCKET_FILL_OPTIONS: BucketFillOptions;
33
+ export type BucketFillFailureReason = "no_owner" | "open_region" | "too_complex" | "too_small" | "invalid_polygon";
34
+ /**
35
+ * Where the generated fill element belongs in the scene order, expressed
36
+ * relative to an existing element so the caller can resolve it against
37
+ * whatever (e.g. deleted-inclusive) array it inserts into.
38
+ */
39
+ export type BucketFillInsertion = {
40
+ placement: "above" | "below";
41
+ elementId: ExcalidrawElement["id"];
42
+ };
43
+ export type BucketFillGeometryResult = {
44
+ ok: true;
45
+ /**
46
+ * the closed element under the click, or null for fills resolved by
47
+ * the owner-less fallback (regions formed by open lines)
48
+ */
49
+ ownerId: ExcalidrawElement["id"] | null;
50
+ boundaryElementIds: ExcalidrawElement["id"][];
51
+ /**
52
+ * closed polygon ring in scene coordinates. When the region contains
53
+ * islands, this is a keyhole path: the hole contours are spliced in
54
+ * via zero-width bridges, so it still renders as one polygon with
55
+ * unpainted hole interiors
56
+ */
57
+ scenePoints: GlobalPoint[];
58
+ insertion: BucketFillInsertion;
59
+ } | {
60
+ ok: false;
61
+ reason: BucketFillFailureReason;
62
+ };
63
+ /**
64
+ * Whether the element visually paints an opaque background fill — i.e. can
65
+ * actually hide outlines beneath it. Element types that never render their
66
+ * `backgroundColor` (text, image, frames), see-through fill styles
67
+ * (hachure/cross-hatch), partial element opacity, and colors with an alpha
68
+ * channel below 1 (`#RRGGBBAA`, `rgba(…)`) all don't count — anything under
69
+ * them shows through.
70
+ *
71
+ * Shared with the app layer's z-order pass so "covers" means the same thing
72
+ * in boundary clipping and in fill insertion.
73
+ */
74
+ export declare const rendersOpaqueFill: (element: ExcalidrawElement) => boolean;
75
+ /**
76
+ * Whether the element renders as pure paint the bucket tool could have
77
+ * produced: a closed, visible line polygon with a background and no visible
78
+ * stroke. Recognition is by SHAPE, not by a metadata marker — any marker
79
+ * would go stale the moment the user restyles a fill, and a hand-drawn
80
+ * strokeless background polygon is indistinguishable from a generated fill
81
+ * anyway. Such paint never becomes an owner and is what the app layer
82
+ * restyles in place on re-click (see `isRestylableFill`).
83
+ */
84
+ export declare const isBucketFillCompatible: (element: ExcalidrawElement) => element is ExcalidrawLineElement;
85
+ export declare const computeBucketFillPolygon: (args: {
86
+ point: GlobalPoint;
87
+ elements: readonly NonDeletedExcalidrawElement[];
88
+ elementsMap: ElementsMap;
89
+ options?: Partial<BucketFillOptions>;
90
+ }) => BucketFillGeometryResult;
91
+ /**
92
+ * Whether the element the click landed on is a fill the bucket tool should
93
+ * restyle in place (instead of stacking an identical fill on top), given
94
+ * the computed region.
95
+ *
96
+ * Fill-compatibility is decided by shape (`isBucketFillCompatible`): a fill
97
+ * the user gave a stroke to has been repurposed into an outline and
98
+ * participates as a boundary instead of being restyled.
99
+ *
100
+ * One guard on top: the computed region's net area and bounds must match
101
+ * the element's. Without it, a click inside a shape drawn ON TOP of a
102
+ * filled region would recolor the underlying fill instead of filling that
103
+ * shape; a click on a since-subdivided part of an old fill likewise
104
+ * creates a new (smaller) fill rather than restyling the old one.
105
+ */
106
+ export declare const isRestylableFill: (args: {
107
+ hitElement: ExcalidrawElement;
108
+ scenePoints: readonly GlobalPoint[];
109
+ elementsMap: ElementsMap;
110
+ }) => boolean;
@@ -16,7 +16,7 @@ export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsM
16
16
  export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
17
17
  export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement>[];
18
18
  export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
19
- export declare const getHoveredElementForFocusPoint: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => ExcalidrawBindableElement | null;
19
+ export declare const getHoveredElementForFocusPoint: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
20
20
  /**
21
21
  * Intersect a line with an element for binding test
22
22
  *
@@ -1,8 +1,8 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
- export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw";
4
- export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
5
- export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe";
2
+ export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
3
+ export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
4
+ export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
5
+ export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
6
6
  export declare const hasFreedrawMode: (type: ElementOrToolType) => type is "freedraw";
7
7
  export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "embeddable" | "iframe" | "image";
8
8
  export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
@@ -0,0 +1,23 @@
1
+ import type { App, AppState } from "@excalidraw/excalidraw/types";
2
+ import type { LocalPoint, GlobalPoint } from "@excalidraw/math";
3
+ import type { Bounds } from "@excalidraw/common";
4
+ import type { ExcalidrawArrowElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, ExcalidrawRectangleElement, ElementsMap, NonDeleted, ExcalidrawLineElement } from "@excalidraw/element/types";
5
+ declare global {
6
+ interface Window {
7
+ LAST_POINTS?: readonly GlobalPoint[];
8
+ }
9
+ }
10
+ type NonDeletedRecognizedShapeElement = NonDeleted<ExcalidrawRectangleElement | ExcalidrawEllipseElement | ExcalidrawDiamondElement | ExcalidrawArrowElement | ExcalidrawLineElement | ExcalidrawFreeDrawElement>;
11
+ type Shape = NonDeletedRecognizedShapeElement["type"];
12
+ interface ShapeRecognitionResult<P extends LocalPoint | GlobalPoint> {
13
+ type: Shape;
14
+ points: readonly P[];
15
+ boundingBox: Bounds;
16
+ }
17
+ export declare const recognizeShape: <P extends LocalPoint | GlobalPoint>(points: P[], previousElement: ExcalidrawElement | null, zoom?: number) => ShapeRecognitionResult<P>;
18
+ export declare const convertToShape: (points: GlobalPoint[], appState: AppState, elementsMap: ElementsMap, previousElement: ExcalidrawElement | null, frames?: readonly ExcalidrawFrameLikeElement[]) => NonDeletedRecognizedShapeElement | undefined;
19
+ export declare const convertToShapeHandlePointerMoveFromPointerDown: (app: App, pointerCoords: {
20
+ x: number;
21
+ y: number;
22
+ }) => boolean;
23
+ export {};
@@ -1,8 +1,8 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
2
  import type { Scene } from "./Scene";
3
- import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
4
4
  export interface Distribution {
5
5
  space: "between";
6
6
  axis: "x" | "y";
7
7
  }
8
- export declare const distributeElements: (selectedElements: ExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => ExcalidrawElement[];
8
+ export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => NonDeletedExcalidrawElement[];
@@ -1,6 +1,7 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  import type { Scene } from "./Scene";
4
+ import type { ExcalidrawTextElement } from "./types";
4
5
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
5
6
  x: number;
6
7
  y: number;
@@ -9,6 +10,32 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
9
10
  y: number;
10
11
  }, gridSize: NullableGridSize) => void;
11
12
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
13
+ /**
14
+ * Sizes a text element as it is dragged out.
15
+ *
16
+ * A dragged text pins one point and grows away from it; `anchorRatio` says
17
+ * where along the box that point sits — 0 for its left edge, 1 for its right,
18
+ * 0.5 for its centre.
19
+ *
20
+ * A free text pins the point the drag started from and takes the ratio from
21
+ * the drag direction, so it can be pulled either way. A text bound to an arrow
22
+ * endpoint instead pins whatever the binding placed it against and takes the
23
+ * ratio from its alignment — which is also what keeps it from growing back
24
+ * over the arrow, since dragging that way makes no progress rather than
25
+ * flipping the box around.
26
+ */
27
+ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, informMutation, }: {
28
+ newElement: ExcalidrawTextElement;
29
+ anchorX: number;
30
+ /** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
31
+ anchorRatio: number;
32
+ pointerX: number;
33
+ /** free text re-tops itself to the drag origin; a bound one must not move */
34
+ nextY?: number;
35
+ zoom: NormalizedZoomValue;
36
+ scene: Scene;
37
+ informMutation?: boolean;
38
+ }) => void;
12
39
  export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
13
40
  newElement: NonDeletedExcalidrawElement;
14
41
  elementType: AppState["activeTool"]["type"];
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { AppState } from "@excalidraw/excalidraw/types";
3
- import type { ExcalidrawElement, GroupId } from "./types";
3
+ import type { ExcalidrawElement, GroupId, NonDeletedExcalidrawElement } from "./types";
4
4
  /**
5
5
  * Duplicate an element, often used in the alt-drag operation.
6
6
  * Note that this method has gotten a bit complicated since the
@@ -47,8 +47,8 @@ export declare const duplicateElements: (opts: {
47
47
  selectedGroupIds: AppState["selectedGroupIds"];
48
48
  };
49
49
  })) => {
50
- duplicatedElements: ExcalidrawElement[];
51
- duplicateElementsMap: Map<string, ExcalidrawElement>;
50
+ duplicatedElements: NonDeletedExcalidrawElement[];
51
+ duplicateElementsMap: Map<string, NonDeletedExcalidrawElement>;
52
52
  elementsWithDuplicates: ExcalidrawElement[];
53
53
  origIdToDuplicateId: Map<string, string>;
54
54
  };
@@ -1,10 +1,10 @@
1
1
  import type { ExcalidrawProps } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkRequired } from "@excalidraw/common/utility-types";
3
- import type { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
3
+ import type { ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
4
4
  type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
5
5
  export declare const createSrcDoc: (body: string) => string;
6
6
  export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
7
- export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => ExcalidrawElement;
7
+ export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => NonDeletedExcalidrawElement;
8
8
  export declare const maybeParseEmbedSrc: (str: string) => string;
9
9
  export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
10
10
  export {};
@@ -1,10 +1,7 @@
1
1
  import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
- import { type ElementsMap, type ExcalidrawBindableElement, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
2
+ import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
3
3
  import type { Scene } from "./Scene";
4
- type LinkDirection = "up" | "right" | "down" | "left";
5
- export declare const getLinkDirectionFromKey: (key: string) => LinkDirection;
6
- export declare const getPredecessors: (node: ExcalidrawBindableElement, elementsMap: ElementsMap, direction: LinkDirection) => ExcalidrawBindableElement[];
7
- export declare const addNewNodes: (startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number) => ExcalidrawElement[];
4
+ export type LinkDirection = "up" | "right" | "down" | "left";
8
5
  export declare class FlowChartNavigator {
9
6
  isExploring: boolean;
10
7
  private sameLevelNodes;
@@ -13,14 +10,17 @@ export declare class FlowChartNavigator {
13
10
  private visitedNodes;
14
11
  clear(): void;
15
12
  exploreByDirection(element: ExcalidrawElement, elementsMap: ElementsMap, direction: LinkDirection): ExcalidrawElement["id"] | null;
13
+ private static getNodeRelatives;
14
+ private static getSuccessors;
15
+ private static getPredecessors;
16
16
  }
17
17
  export declare class FlowChartCreator {
18
18
  isCreatingChart: boolean;
19
19
  private numberOfNodes;
20
20
  private direction;
21
+ private clusterCrossStart;
21
22
  pendingNodes: PendingExcalidrawElements | null;
22
- createNodes(startNode: ExcalidrawFlowchartNodeElement, appState: AppState, direction: LinkDirection, scene: Scene): void;
23
+ createNodes(startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene): void;
23
24
  clear(): void;
24
25
  }
25
26
  export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
26
- export {};
@@ -1,4 +1,4 @@
1
- import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
1
+ import type { ElementsMap, ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  export declare class InvalidFractionalIndexError extends Error {
3
3
  code: "ELEMENT_HAS_INVALID_INDEX";
4
4
  }
@@ -48,7 +48,7 @@ export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[],
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
- export declare const syncInvalidIndices: (elements: readonly ExcalidrawElement[]) => OrderedExcalidrawElement[];
51
+ export declare const syncInvalidIndices: <T extends ExcalidrawElement>(elements: readonly T[]) => Ordered<T>[];
52
52
  /**
53
53
  * Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
54
54
  *
@@ -29,7 +29,7 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
29
29
  *
30
30
  * Considers non-frame bound elements (container or arrow labels) as root.
31
31
  */
32
- export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
32
+ export declare const getRootElements: <T extends ExcalidrawElement>(allElements: readonly T[]) => T[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
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
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)[];
@@ -44,8 +44,8 @@ export declare const getFrameChildrenInsertionIndex: (elements: readonly Excalid
44
44
  *
45
45
  * @returns mutated allElements (same data structure)
46
46
  */
47
- export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
48
- export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<NonDeletedExcalidrawElement>, elementsMap: ElementsMap) => void;
47
+ export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
48
+ export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<ExcalidrawElement>, elementsMap: ElementsMap) => void;
49
49
  export declare const removeAllElementsFromFrame: <T extends ExcalidrawElement>(allElements: readonly T[], frame: ExcalidrawFrameLikeElement) => readonly T[];
50
50
  export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T[];
51
51
  /** does not mutate elements, but returns new ones */
@@ -71,5 +71,5 @@ export declare const isElementInFrame: (element: ExcalidrawElement, allElementsM
71
71
  export declare const shouldApplyFrameClip: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, appState: StaticCanvasAppState, elementsMap: ElementsMap, checkedGroups?: Map<string, boolean>) => boolean;
72
72
  export declare const getDefaultFrameName: (element: ExcalidrawFrameLikeElement) => "Frame" | "AI Frame";
73
73
  export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement) => string;
74
- export declare const getElementsOverlappingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
74
+ export declare const getElementsOverlappingFrame: <T extends ExcalidrawElement>(elements: readonly T[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => T[];
75
75
  export declare const frameAndChildrenSelectedTogether: (selectedElements: readonly ExcalidrawElement[]) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { AppClassProperties, AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
2
  import type { Mutable } from "@excalidraw/common/utility-types";
3
- import type { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ElementsMapOrArray, ElementsMap } from "./types";
4
- export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
3
+ import type { GroupId, ExcalidrawElement, NonDeleted, ElementsMapOrArray, ElementsMap, NonDeletedExcalidrawElement, NonDeletedElementsMapOrArray } from "./types";
4
+ export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeletedExcalidrawElement[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
5
5
  export declare const selectGroupsForSelectedElements: {
6
6
  (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
7
7
  clearCache(): void;
@@ -10,15 +10,15 @@ export declare const selectGroupsForSelectedElements: {
10
10
  * If the element's group is selected, don't render an individual
11
11
  * selection border around it.
12
12
  */
13
- export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
13
+ export declare const isSelectedViaGroup: (appState: Pick<InteractiveCanvasAppState, "editingGroupId" | "selectedGroupIds">, element: ExcalidrawElement) => boolean;
14
14
  export declare const getSelectedGroupForElement: (appState: Pick<InteractiveCanvasAppState, "editingGroupId" | "selectedGroupIds">, element: ExcalidrawElement) => string | undefined;
15
- export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
16
- export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
15
+ export declare const getSelectedGroupIds: (appState: Pick<InteractiveCanvasAppState, "selectedGroupIds">) => GroupId[];
16
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => {
17
17
  [groupId: string]: boolean;
18
18
  };
19
19
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
20
20
  export declare const isElementInGroup: (element: ExcalidrawElement, groupId: string) => boolean;
21
- export declare const getElementsInGroup: (elements: ElementsMapOrArray, groupId: string) => ExcalidrawElement[];
21
+ export declare const getElementsInGroup: <P extends NonDeletedExcalidrawElement | ExcalidrawElement>(elements: P extends NonDeletedExcalidrawElement ? NonDeletedElementsMapOrArray : ElementsMapOrArray, groupId: string) => P[];
22
22
  export declare const getSelectedGroupIdForElement: (element: ExcalidrawElement, selectedGroupIds: {
23
23
  [groupId: string]: boolean;
24
24
  }) => string | undefined;
@@ -26,9 +26,9 @@ export declare const addToGroup: (prevGroupIds: ExcalidrawElement["groupIds"], n
26
26
  export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["groupIds"], selectedGroupIds: {
27
27
  [groupId: string]: boolean;
28
28
  }) => string[];
29
- export declare const getMaximumGroups: (elements: ExcalidrawElement[], elementsMap: ElementsMap) => ExcalidrawElement[][];
29
+ export declare const getMaximumGroups: <T extends NonDeletedExcalidrawElement | ExcalidrawElement>(elements: T[], elementsMap: ElementsMap) => T[][];
30
30
  export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<string>;
31
31
  export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
32
- export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
32
+ export declare const isInGroup: (element: ExcalidrawElement) => 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[][];
34
+ export declare const getSelectedElementsByGroup: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, appState: Readonly<Pick<AppState, "selectedGroupIds" | "editingGroupId">>) => NonDeletedExcalidrawElement[][];
@@ -8,13 +8,15 @@ export declare const getSceneVersion: (elements: readonly ExcalidrawElement[]) =
8
8
  */
9
9
  export declare const hashElementsVersion: (elements: ElementsMapOrArray) => number;
10
10
  export declare const hashString: (s: string) => number;
11
+ export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
11
12
  export declare const getVisibleElements: (elements: readonly ExcalidrawElement[]) => readonly NonDeletedExcalidrawElement[];
12
13
  export declare const getNonDeletedElements: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly NonDeleted<T>[];
13
- export declare const isNonDeletedElement: <T extends ExcalidrawElement>(element: T) => element is NonDeleted<T>;
14
14
  export * from "./align";
15
15
  export * from "./arrange";
16
+ export * from "./arrowEndpointText";
16
17
  export * from "./binding";
17
18
  export * from "./bounds";
19
+ export * from "./bucketFill";
18
20
  export * from "./collision";
19
21
  export * from "./comparisons";
20
22
  export * from "./containerCache";
@@ -60,3 +62,4 @@ export * from "./utils";
60
62
  export * from "./zindex";
61
63
  export * from "./arrows/helpers";
62
64
  export * from "./arrowheads";
65
+ export * from "./convertToShape";
@@ -22,6 +22,7 @@ export declare class LinearElementEditor {
22
22
  };
23
23
  arrowStartIsInside: boolean;
24
24
  altFocusPoint: Readonly<GlobalPoint> | null;
25
+ arrowOtherEndpointInitialBinding: FixedPointBinding | null;
25
26
  }>;
26
27
  /** whether you're dragging a point */
27
28
  readonly isDragging: boolean;
@@ -45,18 +46,18 @@ export declare class LinearElementEditor {
45
46
  * @param id the `elementId` from the instance of this class (so that we can
46
47
  * statically guarantee this method returns an ExcalidrawLinearElement)
47
48
  */
48
- static getElement<T extends ExcalidrawLinearElement>(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): T | null;
49
+ static getElement<T extends ExcalidrawLinearElement>(id: InstanceType<typeof LinearElementEditor>["elementId"], elementsMap: ElementsMap): NonDeleted<T> | null;
49
50
  static handleBoxSelection(event: PointerEvent, appState: AppState, setState: React.Component<any, AppState>["setState"], elementsMap: NonDeletedSceneElementsMap): false | undefined;
50
51
  static handlePointerMove(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null;
51
52
  static handlePointDragging(event: PointerEvent, app: AppClassProperties, scenePointerX: number, scenePointerY: number, linearElementEditor: LinearElementEditor): Pick<AppState, "suggestedBinding" | "selectedLinearElement"> | null;
52
53
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState, scene: Scene): LinearElementEditor;
53
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
54
+ static getEditorMidPoints: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, appState: InteractiveCanvasAppState) => (GlobalPoint | null)[];
54
55
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
55
56
  x: number;
56
57
  y: number;
57
58
  }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
58
- static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, startPoint: P, endPoint: P, index: number, zoom: Zoom, elementsMap: ElementsMap): boolean;
59
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, index: number, elementsMap: ElementsMap): GlobalPoint;
59
+ static isSegmentTooShort<P extends GlobalPoint | LocalPoint>(element: ExcalidrawLinearElement, startPoint: P, endPoint: P, index: number, zoom: Zoom, elementsMap: ElementsMap): boolean;
60
+ static getSegmentMidPoint(element: ExcalidrawLinearElement, index: number, elementsMap: ElementsMap): GlobalPoint;
60
61
  static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
61
62
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
62
63
  x: number;
@@ -69,14 +70,14 @@ export declare class LinearElementEditor {
69
70
  static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
70
71
  static handlePointerMoveInEditMode(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties): LinearElementEditor | null;
71
72
  /** scene coords */
72
- static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
73
+ static getPointGlobalCoordinates(element: ExcalidrawLinearElement, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
73
74
  /** scene coords */
74
- static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): GlobalPoint[];
75
- static getPointAtIndexGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, indexMaybeFromEnd: number, // -1 for last element
75
+ static getPointsGlobalCoordinates(element: ExcalidrawLinearElement, elementsMap: ElementsMap): GlobalPoint[];
76
+ static getPointAtIndexGlobalCoordinates(element: ExcalidrawLinearElement, indexMaybeFromEnd: number, // -1 for last element
76
77
  elementsMap: ElementsMap): GlobalPoint;
77
- static pointFromAbsoluteCoords(element: NonDeleted<ExcalidrawLinearElement>, absoluteCoords: GlobalPoint, elementsMap: ElementsMap): LocalPoint;
78
- static getPointIndexUnderCursor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, zoom: AppState["zoom"], x: number, y: number): number;
79
- static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
78
+ static pointFromAbsoluteCoords(element: ExcalidrawLinearElement, absoluteCoords: GlobalPoint, elementsMap: ElementsMap): LocalPoint;
79
+ static getPointIndexUnderCursor(element: ExcalidrawLinearElement, elementsMap: ElementsMap, zoom: AppState["zoom"], x: number, y: number): number;
80
+ static createPointAt(element: ExcalidrawLinearElement, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
80
81
  /**
81
82
  * Normalizes line points so that the start point is at [0,0]. This is
82
83
  * expected in various parts of the codebase.
@@ -107,6 +108,12 @@ export declare class LinearElementEditor {
107
108
  } | undefined;
108
109
  private static _updatePoints;
109
110
  private static _getShiftLockedDelta;
111
+ /**
112
+ * The point a bound text label is centered on — the middle of the linear
113
+ * element, whether that's an actual point or the midpoint of the middle
114
+ * segment.
115
+ */
116
+ static getBoundTextElementCenter: (element: ExcalidrawLinearElement, elementsMap: ElementsMap) => GlobalPoint;
110
117
  static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
111
118
  x: number;
112
119
  y: number;
@@ -16,6 +16,19 @@ export declare const newFrameElement: (opts: {
16
16
  export declare const newMagicFrameElement: (opts: {
17
17
  name?: string;
18
18
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawMagicFrameElement>;
19
+ /**
20
+ * The point of the text box its alignment pins, as ratios of width/height.
21
+ *
22
+ * This is the point that stays put as the text grows — see the sides passed to
23
+ * `adjustXYWithRotation` in `getAdjustedDimensions`.
24
+ */
25
+ export declare const getTextAnchorRatios: (opts: {
26
+ textAlign: ExcalidrawTextElement["textAlign"];
27
+ verticalAlign: ExcalidrawTextElement["verticalAlign"];
28
+ }) => {
29
+ x: number;
30
+ y: number;
31
+ };
19
32
  export declare const newTextElement: (opts: {
20
33
  text: string;
21
34
  originalText?: string;
@@ -9,14 +9,11 @@ export interface ExcalidrawElementWithCanvas {
9
9
  canvas: HTMLCanvasElement;
10
10
  theme: AppState["theme"];
11
11
  scale: number;
12
- angle: number;
13
12
  zoomValue: AppState["zoom"]["value"];
14
13
  canvasOffsetX: number;
15
14
  canvasOffsetY: number;
16
- boundTextElementVersion: number | null;
17
15
  imageCrop: ExcalidrawImageElement["crop"] | null;
18
16
  containingFrameOpacity: number;
19
- boundTextCanvas: HTMLCanvasElement;
20
17
  }
21
18
  export declare const DEFAULT_LINK_SIZE = 14;
22
19
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
@@ -3,7 +3,7 @@ import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
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 } from "./types";
6
+ import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap } from "./types";
7
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[];
@@ -16,7 +16,7 @@ export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTe
16
16
  export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number) => void;
17
17
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
18
18
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
19
- export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: ExcalidrawElement, origElement: ExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
19
+ export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: NonDeletedExcalidrawElement, origElement: NonDeletedExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
20
20
  shouldMaintainAspectRatio?: boolean;
21
21
  shouldResizeFromCenter?: boolean;
22
22
  shouldInformMutation?: boolean;
@@ -8,8 +8,8 @@ import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeleted, No
8
8
  * @param selectedElements
9
9
  */
10
10
  export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
11
- export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, elementsMap: ElementsMap, excludeElementsInFrames?: boolean, boxSelectionMode?: BoxSelectionMode) => NonDeletedExcalidrawElement[];
12
- export declare const getVisibleAndNonSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => NonDeletedExcalidrawElement[];
11
+ export declare const getElementsWithinSelection: <T extends ExcalidrawElement>(elements: readonly T[], selection: ExcalidrawElement, elementsMap: ElementsMap, excludeElementsInFrames?: boolean, boxSelectionMode?: BoxSelectionMode) => T[];
12
+ export declare const getVisibleAndNonSelectedElements: <T extends NonDeletedExcalidrawElement>(elements: readonly T[], selectedElements: readonly ExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => T[];
13
13
  export declare const isSomeElementSelected: {
14
14
  (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
15
15
  clearCache(): void;
@@ -17,8 +17,8 @@ export declare const isSomeElementSelected: {
17
17
  export declare const getSelectedElements: (elements: ElementsMapOrArray, appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
18
18
  includeBoundTextElement?: boolean;
19
19
  includeElementsInFrames?: boolean;
20
- }) => ExcalidrawElement[];
21
- export declare const getTargetElements: (elements: ElementsMapOrArray, appState: Pick<AppState, "selectedElementIds" | "editingTextElement" | "newElement">) => ExcalidrawElement[];
20
+ }) => NonDeletedExcalidrawElement[];
21
+ export declare const getTargetElements: (elements: ElementsMapOrArray, appState: Pick<AppState, "selectedElementIds" | "editingTextElement" | "newElement" | "activeTool">) => NonDeletedExcalidrawElement[] | import("./types").ExcalidrawTextElement[];
22
22
  /**
23
23
  * returns prevState's selectedElementids if no change from previous, so as to
24
24
  * retain reference identity for memoization
@@ -26,7 +26,7 @@ export declare const getTargetElements: (elements: ElementsMapOrArray, appState:
26
26
  export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
27
27
  [id: string]: true;
28
28
  }>;
29
- export declare const getSelectionStateForElements: (targetElements: readonly ExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
29
+ export declare const getSelectionStateForElements: (targetElements: readonly NonDeletedExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
30
30
  selectedElementIds: AppState["selectedElementIds"];
31
31
  selectedGroupIds: AppState["selectedGroupIds"];
32
32
  editingGroupId: AppState["editingGroupId"];
@@ -41,3 +41,15 @@ export declare const toggleLinePolygonState: (element: ExcalidrawLineElement, ne
41
41
  points: ExcalidrawLineElement["points"];
42
42
  } | null;
43
43
  export declare const getFreedrawOutlinePoints: (element: ExcalidrawFreeDrawElement) => [number, number][];
44
+ /**
45
+ * The streamline-smoothed centerline the freedraw stroke is rendered
46
+ * around, in element-local coordinates. Boundary-sensitive consumers (e.g.
47
+ * bucket fill) should use this instead of `element.points`: raw input
48
+ * points can sit 20px+ apart and the rendered stroke is smoothed between
49
+ * them, so raw chords visibly deviate from what's on screen.
50
+ *
51
+ * Constant-width ("laser geometry") strokes technically smooth via
52
+ * `LaserPointer` instead; the perfect-freehand centerline with the same
53
+ * `streamline` is a close approximation the stroke width hides.
54
+ */
55
+ export declare const getFreedrawStrokeCenterPoints: (element: ExcalidrawFreeDrawElement) => [number, number][];
@@ -1,2 +1,12 @@
1
1
  import type { ExcalidrawElement } from "./types";
2
+ /**
3
+ * In theory, when we have text elements bound to a container, they
4
+ * should be right after the container element in the elements array.
5
+ * However, this is not guaranteed due to old and potential future bugs.
6
+ *
7
+ * This function sorts containers and their bound texts together. It prefers
8
+ * original z-index of container (i.e. it moves bound text elements after
9
+ * containers).
10
+ */
11
+ export declare const normalizeBoundElementsOrder: <T extends ExcalidrawElement>(elements: readonly T[]) => readonly T[];
2
12
  export declare const normalizeElementOrder: (elements: readonly ExcalidrawElement[]) => readonly ExcalidrawElement[];