@dwelle/excalidraw 0.4.0-e8dbc14 → 0.4.0-e9428e5

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 (83) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/excalidraw-assets-dev/{vendor-e713a7c978e2fe4f9623.js → vendor-4e3877ebc9902633043c.js} +2 -2
  3. package/dist/excalidraw-with-preact.development.js +370 -73
  4. package/dist/excalidraw-with-preact.production.min.js +1 -1
  5. package/dist/excalidraw.development.js +370 -73
  6. package/dist/excalidraw.production.min.js +1 -1
  7. package/main.js +1 -5
  8. package/package.json +1 -1
  9. package/types/actions/actionAddToLibrary.d.ts +30 -6
  10. package/types/actions/actionBoundText.d.ts +20 -4
  11. package/types/actions/actionCanvas.d.ts +110 -22
  12. package/types/actions/actionClipboard.d.ts +70 -14
  13. package/types/actions/actionDeleteSelected.d.ts +30 -6
  14. package/types/actions/actionElementLock.d.ts +20 -4
  15. package/types/actions/actionExport.d.ts +86 -22
  16. package/types/actions/actionFinalize.d.ts +20 -4
  17. package/types/actions/actionFrame.d.ts +30 -6
  18. package/types/actions/actionGroup.d.ts +20 -4
  19. package/types/actions/actionLinearEditor.d.ts +10 -2
  20. package/types/actions/actionMenu.d.ts +24 -6
  21. package/types/actions/actionProperties.d.ts +130 -26
  22. package/types/actions/actionSelectAll.d.ts +10 -2
  23. package/types/actions/actionStyles.d.ts +10 -2
  24. package/types/actions/actionToggleGridMode.d.ts +10 -2
  25. package/types/actions/actionToggleObjectsSnapMode.d.ts +10 -2
  26. package/types/actions/actionToggleStats.d.ts +10 -2
  27. package/types/actions/actionToggleViewMode.d.ts +10 -2
  28. package/types/actions/actionToggleZenMode.d.ts +10 -2
  29. package/types/appState.d.ts +2 -2
  30. package/types/components/App.d.ts +27 -6
  31. package/types/components/Button.d.ts +1 -1
  32. package/types/components/InlineIcon.d.ts +3 -0
  33. package/types/components/LayerUI.d.ts +5 -1
  34. package/types/components/MagicButton.d.ts +9 -0
  35. package/types/components/MagicSettings.d.ts +8 -0
  36. package/types/components/Paragraph.d.ts +4 -0
  37. package/types/components/TTDDialog/MermaidToExcalidraw.d.ts +6 -0
  38. package/types/components/TTDDialog/TTDDialog.d.ts +29 -0
  39. package/types/components/TTDDialog/TTDDialogInput.d.ts +9 -0
  40. package/types/components/TTDDialog/TTDDialogOutput.d.ts +7 -0
  41. package/types/components/TTDDialog/TTDDialogPanel.d.ts +16 -0
  42. package/types/components/TTDDialog/TTDDialogPanels.d.ts +4 -0
  43. package/types/components/TTDDialog/TTDDialogTab.d.ts +7 -0
  44. package/types/components/TTDDialog/TTDDialogTabTrigger.d.ts +8 -0
  45. package/types/components/TTDDialog/TTDDialogTabTriggers.d.ts +6 -0
  46. package/types/components/TTDDialog/TTDDialogTabs.d.ts +9 -0
  47. package/types/components/TTDDialog/TTDDialogTrigger.d.ts +8 -0
  48. package/types/components/TTDDialog/common.d.ts +33 -0
  49. package/types/components/TextField.d.ts +16 -0
  50. package/types/components/dropdownMenu/DropdownMenu.d.ts +6 -0
  51. package/types/components/dropdownMenu/DropdownMenuItem.d.ts +12 -0
  52. package/types/components/icons.d.ts +6 -0
  53. package/types/components/main-menu/MainMenu.d.ts +6 -0
  54. package/types/constants.d.ts +24 -2
  55. package/types/context/tunnels.d.ts +1 -0
  56. package/types/data/EditorLocalStorage.d.ts +8 -0
  57. package/types/data/ai/types.d.ts +242 -0
  58. package/types/data/index.d.ts +3 -3
  59. package/types/data/magic.d.ts +23 -0
  60. package/types/data/transform.d.ts +11 -7
  61. package/types/element/ElementCanvasButtons.d.ts +6 -0
  62. package/types/element/Hyperlink.d.ts +10 -2
  63. package/types/element/collision.d.ts +2 -2
  64. package/types/element/embeddable.d.ts +16 -21
  65. package/types/element/index.d.ts +3 -4
  66. package/types/element/linearElementEditor.d.ts +10 -2
  67. package/types/element/newElement.d.ts +7 -1
  68. package/types/element/textElement.d.ts +2 -2
  69. package/types/element/typeChecks.d.ts +9 -6
  70. package/types/element/types.d.ts +29 -2
  71. package/types/frame.d.ts +21 -20
  72. package/types/packages/excalidraw/index.d.ts +2 -0
  73. package/types/packages/excalidraw/main.d.ts +3 -1
  74. package/types/scene/Scene.d.ts +4 -4
  75. package/types/scene/ShapeCache.d.ts +1 -1
  76. package/types/scene/comparisons.d.ts +7 -6
  77. package/types/scene/export.d.ts +3 -3
  78. package/types/scene/types.d.ts +2 -0
  79. package/types/shapes.d.ts +1 -1
  80. package/types/types.d.ts +24 -10
  81. package/types/utils.d.ts +1 -0
  82. package/types/components/MermaidToExcalidraw.d.ts +0 -3
  83. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e713a7c978e2fe4f9623.d.ts → vendor-4e3877ebc9902633043c.d.ts} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { Point } from "../types";
2
2
  import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
3
  import { MarkNonNullable, ValueOf } from "../utility-types";
4
+ import { MagicCacheData } from "../data/magic";
4
5
  export type ChartType = "bar" | "line";
5
6
  export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
6
7
  export type FontFamilyKeys = keyof typeof FONT_FAMILY;
@@ -84,6 +85,26 @@ export type ExcalidrawEmbeddableElement = _ExcalidrawElementBase & Readonly<{
84
85
  */
85
86
  validated: boolean | null;
86
87
  }>;
88
+ export type ExcalidrawIframeElement = _ExcalidrawElementBase & Readonly<{
89
+ type: "iframe";
90
+ customData?: {
91
+ generationData?: MagicCacheData;
92
+ };
93
+ }>;
94
+ export type ExcalidrawIframeLikeElement = ExcalidrawIframeElement | ExcalidrawEmbeddableElement;
95
+ export type IframeData = ({
96
+ intrinsicSize: {
97
+ w: number;
98
+ h: number;
99
+ };
100
+ warning?: string;
101
+ } & ({
102
+ type: "video" | "generic";
103
+ link: string;
104
+ } | {
105
+ type: "document";
106
+ srcdoc: (theme: Theme) => string;
107
+ }));
87
108
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
88
109
  type: "image";
89
110
  fileId: FileId | null;
@@ -97,6 +118,11 @@ export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
97
118
  type: "frame";
98
119
  name: string | null;
99
120
  };
121
+ export type ExcalidrawMagicFrameElement = _ExcalidrawElementBase & {
122
+ type: "magicframe";
123
+ name: string | null;
124
+ };
125
+ export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagicFrameElement;
100
126
  /**
101
127
  * These are elements that don't have any additional properties.
102
128
  */
@@ -106,7 +132,7 @@ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRe
106
132
  * no computed data. The list of all ExcalidrawElements should be shareable
107
133
  * between peers and contain no state local to the peer.
108
134
  */
109
- export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawEmbeddableElement;
135
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawMagicFrameElement | ExcalidrawIframeElement | ExcalidrawEmbeddableElement;
110
136
  export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
111
137
  isDeleted: boolean;
112
138
  };
@@ -129,7 +155,7 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
129
155
  _brand: "unitlessLineHeight";
130
156
  };
131
157
  }>;
132
- export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement;
158
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement | ExcalidrawMagicFrameElement;
133
159
  export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
134
160
  export type ExcalidrawTextElementWithContainer = {
135
161
  containerId: ExcalidrawTextContainer["id"];
@@ -162,4 +188,5 @@ export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
162
188
  export type FileId = string & {
163
189
  _brand: "FileId";
164
190
  };
191
+ export type ExcalidrawElementType = ExcalidrawElement["type"];
165
192
  export {};
package/types/frame.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
1
+ import { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
2
  import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
3
3
  import { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
4
4
  export declare const bindElementsToFramesAfterDuplication: (nextElements: ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
5
- export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameElement): boolean;
6
- export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
7
- export declare const isElementContainingFrame: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
8
- export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
9
- export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => boolean;
10
- export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameElement) => boolean;
5
+ export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement): boolean;
6
+ export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
7
+ export declare const isElementContainingFrame: (elements: readonly ExcalidrawElement[], element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement) => boolean;
8
+ export declare const getElementsIntersectingFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
9
+ export declare const elementsAreInFrameBounds: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => boolean;
10
+ export declare const elementOverlapsWithFrame: (element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement) => boolean;
11
11
  export declare const isCursorInFrame: (cursorCoords: {
12
12
  x: number;
13
13
  y: number;
14
- }, frame: NonDeleted<ExcalidrawFrameElement>) => boolean;
15
- export declare const groupsAreAtLeastIntersectingTheFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
16
- export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameElement) => boolean;
14
+ }, frame: NonDeleted<ExcalidrawFrameLikeElement>) => boolean;
15
+ export declare const groupsAreAtLeastIntersectingTheFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameLikeElement) => boolean;
16
+ export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDeletedExcalidrawElement[], groupIds: readonly string[], frame: ExcalidrawFrameLikeElement) => boolean;
17
17
  /**
18
18
  * Returns a map of frameId to frame elements. Includes empty frames.
19
19
  */
20
- export declare const groupByFrames: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
20
+ export declare const groupByFrameLikes: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
21
21
  export declare const getFrameChildren: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
22
- export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawFrameElement[];
22
+ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawFrameLikeElement[];
23
23
  /**
24
24
  * Returns ExcalidrawFrameElements and non-frame-children elements.
25
25
  *
@@ -29,28 +29,29 @@ export declare const getFrameElements: (allElements: ExcalidrawElementsIncluding
29
29
  * Considers non-frame bound elements (container or arrow labels) as root.
30
30
  */
31
31
  export declare const getRootElements: (allElements: ExcalidrawElementsIncludingDeleted) => ExcalidrawElement[];
32
- export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
33
- export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement) => ExcalidrawElement[];
34
- export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameElement | null;
32
+ export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
33
+ export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
34
+ export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameLikeElement | null;
35
35
  /**
36
36
  * Retains (or repairs for target frame) the ordering invriant where children
37
37
  * elements come right before the parent frame:
38
38
  * [el, el, child, child, frame, el]
39
39
  */
40
- export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
40
+ export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
41
41
  export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
42
- export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
43
- export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
42
+ export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
43
+ export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, appState: AppState) => ExcalidrawElement[];
44
44
  /** does not mutate elements, but returns new ones */
45
45
  export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
46
46
  /**
47
47
  * filters out elements that are inside groups that contain a frame element
48
48
  * anywhere in the group tree
49
49
  */
50
- export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
50
+ export declare const omitGroupsContainingFrameLikes: (allElements: ExcalidrawElementsIncludingDeleted, selectedElements?: readonly ExcalidrawElement[]) => ExcalidrawElement[];
51
51
  /**
52
52
  * depending on the appState, return target frame, which is the frame the given element
53
53
  * is going to be added to or remove from
54
54
  */
55
- export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
55
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => import("./element/types").ExcalidrawFrameElement | import("./element/types").ExcalidrawMagicFrameElement | null;
56
56
  export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
57
+ export declare const getFrameLikeTitle: (element: ExcalidrawFrameLikeElement, frameIdx: number) => string;
@@ -24,6 +24,8 @@ export { useDevice } from "../../components/App";
24
24
  export { WelcomeScreen };
25
25
  export { LiveCollaborationTrigger };
26
26
  export { DefaultSidebar } from "../../components/DefaultSidebar";
27
+ export { TTDDialog } from "../../components/TTDDialog/TTDDialog";
28
+ export { TTDDialogTrigger } from "../../components/TTDDialog/TTDDialogTrigger";
27
29
  export { exportToCanvas } from "../../scene/export";
28
30
  export { normalizeLink } from "../../data/url";
29
31
  export { convertToExcalidrawElements } from "../../data/transform";
@@ -1,2 +1,4 @@
1
- declare const _exports: any;
1
+ declare const _exports: {
2
+ ExcalidrawLib: {};
3
+ };
2
4
  export = _exports;
@@ -1,4 +1,4 @@
1
- import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
1
+ import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
3
  import { AppState } from "../types";
4
4
  type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
@@ -19,14 +19,14 @@ declare class Scene {
19
19
  private callbacks;
20
20
  private nonDeletedElements;
21
21
  private elements;
22
- private nonDeletedFrames;
22
+ private nonDeletedFramesLikes;
23
23
  private frames;
24
24
  private elementsMap;
25
25
  private selectedElementsCache;
26
26
  private versionNonce;
27
27
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
28
28
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
29
- getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
29
+ getFramesIncludingDeleted(): readonly ExcalidrawFrameLikeElement[];
30
30
  getSelectedElements(opts: {
31
31
  selectedElementIds: AppState["selectedElementIds"];
32
32
  /**
@@ -38,7 +38,7 @@ declare class Scene {
38
38
  includeBoundTextElement?: boolean;
39
39
  includeElementsInFrames?: boolean;
40
40
  }): NonDeleted<ExcalidrawElement>[];
41
- getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
41
+ getNonDeletedFramesLikes(): readonly NonDeleted<ExcalidrawFrameLikeElement>[];
42
42
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
43
43
  getVersionNonce(): number | undefined;
44
44
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
@@ -16,5 +16,5 @@ export declare class ShapeCache {
16
16
  * Generates & caches shape for element if not already cached, otherwise
17
17
  * returns cached shape.
18
18
  */
19
- static generateElementShape: <T extends import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawEmbeddableElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawFrameElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement>(element: T, isExporting?: boolean) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
19
+ static generateElementShape: <T extends import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawEmbeddableElement | import("../element/types").ExcalidrawIframeElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawFrameElement | import("../element/types").ExcalidrawMagicFrameElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement>(element: T, isExporting?: boolean) => ((T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined) & ({} | null)) | (T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable | null);
20
20
  }
@@ -1,9 +1,10 @@
1
1
  import { NonDeletedExcalidrawElement } from "../element/types";
2
- export declare const hasBackground: (type: string) => boolean;
3
- export declare const hasStrokeColor: (type: string) => boolean;
4
- export declare const hasStrokeWidth: (type: string) => boolean;
5
- export declare const hasStrokeStyle: (type: string) => boolean;
6
- export declare const canChangeRoundness: (type: string) => boolean;
7
- export declare const canHaveArrowheads: (type: string) => boolean;
2
+ import { ElementOrToolType } from "../types";
3
+ export declare const hasBackground: (type: ElementOrToolType) => boolean;
4
+ export declare const hasStrokeColor: (type: ElementOrToolType) => boolean;
5
+ export declare const hasStrokeWidth: (type: ElementOrToolType) => boolean;
6
+ export declare const hasStrokeStyle: (type: ElementOrToolType) => boolean;
7
+ export declare const canChangeRoundness: (type: ElementOrToolType) => boolean;
8
+ export declare const canHaveArrowheads: (type: ElementOrToolType) => boolean;
8
9
  export declare const getElementAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement | null;
9
10
  export declare const getElementsAtPosition: (elements: readonly NonDeletedExcalidrawElement[], isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean) => NonDeletedExcalidrawElement[];
@@ -1,4 +1,4 @@
1
- import { ExcalidrawFrameElement, NonDeletedExcalidrawElement, Theme } from "../element/types";
1
+ import { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement, Theme } from "../element/types";
2
2
  import { Bounds } from "../element/bounds";
3
3
  import { AppState, BinaryFiles } from "../types";
4
4
  export type ExportToCanvasData = {
@@ -167,7 +167,7 @@ export type ExportToCanvasConfig = {
167
167
  height: number;
168
168
  scale?: number;
169
169
  };
170
- exportingFrame?: ExcalidrawFrameElement | null;
170
+ exportingFrame?: ExcalidrawFrameLikeElement | null;
171
171
  };
172
172
  /**
173
173
  * This API is usually used as a precursor to searializing to Blob or PNG,
@@ -187,6 +187,6 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
187
187
  frameRendering?: AppState["frameRendering"];
188
188
  }, files: BinaryFiles | null, opts?: {
189
189
  renderEmbeddables?: boolean;
190
- exportingFrame?: ExcalidrawFrameElement | null;
190
+ exportingFrame?: ExcalidrawFrameLikeElement | null;
191
191
  }) => Promise<SVGSVGElement>;
192
192
  export declare const getCanvasSize: (elements: readonly NonDeletedExcalidrawElement[]) => Bounds;
@@ -93,6 +93,7 @@ export type ElementShapes = {
93
93
  rectangle: Drawable;
94
94
  ellipse: Drawable;
95
95
  diamond: Drawable;
96
+ iframe: Drawable;
96
97
  embeddable: Drawable;
97
98
  freedraw: Drawable | null;
98
99
  arrow: Drawable[];
@@ -100,4 +101,5 @@ export type ElementShapes = {
100
101
  text: null;
101
102
  image: null;
102
103
  frame: null;
104
+ magicframe: null;
103
105
  };
package/types/shapes.d.ts CHANGED
@@ -59,4 +59,4 @@ export declare const SHAPES: readonly [{
59
59
  readonly numericKey: "0";
60
60
  readonly fillable: false;
61
61
  }];
62
- export declare const findShapeByKey: (key: string) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser" | null;
62
+ export declare const findShapeByKey: (key: string) => "text" | "image" | "line" | "arrow" | "selection" | "rectangle" | "diamond" | "ellipse" | "freedraw" | "eraser" | null;
package/types/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "./element/types";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType } from "./element/types";
3
+ import { Action } from "./actions/types";
3
4
  import { Point as RoughPoint } from "roughjs/bin/geometry";
4
5
  import { LinearElementEditor } from "./element/linearElementEditor";
5
6
  import { SuggestedBinding } from "./element/binding";
@@ -71,7 +72,8 @@ export type BinaryFileData = {
71
72
  };
72
73
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
73
74
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
74
- export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "laser";
75
+ export type ToolType = "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
76
+ export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
75
77
  export type ActiveTool = {
76
78
  type: ToolType;
77
79
  customType: null;
@@ -114,13 +116,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
114
116
  suggestedBindings: AppState["suggestedBindings"];
115
117
  isRotating: AppState["isRotating"];
116
118
  elementsToHighlight: AppState["elementsToHighlight"];
117
- openSidebar: AppState["openSidebar"];
118
- showHyperlinkPopup: AppState["showHyperlinkPopup"];
119
119
  collaborators: AppState["collaborators"];
120
120
  snapLines: AppState["snapLines"];
121
121
  zenModeEnabled: AppState["zenModeEnabled"];
122
122
  }>;
123
- export type AppState = {
123
+ export interface AppState {
124
124
  contextMenu: {
125
125
  items: ContextMenuItems;
126
126
  top: number;
@@ -140,7 +140,7 @@ export type AppState = {
140
140
  isBindingEnabled: boolean;
141
141
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
142
142
  suggestedBindings: SuggestedBinding[];
143
- frameToHighlight: NonDeleted<ExcalidrawFrameElement> | null;
143
+ frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
144
144
  frameRendering: {
145
145
  enabled: boolean;
146
146
  name: boolean;
@@ -193,7 +193,15 @@ export type AppState = {
193
193
  name: SidebarName;
194
194
  tab?: SidebarTabName;
195
195
  } | null;
196
- openDialog: "imageExport" | "help" | "jsonExport" | "mermaid" | null;
196
+ openDialog: null | {
197
+ name: "imageExport" | "help" | "jsonExport";
198
+ } | {
199
+ name: "magicSettings";
200
+ source: "tool" | "generation" | "settings";
201
+ } | {
202
+ name: "ttd";
203
+ tab: string;
204
+ };
197
205
  /**
198
206
  * Reflects user preference for whether the default sidebar should be docked.
199
207
  *
@@ -252,7 +260,7 @@ export type AppState = {
252
260
  y: number;
253
261
  } | null;
254
262
  objectsSnapModeEnabled: boolean;
255
- };
263
+ }
256
264
  export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
257
265
  export type NormalizedZoomValue = number & {
258
266
  _brand: "normalizedZoom";
@@ -343,6 +351,7 @@ export interface ExcalidrawProps {
343
351
  children?: React.ReactNode;
344
352
  validateEmbeddable?: boolean | string[] | RegExp | RegExp[] | ((link: string) => boolean | undefined);
345
353
  renderEmbeddable?: (element: NonDeleted<ExcalidrawEmbeddableElement>, appState: AppState) => JSX.Element | null;
354
+ aiEnabled?: boolean;
346
355
  interactive?: boolean;
347
356
  ui?: boolean;
348
357
  activeTool?: {
@@ -396,6 +405,7 @@ export type AppProps = Merge<ExcalidrawProps, {
396
405
  handleKeyboardGlobally: boolean;
397
406
  isCollaborating: boolean;
398
407
  children?: React.ReactNode;
408
+ aiEnabled: boolean;
399
409
  }>;
400
410
  /** A subset of App class properties that we need to use elsewhere
401
411
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
@@ -424,6 +434,8 @@ export type AppClassProperties = {
424
434
  togglePenMode: App["togglePenMode"];
425
435
  setActiveTool: App["setActiveTool"];
426
436
  setOpenDialog: App["setOpenDialog"];
437
+ insertEmbeddableElement: App["insertEmbeddableElement"];
438
+ onMagicframeToolSelect: App["onMagicframeToolSelect"];
427
439
  };
428
440
  export type PointerDownState = Readonly<{
429
441
  origin: Readonly<{
@@ -497,6 +509,7 @@ export type ExcalidrawImperativeAPI = {
497
509
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
498
510
  getAppState: () => InstanceType<typeof App>["state"];
499
511
  getFiles: () => InstanceType<typeof App>["files"];
512
+ registerAction: (action: Action) => void;
500
513
  refresh: InstanceType<typeof App>["refresh"];
501
514
  setToast: InstanceType<typeof App>["setToast"];
502
515
  addFiles: (data: BinaryFileData[]) => void;
@@ -535,10 +548,10 @@ type FrameNameBounds = {
535
548
  angle: number;
536
549
  };
537
550
  export type FrameNameBoundsCache = {
538
- get: (frameElement: ExcalidrawFrameElement) => FrameNameBounds | null;
551
+ get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
539
552
  _cache: Map<string, FrameNameBounds & {
540
553
  zoom: AppState["zoom"]["value"];
541
- versionNonce: ExcalidrawFrameElement["versionNonce"];
554
+ versionNonce: ExcalidrawFrameLikeElement["versionNonce"];
542
555
  }>;
543
556
  };
544
557
  export type KeyboardModifiersObject = {
@@ -548,4 +561,5 @@ export type KeyboardModifiersObject = {
548
561
  metaKey: boolean;
549
562
  };
550
563
  export type Primitive = number | string | boolean | bigint | symbol | null | undefined;
564
+ export type JSONValue = string | number | boolean | null | object;
551
565
  export {};
package/types/utils.d.ts CHANGED
@@ -201,3 +201,4 @@ export declare const isRenderThrottlingEnabled: () => boolean;
201
201
  /** Checks if value is inside given collection. Useful for type-safety. */
202
202
  export declare const isMemberOf: <T extends string>(collection: Set<T> | Record<T, any> | Map<T, any> | readonly T[], value: string) => value is T;
203
203
  export declare const cloneJSON: <T>(obj: T) => T;
204
+ export declare const isFiniteNumber: (value: any) => value is number;
@@ -1,3 +0,0 @@
1
- import "./MermaidToExcalidraw.scss";
2
- declare const MermaidToExcalidraw: () => JSX.Element;
3
- export default MermaidToExcalidraw;