@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,10 +1,42 @@
1
- declare namespace _default {
2
- const elements: ({
1
+ import { ExcalidrawElementSkeleton } from "../../../data/transform";
2
+ declare const _default: {
3
+ elements: ExcalidrawElementSkeleton[];
4
+ appState: {
5
+ viewBackgroundColor: string;
6
+ currentItemFontFamily: number;
7
+ };
8
+ scrollToContent: boolean;
9
+ libraryItems: ({
10
+ type: string;
11
+ x: number;
12
+ y: number;
13
+ strokeColor: string;
14
+ backgroundColor: string;
15
+ width: number;
16
+ height: number;
17
+ strokeSharpness: string;
18
+ points: number[][];
19
+ }[] | ({
20
+ type: string;
21
+ fillStyle: string;
22
+ strokeWidth: number;
23
+ strokeStyle: string;
24
+ x: number;
25
+ y: number;
26
+ strokeColor: string;
27
+ backgroundColor: string;
28
+ width: number;
29
+ height: number;
30
+ groupIds: string[];
31
+ points: number[][];
32
+ roughness?: undefined;
33
+ opacity?: undefined;
34
+ angle?: undefined;
35
+ seed?: undefined;
36
+ strokeSharpness?: undefined;
37
+ boundElementIds?: undefined;
38
+ } | {
3
39
  type: string;
4
- version: number;
5
- versionNonce: number;
6
- isDeleted: boolean;
7
- id: string;
8
40
  fillStyle: string;
9
41
  strokeWidth: number;
10
42
  strokeStyle: string;
@@ -18,50 +50,72 @@ declare namespace _default {
18
50
  width: number;
19
51
  height: number;
20
52
  seed: number;
21
- groupIds: never[];
22
- frameId: null;
23
- fileId?: undefined;
24
- strokeSharpness?: undefined;
25
- boundElements?: undefined;
26
- updated?: undefined;
27
- link?: undefined;
28
- status?: undefined;
29
- scale?: undefined;
53
+ groupIds: string[];
54
+ strokeSharpness: string;
55
+ points: number[][];
56
+ boundElementIds?: undefined;
30
57
  } | {
31
- fileId: string;
32
58
  type: string;
59
+ fillStyle: string;
60
+ strokeWidth: number;
61
+ strokeStyle: string;
62
+ roughness: number;
63
+ opacity: number;
64
+ angle: number;
33
65
  x: number;
34
66
  y: number;
67
+ strokeColor: string;
68
+ backgroundColor: string;
35
69
  width: number;
36
70
  height: number;
71
+ seed: number;
72
+ groupIds: string[];
73
+ strokeSharpness: string;
74
+ boundElementIds: string[];
75
+ points?: undefined;
76
+ } | {
77
+ type: string;
78
+ fillStyle: string;
79
+ strokeWidth: number;
80
+ strokeStyle: string;
81
+ roughness: number;
82
+ opacity: number;
37
83
  angle: number;
84
+ x: number;
85
+ y: number;
38
86
  strokeColor: string;
39
87
  backgroundColor: string;
88
+ width: number;
89
+ height: number;
90
+ seed: number;
91
+ groupIds: string[];
92
+ strokeSharpness: string;
93
+ points?: undefined;
94
+ boundElementIds?: undefined;
95
+ })[] | ({
96
+ type: string;
40
97
  fillStyle: string;
41
98
  strokeWidth: number;
42
99
  strokeStyle: string;
43
100
  roughness: number;
44
101
  opacity: number;
45
- groupIds: never[];
46
- frameId: null;
47
- strokeSharpness: string;
102
+ angle: number;
103
+ x: number;
104
+ y: number;
105
+ strokeColor: string;
106
+ backgroundColor: string;
107
+ width: number;
108
+ height: number;
48
109
  seed: number;
49
- version: number;
50
- versionNonce: number;
51
- isDeleted: boolean;
52
- boundElements: null;
53
- updated: number;
54
- link: null;
55
- status: string;
56
- scale: number[];
110
+ groupIds: string[];
111
+ strokeSharpness: string;
112
+ points: number[][];
113
+ version?: undefined;
114
+ versionNonce?: undefined;
115
+ isDeleted?: undefined;
57
116
  id?: undefined;
58
- })[];
59
- namespace appState {
60
- const viewBackgroundColor: string;
61
- const currentItemFontFamily: number;
62
- }
63
- const scrollToContent: boolean;
64
- const libraryItems: (({
117
+ boundElementIds?: undefined;
118
+ } | {
65
119
  type: string;
66
120
  version: number;
67
121
  versionNonce: number;
@@ -81,21 +135,11 @@ declare namespace _default {
81
135
  height: number;
82
136
  seed: number;
83
137
  groupIds: string[];
84
- frameId: null;
85
138
  strokeSharpness: string;
86
- boundElementIds: never[];
87
- startBinding: null;
88
- endBinding: null;
89
139
  points: number[][];
90
- lastCommittedPoint: null;
91
- startArrowhead: null;
92
- endArrowhead: null;
140
+ boundElementIds?: undefined;
93
141
  } | {
94
142
  type: string;
95
- version: number;
96
- versionNonce: number;
97
- isDeleted: boolean;
98
- id: string;
99
143
  fillStyle: string;
100
144
  strokeWidth: number;
101
145
  strokeStyle: string;
@@ -110,21 +154,15 @@ declare namespace _default {
110
154
  height: number;
111
155
  seed: number;
112
156
  groupIds: string[];
113
- frameId: null;
114
157
  strokeSharpness: string;
115
158
  boundElementIds: string[];
116
- startBinding?: undefined;
117
- endBinding?: undefined;
118
159
  points?: undefined;
119
- lastCommittedPoint?: undefined;
120
- startArrowhead?: undefined;
121
- endArrowhead?: undefined;
160
+ version?: undefined;
161
+ versionNonce?: undefined;
162
+ isDeleted?: undefined;
163
+ id?: undefined;
122
164
  })[] | ({
123
165
  type: string;
124
- version: number;
125
- versionNonce: number;
126
- isDeleted: boolean;
127
- id: string;
128
166
  fillStyle: string;
129
167
  strokeWidth: number;
130
168
  strokeStyle: string;
@@ -139,19 +177,10 @@ declare namespace _default {
139
177
  height: number;
140
178
  seed: number;
141
179
  groupIds: string[];
142
- frameId: null;
143
180
  strokeSharpness: string;
144
- boundElementIds: string[];
145
181
  points?: undefined;
146
- lastCommittedPoint?: undefined;
147
- startArrowhead?: undefined;
148
- endArrowhead?: undefined;
149
182
  } | {
150
183
  type: string;
151
- version: number;
152
- versionNonce: number;
153
- isDeleted: boolean;
154
- id: string;
155
184
  fillStyle: string;
156
185
  strokeWidth: number;
157
186
  strokeStyle: string;
@@ -166,13 +195,96 @@ declare namespace _default {
166
195
  height: number;
167
196
  seed: number;
168
197
  groupIds: string[];
169
- frameId: null;
170
198
  strokeSharpness: string;
171
- boundElementIds: never[];
172
199
  points: number[][];
173
- lastCommittedPoint: null;
174
- startArrowhead: null;
175
- endArrowhead: null;
200
+ } | {
201
+ type: string;
202
+ fillStyle: string;
203
+ strokeWidth: number;
204
+ strokeStyle: string;
205
+ x: number;
206
+ y: number;
207
+ strokeColor: string;
208
+ backgroundColor: string;
209
+ width: number;
210
+ height: number;
211
+ groupIds: string[];
212
+ strokeSharpness: string;
213
+ points: number[][];
214
+ roughness?: undefined;
215
+ opacity?: undefined;
216
+ angle?: undefined;
217
+ seed?: undefined;
218
+ } | {
219
+ type: string;
220
+ fillStyle: string;
221
+ strokeWidth: number;
222
+ strokeStyle: string;
223
+ roughness: number;
224
+ opacity: number;
225
+ angle: number;
226
+ x: number;
227
+ y: number;
228
+ strokeColor: string;
229
+ backgroundColor: string;
230
+ width: number;
231
+ height: number;
232
+ groupIds: string[];
233
+ strokeSharpness: string;
234
+ points: number[][];
235
+ seed?: undefined;
236
+ } | {
237
+ type: string;
238
+ fillStyle: string;
239
+ strokeWidth: number;
240
+ strokeStyle: string;
241
+ opacity: number;
242
+ x: number;
243
+ y: number;
244
+ strokeColor: string;
245
+ backgroundColor: string;
246
+ width: number;
247
+ height: number;
248
+ seed: number;
249
+ groupIds: string[];
250
+ strokeSharpness: string;
251
+ points: number[][];
252
+ roughness?: undefined;
253
+ angle?: undefined;
254
+ })[] | ({
255
+ type: string;
256
+ fillStyle: string;
257
+ strokeWidth: number;
258
+ strokeStyle: string;
259
+ roughness: number;
260
+ opacity: number;
261
+ angle: number;
262
+ x: number;
263
+ y: number;
264
+ strokeColor: string;
265
+ backgroundColor: string;
266
+ width: number;
267
+ height: number;
268
+ seed: number;
269
+ groupIds: string[];
270
+ strokeSharpness: string;
271
+ } | {
272
+ type: string;
273
+ fillStyle: string;
274
+ strokeWidth: number;
275
+ strokeStyle: string;
276
+ x: number;
277
+ y: number;
278
+ strokeColor: string;
279
+ backgroundColor: string;
280
+ width: number;
281
+ height: number;
282
+ seed: number;
283
+ groupIds: string[];
284
+ strokeSharpness: string;
285
+ roughness?: undefined;
286
+ opacity?: undefined;
287
+ angle?: undefined;
176
288
  })[])[];
177
- }
289
+ };
178
290
  export default _default;
@@ -26,3 +26,4 @@ export { WelcomeScreen };
26
26
  export { LiveCollaborationTrigger };
27
27
  export { DefaultSidebar } from "../../components/DefaultSidebar";
28
28
  export { normalizeLink } from "../../data/url";
29
+ export { convertToExcalidrawElements } from "../../data/transform";
@@ -36,13 +36,16 @@ export namespace module {
36
36
  } | {
37
37
  test: RegExp;
38
38
  exclude: RegExp;
39
- use: {
39
+ use: ({
40
+ loader: string;
41
+ options?: undefined;
42
+ } | {
40
43
  loader: string;
41
44
  options: {
42
45
  transpileOnly: boolean;
43
46
  configFile: string;
44
47
  };
45
- }[];
48
+ })[];
46
49
  type?: undefined;
47
50
  } | {
48
51
  test: RegExp;
@@ -36,6 +36,9 @@ export namespace module {
36
36
  test: RegExp;
37
37
  exclude: RegExp;
38
38
  use: ({
39
+ loader: string;
40
+ options?: undefined;
41
+ } | {
39
42
  loader: string;
40
43
  options: {
41
44
  transpileOnly: boolean;
@@ -21,8 +21,9 @@ export declare const exportToBlob: (opts: ExportOpts & {
21
21
  quality?: number;
22
22
  exportPadding?: number;
23
23
  }) => Promise<Blob>;
24
- export declare const exportToSvg: ({ elements, appState, files, exportPadding, }: Omit<ExportOpts, "getDimensions"> & {
24
+ export declare const exportToSvg: ({ elements, appState, files, exportPadding, renderEmbeddables, }: Omit<ExportOpts, "getDimensions"> & {
25
25
  exportPadding?: number | undefined;
26
+ renderEmbeddables?: boolean | undefined;
26
27
  }) => Promise<SVGSVGElement>;
27
28
  export declare const exportToClipboard: (opts: ExportOpts & {
28
29
  mimeType?: string;
@@ -1,37 +1,25 @@
1
1
  import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement } from "../element/types";
2
- import { RoughCanvas } from "roughjs/bin/canvas";
3
- import { Drawable, Options } from "roughjs/bin/core";
4
- import { RoughSVG } from "roughjs/bin/svg";
5
- import { RenderConfig } from "../scene/types";
6
- import { AppState, BinaryFiles } from "../types";
2
+ import type { RoughCanvas } from "roughjs/bin/canvas";
3
+ import type { RoughSVG } from "roughjs/bin/svg";
4
+ import { StaticCanvasRenderConfig } from "../scene/types";
5
+ import { AppState, StaticCanvasAppState, BinaryFiles, InteractiveCanvasAppState } from "../types";
7
6
  export interface ExcalidrawElementWithCanvas {
8
7
  element: ExcalidrawElement | ExcalidrawTextElement;
9
8
  canvas: HTMLCanvasElement;
10
- theme: RenderConfig["theme"];
9
+ theme: AppState["theme"];
11
10
  scale: number;
12
- zoomValue: RenderConfig["zoom"]["value"];
11
+ zoomValue: AppState["zoom"]["value"];
13
12
  canvasOffsetX: number;
14
13
  canvasOffsetY: number;
15
14
  boundTextElementVersion: number | null;
16
15
  containingFrameOpacity: number;
17
16
  }
18
17
  export declare const DEFAULT_LINK_SIZE = 14;
19
- type ElementShape = Drawable | Drawable[] | null;
20
- type ElementShapes = {
21
- freedraw: Drawable | null;
22
- arrow: Drawable[];
23
- line: Drawable[];
24
- text: null;
25
- image: null;
26
- };
27
- export declare const getShapeForElement: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : Drawable | null | undefined;
28
- export declare const setShapeForElement: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
29
- export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
30
- export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
31
- export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: RenderConfig, appState: AppState) => void;
32
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null) => void;
18
+ export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
19
+ export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
20
+ export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
21
+ export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX: number, offsetY: number, exportWithDarkMode?: boolean, exportingFrameId?: string | null, renderEmbeddables?: boolean) => void;
33
22
  export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
34
23
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
35
24
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
36
25
  export declare function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement): string;
37
- export {};
@@ -1,50 +1,31 @@
1
- import { RoughCanvas } from "roughjs/bin/canvas";
2
1
  import { RoughSVG } from "roughjs/bin/svg";
3
- import { AppState, BinaryFiles, Zoom } from "../types";
4
- import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
5
- import { RenderConfig } from "../scene/types";
2
+ import { BinaryFiles } from "../types";
3
+ import { NonDeletedExcalidrawElement } from "../element/types";
4
+ import { InteractiveSceneRenderConfig, StaticSceneRenderConfig } from "../scene/types";
6
5
  import "canvas-roundrect-polyfill";
7
6
  export declare const DEFAULT_SPACING = 2;
8
- export declare const _renderScene: ({ elements, appState, scale, rc, canvas, renderConfig, }: {
9
- elements: readonly NonDeletedExcalidrawElement[];
10
- appState: AppState;
11
- scale: number;
12
- rc: RoughCanvas;
13
- canvas: HTMLCanvasElement;
14
- renderConfig: RenderConfig;
15
- }) => {
7
+ /**
8
+ * Interactive scene is the ui-canvas where we render boundinb boxes, selections
9
+ * and other ui stuff.
10
+ */
11
+ export declare const renderInteractiveScene: <U extends ({ canvas, elements, visibleElements, selectedElements, scale, appState, renderConfig, }: InteractiveSceneRenderConfig) => {
16
12
  atLeastOneVisibleElement: boolean;
17
- scrollBars?: undefined;
18
- } | {
19
- atLeastOneVisibleElement: boolean;
20
- scrollBars: import("../scene/types").ScrollBars | undefined;
21
- };
22
- /** renderScene throttled to animation framerate */
23
- export declare const renderScene: <T extends boolean = false>(config: {
24
13
  elements: readonly NonDeletedExcalidrawElement[];
25
- appState: AppState;
26
- scale: number;
27
- rc: RoughCanvas;
28
- canvas: HTMLCanvasElement;
29
- renderConfig: RenderConfig;
30
- callback?: ((data: ReturnType<typeof _renderScene>) => void) | undefined;
31
- }, throttle?: T | undefined) => T extends true ? void : {
32
- atLeastOneVisibleElement: boolean;
33
14
  scrollBars?: undefined;
34
15
  } | {
35
- atLeastOneVisibleElement: boolean;
36
16
  scrollBars: import("../scene/types").ScrollBars | undefined;
37
- };
38
- export declare const isVisibleElement: (element: ExcalidrawElement, canvasWidth: number, canvasHeight: number, viewTransformations: {
39
- zoom: Zoom;
40
- offsetLeft: number;
41
- offsetTop: number;
42
- scrollX: number;
43
- scrollY: number;
44
- }) => boolean;
45
- export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, }?: {
17
+ atLeastOneVisibleElement: boolean;
18
+ elements: readonly NonDeletedExcalidrawElement[];
19
+ }, T extends boolean = false>(renderConfig: InteractiveSceneRenderConfig, throttle?: T | undefined) => T extends true ? void : ReturnType<U>;
20
+ /**
21
+ * Static scene is the non-ui canvas where we render elements.
22
+ */
23
+ export declare const renderStaticScene: (renderConfig: StaticSceneRenderConfig, throttle?: boolean) => void;
24
+ export declare const cancelRender: () => void;
25
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, exportWithDarkMode, exportingFrameId, renderEmbeddables, }?: {
46
26
  offsetX?: number | undefined;
47
27
  offsetY?: number | undefined;
48
28
  exportWithDarkMode?: boolean | undefined;
49
29
  exportingFrameId?: string | null | undefined;
30
+ renderEmbeddables?: boolean | undefined;
50
31
  }) => void;
@@ -0,0 +1,25 @@
1
+ import { NonDeletedExcalidrawElement } from "../element/types";
2
+ import { AppState } from "../types";
3
+ import Scene from "./Scene";
4
+ export declare class Renderer {
5
+ private scene;
6
+ constructor(scene: Scene);
7
+ getRenderableElements: ((opts: {
8
+ zoom: AppState["zoom"];
9
+ offsetLeft: AppState["offsetLeft"];
10
+ offsetTop: AppState["offsetTop"];
11
+ scrollX: AppState["scrollX"];
12
+ scrollY: AppState["scrollY"];
13
+ height: AppState["height"];
14
+ width: AppState["width"];
15
+ editingElement: AppState["editingElement"];
16
+ pendingImageElementId: AppState["pendingImageElementId"];
17
+ versionNonce: ReturnType<InstanceType<typeof Scene>["getVersionNonce"]>;
18
+ }) => {
19
+ canvasElements: NonDeletedExcalidrawElement[];
20
+ visibleElements: readonly NonDeletedExcalidrawElement[];
21
+ }) & {
22
+ clear: () => void;
23
+ };
24
+ destroy(): void;
25
+ }
@@ -1,5 +1,6 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameElement } from "../element/types";
2
2
  import { LinearElementEditor } from "../element/linearElementEditor";
3
+ import { AppState } from "../types";
3
4
  type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
4
5
  type ElementKey = ExcalidrawElement | ElementIdKey;
5
6
  type SceneStateCallback = () => void;
@@ -16,11 +17,25 @@ declare class Scene {
16
17
  private nonDeletedFrames;
17
18
  private frames;
18
19
  private elementsMap;
20
+ private selectedElementsCache;
21
+ private versionNonce;
19
22
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
20
23
  getNonDeletedElements(): readonly NonDeletedExcalidrawElement[];
21
24
  getFramesIncludingDeleted(): readonly ExcalidrawFrameElement[];
25
+ getSelectedElements(opts: {
26
+ selectedElementIds: AppState["selectedElementIds"];
27
+ /**
28
+ * for specific cases where you need to use elements not from current
29
+ * scene state. This in effect will likely result in cache-miss, and
30
+ * the cache won't be updated in this case.
31
+ */
32
+ elements?: readonly ExcalidrawElement[];
33
+ includeBoundTextElement?: boolean;
34
+ includeElementsInFrames?: boolean;
35
+ }): NonDeleted<ExcalidrawElement>[];
22
36
  getNonDeletedFrames(): readonly NonDeleted<ExcalidrawFrameElement>[];
23
37
  getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
38
+ getVersionNonce(): number | undefined;
24
39
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
25
40
  /**
26
41
  * A utility method to help with updating all scene elements, with the added
@@ -0,0 +1,12 @@
1
+ import type { Drawable, Options } from "roughjs/bin/core";
2
+ import type { RoughGenerator } from "roughjs/bin/generator";
3
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "../element/types";
4
+ export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
5
+ /**
6
+ * Generates the roughjs shape for given element.
7
+ *
8
+ * Low-level. Use `ShapeCache.generateElementShape` instead.
9
+ *
10
+ * @private
11
+ */
12
+ export declare const _generateElementShape: (element: Exclude<NonDeletedExcalidrawElement, ExcalidrawSelectionElement>, generator: RoughGenerator, isExporting?: boolean) => Drawable | Drawable[] | null;
@@ -0,0 +1,20 @@
1
+ import { Drawable } from "roughjs/bin/core";
2
+ import { ExcalidrawElement } from "../element/types";
3
+ import { ElementShape, ElementShapes } from "./types";
4
+ export declare class ShapeCache {
5
+ private static rg;
6
+ private static cache;
7
+ /**
8
+ * Retrieves shape from cache if available. Use this only if shape
9
+ * is optional and you have a fallback in case it's not cached.
10
+ */
11
+ static get: <T extends ExcalidrawElement>(element: T) => T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] | undefined : ElementShape | undefined;
12
+ static set: <T extends ExcalidrawElement>(element: T, shape: T["type"] extends keyof ElementShapes ? ElementShapes[T["type"]] : Drawable) => WeakMap<ExcalidrawElement, ElementShape>;
13
+ static delete: (element: ExcalidrawElement) => boolean;
14
+ static destroy: () => void;
15
+ /**
16
+ * Generates & caches shape for element if not already cached, otherwise
17
+ * returns cached shape.
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);
20
+ }
@@ -20,5 +20,6 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
20
20
  renderFrame?: boolean;
21
21
  }, files: BinaryFiles | null, opts?: {
22
22
  serializeAsJSON?: () => string;
23
+ renderEmbeddables?: boolean;
23
24
  }) => Promise<SVGSVGElement>;
24
25
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
@@ -11,7 +11,7 @@ export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, }:
11
11
  scrollX: number;
12
12
  scrollY: number;
13
13
  };
14
- export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState, canvas: HTMLCanvasElement | null) => {
14
+ export declare const calculateScrollCenter: (elements: readonly ExcalidrawElement[], appState: AppState) => {
15
15
  scrollX: number;
16
16
  scrollY: number;
17
17
  };
@@ -1,14 +1,10 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { Zoom } from "../types";
2
+ import { InteractiveCanvasAppState } from "../types";
3
3
  import { ScrollBars } from "./types";
4
4
  export declare const SCROLLBAR_MARGIN = 4;
5
5
  export declare const SCROLLBAR_WIDTH = 6;
6
6
  export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
7
- export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, { scrollX, scrollY, zoom, }: {
8
- scrollX: number;
9
- scrollY: number;
10
- zoom: Zoom;
11
- }) => ScrollBars;
7
+ export declare const getScrollBars: (elements: readonly ExcalidrawElement[], viewportWidth: number, viewportHeight: number, appState: InteractiveCanvasAppState) => ScrollBars;
12
8
  export declare const isOverScrollBars: (scrollBars: ScrollBars, x: number, y: number) => {
13
9
  isOverEither: boolean;
14
10
  isOverHorizontal: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
2
+ import { AppState, InteractiveCanvasAppState } from "../types";
3
3
  /**
4
4
  * Frames and their containing elements are not to be selected at the same time.
5
5
  * Given an array of selected elements, if there are frames and their containing elements
@@ -8,14 +8,24 @@ import { AppState } from "../types";
8
8
  */
9
9
  export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
10
10
  export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
11
- export declare const isSomeElementSelected: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">) => boolean;
11
+ export declare const isSomeElementSelected: {
12
+ (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
13
+ clearCache(): void;
14
+ };
12
15
  /**
13
16
  * Returns common attribute (picked by `getAttribute` callback) of selected
14
17
  * elements. If elements don't share the same value, returns `null`.
15
18
  */
16
19
  export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
17
- export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, opts?: {
20
+ export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
18
21
  includeBoundTextElement?: boolean;
19
22
  includeElementsInFrames?: boolean;
20
23
  }) => ExcalidrawElement[];
21
24
  export declare const getTargetElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds" | "editingElement">) => ExcalidrawElement[];
25
+ /**
26
+ * returns prevState's selectedElementids if no change from previous, so as to
27
+ * retain reference identity for memoization
28
+ */
29
+ export declare const makeNextSelectedElementIds: (nextSelectedElementIds: AppState["selectedElementIds"], prevState: Pick<AppState, "selectedElementIds">) => Readonly<{
30
+ [id: string]: true;
31
+ }>;