@excalidraw/math 0.18.0-1118751 → 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 (127) hide show
  1. package/dist/types/common/src/constants.d.ts +4 -0
  2. package/dist/types/common/src/utils.d.ts +12 -1
  3. package/dist/types/element/src/align.d.ts +4 -1
  4. package/dist/types/element/src/binding.d.ts +70 -0
  5. package/dist/types/element/src/bounds.d.ts +10 -2
  6. package/dist/types/element/src/collision.d.ts +13 -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 +2 -0
  18. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  19. package/dist/types/element/src/listMarker.d.ts +39 -0
  20. package/dist/types/element/src/newElement.d.ts +17 -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 +10 -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 +30 -3
  32. package/dist/types/excalidraw/actions/actionBoundText.d.ts +56 -214
  33. package/dist/types/excalidraw/actions/actionCanvas.d.ts +76 -16
  34. package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -2
  35. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -1
  36. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -564
  37. package/dist/types/excalidraw/actions/actionDeselect.d.ts +14 -2
  38. package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -1
  39. package/dist/types/excalidraw/actions/actionElementLock.d.ts +20 -2
  40. package/dist/types/excalidraw/actions/actionExport.d.ts +27 -9
  41. package/dist/types/excalidraw/actions/actionFrame.d.ts +71 -528
  42. package/dist/types/excalidraw/actions/actionGroup.d.ts +22 -4
  43. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -1
  44. package/dist/types/excalidraw/actions/actionLink.d.ts +10 -1
  45. package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -1
  46. package/dist/types/excalidraw/actions/actionProperties.d.ts +20 -2
  47. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +11 -2
  48. package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -1
  49. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +10 -1
  50. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -1
  51. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +10 -1
  52. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  53. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -1
  54. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -1
  55. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  56. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -1
  57. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -1
  58. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  59. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -1
  60. package/dist/types/excalidraw/actions/index.d.ts +3 -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 +9 -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.arrowText.d.ts +5 -39
  71. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  72. package/dist/types/excalidraw/components/App.d.ts +79 -264
  73. package/dist/types/excalidraw/components/App.duplicate.d.ts +52 -2
  74. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  75. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  76. package/dist/types/excalidraw/components/App.pan.d.ts +8 -0
  77. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  78. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  79. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  80. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  81. package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
  82. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  83. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  84. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  85. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  86. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  87. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  88. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  89. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  90. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  91. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  92. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  93. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  94. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  95. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  96. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  97. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  98. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  99. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  100. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  101. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  102. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  103. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  104. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  105. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  106. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  107. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  108. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  109. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  110. package/dist/types/excalidraw/data/blob.d.ts +34 -16
  111. package/dist/types/excalidraw/data/index.d.ts +3 -3
  112. package/dist/types/excalidraw/data/json.d.ts +17 -8
  113. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  114. package/dist/types/excalidraw/history.d.ts +10 -4
  115. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  116. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  117. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  118. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  119. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  120. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  121. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  122. package/dist/types/excalidraw/types.d.ts +83 -14
  123. package/dist/types/excalidraw/viewport.d.ts +23 -1
  124. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  125. package/dist/types/utils/src/index.d.ts +3 -1
  126. package/package.json +2 -2
  127. package/dist/types/utils/src/export.d.ts +0 -36
@@ -0,0 +1,140 @@
1
+ import type { ArrowEndpoint } from "@excalidraw/element";
2
+ import type { ExcalidrawTextContainer, ExcalidrawTextElement, NonDeleted } from "@excalidraw/element/types";
3
+ import type React from "react";
4
+ import type App from "./App";
5
+ import type { PointerDownState } from "../types";
6
+ type ScenePoint = {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ /** the modifier state a target depends on — off a pointer or keyboard event */
11
+ export type Modifiers = Pick<KeyboardEvent, "ctrlKey" | "metaKey">;
12
+ /** What a text-tool click at a position does. */
13
+ export type TextToolTarget =
14
+ /** binds a new text to a free arrow endpoint */
15
+ {
16
+ type: "endpoint";
17
+ endpoint: ArrowEndpoint;
18
+ }
19
+ /** edits this text (a label included, at its derived position) */
20
+ | {
21
+ type: "text";
22
+ element: NonDeleted<ExcalidrawTextElement>;
23
+ }
24
+ /** binds a new label to this empty container (an arrow included) */
25
+ | {
26
+ type: "container";
27
+ element: NonDeleted<ExcalidrawTextContainer>;
28
+ }
29
+ /** creates free text at the pointer */
30
+ | {
31
+ type: "free";
32
+ };
33
+ /**
34
+ * The text tool's pointer interaction.
35
+ *
36
+ * Everything hangs off one question — what would a click at this position
37
+ * do (`getTargetAt`)? — answered once and used for the hover affordance
38
+ * (`appState.textToolHover`), the cursor and the pointerdown itself, so the
39
+ * affordance can never promise something the click won't deliver.
40
+ *
41
+ * A click on an empty container's center is armed on pointerdown and
42
+ * committed on pointerup as a bound label; dragging past the autowrap
43
+ * threshold first turns it into a free fixed-width text at the origin
44
+ * instead.
45
+ *
46
+ * Text editing itself (`app.text.startTextEditing`, see `AppText`) is
47
+ * shared with Enter, double-click and the other entry points.
48
+ */
49
+ export declare class AppTextTool {
50
+ private app;
51
+ constructor(app: App);
52
+ /**
53
+ * A click on an empty container's center, armed on pointerdown and decided
54
+ * on the pointer's way out: a click binds a label, a drag creates free
55
+ * text instead. Deferring is what keeps the drag from first binding to
56
+ * (and provisionally enlarging) the container.
57
+ */
58
+ private pending;
59
+ /**
60
+ * The modifiers the hover was last resolved with — what a refresh without
61
+ * an event of its own (the viewport moving under a still pointer) uses.
62
+ */
63
+ private lastModifiers;
64
+ /**
65
+ * What a click at this position would do, in the order the click resolves
66
+ * it: a free arrow endpoint (the smaller, more deliberate target; z-aware,
67
+ * and off while ctrl/cmd disables binding) → the text under the pointer,
68
+ * which the click edits → an empty container near its center, which gets
69
+ * a label unless ctrl/cmd opts out → free text at the pointer.
70
+ *
71
+ * Ctrl/cmd is "no binding" throughout the tool, as elsewhere in the
72
+ * editor. For the container it is read off the event rather than the
73
+ * arrow-binding preference: a label is not an arrow binding.
74
+ */
75
+ getTargetAt: (scenePointer: ScenePoint, modifiers: Modifiers) => TextToolTarget;
76
+ /**
77
+ * Keeps `appState.textToolHover` — the affordance for what a click would
78
+ * do — in sync with the pointer, and returns the target (for the cursor).
79
+ * Suppressed while something else owns the interaction: a text being
80
+ * edited or drag-sized, a multi-point element, a box selection, a drag of
81
+ * the selection, or the pointer over a scrollbar.
82
+ */
83
+ updateHover: (scenePointer: ScenePoint, modifiers: Modifiers, isOverScrollBar?: boolean) => TextToolTarget | null;
84
+ /**
85
+ * Re-resolves the hover — and the cursor that goes with it — where the
86
+ * pointer last was, for what changes a click's outcome without the pointer
87
+ * moving: the ctrl/cmd toggle (pass its event), or the viewport scrolling
88
+ * or zooming under the pointer (no event; the last modifiers stand). The
89
+ * scene position is re-derived from the pointer's viewport position, so a
90
+ * moved viewport resolves what is under the pointer now.
91
+ *
92
+ * Nothing to refresh with another tool or without a hovering pointer — a
93
+ * finger never hovers (its last move is where it lifted), and the
94
+ * affordance a press armed is cleared when the press resolves or is
95
+ * canceled. The cursor is left to viewport navigation (space/wheel
96
+ * panning, a scrollbar drag, the hand tool), as on pointermove.
97
+ */
98
+ refresh: (modifiers?: Modifiers) => void;
99
+ /**
100
+ * Drops a pending center click without acting on it — the tool was left,
101
+ * the browser took the pointer (pointercancel), or a second finger turned
102
+ * the press into a pinch/pan — so no pointerup of ours will decide it. The
103
+ * outline it armed goes with it: while pending, the hover is that click's.
104
+ */
105
+ cancel: () => void;
106
+ clearHover: () => void;
107
+ private setHover;
108
+ /**
109
+ * The cursor for what a click would do: a pointer over the arrow anchors
110
+ * text would attach to, a text cursor over text the click would edit, the
111
+ * tool's crosshair otherwise — also while the affordance is suppressed
112
+ * (editing, drag-sizing), where a click has nothing to point at.
113
+ */
114
+ cursorFor: (target: TextToolTarget | null) => string;
115
+ handlePointerDown: (event: React.PointerEvent<HTMLElement>, pointerDownState: PointerDownState) => void;
116
+ /**
117
+ * The pointer-move half of a pending center click. Once the pointer has
118
+ * moved past the autowrap threshold the click is a drag: free text is
119
+ * created at the origin and sized by the drag from here on. Horizontal
120
+ * only (a text is only ever sized that way) and in screen space, and
121
+ * deliberately wider than the generic drag threshold so a jittery click
122
+ * still binds. Returns whether a pending click owned the move.
123
+ */
124
+ handlePointerMove: (event: PointerEvent, pointerDownState: PointerDownState) => boolean;
125
+ /**
126
+ * The pointer-up half: a genuine pointerup binds the label. The
127
+ * missing-pointerup cleanup replays this with the pointerdown event (a
128
+ * second finger landing mid-press), and a tool switch orphans the click —
129
+ * both discard it instead.
130
+ */
131
+ handlePointerUp: (event: PointerEvent, pointerDownState: PointerDownState) => void;
132
+ private isDrag;
133
+ private resolvePending;
134
+ /**
135
+ * The click has been acted on: drop the affordance, revert the tool unless
136
+ * it is locked, restore the cursor.
137
+ */
138
+ private finish;
139
+ }
140
+ export {};
@@ -1,10 +1,16 @@
1
1
  import { type StylesPanelMode } from "@excalidraw/common";
2
2
  import type { NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
+ import { type AnimationKey, type AnimationScheduler } from "../renderer/animation";
3
4
  import { type SetViewportOptions } from "../viewport";
4
5
  import type { AppProps, AppState, Offsets, ScrollConstraints, ViewportOffsets, ViewportOffsetsOptions, ViewportUIName } from "../types";
5
6
  import type App from "./App";
6
- export declare const SCROLL_TO_CONTENT_ANIMATION_KEY = "animateScrollToContent";
7
- export declare const SCROLL_CONSTRAINTS_SNAP_BACK_ANIMATION_KEY = "animateScrollConstraintsSnapBack";
7
+ /** The AnimationController keys a viewport uses, unique per AppViewport so
8
+ * concurrent editors in the same window never share (or cancel) each
9
+ * other's animations. */
10
+ export type ViewportAnimationKeys = {
11
+ scrollToContent: AnimationKey;
12
+ snapBack: AnimationKey;
13
+ };
8
14
  /** single source of truth for the `--right-sidebar-width` CSS variable */
9
15
  export declare const RIGHT_SIDEBAR_WIDTH = 302;
10
16
  type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
@@ -19,7 +25,7 @@ type AppViewportDependencies = {
19
25
  * AnimationController. No-op when already within the hard bounds (or when
20
26
  * there is no lock).
21
27
  */
22
- export declare const snapBackToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (updater: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => Viewport | null) => void, duration?: number) => void;
28
+ export declare const snapBackToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (updater: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => Viewport | null) => void, keys: ViewportAnimationKeys, scheduler?: AnimationScheduler, duration?: number) => void;
23
29
  /**
24
30
  * Owns viewport state transitions and App-bound viewport concerns. Pure
25
31
  * viewport geometry remains in `viewport.ts` so actions and public helpers can
@@ -34,12 +40,55 @@ export declare class AppViewport {
34
40
  };
35
41
  private activeTransition;
36
42
  private uiLastMeasured;
43
+ /** @see beginGesture */
44
+ private activeExternalGestures;
45
+ /** Unique per instance (see `ViewportAnimationKeys`); exposed for tests
46
+ * observing the animations. */
47
+ readonly scrollToContentAnimationKey: symbol;
48
+ readonly snapBackAnimationKey: symbol;
37
49
  constructor(app: App, dependencies: AppViewportDependencies);
38
50
  get isAnimating(): boolean;
39
51
  /** Whether a programmatic transition into a locked viewport currently owns
40
52
  * user pan/zoom input. */
41
53
  get isLockedTransitionPending(): boolean;
42
54
  invalidateUIOffset: (name: ViewportUIName) => void;
55
+ /**
56
+ * The side a rendered side UI (`data-viewport-ui="side"`) docks to, and
57
+ * how far it reaches into the canvas from it, in screen px.
58
+ */
59
+ private measureSide;
60
+ /**
61
+ * The side a named surface docks to while it's hidden, and how far it
62
+ * reaches into the canvas from it: as last measured, else approximately.
63
+ */
64
+ private getReservedSide;
65
+ private querySideUI;
66
+ /**
67
+ * Where a rendered side UI is, relative to the editor's container, in
68
+ * screen px; null when it isn't rendered.
69
+ */
70
+ getSideUIRect: (name: ViewportUIName) => {
71
+ left: number;
72
+ right: number;
73
+ top: number;
74
+ bottom: number;
75
+ } | null;
76
+ /**
77
+ * How far the named side UIs reach into the canvas, in screen px, from
78
+ * the left and the right: the part of the canvas they cover. Zero at a
79
+ * side none of them is rendered at — e.g. with the sidebar closed, or on
80
+ * phones, where it's an overlay that doesn't count as viewport UI — unless
81
+ * a hidden one is reserved (see `ViewportOffsetsOptions.reserve`).
82
+ */
83
+ getSideInsets: (names: readonly ViewportUIName[], opts?: Pick<ViewportOffsetsOptions, "reserve">) => {
84
+ left: number;
85
+ right: number;
86
+ };
87
+ /** How far the sidebar reaches into the canvas (see `getSideInsets`). */
88
+ getSidebarInsets: () => {
89
+ left: number;
90
+ right: number;
91
+ };
43
92
  /**
44
93
  * Resolves user-supplied viewport offsets into concrete per-side pixel
45
94
  * values. Static sides take precedence over UI-derived sides.
@@ -54,7 +103,10 @@ export declare class AppViewport {
54
103
  resolveInitialViewport: (opts: Omit<SetViewportOptions, "animation">, elementsMap: NonDeletedSceneElementsMap, appState: AppState) => (Viewport & {
55
104
  scrollConstraints: ScrollConstraints | null;
56
105
  }) | null;
57
- /** Navigates to a target and optionally installs scroll/zoom constraints. */
106
+ /**
107
+ * Navigates to a target and optionally installs scroll/zoom constraints.
108
+ * Navigating stops following a collaborator, as a user's pan does.
109
+ */
58
110
  setViewport: (opts: SetViewportOptions | null) => void;
59
111
  /** Use when changing scrollX/scrollY/zoom based on user interaction. */
60
112
  translate: <K extends keyof AppState>(state: AppState | Pick<AppState, K> | null | ((prevState: Readonly<AppState>, props: Readonly<AppProps>) => AppState | Pick<AppState, K> | null), opts?: {
@@ -63,6 +115,14 @@ export declare class AppViewport {
63
115
  }) => boolean;
64
116
  /** Clamps the viewport into the active scroll constraints. */
65
117
  constrain: (overscroll?: number) => void;
118
+ /**
119
+ * Marks a viewport gesture driven from outside of the canvas (e.g. dragging
120
+ * the minimap) as active, so that a rubberband overscroll is held for as
121
+ * long as it lasts, same as during a pan — including one that's snapping
122
+ * back already. Returns the function ending it, which releases the
123
+ * overscroll.
124
+ */
125
+ beginGesture: () => () => void;
66
126
  /** Releases a held rubberband overscroll. */
67
127
  releaseOverscroll: () => void;
68
128
  private snapBack;
@@ -21,6 +21,10 @@ export declare class AppWheel {
21
21
  * ctrl+wheel).
22
22
  */
23
23
  preventBrowserZoom: (event: WheelEvent) => void;
24
- /** zooms around the pointer by a wheel delta (positive = zoom out) */
25
- private zoomBy;
24
+ /**
25
+ * Zooms by a wheel delta (positive = zoom out) — around the pointer, or
26
+ * around the center of the viewport (when wheeling elsewhere than over
27
+ * the canvas, e.g. over the minimap).
28
+ */
29
+ zoomBy: (deltaY: number, anchor?: "pointer" | "center") => void;
26
30
  }
@@ -0,0 +1,31 @@
1
+ import type { ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ActionResult } from "../actions/types";
3
+ import type { AppState } from "../types";
4
+ import type App from "./App";
5
+ /**
6
+ * Wraps the selection in what fits it, or unwraps it, preferring containers
7
+ * over frames:
8
+ *
9
+ * 1. a text and a container without one: binds the text to the container
10
+ * 2. texts, with any labeled containers: wraps each text in a container
11
+ * 3. labeled containers: unwraps their texts, removing the containers
12
+ * 4. a frame with any of its children, or all of a frame's children: removes
13
+ * the frame
14
+ * 5. anything else without a frame: wraps it in a frame
15
+ *
16
+ * The containers (3) removed come back in place of new ones while the
17
+ * selection it left stands, so diamonds, notes and arrows survive a toggle.
18
+ */
19
+ export declare class AppWrap {
20
+ private app;
21
+ private unwrapped;
22
+ constructor(app: App);
23
+ toggle: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>) => ActionResult;
24
+ /** frees the containers' texts, moving the containers' arrows onto them */
25
+ private unwrap;
26
+ /**
27
+ * puts the unwrapped texts back into their containers, along with the
28
+ * containers' arrows — `null` when any of them is gone
29
+ */
30
+ private rewrap;
31
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ConvertibleTypes, ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElementWithContainer } from "@excalidraw/element/types";
2
2
  import type { Scene } from "@excalidraw/element";
3
+ import type { RenderEnvironment } from "@excalidraw/element/renderEnvironment";
3
4
  import "./ConvertElementTypePopup.scss";
4
5
  import type App from "./App";
5
6
  export declare const convertElementTypePopupAtom: import("jotai").PrimitiveAtom<{
@@ -12,7 +13,7 @@ export declare const convertElementTypePopupAtom: import("jotai").PrimitiveAtom<
12
13
  declare const ConvertElementTypePopup: ({ app }: {
13
14
  app: App;
14
15
  }) => import("react/jsx-runtime").JSX.Element;
15
- export declare const adjustBoundTextSize: (container: ExcalidrawTextContainer, boundText: ExcalidrawTextElementWithContainer, scene: Scene) => void;
16
+ export declare const adjustBoundTextSize: (container: ExcalidrawTextContainer, boundText: ExcalidrawTextElementWithContainer, scene: Scene, renderEnvironment?: RenderEnvironment) => void;
16
17
  type ConversionType = "generic" | "linear" | null;
17
18
  export declare const convertElementTypes: (app: App, { conversionType, nextType, direction, }: {
18
19
  conversionType: ConversionType;
@@ -0,0 +1,2 @@
1
+ import "./FileDropOverlay.scss";
2
+ export declare const FileDropOverlay: () => import("react/jsx-runtime").JSX.Element | null;
@@ -15,9 +15,13 @@ interface Props {
15
15
  isItemSelected: (id: LibraryItem["id"] | null) => boolean;
16
16
  svgCache: SvgCache;
17
17
  itemsRenderedPerBatch: number;
18
+ /** larger items with their name below */
19
+ showNames?: boolean;
18
20
  }
19
- export declare const LibraryMenuSectionGrid: ({ children, }: {
21
+ export declare const LibraryMenuSectionGrid: ({ children, showNames, }: {
20
22
  children: ReactNode;
23
+ /** fewer columns, for items rendered with `showNames` */
24
+ showNames?: boolean;
21
25
  }) => import("react/jsx-runtime").JSX.Element;
22
- export declare const LibraryMenuSection: React.MemoExoticComponent<({ items, onItemSelectToggle, onItemDrag, isItemSelected, onClick, svgCache, itemsRenderedPerBatch, }: Props) => import("react/jsx-runtime").JSX.Element>;
26
+ export declare const LibraryMenuSection: React.MemoExoticComponent<({ items, onItemSelectToggle, onItemDrag, isItemSelected, onClick, svgCache, itemsRenderedPerBatch, showNames, }: Props) => import("react/jsx-runtime").JSX.Element>;
23
27
  export {};
@@ -1,8 +1,11 @@
1
1
  import "./LibraryUnit.scss";
2
2
  import type { LibraryItem } from "../types";
3
3
  import type { SvgCache } from "../hooks/useLibraryItemSvg";
4
- export declare const LibraryUnit: import("react").MemoExoticComponent<({ id, elements, isPending, onClick, selected, onToggle, onDrag, svgCache, }: {
4
+ export declare const LibraryUnit: import("react").MemoExoticComponent<({ id, name, showName, elements, isPending, onClick, selected, onToggle, onDrag, svgCache, }: {
5
5
  id: LibraryItem["id"] | /** for pending item */ null;
6
+ name?: LibraryItem["name"];
7
+ /** render larger, with the name below the item */
8
+ showName?: boolean;
6
9
  elements?: LibraryItem["elements"];
7
10
  isPending?: boolean;
8
11
  onClick: (id: LibraryItem["id"] | null) => void;
@@ -11,4 +14,6 @@ export declare const LibraryUnit: import("react").MemoExoticComponent<({ id, ele
11
14
  onDrag: (id: string, event: React.DragEvent) => void;
12
15
  svgCache: SvgCache;
13
16
  }) => import("react/jsx-runtime").JSX.Element>;
14
- export declare const EmptyLibraryUnit: () => import("react/jsx-runtime").JSX.Element;
17
+ export declare const EmptyLibraryUnit: ({ showName }: {
18
+ showName?: boolean;
19
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import "./Minimap.scss";
2
+ /**
3
+ * The vertical space (px) the UI above the minimap gives up for it: its
4
+ * height + the gap below it (see Minimap.scss), less a part of the clearance
5
+ * that UI keeps from the footer anyway — the minimap can sit closer to it.
6
+ */
7
+ export declare const MINIMAP_RESERVED_HEIGHT = 138;
8
+ /**
9
+ * The minimap isn't available in editors shorter than this (px): it shares
10
+ * the left edge with the styles panel, which would be left with no room.
11
+ */
12
+ export declare const MINIMAP_MIN_EDITOR_HEIGHT = 500;
13
+ export declare const Minimap: ({ className }: {
14
+ className?: string;
15
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * TEMPORARY: a pulsing dot on the minimap toggle announcing the (new)
3
+ * minimap. Stops showing on its own after `ANNOUNCEMENT_END` — remove this
4
+ * file (and its uses) any time after.
5
+ */
6
+ import type { AppClassProperties } from "../../types";
7
+ export declare const MinimapAnnouncementDot: ({ app, minimapEnabled, }: {
8
+ app: AppClassProperties;
9
+ minimapEnabled: boolean;
10
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The minimap's logic on the editor's side, loaded once the minimap is first
3
+ * shown.
4
+ *
5
+ * DON'T depend on anything from the outside (types aside), so that this
6
+ * lazy-loaded chunk stays self-contained.
7
+ */
8
+ import type { AppClassProperties } from "../../types";
9
+ /**
10
+ * Drives the minimap canvas. All the main thread does is to copy a few
11
+ * numbers per element (throttled, and only when the scene changes) and to
12
+ * forward the viewport — bounds, layout and drawing happen in a worker
13
+ * rendering to an OffscreenCanvas. Falls back to the main thread where
14
+ * that's not supported.
15
+ */
16
+ export declare class MinimapController {
17
+ private app;
18
+ private container;
19
+ private canvas;
20
+ private worker;
21
+ private fallback;
22
+ private shared;
23
+ private isDestroyed;
24
+ private cleanups;
25
+ private config;
26
+ /** the transform of the last rendered frame */
27
+ private transform;
28
+ /** bounds of the elements of the last rendered frame */
29
+ private contentBounds;
30
+ private scratch;
31
+ private elementsSeq;
32
+ private isElementsDirty;
33
+ private isAwaitingFrame;
34
+ private nextEncodingAt;
35
+ private encodingTimer;
36
+ private encodingFrame;
37
+ private drag;
38
+ /** @see unlockOnceSettled */
39
+ private unlockFrame;
40
+ constructor(app: AppClassProperties, container: HTMLElement);
41
+ private init;
42
+ private subscribe;
43
+ /** tears down everything but the instance itself, so it can be restarted */
44
+ private teardown;
45
+ private restartOnMainThread;
46
+ destroy(): void;
47
+ private send;
48
+ private getConfig;
49
+ private syncConfig;
50
+ private getViewport;
51
+ private syncViewport;
52
+ private scheduleEncoding;
53
+ private sendElements;
54
+ /** @see MinimapRecord for the format */
55
+ private encodeElements;
56
+ private onFrame;
57
+ /** the position of the pointer in the minimap (CSS px) */
58
+ private getPointerPosition;
59
+ private onPointerDown;
60
+ /**
61
+ * The viewport can be dragged up to its own size past the content, i.e.
62
+ * until the content is just out of view (or as far as it already is).
63
+ */
64
+ private getDragBounds;
65
+ private onPointerMove;
66
+ /** moves the viewport where the pointer drags it */
67
+ private moveViewport;
68
+ /**
69
+ * Keeps panning the viewport for as long as the pointer is held outside of
70
+ * the minimap, the faster the further out it is — the pointer may have
71
+ * nowhere further to go (the minimap sits in the corner of the screen).
72
+ */
73
+ private autoPan;
74
+ /**
75
+ * Zooms the canvas around the center of its viewport, wherever in the
76
+ * minimap the pointer (or the viewport) is — as opposed to over the canvas,
77
+ * wheeling over the minimap never pans.
78
+ */
79
+ private onWheel;
80
+ private onPointerUp;
81
+ private endDrag;
82
+ /**
83
+ * Ending the drag may leave the viewport animating (the rubberband
84
+ * overscroll of a locked viewport snapping back). The minimap is kept as is
85
+ * until that settles, so that only the viewport moves, instead of the
86
+ * minimap refitting itself under it on each frame.
87
+ */
88
+ private unlockOnceSettled;
89
+ private cancelUnlock;
90
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Minimap renderer & message protocol, shared by the worker and by the
3
+ * main-thread fallback.
4
+ *
5
+ * DON'T depend on anything from the outside, as this module is part of a
6
+ * separate lazy-loaded chunk that's also loaded by the worker — including
7
+ * anything from the main chunk would pull the whole editor into the worker.
8
+ */
9
+ /**
10
+ * Elements are sent as a flat Float32Array of records, so that the main
11
+ * thread only copies a few numbers per element and everything else (bounds,
12
+ * transform, drawing) happens off the main thread. Each record starts with
13
+ * its kind:
14
+ *
15
+ * - `BOX` & `FRAME`: `kind, x, y, width, height, angle`
16
+ * - `PATH`: `kind, x, y, angle, pointsCount, ...[pointX, pointY]` (points
17
+ * are relative to `x`/`y`, same as on linear elements)
18
+ */
19
+ export declare const MinimapRecord: {
20
+ /** drawn as a filled block */
21
+ readonly BOX: 0;
22
+ /** drawn as an outline, so that it doesn't cover its children */
23
+ readonly FRAME: 1;
24
+ /** drawn as a polyline */
25
+ readonly PATH: 2;
26
+ };
27
+ export declare const MINIMAP_BOX_RECORD_SIZE = 6;
28
+ export declare const MINIMAP_PATH_RECORD_HEADER_SIZE = 5;
29
+ /** scene → minimap (CSS pixels): `minimap = scene * scale + translate` */
30
+ export type MinimapTransform = {
31
+ scale: number;
32
+ translateX: number;
33
+ translateY: number;
34
+ };
35
+ /** in scene coordinates */
36
+ export type MinimapViewport = {
37
+ x: number;
38
+ y: number;
39
+ width: number;
40
+ height: number;
41
+ };
42
+ export type MinimapColors = {
43
+ element: string;
44
+ viewport: string;
45
+ };
46
+ export type MinimapConfig = {
47
+ /** CSS pixels */
48
+ width: number;
49
+ /** CSS pixels */
50
+ height: number;
51
+ devicePixelRatio: number;
52
+ colors: MinimapColors;
53
+ };
54
+ type MinimapCanvas = OffscreenCanvas | HTMLCanvasElement;
55
+ export type MinimapInMessage = {
56
+ type: "init";
57
+ canvas: MinimapCanvas;
58
+ config: MinimapConfig;
59
+ } | {
60
+ type: "config";
61
+ config: MinimapConfig;
62
+ } | {
63
+ type: "elements";
64
+ seq: number;
65
+ records: Float32Array;
66
+ } | {
67
+ type: "viewport";
68
+ viewport: MinimapViewport;
69
+ }
70
+ /**
71
+ * While a transform is supplied, it's used as is instead of being fitted
72
+ * to the content. Used while dragging the viewport of a locked (scroll-
73
+ * constrained) editor, so that the minimap doesn't rescale as the viewport
74
+ * rubberbands past the lock.
75
+ */
76
+ | {
77
+ type: "lock";
78
+ transform: MinimapTransform | null;
79
+ };
80
+ export type MinimapOutMessage = {
81
+ type: "frame";
82
+ /** the transform the frame was rendered with */
83
+ transform: MinimapTransform;
84
+ /** `seq` of the elements the frame was rendered with */
85
+ elementsSeq: number;
86
+ /** bounds of those elements, in scene coordinates (null if there are none) */
87
+ contentBounds: MinimapBounds | null;
88
+ };
89
+ /** CSS pixels. Keeps the viewport visible (and grabbable) when tiny. */
90
+ export declare const MINIMAP_MIN_VIEWPORT_SIZE = 6;
91
+ export type MinimapBounds = [
92
+ minX: number,
93
+ minY: number,
94
+ maxX: number,
95
+ maxY: number
96
+ ];
97
+ /**
98
+ * The on-minimap rect of the viewport, grown to the minimum size around its
99
+ * center.
100
+ */
101
+ export declare const getMinimapViewportRect: (viewport: MinimapViewport, transform: MinimapTransform) => {
102
+ x: number;
103
+ y: number;
104
+ width: number;
105
+ height: number;
106
+ };
107
+ export type MinimapScheduler = {
108
+ requestFrame: (callback: () => void) => number;
109
+ cancelFrame: (id: number) => void;
110
+ };
111
+ /**
112
+ * Receives the messages of the editor and renders at most once per frame.
113
+ * Runs in the worker, or on the main thread where workers (or
114
+ * OffscreenCanvas) aren't available — there, supply the scheduler of the
115
+ * window the minimap is rendered in, which may not be the one the code runs
116
+ * in (an editor mounted into a pop-out window).
117
+ */
118
+ export declare const createMinimapEndpoint: (postMessage: (message: MinimapOutMessage) => void, { requestFrame, cancelFrame }?: MinimapScheduler) => {
119
+ handle: (message: MinimapInMessage) => void;
120
+ destroy: () => void;
121
+ };
122
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * DON'T depend on anything from the outside, as this module is part of a
3
+ * separate lazy-loaded chunk (see `subset-worker.chunk.ts` for details).
4
+ */
5
+ /**
6
+ * Due to this export (and related dynamic import), this worker code will be
7
+ * included in the bundle automatically (as a separate chunk), without the
8
+ * need for esbuild / vite / rollup plugins.
9
+ *
10
+ * `import.meta.url` is undefined in nodejs
11
+ */
12
+ export declare const WorkerUrl: URL | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
- import type { Scene } from "@excalidraw/element";
2
+ import type { RenderEnvironment, Scene } from "@excalidraw/element";
3
3
  import type { AppState } from "../../types";
4
4
  export type StatsInputProperty = "x" | "y" | "width" | "height" | "angle" | "fontSize" | "gridStep";
5
5
  export declare const SMALLEST_DELTA = 0.01;
@@ -15,5 +15,7 @@ export declare const newOrigin: (x1: number, y1: number, w1: number, h1: number,
15
15
  x: number;
16
16
  y: number;
17
17
  };
18
- export declare const moveElement: (newTopLeftX: number, newTopLeftY: number, originalElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, originalElementsMap: ElementsMap, shouldInformMutation?: boolean) => void;
18
+ export declare const moveElement: (newTopLeftX: number, newTopLeftY: number, originalElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, originalElementsMap: ElementsMap, shouldInformMutation?: boolean,
19
+ /** measures the labels of the bound arrows the move moves */
20
+ renderEnvironment?: RenderEnvironment) => void;
19
21
  export declare const getAtomicUnits: (targetElements: readonly ExcalidrawElement[], appState: AppState) => AtomicUnit[];
@@ -1,7 +1,8 @@
1
1
  import "./MermaidToExcalidraw.scss";
2
2
  import type { MermaidToExcalidrawLibProps } from "./types";
3
- declare const MermaidToExcalidraw: ({ mermaidToExcalidrawLib, isActive, }: {
3
+ declare const MermaidToExcalidraw: ({ mermaidToExcalidrawLib, onRetryLoad, isActive, }: {
4
4
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
5
+ onRetryLoad?: () => void;
5
6
  isActive?: boolean;
6
7
  }) => import("react/jsx-runtime").JSX.Element;
7
8
  export default MermaidToExcalidraw;
@@ -1,11 +1,14 @@
1
+ import type { MermaidToExcalidrawLibProps } from "./types";
1
2
  interface TTDDialogOutputProps {
2
3
  error: Error | null;
3
4
  canvasRef: React.RefObject<HTMLDivElement | null>;
4
- loaded: boolean;
5
+ loadStatus: MermaidToExcalidrawLibProps["status"];
6
+ loadErrorReloadRequired?: boolean;
7
+ onRetryLoad?: () => void;
5
8
  hideErrorDetails?: boolean;
6
9
  sourceText?: string;
7
10
  autoFixAvailable?: boolean;
8
11
  onApplyAutoFix?: () => void;
9
12
  }
10
- export declare const TTDDialogOutput: ({ error, canvasRef, loaded, hideErrorDetails, sourceText, autoFixAvailable, onApplyAutoFix, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const TTDDialogOutput: ({ error, canvasRef, loadStatus, loadErrorReloadRequired, onRetryLoad, hideErrorDetails, sourceText, autoFixAvailable, onApplyAutoFix, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
11
14
  export {};