@excalidraw/math 0.18.0-2b1c2a9 → 0.18.0-2c3dcc0

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 (164) hide show
  1. package/dist/dev/index.js +8 -2
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +3 -0
  5. package/dist/types/common/src/constants.d.ts +56 -0
  6. package/dist/types/common/src/keys.d.ts +4 -0
  7. package/dist/types/common/src/random.d.ts +7 -0
  8. package/dist/types/common/src/utils.d.ts +12 -1
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/align.d.ts +4 -1
  11. package/dist/types/element/src/binding.d.ts +75 -7
  12. package/dist/types/element/src/bounds.d.ts +10 -2
  13. package/dist/types/element/src/collision.d.ts +21 -5
  14. package/dist/types/element/src/comparisons.d.ts +5 -3
  15. package/dist/types/element/src/cropElement.d.ts +36 -4
  16. package/dist/types/element/src/delta.d.ts +30 -2
  17. package/dist/types/element/src/distribute.d.ts +4 -1
  18. package/dist/types/element/src/dragElements.d.ts +8 -3
  19. package/dist/types/element/src/duplicate.d.ts +60 -0
  20. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  21. package/dist/types/element/src/embeddable.d.ts +2 -1
  22. package/dist/types/element/src/flowchart.d.ts +6 -8
  23. package/dist/types/element/src/frame.d.ts +21 -3
  24. package/dist/types/element/src/groups.d.ts +1 -6
  25. package/dist/types/element/src/image.d.ts +5 -2
  26. package/dist/types/element/src/index.d.ts +3 -0
  27. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  28. package/dist/types/element/src/listMarker.d.ts +39 -0
  29. package/dist/types/element/src/mutateElement.d.ts +1 -1
  30. package/dist/types/element/src/newElement.d.ts +40 -3
  31. package/dist/types/element/src/renderElement.d.ts +31 -4
  32. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  33. package/dist/types/element/src/resizeElements.d.ts +15 -5
  34. package/dist/types/element/src/selection.d.ts +4 -10
  35. package/dist/types/element/src/shape.d.ts +17 -1
  36. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  37. package/dist/types/element/src/stickyNote.d.ts +191 -0
  38. package/dist/types/element/src/textElement.d.ts +10 -2
  39. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  40. package/dist/types/element/src/textWrapping.d.ts +3 -2
  41. package/dist/types/element/src/transform.d.ts +30 -7
  42. package/dist/types/element/src/typeChecks.d.ts +3 -2
  43. package/dist/types/element/src/types.d.ts +28 -6
  44. package/dist/types/element/src/utils.d.ts +8 -1
  45. package/dist/types/element/src/zindex.d.ts +1 -1
  46. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -3
  47. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  48. package/dist/types/excalidraw/actions/actionBoundText.d.ts +62 -208
  49. package/dist/types/excalidraw/actions/actionCanvas.d.ts +121 -16
  50. package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -2
  51. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -1
  52. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -546
  53. package/dist/types/excalidraw/actions/actionDeselect.d.ts +20 -2
  54. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  55. package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -1
  56. package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -2
  57. package/dist/types/excalidraw/actions/actionExport.d.ts +39 -9
  58. package/dist/types/excalidraw/actions/actionFrame.d.ts +92 -479
  59. package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -4
  60. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +66 -2
  61. package/dist/types/excalidraw/actions/actionLink.d.ts +16 -1
  62. package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -1
  63. package/dist/types/excalidraw/actions/actionProperties.d.ts +42 -8
  64. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -2
  65. package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -2
  66. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  67. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -1
  68. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -1
  69. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -1
  70. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  71. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -1
  72. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -1
  73. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  74. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -1
  75. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -1
  76. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  77. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -1
  78. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  79. package/dist/types/excalidraw/actions/index.d.ts +3 -0
  80. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  81. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  82. package/dist/types/excalidraw/appState.d.ts +26 -8
  83. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  84. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  85. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  86. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  87. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  88. package/dist/types/excalidraw/components/Actions.d.ts +10 -2
  89. package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
  90. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  91. package/dist/types/excalidraw/components/App.d.ts +129 -218
  92. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  93. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  94. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  95. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  96. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  97. package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
  98. package/dist/types/excalidraw/components/App.text.d.ts +194 -0
  99. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  100. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  101. package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
  102. package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
  103. package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
  104. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  105. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  106. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  107. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  108. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  109. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  110. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  111. package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
  112. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  113. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  114. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  115. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  116. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  117. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  118. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  119. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  120. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  121. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  122. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  123. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  124. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  125. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  126. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  127. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  128. package/dist/types/excalidraw/components/Tools.d.ts +7 -2
  129. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  130. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  131. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  132. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  133. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  134. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  135. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  136. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  137. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  138. package/dist/types/excalidraw/components/icons.d.ts +2 -0
  139. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
  140. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
  141. package/dist/types/excalidraw/data/blob.d.ts +46 -16
  142. package/dist/types/excalidraw/data/index.d.ts +3 -3
  143. package/dist/types/excalidraw/data/json.d.ts +23 -8
  144. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  145. package/dist/types/excalidraw/history.d.ts +10 -4
  146. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  147. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  148. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  149. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  150. package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
  151. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  152. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  153. package/dist/types/excalidraw/scene/Renderer.d.ts +64 -3
  154. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  155. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  156. package/dist/types/excalidraw/scene/types.d.ts +26 -2
  157. package/dist/types/excalidraw/types.d.ts +191 -22
  158. package/dist/types/excalidraw/viewport.d.ts +29 -1
  159. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  160. package/dist/types/utils/src/index.d.ts +3 -1
  161. package/dist/types/utils/src/shape.d.ts +2 -2
  162. package/package.json +2 -2
  163. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
  164. package/dist/types/utils/src/export.d.ts +0 -35
@@ -0,0 +1,12 @@
1
+ import type { FontFamilyValues } from "@excalidraw/element/types";
2
+ import type { TopPicksDnD } from "../TopPicksDnD/topPicksDnD";
3
+ export type FontPickerDnD = TopPicksDnD<FontFamilyValues>;
4
+ export declare const FontPickerDnDContext: import("react").Context<FontPickerDnD | null>;
5
+ export declare const useFontPickerDnD: () => FontPickerDnD | null;
6
+ /** pinning fonts from the font picker list to the top-picks strip, and
7
+ * reordering the strip */
8
+ export declare const useFontTopPicksDnD: ({ enabled, picks, onPicksChange, }: {
9
+ enabled: boolean;
10
+ picks: readonly FontFamilyValues[];
11
+ onPicksChange: (picks: FontFamilyValues[]) => void;
12
+ }) => FontPickerDnD;
@@ -41,6 +41,8 @@ type IconButtonProps = (IconButtonBaseProps & {
41
41
  onSelect?(data: {
42
42
  pointerType: PointerType | null;
43
43
  }): void;
44
+ /** the press that may become a click — e.g. to arm a drag out of the toolbar */
45
+ onPointerDown?(event: React.PointerEvent<HTMLButtonElement>): void;
44
46
  });
45
47
  export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<unknown>>;
46
48
  export {};
@@ -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 {};
@@ -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,7 +1,7 @@
1
1
  import type { AppClassProperties, AppState, ToolType, UIAppState } from "../types";
2
2
  export type ToolConfig = {
3
3
  icon: React.ReactNode;
4
- /** letter shortcut(s) — the first one is shown in tooltips */
4
+ /** letter shortcut(s) — the first one is shown in tooltips and badges */
5
5
  letterKey?: string | readonly string[];
6
6
  /** whether `letterKey` requires Shift to be held (e.g. Shift+X) */
7
7
  shiftKey?: boolean;
@@ -31,6 +31,7 @@ export declare const TOOLS: {
31
31
  line: ToolConfig;
32
32
  freedraw: ToolConfig;
33
33
  text: ToolConfig;
34
+ stickynote: ToolConfig;
34
35
  image: ToolConfig;
35
36
  eraser: ToolConfig;
36
37
  frame: ToolConfig;
@@ -49,7 +50,7 @@ export declare const TOGGLE_TOOLS: readonly (ToolType | "custom")[];
49
50
  export declare const getToolLetter: (type: ToolbarToolType) => string | undefined;
50
51
  /** human-readable shortcut hint, e.g. "R or 2", used in tooltips & aria */
51
52
  export declare const getToolShortcut: (type: ToolbarToolType) => string;
52
- export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
53
+ export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
53
54
  /**
54
55
  * Whether a toolbar entry activating the given tool renders disabled — true
55
56
  * when the active tool is host-controlled (`props.activeTool`) and the entry
@@ -99,6 +100,10 @@ export declare const TextToolButton: {
99
100
  ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
100
101
  displayName: string;
101
102
  };
103
+ export declare const StickyNoteToolButton: {
104
+ ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
105
+ displayName: string;
106
+ };
102
107
  export declare const ImageToolButton: {
103
108
  ({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
104
109
  displayName: string;
@@ -1,18 +1,42 @@
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. */
20
+ export declare const hideTooltip: () => void;
21
+ /**
22
+ * Shows the tooltip for `item`. For elements that can't be wrapped
23
+ * in <Tooltip>. Pair with `hideTooltip()`.
24
+ */
25
+ export declare const showTooltip: (item: HTMLElement, label: string, { long, delay, position, }?: {
26
+ long?: boolean;
27
+ /** show after a short delay (unless a tooltip was visible just now) */
28
+ delay?: boolean;
29
+ position?: "bottom" | "top";
30
+ }) => void;
10
31
  type TooltipProps = {
11
32
  children: React.ReactNode;
12
33
  label: string;
13
34
  long?: boolean;
14
35
  style?: React.CSSProperties;
36
+ className?: string;
15
37
  disabled?: boolean;
38
+ /** show after a short delay (unless a tooltip was visible just now) */
39
+ delay?: boolean;
16
40
  };
17
- export declare const Tooltip: ({ children, label, long, style, disabled, }: TooltipProps) => import("react/jsx-runtime").JSX.Element | null;
41
+ export declare const Tooltip: ({ children, label, long, style, className, disabled, delay, }: TooltipProps) => import("react/jsx-runtime").JSX.Element | null;
18
42
  export {};
@@ -0,0 +1,14 @@
1
+ import type { ReactElement } from "react";
2
+ /**
3
+ * right-click context menu of a customizable top-picks strip, resetting it
4
+ * to its default picks. Renders the strip as-is when not customizable.
5
+ */
6
+ export declare const TopPicksContextMenu: ({ children, onReset, isCustomized, resetLabel, }: {
7
+ /** the strip (must accept a ref — used as the menu trigger) */
8
+ children: ReactElement;
9
+ /** present when the strip is user-customizable */
10
+ onReset?: () => void;
11
+ /** whether custom picks are currently applied (enables the reset item) */
12
+ isCustomized: boolean;
13
+ resetLabel: string;
14
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * "drag to pin" hint shown in a picker popup whose top picks are
3
+ * customizable — with a reset link while the picks are customized
4
+ */
5
+ export declare const TopPicksTip: ({ className, tip, onReset, resetTitle, }: {
6
+ className?: string;
7
+ tip: string;
8
+ /** present only while the top picks are customized */
9
+ onReset?: () => void;
10
+ resetTitle: string;
11
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,58 @@
1
+ import "./TopPicksDnD.scss";
2
+ type DragOrigin = {
3
+ kind: "source";
4
+ } | {
5
+ kind: "pick";
6
+ index: number;
7
+ };
8
+ export type TopPicksDragState<T> = {
9
+ value: T;
10
+ origin: DragOrigin;
11
+ /** hovered strip slot — the slot to replace (source drags) or the final
12
+ * position (pick reorders). null while the pointer is outside the strip */
13
+ overIndex: number | null;
14
+ /** index of an already-pinned identical value that blocks the drop */
15
+ duplicateIndex: number | null;
16
+ /** signed distance between strip slot centers (for reorder preview) */
17
+ slotSpan: number;
18
+ } | null;
19
+ export type TopPicksGhost = {
20
+ /** the ghost's visual. Rendered into the source's `document.body` — outside the
21
+ * editor's CSS scope, so theme-dependent styling must be resolved from the
22
+ * rendered DOM (computed styles) rather than CSS variables */
23
+ content: HTMLElement;
24
+ /** where the ghost spawns (its size) and flies back to on cancel */
25
+ rect: DOMRect;
26
+ };
27
+ /** called on pointerdown (the source may not stay mounted until the drag
28
+ * activates), for every potential drag — keep it cheap */
29
+ export type CreateTopPicksGhost<T> = (args: {
30
+ value: T;
31
+ /** the element the drag started on */
32
+ sourceEl: HTMLElement;
33
+ /** the registered strip */
34
+ stripEl: HTMLElement;
35
+ }) => TopPicksGhost;
36
+ export type TopPicksDnD<T> = {
37
+ dragState: TopPicksDragState<T>;
38
+ startSourceDrag: (event: React.PointerEvent, value: T | null) => void;
39
+ startPickDrag: (event: React.PointerEvent, index: number, value: T) => void;
40
+ setStripEl: (el: HTMLDivElement | null) => void;
41
+ };
42
+ /**
43
+ * live preview of the reorder result — the translation (px) moving the pick
44
+ * at `index` to the slot it would occupy if dropped right now
45
+ */
46
+ export declare const getTopPickReorderOffset: (dragState: TopPicksDragState<unknown>, index: number) => number;
47
+ /** "marching ants" outline hinting that the strip accepts the drop — SVG
48
+ * because CSS dashed outlines/borders can't animate their dash offset */
49
+ export declare const TopPicksDnDOutline: () => import("react/jsx-runtime").JSX.Element;
50
+ export declare const useTopPicksDnD: <T>({ enabled, picks, onPicksChange, isSamePick, createGhost, }: {
51
+ enabled: boolean;
52
+ picks: readonly T[];
53
+ onPicksChange: (picks: T[]) => void;
54
+ /** value-equality — pins identical to an existing pick are refused */
55
+ isSamePick?: (a: T, b: T) => boolean;
56
+ createGhost: CreateTopPicksGhost<T>;
57
+ }) => TopPicksDnD<T>;
58
+ export {};