@excalidraw/excalidraw 0.15.2-b7350f9 → 0.15.2-fc9a9a2

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 (99) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/excalidraw-assets/locales/{es-ES-json-f2467c6a875a9e288756.js → es-ES-json-4f3da97feff33cb00e6d.js} +1 -1
  3. package/dist/excalidraw-assets/locales/{hi-IN-json-e22f4ad73126c2971850.js → hi-IN-json-3898c9c1216b44476529.js} +1 -1
  4. package/dist/excalidraw-assets/locales/{id-ID-json-0e69caf5d919807ed234.js → id-ID-json-43d505d7071a0e359681.js} +1 -1
  5. package/dist/excalidraw-assets/locales/{kk-KZ-json-106d2a41c68f69765668.js → kk-KZ-json-f648362328b839e9313f.js} +1 -1
  6. package/dist/excalidraw-assets/locales/{pa-IN-json-0fd029451b07248c5194.js → pa-IN-json-d9ee09801ed220840b2b.js} +1 -1
  7. package/dist/excalidraw-assets/{vendor-53d1c69ef585b6dd219b.js → vendor-ef3c5d81a00ef582b871.js} +2 -2
  8. package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
  9. package/dist/excalidraw.development.js +2189 -2123
  10. package/dist/excalidraw.production.min.js +1 -1
  11. package/dist/excalidraw.production.min.js.LICENSE.txt +15 -0
  12. package/package.json +7 -2
  13. package/types/actions/actionAddToLibrary.d.ts +51 -25
  14. package/types/actions/actionAlign.d.ts +19 -20
  15. package/types/actions/actionBoundText.d.ts +38 -20
  16. package/types/actions/actionCanvas.d.ts +310 -88
  17. package/types/actions/actionClipboard.d.ts +81 -40
  18. package/types/actions/actionDeleteSelected.d.ts +45 -22
  19. package/types/actions/actionDistribute.d.ts +5 -6
  20. package/types/actions/actionDuplicateSelection.d.ts +0 -1
  21. package/types/actions/actionElementLock.d.ts +36 -19
  22. package/types/actions/actionExport.d.ts +161 -80
  23. package/types/actions/actionFinalize.d.ts +31 -17
  24. package/types/actions/actionFlip.d.ts +2 -3
  25. package/types/actions/actionFrame.d.ts +56 -30
  26. package/types/actions/actionGroup.d.ts +5 -6
  27. package/types/actions/actionLinearEditor.d.ts +19 -11
  28. package/types/actions/actionMenu.d.ts +51 -25
  29. package/types/actions/actionProperties.d.ts +221 -105
  30. package/types/actions/actionSelectAll.d.ts +0 -1
  31. package/types/actions/actionStyles.d.ts +17 -9
  32. package/types/actions/actionToggleGridMode.d.ts +17 -9
  33. package/types/actions/actionToggleStats.d.ts +17 -9
  34. package/types/actions/actionToggleViewMode.d.ts +17 -9
  35. package/types/actions/actionToggleZenMode.d.ts +17 -9
  36. package/types/actions/types.d.ts +4 -3
  37. package/types/appState.d.ts +7 -7
  38. package/types/colors.d.ts +9 -9
  39. package/types/components/App.d.ts +27 -1
  40. package/types/components/Button.d.ts +0 -1
  41. package/types/components/Card.d.ts +0 -1
  42. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
  43. package/types/components/DefaultSidebar.d.ts +0 -1
  44. package/types/components/EyeDropper.d.ts +0 -1
  45. package/types/components/HintViewer.d.ts +3 -4
  46. package/types/components/LayerUI.d.ts +2 -1
  47. package/types/components/LibraryMenuHeaderContent.d.ts +0 -1
  48. package/types/components/LibraryUnit.d.ts +0 -1
  49. package/types/components/LoadingMessage.d.ts +0 -1
  50. package/types/components/MobileMenu.d.ts +3 -2
  51. package/types/components/Section.d.ts +1 -1
  52. package/types/components/Sidebar/SidebarTab.d.ts +0 -1
  53. package/types/components/Sidebar/SidebarTabTrigger.d.ts +0 -1
  54. package/types/components/Sidebar/SidebarTabTriggers.d.ts +0 -1
  55. package/types/components/Sidebar/SidebarTabs.d.ts +0 -1
  56. package/types/components/Stack.d.ts +2 -2
  57. package/types/components/Trans.d.ts +2 -1
  58. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -1
  59. package/types/components/icons.d.ts +1 -0
  60. package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
  61. package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
  62. package/types/components/welcome-screen/WelcomeScreen.d.ts +0 -1
  63. package/types/constants.d.ts +13 -3
  64. package/types/data/url.d.ts +7 -0
  65. package/types/element/Hyperlink.d.ts +26 -14
  66. package/types/element/collision.d.ts +2 -2
  67. package/types/element/embeddable.d.ts +153 -0
  68. package/types/element/linearElementEditor.d.ts +18 -10
  69. package/types/element/newElement.d.ts +5 -2
  70. package/types/element/transformHandles.d.ts +1 -1
  71. package/types/element/typeChecks.d.ts +2 -1
  72. package/types/element/types.d.ts +13 -2
  73. package/types/frame.d.ts +2 -2
  74. package/types/groups.d.ts +3 -3
  75. package/types/history.d.ts +3 -3
  76. package/types/hooks/useOutsideClick.d.ts +0 -1
  77. package/types/hooks/useScrollPosition.d.ts +0 -1
  78. package/types/i18n.d.ts +5 -2
  79. package/types/keys.d.ts +2 -0
  80. package/types/packages/excalidraw/index.d.ts +1 -0
  81. package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
  82. package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
  83. package/types/packages/utils.d.ts +2 -1
  84. package/types/renderer/renderElement.d.ts +1 -1
  85. package/types/renderer/renderScene.d.ts +2 -1
  86. package/types/scene/Scene.d.ts +13 -0
  87. package/types/scene/export.d.ts +1 -0
  88. package/types/scene/selection.d.ts +11 -1
  89. package/types/types.d.ts +20 -9
  90. package/types/utility-types.d.ts +3 -1
  91. package/types/utils.d.ts +42 -15
  92. /package/dist/excalidraw-assets/{vendor-53d1c69ef585b6dd219b.js.LICENSE.txt → vendor-ef3c5d81a00ef582b871.js.LICENSE.txt} +0 -0
  93. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{es-ES-json-f2467c6a875a9e288756.d.ts → es-ES-json-4f3da97feff33cb00e6d.d.ts} +0 -0
  94. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{hi-IN-json-e22f4ad73126c2971850.d.ts → hi-IN-json-3898c9c1216b44476529.d.ts} +0 -0
  95. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{id-ID-json-0e69caf5d919807ed234.d.ts → id-ID-json-43d505d7071a0e359681.d.ts} +0 -0
  96. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{kk-KZ-json-106d2a41c68f69765668.d.ts → kk-KZ-json-f648362328b839e9313f.d.ts} +0 -0
  97. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{pa-IN-json-0fd029451b07248c5194.d.ts → pa-IN-json-d9ee09801ed220840b2b.d.ts} +0 -0
  98. /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-53d1c69ef585b6dd219b.d.ts → vendor-ef3c5d81a00ef582b871.d.ts} +0 -0
  99. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  export declare const Section: React.FC<{
3
- heading: string;
3
+ heading: "canvasActions" | "selectedShapeActions" | "shapes";
4
4
  children?: React.ReactNode | ((heading: React.ReactNode) => React.ReactNode);
5
5
  className?: string;
6
6
  }>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SidebarTabName } from "../../types";
3
2
  export declare const SidebarTab: {
4
3
  ({ tab, children, ...rest }: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { SidebarTabName } from "../../types";
3
2
  export declare const SidebarTabTrigger: {
4
3
  ({ children, tab, onSelect, ...rest }: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const SidebarTabTriggers: {
3
2
  ({ children, ...rest }: {
4
3
  children: React.ReactNode;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const SidebarTabs: {
3
2
  ({ children, ...rest }: {
4
3
  children: React.ReactNode;
@@ -10,7 +10,7 @@ type StackProps = {
10
10
  ref: React.RefObject<HTMLDivElement>;
11
11
  };
12
12
  declare const _default: {
13
- Row: React.ForwardRefExoticComponent<Pick<StackProps, "style" | "className" | "children" | "gap" | "justifyContent" | "align"> & React.RefAttributes<HTMLDivElement>>;
14
- Col: React.ForwardRefExoticComponent<Pick<StackProps, "style" | "className" | "children" | "gap" | "justifyContent" | "align"> & React.RefAttributes<HTMLDivElement>>;
13
+ Row: React.ForwardRefExoticComponent<Pick<StackProps, "style" | "className" | "children" | "align" | "gap" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
14
+ Col: React.ForwardRefExoticComponent<Pick<StackProps, "style" | "className" | "children" | "align" | "gap" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
15
15
  };
16
16
  export default _default;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
+ import { TranslationKeys } from "../i18n";
2
3
  declare const Trans: ({ i18nKey, children, ...props }: {
3
4
  [key: string]: React.ReactNode | ((el: React.ReactNode) => React.ReactNode);
4
- i18nKey: string;
5
+ i18nKey: TranslationKeys;
5
6
  }) => React.FunctionComponentElement<{
6
7
  children?: React.ReactNode;
7
8
  }>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const MenuTrigger: {
3
2
  ({ className, children, onToggle, title, ...rest }: {
4
3
  className?: string | undefined;
@@ -31,6 +31,7 @@ export declare const EraserIcon: JSX.Element;
31
31
  export declare const ZoomInIcon: JSX.Element;
32
32
  export declare const ZoomOutIcon: JSX.Element;
33
33
  export declare const TrashIcon: JSX.Element;
34
+ export declare const EmbedIcon: JSX.Element;
34
35
  export declare const DuplicateIcon: JSX.Element;
35
36
  export declare const MoonIcon: JSX.Element;
36
37
  export declare const SunIcon: JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import "./LiveCollaborationTrigger.scss";
3
2
  declare const LiveCollaborationTrigger: {
4
3
  ({ isCollaborating, onSelect, ...rest }: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const Center: {
3
2
  ({ children }: {
4
3
  children?: React.ReactNode;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import "./WelcomeScreen.scss";
3
2
  declare const WelcomeScreen: {
4
3
  (props: {
@@ -57,8 +57,17 @@ export declare enum EVENT {
57
57
  VISIBILITY_CHANGE = "visibilitychange",
58
58
  SCROLL = "scroll",
59
59
  EXCALIDRAW_LINK = "excalidraw-link",
60
- MENU_ITEM_SELECT = "menu.itemSelect"
60
+ MENU_ITEM_SELECT = "menu.itemSelect",
61
+ MESSAGE = "message"
61
62
  }
63
+ export declare const YOUTUBE_STATES: {
64
+ readonly UNSTARTED: -1;
65
+ readonly ENDED: 0;
66
+ readonly PLAYING: 1;
67
+ readonly PAUSED: 2;
68
+ readonly BUFFERING: 3;
69
+ readonly CUED: 5;
70
+ };
62
71
  export declare const ENV: {
63
72
  TEST: string;
64
73
  DEVELOPMENT: string;
@@ -72,8 +81,8 @@ export declare const FONT_FAMILY: {
72
81
  Cascadia: number;
73
82
  };
74
83
  export declare const THEME: {
75
- LIGHT: string;
76
- DARK: string;
84
+ readonly LIGHT: "light";
85
+ readonly DARK: "dark";
77
86
  };
78
87
  export declare const FRAME_STYLE: {
79
88
  strokeColor: string;
@@ -208,3 +217,4 @@ export declare const DEFAULT_SIDEBAR: {
208
217
  readonly name: "default";
209
218
  readonly defaultTab: "library";
210
219
  };
220
+ export declare const LIBRARY_DISABLED_TYPES: Set<"embeddable" | "image">;
@@ -0,0 +1,7 @@
1
+ export declare const normalizeLink: (link: string) => string;
2
+ export declare const isLocalLink: (link: string | null) => boolean;
3
+ /**
4
+ * Returns URL sanitized and safe for usage in places such as
5
+ * iframe's src attribute or <a> href attributes.
6
+ */
7
+ export declare const toValidURL: (link: string) => string;
@@ -1,16 +1,18 @@
1
- /// <reference types="react" />
2
1
  import { AppState, ExcalidrawProps, UIAppState } from "../types";
3
2
  import { NonDeletedExcalidrawElement } from "./types";
4
3
  import { Bounds } from "./bounds";
5
4
  import "./Hyperlink.scss";
6
5
  export declare const EXTERNAL_LINK_IMG: HTMLImageElement;
7
- export declare const Hyperlink: ({ element, setAppState, onLinkOpen, }: {
6
+ export declare const Hyperlink: ({ element, setAppState, onLinkOpen, setToast, }: {
8
7
  element: NonDeletedExcalidrawElement;
9
8
  setAppState: React.Component<any, AppState>["setState"];
10
9
  onLinkOpen: ExcalidrawProps["onLinkOpen"];
10
+ setToast: (toast: {
11
+ message: string;
12
+ closable?: boolean;
13
+ duration?: number;
14
+ } | null) => void;
11
15
  }) => JSX.Element | null;
12
- export declare const normalizeLink: (link: string) => string;
13
- export declare const isLocalLink: (link: string | null) => boolean;
14
16
  export declare const actionLink: {
15
17
  name: "hyperlink";
16
18
  perform: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => false | {
@@ -26,6 +28,10 @@ export declare const actionLink: {
26
28
  showWelcomeScreen: boolean;
27
29
  isLoading: boolean;
28
30
  errorMessage: import("react").ReactNode;
31
+ activeEmbeddable: {
32
+ element: NonDeletedExcalidrawElement;
33
+ state: "active" | "hover";
34
+ } | null;
29
35
  draggingElement: NonDeletedExcalidrawElement | null;
30
36
  resizingElement: NonDeletedExcalidrawElement | null;
31
37
  multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
@@ -34,7 +40,12 @@ export declare const actionLink: {
34
40
  startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
35
41
  suggestedBindings: import("./binding").SuggestedBinding[];
36
42
  frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
37
- shouldRenderFrames: boolean;
43
+ frameRendering: {
44
+ enabled: boolean;
45
+ name: boolean;
46
+ outline: boolean;
47
+ clip: boolean;
48
+ };
38
49
  editingFrame: string | null;
39
50
  elementsToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawElement>[] | null;
40
51
  editingElement: NonDeletedExcalidrawElement | null;
@@ -43,7 +54,7 @@ export declare const actionLink: {
43
54
  lastActiveTool: import("../types").LastActiveTool;
44
55
  locked: boolean;
45
56
  } & ({
46
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
57
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
47
58
  customType: null;
48
59
  } | {
49
60
  type: "custom";
@@ -87,11 +98,11 @@ export declare const actionLink: {
87
98
  openDialog: "imageExport" | "help" | "jsonExport" | null;
88
99
  defaultSidebarDockedPreference: boolean;
89
100
  lastPointerDownWith: import("./types").PointerType;
90
- selectedElementIds: {
91
- [id: string]: boolean;
92
- };
101
+ selectedElementIds: Readonly<{
102
+ [id: string]: true;
103
+ }>;
93
104
  previousSelectedElementIds: {
94
- [id: string]: boolean;
105
+ [id: string]: true;
95
106
  };
96
107
  selectedElementsAreBeingDragged: boolean;
97
108
  shouldCacheIgnoreZoom: boolean;
@@ -101,7 +112,7 @@ export declare const actionLink: {
101
112
  duration?: number | undefined;
102
113
  } | null;
103
114
  zenModeEnabled: boolean;
104
- theme: string;
115
+ theme: import("./types").Theme;
105
116
  gridSize: number | null;
106
117
  viewModeEnabled: boolean;
107
118
  selectedGroupIds: {
@@ -133,15 +144,16 @@ export declare const actionLink: {
133
144
  action: string;
134
145
  };
135
146
  keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
136
- contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.edit" | "labels.link.create";
147
+ contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
137
148
  predicate: (elements: readonly import("./types").ExcalidrawElement[], appState: AppState) => boolean;
138
149
  PanelComponent: ({ elements, appState, updateData }: import("../actions/types").PanelComponentProps) => JSX.Element;
139
150
  } & {
140
151
  keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
141
152
  };
142
- export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.edit" | "labels.link.create";
153
+ export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.editEmbed" | "labels.link.edit" | "labels.link.createEmbed" | "labels.link.create";
143
154
  export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: UIAppState) => [x: number, y: number, width: number, height: number];
144
- export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
155
+ export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number]) => boolean;
156
+ export declare const isPointHittingLink: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number], isMobile: boolean) => boolean;
145
157
  export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
146
158
  export declare const hideHyperlinkToolip: () => void;
147
159
  export declare const shouldHideLinkPopup: (element: NonDeletedExcalidrawElement, appState: AppState, [clientX, clientY]: readonly [number, number]) => Boolean;
@@ -1,5 +1,5 @@
1
1
  import * as GA from "../ga";
2
- import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameElement } from "./types";
2
+ import { NonDeletedExcalidrawElement, ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawRectangleElement, ExcalidrawEmbeddableElement, ExcalidrawDiamondElement, ExcalidrawTextElement, ExcalidrawEllipseElement, NonDeleted, ExcalidrawImageElement, ExcalidrawFrameElement } from "./types";
3
3
  import { FrameNameBoundsCache, Point } from "../types";
4
4
  import { AppState } from "../types";
5
5
  export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, frameNameBoundsCache: FrameNameBoundsCache, x: number, y: number) => boolean;
@@ -18,4 +18,4 @@ export declare const determineFocusPoint: (element: ExcalidrawBindableElement, f
18
18
  export declare const intersectElementWithLine: (element: ExcalidrawBindableElement, a: readonly [number, number], b: readonly [number, number], gap?: number) => Point[];
19
19
  export declare const getCircleIntersections: (center: readonly [number, number, number, number, number, number, number, number], radius: number, line: readonly [number, number, number, number, number, number, number, number]) => GA.Point[];
20
20
  export declare const findFocusPointForEllipse: (ellipse: ExcalidrawEllipseElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
21
- export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawFrameElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
21
+ export declare const findFocusPointForRectangulars: (element: ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawDiamondElement | ExcalidrawTextElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement, relativeDistance: number, point: readonly [number, number, number, number, number, number, number, number]) => readonly [number, number, number, number, number, number, number, number];
@@ -0,0 +1,153 @@
1
+ import { ExcalidrawProps } from "../types";
2
+ import { ExcalidrawElement, ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement, Theme } from "./types";
3
+ type EmbeddedLink = ({
4
+ aspectRatio: {
5
+ w: number;
6
+ h: number;
7
+ };
8
+ warning?: string;
9
+ } & ({
10
+ type: "video" | "generic";
11
+ link: string;
12
+ } | {
13
+ type: "document";
14
+ srcdoc: (theme: Theme) => string;
15
+ })) | null;
16
+ export declare const getEmbedLink: (link: string | null | undefined) => EmbeddedLink;
17
+ export declare const isEmbeddableOrFrameLabel: (element: NonDeletedExcalidrawElement) => Boolean;
18
+ export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawEmbeddableElement) => ExcalidrawElement;
19
+ export declare const actionSetEmbeddableAsActiveTool: {
20
+ name: "setEmbeddableAsActiveTool";
21
+ trackEvent: {
22
+ category: "toolbar";
23
+ };
24
+ perform: (elements: readonly ExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => {
25
+ elements: readonly ExcalidrawElement[];
26
+ appState: {
27
+ activeTool: {
28
+ lastActiveTool: import("../types").LastActiveTool;
29
+ locked: boolean;
30
+ } & ({
31
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
32
+ customType: null;
33
+ } | {
34
+ type: "custom";
35
+ customType: string;
36
+ });
37
+ contextMenu: {
38
+ items: import("../components/ContextMenu").ContextMenuItems;
39
+ top: number;
40
+ left: number;
41
+ } | null;
42
+ showWelcomeScreen: boolean;
43
+ isLoading: boolean;
44
+ errorMessage: import("react").ReactNode;
45
+ activeEmbeddable: {
46
+ element: NonDeletedExcalidrawElement;
47
+ state: "active" | "hover";
48
+ } | null;
49
+ draggingElement: NonDeletedExcalidrawElement | null;
50
+ resizingElement: NonDeletedExcalidrawElement | null;
51
+ multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
52
+ selectionElement: NonDeletedExcalidrawElement | null;
53
+ isBindingEnabled: boolean;
54
+ startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
55
+ suggestedBindings: import("./binding").SuggestedBinding[];
56
+ frameToHighlight: import("./types").NonDeleted<import("./types").ExcalidrawFrameElement> | null;
57
+ frameRendering: {
58
+ enabled: boolean;
59
+ name: boolean;
60
+ outline: boolean;
61
+ clip: boolean;
62
+ };
63
+ editingFrame: string | null;
64
+ elementsToHighlight: import("./types").NonDeleted<ExcalidrawElement>[] | null;
65
+ editingElement: NonDeletedExcalidrawElement | null;
66
+ editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
67
+ penMode: boolean;
68
+ penDetected: boolean;
69
+ exportBackground: boolean;
70
+ exportEmbedScene: boolean;
71
+ exportWithDarkMode: boolean;
72
+ exportScale: number;
73
+ currentItemStrokeColor: string;
74
+ currentItemBackgroundColor: string;
75
+ currentItemFillStyle: import("./types").FillStyle;
76
+ currentItemStrokeWidth: number;
77
+ currentItemStrokeStyle: import("./types").StrokeStyle;
78
+ currentItemRoughness: number;
79
+ currentItemOpacity: number;
80
+ currentItemFontFamily: number;
81
+ currentItemFontSize: number;
82
+ currentItemTextAlign: string;
83
+ currentItemStartArrowhead: import("./types").Arrowhead | null;
84
+ currentItemEndArrowhead: import("./types").Arrowhead | null;
85
+ currentItemRoundness: import("./types").StrokeRoundness;
86
+ viewBackgroundColor: string;
87
+ scrollX: number;
88
+ scrollY: number;
89
+ cursorButton: "up" | "down";
90
+ scrolledOutside: boolean;
91
+ name: string;
92
+ isResizing: boolean;
93
+ isRotating: boolean;
94
+ zoom: Readonly<{
95
+ value: import("../types").NormalizedZoomValue;
96
+ }>;
97
+ openMenu: "canvas" | "shape" | null;
98
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
99
+ openSidebar: {
100
+ name: string;
101
+ tab?: string | undefined;
102
+ } | null;
103
+ openDialog: "imageExport" | "help" | "jsonExport" | null;
104
+ defaultSidebarDockedPreference: boolean;
105
+ lastPointerDownWith: import("./types").PointerType;
106
+ selectedElementIds: Readonly<{
107
+ [id: string]: true;
108
+ }>;
109
+ previousSelectedElementIds: {
110
+ [id: string]: true;
111
+ };
112
+ selectedElementsAreBeingDragged: boolean;
113
+ shouldCacheIgnoreZoom: boolean;
114
+ toast: {
115
+ message: string;
116
+ closable?: boolean | undefined;
117
+ duration?: number | undefined;
118
+ } | null;
119
+ zenModeEnabled: boolean;
120
+ theme: Theme;
121
+ gridSize: number | null;
122
+ viewModeEnabled: boolean;
123
+ selectedGroupIds: {
124
+ [groupId: string]: boolean;
125
+ };
126
+ editingGroupId: string | null;
127
+ width: number;
128
+ height: number;
129
+ offsetTop: number;
130
+ offsetLeft: number;
131
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
132
+ collaborators: Map<string, import("../types").Collaborator>;
133
+ showStats: boolean;
134
+ currentChartType: import("./types").ChartType;
135
+ pasteDialog: {
136
+ shown: false;
137
+ data: null;
138
+ } | {
139
+ shown: true;
140
+ data: import("../charts").Spreadsheet;
141
+ };
142
+ pendingImageElementId: string | null;
143
+ showHyperlinkPopup: false | "editor" | "info";
144
+ selectedLinearElement: import("./linearElementEditor").LinearElementEditor | null;
145
+ };
146
+ commitToHistory: false;
147
+ };
148
+ } & {
149
+ keyTest?: undefined;
150
+ };
151
+ export declare const extractSrc: (htmlString: string) => string;
152
+ export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
153
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
3
2
  import { Point, AppState, PointerCoords } from "../types";
4
3
  import History from "../history";
@@ -131,6 +130,10 @@ export declare class LinearElementEditor {
131
130
  showWelcomeScreen: boolean;
132
131
  isLoading: boolean;
133
132
  errorMessage: import("react").ReactNode;
133
+ activeEmbeddable: {
134
+ element: import("./types").NonDeletedExcalidrawElement;
135
+ state: "active" | "hover";
136
+ } | null;
134
137
  draggingElement: import("./types").NonDeletedExcalidrawElement | null;
135
138
  resizingElement: import("./types").NonDeletedExcalidrawElement | null;
136
139
  multiElement: NonDeleted<ExcalidrawLinearElement> | null;
@@ -139,7 +142,12 @@ export declare class LinearElementEditor {
139
142
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
140
143
  suggestedBindings: import("./binding").SuggestedBinding[];
141
144
  frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameElement> | null;
142
- shouldRenderFrames: boolean;
145
+ frameRendering: {
146
+ enabled: boolean;
147
+ name: boolean;
148
+ outline: boolean;
149
+ clip: boolean;
150
+ };
143
151
  editingFrame: string | null;
144
152
  elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
145
153
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
@@ -147,7 +155,7 @@ export declare class LinearElementEditor {
147
155
  lastActiveTool: import("../types").LastActiveTool;
148
156
  locked: boolean;
149
157
  } & ({
150
- type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "frame" | "freedraw" | "eraser" | "hand";
158
+ type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "eraser" | "hand";
151
159
  customType: null;
152
160
  } | {
153
161
  type: "custom";
@@ -171,7 +179,7 @@ export declare class LinearElementEditor {
171
179
  currentItemTextAlign: string;
172
180
  currentItemStartArrowhead: import("./types").Arrowhead | null;
173
181
  currentItemEndArrowhead: import("./types").Arrowhead | null;
174
- currentItemRoundness: import("./types").StrokeRoundness;
182
+ currentItemRoundness: import("./types").StrokeRoundness; /** @returns whether point was dragged */
175
183
  viewBackgroundColor: string;
176
184
  scrollX: number;
177
185
  scrollY: number;
@@ -192,11 +200,11 @@ export declare class LinearElementEditor {
192
200
  openDialog: "imageExport" | "help" | "jsonExport" | null;
193
201
  defaultSidebarDockedPreference: boolean;
194
202
  lastPointerDownWith: import("./types").PointerType;
195
- selectedElementIds: {
196
- [id: string]: boolean;
197
- };
203
+ selectedElementIds: Readonly<{
204
+ [id: string]: true;
205
+ }>;
198
206
  previousSelectedElementIds: {
199
- [id: string]: boolean;
207
+ [id: string]: true;
200
208
  };
201
209
  selectedElementsAreBeingDragged: boolean;
202
210
  shouldCacheIgnoreZoom: boolean;
@@ -206,7 +214,7 @@ export declare class LinearElementEditor {
206
214
  duration?: number | undefined;
207
215
  } | null;
208
216
  zenModeEnabled: boolean;
209
- theme: string;
217
+ theme: import("./types").Theme;
210
218
  gridSize: number | null;
211
219
  viewModeEnabled: boolean;
212
220
  selectedGroupIds: {
@@ -229,7 +237,7 @@ export declare class LinearElementEditor {
229
237
  data: import("../charts").Spreadsheet;
230
238
  };
231
239
  pendingImageElementId: string | null;
232
- showHyperlinkPopup: false | "info" | "editor";
240
+ showHyperlinkPopup: false | "editor" | "info";
233
241
  selectedLinearElement: LinearElementEditor | null;
234
242
  };
235
243
  };
@@ -1,10 +1,14 @@
1
- import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement } from "../element/types";
1
+ import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
3
  import { MarkOptional, Mutable } from "../utility-types";
4
4
  type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity">;
5
5
  export declare const newElement: (opts: {
6
6
  type: ExcalidrawGenericElement["type"];
7
7
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
8
+ export declare const newEmbeddableElement: (opts: {
9
+ type: "embeddable";
10
+ validated: boolean | undefined;
11
+ } & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
8
12
  export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
9
13
  export declare const newTextElement: (opts: {
10
14
  text: string;
@@ -15,7 +19,6 @@ export declare const newTextElement: (opts: {
15
19
  containerId?: ExcalidrawTextContainer["id"];
16
20
  lineHeight?: ExcalidrawTextElement["lineHeight"];
17
21
  strokeWidth?: ExcalidrawTextElement["strokeWidth"];
18
- isFrameName?: boolean;
19
22
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
20
23
  export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, text?: string) => {
21
24
  x: number;
@@ -23,8 +23,8 @@ export declare const OMIT_SIDES_FOR_FRAME: {
23
23
  export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
24
24
  s?: boolean | undefined;
25
25
  e?: boolean | undefined;
26
- n?: boolean | undefined;
27
26
  w?: boolean | undefined;
27
+ n?: boolean | undefined;
28
28
  nw?: boolean | undefined;
29
29
  ne?: boolean | undefined;
30
30
  sw?: boolean | undefined;
@@ -1,9 +1,10 @@
1
1
  import { AppState } from "../types";
2
2
  import { MarkNonNullable } from "../utility-types";
3
- import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType } from "./types";
3
+ import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawGenericElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType } from "./types";
4
4
  export declare const isGenericElement: (element: ExcalidrawElement | null) => element is ExcalidrawGenericElement;
5
5
  export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
6
6
  export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
7
+ export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
7
8
  export declare const isTextElement: (element: ExcalidrawElement | null) => element is ExcalidrawTextElement;
8
9
  export declare const isFrameElement: (element: ExcalidrawElement | null) => element is ExcalidrawFrameElement;
9
10
  export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) => element is ExcalidrawFreeDrawElement;
@@ -73,6 +73,17 @@ export type ExcalidrawDiamondElement = _ExcalidrawElementBase & {
73
73
  export type ExcalidrawEllipseElement = _ExcalidrawElementBase & {
74
74
  type: "ellipse";
75
75
  };
76
+ export type ExcalidrawEmbeddableElement = _ExcalidrawElementBase & Readonly<{
77
+ /**
78
+ * indicates whether the embeddable src (url) has been validated for rendering.
79
+ * nullish value indicates that the validation is pending. We reset the
80
+ * value on each restore (or url change) so that we can guarantee
81
+ * the validation came from a trusted source (the editor). Also because we
82
+ * may not have access to host-app supplied url validator during restore.
83
+ */
84
+ validated?: boolean;
85
+ type: "embeddable";
86
+ }>;
76
87
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
77
88
  type: "image";
78
89
  fileId: FileId | null;
@@ -89,7 +100,7 @@ export type ExcalidrawFrameElement = _ExcalidrawElementBase & {
89
100
  /**
90
101
  * These are elements that don't have any additional properties.
91
102
  */
92
- export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
103
+ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawEmbeddableElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
93
104
  /**
94
105
  * ExcalidrawElement should be JSON serializable and (eventually) contain
95
106
  * no computed data. The list of all ExcalidrawElements should be shareable
@@ -118,7 +129,7 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
118
129
  _brand: "unitlessLineHeight";
119
130
  };
120
131
  }>;
121
- export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawFrameElement;
132
+ export type ExcalidrawBindableElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawTextElement | ExcalidrawImageElement | ExcalidrawEmbeddableElement | ExcalidrawFrameElement;
122
133
  export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement | ExcalidrawArrowElement;
123
134
  export type ExcalidrawTextElementWithContainer = {
124
135
  containerId: ExcalidrawTextContainer["id"];
package/types/frame.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, ExcalidrawFrameElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppState } from "./types";
2
+ import { AppClassProperties, AppState } 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
5
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
@@ -26,7 +26,7 @@ export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIn
26
26
  export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
27
27
  export declare const replaceAllElementsInFrame: (allElements: ExcalidrawElementsIncludingDeleted, nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
28
28
  /** does not mutate elements, but return new ones */
29
- export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => ExcalidrawElementsIncludingDeleted;
29
+ export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState, app: AppClassProperties) => ExcalidrawElementsIncludingDeleted;
30
30
  /**
31
31
  * filters out elements that are inside groups that contain a frame element
32
32
  * anywhere in the group tree
package/types/groups.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types";
2
- import { AppState } from "./types";
1
+ import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { AppClassProperties, AppState } from "./types";
3
3
  export declare const selectGroup: (groupId: GroupId, appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
4
4
  /**
5
5
  * If the element's group is selected, don't render an individual
@@ -12,7 +12,7 @@ export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
12
12
  * When you select an element, you often want to actually select the whole group it's in, unless
13
13
  * you're currently editing that group.
14
14
  */
15
- export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
15
+ export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeletedExcalidrawElement[], prevAppState: AppState, app: AppClassProperties | null) => AppState;
16
16
  export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
17
17
  [groupId: string]: boolean;
18
18
  };
@@ -5,9 +5,9 @@ export interface HistoryEntry {
5
5
  elements: ExcalidrawElement[];
6
6
  }
7
7
  declare const clearAppStatePropertiesForHistory: (appState: AppState) => {
8
- selectedElementIds: {
9
- [id: string]: boolean;
10
- };
8
+ selectedElementIds: Readonly<{
9
+ [id: string]: true;
10
+ }>;
11
11
  selectedGroupIds: {
12
12
  [groupId: string]: boolean;
13
13
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare function useOutsideClick<T extends HTMLElement>(ref: React.RefObject<T>,
3
2
  /** if performance is of concern, memoize the callback */
4
3
  callback: (event: Event) => void,
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const useScrollPosition: <T extends HTMLElement>(elementRef: import("react").RefObject<T>) => number;