@excalidraw/math 0.18.0-2b1c2a9 → 0.18.0-2c3dcc0
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.
- package/dist/dev/index.js +8 -2
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/colors.d.ts +3 -0
- package/dist/types/common/src/constants.d.ts +56 -0
- package/dist/types/common/src/keys.d.ts +4 -0
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +12 -1
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +4 -1
- package/dist/types/element/src/binding.d.ts +75 -7
- package/dist/types/element/src/bounds.d.ts +10 -2
- package/dist/types/element/src/collision.d.ts +21 -5
- package/dist/types/element/src/comparisons.d.ts +5 -3
- package/dist/types/element/src/cropElement.d.ts +36 -4
- package/dist/types/element/src/delta.d.ts +30 -2
- package/dist/types/element/src/distribute.d.ts +4 -1
- package/dist/types/element/src/dragElements.d.ts +8 -3
- package/dist/types/element/src/duplicate.d.ts +60 -0
- package/dist/types/element/src/elbowArrow.d.ts +5 -0
- package/dist/types/element/src/embeddable.d.ts +2 -1
- package/dist/types/element/src/flowchart.d.ts +6 -8
- package/dist/types/element/src/frame.d.ts +21 -3
- package/dist/types/element/src/groups.d.ts +1 -6
- package/dist/types/element/src/image.d.ts +5 -2
- package/dist/types/element/src/index.d.ts +3 -0
- package/dist/types/element/src/linearElementEditor.d.ts +4 -1
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +40 -3
- package/dist/types/element/src/renderElement.d.ts +31 -4
- package/dist/types/element/src/renderEnvironment.d.ts +66 -0
- package/dist/types/element/src/resizeElements.d.ts +15 -5
- package/dist/types/element/src/selection.d.ts +4 -10
- package/dist/types/element/src/shape.d.ts +17 -1
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/stickyNote.d.ts +191 -0
- package/dist/types/element/src/textElement.d.ts +10 -2
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +3 -2
- package/dist/types/element/src/transform.d.ts +30 -7
- package/dist/types/element/src/typeChecks.d.ts +3 -2
- package/dist/types/element/src/types.d.ts +28 -6
- package/dist/types/element/src/utils.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -3
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +62 -208
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +121 -16
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -546
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +39 -9
- package/dist/types/excalidraw/actions/actionFrame.d.ts +92 -479
- package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -4
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +66 -2
- package/dist/types/excalidraw/actions/actionLink.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +42 -8
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -1
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +3 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +26 -8
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
- package/dist/types/excalidraw/charts/index.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +10 -2
- package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +129 -218
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.host.d.ts +102 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
- package/dist/types/excalidraw/components/App.text.d.ts +194 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
- package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
- package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
- package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
- package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
- package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
- package/dist/types/excalidraw/components/Tools.d.ts +7 -2
- package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
- package/dist/types/excalidraw/data/blob.d.ts +46 -16
- package/dist/types/excalidraw/data/index.d.ts +3 -3
- package/dist/types/excalidraw/data/json.d.ts +23 -8
- package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
- package/dist/types/excalidraw/history.d.ts +10 -4
- package/dist/types/excalidraw/mermaid.d.ts +7 -0
- package/dist/types/excalidraw/reactUtils.d.ts +1 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +64 -3
- package/dist/types/excalidraw/scene/export.d.ts +343 -20
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +26 -2
- package/dist/types/excalidraw/types.d.ts +191 -22
- package/dist/types/excalidraw/viewport.d.ts +29 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
- package/dist/types/utils/src/index.d.ts +3 -1
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
- package/dist/types/utils/src/export.d.ts +0 -35
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
2
2
|
import type { Scene } from "@excalidraw/element";
|
|
3
3
|
import type { RenderableElementsMap } from "./types";
|
|
4
|
-
import type { AppState } from "../types";
|
|
4
|
+
import type { AppState, ElementRenderOffsets } from "../types";
|
|
5
5
|
type GetRenderableElementsOpts = {
|
|
6
6
|
zoom: AppState["zoom"];
|
|
7
7
|
offsetLeft: AppState["offsetLeft"];
|
|
@@ -19,6 +19,19 @@ type GetRenderableElementsOpts = {
|
|
|
19
19
|
export declare class Renderer {
|
|
20
20
|
private scene;
|
|
21
21
|
constructor(scene: Scene);
|
|
22
|
+
/**
|
|
23
|
+
* Adjusts the document-visible set for render-override translations: an
|
|
24
|
+
* element leaves it when its offset moves it out of view and enters it when
|
|
25
|
+
* its offset brings it in; everything else keeps its document visibility.
|
|
26
|
+
* Only translated elements go through viewport geometry. The result is
|
|
27
|
+
* memoized on the offsets' identity so that opacity-only snapshots don't
|
|
28
|
+
* reach it at all.
|
|
29
|
+
*/
|
|
30
|
+
getVisibleElementsWithRenderOffsets(visibleElements: readonly NonDeletedExcalidrawElement[], elementsMap: RenderableElementsMap, appState: AppState, offsets: ElementRenderOffsets): readonly NonDeletedExcalidrawElement[];
|
|
31
|
+
private _getVisibleElementsWithRenderOffsets;
|
|
32
|
+
/** the document-visible elements as a set, cached per visible array */
|
|
33
|
+
private visibleSets;
|
|
34
|
+
private getVisibleSet;
|
|
22
35
|
private getVisibleCanvasElements;
|
|
23
36
|
private getRenderableElementsMap;
|
|
24
37
|
private sortSelectedElementsIntoHighlightedFrame;
|
|
@@ -53,6 +66,7 @@ export declare class Renderer {
|
|
|
53
66
|
frameId: string | null;
|
|
54
67
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
55
68
|
updated: number;
|
|
69
|
+
created: number | null;
|
|
56
70
|
link: string | null;
|
|
57
71
|
locked: boolean;
|
|
58
72
|
customData?: Record<string, any>;
|
|
@@ -92,6 +106,7 @@ export declare class Renderer {
|
|
|
92
106
|
frameId: string | null;
|
|
93
107
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
94
108
|
updated: number;
|
|
109
|
+
created: number | null;
|
|
95
110
|
link: string | null;
|
|
96
111
|
locked: boolean;
|
|
97
112
|
customData?: Record<string, any>;
|
|
@@ -126,6 +141,43 @@ export declare class Renderer {
|
|
|
126
141
|
frameId: string | null;
|
|
127
142
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
128
143
|
updated: number;
|
|
144
|
+
created: number | null;
|
|
145
|
+
link: string | null;
|
|
146
|
+
locked: boolean;
|
|
147
|
+
customData?: Record<string, any>;
|
|
148
|
+
}> & Readonly<{
|
|
149
|
+
type: "stickynote";
|
|
150
|
+
baseHeight: number;
|
|
151
|
+
}> & {
|
|
152
|
+
isDeleted: false;
|
|
153
|
+
}) | (Readonly<{
|
|
154
|
+
id: string;
|
|
155
|
+
x: number;
|
|
156
|
+
y: number;
|
|
157
|
+
strokeColor: string;
|
|
158
|
+
backgroundColor: string;
|
|
159
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
160
|
+
strokeWidth: number;
|
|
161
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
162
|
+
roundness: null | {
|
|
163
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
164
|
+
value?: number;
|
|
165
|
+
};
|
|
166
|
+
roughness: number;
|
|
167
|
+
opacity: number;
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
angle: import("@excalidraw/math").Radians;
|
|
171
|
+
seed: number;
|
|
172
|
+
version: number;
|
|
173
|
+
versionNonce: number;
|
|
174
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
175
|
+
isDeleted: boolean;
|
|
176
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
177
|
+
frameId: string | null;
|
|
178
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
179
|
+
updated: number;
|
|
180
|
+
created: number | null;
|
|
129
181
|
link: string | null;
|
|
130
182
|
locked: boolean;
|
|
131
183
|
customData?: Record<string, any>;
|
|
@@ -160,6 +212,7 @@ export declare class Renderer {
|
|
|
160
212
|
frameId: string | null;
|
|
161
213
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
162
214
|
updated: number;
|
|
215
|
+
created: number | null;
|
|
163
216
|
link: string | null;
|
|
164
217
|
locked: boolean;
|
|
165
218
|
customData?: Record<string, any>;
|
|
@@ -194,6 +247,7 @@ export declare class Renderer {
|
|
|
194
247
|
frameId: string | null;
|
|
195
248
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
196
249
|
updated: number;
|
|
250
|
+
created: number | null;
|
|
197
251
|
link: string | null;
|
|
198
252
|
locked: boolean;
|
|
199
253
|
customData?: Record<string, any>;
|
|
@@ -228,6 +282,7 @@ export declare class Renderer {
|
|
|
228
282
|
frameId: string | null;
|
|
229
283
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
230
284
|
updated: number;
|
|
285
|
+
created: number | null;
|
|
231
286
|
link: string | null;
|
|
232
287
|
locked: boolean;
|
|
233
288
|
customData?: Record<string, any>;
|
|
@@ -265,6 +320,7 @@ export declare class Renderer {
|
|
|
265
320
|
frameId: string | null;
|
|
266
321
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
267
322
|
updated: number;
|
|
323
|
+
created: number | null;
|
|
268
324
|
link: string | null;
|
|
269
325
|
locked: boolean;
|
|
270
326
|
customData?: Record<string, any>;
|
|
@@ -303,6 +359,7 @@ export declare class Renderer {
|
|
|
303
359
|
frameId: string | null;
|
|
304
360
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
305
361
|
updated: number;
|
|
362
|
+
created: number | null;
|
|
306
363
|
link: string | null;
|
|
307
364
|
locked: boolean;
|
|
308
365
|
customData?: Record<string, any>;
|
|
@@ -338,6 +395,7 @@ export declare class Renderer {
|
|
|
338
395
|
frameId: string | null;
|
|
339
396
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
340
397
|
updated: number;
|
|
398
|
+
created: number | null;
|
|
341
399
|
link: string | null;
|
|
342
400
|
locked: boolean;
|
|
343
401
|
customData?: Record<string, any>;
|
|
@@ -373,6 +431,7 @@ export declare class Renderer {
|
|
|
373
431
|
frameId: string | null;
|
|
374
432
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
375
433
|
updated: number;
|
|
434
|
+
created: number | null;
|
|
376
435
|
link: string | null;
|
|
377
436
|
locked: boolean;
|
|
378
437
|
customData?: Record<string, any>;
|
|
@@ -380,10 +439,11 @@ export declare class Renderer {
|
|
|
380
439
|
type: "text";
|
|
381
440
|
fontSize: number;
|
|
382
441
|
fontFamily: import("@excalidraw/element/types").FontFamilyValues;
|
|
442
|
+
baseFontSize: number | null;
|
|
383
443
|
text: string;
|
|
384
444
|
textAlign: import("@excalidraw/element/types").TextAlign;
|
|
385
445
|
verticalAlign: import("@excalidraw/element/types").VerticalAlign;
|
|
386
|
-
containerId: import("@excalidraw/element/types").
|
|
446
|
+
containerId: import("@excalidraw/element/types").ExcalidrawTextContainer["id"] | null;
|
|
387
447
|
originalText: string;
|
|
388
448
|
autoResize: boolean;
|
|
389
449
|
lineHeight: number & {
|
|
@@ -419,6 +479,7 @@ export declare class Renderer {
|
|
|
419
479
|
frameId: string | null;
|
|
420
480
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
421
481
|
updated: number;
|
|
482
|
+
created: number | null;
|
|
422
483
|
link: string | null;
|
|
423
484
|
locked: boolean;
|
|
424
485
|
customData?: Record<string, any>;
|
|
@@ -433,6 +494,6 @@ export declare class Renderer {
|
|
|
433
494
|
}) | null;
|
|
434
495
|
canvasNonce: string;
|
|
435
496
|
};
|
|
436
|
-
destroy(): void;
|
|
497
|
+
destroy(staticCanvas: HTMLCanvasElement): void;
|
|
437
498
|
}
|
|
438
499
|
export {};
|
|
@@ -1,31 +1,299 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MIME_TYPES } from "@excalidraw/common";
|
|
2
|
+
import type { RenderEnvironment } from "@excalidraw/element";
|
|
3
|
+
import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement, Theme } from "@excalidraw/element/types";
|
|
4
|
+
import { cleanAppStateForExport } from "../appState";
|
|
2
5
|
import type { AppState, BinaryFiles } from "../types";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export type ExportSceneData = {
|
|
7
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
8
|
+
/**
|
|
9
|
+
* The scene settings a `.excalidraw` file stores (`viewBackgroundColor`,
|
|
10
|
+
* grid settings) — not editor state. Used as the default background
|
|
11
|
+
* (`canvasBackgroundColor`) and embedded with the scene (`embedScene`).
|
|
12
|
+
* Anything else passed in is ignored; rendering options go to `config`.
|
|
13
|
+
*/
|
|
14
|
+
appState?: ReturnType<typeof cleanAppStateForExport>;
|
|
15
|
+
files?: BinaryFiles | null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The host capabilities an export uses, shared by every format: e.g. for test
|
|
19
|
+
* environments, Node.js or another window.
|
|
20
|
+
*
|
|
21
|
+
* Unlike the editor's `renderEnvironment` prop, this needn't be the same
|
|
22
|
+
* object across exports (e.g. on a server): exports draw without the element
|
|
23
|
+
* caches keyed by an environment, and measure little text. Passing a complete
|
|
24
|
+
* one (`createCanvas` and `createImage`) as-is, as the editor does, only keeps
|
|
25
|
+
* its measuring caches warm.
|
|
26
|
+
*/
|
|
27
|
+
type ExportEnvironment = {
|
|
28
|
+
/**
|
|
29
|
+
* Creates the canvas a canvas/PNG/JPEG export renders into, and any canvas
|
|
30
|
+
* the export measures text with (e.g. frame labels, embed placeholders).
|
|
31
|
+
*
|
|
32
|
+
* Do not set `canvas.width/height` or modify the canvas context as that's
|
|
33
|
+
* handled by Excalidraw.
|
|
34
|
+
*
|
|
35
|
+
* Defaults to `document.createElement("canvas")`.
|
|
36
|
+
*/
|
|
37
|
+
createCanvas?: RenderEnvironment["createCanvas"];
|
|
38
|
+
/**
|
|
39
|
+
* Creates the images that image elements are decoded into.
|
|
40
|
+
*
|
|
41
|
+
* Defaults to `new Image()`.
|
|
42
|
+
*/
|
|
43
|
+
createImage?: RenderEnvironment["createImage"];
|
|
44
|
+
/**
|
|
45
|
+
* Creates the paths that freedraw elements are filled through.
|
|
46
|
+
*
|
|
47
|
+
* Defaults to the global `Path2D`.
|
|
48
|
+
*/
|
|
49
|
+
createPath?: RenderEnvironment["createPath"];
|
|
50
|
+
/**
|
|
51
|
+
* The document an SVG export is built in, e.g. a popout window's or,
|
|
52
|
+
* outside the browser, a DOM implementation's (such as `linkedom`).
|
|
53
|
+
*
|
|
54
|
+
* Defaults to the global `document`.
|
|
55
|
+
*/
|
|
56
|
+
document?: RenderEnvironment["document"];
|
|
57
|
+
/**
|
|
58
|
+
* Measures text (frame labels, embed placeholders), e.g. where there is no
|
|
59
|
+
* canvas to measure on.
|
|
60
|
+
*
|
|
61
|
+
* Defaults to the global provider set with `setCustomTextMetricsProvider`,
|
|
62
|
+
* else to measuring on a canvas from `createCanvas`.
|
|
63
|
+
*/
|
|
64
|
+
textMetrics?: RenderEnvironment["textMetrics"];
|
|
65
|
+
/**
|
|
66
|
+
* Loads the fonts the exported elements use, before rendering.
|
|
67
|
+
*
|
|
68
|
+
* Defaults to loading them through the browser's
|
|
69
|
+
* [FontFace API](https://developer.mozilla.org/en-US/docs/Web/API/FontFace).
|
|
70
|
+
*/
|
|
71
|
+
loadFonts?: () => Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
type ExportSceneBaseConfig = {
|
|
74
|
+
/**
|
|
75
|
+
* @default "light"
|
|
76
|
+
*/
|
|
77
|
+
theme?: Theme;
|
|
78
|
+
/**
|
|
79
|
+
* Canvas background. Valid values are:
|
|
80
|
+
*
|
|
81
|
+
* - `undefined` - the background of "appState.viewBackgroundColor" is used.
|
|
82
|
+
* - `false` - no background is used (transparent). Not supported for JPEG,
|
|
83
|
+
* which falls back to the default.
|
|
84
|
+
* - `string` - should be a valid CSS color.
|
|
85
|
+
*
|
|
86
|
+
* Specified in light-theme terms: `theme: "dark"` transforms it like any
|
|
87
|
+
* other scene color. Only affects the rendered image, not the embedded
|
|
88
|
+
* scene (`embedScene`).
|
|
89
|
+
*
|
|
90
|
+
* @default undefined
|
|
91
|
+
*/
|
|
92
|
+
canvasBackgroundColor?: string | false;
|
|
93
|
+
/**
|
|
94
|
+
* Canvas padding in pixels. Affected by `scale`.
|
|
95
|
+
*
|
|
96
|
+
* When `fit` is `none`, padding is added around the content bounding box,
|
|
97
|
+
* or around the `width`/`height` frame if set — in which case the content
|
|
98
|
+
* may overflow the frame, thus right or bottom padding may be ignored.
|
|
99
|
+
*
|
|
100
|
+
* When `fit` is `contain`, or `maxWidthOrHeight`/`widthOrHeight` is set,
|
|
101
|
+
* padding is subtracted from the target size (so the export doesn't exceed
|
|
102
|
+
* it, `scale` aside), and serves as a minimum distance between the content
|
|
103
|
+
* and the canvas edges — it may be exceeded on one axis to maintain the
|
|
104
|
+
* aspect ratio. It is recommended to set `position` to `center` when using
|
|
105
|
+
* `fit: "contain"`.
|
|
106
|
+
*
|
|
107
|
+
* @default 10
|
|
108
|
+
*/
|
|
109
|
+
padding?: number;
|
|
110
|
+
/**
|
|
111
|
+
* A multiplier to increase/decrease the frame dimensions
|
|
112
|
+
* (content resolution).
|
|
113
|
+
*
|
|
114
|
+
* For example, if your canvas is 300x150 and you set scale to 2, the
|
|
115
|
+
* resulting size will be 600x300.
|
|
116
|
+
*
|
|
117
|
+
* Can be a function, which receives the export dimensions at scale 1
|
|
118
|
+
* (padding included) and returns the multiplier — e.g. to cap the output
|
|
119
|
+
* by a pixel budget.
|
|
120
|
+
*
|
|
121
|
+
* @default 1
|
|
122
|
+
*/
|
|
123
|
+
scale?: number | ((width: number, height: number) => number);
|
|
124
|
+
/**
|
|
125
|
+
* Host environment overrides, e.g. for test environments or Node.js.
|
|
126
|
+
*/
|
|
127
|
+
environment?: ExportEnvironment;
|
|
7
128
|
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
8
|
-
|
|
9
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Which frame decorations to render. Ignored when exporting a single frame
|
|
131
|
+
* (`exportingFrame`), which renders neither its name nor outline, and clips
|
|
132
|
+
* to it.
|
|
133
|
+
*
|
|
134
|
+
* @default { name: true, outline: true, clip: true }
|
|
135
|
+
*/
|
|
136
|
+
frames?: {
|
|
137
|
+
name?: boolean;
|
|
138
|
+
outline?: boolean;
|
|
139
|
+
clip?: boolean;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The ways to size the export — only one can be used. The positioning options
|
|
144
|
+
* (`fit`, `position`, `x`, `y`, `origin`) belong to `width`/`height` (or no
|
|
145
|
+
* size option).
|
|
146
|
+
*/
|
|
147
|
+
type ExportSizeOptions = {
|
|
148
|
+
/**
|
|
149
|
+
* Makes sure the canvas content fits into a frame of width/height no larger
|
|
150
|
+
* than this value, while maintaining the aspect ratio.
|
|
151
|
+
*
|
|
152
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
153
|
+
* `scale`.
|
|
154
|
+
*
|
|
155
|
+
* Can't be combined with `width`/`height`, `widthOrHeight`, or the
|
|
156
|
+
* positioning options (`fit`, `position`, `x`, `y`, `origin`).
|
|
157
|
+
*/
|
|
158
|
+
maxWidthOrHeight?: number;
|
|
159
|
+
/**
|
|
160
|
+
* Scale the canvas content to be exactly this many pixels wide/tall,
|
|
161
|
+
* maintaining the aspect ratio.
|
|
162
|
+
*
|
|
163
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
164
|
+
* `scale`.
|
|
165
|
+
*
|
|
166
|
+
* Can't be combined with `width`/`height`, `maxWidthOrHeight`, or the
|
|
167
|
+
* positioning options (`fit`, `position`, `x`, `y`, `origin`).
|
|
168
|
+
*/
|
|
169
|
+
widthOrHeight?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Width of the frame. Supply `x` or `y` if you want to offset the canvas
|
|
172
|
+
* content.
|
|
173
|
+
*
|
|
174
|
+
* If `width` omitted but `height` supplied, `width` is calculated from the
|
|
175
|
+
* content's aspect ratio when `fit` is `contain` (the default), or is the
|
|
176
|
+
* content bounding box width when `fit` is `none`.
|
|
177
|
+
*
|
|
178
|
+
* Defaults to the content bounding box width when both `width` and `height`
|
|
179
|
+
* are omitted.
|
|
180
|
+
*
|
|
181
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`.
|
|
182
|
+
*/
|
|
183
|
+
width?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Height of the frame.
|
|
186
|
+
*
|
|
187
|
+
* If `height` omitted but `width` supplied, `height` is calculated from the
|
|
188
|
+
* content's aspect ratio when `fit` is `contain` (the default), or is the
|
|
189
|
+
* content bounding box height when `fit` is `none`.
|
|
190
|
+
*
|
|
191
|
+
* Defaults to the content bounding box height when both `width` and `height`
|
|
192
|
+
* are omitted.
|
|
193
|
+
*
|
|
194
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`.
|
|
195
|
+
*/
|
|
196
|
+
height?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Left edge of the exported region (`padding` is added around it). By
|
|
199
|
+
* default the coordinate is relative to the canvas. You can switch to
|
|
200
|
+
* content coordinates by setting `origin` to `content`.
|
|
201
|
+
*
|
|
202
|
+
* Defaults to the `x` position of the content bounding box.
|
|
203
|
+
*
|
|
204
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`, and is
|
|
205
|
+
* ignored with `fit: "contain"`, so setting `x` or `y` makes `fit` default
|
|
206
|
+
* to `none` (cropping the region).
|
|
207
|
+
*/
|
|
208
|
+
x?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Top edge of the exported region (`padding` is added around it). By
|
|
211
|
+
* default the coordinate is relative to the canvas. You can switch to
|
|
212
|
+
* content coordinates by setting `origin` to `content`.
|
|
213
|
+
*
|
|
214
|
+
* Defaults to the `y` position of the content bounding box.
|
|
215
|
+
*
|
|
216
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`, and is
|
|
217
|
+
* ignored with `fit: "contain"`, so setting `x` or `y` makes `fit` default
|
|
218
|
+
* to `none` (cropping the region).
|
|
219
|
+
*/
|
|
220
|
+
y?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Indicates the coordinate system of the `x` and `y` values.
|
|
223
|
+
*
|
|
224
|
+
* - `canvas` - `x` and `y` are relative to the canvas [0, 0] position.
|
|
225
|
+
* - `content` - `x` and `y` are relative to the content bounding box.
|
|
226
|
+
*
|
|
227
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`.
|
|
228
|
+
*
|
|
229
|
+
* @default "canvas"
|
|
230
|
+
*/
|
|
231
|
+
origin?: "canvas" | "content";
|
|
232
|
+
/**
|
|
233
|
+
* How the content should be scaled into the `width`/`height` frame.
|
|
234
|
+
*
|
|
235
|
+
* Behavior aligns with the `object-fit` CSS property.
|
|
236
|
+
*
|
|
237
|
+
* - `none` - no scaling.
|
|
238
|
+
* - `contain` - scale to fit the frame. Includes `padding`.
|
|
239
|
+
*
|
|
240
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`.
|
|
241
|
+
*
|
|
242
|
+
* @default "contain" if `width` or `height` is set (and `x`/`y` aren't),
|
|
243
|
+
* otherwise "none"
|
|
244
|
+
*/
|
|
245
|
+
fit?: "none" | "contain";
|
|
246
|
+
/**
|
|
247
|
+
* When either `x` or `y` are not specified, indicates how the canvas should
|
|
248
|
+
* be aligned on the respective axis.
|
|
249
|
+
*
|
|
250
|
+
* - `topLeft` - canvas aligned to top left.
|
|
251
|
+
* - `center` - canvas is centered on the axis which is not specified
|
|
252
|
+
* (or both).
|
|
253
|
+
*
|
|
254
|
+
* Can't be combined with `maxWidthOrHeight` or `widthOrHeight`.
|
|
255
|
+
*
|
|
256
|
+
* @default "center"
|
|
257
|
+
*/
|
|
258
|
+
position?: "center" | "topLeft";
|
|
259
|
+
};
|
|
260
|
+
type ExportSizeOption<K extends keyof ExportSizeOptions> = Pick<ExportSizeOptions, K> & {
|
|
261
|
+
[P in keyof ExportSizeOptions as P extends K ? never : P]?: never;
|
|
262
|
+
};
|
|
263
|
+
type ExportSizeConfig = ExportSizeOption<"width" | "height" | "fit" | "position" | "x" | "y" | "origin"> | ExportSizeOption<"maxWidthOrHeight"> | ExportSizeOption<"widthOrHeight">;
|
|
264
|
+
export type ExportSceneConfig = ExportSceneBaseConfig & ExportSizeConfig;
|
|
265
|
+
/**
|
|
266
|
+
* The export config the editor's export settings translate to. Internal: hosts
|
|
267
|
+
* pass their own config.
|
|
268
|
+
*/
|
|
269
|
+
export declare const getExportConfigFromAppState: (appState: Pick<AppState, "exportWithDarkMode" | "exportBackground" | "viewBackgroundColor" | "exportScale" | "frameRendering">) => {
|
|
270
|
+
theme: "light" | "dark";
|
|
271
|
+
canvasBackgroundColor: string | false;
|
|
10
272
|
scale: number;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
273
|
+
frames: {
|
|
274
|
+
enabled: boolean;
|
|
275
|
+
name: boolean;
|
|
276
|
+
outline: boolean;
|
|
277
|
+
clip: boolean;
|
|
278
|
+
} | {
|
|
279
|
+
name: boolean;
|
|
280
|
+
outline: boolean;
|
|
281
|
+
clip: boolean;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
type ExportToSvgConfig = Pick<ExportSceneBaseConfig, "canvasBackgroundColor" | "padding" | "theme" | "exportingFrame" | "scale" | "frames" | "environment"> & ExportSizeConfig & {
|
|
21
285
|
/**
|
|
22
286
|
* if true, all embeddables passed in will be rendered when possible.
|
|
23
287
|
*/
|
|
24
288
|
renderEmbeddables?: boolean;
|
|
25
|
-
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
26
289
|
skipInliningFonts?: true;
|
|
27
290
|
reuseImages?: boolean;
|
|
28
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Embeds the scene into the SVG, so that it can be imported back into
|
|
293
|
+
* Excalidraw.
|
|
294
|
+
*/
|
|
295
|
+
embedScene?: boolean;
|
|
296
|
+
};
|
|
29
297
|
export declare const encodeSvgBase64Payload: ({ payload, metadataElement, }: {
|
|
30
298
|
payload: string;
|
|
31
299
|
metadataElement: SVGMetadataElement;
|
|
@@ -33,4 +301,59 @@ export declare const encodeSvgBase64Payload: ({ payload, metadataElement, }: {
|
|
|
33
301
|
export declare const decodeSvgBase64Payload: ({ svg }: {
|
|
34
302
|
svg: string;
|
|
35
303
|
}) => string;
|
|
36
|
-
export
|
|
304
|
+
export { MIME_TYPES };
|
|
305
|
+
type ExportToPngConfig = ExportSceneConfig & {
|
|
306
|
+
/**
|
|
307
|
+
* Embeds the scene into the PNG metadata, so that it can be imported back
|
|
308
|
+
* into Excalidraw.
|
|
309
|
+
*/
|
|
310
|
+
embedScene?: boolean;
|
|
311
|
+
};
|
|
312
|
+
type ExportToJpegConfig = ExportSceneConfig & {
|
|
313
|
+
/**
|
|
314
|
+
* Encoding quality between 0 and 1.
|
|
315
|
+
*
|
|
316
|
+
* @default 0.92
|
|
317
|
+
*/
|
|
318
|
+
quality?: number;
|
|
319
|
+
};
|
|
320
|
+
export type ExportSceneOptions = {
|
|
321
|
+
data: ExportSceneData;
|
|
322
|
+
} & ({
|
|
323
|
+
type: "canvas";
|
|
324
|
+
config?: ExportSceneConfig;
|
|
325
|
+
} | {
|
|
326
|
+
type: "png";
|
|
327
|
+
config?: ExportToPngConfig;
|
|
328
|
+
} | {
|
|
329
|
+
type: "jpeg";
|
|
330
|
+
config?: ExportToJpegConfig;
|
|
331
|
+
} | {
|
|
332
|
+
type: "svg";
|
|
333
|
+
config?: ExportToSvgConfig;
|
|
334
|
+
});
|
|
335
|
+
/**
|
|
336
|
+
* Exports the scene to a canvas, a PNG or JPEG blob, or an SVG element.
|
|
337
|
+
*/
|
|
338
|
+
export declare function exportScene(opts: Extract<ExportSceneOptions, {
|
|
339
|
+
type: "canvas";
|
|
340
|
+
}>): Promise<HTMLCanvasElement>;
|
|
341
|
+
export declare function exportScene(opts: Extract<ExportSceneOptions, {
|
|
342
|
+
type: "png" | "jpeg";
|
|
343
|
+
}>): Promise<Blob>;
|
|
344
|
+
export declare function exportScene(opts: Extract<ExportSceneOptions, {
|
|
345
|
+
type: "svg";
|
|
346
|
+
}>): Promise<SVGSVGElement>;
|
|
347
|
+
export declare function exportScene(opts: ExportSceneOptions): Promise<HTMLCanvasElement | Blob | SVGSVGElement>;
|
|
348
|
+
export declare const exportToClipboard: (opts: {
|
|
349
|
+
data: ExportSceneData;
|
|
350
|
+
} & ({
|
|
351
|
+
type: "png";
|
|
352
|
+
config?: ExportToPngConfig;
|
|
353
|
+
} | {
|
|
354
|
+
type: "svg";
|
|
355
|
+
config?: ExportToSvgConfig;
|
|
356
|
+
} | {
|
|
357
|
+
type: "json";
|
|
358
|
+
config?: never;
|
|
359
|
+
})) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { isSomeElementSelected, getElementsWithinSelection, getSelectedElements, getTargetElements, } from "@excalidraw/element";
|
|
2
2
|
export { getScrollToContentState } from "../viewport";
|
|
3
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
3
|
+
export { hasBackground, hasFillStyle, hasRoughness, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
4
4
|
export { getNormalizedZoom, getNormalizedGridSize, getNormalizedGridStep, } from "./normalize";
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import type { UserIdleState, EditorInterface } from "@excalidraw/common";
|
|
2
|
-
import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
2
|
+
import type { ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
3
3
|
import type { MakeBrand } from "@excalidraw/common/utility-types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { RenderEnvironment } from "@excalidraw/element/renderEnvironment";
|
|
5
|
+
import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementRenderOverrides, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
|
|
5
6
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
6
7
|
import type { Drawable } from "roughjs/bin/core";
|
|
7
8
|
export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
|
|
8
9
|
export type StaticCanvasRenderConfig = {
|
|
9
10
|
canvasBackgroundColor: AppState["viewBackgroundColor"];
|
|
11
|
+
/**
|
|
12
|
+
* Backing-store scale the target canvas was bootstrapped with -- the owner
|
|
13
|
+
* window's devicePixelRatio when rendering into the editor, exportScale when
|
|
14
|
+
* exporting. Element caches are built and blitted at this ratio, so it must
|
|
15
|
+
* be the same value passed as `StaticSceneRenderConfig["scale"]`.
|
|
16
|
+
*/
|
|
17
|
+
scale: number;
|
|
18
|
+
/**
|
|
19
|
+
* Host environment that creates the canvases and images this render
|
|
20
|
+
* rasterizes (per-editor owner window in the app; the export's
|
|
21
|
+
* `config.environment` when exporting). Defaults to the browser's.
|
|
22
|
+
*/
|
|
23
|
+
renderEnvironment?: RenderEnvironment;
|
|
24
|
+
/** export only: clips everything drawn to this frame (square corners) */
|
|
25
|
+
clipToFrame?: ExcalidrawFrameLikeElement | null;
|
|
10
26
|
imageCache: AppClassProperties["imageCache"];
|
|
11
27
|
renderGrid: boolean;
|
|
12
28
|
/** whether to render link icons on elements with links (never rendered
|
|
@@ -19,8 +35,15 @@ export type StaticCanvasRenderConfig = {
|
|
|
19
35
|
elementsPendingErasure: ElementsPendingErasure;
|
|
20
36
|
pendingFlowchartNodes: PendingExcalidrawElements | null;
|
|
21
37
|
theme: AppState["theme"];
|
|
38
|
+
elementRenderOverrides?: ElementRenderOverrides;
|
|
22
39
|
};
|
|
23
40
|
export type SVGRenderConfig = {
|
|
41
|
+
/**
|
|
42
|
+
* Host environment used for the text measurements this render needs (the
|
|
43
|
+
* SVG itself is built through `exportToSvg`'s owner document). Defaults to
|
|
44
|
+
* the browser's.
|
|
45
|
+
*/
|
|
46
|
+
renderEnvironment?: RenderEnvironment;
|
|
24
47
|
offsetX: number;
|
|
25
48
|
offsetY: number;
|
|
26
49
|
isExporting: boolean;
|
|
@@ -132,6 +155,7 @@ export type ElementShapes = {
|
|
|
132
155
|
arrow: Drawable[];
|
|
133
156
|
line: Drawable[];
|
|
134
157
|
text: null;
|
|
158
|
+
stickynote: null;
|
|
135
159
|
image: null;
|
|
136
160
|
frame: null;
|
|
137
161
|
magicframe: null;
|