@excalidraw/element 0.18.0-2874f9e → 0.18.0-2a82821

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 (144) hide show
  1. package/dist/dev/index.js +5228 -4610
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +19 -18
  4. package/dist/types/common/src/appEventBus.d.ts +27 -0
  5. package/dist/types/common/src/colors.d.ts +2 -2
  6. package/dist/types/common/src/constants.d.ts +9 -7
  7. package/dist/types/common/src/index.d.ts +2 -0
  8. package/dist/types/common/src/utils.d.ts +1 -3
  9. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  10. package/dist/types/element/src/Scene.d.ts +7 -3
  11. package/dist/types/element/src/arrowheads.d.ts +3 -0
  12. package/dist/types/element/src/binding.d.ts +3 -4
  13. package/dist/types/element/src/bounds.d.ts +22 -3
  14. package/dist/types/element/src/comparisons.d.ts +1 -0
  15. package/dist/types/element/src/duplicate.d.ts +1 -0
  16. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  17. package/dist/types/element/src/frame.d.ts +7 -6
  18. package/dist/types/element/src/index.d.ts +1 -0
  19. package/dist/types/element/src/linearElementEditor.d.ts +5 -2
  20. package/dist/types/element/src/mutateElement.d.ts +2 -0
  21. package/dist/types/element/src/newElement.d.ts +1 -0
  22. package/dist/types/element/src/selection.d.ts +7 -3
  23. package/dist/types/element/src/shape.d.ts +1 -1
  24. package/dist/types/element/src/textElement.d.ts +1 -1
  25. package/dist/types/element/src/textWrapping.d.ts +26 -0
  26. package/dist/types/element/src/typeChecks.d.ts +1 -0
  27. package/dist/types/element/src/types.d.ts +11 -2
  28. package/dist/types/element/src/utils.d.ts +2 -2
  29. package/dist/types/element/src/visualdebug.d.ts +1 -2
  30. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +35 -38
  31. package/dist/types/excalidraw/actions/actionBoundText.d.ts +25 -27
  32. package/dist/types/excalidraw/actions/actionCanvas.d.ts +144 -156
  33. package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -26
  34. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -13
  35. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +36 -39
  36. package/dist/types/excalidraw/actions/actionDeselect.d.ts +160 -0
  37. package/dist/types/excalidraw/actions/actionElementLink.d.ts +8 -13
  38. package/dist/types/excalidraw/actions/actionElementLock.d.ts +24 -26
  39. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -13
  40. package/dist/types/excalidraw/actions/actionExport.d.ts +67 -349
  41. package/dist/types/excalidraw/actions/actionFrame.d.ts +49 -52
  42. package/dist/types/excalidraw/actions/actionGroup.d.ts +25 -27
  43. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +13 -13
  44. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -13
  45. package/dist/types/excalidraw/actions/actionMenu.d.ts +8 -13
  46. package/dist/types/excalidraw/actions/actionProperties.d.ts +36 -29
  47. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -13
  48. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -12
  49. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  50. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +173 -0
  51. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +12 -13
  52. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +173 -0
  53. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +12 -13
  54. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -13
  55. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +12 -13
  56. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +12 -13
  57. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -13
  58. package/dist/types/excalidraw/actions/index.d.ts +4 -1
  59. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  60. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  61. package/dist/types/excalidraw/appState.d.ts +6 -2
  62. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  63. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  64. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  65. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  66. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  67. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  68. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  69. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  70. package/dist/types/excalidraw/clipboard.d.ts +2 -5
  71. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  72. package/dist/types/excalidraw/components/App.d.ts +54 -14
  73. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  74. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  75. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  76. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  77. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  78. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  79. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  80. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  81. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  82. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  83. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  84. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  85. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  86. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  87. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  88. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  89. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  90. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  91. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  92. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  93. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  94. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  95. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
  96. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  97. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  98. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  99. package/dist/types/excalidraw/components/icons.d.ts +19 -8
  100. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +9 -3
  101. package/dist/types/excalidraw/components/shapes.d.ts +7 -0
  102. package/dist/types/excalidraw/data/blob.d.ts +31 -34
  103. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  104. package/dist/types/excalidraw/data/index.d.ts +2 -3
  105. package/dist/types/excalidraw/data/json.d.ts +30 -23
  106. package/dist/types/excalidraw/data/library.d.ts +1 -1
  107. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  108. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  109. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  110. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  111. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  112. package/dist/types/excalidraw/renderer/animation.d.ts +4 -1
  113. package/dist/types/excalidraw/scene/Renderer.d.ts +426 -19
  114. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  115. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  116. package/dist/types/excalidraw/types.d.ts +110 -18
  117. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  118. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  119. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  120. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  121. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  122. package/dist/types/laser-pointer/src/state.d.ts +35 -0
  123. package/dist/types/math/src/constants.d.ts +0 -1
  124. package/dist/types/math/src/curve.d.ts +4 -1
  125. package/dist/types/math/src/point.d.ts +2 -1
  126. package/dist/types/utils/src/index.d.ts +1 -2
  127. package/package.json +4 -3
  128. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  129. package/dist/types/excalidraw/charts.d.ts +0 -27
  130. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  131. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  132. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  133. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  134. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  135. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  136. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  137. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  138. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  139. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  140. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  141. package/dist/types/excalidraw/index.d.ts +0 -47
  142. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  143. package/dist/types/utils/src/bbox.d.ts +0 -9
  144. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -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,4 +1,4 @@
1
- export declare const activeConfirmDialogAtom: import("jotai/vanilla/atom").PrimitiveAtom<"clearCanvas" | null> & {
1
+ export declare const activeConfirmDialogAtom: import("jotai").PrimitiveAtom<"clearCanvas" | null> & {
2
2
  init: "clearCanvas" | null;
3
3
  };
4
4
  export declare const ActiveConfirmDialog: () => import("react/jsx-runtime").JSX.Element | null;
@@ -1,27 +1,42 @@
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";
6
6
  import { ActionManager } from "../actions/manager";
7
- import { AnimationFrameHandler } from "../animation-frame-handler";
8
7
  import { History } from "../history";
9
8
  import { Fonts } from "../fonts";
10
9
  import { type WritableAtom } from "../editor-jotai";
11
10
  import { Renderer } from "../scene/Renderer";
12
- import { LaserTrails } from "../laser-trails";
11
+ import { LaserTrails } from "../laserTrails";
13
12
  import { isOverScrollBars } from "../scene/scrollbars";
14
13
  import { LassoTrail } from "../lasso";
15
14
  import { EraserTrail } from "../eraser";
15
+ import { type OnStateChange } from "./AppStateObserver";
16
16
  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";
17
+ import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
19
18
  import type { RoughCanvas } from "roughjs/bin/canvas";
20
19
  import type { ActionResult } from "../actions/types";
20
+ declare const editorLifecycleEventBehavior: {
21
+ readonly "editor:mount": {
22
+ readonly cardinality: "once";
23
+ readonly replay: "last";
24
+ };
25
+ readonly "editor:initialize": {
26
+ readonly cardinality: "once";
27
+ readonly replay: "last";
28
+ };
29
+ readonly "editor:unmount": {
30
+ readonly cardinality: "once";
31
+ readonly replay: "last";
32
+ };
33
+ };
21
34
  export declare const ExcalidrawContainerContext: React.Context<{
22
35
  container: HTMLDivElement | null;
23
36
  id: string | null;
24
37
  }>;
38
+ export declare const ExcalidrawAPIContext: React.Context<ExcalidrawImperativeAPI | null>;
39
+ export declare const ExcalidrawAPISetContext: React.Context<((api: ExcalidrawImperativeAPI | null) => void) | null>;
25
40
  export declare const useApp: () => AppClassProperties;
26
41
  export declare const useAppProps: () => AppProps;
27
42
  export declare const useEditorInterface: () => Readonly<{
@@ -44,9 +59,14 @@ export declare const useExcalidrawElements: () => readonly NonDeletedExcalidrawE
44
59
  export declare const useExcalidrawAppState: () => AppState;
45
60
  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
61
  export declare const useExcalidrawActionManager: () => ActionManager;
62
+ /**
63
+ * Requires wrapping your component in <ExcalidrawAPIContext.Provider>
64
+ */
65
+ export declare const useExcalidrawAPI: () => ExcalidrawImperativeAPI | null;
47
66
  declare class App extends React.Component<AppProps, AppState> {
48
67
  canvas: AppClassProperties["canvas"];
49
68
  interactiveCanvas: AppClassProperties["interactiveCanvas"];
69
+ sessionExportThemeOverride: AppState["theme"] | undefined;
50
70
  rc: RoughCanvas;
51
71
  unmounted: boolean;
52
72
  actionManager: ActionManager;
@@ -80,20 +100,26 @@ declare class App extends React.Component<AppProps, AppState> {
80
100
  /** embeds that have been inserted to DOM (as a perf optim, we don't want to
81
101
  * insert to DOM before user initially scrolls to them) */
82
102
  private initializedEmbeds;
83
- private handleToastClose;
84
103
  private elementsPendingErasure;
104
+ private _initialized;
105
+ private readonly editorLifecycleEvents;
106
+ onEvent: AppEventBus<ExcalidrawImperativeAPIEventMap, typeof editorLifecycleEventBehavior>["on"];
107
+ private appStateObserver;
108
+ onStateChange: OnStateChange;
85
109
  flowChartCreator: FlowChartCreator;
86
110
  private flowChartNavigator;
87
111
  bindModeHandler: ReturnType<typeof setTimeout> | null;
88
112
  hitLinkElement?: NonDeletedExcalidrawElement;
89
113
  lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
90
114
  lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
115
+ lastPointerUpIsDoubleClick: boolean;
91
116
  lastPointerMoveEvent: PointerEvent | null;
92
117
  /** current frame pointer cords */
93
118
  lastPointerMoveCoords: {
94
119
  x: number;
95
120
  y: number;
96
121
  } | null;
122
+ private lastCompletedCanvasClicks;
97
123
  /** previous frame pointer coords */
98
124
  previousPointerMoveCoords: {
99
125
  x: number;
@@ -103,7 +129,6 @@ declare class App extends React.Component<AppProps, AppState> {
103
129
  x: number;
104
130
  y: number;
105
131
  };
106
- animationFrameHandler: AnimationFrameHandler;
107
132
  laserTrails: LaserTrails;
108
133
  eraserTrail: EraserTrail;
109
134
  lassoTrail: LassoTrail;
@@ -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;
@@ -251,10 +278,12 @@ declare class App extends React.Component<AppProps, AppState> {
251
278
  * If disabled, returns null.
252
279
  */
253
280
  getEffectiveGridSize: () => NullableGridSize;
281
+ private getTextCreationGridPoint;
254
282
  private getHTMLIFrameElement;
255
283
  private handleIframeLikeElementHover;
256
284
  /** @returns true if iframe-like element click handled */
257
285
  private handleIframeLikeCenterClick;
286
+ private isDoubleClick;
258
287
  private isIframeLikeElementCenter;
259
288
  private updateEmbedValidationStatus;
260
289
  private updateEmbeddables;
@@ -330,6 +359,7 @@ declare class App extends React.Component<AppProps, AppState> {
330
359
  } | "cursor" | "center";
331
360
  retainSeed?: boolean;
332
361
  fitToContent?: boolean;
362
+ preserveFrameChildrenOrder?: boolean;
333
363
  }) => void;
334
364
  private addElementsFromMixedContentPaste;
335
365
  private addTextFromPaste;
@@ -379,11 +409,7 @@ declare class App extends React.Component<AppProps, AppState> {
379
409
  private maybeUnfollowRemoteUser;
380
410
  /** use when changing scrollX/scrollY/zoom based on user interaction */
381
411
  private translateCanvas;
382
- setToast: (toast: {
383
- message: string;
384
- closable?: boolean;
385
- duration?: number;
386
- } | null) => void;
412
+ setToast: (toast: AppState["toast"]) => void;
387
413
  restoreFileFromShare: () => Promise<void>;
388
414
  /**
389
415
  * adds supplied files to existing files in the appState.
@@ -449,7 +475,11 @@ declare class App extends React.Component<AppProps, AppState> {
449
475
  private onGestureEnd;
450
476
  private handleTextWysiwyg;
451
477
  private deselectElements;
478
+ private getSelectedTextElement;
479
+ private getSelectedTextEditingContainerAtPosition;
452
480
  private getTextElementAtPosition;
481
+ private isHittingTextAutoResizeHandle;
482
+ private handleTextAutoResizeHandlePointerDown;
453
483
  private getElementAtPosition;
454
484
  private getElementsAtPosition;
455
485
  getElementHitThreshold(element: ExcalidrawElement): number;
@@ -458,10 +488,20 @@ declare class App extends React.Component<AppProps, AppState> {
458
488
  private startTextEditing;
459
489
  private startImageCropping;
460
490
  private finishImageCropping;
491
+ private shouldHandleBrowserCanvasDoubleClick;
461
492
  private handleCanvasDoubleClick;
493
+ private handleCanvasClick;
462
494
  private getElementLinkAtPosition;
463
495
  private handleElementLinkClick;
496
+ /**
497
+ * finds candidate frame under cursor (when dragging frame children/elements
498
+ * inside frames)
499
+ */
464
500
  private getTopLayerFrameAtSceneCoords;
501
+ private updateFrameToHighlight;
502
+ private maybeUpdateFrameToHighlightOnPointerMove;
503
+ private insertNewElements;
504
+ private insertNewElement;
465
505
  private handleCanvasPointerMove;
466
506
  private handleEraser;
467
507
  private handleTouchMove;
@@ -503,6 +543,7 @@ declare class App extends React.Component<AppProps, AppState> {
503
543
  private newImagePlaceholder;
504
544
  private handleLinearElementOnPointerDown;
505
545
  private getCurrentItemRoundness;
546
+ private getCurrentItemStrokeWidth;
506
547
  private createGenericElementOnPointerDown;
507
548
  private createFrameElementOnPointerDown;
508
549
  private maybeCacheReferenceSnapPoints;
@@ -531,12 +572,11 @@ declare class App extends React.Component<AppProps, AppState> {
531
572
  /** generally you should use `addNewImagesToImageCache()` directly if you need
532
573
  * to render new images. This is just a failsafe */
533
574
  private scheduleImageRefresh;
534
- private updateBindingEnabledOnPointerMove;
535
575
  private clearSelection;
536
576
  private handleInteractiveCanvasRef;
537
577
  private insertImages;
538
578
  private handleAppOnDrop;
539
- loadFileToCanvas: (file: File, fileHandle: FileSystemHandle | null) => Promise<void>;
579
+ loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null) => Promise<void>;
540
580
  private handleCanvasContextMenu;
541
581
  private maybeDragNewGenericElement;
542
582
  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 {};
@@ -14,7 +14,7 @@ export declare const isCustomColor: ({ color, palette, }: {
14
14
  }) => boolean;
15
15
  export declare const getMostUsedCustomColors: (elements: readonly ExcalidrawElement[], type: "elementBackground" | "elementStroke", palette: ColorPaletteCustom) => string[];
16
16
  export type ActiveColorPickerSectionAtomType = "custom" | "baseColors" | "shades" | "hex" | null;
17
- export declare const activeColorPickerSectionAtom: import("jotai/vanilla/atom").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
17
+ export declare const activeColorPickerSectionAtom: import("jotai").PrimitiveAtom<ActiveColorPickerSectionAtomType> & {
18
18
  init: ActiveColorPickerSectionAtomType;
19
19
  };
20
20
  export type ColorPickerType = "canvasBackground" | "elementBackground" | "elementStroke";
@@ -1,2 +1 @@
1
- import type { CommandPaletteItem } from "./types";
2
- export declare const toggleTheme: CommandPaletteItem;
1
+ export {};
@@ -2,7 +2,7 @@ import type { ConvertibleTypes, ExcalidrawElement, ExcalidrawTextContainer, Exca
2
2
  import type { Scene } from "@excalidraw/element";
3
3
  import "./ConvertElementTypePopup.scss";
4
4
  import type App from "./App";
5
- export declare const convertElementTypePopupAtom: import("jotai/vanilla/atom").PrimitiveAtom<{
5
+ export declare const convertElementTypePopupAtom: import("jotai").PrimitiveAtom<{
6
6
  type: "panel";
7
7
  } | null> & {
8
8
  init: {
@@ -13,7 +13,7 @@ export type EyeDropperProperties = {
13
13
  **/
14
14
  colorPickerType: ColorPickerType;
15
15
  };
16
- export declare const activeEyeDropperAtom: import("jotai/vanilla/atom").PrimitiveAtom<EyeDropperProperties | null> & {
16
+ export declare const activeEyeDropperAtom: import("jotai").PrimitiveAtom<EyeDropperProperties | null> & {
17
17
  init: EyeDropperProperties | null;
18
18
  };
19
19
  export declare const EyeDropper: React.FC<{
@@ -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,6 +1,6 @@
1
1
  import React from "react";
2
2
  import "./LibraryMenu.scss";
3
- export declare const isLibraryMenuOpenAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
3
+ export declare const isLibraryMenuOpenAtom: import("jotai").PrimitiveAtom<boolean> & {
4
4
  init: boolean;
5
5
  };
6
6
  /**
@@ -11,7 +11,7 @@ export type OverwriteConfirmState = {
11
11
  } | {
12
12
  active: false;
13
13
  };
14
- export declare const overwriteConfirmStateAtom: import("jotai/vanilla/atom").PrimitiveAtom<OverwriteConfirmState> & {
14
+ export declare const overwriteConfirmStateAtom: import("jotai").PrimitiveAtom<OverwriteConfirmState> & {
15
15
  init: OverwriteConfirmState;
16
16
  };
17
17
  export declare function openConfirmModal({ title, description, actionLabel, color, }: {
@@ -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;
@@ -1,8 +1,14 @@
1
+ import React from "react";
1
2
  import "./Range.scss";
2
- import type { AppClassProperties } from "../types";
3
3
  export type RangeProps = {
4
- updateData: (value: number) => void;
5
- app: AppClassProperties;
4
+ label: React.ReactNode;
5
+ value: number;
6
+ onChange: (value: number) => void;
7
+ min?: number;
8
+ max?: number;
9
+ step?: number;
10
+ minLabel?: React.ReactNode;
11
+ hasCommonValue?: boolean;
6
12
  testId?: string;
7
13
  };
8
- export declare const Range: ({ updateData, app, testId }: RangeProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const Range: ({ label, value, onChange, min, max, step, minLabel, hasCommonValue, testId, }: RangeProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import "./SVGLayer.scss";
2
- import type { Trail } from "../animated-trail";
2
+ import type { Trail } from "../animatedTrail";
3
3
  type SVGLayerProps = {
4
4
  trails: Trail[];
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import "./SearchMenu.scss";
2
- export declare const searchItemInFocusAtom: import("jotai/vanilla/atom").PrimitiveAtom<number | null> & {
2
+ export declare const searchItemInFocusAtom: import("jotai").PrimitiveAtom<number | null> & {
3
3
  init: number | null;
4
4
  };
5
5
  export declare const SearchMenu: () => import("react/jsx-runtime").JSX.Element;
@@ -8,7 +8,7 @@ import "./Sidebar.scss";
8
8
  *
9
9
  * Since we can only render one Sidebar at a time, we can use a simple flag.
10
10
  */
11
- export declare const isSidebarDockedAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
11
+ export declare const isSidebarDockedAtom: import("jotai").PrimitiveAtom<boolean> & {
12
12
  init: boolean;
13
13
  };
14
14
  export declare const SidebarInner: React.ForwardRefExoticComponent<Omit<{
@@ -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,13 +1,13 @@
1
1
  import type { RateLimits, TChat } from "./types";
2
- export declare const rateLimitsAtom: import("jotai/vanilla/atom").PrimitiveAtom<RateLimits | null> & {
2
+ export declare const rateLimitsAtom: import("jotai").PrimitiveAtom<RateLimits | null> & {
3
3
  init: RateLimits | null;
4
4
  };
5
- export declare const showPreviewAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
5
+ export declare const showPreviewAtom: import("jotai").PrimitiveAtom<boolean> & {
6
6
  init: boolean;
7
7
  };
8
- export declare const errorAtom: import("jotai/vanilla/atom").PrimitiveAtom<Error | null> & {
8
+ export declare const errorAtom: import("jotai").PrimitiveAtom<Error | null> & {
9
9
  init: Error | null;
10
10
  };
11
- export declare const chatHistoryAtom: import("jotai/vanilla/atom").PrimitiveAtom<TChat.ChatHistory> & {
11
+ export declare const chatHistoryAtom: import("jotai").PrimitiveAtom<TChat.ChatHistory> & {
12
12
  init: TChat.ChatHistory;
13
13
  };
@@ -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>;
@@ -9,13 +9,13 @@ interface UseTTDChatStorageReturn {
9
9
  restoreChat: (chat: SavedChat) => SavedChat;
10
10
  createNewChatId: () => Promise<string>;
11
11
  }
12
- export declare const savedChatsAtom: import("jotai/vanilla/atom").PrimitiveAtom<SavedChats> & {
12
+ export declare const savedChatsAtom: import("jotai").PrimitiveAtom<SavedChats> & {
13
13
  init: SavedChats;
14
14
  };
15
- export declare const isLoadingChatsAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
15
+ export declare const isLoadingChatsAtom: import("jotai").PrimitiveAtom<boolean> & {
16
16
  init: boolean;
17
17
  };
18
- export declare const chatsLoadedAtom: import("jotai/vanilla/atom").PrimitiveAtom<boolean> & {
18
+ export declare const chatsLoadedAtom: import("jotai").PrimitiveAtom<boolean> & {
19
19
  init: boolean;
20
20
  };
21
21
  export declare const useTTDChatStorage: ({ persistenceAdapter, }: UseTTDChatStorageProps) => UseTTDChatStorageReturn;
@@ -0,0 +1 @@
1
+ export declare const getMermaidAutoFixCandidates: (sourceText: string, errorMessage: string) => string[];