@excalidraw/excalidraw 0.15.2-3ddcc48 → 0.15.2-5302490

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 (117) hide show
  1. package/CHANGELOG.md +19 -0
  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 +2237 -2116
  10. package/dist/excalidraw.production.min.js +1 -1
  11. package/package.json +7 -2
  12. package/types/actions/actionAddToLibrary.d.ts +51 -25
  13. package/types/actions/actionAlign.d.ts +19 -20
  14. package/types/actions/actionBoundText.d.ts +38 -20
  15. package/types/actions/actionCanvas.d.ts +182 -90
  16. package/types/actions/actionClipboard.d.ts +81 -40
  17. package/types/actions/actionDeleteSelected.d.ts +45 -22
  18. package/types/actions/actionDistribute.d.ts +5 -6
  19. package/types/actions/actionDuplicateSelection.d.ts +0 -1
  20. package/types/actions/actionElementLock.d.ts +36 -19
  21. package/types/actions/actionExport.d.ts +161 -80
  22. package/types/actions/actionFinalize.d.ts +32 -18
  23. package/types/actions/actionFlip.d.ts +2 -3
  24. package/types/actions/actionFrame.d.ts +56 -30
  25. package/types/actions/actionGroup.d.ts +246 -9
  26. package/types/actions/actionLinearEditor.d.ts +19 -11
  27. package/types/actions/actionMenu.d.ts +51 -25
  28. package/types/actions/actionProperties.d.ts +223 -105
  29. package/types/actions/actionSelectAll.d.ts +121 -2
  30. package/types/actions/actionStyles.d.ts +17 -9
  31. package/types/actions/actionToggleGridMode.d.ts +17 -9
  32. package/types/actions/actionToggleStats.d.ts +17 -9
  33. package/types/actions/actionToggleViewMode.d.ts +17 -9
  34. package/types/actions/actionToggleZenMode.d.ts +17 -9
  35. package/types/actions/types.d.ts +4 -3
  36. package/types/appState.d.ts +7 -7
  37. package/types/clipboard.d.ts +1 -0
  38. package/types/colors.d.ts +9 -9
  39. package/types/components/Actions.d.ts +2 -2
  40. package/types/components/App.d.ts +24 -7
  41. package/types/components/Button.d.ts +0 -1
  42. package/types/components/Card.d.ts +0 -1
  43. package/types/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
  44. package/types/components/DefaultSidebar.d.ts +0 -1
  45. package/types/components/ExcalidrawLogo.d.ts +15 -0
  46. package/types/components/EyeDropper.d.ts +0 -1
  47. package/types/components/HintViewer.d.ts +3 -4
  48. package/types/components/JSONExportDialog.d.ts +1 -1
  49. package/types/components/LayerUI.d.ts +4 -2
  50. package/types/components/LibraryMenuHeaderContent.d.ts +0 -1
  51. package/types/components/LibraryUnit.d.ts +0 -1
  52. package/types/components/LoadingMessage.d.ts +0 -1
  53. package/types/components/MobileMenu.d.ts +4 -3
  54. package/types/components/Section.d.ts +1 -1
  55. package/types/components/Sidebar/SidebarTab.d.ts +0 -1
  56. package/types/components/Sidebar/SidebarTabTrigger.d.ts +0 -1
  57. package/types/components/Sidebar/SidebarTabTriggers.d.ts +0 -1
  58. package/types/components/Sidebar/SidebarTabs.d.ts +0 -1
  59. package/types/components/Stack.d.ts +2 -2
  60. package/types/components/Trans.d.ts +2 -1
  61. package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
  62. package/types/components/canvases/StaticCanvas.d.ts +18 -0
  63. package/types/components/canvases/index.d.ts +3 -0
  64. package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -1
  65. package/types/components/icons.d.ts +1 -0
  66. package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
  67. package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
  68. package/types/components/welcome-screen/WelcomeScreen.d.ts +0 -1
  69. package/types/constants.d.ts +17 -3
  70. package/types/data/transform.d.ts +71 -0
  71. package/types/data/url.d.ts +5 -0
  72. package/types/element/Hyperlink.d.ts +27 -13
  73. package/types/element/binding.d.ts +1 -0
  74. package/types/element/collision.d.ts +2 -2
  75. package/types/element/embeddable.d.ts +153 -0
  76. package/types/element/linearElementEditor.d.ts +20 -12
  77. package/types/element/newElement.d.ts +14 -7
  78. package/types/element/sizeHelpers.d.ts +8 -1
  79. package/types/element/textElement.d.ts +5 -7
  80. package/types/element/textWysiwyg.d.ts +1 -1
  81. package/types/element/transformHandles.d.ts +3 -3
  82. package/types/element/typeChecks.d.ts +2 -1
  83. package/types/element/types.d.ts +13 -2
  84. package/types/frame.d.ts +5 -5
  85. package/types/groups.d.ts +12 -12
  86. package/types/history.d.ts +3 -3
  87. package/types/hooks/useOutsideClick.d.ts +0 -1
  88. package/types/hooks/useScrollPosition.d.ts +0 -1
  89. package/types/i18n.d.ts +5 -2
  90. package/types/keys.d.ts +1 -0
  91. package/types/packages/excalidraw/example/initialData.d.ts +182 -70
  92. package/types/packages/excalidraw/index.d.ts +1 -0
  93. package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
  94. package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
  95. package/types/packages/utils.d.ts +2 -1
  96. package/types/renderer/renderElement.d.ts +10 -22
  97. package/types/renderer/renderScene.d.ts +18 -37
  98. package/types/scene/Renderer.d.ts +25 -0
  99. package/types/scene/Scene.d.ts +15 -0
  100. package/types/scene/Shape.d.ts +12 -0
  101. package/types/scene/ShapeCache.d.ts +20 -0
  102. package/types/scene/export.d.ts +1 -0
  103. package/types/scene/scroll.d.ts +1 -1
  104. package/types/scene/scrollbars.d.ts +2 -6
  105. package/types/scene/selection.d.ts +13 -3
  106. package/types/scene/types.d.ts +57 -24
  107. package/types/types.d.ts +63 -12
  108. package/types/utility-types.d.ts +3 -1
  109. package/types/utils.d.ts +13 -5
  110. /package/dist/excalidraw-assets/{vendor-53d1c69ef585b6dd219b.js.LICENSE.txt → vendor-ef3c5d81a00ef582b871.js.LICENSE.txt} +0 -0
  111. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{es-ES-json-f2467c6a875a9e288756.d.ts → es-ES-json-4f3da97feff33cb00e6d.d.ts} +0 -0
  112. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{hi-IN-json-e22f4ad73126c2971850.d.ts → hi-IN-json-3898c9c1216b44476529.d.ts} +0 -0
  113. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{id-ID-json-0e69caf5d919807ed234.d.ts → id-ID-json-43d505d7071a0e359681.d.ts} +0 -0
  114. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{kk-KZ-json-106d2a41c68f69765668.d.ts → kk-KZ-json-f648362328b839e9313f.d.ts} +0 -0
  115. /package/types/packages/excalidraw/dist/excalidraw-assets/locales/{pa-IN-json-0fd029451b07248c5194.d.ts → pa-IN-json-d9ee09801ed220840b2b.d.ts} +0 -0
  116. /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-53d1c69ef585b6dd219b.d.ts → vendor-ef3c5d81a00ef582b871.d.ts} +0 -0
  117. /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
@@ -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,6 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer } from "./types";
3
- import { Point, AppState, PointerCoords } from "../types";
2
+ import { Point, AppState, PointerCoords, InteractiveCanvasAppState } from "../types";
4
3
  import History from "../history";
5
4
  import Scene from "../scene/Scene";
6
5
  declare const editorMidPointsCache: {
@@ -53,8 +52,8 @@ export declare class LinearElementEditor {
53
52
  y: number;
54
53
  }[]) => void, linearElementEditor: LinearElementEditor): boolean;
55
54
  static handlePointerUp(event: PointerEvent, editingLinearElement: LinearElementEditor, appState: AppState): LinearElementEditor;
56
- static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => (typeof editorMidPointsCache)["points"];
57
- static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: AppState) => void;
55
+ static getEditorMidPoints: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => (typeof editorMidPointsCache)["points"];
56
+ static updateEditorMidPointsCache: (element: NonDeleted<ExcalidrawLinearElement>, appState: InteractiveCanvasAppState) => void;
58
57
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
59
58
  x: number;
60
59
  y: number;
@@ -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";
@@ -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
- 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">;
4
+ export 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: ExcalidrawEmbeddableElement["validated"];
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;
@@ -12,10 +16,9 @@ export declare const newTextElement: (opts: {
12
16
  fontFamily?: FontFamilyValues;
13
17
  textAlign?: TextAlign;
14
18
  verticalAlign?: VerticalAlign;
15
- containerId?: ExcalidrawTextContainer["id"];
19
+ containerId?: ExcalidrawTextContainer["id"] | null;
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;
@@ -37,8 +40,8 @@ export declare const newFreeDrawElement: (opts: {
37
40
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawFreeDrawElement>;
38
41
  export declare const newLinearElement: (opts: {
39
42
  type: ExcalidrawLinearElement["type"];
40
- startArrowhead: Arrowhead | null;
41
- endArrowhead: Arrowhead | null;
43
+ startArrowhead?: Arrowhead | null;
44
+ endArrowhead?: Arrowhead | null;
42
45
  points?: ExcalidrawLinearElement["points"];
43
46
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawLinearElement>;
44
47
  export declare const newImageElement: (opts: {
@@ -57,6 +60,11 @@ export declare const newImageElement: (opts: {
57
60
  * Typed arrays and other non-null objects.
58
61
  */
59
62
  export declare const deepCopyElement: <T extends ExcalidrawElement>(val: T) => Mutable<T>;
63
+ /**
64
+ * utility wrapper to generate new id. In test env it reuses the old + postfix
65
+ * for test assertions.
66
+ */
67
+ export declare const regenerateId: (previousId: string | null) => string;
60
68
  /**
61
69
  * Duplicate an element, often used in the alt-drag operation.
62
70
  * Note that this method has gotten a bit complicated since the
@@ -86,4 +94,3 @@ export declare const duplicateElements: (elements: readonly ExcalidrawElement[],
86
94
  /** NOTE also updates version flags and `updated` */
87
95
  randomizeSeed: boolean;
88
96
  }) => ExcalidrawElement[];
89
- export {};
@@ -1,6 +1,13 @@
1
1
  import { ExcalidrawElement } from "./types";
2
- import { AppState } from "../types";
2
+ import { AppState, Zoom } from "../types";
3
3
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
4
+ export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
5
+ zoom: Zoom;
6
+ offsetLeft: number;
7
+ offsetTop: number;
8
+ scrollX: number;
9
+ scrollY: number;
10
+ }) => boolean;
4
11
  /**
5
12
  * Makes a perfect shape or diagonal/horizontal/vertical line
6
13
  */
@@ -6,7 +6,7 @@ export declare const normalizeText: (text: string) => string;
6
6
  export declare const splitIntoLines: (text: string) => string[];
7
7
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null) => void;
8
8
  export declare const bindTextToShapeAfterDuplication: (sceneElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
9
- export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType) => void;
9
+ export declare const handleBindTextResize: (container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean) => void;
10
10
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => {
11
11
  x: number;
12
12
  y: number;
@@ -47,10 +47,6 @@ export declare const getBoundTextElement: (element: ExcalidrawElement | null) =>
47
47
  export declare const getContainerElement: (element: (ExcalidrawElement & {
48
48
  containerId: ExcalidrawElement["id"] | null;
49
49
  }) | null) => ExcalidrawElement | null;
50
- export declare const getContainerDims: (element: ExcalidrawElement) => {
51
- width: number;
52
- height: number;
53
- };
54
50
  export declare const getContainerCenter: (container: ExcalidrawElement, appState: AppState) => {
55
51
  x: number;
56
52
  y: number;
@@ -69,9 +65,11 @@ export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedExca
69
65
  export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedExcalidrawElement[]) => boolean;
70
66
  export declare const getTextBindableContainerAtPosition: (elements: readonly ExcalidrawElement[], appState: AppState, x: number, y: number) => ExcalidrawTextContainer | null;
71
67
  declare const VALID_CONTAINER_TYPES: Set<string>;
72
- export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
68
+ export declare const isValidTextContainer: (element: {
69
+ type: ExcalidrawElement["type"];
70
+ }) => boolean;
73
71
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
74
- export declare const getBoundTextMaxWidth: (container: ExcalidrawElement) => number;
72
+ export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement?: ExcalidrawTextElement | null) => number;
75
73
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
76
74
  export declare const isMeasureTextSupported: () => boolean;
77
75
  export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
@@ -15,7 +15,7 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
15
15
  }) => void;
16
16
  getViewportCoords: (x: number, y: number) => [number, number];
17
17
  element: ExcalidrawTextElement;
18
- canvas: HTMLCanvasElement | null;
18
+ canvas: HTMLCanvasElement;
19
19
  excalidrawContainer: HTMLDivElement | null;
20
20
  app: App;
21
21
  }) => void;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
2
- import { AppState, Zoom } from "../types";
2
+ import { InteractiveCanvasAppState, Zoom } from "../types";
3
3
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
4
4
  export type TransformHandleType = TransformHandleDirection | "rotation";
5
5
  export type TransformHandle = [number, number, number, 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;
@@ -32,4 +32,4 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
32
32
  rotation?: boolean | undefined;
33
33
  }, margin?: number) => TransformHandles;
34
34
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, pointerType?: PointerType) => TransformHandles;
35
- export declare const shouldShowBoundingBox: (elements: NonDeletedExcalidrawElement[], appState: AppState) => boolean;
35
+ export declare const shouldShowBoundingBox: (elements: readonly NonDeletedExcalidrawElement[], appState: InteractiveCanvasAppState) => boolean;
@@ -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
+ type: "embeddable";
78
+ /**
79
+ * indicates whether the embeddable src (url) has been validated for rendering.
80
+ * null value indicates that the validation is pending. We reset the
81
+ * value on each restore (or url change) so that we can guarantee
82
+ * the validation came from a trusted source (the editor). Also because we
83
+ * may not have access to host-app supplied url validator during restore.
84
+ */
85
+ validated: boolean | null;
86
+ }>;
76
87
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
77
88
  type: "image";
78
89
  fileId: FileId | null;
@@ -95,7 +106,7 @@ export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRe
95
106
  * no computed data. The list of all ExcalidrawElements should be shareable
96
107
  * between peers and contain no state local to the peer.
97
108
  */
98
- export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement;
109
+ export type ExcalidrawElement = ExcalidrawGenericElement | ExcalidrawTextElement | ExcalidrawLinearElement | ExcalidrawFreeDrawElement | ExcalidrawImageElement | ExcalidrawFrameElement | ExcalidrawEmbeddableElement;
99
110
  export type NonDeleted<TElement extends ExcalidrawElement> = TElement & {
100
111
  isDeleted: boolean;
101
112
  };
@@ -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, 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
5
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
@@ -25,8 +25,8 @@ export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludi
25
25
  export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
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
- /** does not mutate elements, but return new ones */
29
- export declare const updateFrameMembershipOfSelectedElements: (allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => ExcalidrawElementsIncludingDeleted;
28
+ /** does not mutate elements, but returns new ones */
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
@@ -36,5 +36,5 @@ export declare const omitGroupsContainingFrames: (allElements: ExcalidrawElement
36
36
  * depending on the appState, return target frame, which is the frame the given element
37
37
  * is going to be added to or remove from
38
38
  */
39
- export declare const getTargetFrame: (element: ExcalidrawElement, appState: AppState) => ExcalidrawFrameElement | null;
40
- export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: AppState) => boolean;
39
+ export declare const getTargetFrame: (element: ExcalidrawElement, appState: StaticCanvasAppState) => ExcalidrawFrameElement | null;
40
+ export declare const isElementInFrame: (element: ExcalidrawElement, allElements: ExcalidrawElementsIncludingDeleted, appState: StaticCanvasAppState) => boolean;
package/types/groups.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types";
2
- import { AppState } from "./types";
3
- export declare const selectGroup: (groupId: GroupId, appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
1
+ import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
2
+ import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
3
+ import { Mutable } from "./utility-types";
4
+ export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
5
+ export declare const selectGroupsForSelectedElements: {
6
+ (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
7
+ clearCache(): void;
8
+ };
4
9
  /**
5
10
  * If the element's group is selected, don't render an individual
6
11
  * selection border around it.
7
12
  */
8
- export declare const isSelectedViaGroup: (appState: AppState, element: ExcalidrawElement) => boolean;
9
- export declare const getSelectedGroupForElement: (appState: AppState, element: ExcalidrawElement) => string | undefined;
10
- export declare const getSelectedGroupIds: (appState: AppState) => GroupId[];
11
- /**
12
- * When you select an element, you often want to actually select the whole group it's in, unless
13
- * you're currently editing that group.
14
- */
15
- export declare const selectGroupsForSelectedElements: (appState: AppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => AppState;
16
- export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: AppState) => {
13
+ export declare const isSelectedViaGroup: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => boolean;
14
+ export declare const getSelectedGroupForElement: (appState: InteractiveCanvasAppState, element: ExcalidrawElement) => string | undefined;
15
+ export declare const getSelectedGroupIds: (appState: InteractiveCanvasAppState) => GroupId[];
16
+ export declare const selectGroupsFromGivenElements: (elements: readonly NonDeleted<ExcalidrawElement>[], appState: InteractiveCanvasAppState) => {
17
17
  [groupId: string]: boolean;
18
18
  };
19
19
  export declare const editGroupForSelectedElement: (appState: AppState, element: NonDeleted<ExcalidrawElement>) => AppState;
@@ -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;
package/types/i18n.d.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import fallbackLangData from "./locales/en.json";
2
+ import { NestedKeyOf } from "./utility-types";
1
3
  export interface Language {
2
4
  code: string;
3
5
  label: string;
4
6
  rtl?: boolean;
5
7
  }
8
+ export type TranslationKeys = NestedKeyOf<typeof fallbackLangData>;
6
9
  export declare const defaultLang: {
7
10
  code: string;
8
11
  label: string;
@@ -10,11 +13,11 @@ export declare const defaultLang: {
10
13
  export declare const languages: Language[];
11
14
  export declare const setLanguage: (lang: Language) => Promise<void>;
12
15
  export declare const getLanguage: () => Language;
13
- export declare const t: (path: string, replacement?: {
16
+ export declare const t: (path: NestedKeyOf<typeof fallbackLangData>, replacement?: {
14
17
  [key: string]: string | number;
15
18
  } | null | undefined, fallback?: string) => string;
16
19
  export declare const useI18n: () => {
17
- t: (path: string, replacement?: {
20
+ t: (path: NestedKeyOf<typeof fallbackLangData>, replacement?: {
18
21
  [key: string]: string | number;
19
22
  } | null | undefined, fallback?: string) => string;
20
23
  langCode: string;
package/types/keys.d.ts CHANGED
@@ -61,6 +61,7 @@ export declare const KEYS: {
61
61
  readonly Y: "y";
62
62
  readonly Z: "z";
63
63
  readonly K: "k";
64
+ readonly W: "w";
64
65
  readonly 0: "0";
65
66
  readonly 1: "1";
66
67
  readonly 2: "2";