@excalidraw/math 0.18.0-7ea3229 → 0.18.0-816c81c

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 (87) hide show
  1. package/dist/types/common/src/appEventBus.d.ts +27 -0
  2. package/dist/types/common/src/colors.d.ts +1 -1
  3. package/dist/types/common/src/index.d.ts +2 -0
  4. package/dist/types/common/src/utils.d.ts +1 -3
  5. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  6. package/dist/types/element/src/Scene.d.ts +2 -0
  7. package/dist/types/element/src/arrowheads.d.ts +3 -0
  8. package/dist/types/element/src/binding.d.ts +3 -4
  9. package/dist/types/element/src/bounds.d.ts +1 -1
  10. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  11. package/dist/types/element/src/index.d.ts +1 -0
  12. package/dist/types/element/src/linearElementEditor.d.ts +3 -0
  13. package/dist/types/element/src/mutateElement.d.ts +2 -0
  14. package/dist/types/element/src/types.d.ts +5 -2
  15. package/dist/types/element/src/utils.d.ts +1 -1
  16. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +23 -29
  17. package/dist/types/excalidraw/actions/actionBoundText.d.ts +16 -20
  18. package/dist/types/excalidraw/actions/actionCanvas.d.ts +97 -121
  19. package/dist/types/excalidraw/actions/actionClipboard.d.ts +16 -20
  20. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +8 -10
  21. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +24 -30
  22. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -10
  23. package/dist/types/excalidraw/actions/actionElementLock.d.ts +16 -20
  24. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +8 -10
  25. package/dist/types/excalidraw/actions/actionExport.d.ts +60 -344
  26. package/dist/types/excalidraw/actions/actionFrame.d.ts +32 -40
  27. package/dist/types/excalidraw/actions/actionGroup.d.ts +16 -20
  28. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -10
  29. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -10
  30. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -10
  31. package/dist/types/excalidraw/actions/actionProperties.d.ts +16 -20
  32. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +8 -10
  33. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -9
  34. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
  35. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -10
  36. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
  37. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -10
  38. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -10
  39. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +8 -10
  40. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -10
  41. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -10
  42. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  43. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  44. package/dist/types/excalidraw/appState.d.ts +4 -2
  45. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  46. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  47. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  48. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  49. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  50. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  51. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  52. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  53. package/dist/types/excalidraw/clipboard.d.ts +2 -5
  54. package/dist/types/excalidraw/components/App.d.ts +33 -11
  55. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  56. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  57. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  58. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  59. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  60. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  61. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  62. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  63. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  64. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  65. package/dist/types/excalidraw/components/icons.d.ts +17 -8
  66. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  67. package/dist/types/excalidraw/data/blob.d.ts +25 -30
  68. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  69. package/dist/types/excalidraw/data/index.d.ts +2 -3
  70. package/dist/types/excalidraw/data/json.d.ts +28 -22
  71. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  72. package/dist/types/excalidraw/types.d.ts +84 -13
  73. package/package.json +2 -2
  74. package/dist/types/excalidraw/charts.d.ts +0 -27
  75. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  76. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  77. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  78. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  79. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  80. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  81. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  82. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  83. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  84. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  85. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  86. package/dist/types/excalidraw/index.d.ts +0 -47
  87. package/dist/types/excalidraw/polyfill.d.ts +0 -2
@@ -14,7 +14,7 @@ export type ActionResult = {
14
14
  type ActionFn<TData = any> = (elements: readonly OrderedExcalidrawElement[], appState: Readonly<AppState>, formData: TData | undefined, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
15
15
  export type UpdaterFn = (res: ActionResult) => void;
16
16
  export type ActionFilterFn = (action: Action) => void;
17
- export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "objectsSnapMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeArrowType" | "changeArrowProperties" | "changeOpacity" | "changeFontSize" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "setFrameAsActiveTool" | "setEmbeddableAsActiveTool" | "createContainerFromText" | "wrapTextInContainer" | "commandPalette" | "autoResize" | "elementStats" | "searchMenu" | "copyElementLink" | "linkToElement" | "cropEditor" | "wrapSelectionInFrame" | "toggleLassoTool" | "toggleShapeSwitch" | "togglePolygon";
17
+ export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "objectsSnapMode" | "arrowBinding" | "midpointSnapping" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeArrowType" | "changeArrowProperties" | "changeOpacity" | "changeFontSize" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "toggleEraserTool" | "toggleHandTool" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "setFrameAsActiveTool" | "setEmbeddableAsActiveTool" | "createContainerFromText" | "wrapTextInContainer" | "commandPalette" | "autoResize" | "elementStats" | "searchMenu" | "copyElementLink" | "linkToElement" | "cropEditor" | "wrapSelectionInFrame" | "toggleLassoTool" | "toggleShapeSwitch" | "togglePolygon";
18
18
  export type PanelComponentProps = {
19
19
  elements: readonly ExcalidrawElement[];
20
20
  appState: AppState;
@@ -22,12 +22,16 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
22
22
  [groupId: string]: boolean;
23
23
  } | undefined;
24
24
  selectedLinearElement?: import("@excalidraw/element").LinearElementEditor | null | undefined;
25
+ isBindingEnabled?: boolean | undefined;
26
+ isMidpointSnappingEnabled?: boolean | undefined;
25
27
  zenModeEnabled?: boolean | undefined;
26
28
  shouldCacheIgnoreZoom?: boolean | undefined;
27
29
  exportScale?: number | undefined;
30
+ currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
28
31
  bindMode?: import("@excalidraw/element/types").BindMode | undefined;
29
32
  gridSize?: number | undefined;
30
33
  showWelcomeScreen?: boolean | undefined;
34
+ bindingPreference?: "enabled" | "disabled" | undefined;
31
35
  preferredSelectionTool?: {
32
36
  type: "selection" | "lasso";
33
37
  initialized: boolean;
@@ -50,7 +54,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
50
54
  currentItemStartArrowhead?: import("@excalidraw/element/types").Arrowhead | null | undefined;
51
55
  currentItemEndArrowhead?: import("@excalidraw/element/types").Arrowhead | null | undefined;
52
56
  currentItemRoundness?: import("@excalidraw/element/types").StrokeRoundness | undefined;
53
- currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
54
57
  cursorButton?: "up" | "down" | undefined;
55
58
  scrolledOutside?: boolean | undefined;
56
59
  openMenu?: "canvas" | null | undefined;
@@ -69,7 +72,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
69
72
  open: boolean;
70
73
  panels: number;
71
74
  } | undefined;
72
- currentChartType?: import("@excalidraw/element/types").ChartType | undefined;
73
75
  objectsSnapModeEnabled?: boolean | undefined;
74
76
  lockedMultiSelections?: {
75
77
  [groupId: string]: true;
@@ -0,0 +1,2 @@
1
+ import type { ChartElements, Spreadsheet } from "./charts.types";
2
+ export declare const renderBarChart: (spreadsheet: Spreadsheet, x: number, y: number, colorSeed?: number) => ChartElements;
@@ -0,0 +1,48 @@
1
+ import type { Radians } from "@excalidraw/math";
2
+ export declare const CARTESIAN_BASE_SLOT_WIDTH = 44;
3
+ export declare const CARTESIAN_BAR_SLOT_EXTRA_PER_SERIES = 22;
4
+ export declare const CARTESIAN_BAR_SLOT_EXTRA_MAX = 66;
5
+ export declare const CARTESIAN_LINE_SLOT_WIDTH = 48;
6
+ export declare const CARTESIAN_GAP = 14;
7
+ export declare const CARTESIAN_BAR_HEIGHT = 304;
8
+ export declare const CARTESIAN_LINE_HEIGHT = 320;
9
+ export declare const CARTESIAN_LABEL_ROTATION: Radians;
10
+ export declare const CARTESIAN_LABEL_MIN_WIDTH = 28;
11
+ export declare const CARTESIAN_LABEL_SLOT_PADDING = 4;
12
+ export declare const CARTESIAN_LABEL_AXIS_CLEARANCE = 2;
13
+ export declare const CARTESIAN_LABEL_MAX_WIDTH_BUFFER = 10;
14
+ export declare const CARTESIAN_LABEL_ROTATED_WIDTH_BUFFER = 10;
15
+ export declare const CARTESIAN_LABEL_OVERFLOW_PREFERENCE_BUFFER = 8;
16
+ export declare const BAR_GAP = 12;
17
+ export declare const BAR_HEIGHT = 256;
18
+ export declare const GRID_OPACITY = 10;
19
+ export declare const RADAR_GRID_LEVELS = 4;
20
+ export declare const RADAR_LABEL_OFFSET: number;
21
+ export declare const RADAR_PADDING: number;
22
+ export declare const RADAR_SINGLE_SERIES_LOG_SCALE_THRESHOLD = 100;
23
+ export declare const RADAR_AXIS_LABEL_MAX_WIDTH = 140;
24
+ export declare const RADAR_AXIS_LABEL_ALIGNMENT_THRESHOLD = 0.35;
25
+ export declare const RADAR_AXIS_LABEL_CLEARANCE: number;
26
+ export declare const RADAR_LEGEND_SWATCH_SIZE = 20;
27
+ export declare const RADAR_LEGEND_ITEM_GAP: number;
28
+ export declare const RADAR_LEGEND_TEXT_GAP = 12;
29
+ export declare const commonProps: {
30
+ readonly fillStyle: "hachure";
31
+ readonly fontFamily: number;
32
+ readonly fontSize: 20;
33
+ readonly opacity: 100;
34
+ readonly roughness: 1;
35
+ readonly strokeColor: "#1e1e1e";
36
+ readonly roundness: null;
37
+ readonly strokeStyle: "solid";
38
+ readonly strokeWidth: 1;
39
+ readonly verticalAlign: string;
40
+ readonly locked: false;
41
+ };
42
+ export type CartesianChartType = "bar" | "line";
43
+ export type CartesianChartLayout = {
44
+ slotWidth: number;
45
+ gap: number;
46
+ chartHeight: number;
47
+ xLabelMaxWidth: number;
48
+ };
@@ -0,0 +1,32 @@
1
+ import { getFontString } from "@excalidraw/common";
2
+ import type { ChartType } from "@excalidraw/element/types";
3
+ import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
4
+ import { type CartesianChartLayout, type CartesianChartType } from "./charts.constants";
5
+ import type { ChartElements, Spreadsheet, SpreadsheetSeries } from "./charts.types";
6
+ export declare const isSpreadsheetValidForChartType: (spreadsheet: Spreadsheet | null, chartType: ChartType) => boolean;
7
+ export declare const getCartesianChartLayout: (chartType: CartesianChartType, seriesCount: number) => CartesianChartLayout;
8
+ export declare const getChartDimensions: (spreadsheet: Spreadsheet, layout: CartesianChartLayout) => {
9
+ chartWidth: number;
10
+ chartHeight: number;
11
+ };
12
+ export declare const getRadarDimensions: () => {
13
+ chartWidth: number;
14
+ chartHeight: number;
15
+ };
16
+ export declare const getSeriesColors: (seriesCount: number, colorOffset: number) => readonly string[];
17
+ export declare const getColorOffset: (colorSeed?: number) => number;
18
+ export declare const getBackgroundColor: (colorOffset: number) => "#fff5f5" | "#ffc9c9" | "#ff8787" | "#fa5252" | "#e03131" | "#fff0f6" | "#fcc2d7" | "#f783ac" | "#e64980" | "#c2255c" | "#f8f0fc" | "#eebefa" | "#da77f2" | "#be4bdb" | "#9c36b5" | "#f3f0ff" | "#d0bfff" | "#9775fa" | "#7950f2" | "#6741d9" | "#e7f5ff" | "#a5d8ff" | "#4dabf7" | "#228be6" | "#1971c2" | "#e3fafc" | "#99e9f2" | "#3bc9db" | "#15aabf" | "#0c8599" | "#e6fcf5" | "#96f2d7" | "#38d9a9" | "#12b886" | "#099268" | "#ebfbee" | "#b2f2bb" | "#69db7c" | "#40c057" | "#2f9e44" | "#fff9db" | "#ffec99" | "#ffd43b" | "#fab005" | "#f08c00" | "#fff4e6" | "#ffd8a8" | "#ffa94d" | "#fd7e14" | "#e8590c";
19
+ export declare const getRadarValueScale: (series: SpreadsheetSeries[], _labelsLength: number) => {
20
+ renderSteps: boolean;
21
+ normalize: (value: number, _axisIndex: number) => number;
22
+ };
23
+ export declare const getRadarDisplayText: (text: string, fontString: ReturnType<typeof getFontString>, maxWidth: number) => string;
24
+ export declare const createRadarAxisLabels: (labels: readonly string[], angles: readonly number[], centerX: number, centerY: number, radius: number, backgroundColor: string) => {
25
+ axisLabels: ChartElements;
26
+ axisLabelTopY: number;
27
+ axisLabelBottomY: number;
28
+ };
29
+ export declare const createSeriesLegend: (series: SpreadsheetSeries[], seriesColors: readonly string[], centerX: number, minLegendTopY: number, fallbackLegendY: number, backgroundColor: string) => ChartElements;
30
+ export declare const getRotatedTextElementBottom: (element: NonDeletedExcalidrawElement) => number;
31
+ export declare const chartXLabels: (spreadsheet: Spreadsheet, x: number, y: number, backgroundColor: string, layout: CartesianChartLayout) => ChartElements;
32
+ export declare const chartBaseElements: (spreadsheet: Spreadsheet, x: number, y: number, backgroundColor: string, layout: CartesianChartLayout, maxValue?: number, debug?: boolean) => ChartElements;
@@ -0,0 +1,2 @@
1
+ import type { ChartElements, Spreadsheet } from "./charts.types";
2
+ export declare const renderLineChart: (spreadsheet: Spreadsheet, x: number, y: number, colorSeed?: number) => ChartElements;
@@ -0,0 +1,10 @@
1
+ import { type ParseSpreadsheetResult } from "./charts.types";
2
+ /**
3
+ * @private exported for testing
4
+ */
5
+ export declare const tryParseNumber: (s: string) => number | null;
6
+ /**
7
+ * @private exported for testing
8
+ */
9
+ export declare const tryParseCells: (cells: string[][]) => ParseSpreadsheetResult;
10
+ export declare const tryParseSpreadsheet: (text: string) => ParseSpreadsheetResult;
@@ -0,0 +1,2 @@
1
+ import type { ChartElements, Spreadsheet } from "./charts.types";
2
+ export declare const renderRadarChart: (spreadsheet: Spreadsheet, x: number, y: number, colorSeed?: number) => ChartElements | null;
@@ -0,0 +1,18 @@
1
+ import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
+ export type ChartElements = readonly NonDeletedExcalidrawElement[];
3
+ export interface Spreadsheet {
4
+ title: string | null;
5
+ labels: string[] | null;
6
+ series: SpreadsheetSeries[];
7
+ }
8
+ export interface SpreadsheetSeries {
9
+ title: string | null;
10
+ values: number[];
11
+ }
12
+ export type ParseSpreadsheetResult = {
13
+ ok: false;
14
+ reason: string;
15
+ } | {
16
+ ok: true;
17
+ data: Spreadsheet;
18
+ };
@@ -0,0 +1,7 @@
1
+ import type { ChartType } from "@excalidraw/element/types";
2
+ import { tryParseCells, tryParseNumber, tryParseSpreadsheet } from "./charts.parse";
3
+ import type { ChartElements, Spreadsheet } from "./charts.types";
4
+ export { type ParseSpreadsheetResult, type Spreadsheet, type SpreadsheetSeries, type ChartElements, } from "./charts.types";
5
+ export { isSpreadsheetValidForChartType } from "./charts.helpers";
6
+ export { tryParseCells, tryParseNumber, tryParseSpreadsheet };
7
+ export declare const renderSpreadsheet: (chartType: ChartType, spreadsheet: Spreadsheet, x: number, y: number, colorSeed?: number) => ChartElements | null;
@@ -2,15 +2,12 @@ import { ALLOWED_PASTE_MIME_TYPES } from "@excalidraw/common";
2
2
  import type { ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { IMAGE_MIME_TYPES, STRING_MIME_TYPES } from "@excalidraw/common";
4
4
  import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
5
- import type { FileSystemHandle } from "./data/filesystem";
6
- import type { Spreadsheet } from "./charts";
7
5
  import type { BinaryFiles } from "./types";
8
6
  export type PastedMixedContent = {
9
7
  type: "text" | "imageUrl";
10
8
  value: string;
11
9
  }[];
12
10
  export interface ClipboardData {
13
- spreadsheet?: Spreadsheet;
14
11
  elements?: readonly ExcalidrawElement[];
15
12
  files?: BinaryFiles;
16
13
  text?: string;
@@ -54,7 +51,7 @@ type AllowedParsedDataTransferItem = {
54
51
  type: ValueOf<typeof IMAGE_MIME_TYPES>;
55
52
  kind: "file";
56
53
  file: File;
57
- fileHandle: FileSystemHandle | null;
54
+ fileHandle: FileSystemFileHandle | null;
58
55
  } | {
59
56
  type: ValueOf<typeof STRING_MIME_TYPES>;
60
57
  kind: "string";
@@ -64,7 +61,7 @@ type ParsedDataTransferItem = {
64
61
  type: string;
65
62
  kind: "file";
66
63
  file: File;
67
- fileHandle: FileSystemHandle | null;
64
+ fileHandle: FileSystemFileHandle | null;
68
65
  } | {
69
66
  type: string;
70
67
  kind: "string";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
2
+ import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
3
3
  import { LinearElementEditor, FlowChartCreator, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
4
  import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
5
  import type { Mutable } from "@excalidraw/common/utility-types";
@@ -13,15 +13,31 @@ import { LaserTrails } from "../laser-trails";
13
13
  import { isOverScrollBars } from "../scene/scrollbars";
14
14
  import { LassoTrail } from "../lasso";
15
15
  import { EraserTrail } from "../eraser";
16
+ import { type OnStateChange } from "./AppStateObserver";
16
17
  import type { ExportedElements } from "../data";
17
- import type { FileSystemHandle } from "../data/filesystem";
18
- import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
18
+ import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
19
19
  import type { RoughCanvas } from "roughjs/bin/canvas";
20
20
  import type { ActionResult } from "../actions/types";
21
+ declare const editorLifecycleEventBehavior: {
22
+ readonly "editor:mount": {
23
+ readonly cardinality: "once";
24
+ readonly replay: "last";
25
+ };
26
+ readonly "editor:initialize": {
27
+ readonly cardinality: "once";
28
+ readonly replay: "last";
29
+ };
30
+ readonly "editor:unmount": {
31
+ readonly cardinality: "once";
32
+ readonly replay: "last";
33
+ };
34
+ };
21
35
  export declare const ExcalidrawContainerContext: React.Context<{
22
36
  container: HTMLDivElement | null;
23
37
  id: string | null;
24
38
  }>;
39
+ export declare const ExcalidrawAPIContext: React.Context<ExcalidrawImperativeAPI | null>;
40
+ export declare const ExcalidrawAPISetContext: React.Context<((api: ExcalidrawImperativeAPI | null) => void) | null>;
25
41
  export declare const useApp: () => AppClassProperties;
26
42
  export declare const useAppProps: () => AppProps;
27
43
  export declare const useEditorInterface: () => Readonly<{
@@ -44,9 +60,14 @@ export declare const useExcalidrawElements: () => readonly NonDeletedExcalidrawE
44
60
  export declare const useExcalidrawAppState: () => AppState;
45
61
  export declare const useExcalidrawSetAppState: () => <K extends keyof AppState>(state: AppState | ((prevState: Readonly<AppState>, props: Readonly<any>) => AppState | Pick<AppState, K> | null) | Pick<AppState, K> | null, callback?: (() => void) | undefined) => void;
46
62
  export declare const useExcalidrawActionManager: () => ActionManager;
63
+ /**
64
+ * Requires wrapping your component in <ExcalidrawAPIContext.Provider>
65
+ */
66
+ export declare const useExcalidrawAPI: () => ExcalidrawImperativeAPI | null;
47
67
  declare class App extends React.Component<AppProps, AppState> {
48
68
  canvas: AppClassProperties["canvas"];
49
69
  interactiveCanvas: AppClassProperties["interactiveCanvas"];
70
+ sessionExportThemeOverride: AppState["theme"] | undefined;
50
71
  rc: RoughCanvas;
51
72
  unmounted: boolean;
52
73
  actionManager: ActionManager;
@@ -80,8 +101,12 @@ declare class App extends React.Component<AppProps, AppState> {
80
101
  /** embeds that have been inserted to DOM (as a perf optim, we don't want to
81
102
  * insert to DOM before user initially scrolls to them) */
82
103
  private initializedEmbeds;
83
- private handleToastClose;
84
104
  private elementsPendingErasure;
105
+ private _initialized;
106
+ private readonly editorLifecycleEvents;
107
+ onEvent: AppEventBus<ExcalidrawImperativeAPIEventMap, typeof editorLifecycleEventBehavior>["on"];
108
+ private appStateObserver;
109
+ onStateChange: OnStateChange;
85
110
  flowChartCreator: FlowChartCreator;
86
111
  private flowChartNavigator;
87
112
  bindModeHandler: ReturnType<typeof setTimeout> | null;
@@ -238,6 +263,8 @@ declare class App extends React.Component<AppProps, AppState> {
238
263
  }>]>;
239
264
  missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
240
265
  onRemoveEventListenersEmitter: Emitter<[]>;
266
+ api: ExcalidrawImperativeAPI;
267
+ private createExcalidrawAPI;
241
268
  constructor(props: AppProps);
242
269
  updateEditorAtom: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
243
270
  private onWindowMessage;
@@ -379,11 +406,7 @@ declare class App extends React.Component<AppProps, AppState> {
379
406
  private maybeUnfollowRemoteUser;
380
407
  /** use when changing scrollX/scrollY/zoom based on user interaction */
381
408
  private translateCanvas;
382
- setToast: (toast: {
383
- message: string;
384
- closable?: boolean;
385
- duration?: number;
386
- } | null) => void;
409
+ setToast: (toast: AppState["toast"]) => void;
387
410
  restoreFileFromShare: () => Promise<void>;
388
411
  /**
389
412
  * adds supplied files to existing files in the appState.
@@ -531,12 +554,11 @@ declare class App extends React.Component<AppProps, AppState> {
531
554
  /** generally you should use `addNewImagesToImageCache()` directly if you need
532
555
  * to render new images. This is just a failsafe */
533
556
  private scheduleImageRefresh;
534
- private updateBindingEnabledOnPointerMove;
535
557
  private clearSelection;
536
558
  private handleInteractiveCanvasRef;
537
559
  private insertImages;
538
560
  private handleAppOnDrop;
539
- loadFileToCanvas: (file: File, fileHandle: FileSystemHandle | null) => Promise<void>;
561
+ loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null) => Promise<void>;
540
562
  private handleCanvasContextMenu;
541
563
  private maybeDragNewGenericElement;
542
564
  private maybeHandleCrop;
@@ -0,0 +1,37 @@
1
+ import type { AppState, UnsubscribeCallback } from "../types";
2
+ type StateChangeSelector = keyof AppState | (keyof AppState)[] | ((appState: AppState) => unknown);
3
+ export type OnStateChange = {
4
+ <K extends keyof AppState>(prop: K, callback: (value: AppState[K], appState: AppState) => void, opts?: {
5
+ once: boolean;
6
+ }): UnsubscribeCallback;
7
+ <K extends keyof AppState>(prop: K): Promise<AppState[K]>;
8
+ (prop: (keyof AppState)[], callback: (appState: AppState, appState2: AppState) => void, opts?: {
9
+ once: boolean;
10
+ }): UnsubscribeCallback;
11
+ (prop: (keyof AppState)[]): Promise<AppState>;
12
+ <T>(prop: (appState: AppState) => T, callback: (value: T, appState: AppState) => void, opts?: {
13
+ once: boolean;
14
+ }): UnsubscribeCallback;
15
+ <T>(prop: (appState: AppState) => T): Promise<T>;
16
+ (opts: {
17
+ predicate: (appState: AppState) => boolean;
18
+ callback: (appState: AppState) => void;
19
+ once?: boolean;
20
+ }): UnsubscribeCallback;
21
+ (opts: {
22
+ predicate: (appState: AppState) => boolean;
23
+ }): Promise<AppState>;
24
+ (selector: StateChangeSelector, callback: (value: any, appState: AppState) => void): any;
25
+ };
26
+ export declare class AppStateObserver {
27
+ private readonly getState;
28
+ private listeners;
29
+ constructor(getState: () => AppState);
30
+ private isStateChangePredicateOptions;
31
+ private subscribe;
32
+ private normalize;
33
+ onStateChange: OnStateChange;
34
+ flush(prevState: AppState): void;
35
+ clear(): void;
36
+ }
37
+ export {};
@@ -1,15 +1,20 @@
1
1
  import "./IconPicker.scss";
2
2
  import type { JSX } from "react";
3
- export declare function IconPicker<T>({ value, label, options, onChange, group, numberOfOptionsToAlwaysShow, }: {
3
+ type Option<T> = {
4
+ value: T;
5
+ text: string;
6
+ icon: JSX.Element;
7
+ keyBinding: string | null;
8
+ };
9
+ type PickerSection<T> = {
10
+ name: string;
11
+ options: readonly Option<T>[];
12
+ };
13
+ export declare function IconPicker<T>({ value, label, visibleSections, hiddenSections, onChange, }: {
4
14
  label: string;
5
15
  value: T;
6
- options: readonly {
7
- value: T;
8
- text: string;
9
- icon: JSX.Element;
10
- keyBinding: string | null;
11
- }[];
16
+ visibleSections: readonly PickerSection<T>[];
17
+ hiddenSections?: readonly PickerSection<T>[];
12
18
  onChange: (value: T) => void;
13
- numberOfOptionsToAlwaysShow?: number;
14
- group?: string;
15
19
  }): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -1,8 +1,7 @@
1
- import React from "react";
2
1
  import "./PasteChartDialog.scss";
3
- import type { UIAppState } from "../types";
4
- export declare const PasteChartDialog: ({ setAppState, appState, onClose, }: {
5
- appState: UIAppState;
2
+ import type { Spreadsheet } from "../charts";
3
+ export declare const PasteChartDialog: ({ data, rawText, onClose, }: {
4
+ data: Spreadsheet;
5
+ rawText: string;
6
6
  onClose: () => void;
7
- setAppState: React.Component<any, UIAppState>["setState"];
8
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { Theme } from "@excalidraw/element/types";
2
+ export interface CodeMirrorEditorProps {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ onKeyboardSubmit?: () => void;
6
+ placeholder?: string;
7
+ theme: Theme;
8
+ errorLine?: number | null;
9
+ }
10
+ declare const CodeMirrorEditor: ({ value, onChange, onKeyboardSubmit, placeholder, theme, errorLine, }: CodeMirrorEditorProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default CodeMirrorEditor;
@@ -1,9 +1,9 @@
1
- import type { ChangeEventHandler } from "react";
2
1
  interface TTDDialogInputProps {
3
2
  input: string;
4
3
  placeholder: string;
5
- onChange: ChangeEventHandler<HTMLTextAreaElement>;
4
+ onChange: (value: string) => void;
6
5
  onKeyboardSubmit?: () => void;
6
+ errorLine?: number | null;
7
7
  }
8
- export declare const TTDDialogInput: ({ input, placeholder, onChange, onKeyboardSubmit, }: TTDDialogInputProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const TTDDialogInput: ({ input, placeholder, onChange, onKeyboardSubmit, errorLine, }: TTDDialogInputProps) => import("react/jsx-runtime").JSX.Element | null;
9
9
  export {};
@@ -3,6 +3,9 @@ interface TTDDialogOutputProps {
3
3
  canvasRef: React.RefObject<HTMLDivElement | null>;
4
4
  loaded: boolean;
5
5
  hideErrorDetails?: boolean;
6
+ sourceText?: string;
7
+ autoFixAvailable?: boolean;
8
+ onApplyAutoFix?: () => void;
6
9
  }
7
- export declare const TTDDialogOutput: ({ error, canvasRef, loaded, hideErrorDetails, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const TTDDialogOutput: ({ error, canvasRef, loaded, hideErrorDetails, sourceText, autoFixAvailable, onApplyAutoFix, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
8
11
  export {};
@@ -0,0 +1,2 @@
1
+ import { StreamLanguage } from "@codemirror/language";
2
+ export declare function mermaidLite(): StreamLanguage<unknown>;
@@ -0,0 +1 @@
1
+ export declare const getMermaidAutoFixCandidates: (sourceText: string, errorMessage: string) => string[];
@@ -0,0 +1,10 @@
1
+ export declare const isMermaidParseSyntaxError: (message: string) => boolean;
2
+ export declare const isMermaidAutoFixableError: (message: string) => boolean;
3
+ export declare const isMermaidCaretLine: (line: string) => boolean;
4
+ export declare const getMermaidInactiveParticipant: (message: string) => string | null;
5
+ export declare const getMermaidErrorLineNumber: (message: string, sourceText?: string) => number | null;
6
+ export declare const getMermaidSyntaxErrorGuidance: (message: string, sourceText?: string) => {
7
+ summary: string;
8
+ likelyCauses: string[];
9
+ } | null;
10
+ export declare const formatMermaidParseErrorMessage: (message: string) => string;
@@ -1,9 +1,13 @@
1
1
  import "./Toast.scss";
2
- import type { CSSProperties } from "react";
3
- export declare const Toast: ({ message, onClose, closable, duration, style, }: {
4
- message: string;
2
+ import type { CSSProperties, ReactNode } from "react";
3
+ export declare const Toast: (({ message, onClose, closable, duration, style, }: {
4
+ message: ReactNode;
5
5
  onClose: () => void;
6
6
  closable?: boolean;
7
7
  duration?: number;
8
8
  style?: CSSProperties;
9
- }) => import("react/jsx-runtime").JSX.Element;
9
+ }) => import("react/jsx-runtime").JSX.Element) & {
10
+ ProgressBar: ({ progress }: {
11
+ progress: number;
12
+ }) => import("react/jsx-runtime").JSX.Element;
13
+ };
@@ -122,34 +122,43 @@ export declare const ArrowheadNoneIcon: React.MemoExoticComponent<({ flip }: {
122
122
  export declare const ArrowheadArrowIcon: React.MemoExoticComponent<({ flip }: {
123
123
  flip?: boolean;
124
124
  }) => import("react/jsx-runtime").JSX.Element>;
125
+ export declare const ArrowheadTriangleIcon: React.MemoExoticComponent<({ flip }: {
126
+ flip?: boolean;
127
+ }) => import("react/jsx-runtime").JSX.Element>;
128
+ export declare const ArrowheadTriangleOutlineIcon: React.MemoExoticComponent<({ flip }: {
129
+ flip?: boolean;
130
+ }) => import("react/jsx-runtime").JSX.Element>;
125
131
  export declare const ArrowheadCircleIcon: React.MemoExoticComponent<({ flip }: {
126
132
  flip?: boolean;
127
133
  }) => import("react/jsx-runtime").JSX.Element>;
128
134
  export declare const ArrowheadCircleOutlineIcon: React.MemoExoticComponent<({ flip }: {
129
135
  flip?: boolean;
130
136
  }) => import("react/jsx-runtime").JSX.Element>;
131
- export declare const ArrowheadBarIcon: React.MemoExoticComponent<({ flip }: {
137
+ export declare const ArrowheadDiamondIcon: React.MemoExoticComponent<({ flip }: {
132
138
  flip?: boolean;
133
139
  }) => import("react/jsx-runtime").JSX.Element>;
134
- export declare const ArrowheadTriangleIcon: React.MemoExoticComponent<({ flip }: {
140
+ export declare const ArrowheadDiamondOutlineIcon: React.MemoExoticComponent<({ flip }: {
135
141
  flip?: boolean;
136
142
  }) => import("react/jsx-runtime").JSX.Element>;
137
- export declare const ArrowheadTriangleOutlineIcon: React.MemoExoticComponent<({ flip }: {
143
+ export declare const ArrowheadBarIcon: React.MemoExoticComponent<({ flip }: {
138
144
  flip?: boolean;
139
145
  }) => import("react/jsx-runtime").JSX.Element>;
140
- export declare const ArrowheadDiamondIcon: React.MemoExoticComponent<({ flip }: {
146
+ export declare const ArrowheadCardinalityOneIcon: React.MemoExoticComponent<({ flip }: {
141
147
  flip?: boolean;
142
148
  }) => import("react/jsx-runtime").JSX.Element>;
143
- export declare const ArrowheadDiamondOutlineIcon: React.MemoExoticComponent<({ flip }: {
149
+ export declare const ArrowheadCardinalityManyIcon: React.MemoExoticComponent<({ flip }: {
150
+ flip?: boolean;
151
+ }) => import("react/jsx-runtime").JSX.Element>;
152
+ export declare const ArrowheadCardinalityOneOrManyIcon: React.MemoExoticComponent<({ flip }: {
144
153
  flip?: boolean;
145
154
  }) => import("react/jsx-runtime").JSX.Element>;
146
- export declare const ArrowheadCrowfootIcon: React.MemoExoticComponent<({ flip }: {
155
+ export declare const ArrowheadCardinalityExactlyOneIcon: React.MemoExoticComponent<({ flip }: {
147
156
  flip?: boolean;
148
157
  }) => import("react/jsx-runtime").JSX.Element>;
149
- export declare const ArrowheadCrowfootOneIcon: React.MemoExoticComponent<({ flip }: {
158
+ export declare const ArrowheadCardinalityZeroOrOneIcon: React.MemoExoticComponent<({ flip }: {
150
159
  flip?: boolean;
151
160
  }) => import("react/jsx-runtime").JSX.Element>;
152
- export declare const ArrowheadCrowfootOneOrManyIcon: React.MemoExoticComponent<({ flip }: {
161
+ export declare const ArrowheadCardinalityZeroOrManyIcon: React.MemoExoticComponent<({ flip }: {
153
162
  flip?: boolean;
154
163
  }) => import("react/jsx-runtime").JSX.Element>;
155
164
  export declare const FontSizeSmallIcon: import("react/jsx-runtime").JSX.Element;
@@ -71,6 +71,8 @@ export declare const Preferences: {
71
71
  }): import("react/jsx-runtime").JSX.Element;
72
72
  ToggleToolLock: () => import("react/jsx-runtime").JSX.Element;
73
73
  ToggleSnapMode: () => import("react/jsx-runtime").JSX.Element;
74
+ ToggleArrowBinding: () => import("react/jsx-runtime").JSX.Element;
75
+ ToggleMidpointSnapping: () => import("react/jsx-runtime").JSX.Element;
74
76
  ToggleGridMode: () => import("react/jsx-runtime").JSX.Element;
75
77
  ToggleZenMode: () => import("react/jsx-runtime").JSX.Element;
76
78
  ToggleViewMode: () => import("react/jsx-runtime").JSX.Element;