@excalidraw/math 0.18.0-143b5b6 → 0.18.0-1440f2d

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 (116) hide show
  1. package/dist/types/common/src/constants.d.ts +1 -0
  2. package/dist/types/common/src/utils.d.ts +7 -1
  3. package/dist/types/element/src/align.d.ts +4 -1
  4. package/dist/types/element/src/binding.d.ts +62 -0
  5. package/dist/types/element/src/bounds.d.ts +10 -2
  6. package/dist/types/element/src/collision.d.ts +7 -0
  7. package/dist/types/element/src/cropElement.d.ts +36 -4
  8. package/dist/types/element/src/delta.d.ts +7 -1
  9. package/dist/types/element/src/distribute.d.ts +4 -1
  10. package/dist/types/element/src/dragElements.d.ts +8 -3
  11. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  12. package/dist/types/element/src/embeddable.d.ts +2 -1
  13. package/dist/types/element/src/flowchart.d.ts +1 -7
  14. package/dist/types/element/src/frame.d.ts +19 -1
  15. package/dist/types/element/src/groups.d.ts +1 -6
  16. package/dist/types/element/src/image.d.ts +5 -2
  17. package/dist/types/element/src/index.d.ts +1 -0
  18. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  19. package/dist/types/element/src/listMarker.d.ts +7 -2
  20. package/dist/types/element/src/newElement.d.ts +3 -1
  21. package/dist/types/element/src/renderElement.d.ts +10 -0
  22. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  23. package/dist/types/element/src/resizeElements.d.ts +15 -5
  24. package/dist/types/element/src/selection.d.ts +1 -7
  25. package/dist/types/element/src/shape.d.ts +2 -0
  26. package/dist/types/element/src/stickyNote.d.ts +8 -0
  27. package/dist/types/element/src/textElement.d.ts +3 -2
  28. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  29. package/dist/types/element/src/textWrapping.d.ts +3 -2
  30. package/dist/types/element/src/transform.d.ts +5 -1
  31. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -0
  32. package/dist/types/excalidraw/actions/actionBoundText.d.ts +47 -221
  33. package/dist/types/excalidraw/actions/actionCanvas.d.ts +13 -9
  34. package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -0
  35. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -0
  36. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -588
  37. package/dist/types/excalidraw/actions/actionDeselect.d.ts +2 -1
  38. package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -0
  39. package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -0
  40. package/dist/types/excalidraw/actions/actionExport.d.ts +9 -7
  41. package/dist/types/excalidraw/actions/actionFrame.d.ts +44 -525
  42. package/dist/types/excalidraw/actions/actionGroup.d.ts +4 -2
  43. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -0
  44. package/dist/types/excalidraw/actions/actionLink.d.ts +1 -0
  45. package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -0
  46. package/dist/types/excalidraw/actions/actionProperties.d.ts +2 -0
  47. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +2 -1
  48. package/dist/types/excalidraw/actions/actionStyles.d.ts +1 -0
  49. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -0
  50. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -0
  51. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -0
  52. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  53. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -0
  54. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -0
  55. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +1 -0
  56. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -0
  57. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -0
  58. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  59. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -0
  60. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  61. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  62. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  63. package/dist/types/excalidraw/appState.d.ts +8 -7
  64. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  65. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  66. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  67. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  68. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  69. package/dist/types/excalidraw/components/Actions.d.ts +9 -2
  70. package/dist/types/excalidraw/components/App.d.ts +23 -8
  71. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  72. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  73. package/dist/types/excalidraw/components/App.selectionTool.d.ts +42 -6
  74. package/dist/types/excalidraw/components/App.viewport.d.ts +23 -3
  75. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  76. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  77. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  78. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  79. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  80. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  81. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  82. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  83. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  84. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  85. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  86. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  87. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  88. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  89. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  90. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  91. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  92. package/dist/types/excalidraw/components/Tooltip.d.ts +11 -1
  93. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  94. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  95. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  96. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  97. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  98. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  99. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
  100. package/dist/types/excalidraw/data/blob.d.ts +16 -14
  101. package/dist/types/excalidraw/data/index.d.ts +3 -3
  102. package/dist/types/excalidraw/data/json.d.ts +8 -7
  103. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  104. package/dist/types/excalidraw/history.d.ts +10 -4
  105. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  106. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  107. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  108. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  109. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  110. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  111. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  112. package/dist/types/excalidraw/types.d.ts +48 -1
  113. package/dist/types/excalidraw/viewport.d.ts +1 -0
  114. package/dist/types/utils/src/index.d.ts +3 -1
  115. package/package.json +2 -2
  116. package/dist/types/utils/src/export.d.ts +0 -36
@@ -1,10 +1,11 @@
1
1
  import { type LocalPoint } from "@excalidraw/math";
2
2
  import type { PointerDownState } from "@excalidraw/excalidraw/types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { Scene } from "./Scene";
4
5
  import type { BoundingBox } from "./bounds";
5
6
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
6
- import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, 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;
7
+ import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawElement, ElementsMap } from "./types";
8
+ 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, renderEnvironment?: RenderEnvironment) => boolean;
8
9
  export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
9
10
  points: LocalPoint[];
10
11
  } | {
@@ -13,15 +14,23 @@ export declare const rescalePointsInElement: (element: NonDeletedExcalidrawEleme
13
14
  export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
14
15
  size: number;
15
16
  } | null;
16
- export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number) => void;
17
+ export declare const resizeSingleTextElement: (origElement: NonDeleted<ExcalidrawTextElement>, element: NonDeleted<ExcalidrawTextElement>, scene: Scene, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, nextWidth: number, nextHeight: number, renderEnvironment?: RenderEnvironment) => void;
17
18
  export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
18
19
  export declare const getResizeArrowDirection: (transformHandleType: MaybeTransformHandleType, element: NonDeleted<ExcalidrawLinearElement>) => "origin" | "end";
19
- export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: NonDeletedExcalidrawElement, origElement: NonDeletedExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
20
+ export declare const resizeSingleElement: (nextWidth: number, nextHeight: number, latestElement: NonDeletedExcalidrawElement, origElement: NonDeletedExcalidrawElement, originalElementsMap: ElementsMap, scene: Scene, handleDirection: TransformHandleDirection, { shouldInformMutation, shouldMaintainAspectRatio, shouldResizeFromCenter, renderEnvironment, }?: {
20
21
  shouldMaintainAspectRatio?: boolean;
21
22
  shouldResizeFromCenter?: boolean;
22
23
  shouldInformMutation?: boolean;
24
+ renderEnvironment?: RenderEnvironment;
23
25
  }) => void;
24
- export declare const resizeMultipleElements: (selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, handleDirection: TransformHandleDirection, scene: Scene, originalElementsMap: ElementsMap, { shouldMaintainAspectRatio, shouldResizeFromCenter, flipByX, flipByY, nextHeight, nextWidth, originalBoundingBox, }?: {
26
+ export declare const getNextSingleWidthAndHeightFromPointer: (latestElement: ExcalidrawElement, origElement: ExcalidrawElement, handleDirection: TransformHandleDirection, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
27
+ shouldMaintainAspectRatio?: boolean;
28
+ shouldResizeFromCenter?: boolean;
29
+ }) => {
30
+ nextWidth: number;
31
+ nextHeight: number;
32
+ };
33
+ export declare const resizeMultipleElements: (selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, handleDirection: TransformHandleDirection, scene: Scene, originalElementsMap: ElementsMap, { shouldMaintainAspectRatio, shouldResizeFromCenter, flipByX, flipByY, nextHeight, nextWidth, originalBoundingBox, renderEnvironment, }?: {
25
34
  nextWidth?: number;
26
35
  nextHeight?: number;
27
36
  shouldMaintainAspectRatio?: boolean;
@@ -29,4 +38,5 @@ export declare const resizeMultipleElements: (selectedElements: readonly NonDele
29
38
  flipByX?: boolean;
30
39
  flipByY?: boolean;
31
40
  originalBoundingBox?: BoundingBox;
41
+ renderEnvironment?: RenderEnvironment;
32
42
  }) => void;
@@ -1,6 +1,6 @@
1
1
  import type { AppState, BoxSelectionMode, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
- import { LinearElementEditor } from "./linearElementEditor";
3
2
  import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
3
+ export declare const shouldIgnoreElementFromSelection: (element: ExcalidrawElement) => boolean;
4
4
  /**
5
5
  * Frames and their containing elements are not to be selected at the same time.
6
6
  * Given an array of selected elements, if there are frames and their containing elements
@@ -26,12 +26,6 @@ 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 NonDeletedExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => {
30
- editingGroupId: AppState["editingGroupId"];
31
- selectedElementIds: AppState["selectedElementIds"];
32
- selectedGroupIds: AppState["selectedGroupIds"];
33
- selectedLinearElement: LinearElementEditor | null;
34
- };
35
29
  /**
36
30
  * Returns editing or single-selected text element, if any.
37
31
  */
@@ -36,6 +36,8 @@ export declare const generateLinearCollisionShape: (element: ExcalidrawLinearEle
36
36
  op: string;
37
37
  data: number[];
38
38
  }[];
39
+ export declare const ELBOW_ARROW_CORNER_RADIUS = 16;
40
+ export declare const generateElbowArrowShape: (routePoints: readonly LocalPoint[], radius: number) => string;
39
41
  /**
40
42
  * get the pure geometric shape of an excalidraw elementw
41
43
  * which is then used for hit detection
@@ -1,3 +1,4 @@
1
+ import type { RenderEnvironment } from "./renderEnvironment";
1
2
  import type { Scene } from "./Scene";
2
3
  import type { VerticalResizeAnchor } from "./sizeHelpers";
3
4
  import type { TransformHandleDirection } from "./transformHandles";
@@ -124,6 +125,12 @@ export type StickyNoteLayoutOpts = {
124
125
  baseFontSize?: number;
125
126
  /** the edge that stays put when the content correction changes the height */
126
127
  anchor?: StickyNoteLayoutAnchor;
128
+ /**
129
+ * the host whose text metrics the fit measures with; omitted = the global
130
+ * environment. An editor passes its own so a note laid out in one window
131
+ * (or headlessly) is measured with that realm's fonts and canvas.
132
+ */
133
+ renderEnvironment?: RenderEnvironment;
127
134
  };
128
135
  export type StickyNoteLayout = {
129
136
  container: Pick<ExcalidrawStickyNoteElement, "x" | "y" | "width" | "height" | "baseHeight">;
@@ -180,4 +187,5 @@ export declare const updateStickyNoteLayout: (container: ExcalidrawStickyNoteEle
180
187
  */
181
188
  export declare const relayoutStickyNotes: <T extends ExcalidrawElement>(elements: readonly T[], affectedIds: ReadonlySet<ExcalidrawElement["id"]>, opts?: {
182
189
  prevElementsMap?: ElementsMap;
190
+ renderEnvironment?: RenderEnvironment;
183
191
  }) => readonly T[];
@@ -1,10 +1,11 @@
1
1
  import { type Radians } from "@excalidraw/math";
2
2
  import type { ExtractSetType } from "@excalidraw/common/utility-types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { Scene } from "./Scene";
4
5
  import type { MaybeTransformHandleType } from "./transformHandles";
5
6
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeleted } from "./types";
6
- export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
7
- export declare const handleBindTextResize: (container: ExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean, shouldResizeFromCenter?: boolean, flipByY?: boolean) => void;
7
+ export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene, renderEnvironment?: RenderEnvironment) => void;
8
+ export declare const handleBindTextResize: (container: ExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean, shouldResizeFromCenter?: boolean, flipByY?: boolean, renderEnvironment?: RenderEnvironment) => void;
8
9
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
9
10
  x: number;
10
11
  y: number;
@@ -1,10 +1,11 @@
1
+ import type { RenderEnvironment } from "./renderEnvironment";
1
2
  import type { FontString, ExcalidrawTextElement } from "./types";
2
- export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => {
3
+ export declare const measureText: (text: string, font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], env?: RenderEnvironment) => {
3
4
  width: number;
4
5
  height: number;
5
6
  };
6
- export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
7
- export declare const getMinTextElementWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
7
+ export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], env?: RenderEnvironment) => number;
8
+ export declare const getMinTextElementWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"], env?: RenderEnvironment) => number;
8
9
  export declare const isMeasureTextSupported: () => boolean;
9
10
  export declare const normalizeText: (text: string) => string;
10
11
  /**
@@ -19,21 +20,24 @@ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => E
19
20
  export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
20
21
  export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
21
22
  /**
22
- * Set a custom text metrics provider.
23
+ * Set a custom text metrics provider, for all text measured in an environment
24
+ * without its own (`RenderEnvironment["textMetrics"]`) -- e.g. elements
25
+ * created outside the editor, on a server. Pass `undefined` to go back to
26
+ * measuring on a canvas.
23
27
  *
24
28
  * Useful for overriding the width calculation algorithm where canvas API is not available / desired.
25
29
  */
26
- export declare const setCustomTextMetricsProvider: (provider: TextMetricsProvider) => void;
30
+ export declare const setCustomTextMetricsProvider: (provider: TextMetricsProvider | undefined) => void;
27
31
  export interface TextMetricsProvider {
28
32
  getLineWidth(text: string, fontString: FontString): number;
29
33
  }
30
- export declare const getLineWidth: (text: string, font: FontString) => number;
31
- export declare const getTextWidth: (text: string, font: FontString) => number;
34
+ export declare const getLineWidth: (text: string, font: FontString, env?: RenderEnvironment) => number;
35
+ export declare const getTextWidth: (text: string, font: FontString, env?: RenderEnvironment) => number;
32
36
  export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
33
37
  export declare const charWidth: {
34
- calculate: (char: string, font: FontString) => number;
35
- getCache: (font: FontString) => number[];
38
+ calculate: (char: string, font: FontString, env?: RenderEnvironment) => number;
39
+ getCache: (font: FontString, env?: RenderEnvironment) => number[] | undefined;
36
40
  clearCache: (font: FontString) => void;
37
41
  };
38
- export declare const getMinCharWidth: (font: FontString) => number;
39
- export declare const getMaxCharWidth: (font: FontString) => number;
42
+ export declare const getMinCharWidth: (font: FontString, env?: RenderEnvironment) => number;
43
+ export declare const getMaxCharWidth: (font: FontString, env?: RenderEnvironment) => number;
@@ -1,3 +1,4 @@
1
+ import type { RenderEnvironment } from "./renderEnvironment";
1
2
  import type { FontString } from "./types";
2
3
  /**
3
4
  * Test if a given text contains any CJK characters (including symbols, punctuation, etc,).
@@ -17,7 +18,7 @@ export declare const parseTokens: (line: string) => string[];
17
18
  * This is a convenience adapter over `getWrappedTextLines()` for call sites
18
19
  * that only need the rendered wrapped string and not the source offsets.
19
20
  */
20
- export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
21
+ export declare const wrapText: (text: string, font: FontString, maxWidth: number, env?: RenderEnvironment) => string;
21
22
  /**
22
23
  * A single rendered visual line produced from the original text.
23
24
  *
@@ -36,4 +37,4 @@ export type WrappedTextLine = {
36
37
  * This is the source-of-truth wrapping pipeline for callers that need more than the
37
38
  * final wrapped string, for example caret placement or future editor/rich-text mapping.
38
39
  */
39
- export declare const getWrappedTextLines: (text: string, font: FontString, maxWidth: number) => WrappedTextLine[];
40
+ export declare const getWrappedTextLines: (text: string, font: FontString, maxWidth: number, env?: RenderEnvironment) => WrappedTextLine[];
@@ -1,5 +1,6 @@
1
1
  import type { MarkOptional } from "@excalidraw/common/utility-types";
2
2
  import { type ElementConstructorOpts } from "./newElement";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawFrameElement, ExcalidrawFreeDrawElement, ExcalidrawGenericElement, ExcalidrawIframeLikeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawMagicFrameElement, ExcalidrawSelectionElement, ExcalidrawTextElement, FileId, FontFamilyValues, NonDeletedExcalidrawElement, Ordered, TextAlign, VerticalAlign, ExcalidrawStickyNoteElement } from "./types";
4
5
  /**
5
6
  * Options for elements generated from a skeleton fragment (bound labels and
@@ -17,6 +18,8 @@ export type ValidLinearElement = {
17
18
  fontFamily?: FontFamilyValues;
18
19
  textAlign?: TextAlign;
19
20
  verticalAlign?: VerticalAlign;
21
+ /** where along an arrow's path (0-1) the label is centered */
22
+ labelPosition?: ExcalidrawTextElement["labelPosition"];
20
23
  } & FragmentConstructorOpts;
21
24
  end?: (({
22
25
  type: Exclude<ExcalidrawBindableElement["type"], "image" | "text" | "frame" | "magicframe" | "embeddable" | "iframe">;
@@ -95,6 +98,7 @@ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, Excal
95
98
  name?: string;
96
99
  } & Partial<ExcalidrawMagicFrameElement>);
97
100
  export declare const convertToExcalidrawElements: (elementsSkeleton: ExcalidrawElementSkeleton[] | null, opts?: {
98
- regenerateIds: boolean;
101
+ regenerateIds?: boolean;
102
+ renderEnvironment?: RenderEnvironment;
99
103
  }) => Ordered<NonDeletedExcalidrawElement>[];
100
104
  export {};
@@ -136,6 +136,7 @@ export declare const actionAddToLibrary: {
136
136
  selectedElementsAreBeingDragged: boolean;
137
137
  shouldCacheIgnoreZoom: boolean;
138
138
  zenModeEnabled: boolean;
139
+ minimapEnabled: boolean;
139
140
  theme: import("@excalidraw/element/types").Theme;
140
141
  gridSize: number;
141
142
  gridStep: number;
@@ -318,6 +319,7 @@ export declare const actionAddToLibrary: {
318
319
  duration?: number;
319
320
  } | null;
320
321
  zenModeEnabled: boolean;
322
+ minimapEnabled: boolean;
321
323
  theme: import("@excalidraw/element/types").Theme;
322
324
  gridSize: number;
323
325
  gridStep: number;
@@ -500,6 +502,7 @@ export declare const actionAddToLibrary: {
500
502
  duration?: number;
501
503
  } | null;
502
504
  zenModeEnabled: boolean;
505
+ minimapEnabled: boolean;
503
506
  theme: import("@excalidraw/element/types").Theme;
504
507
  gridSize: number;
505
508
  gridStep: number;
@@ -1,34 +1,26 @@
1
- import type { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawTextElement } from "@excalidraw/element/types";
2
- import type { Mutable } from "@excalidraw/common/utility-types";
3
- import type { AppState } from "../types";
1
+ import type { Scene } from "@excalidraw/element";
2
+ import type { ExcalidrawElement, ExcalidrawLinearElement, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
+ import type { ActionResult } from "./types";
4
+ import type { AppClassProperties, AppState } from "../types";
5
+ /**
6
+ * Frees the container's text as it rendered: wrapped the same, at a fixed
7
+ * width.
8
+ */
9
+ export declare const unbindTextFromContainer: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, scene: Scene) => void;
4
10
  export declare const actionUnbindText: {
5
11
  name: "unbindText";
6
12
  label: string;
7
13
  trackEvent: {
8
14
  category: "element";
9
15
  };
10
- predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
11
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
16
+ predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: AppClassProperties) => boolean;
17
+ perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: AppClassProperties) => {
12
18
  elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[];
13
- appState: Readonly<AppState>;
14
- captureUpdate: "IMMEDIATELY";
15
- };
16
- } & {
17
- keyTest?: undefined;
18
- };
19
- export declare const actionBindText: {
20
- name: "bindText";
21
- label: string;
22
- trackEvent: {
23
- category: "element";
24
- };
25
- predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
26
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
27
- elements: ExcalidrawElement[];
28
19
  appState: {
29
- selectedElementIds: {
30
- [x: string]: true;
31
- };
20
+ selectedElementIds: AppState["selectedElementIds"];
21
+ editingGroupId: AppState["editingGroupId"];
22
+ selectedGroupIds: AppState["selectedGroupIds"];
23
+ selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
32
24
  contextMenu: {
33
25
  items: import("../components/ContextMenu").ContextMenuItems;
34
26
  top: number;
@@ -38,13 +30,13 @@ export declare const actionBindText: {
38
30
  isLoading: boolean;
39
31
  errorMessage: React.ReactNode;
40
32
  activeEmbeddable: {
41
- element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
33
+ element: NonDeletedExcalidrawElement;
42
34
  state: "hover" | "active";
43
35
  } | null;
44
- newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
45
- resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
46
- multiElement: import("@excalidraw/element/types").NonDeleted<ExcalidrawLinearElement> | null;
47
- selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
36
+ newElement: NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
37
+ resizingElement: NonDeletedExcalidrawElement | null;
38
+ multiElement: NonDeleted<ExcalidrawLinearElement> | null;
39
+ selectionElement: NonDeletedExcalidrawElement | null;
48
40
  isBindingEnabled: boolean;
49
41
  boxSelectionMode: import("../types").BoxSelectionMode;
50
42
  bindingPreference: "enabled" | "disabled";
@@ -52,7 +44,7 @@ export declare const actionBindText: {
52
44
  showHints: boolean;
53
45
  inputDevice: import("../types").InputDevice;
54
46
  suggestedBinding: {
55
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
47
+ element: NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
56
48
  midPoint?: import("@excalidraw/math").GlobalPoint;
57
49
  } | null;
58
50
  textToolHover: {
@@ -66,7 +58,7 @@ export declare const actionBindText: {
66
58
  elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
67
59
  anchor: "start" | "end" | "label";
68
60
  } | null;
69
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
61
+ frameToHighlight: NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
70
62
  frameRendering: {
71
63
  enabled: boolean;
72
64
  name: boolean;
@@ -74,7 +66,7 @@ export declare const actionBindText: {
74
66
  clip: boolean;
75
67
  };
76
68
  editingFrame: import("@excalidraw/element/types").ExcalidrawFrameLikeElement["id"] | null;
77
- elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
69
+ elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
78
70
  editingTextElement: ExcalidrawTextElement | null;
79
71
  activeTool: {
80
72
  lastActiveTool: import("../types").ActiveTool | null;
@@ -158,15 +150,12 @@ export declare const actionBindText: {
158
150
  duration?: number;
159
151
  } | null;
160
152
  zenModeEnabled: boolean;
153
+ minimapEnabled: boolean;
161
154
  theme: import("@excalidraw/element/types").Theme;
162
155
  gridSize: number;
163
156
  gridStep: number;
164
157
  gridModeEnabled: boolean;
165
158
  viewModeEnabled: boolean;
166
- selectedGroupIds: {
167
- [groupId: string]: boolean;
168
- };
169
- editingGroupId: import("@excalidraw/element/types").GroupId | null;
170
159
  width: number;
171
160
  height: number;
172
161
  offsetTop: number;
@@ -178,7 +167,6 @@ export declare const actionBindText: {
178
167
  panels: number;
179
168
  };
180
169
  showHyperlinkPopup: false | "info" | "editor";
181
- selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
182
170
  snapLines: readonly import("../snapping").SnapLine[];
183
171
  originSnapOffset: {
184
172
  x: number;
@@ -210,197 +198,35 @@ export declare const actionBindText: {
210
198
  } & {
211
199
  keyTest?: undefined;
212
200
  };
201
+ export declare const actionBindText: {
202
+ name: "bindText";
203
+ label: string;
204
+ trackEvent: {
205
+ category: "element";
206
+ };
207
+ predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: AppClassProperties) => boolean;
208
+ perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: AppClassProperties) => ActionResult;
209
+ } & {
210
+ keyTest?: undefined;
211
+ };
212
+ /**
213
+ * A note and its label share one ink: the text the user styled wins, unless it
214
+ * is transparent (a note's label never is).
215
+ */
216
+ export declare const getStickyNoteInk: (textElement: ExcalidrawTextElement, container: ExcalidrawElement) => string | null;
217
+ /** binds the text to the (label-less) container, selecting the container */
218
+ export declare const bindTextToContainer: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, textElement: ExcalidrawTextElement, container: NonDeleted<ExcalidrawTextContainer>, app: AppClassProperties) => ActionResult;
219
+ export declare const pushContainerBelowText: (elements: readonly ExcalidrawElement[], container: ExcalidrawElement, textElement: ExcalidrawTextElement) => ExcalidrawElement[];
213
220
  export declare const actionWrapTextInContainer: {
214
221
  name: "wrapTextInContainer";
215
222
  label: string;
216
223
  trackEvent: {
217
224
  category: "element";
218
225
  };
219
- predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
220
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: import("../types").AppClassProperties) => {
221
- elements: readonly ExcalidrawElement[];
222
- appState: {
223
- selectedElementIds: Mutable<Readonly<{
224
- [id: string]: true;
225
- }>>;
226
- contextMenu: {
227
- items: import("../components/ContextMenu").ContextMenuItems;
228
- top: number;
229
- left: number;
230
- } | null;
231
- showWelcomeScreen: boolean;
232
- isLoading: boolean;
233
- errorMessage: React.ReactNode;
234
- activeEmbeddable: {
235
- element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
236
- state: "hover" | "active";
237
- } | null;
238
- newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
239
- resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
240
- multiElement: import("@excalidraw/element/types").NonDeleted<ExcalidrawLinearElement> | null;
241
- selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
242
- isBindingEnabled: boolean;
243
- boxSelectionMode: import("../types").BoxSelectionMode;
244
- bindingPreference: "enabled" | "disabled";
245
- isMidpointSnappingEnabled: boolean;
246
- showHints: boolean;
247
- inputDevice: import("../types").InputDevice;
248
- suggestedBinding: {
249
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
250
- midPoint?: import("@excalidraw/math").GlobalPoint;
251
- } | null;
252
- textToolHover: {
253
- type: "text";
254
- elementId: ExcalidrawElement["id"];
255
- } | {
256
- type: "container";
257
- elementId: ExcalidrawElement["id"];
258
- } | {
259
- type: "arrow";
260
- elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
261
- anchor: "start" | "end" | "label";
262
- } | null;
263
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
264
- frameRendering: {
265
- enabled: boolean;
266
- name: boolean;
267
- outline: boolean;
268
- clip: boolean;
269
- };
270
- editingFrame: import("@excalidraw/element/types").ExcalidrawFrameLikeElement["id"] | null;
271
- elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
272
- editingTextElement: ExcalidrawTextElement | null;
273
- activeTool: {
274
- lastActiveTool: import("../types").ActiveTool | null;
275
- locked: boolean;
276
- fromSelection: boolean;
277
- } & import("../types").ActiveTool;
278
- preferredSelectionTool: {
279
- type: "selection" | "lasso";
280
- initialized: boolean;
281
- };
282
- penMode: boolean;
283
- penDetected: boolean;
284
- exportBackground: boolean;
285
- exportEmbedScene: boolean;
286
- exportWithDarkMode: boolean;
287
- exportScale: number;
288
- currentItemStrokeColor: string;
289
- currentItemStickynoteStrokeColor: string;
290
- currentItemStickynoteBackgroundColor: string;
291
- currentItemBackgroundColor: string;
292
- currentItemFillStyle: ExcalidrawElement["fillStyle"];
293
- currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
294
- currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
295
- currentItemRoughness: number;
296
- currentItemStrokeVariability: import("@excalidraw/element/types").StrokeVariability;
297
- currentItemOpacity: number;
298
- currentItemFontFamily: import("@excalidraw/element/types").FontFamilyValues;
299
- currentItemFontSize: number;
300
- currentItemTextAlign: import("@excalidraw/element/types").TextAlign;
301
- currentItemStartArrowhead: import("@excalidraw/element/types").Arrowhead | null;
302
- currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
303
- currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
304
- currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
305
- currentItemArrowType: "sharp" | "round" | "elbow";
306
- viewBackgroundColor: string;
307
- scrollX: number;
308
- scrollY: number;
309
- scrollConstraints: import("../types").ScrollConstraints | null;
310
- cursorButton: "up" | "down";
311
- scrolledOutside: boolean;
312
- name: string | null;
313
- isResizing: boolean;
314
- isRotating: boolean;
315
- zoom: import("../types").Zoom;
316
- openMenu: "canvas" | null;
317
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
318
- openSidebar: {
319
- name: import("../types").SidebarName;
320
- tab?: import("../types").SidebarTabName;
321
- } | null;
322
- openDialog: null | {
323
- name: "imageExport" | "help" | "jsonExport";
324
- } | {
325
- name: "ttd";
326
- tab: "text-to-diagram" | "mermaid";
327
- } | {
328
- name: "commandPalette";
329
- } | {
330
- name: "settings";
331
- } | {
332
- name: "elementLinkSelector";
333
- sourceElementId: ExcalidrawElement["id"];
334
- } | {
335
- name: "charts";
336
- data: import("../charts").Spreadsheet;
337
- rawText: string;
338
- };
339
- defaultSidebarDockedPreference: boolean;
340
- lastPointerDownWith: import("@excalidraw/element/types").PointerType;
341
- hoveredElementIds: Readonly<{
342
- [id: string]: true;
343
- }>;
344
- previousSelectedElementIds: {
345
- [id: string]: true;
346
- };
347
- selectedElementsAreBeingDragged: boolean;
348
- shouldCacheIgnoreZoom: boolean;
349
- toast: {
350
- message: React.ReactNode;
351
- closable?: boolean;
352
- duration?: number;
353
- } | null;
354
- zenModeEnabled: boolean;
355
- theme: import("@excalidraw/element/types").Theme;
356
- gridSize: number;
357
- gridStep: number;
358
- gridModeEnabled: boolean;
359
- viewModeEnabled: boolean;
360
- selectedGroupIds: {
361
- [groupId: string]: boolean;
362
- };
363
- editingGroupId: import("@excalidraw/element/types").GroupId | null;
364
- width: number;
365
- height: number;
366
- offsetTop: number;
367
- offsetLeft: number;
368
- fileHandle: FileSystemFileHandle | null;
369
- collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
370
- stats: {
371
- open: boolean;
372
- panels: number;
373
- };
374
- showHyperlinkPopup: false | "info" | "editor";
375
- selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
376
- snapLines: readonly import("../snapping").SnapLine[];
377
- originSnapOffset: {
378
- x: number;
379
- y: number;
380
- } | null;
381
- objectsSnapModeEnabled: boolean;
382
- isCropping: boolean;
383
- croppingElementId: ExcalidrawElement["id"] | null;
384
- searchMatches: Readonly<{
385
- focusedId: ExcalidrawElement["id"] | null;
386
- matches: readonly import("../types").SearchMatch[];
387
- }> | null;
388
- activeLockedId: string | null;
389
- lockedMultiSelections: {
390
- [groupId: string]: true;
391
- };
392
- bindMode: import("@excalidraw/element/types").BindMode;
393
- colorTopPicks: {
394
- elementStroke: readonly string[] | null;
395
- elementBackground: readonly string[] | null;
396
- bucketFill: readonly string[] | null;
397
- stickyNoteStroke: readonly string[] | null;
398
- stickyNoteBackground: readonly string[] | null;
399
- };
400
- fontTopPicks: readonly import("@excalidraw/element/types").FontFamilyValues[] | null;
401
- };
402
- captureUpdate: "IMMEDIATELY";
403
- };
226
+ predicate: (elements: readonly ExcalidrawElement[], appState: AppState, _: import("../types").ExcalidrawProps, app: AppClassProperties) => boolean;
227
+ perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<AppState>, _: unknown, app: AppClassProperties) => ActionResult;
404
228
  } & {
405
229
  keyTest?: undefined;
406
230
  };
231
+ /** wraps each (unbound) text in a new container, selecting the containers */
232
+ export declare const wrapTextsInContainers: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, textElements: readonly ExcalidrawTextElement[], app: AppClassProperties) => ActionResult;