@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
@@ -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 {};
@@ -1,9 +1,12 @@
1
+ import type { MermaidToExcalidrawLibProps } from "./types";
1
2
  interface TTDPreviewPanelProps {
2
3
  canvasRef: React.RefObject<HTMLDivElement | null>;
3
4
  error: Error | null;
4
- loaded: boolean;
5
+ loadStatus: MermaidToExcalidrawLibProps["status"];
6
+ loadErrorReloadRequired?: boolean;
7
+ onRetryLoad?: () => void;
5
8
  onInsert: () => void;
6
9
  hideErrorDetails?: boolean;
7
10
  }
8
- export declare const TTDPreviewPanel: ({ canvasRef, error, loaded, onInsert, hideErrorDetails, }: TTDPreviewPanelProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const TTDPreviewPanel: ({ canvasRef, error, loadStatus, loadErrorReloadRequired, onRetryLoad, onInsert, hideErrorDetails, }: TTDPreviewPanelProps) => import("react/jsx-runtime").JSX.Element;
9
12
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { MermaidToExcalidrawLibProps, TTDPersistenceAdapter, TTTDDialog } from "./types";
2
- export declare const TextToDiagram: ({ mermaidToExcalidrawLib, onTextSubmit, renderWelcomeScreen, renderWarning, persistenceAdapter, }: {
2
+ export declare const TextToDiagram: ({ mermaidToExcalidrawLib, onRetryLoad, onTextSubmit, renderWelcomeScreen, renderWarning, persistenceAdapter, }: {
3
3
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
4
+ onRetryLoad?: () => void;
4
5
  onTextSubmit(props: TTTDDialog.OnTextSubmitProps): Promise<TTTDDialog.OnTextSubmitRetValue>;
5
6
  renderWelcomeScreen?: TTTDDialog.renderWelcomeScreen;
6
7
  renderWarning?: TTTDDialog.renderWarning;
@@ -1,3 +1,4 @@
1
+ import type { RenderEnvironment } from "@excalidraw/element";
1
2
  import type { NonDeletedExcalidrawElement, Theme } from "@excalidraw/element/types";
2
3
  import type { MermaidToExcalidrawLibProps } from "./types";
3
4
  import type { AppClassProperties, BinaryFiles } from "../../types";
@@ -5,7 +6,7 @@ export declare const resetPreview: ({ canvasRef, setError, }: {
5
6
  canvasRef: React.RefObject<HTMLDivElement | null>;
6
7
  setError: (error: Error | null) => void;
7
8
  }) => void;
8
- export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidrawLib, mermaidDefinition, setError, data, theme, }: {
9
+ export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidrawLib, mermaidDefinition, setError, data, theme, renderEnvironment, }: {
9
10
  canvasRef: React.RefObject<HTMLDivElement | null>;
10
11
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
11
12
  mermaidDefinition: string;
@@ -15,6 +16,8 @@ export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidr
15
16
  files: BinaryFiles | null;
16
17
  }>;
17
18
  theme: Theme;
19
+ /** the host's environment (`app.renderEnvironment`), to measure labels with */
20
+ renderEnvironment?: RenderEnvironment;
18
21
  }) => Promise<{
19
22
  success: true;
20
23
  } | {
@@ -1,6 +1,7 @@
1
- import type { TTTDDialog } from "../types";
2
- export declare const useTextGeneration: ({ onTextSubmit, }: {
1
+ import type { MermaidToExcalidrawLibProps, TTTDDialog } from "../types";
2
+ export declare const useTextGeneration: ({ onTextSubmit, mermaidToExcalidrawLib, }: {
3
3
  onTextSubmit: (props: TTTDDialog.OnTextSubmitProps) => Promise<TTTDDialog.OnTextSubmitRetValue>;
4
+ mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
4
5
  }) => {
5
6
  onGenerate: TTTDDialog.OnGenerate;
6
7
  handleAbort: () => void;
@@ -27,6 +27,12 @@ export declare namespace TChat {
27
27
  type: "user" | "assistant" | "warning";
28
28
  warningType?: /* daily rate limit */ "messageLimitExceeded" | /* general 429 */ "rateLimitExceeded";
29
29
  content?: string;
30
+ /**
31
+ * What an assistant's diagram was rendered with: Pele, since
32
+ * `@excalidraw/mermaid-to-excalidraw` v3. Not set on (saved) messages
33
+ * from before, which were rendered with Mermaid.
34
+ */
35
+ renderer?: "pele";
30
36
  };
31
37
  type ChatHistory = {
32
38
  id: string;
@@ -57,7 +63,14 @@ export interface TTDPersistenceAdapter {
57
63
  saveChats(chats: SavedChats): Promise<void>;
58
64
  }
59
65
  export interface MermaidToExcalidrawLibProps {
60
- loaded: boolean;
66
+ /** loading state of the (lazy) lib. "error" e.g. while offline */
67
+ status: "loading" | "loaded" | "error";
68
+ /**
69
+ * set when loading failed while online (e.g. stale app version after
70
+ * a deploy, or the browser cached the failed fetch), i.e. only a page
71
+ * reload will likely recover
72
+ */
73
+ reloadRequired?: boolean;
61
74
  api: Promise<{
62
75
  parseMermaidToExcalidraw: (definition: string, config?: MermaidConfig) => Promise<MermaidToExcalidrawResult>;
63
76
  }>;
@@ -1,10 +1,26 @@
1
+ /** a lazy-loaded chunk (e.g. one of Pele's diagram chunks) failed to load */
2
+ export declare const isModuleLoadError: (error: unknown) => boolean;
1
3
  export declare const isMermaidParseSyntaxError: (message: string) => boolean;
4
+ /** the definition doesn't start with a (known) diagram type */
5
+ export declare const isMermaidUnknownDiagramError: (message: string) => boolean;
2
6
  export declare const isMermaidAutoFixableError: (message: string) => boolean;
7
+ export type MermaidDiagramType = "flowchart" | "sequence" | "class" | "state" | "er";
8
+ /**
9
+ * Index of the line that declares the diagram type: the first one that isn't
10
+ * empty, a comment, a directive (`%%{...}%%`) or front matter (`---` block).
11
+ */
12
+ export declare const getMermaidHeaderLineIndex: (sourceText: string) => number | null;
13
+ /** The diagram type the definition declares (of those Excalidraw converts). */
14
+ export declare const getMermaidDiagramType: (sourceText: string) => MermaidDiagramType | null;
3
15
  export declare const isMermaidCaretLine: (line: string) => boolean;
4
16
  export declare const getMermaidInactiveParticipant: (message: string) => string | null;
5
17
  export declare const getMermaidErrorLineNumber: (message: string, sourceText?: string) => number | null;
18
+ /** A line closing a block that `end`s */
19
+ export declare const MERMAID_END_LINE: RegExp;
20
+ export declare const getMermaidEndBlockOpener: (type: MermaidDiagramType | null) => RegExp | null;
6
21
  export declare const getMermaidSyntaxErrorGuidance: (message: string, sourceText?: string) => {
7
22
  summary: string;
8
23
  likelyCauses: string[];
9
24
  } | null;
25
+ /** The parse error, without the tokens it expected */
10
26
  export declare const formatMermaidParseErrorMessage: (message: string) => string;
@@ -1,12 +1,22 @@
1
1
  import React from "react";
2
2
  import "./Tooltip.scss";
3
- export declare const getTooltipDiv: () => HTMLDivElement;
3
+ export declare const TOOLTIP_CLASS = "excalidraw-tooltip";
4
+ export declare const TOOLTIP_VISIBLE_CLASS = "excalidraw-tooltip--visible";
5
+ export declare const getTooltipDiv: (ownerDocument: Document) => HTMLDivElement;
6
+ /**
7
+ * Hides `ownerDocument`'s tooltip, for tooltips not shown through
8
+ * `showTooltip` (see `hideTooltip`).
9
+ */
10
+ export declare const hideDocumentTooltip: (ownerDocument: Document) => void;
4
11
  export declare const updateTooltipPosition: (tooltip: HTMLDivElement, item: {
5
12
  left: number;
6
13
  top: number;
7
14
  width: number;
8
15
  height: number;
9
16
  }, position?: "bottom" | "top") => void;
17
+ /** ms before a `delay`ed tooltip shows */
18
+ export declare const TOOLTIP_DELAY = 500;
19
+ /** Hides the tooltip `showTooltip` shows, and cancels a pending one. */
10
20
  export declare const hideTooltip: () => void;
11
21
  /**
12
22
  * Shows the tooltip for `item`. For elements that can't be wrapped
@@ -17,7 +17,7 @@ export type TopPicksDragState<T> = {
17
17
  slotSpan: number;
18
18
  } | null;
19
19
  export type TopPicksGhost = {
20
- /** the ghost's visual. Rendered into `document.body` — outside the
20
+ /** the ghost's visual. Rendered into the source's `document.body` — outside the
21
21
  * editor's CSS scope, so theme-dependent styling must be resolved from the
22
22
  * rendered DOM (computed styles) rather than CSS variables */
23
23
  content: HTMLElement;
@@ -31,6 +31,5 @@ type InteractiveCanvasProps = {
31
31
  onPointerDown: Exclude<DOMAttributes<HTMLCanvasElement>["onPointerDown"], undefined>;
32
32
  onDoubleClick: Exclude<DOMAttributes<HTMLCanvasElement>["onDoubleClick"], undefined>;
33
33
  };
34
- export declare const INTERACTIVE_SCENE_ANIMATION_KEY = "animateInteractiveScene";
35
34
  declare const _default: React.MemoExoticComponent<(props: InteractiveCanvasProps) => import("react/jsx-runtime").JSX.Element>;
36
35
  export default _default;
@@ -1,13 +1,15 @@
1
1
  import type { ActionManager } from "../../actions/manager";
2
2
  import type { UIAppState } from "../../types";
3
3
  declare const Footer: {
4
- ({ appState, actionManager, showExitZenModeBtn, renderWelcomeScreen, defaultUIEnabled, zoomUIEnabled, }: {
4
+ ({ appState, actionManager, showExitZenModeBtn, renderWelcomeScreen, defaultUIEnabled, zoomUIEnabled, minimapUIEnabled, }: {
5
5
  appState: UIAppState;
6
6
  actionManager: ActionManager;
7
7
  showExitZenModeBtn: boolean;
8
8
  renderWelcomeScreen: boolean;
9
9
  defaultUIEnabled: boolean;
10
10
  zoomUIEnabled: boolean;
11
+ /** whether the minimap (when toggled on) and its toggle are rendered */
12
+ minimapUIEnabled: boolean;
11
13
  }): import("react/jsx-runtime").JSX.Element;
12
14
  displayName: string;
13
15
  };
@@ -2,6 +2,7 @@ import type { Scene } from "@excalidraw/element";
2
2
  import type { ElementsMap, ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  import "./Hyperlink.scss";
4
4
  import type { AppState, ExcalidrawProps, UIAppState } from "../../types";
5
+ export type HyperlinkTooltipOwner = Record<string, unknown>;
5
6
  export declare const Hyperlink: ({ element, scene, setAppState, onLinkOpen, setToast, updateEmbedValidationStatus, }: {
6
7
  element: NonDeletedExcalidrawElement;
7
8
  scene: Scene;
@@ -15,5 +16,5 @@ export declare const Hyperlink: ({ element, scene, setAppState, onLinkOpen, setT
15
16
  updateEmbedValidationStatus: (element: ExcalidrawEmbeddableElement, status: boolean) => void;
16
17
  }) => import("react/jsx-runtime").JSX.Element | null;
17
18
  export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.create";
18
- export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState, elementsMap: ElementsMap) => void;
19
- export declare const hideHyperlinkToolip: () => void;
19
+ export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState, elementsMap: ElementsMap, ownerDocument: Document, owner: HyperlinkTooltipOwner) => void;
20
+ export declare const hideHyperlinkToolip: (owner?: HyperlinkTooltipOwner) => void;
@@ -1,10 +1,21 @@
1
+ import type { RenderEnvironment } from "@excalidraw/element/renderEnvironment";
1
2
  import type { GlobalPoint, Radians } from "@excalidraw/math";
2
3
  import type { Bounds } from "@excalidraw/common";
3
4
  import type { ElementsMap, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
4
5
  import type { AppState } from "../../types";
5
6
  export declare const DEFAULT_LINK_SIZE = 12;
6
- export declare const EXTERNAL_LINK_IMG: HTMLImageElement;
7
- export declare const ELEMENT_LINK_IMG: HTMLImageElement;
7
+ type SettledLinkImgStatus = Exclude<LinkImgStatus, "decoding">;
8
+ export type LinkImgStatus = "decoding" | "decoded" | "failed";
9
+ export type LinkImg = {
10
+ /** Only safe as a `drawImage` source while `status` is `decoded`. */
11
+ img: HTMLImageElement;
12
+ status: LinkImgStatus;
13
+ settled: Promise<SettledLinkImgStatus>;
14
+ };
15
+ export declare const getExternalLinkImg: (renderEnvironment: RenderEnvironment) => LinkImg;
16
+ export declare const getElementLinkImg: (renderEnvironment: RenderEnvironment) => LinkImg;
17
+ export declare const startLinkImgDecoding: (renderEnvironment: RenderEnvironment) => Promise<boolean>;
8
18
  export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: Radians, appState: Pick<AppState, "zoom">) => Bounds;
9
19
  export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, [x, y]: GlobalPoint) => boolean;
10
20
  export declare const isPointHittingLink: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, [x, y]: GlobalPoint, isMobile: boolean) => boolean;
21
+ export {};
@@ -230,6 +230,7 @@ export declare const zoomAreaIcon: import("react/jsx-runtime").JSX.Element;
230
230
  export declare const svgIcon: import("react/jsx-runtime").JSX.Element;
231
231
  export declare const pngIcon: import("react/jsx-runtime").JSX.Element;
232
232
  export declare const magnetIcon: import("react/jsx-runtime").JSX.Element;
233
+ export declare const minimapIcon: import("react/jsx-runtime").JSX.Element;
233
234
  export declare const coffeeIcon: import("react/jsx-runtime").JSX.Element;
234
235
  export declare const DeviceDesktopIcon: import("react/jsx-runtime").JSX.Element;
235
236
  export declare const loginIcon: import("react/jsx-runtime").JSX.Element;
@@ -82,6 +82,7 @@ export declare const Preferences: {
82
82
  ToggleGridMode: () => import("react/jsx-runtime").JSX.Element;
83
83
  ToggleZenMode: () => import("react/jsx-runtime").JSX.Element;
84
84
  ToggleViewMode: () => import("react/jsx-runtime").JSX.Element | null;
85
+ ToggleMinimap: () => import("react/jsx-runtime").JSX.Element | null;
85
86
  ToggleElementProperties: () => import("react/jsx-runtime").JSX.Element;
86
87
  displayName: string;
87
88
  };
@@ -30,6 +30,11 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
30
30
  };
31
31
  name: string | null;
32
32
  zoom: import("../types").Zoom;
33
+ isBindingEnabled: boolean;
34
+ isMidpointSnappingEnabled: boolean;
35
+ selectedElementIds: Readonly<{
36
+ [id: string]: true;
37
+ }>;
33
38
  scrollX: number;
34
39
  scrollY: number;
35
40
  viewModeEnabled: boolean;
@@ -51,9 +56,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
51
56
  rawText: string;
52
57
  };
53
58
  editingGroupId: import("@excalidraw/element/types").GroupId | null;
54
- selectedElementIds: Readonly<{
55
- [id: string]: true;
56
- }>;
57
59
  frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
58
60
  activeTool: {
59
61
  lastActiveTool: import("../types").ActiveTool | null;
@@ -71,8 +73,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
71
73
  selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
72
74
  multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
73
75
  newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
74
- isBindingEnabled: boolean;
75
- isMidpointSnappingEnabled: boolean;
76
76
  gridModeEnabled: boolean;
77
77
  suggestedBinding: {
78
78
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
@@ -108,8 +108,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
108
108
  shouldCacheIgnoreZoom: boolean;
109
109
  exportScale: number;
110
110
  currentItemArrowType: "sharp" | "round" | "elbow";
111
- gridSize: number;
112
- bindMode: import("@excalidraw/element/types").BindMode;
113
111
  contextMenu: {
114
112
  items: import("../components/ContextMenu").ContextMenuItems;
115
113
  top: number;
@@ -171,6 +169,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
171
169
  closable?: boolean;
172
170
  duration?: number;
173
171
  } | null;
172
+ minimapEnabled: boolean;
173
+ gridSize: number;
174
174
  gridStep: number;
175
175
  fileHandle: FileSystemFileHandle | null;
176
176
  stats: {
@@ -186,6 +186,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
186
186
  lockedMultiSelections: {
187
187
  [groupId: string]: true;
188
188
  };
189
+ bindMode: import("@excalidraw/element/types").BindMode;
189
190
  colorTopPicks: {
190
191
  elementStroke: readonly string[] | null;
191
192
  elementBackground: readonly string[] | null;
@@ -218,6 +219,11 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
218
219
  };
219
220
  name: string | null;
220
221
  zoom: import("../types").Zoom;
222
+ isBindingEnabled: boolean;
223
+ isMidpointSnappingEnabled: boolean;
224
+ selectedElementIds: Readonly<{
225
+ [id: string]: true;
226
+ }>;
221
227
  scrollX: number;
222
228
  scrollY: number;
223
229
  viewModeEnabled: boolean;
@@ -239,9 +245,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
239
245
  rawText: string;
240
246
  };
241
247
  editingGroupId: import("@excalidraw/element/types").GroupId | null;
242
- selectedElementIds: Readonly<{
243
- [id: string]: true;
244
- }>;
245
248
  frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
246
249
  activeTool: {
247
250
  lastActiveTool: import("../types").ActiveTool | null;
@@ -259,8 +262,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
259
262
  selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
260
263
  multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
261
264
  newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
262
- isBindingEnabled: boolean;
263
- isMidpointSnappingEnabled: boolean;
264
265
  gridModeEnabled: boolean;
265
266
  suggestedBinding: {
266
267
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
@@ -296,8 +297,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
296
297
  shouldCacheIgnoreZoom: boolean;
297
298
  exportScale: number;
298
299
  currentItemArrowType: "sharp" | "round" | "elbow";
299
- gridSize: number;
300
- bindMode: import("@excalidraw/element/types").BindMode;
301
300
  contextMenu: {
302
301
  items: import("../components/ContextMenu").ContextMenuItems;
303
302
  top: number;
@@ -359,6 +358,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
359
358
  closable?: boolean;
360
359
  duration?: number;
361
360
  } | null;
361
+ minimapEnabled: boolean;
362
+ gridSize: number;
362
363
  gridStep: number;
363
364
  fileHandle: FileSystemFileHandle | null;
364
365
  stats: {
@@ -374,6 +375,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
374
375
  lockedMultiSelections: {
375
376
  [groupId: string]: true;
376
377
  };
378
+ bindMode: import("@excalidraw/element/types").BindMode;
377
379
  colorTopPicks: {
378
380
  elementStroke: readonly string[] | null;
379
381
  elementBackground: readonly string[] | null;