@excalidraw/common 0.18.0-1118751 → 0.18.0-1440f2d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/dev/index.js +37 -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 +4 -0
  5. package/dist/types/common/src/utils.d.ts +12 -1
  6. package/dist/types/element/src/align.d.ts +4 -1
  7. package/dist/types/element/src/binding.d.ts +70 -0
  8. package/dist/types/element/src/bounds.d.ts +10 -2
  9. package/dist/types/element/src/collision.d.ts +13 -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 +2 -0
  21. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  22. package/dist/types/element/src/listMarker.d.ts +39 -0
  23. package/dist/types/element/src/newElement.d.ts +17 -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 +10 -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 +30 -3
  35. package/dist/types/excalidraw/actions/actionBoundText.d.ts +56 -214
  36. package/dist/types/excalidraw/actions/actionCanvas.d.ts +72 -12
  37. package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -2
  38. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -1
  39. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -564
  40. package/dist/types/excalidraw/actions/actionDeselect.d.ts +13 -1
  41. package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -1
  42. package/dist/types/excalidraw/actions/actionElementLock.d.ts +20 -2
  43. package/dist/types/excalidraw/actions/actionExport.d.ts +22 -4
  44. package/dist/types/excalidraw/actions/actionFrame.d.ts +71 -528
  45. package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -2
  46. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -1
  47. package/dist/types/excalidraw/actions/actionLink.d.ts +10 -1
  48. package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -1
  49. package/dist/types/excalidraw/actions/actionProperties.d.ts +20 -2
  50. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -1
  51. package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -1
  52. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +10 -1
  53. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -1
  54. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +10 -1
  55. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  56. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -1
  57. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -1
  58. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  59. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -1
  60. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -1
  61. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  62. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -1
  63. package/dist/types/excalidraw/actions/index.d.ts +3 -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 +4 -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.arrowText.d.ts +5 -39
  74. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  75. package/dist/types/excalidraw/components/App.d.ts +79 -264
  76. package/dist/types/excalidraw/components/App.duplicate.d.ts +52 -2
  77. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  78. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  79. package/dist/types/excalidraw/components/App.pan.d.ts +8 -0
  80. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  81. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  82. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  83. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  84. package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
  85. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  86. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  87. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  88. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  89. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  90. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  91. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  92. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  93. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  94. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  95. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  96. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  97. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  98. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  99. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  100. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  101. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  102. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  103. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  104. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  105. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  106. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  107. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  108. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  109. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  110. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  111. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  112. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  113. package/dist/types/excalidraw/data/blob.d.ts +24 -6
  114. package/dist/types/excalidraw/data/index.d.ts +3 -3
  115. package/dist/types/excalidraw/data/json.d.ts +12 -3
  116. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  117. package/dist/types/excalidraw/history.d.ts +10 -4
  118. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  119. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  120. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  121. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  122. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  123. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  124. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  125. package/dist/types/excalidraw/types.d.ts +83 -14
  126. package/dist/types/excalidraw/viewport.d.ts +23 -1
  127. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  128. package/dist/types/utils/src/index.d.ts +3 -1
  129. package/package.json +1 -1
  130. package/dist/types/utils/src/export.d.ts +0 -36
@@ -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,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 {};
@@ -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;
@@ -78,9 +78,11 @@ export declare const Preferences: {
78
78
  ToggleSnapMode: () => import("react/jsx-runtime").JSX.Element;
79
79
  ToggleArrowBinding: () => import("react/jsx-runtime").JSX.Element;
80
80
  ToggleMidpointSnapping: () => import("react/jsx-runtime").JSX.Element;
81
+ ToggleShowHints: () => import("react/jsx-runtime").JSX.Element;
81
82
  ToggleGridMode: () => import("react/jsx-runtime").JSX.Element;
82
83
  ToggleZenMode: () => import("react/jsx-runtime").JSX.Element;
83
84
  ToggleViewMode: () => import("react/jsx-runtime").JSX.Element | null;
85
+ ToggleMinimap: () => import("react/jsx-runtime").JSX.Element | null;
84
86
  ToggleElementProperties: () => import("react/jsx-runtime").JSX.Element;
85
87
  displayName: string;
86
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;
@@ -54,12 +56,20 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
54
56
  boxSelectionMode: import("../types").BoxSelectionMode;
55
57
  bindingPreference: "enabled" | "disabled";
56
58
  isMidpointSnappingEnabled: boolean;
59
+ showHints: boolean;
57
60
  inputDevice: import("../types").InputDevice;
58
61
  suggestedBinding: {
59
62
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
60
63
  midPoint?: import("@excalidraw/math").GlobalPoint;
61
64
  } | null;
62
- hoveredArrowTextAnchor: {
65
+ textToolHover: {
66
+ type: "text";
67
+ elementId: ExcalidrawElement["id"];
68
+ } | {
69
+ type: "container";
70
+ elementId: ExcalidrawElement["id"];
71
+ } | {
72
+ type: "arrow";
63
73
  elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
64
74
  anchor: "start" | "end" | "label";
65
75
  } | null;
@@ -101,8 +111,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
101
111
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
102
112
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
103
113
  viewBackgroundColor: string;
104
- scrollX: number;
105
- scrollY: number;
106
114
  scrollConstraints: import("../types").ScrollConstraints | null;
107
115
  cursorButton: "up" | "down";
108
116
  scrolledOutside: boolean;
@@ -149,6 +157,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
149
157
  closable?: boolean;
150
158
  duration?: number;
151
159
  } | null;
160
+ minimapEnabled: boolean;
152
161
  gridStep: number;
153
162
  selectedGroupIds: {
154
163
  [groupId: string]: boolean;
@@ -214,6 +223,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
214
223
  name: string | null;
215
224
  currentItemArrowType: "sharp" | "round" | "elbow";
216
225
  gridSize: number;
226
+ scrollX: number;
227
+ scrollY: number;
217
228
  contextMenu: {
218
229
  items: import("../components/ContextMenu").ContextMenuItems;
219
230
  top: number;
@@ -234,12 +245,20 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
234
245
  boxSelectionMode: import("../types").BoxSelectionMode;
235
246
  bindingPreference: "enabled" | "disabled";
236
247
  isMidpointSnappingEnabled: boolean;
248
+ showHints: boolean;
237
249
  inputDevice: import("../types").InputDevice;
238
250
  suggestedBinding: {
239
251
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
240
252
  midPoint?: import("@excalidraw/math").GlobalPoint;
241
253
  } | null;
242
- hoveredArrowTextAnchor: {
254
+ textToolHover: {
255
+ type: "text";
256
+ elementId: ExcalidrawElement["id"];
257
+ } | {
258
+ type: "container";
259
+ elementId: ExcalidrawElement["id"];
260
+ } | {
261
+ type: "arrow";
243
262
  elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
244
263
  anchor: "start" | "end" | "label";
245
264
  } | null;
@@ -281,8 +300,6 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
281
300
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
282
301
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
283
302
  viewBackgroundColor: string;
284
- scrollX: number;
285
- scrollY: number;
286
303
  scrollConstraints: import("../types").ScrollConstraints | null;
287
304
  cursorButton: "up" | "down";
288
305
  scrolledOutside: boolean;
@@ -329,6 +346,7 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
329
346
  closable?: boolean;
330
347
  duration?: number;
331
348
  } | null;
349
+ minimapEnabled: boolean;
332
350
  gridStep: number;
333
351
  selectedGroupIds: {
334
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;
@@ -52,12 +54,20 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
52
54
  boxSelectionMode: import("../types").BoxSelectionMode;
53
55
  bindingPreference: "enabled" | "disabled";
54
56
  isMidpointSnappingEnabled: boolean;
57
+ showHints: boolean;
55
58
  inputDevice: import("../types").InputDevice;
56
59
  suggestedBinding: {
57
60
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
58
61
  midPoint?: import("@excalidraw/math").GlobalPoint;
59
62
  } | null;
60
- hoveredArrowTextAnchor: {
63
+ textToolHover: {
64
+ type: "text";
65
+ elementId: ExcalidrawElement["id"];
66
+ } | {
67
+ type: "container";
68
+ elementId: ExcalidrawElement["id"];
69
+ } | {
70
+ type: "arrow";
61
71
  elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
62
72
  anchor: "start" | "end" | "label";
63
73
  } | null;
@@ -99,8 +109,6 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
99
109
  currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
100
110
  currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
101
111
  viewBackgroundColor: string;
102
- scrollX: number;
103
- scrollY: number;
104
112
  scrollConstraints: import("../types").ScrollConstraints | null;
105
113
  cursorButton: "up" | "down";
106
114
  scrolledOutside: boolean;
@@ -147,6 +155,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
147
155
  closable?: boolean;
148
156
  duration?: number;
149
157
  } | null;
158
+ minimapEnabled: boolean;
150
159
  gridStep: number;
151
160
  selectedGroupIds: {
152
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;
@@ -1,13 +1,15 @@
1
1
  import { Emitter } from "@excalidraw/common";
2
2
  import { StoreDelta } from "@excalidraw/element";
3
- import type { StoreSnapshot, Store } from "@excalidraw/element";
3
+ import type { RenderEnvironment, StoreSnapshot, Store } from "@excalidraw/element";
4
4
  import type { SceneElementsMap } from "@excalidraw/element/types";
5
5
  import type { AppState } from "./types";
6
6
  export declare class HistoryDelta extends StoreDelta {
7
7
  /**
8
8
  * Apply the delta to the passed elements and appState, does not modify the snapshot.
9
9
  */
10
- applyTo(elements: SceneElementsMap, appState: AppState, snapshot: StoreSnapshot): [SceneElementsMap, AppState, boolean];
10
+ applyTo(elements: SceneElementsMap, appState: AppState, snapshot: StoreSnapshot,
11
+ /** measures the labels re-laid out after applying */
12
+ renderEnvironment?: RenderEnvironment): [SceneElementsMap, AppState, boolean];
11
13
  /**
12
14
  * Overriding once to avoid type casting everywhere.
13
15
  */
@@ -40,8 +42,12 @@ export declare class History {
40
42
  * Do not re-record history entries, which were already pushed to undo / redo stack, as part of history action.
41
43
  */
42
44
  record(delta: StoreDelta): void;
43
- undo(elements: SceneElementsMap, appState: AppState): void | [SceneElementsMap, AppState];
44
- redo(elements: SceneElementsMap, appState: AppState): void | [SceneElementsMap, AppState];
45
+ undo(elements: SceneElementsMap, appState: AppState,
46
+ /** measures the labels re-laid out after undoing (the host's, in the editor) */
47
+ renderEnvironment?: RenderEnvironment): void | [SceneElementsMap, AppState];
48
+ redo(elements: SceneElementsMap, appState: AppState,
49
+ /** measures the labels re-laid out after redoing (the host's, in the editor) */
50
+ renderEnvironment?: RenderEnvironment): void | [SceneElementsMap, AppState];
45
51
  private perform;
46
52
  private static pop;
47
53
  private static push;
@@ -1,2 +1,9 @@
1
+ import type { MermaidConfig } from "@excalidraw/mermaid-to-excalidraw";
2
+ /**
3
+ * How Mermaid diagrams are converted: flowchart edges as elbow arrows, which
4
+ * are easier to edit (unless the definition sets its own curve in its front
5
+ * matter or `%%{init}%%`).
6
+ */
7
+ export declare const MERMAID_TO_EXCALIDRAW_CONFIG: MermaidConfig;
1
8
  /** heuristically checks whether the text may be a mermaid diagram definition */
2
9
  export declare const isMaybeMermaidDefinition: (text: string) => boolean;
@@ -6,7 +6,7 @@ export declare const withBatchedUpdates: <TFunction extends ((event: any) => voi
6
6
  * barches React state updates and throttles the calls to a single call per
7
7
  * animation frame
8
8
  */
9
- export declare const withBatchedUpdatesThrottled: <TFunction extends ((event: any) => void) | (() => void)>(func: Parameters<TFunction>["length"] extends 0 | 1 ? TFunction : never) => {
9
+ export declare const withBatchedUpdatesThrottled: <TFunction extends ((event: any) => void) | (() => void)>(func: Parameters<TFunction>["length"] extends 0 | 1 ? TFunction : never, ownerWindow?: Window) => {
10
10
  (...args: Parameters<TFunction>): void;
11
11
  flush(): void;
12
12
  cancel(): void;
@@ -1,16 +1,23 @@
1
+ /** String keys are shared process-wide; symbols are created per owning
2
+ * instance, which lets concurrent instances run the same named animation
3
+ * independently. */
4
+ export type AnimationKey = string | symbol;
1
5
  export type Animation<R extends object> = (params: {
2
6
  deltaTime: number;
3
7
  state?: R;
4
8
  }) => R | null | undefined;
9
+ export type AnimationScheduler = Pick<Window, "requestAnimationFrame" | "cancelAnimationFrame" | "setTimeout" | "clearTimeout">;
5
10
  export declare class AnimationController {
6
- private static scheduledFrame;
11
+ private static scheduledFrames;
7
12
  private static animations;
8
- static start<R extends object>(key: string, animation: Animation<R>): void;
13
+ private static readonly schedulerCleanups;
14
+ static start<R extends object>(key: AnimationKey, animation: Animation<R>, scheduler?: AnimationScheduler): void;
9
15
  private static scheduleNextFrame;
10
16
  private static cancelScheduledFrame;
11
17
  private static cancelScheduledFrameIfIdle;
18
+ private static registerSchedulerCleanup;
12
19
  private static tick;
13
- static running(key: string): boolean;
14
- static cancel(key: string): void;
20
+ static running(key: AnimationKey): boolean;
21
+ static cancel(key: AnimationKey): void;
15
22
  static reset(): void;
16
23
  }
@@ -2,12 +2,17 @@ import type { ExcalidrawFrameLikeElement } from "@excalidraw/element/types";
2
2
  import type { StaticCanvasRenderConfig, StaticSceneRenderConfig } from "../scene/types";
3
3
  import type { StaticCanvasAppState } from "../types";
4
4
  export declare const frameClip: (frame: ExcalidrawFrameLikeElement, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
5
- /** throttled to animation framerate */
6
- export declare const renderStaticSceneThrottled: {
7
- (config: StaticSceneRenderConfig): void;
8
- flush(): void;
9
- cancel(): void;
10
- };
5
+ /**
6
+ * Throttled to animation framerate, one throttle per canvas. A shared
7
+ * throttle drops all but the last caller's pending frame when multiple
8
+ * editors render in the same frame, and a module-realm scheduler would run
9
+ * popout renders on the main window's rAF, which freezes while that window
10
+ * is hidden.
11
+ */
12
+ export declare const renderStaticSceneThrottled: (config: StaticSceneRenderConfig) => void;
13
+ /** Drops the canvas' pending frame; the throttle itself is dropped with the
14
+ * canvas. */
15
+ export declare const cancelStaticSceneThrottle: (canvas: HTMLCanvasElement) => void;
11
16
  /**
12
17
  * Static scene is the non-ui canvas where we render elements.
13
18
  */
@@ -494,6 +494,6 @@ export declare class Renderer {
494
494
  }) | null;
495
495
  canvasNonce: string;
496
496
  };
497
- destroy(): void;
497
+ destroy(staticCanvas: HTMLCanvasElement): void;
498
498
  }
499
499
  export {};