@excalidraw/common 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 (119) hide show
  1. package/dist/dev/index.js +28 -18
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/constants.d.ts +1 -0
  5. package/dist/types/common/src/utils.d.ts +7 -1
  6. package/dist/types/element/src/align.d.ts +4 -1
  7. package/dist/types/element/src/binding.d.ts +62 -0
  8. package/dist/types/element/src/bounds.d.ts +10 -2
  9. package/dist/types/element/src/collision.d.ts +7 -0
  10. package/dist/types/element/src/cropElement.d.ts +36 -4
  11. package/dist/types/element/src/delta.d.ts +7 -1
  12. package/dist/types/element/src/distribute.d.ts +4 -1
  13. package/dist/types/element/src/dragElements.d.ts +8 -3
  14. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  15. package/dist/types/element/src/embeddable.d.ts +2 -1
  16. package/dist/types/element/src/flowchart.d.ts +1 -7
  17. package/dist/types/element/src/frame.d.ts +19 -1
  18. package/dist/types/element/src/groups.d.ts +1 -6
  19. package/dist/types/element/src/image.d.ts +5 -2
  20. package/dist/types/element/src/index.d.ts +1 -0
  21. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  22. package/dist/types/element/src/listMarker.d.ts +7 -2
  23. package/dist/types/element/src/newElement.d.ts +3 -1
  24. package/dist/types/element/src/renderElement.d.ts +10 -0
  25. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  26. package/dist/types/element/src/resizeElements.d.ts +15 -5
  27. package/dist/types/element/src/selection.d.ts +1 -7
  28. package/dist/types/element/src/shape.d.ts +2 -0
  29. package/dist/types/element/src/stickyNote.d.ts +8 -0
  30. package/dist/types/element/src/textElement.d.ts +3 -2
  31. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  32. package/dist/types/element/src/textWrapping.d.ts +3 -2
  33. package/dist/types/element/src/transform.d.ts +5 -1
  34. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -0
  35. package/dist/types/excalidraw/actions/actionBoundText.d.ts +47 -221
  36. package/dist/types/excalidraw/actions/actionCanvas.d.ts +9 -5
  37. package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -0
  38. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -0
  39. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -588
  40. package/dist/types/excalidraw/actions/actionDeselect.d.ts +1 -0
  41. package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -0
  42. package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -0
  43. package/dist/types/excalidraw/actions/actionExport.d.ts +4 -2
  44. package/dist/types/excalidraw/actions/actionFrame.d.ts +44 -525
  45. package/dist/types/excalidraw/actions/actionGroup.d.ts +2 -0
  46. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -0
  47. package/dist/types/excalidraw/actions/actionLink.d.ts +1 -0
  48. package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -0
  49. package/dist/types/excalidraw/actions/actionProperties.d.ts +2 -0
  50. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -0
  51. package/dist/types/excalidraw/actions/actionStyles.d.ts +1 -0
  52. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -0
  53. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -0
  54. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -0
  55. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  56. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -0
  57. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -0
  58. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +1 -0
  59. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -0
  60. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -0
  61. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  62. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -0
  63. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  64. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  65. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  66. package/dist/types/excalidraw/appState.d.ts +3 -2
  67. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  68. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  69. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  70. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  71. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  72. package/dist/types/excalidraw/components/Actions.d.ts +9 -2
  73. package/dist/types/excalidraw/components/App.d.ts +23 -8
  74. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  75. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  76. package/dist/types/excalidraw/components/App.selectionTool.d.ts +42 -6
  77. package/dist/types/excalidraw/components/App.viewport.d.ts +23 -3
  78. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  79. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  80. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  81. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  82. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  83. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  84. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  85. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  86. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  87. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  88. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  89. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  90. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  91. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  92. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  93. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  94. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  95. package/dist/types/excalidraw/components/Tooltip.d.ts +11 -1
  96. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  97. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  98. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  99. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  100. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  101. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  102. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
  103. package/dist/types/excalidraw/data/blob.d.ts +6 -4
  104. package/dist/types/excalidraw/data/index.d.ts +3 -3
  105. package/dist/types/excalidraw/data/json.d.ts +3 -2
  106. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  107. package/dist/types/excalidraw/history.d.ts +10 -4
  108. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  109. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  110. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  111. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  112. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  113. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  114. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  115. package/dist/types/excalidraw/types.d.ts +48 -1
  116. package/dist/types/excalidraw/viewport.d.ts +1 -0
  117. package/dist/types/utils/src/index.d.ts +3 -1
  118. package/package.json +1 -1
  119. package/dist/types/utils/src/export.d.ts +0 -36
@@ -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
  };
@@ -34,6 +34,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
34
34
  name: string | null;
35
35
  currentItemArrowType: "sharp" | "round" | "elbow";
36
36
  gridSize: number;
37
+ scrollX: number;
38
+ scrollY: number;
37
39
  contextMenu: {
38
40
  items: import("../components/ContextMenu").ContextMenuItems;
39
41
  top: number;
@@ -109,8 +111,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
109
111
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
110
112
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
111
113
  viewBackgroundColor: string;
112
- scrollX: number;
113
- scrollY: number;
114
114
  scrollConstraints: import("../types").ScrollConstraints | null;
115
115
  cursorButton: "up" | "down";
116
116
  scrolledOutside: boolean;
@@ -157,6 +157,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
157
157
  closable?: boolean;
158
158
  duration?: number;
159
159
  } | null;
160
+ minimapEnabled: boolean;
160
161
  gridStep: number;
161
162
  selectedGroupIds: {
162
163
  [groupId: string]: boolean;
@@ -222,6 +223,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
222
223
  name: string | null;
223
224
  currentItemArrowType: "sharp" | "round" | "elbow";
224
225
  gridSize: number;
226
+ scrollX: number;
227
+ scrollY: number;
225
228
  contextMenu: {
226
229
  items: import("../components/ContextMenu").ContextMenuItems;
227
230
  top: number;
@@ -297,8 +300,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
297
300
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
298
301
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
299
302
  viewBackgroundColor: string;
300
- scrollX: number;
301
- scrollY: number;
302
303
  scrollConstraints: import("../types").ScrollConstraints | null;
303
304
  cursorButton: "up" | "down";
304
305
  scrolledOutside: boolean;
@@ -345,6 +346,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
345
346
  closable?: boolean;
346
347
  duration?: number;
347
348
  } | null;
349
+ minimapEnabled: boolean;
348
350
  gridStep: number;
349
351
  selectedGroupIds: {
350
352
  [groupId: string]: boolean;
@@ -1,4 +1,5 @@
1
1
  import type { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { RenderEnvironment } from "@excalidraw/element";
2
3
  import type { ExportType } from "../scene/types";
3
4
  import type { AppState, BinaryFiles } from "../types";
4
5
  export { loadFromBlob } from "./blob";
@@ -10,12 +11,11 @@ export declare const prepareElementsForExport: (allElements: readonly Excalidraw
10
11
  exportingFrame: NonDeleted<ExcalidrawFrameLikeElement> | null;
11
12
  exportedElements: ExportedElements;
12
13
  };
13
- export declare const exportCanvas: (type: Omit<ExportType, "backend">, elements: ExportedElements, appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, name, fileHandle, exportingFrame, }: {
14
- exportBackground: boolean;
14
+ export declare const exportCanvas: (type: Omit<ExportType, "backend">, elements: ExportedElements, appState: AppState, files: BinaryFiles, { exportPadding, name, fileHandle, exportingFrame, renderEnvironment, }: {
15
15
  exportPadding?: number;
16
- viewBackgroundColor: string;
17
16
  /** filename, if applicable */
18
17
  name?: string;
19
18
  fileHandle?: FileSystemFileHandle | null;
20
19
  exportingFrame: NonDeleted<ExcalidrawFrameLikeElement> | null;
20
+ renderEnvironment?: RenderEnvironment;
21
21
  }) => Promise<FileSystemFileHandle | null | undefined>;
@@ -32,6 +32,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
32
32
  name: string | null;
33
33
  currentItemArrowType: "sharp" | "round" | "elbow";
34
34
  gridSize: number;
35
+ scrollX: number;
36
+ scrollY: number;
35
37
  contextMenu: {
36
38
  items: import("../components/ContextMenu").ContextMenuItems;
37
39
  top: number;
@@ -107,8 +109,6 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
107
109
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
108
110
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
109
111
  viewBackgroundColor: string;
110
- scrollX: number;
111
- scrollY: number;
112
112
  scrollConstraints: import("../types").ScrollConstraints | null;
113
113
  cursorButton: "up" | "down";
114
114
  scrolledOutside: boolean;
@@ -155,6 +155,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
155
155
  closable?: boolean;
156
156
  duration?: number;
157
157
  } | null;
158
+ minimapEnabled: boolean;
158
159
  gridStep: number;
159
160
  selectedGroupIds: {
160
161
  [groupId: string]: boolean;
@@ -1,5 +1,5 @@
1
1
  import { type FontMetadata } from "@excalidraw/common";
2
- import type { ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
3
3
  import type { Scene } from "@excalidraw/element";
4
4
  import { ExcalidrawFontFace } from "./ExcalidrawFontFace";
5
5
  export declare class Fonts {
@@ -16,6 +16,7 @@ export declare class Fonts {
16
16
  }>;
17
17
  private readonly scene;
18
18
  private readonly ownerDocument;
19
+ private readonly loadedFonts;
19
20
  constructor(scene: Scene, ownerDocument?: Document);
20
21
  /**
21
22
  * Get all the font families for the given scene.
@@ -33,9 +34,15 @@ export declare class Fonts {
33
34
  /**
34
35
  * Load font faces for a given scene and trigger scene update.
35
36
  */
36
- loadSceneFonts: () => Promise<FontFace[]>;
37
+ loadSceneFonts: (defaultFontFamily?: ExcalidrawTextElement["fontFamily"]) => Promise<FontFace[]>;
37
38
  /**
38
39
  * Load font faces for passed elements - use when the scene is unavailable (i.e. export).
40
+ *
41
+ * Loads into the document's font set, or in a worker into the worker's own
42
+ * (`self.fonts`, what an `OffscreenCanvas` there measures with). Where there
43
+ * is neither -- e.g. a DOM shim without `FontFaceSet` (`linkedom`), or Node
44
+ * -- nothing is loaded: the host makes the fonts available itself, and is
45
+ * warned once if the elements use fonts that would need loading.
39
46
  */
40
47
  static loadElementsFonts: (elements: readonly ExcalidrawElement[], ownerDocument?: Document) => Promise<FontFace[]>;
41
48
  /**
@@ -69,10 +76,6 @@ export declare class Fonts {
69
76
  * Get characters for a given family.
70
77
  */
71
78
  private static getCharacters;
72
- /**
73
- * Get all registered font families.
74
- */
75
- private static getAllFamilies;
76
79
  }
77
80
  export interface ExcalidrawFontFaceDescriptor {
78
81
  uri: string;