@excalidraw/common 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 (91) hide show
  1. package/dist/dev/index.js +137 -19
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/src/appEventBus.d.ts +27 -0
  5. package/dist/types/common/src/colors.d.ts +13 -13
  6. package/dist/types/common/src/index.d.ts +2 -0
  7. package/dist/types/common/src/utils.d.ts +1 -3
  8. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  9. package/dist/types/element/src/Scene.d.ts +2 -0
  10. package/dist/types/element/src/arrowheads.d.ts +3 -0
  11. package/dist/types/element/src/binding.d.ts +3 -4
  12. package/dist/types/element/src/bounds.d.ts +1 -1
  13. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  14. package/dist/types/element/src/index.d.ts +1 -0
  15. package/dist/types/element/src/linearElementEditor.d.ts +3 -0
  16. package/dist/types/element/src/mutateElement.d.ts +2 -0
  17. package/dist/types/element/src/selection.d.ts +1 -1
  18. package/dist/types/element/src/types.d.ts +5 -2
  19. package/dist/types/element/src/utils.d.ts +1 -1
  20. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +23 -29
  21. package/dist/types/excalidraw/actions/actionBoundText.d.ts +16 -20
  22. package/dist/types/excalidraw/actions/actionCanvas.d.ts +161 -185
  23. package/dist/types/excalidraw/actions/actionClipboard.d.ts +16 -20
  24. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +8 -10
  25. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +25 -31
  26. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -10
  27. package/dist/types/excalidraw/actions/actionElementLock.d.ts +16 -20
  28. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +8 -10
  29. package/dist/types/excalidraw/actions/actionExport.d.ts +104 -388
  30. package/dist/types/excalidraw/actions/actionFrame.d.ts +32 -40
  31. package/dist/types/excalidraw/actions/actionGroup.d.ts +18 -22
  32. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +8 -10
  33. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -10
  34. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -10
  35. package/dist/types/excalidraw/actions/actionProperties.d.ts +17 -21
  36. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +9 -11
  37. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -9
  38. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
  39. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -10
  40. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
  41. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -10
  42. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -10
  43. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +8 -10
  44. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -10
  45. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -10
  46. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  47. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  48. package/dist/types/excalidraw/appState.d.ts +29 -27
  49. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  50. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  51. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  52. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  53. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  54. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  55. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  56. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  57. package/dist/types/excalidraw/clipboard.d.ts +4 -7
  58. package/dist/types/excalidraw/components/App.d.ts +33 -11
  59. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  60. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  61. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  62. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  63. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  64. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  65. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  66. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  67. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  68. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  69. package/dist/types/excalidraw/components/icons.d.ts +17 -8
  70. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  71. package/dist/types/excalidraw/data/blob.d.ts +157 -162
  72. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  73. package/dist/types/excalidraw/data/index.d.ts +2 -3
  74. package/dist/types/excalidraw/data/json.d.ts +90 -84
  75. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  76. package/dist/types/excalidraw/types.d.ts +84 -13
  77. package/package.json +1 -1
  78. package/dist/types/excalidraw/charts.d.ts +0 -27
  79. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  80. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  81. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  82. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  83. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  84. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  85. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  86. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  87. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  88. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  89. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  90. package/dist/types/excalidraw/index.d.ts +0 -47
  91. package/dist/types/excalidraw/polyfill.d.ts +0 -2
@@ -27,6 +27,8 @@ export declare const actionToggleZenMode: {
27
27
  multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
28
28
  selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
29
29
  isBindingEnabled: boolean;
30
+ bindingPreference: "enabled" | "disabled";
31
+ isMidpointSnappingEnabled: boolean;
30
32
  startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
31
33
  suggestedBinding: {
32
34
  element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
@@ -99,6 +101,10 @@ export declare const actionToggleZenMode: {
99
101
  } | {
100
102
  name: "elementLinkSelector";
101
103
  sourceElementId: import("@excalidraw/element/types").ExcalidrawElement["id"];
104
+ } | {
105
+ name: "charts";
106
+ data: import("../charts").Spreadsheet;
107
+ rawText: string;
102
108
  };
103
109
  defaultSidebarDockedPreference: boolean;
104
110
  lastPointerDownWith: import("@excalidraw/element/types").PointerType;
@@ -114,7 +120,7 @@ export declare const actionToggleZenMode: {
114
120
  selectedElementsAreBeingDragged: boolean;
115
121
  shouldCacheIgnoreZoom: boolean;
116
122
  toast: {
117
- message: string;
123
+ message: React.ReactNode;
118
124
  closable?: boolean;
119
125
  duration?: number;
120
126
  } | null;
@@ -131,20 +137,12 @@ export declare const actionToggleZenMode: {
131
137
  height: number;
132
138
  offsetTop: number;
133
139
  offsetLeft: number;
134
- fileHandle: import("browser-fs-access").FileSystemHandle | null;
140
+ fileHandle: FileSystemFileHandle | null;
135
141
  collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
136
142
  stats: {
137
143
  open: boolean;
138
144
  panels: number;
139
145
  };
140
- currentChartType: import("@excalidraw/element/types").ChartType;
141
- pasteDialog: {
142
- shown: false;
143
- data: null;
144
- } | {
145
- shown: true;
146
- data: import("../charts").Spreadsheet;
147
- };
148
146
  showHyperlinkPopup: false | "info" | "editor";
149
147
  selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
150
148
  snapLines: readonly import("../snapping").SnapLine[];
@@ -19,6 +19,8 @@ export { actionCopy, actionCut, actionCopyAsPng, actionCopyAsSvg, copyText, } fr
19
19
  export { actionToggleGridMode } from "./actionToggleGridMode";
20
20
  export { actionToggleZenMode } from "./actionToggleZenMode";
21
21
  export { actionToggleObjectsSnapMode } from "./actionToggleObjectsSnapMode";
22
+ export { actionToggleArrowBinding } from "./actionToggleArrowBinding";
23
+ export { actionToggleMidpointSnapping } from "./actionToggleMidpointSnapping";
22
24
  export { actionToggleStats } from "./actionToggleStats";
23
25
  export { actionUnbindText, actionBindText } from "./actionBoundText";
24
26
  export { actionLink } from "./actionLink";
@@ -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;
@@ -1,33 +1,22 @@
1
1
  import type { AppState, NormalizedZoomValue } from "./types";
2
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
- viewBackgroundColor?: string | undefined;
4
+ zenModeEnabled?: boolean | undefined;
5
+ gridModeEnabled?: boolean | undefined;
6
+ objectsSnapModeEnabled?: boolean | undefined;
5
7
  theme?: import("@excalidraw/element/types").Theme | undefined;
6
8
  name?: string | null | undefined;
7
- zoom?: Readonly<{
8
- value: NormalizedZoomValue;
9
- }> | undefined;
10
- scrollX?: number | undefined;
11
- scrollY?: number | undefined;
12
- editingGroupId?: string | null | undefined;
13
- selectedElementIds?: Readonly<{
14
- [id: string]: true;
15
- }> | undefined;
9
+ currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
10
+ gridSize?: number | undefined;
16
11
  activeTool?: ({
17
12
  lastActiveTool: import("./types").ActiveTool | null;
18
13
  locked: boolean;
19
14
  fromSelection: boolean;
20
15
  } & import("./types").ActiveTool) | undefined;
21
- selectedGroupIds?: {
22
- [groupId: string]: boolean;
23
- } | undefined;
24
- selectedLinearElement?: import("@excalidraw/element").LinearElementEditor | null | undefined;
25
- zenModeEnabled?: boolean | undefined;
26
- shouldCacheIgnoreZoom?: boolean | undefined;
27
- exportScale?: number | undefined;
28
- bindMode?: import("@excalidraw/element/types").BindMode | undefined;
29
- gridSize?: number | undefined;
30
16
  showWelcomeScreen?: boolean | undefined;
17
+ isBindingEnabled?: boolean | undefined;
18
+ bindingPreference?: "enabled" | "disabled" | undefined;
19
+ isMidpointSnappingEnabled?: boolean | undefined;
31
20
  preferredSelectionTool?: {
32
21
  type: "selection" | "lasso";
33
22
  initialized: boolean;
@@ -37,6 +26,7 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
37
26
  exportBackground?: boolean | undefined;
38
27
  exportEmbedScene?: boolean | undefined;
39
28
  exportWithDarkMode?: boolean | undefined;
29
+ exportScale?: number | undefined;
40
30
  currentItemStrokeColor?: string | undefined;
41
31
  currentItemBackgroundColor?: string | undefined;
42
32
  currentItemFillStyle?: import("@excalidraw/element/types").FillStyle | undefined;
@@ -50,9 +40,14 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
50
40
  currentItemStartArrowhead?: import("@excalidraw/element/types").Arrowhead | null | undefined;
51
41
  currentItemEndArrowhead?: import("@excalidraw/element/types").Arrowhead | null | undefined;
52
42
  currentItemRoundness?: import("@excalidraw/element/types").StrokeRoundness | undefined;
53
- currentItemArrowType?: "round" | "sharp" | "elbow" | undefined;
43
+ viewBackgroundColor?: string | undefined;
44
+ scrollX?: number | undefined;
45
+ scrollY?: number | undefined;
54
46
  cursorButton?: "up" | "down" | undefined;
55
47
  scrolledOutside?: boolean | undefined;
48
+ zoom?: Readonly<{
49
+ value: NormalizedZoomValue;
50
+ }> | undefined;
56
51
  openMenu?: "canvas" | null | undefined;
57
52
  openSidebar?: {
58
53
  name: import("./types").SidebarName;
@@ -60,35 +55,42 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
60
55
  } | null | undefined;
61
56
  defaultSidebarDockedPreference?: boolean | undefined;
62
57
  lastPointerDownWith?: import("@excalidraw/element/types").PointerType | undefined;
58
+ selectedElementIds?: Readonly<{
59
+ [id: string]: true;
60
+ }> | undefined;
63
61
  previousSelectedElementIds?: {
64
62
  [id: string]: true;
65
63
  } | undefined;
64
+ shouldCacheIgnoreZoom?: boolean | undefined;
66
65
  gridStep?: number | undefined;
67
- gridModeEnabled?: boolean | undefined;
66
+ selectedGroupIds?: {
67
+ [groupId: string]: boolean;
68
+ } | undefined;
69
+ editingGroupId?: string | null | undefined;
68
70
  stats?: {
69
71
  open: boolean;
70
72
  panels: number;
71
73
  } | undefined;
72
- currentChartType?: import("@excalidraw/element/types").ChartType | undefined;
73
- objectsSnapModeEnabled?: boolean | undefined;
74
+ selectedLinearElement?: import("@excalidraw/element").LinearElementEditor | null | undefined;
74
75
  lockedMultiSelections?: {
75
76
  [groupId: string]: true;
76
77
  } | undefined;
78
+ bindMode?: import("@excalidraw/element/types").BindMode | undefined;
77
79
  };
78
80
  export declare const cleanAppStateForExport: (appState: Partial<AppState>) => {
79
- viewBackgroundColor?: string | undefined;
81
+ gridModeEnabled?: boolean | undefined;
80
82
  gridSize?: number | undefined;
83
+ viewBackgroundColor?: string | undefined;
81
84
  gridStep?: number | undefined;
82
- gridModeEnabled?: boolean | undefined;
83
85
  lockedMultiSelections?: {
84
86
  [groupId: string]: true;
85
87
  } | undefined;
86
88
  };
87
89
  export declare const clearAppStateForDatabase: (appState: Partial<AppState>) => {
88
- viewBackgroundColor?: string | undefined;
90
+ gridModeEnabled?: boolean | undefined;
89
91
  gridSize?: number | undefined;
92
+ viewBackgroundColor?: string | undefined;
90
93
  gridStep?: number | undefined;
91
- gridModeEnabled?: boolean | undefined;
92
94
  lockedMultiSelections?: {
93
95
  [groupId: string]: true;
94
96
  } | undefined;
@@ -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;
@@ -38,8 +35,6 @@ clipboardEvent?: ClipboardEvent | null) => Promise<void>;
38
35
  * Will prompt user for permission if not granted.
39
36
  */
40
37
  export declare const readSystemClipboard: () => Promise<{
41
- "text/plain"?: string | File | undefined;
42
- "text/html"?: string | File | undefined;
43
38
  "image/svg+xml"?: string | File | undefined;
44
39
  "image/png"?: string | File | undefined;
45
40
  "image/jpeg"?: string | File | undefined;
@@ -49,12 +44,14 @@ export declare const readSystemClipboard: () => Promise<{
49
44
  "image/x-icon"?: string | File | undefined;
50
45
  "image/avif"?: string | File | undefined;
51
46
  "image/jfif"?: string | File | undefined;
47
+ "text/plain"?: string | File | undefined;
48
+ "text/html"?: string | File | undefined;
52
49
  }>;
53
50
  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;