@dwelle/excalidraw 0.4.0-c38ebd4 → 0.4.0-c4ea72b
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/CHANGELOG.md +451 -1
- package/README.md +6 -2
- package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js → vendor-d415b28e9024dee4bb1b.js} +2 -2
- package/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.js → vendor-a14cd58fa2db417e42b2.js} +6 -6
- package/dist/excalidraw.development.js +2807 -1620
- package/dist/excalidraw.production.min.js +1 -1
- package/main.js +1 -8
- package/package.json +8 -3
- package/types/actions/actionAddToLibrary.d.ts +81 -31
- package/types/actions/actionAlign.d.ts +25 -20
- package/types/actions/actionBoundText.d.ts +156 -19
- package/types/actions/actionCanvas.d.ts +504 -96
- package/types/actions/actionClipboard.d.ts +131 -50
- package/types/actions/actionDeleteSelected.d.ts +75 -28
- package/types/actions/actionDistribute.d.ts +7 -8
- package/types/actions/actionDuplicateSelection.d.ts +0 -1
- package/types/actions/actionElementLock.d.ts +271 -0
- package/types/actions/actionExport.d.ts +288 -135
- package/types/actions/actionFinalize.d.ts +52 -22
- package/types/actions/actionFlip.d.ts +4 -7
- package/types/actions/actionFrame.d.ts +423 -0
- package/types/actions/actionGroup.d.ts +246 -9
- package/types/actions/actionHistory.d.ts +1 -1
- package/types/actions/actionLinearEditor.d.ts +29 -13
- package/types/actions/actionMenu.d.ts +82 -33
- package/types/actions/actionNavigate.d.ts +1 -1
- package/types/actions/actionProperties.d.ts +356 -134
- package/types/actions/actionSelectAll.d.ts +121 -2
- package/types/actions/actionStyles.d.ts +27 -11
- package/types/actions/actionToggleGridMode.d.ts +27 -11
- package/types/actions/actionToggleStats.d.ts +27 -11
- package/types/actions/actionToggleViewMode.d.ts +27 -11
- package/types/actions/actionToggleZenMode.d.ts +27 -11
- package/types/actions/actionZindex.d.ts +4 -4
- package/types/actions/index.d.ts +1 -1
- package/types/actions/manager.d.ts +1 -1
- package/types/actions/shortcuts.d.ts +1 -1
- package/types/actions/types.d.ts +10 -9
- package/types/appState.d.ts +12 -9
- package/types/charts.d.ts +2 -2
- package/types/clients.d.ts +5 -6
- package/types/clipboard.d.ts +3 -2
- package/types/colors.d.ts +60 -5
- package/types/components/Actions.d.ts +7 -7
- package/types/components/ActiveConfirmDialog.d.ts +1 -21
- package/types/components/App.d.ts +72 -16
- package/types/components/Avatar.d.ts +1 -2
- package/types/components/Button.d.ts +3 -2
- package/types/components/ButtonIconSelect.d.ts +11 -3
- package/types/components/Card.d.ts +0 -1
- package/types/components/ColorPicker/ColorInput.d.ts +9 -0
- package/types/components/ColorPicker/ColorPicker.d.ts +19 -0
- package/types/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/types/components/ColorPicker/HotkeyLabel.d.ts +8 -0
- package/types/components/ColorPicker/Picker.d.ts +18 -0
- package/types/components/ColorPicker/PickerColorList.d.ts +10 -0
- package/types/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/types/components/ColorPicker/ShadeList.d.ts +8 -0
- package/types/components/ColorPicker/TopPicks.d.ts +9 -0
- package/types/components/ColorPicker/colorPickerUtils.d.ts +21 -0
- package/types/components/ColorPicker/keyboardNavHandlers.d.ts +20 -0
- package/types/components/ContextMenu.d.ts +3 -3
- package/types/components/DefaultSidebar.d.ts +29 -0
- package/types/components/Dialog.d.ts +3 -4
- package/types/components/ExcalidrawLogo.d.ts +15 -0
- package/types/components/EyeDropper.d.ts +28 -0
- package/types/components/FilledButton.d.ts +17 -0
- package/types/components/FixedSideContainer.d.ts +1 -1
- package/types/components/HandButton.d.ts +1 -1
- package/types/components/HelpButton.d.ts +1 -1
- package/types/components/HintViewer.d.ts +4 -5
- package/types/components/HomeButton.d.ts +1 -1
- package/types/components/ImageExportDialog.d.ts +8 -13
- package/types/components/Island.d.ts +1 -1
- package/types/components/JSONExportDialog.d.ts +5 -5
- package/types/components/LayerUI.d.ts +7 -11
- package/types/components/LibraryMenu.d.ts +13 -14
- package/types/components/LibraryMenuBrowseButton.d.ts +2 -2
- package/types/components/LibraryMenuControlButtons.d.ts +9 -0
- package/types/components/LibraryMenuHeaderContent.d.ts +10 -28
- package/types/components/LibraryMenuItems.d.ts +6 -7
- package/types/components/LibraryMenuSection.d.ts +22 -0
- package/types/components/LibraryUnit.d.ts +6 -3
- package/types/components/LoadingMessage.d.ts +0 -1
- package/types/components/LockButton.d.ts +1 -1
- package/types/components/MobileMenu.d.ts +7 -6
- package/types/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
- package/types/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
- package/types/components/PasteChartDialog.d.ts +4 -5
- package/types/components/PenModeButton.d.ts +1 -1
- package/types/components/Popover.d.ts +1 -1
- package/types/components/ProjectName.d.ts +2 -1
- package/types/components/PublishLibrary.d.ts +2 -2
- package/types/components/RadioGroup.d.ts +12 -0
- package/types/components/Section.d.ts +1 -1
- package/types/components/Sidebar/Sidebar.d.ts +66 -63
- package/types/components/Sidebar/SidebarHeader.d.ts +6 -19
- package/types/components/Sidebar/SidebarTab.d.ts +8 -0
- package/types/components/Sidebar/SidebarTabTrigger.d.ts +9 -0
- package/types/components/Sidebar/SidebarTabTriggers.d.ts +6 -0
- package/types/components/Sidebar/SidebarTabs.d.ts +6 -0
- package/types/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/types/components/Sidebar/common.d.ts +24 -7
- package/types/components/Spinner.d.ts +2 -1
- package/types/components/Stack.d.ts +4 -3
- package/types/components/Stats.d.ts +3 -3
- package/types/components/Switch.d.ts +9 -0
- package/types/components/ToolButton.d.ts +5 -4
- package/types/components/Tooltip.d.ts +1 -1
- package/types/components/Trans.d.ts +9 -0
- package/types/components/canvases/InteractiveCanvas.d.ts +27 -0
- package/types/components/canvases/StaticCanvas.d.ts +18 -0
- package/types/components/canvases/index.d.ts +3 -0
- package/types/components/dropdownMenu/DropdownMenu.d.ts +3 -2
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -2
- package/types/components/footer/Footer.d.ts +2 -2
- package/types/components/icons.d.ts +13 -1
- package/types/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -1
- package/types/components/main-menu/MainMenu.d.ts +3 -2
- package/types/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -1
- package/types/components/welcome-screen/WelcomeScreen.d.ts +0 -1
- package/types/constants.d.ts +75 -10
- package/types/context/tunnels.d.ts +19 -0
- package/types/context/ui-appState.d.ts +4 -0
- package/types/data/blob.d.ts +2 -2
- package/types/data/encode.d.ts +1 -1
- package/types/data/filesystem.d.ts +2 -1
- package/types/data/library.d.ts +3 -45
- package/types/data/restore.d.ts +2 -2
- package/types/data/transform.d.ts +71 -0
- package/types/data/types.d.ts +3 -5
- package/types/data/url.d.ts +7 -0
- package/types/element/Hyperlink.d.ts +38 -18
- package/types/element/binding.d.ts +4 -3
- package/types/element/bounds.d.ts +31 -6
- package/types/element/collision.d.ts +7 -7
- package/types/element/dragElements.d.ts +2 -1
- package/types/element/embeddable.d.ts +153 -0
- package/types/element/image.d.ts +11 -1
- package/types/element/index.d.ts +3 -2
- package/types/element/linearElementEditor.d.ts +33 -16
- package/types/element/mutateElement.d.ts +1 -1
- package/types/element/newElement.d.ts +47 -13
- package/types/element/resizeElements.d.ts +1 -0
- package/types/element/showSelectedShapeActions.d.ts +2 -2
- package/types/element/sizeHelpers.d.ts +8 -1
- package/types/element/textElement.d.ts +13 -8
- package/types/element/textWysiwyg.d.ts +1 -1
- package/types/element/transformHandles.d.ts +15 -8
- package/types/element/typeChecks.d.ts +3 -1
- package/types/element/types.d.ts +52 -35
- package/types/emitter.d.ts +1 -1
- package/types/errors.d.ts +1 -1
- package/types/frame.d.ts +40 -0
- package/types/ga.d.ts +5 -5
- package/types/groups.d.ts +15 -11
- package/types/history.d.ts +3 -3
- package/types/hooks/useCreatePortalContainer.d.ts +4 -0
- package/types/hooks/useLibraryItemSvg.d.ts +11 -0
- package/types/hooks/useOutsideClick.d.ts +19 -2
- package/types/hooks/useScrollPosition.d.ts +1 -0
- package/types/hooks/useStable.d.ts +1 -0
- package/types/hooks/useTransition.d.ts +2 -0
- package/types/i18n.d.ts +7 -4
- package/types/jotai.d.ts +16 -104
- package/types/keys.d.ts +4 -1
- package/types/math.d.ts +1 -0
- package/types/packages/excalidraw/example/initialData.d.ts +182 -64
- package/types/packages/excalidraw/index.d.ts +5 -2
- package/types/packages/excalidraw/main.d.ts +3 -1
- package/types/packages/excalidraw/webpack.dev.config.d.ts +5 -2
- package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -0
- package/types/packages/utils.d.ts +9 -2
- package/types/renderer/renderElement.d.ts +12 -22
- package/types/renderer/renderScene.d.ts +19 -27
- package/types/renderer/roundRect.d.ts +1 -1
- package/types/scene/Renderer.d.ts +25 -0
- package/types/scene/Scene.d.ts +27 -5
- package/types/scene/Shape.d.ts +12 -0
- package/types/scene/ShapeCache.d.ts +20 -0
- package/types/scene/export.d.ts +49 -11
- package/types/scene/scroll.d.ts +1 -1
- package/types/scene/scrollbars.d.ts +2 -6
- package/types/scene/selection.d.ts +26 -6
- package/types/scene/types.d.ts +69 -34
- package/types/types.d.ts +145 -56
- package/types/utility-types.d.ts +16 -14
- package/types/utils.d.ts +70 -11
- package/types/zindex.d.ts +4 -4
- package/types/actions/actionToggleLock.d.ts +0 -119
- package/types/components/ColorPicker.d.ts +0 -14
- package/types/components/LibraryButton.d.ts +0 -8
- package/types/components/SingleLibraryItem.d.ts +0 -10
- package/types/components/context/tunnels.d.ts +0 -16
- package/types/components/hoc/withUpstreamOverride.d.ts +0 -10
- /package/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.js.LICENSE.txt → vendor-d415b28e9024dee4bb1b.js.LICENSE.txt} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets/{vendor-2002fe1b8862917b36c1.d.ts → vendor-d415b28e9024dee4bb1b.d.ts} +0 -0
- /package/types/packages/excalidraw/dist/excalidraw-assets-dev/{vendor-e6df8519da951026ff69.d.ts → vendor-a14cd58fa2db417e42b2.d.ts} +0 -0
package/types/scene/export.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { NonDeletedExcalidrawElement, Theme } from "../element/types";
|
|
2
2
|
import { AppState, BinaryFiles } from "../types";
|
|
3
|
+
import { serializeAsJSON } from "../data/json";
|
|
3
4
|
export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
|
|
4
|
-
export
|
|
5
|
+
export type ExportToCanvasData = {
|
|
5
6
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
6
7
|
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
|
|
7
8
|
files: BinaryFiles | null;
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
+
export type ExportToCanvasConfig = {
|
|
10
11
|
theme?: Theme;
|
|
11
12
|
/**
|
|
12
13
|
* Canvas background. Valid values are:
|
|
@@ -19,10 +20,28 @@ export declare type ExportToCanvasConfig = {
|
|
|
19
20
|
*/
|
|
20
21
|
canvasBackgroundColor?: string | false;
|
|
21
22
|
/**
|
|
22
|
-
* Canvas padding in pixels. Affected by scale
|
|
23
|
-
* `cover`.
|
|
23
|
+
* Canvas padding in pixels. Affected by `scale`.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
25
|
+
* When `fit` is set to `none`, padding is added to the content bounding box
|
|
26
|
+
* (including if you set `width` or `height` or `maxWidthOrHeight` or
|
|
27
|
+
* `widthOrHeight`).
|
|
28
|
+
*
|
|
29
|
+
* When `fit` set to `contain`, padding is subtracted from the content
|
|
30
|
+
* bounding box (ensuring the size doesn't exceed the supplied values, with
|
|
31
|
+
* the exeception of using alongside `scale` as noted above), and the padding
|
|
32
|
+
* serves as a minimum distance between the content and the canvas edges, as
|
|
33
|
+
* it may exceed the supplied padding value from one side or the other in
|
|
34
|
+
* order to maintain the aspect ratio. It is recommended to set `position`
|
|
35
|
+
* to `center` when using `fit=contain`.
|
|
36
|
+
*
|
|
37
|
+
* When `fit` is set to `cover`, padding is disabled (set to 0).
|
|
38
|
+
*
|
|
39
|
+
* When `fit` is set to `none` and either `width` or `height` or
|
|
40
|
+
* `maxWidthOrHeight` is set, padding is simply adding to the bounding box
|
|
41
|
+
* and the content may overflow the canvas, thus right or bottom padding
|
|
42
|
+
* may be ignored.
|
|
43
|
+
*
|
|
44
|
+
* @default 0
|
|
26
45
|
*/
|
|
27
46
|
padding?: number;
|
|
28
47
|
/**
|
|
@@ -33,6 +52,16 @@ export declare type ExportToCanvasConfig = {
|
|
|
33
52
|
* `scale`.
|
|
34
53
|
*/
|
|
35
54
|
maxWidthOrHeight?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Scale the canvas content to be excatly this many pixels wide/tall,
|
|
57
|
+
* maintaining the aspect ratio.
|
|
58
|
+
*
|
|
59
|
+
* Cannot be used in conjunction with `maxWidthOrHeight`.
|
|
60
|
+
*
|
|
61
|
+
* Final dimensions can get smaller/larger if used in conjunction with
|
|
62
|
+
* `scale`.
|
|
63
|
+
*/
|
|
64
|
+
widthOrHeight?: number;
|
|
36
65
|
/**
|
|
37
66
|
* Width of the frame. Supply `x` or `y` if you want to ofsset the canvas
|
|
38
67
|
* content.
|
|
@@ -84,12 +113,15 @@ export declare type ExportToCanvasConfig = {
|
|
|
84
113
|
* Behavior aligns with the `object-fit` CSS property.
|
|
85
114
|
*
|
|
86
115
|
* - `none` - no scaling.
|
|
87
|
-
* - `contain` - scale to fit the frame.
|
|
116
|
+
* - `contain` - scale to fit the frame. Includes `padding`.
|
|
88
117
|
* - `cover` - scale to fill the frame while maintaining aspect ratio. If
|
|
89
118
|
* content overflows, it will be cropped.
|
|
90
119
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
120
|
+
* If `maxWidthOrHeight` or `widthOrHeight` is set, `fit` is ignored.
|
|
121
|
+
*
|
|
122
|
+
* @default "contain" unless `width`, `height`, `maxWidthOrHeight`, or
|
|
123
|
+
* `widthOrHeight` is specified in which case `none` is the default (can be
|
|
124
|
+
* changed). If `x` or `y` are specified, `none` is forced.
|
|
93
125
|
*/
|
|
94
126
|
fit?: "none" | "contain" | "cover";
|
|
95
127
|
/**
|
|
@@ -100,9 +132,11 @@ export declare type ExportToCanvasConfig = {
|
|
|
100
132
|
* - `center` - canvas is centered on the axis which is not specified
|
|
101
133
|
* (or both).
|
|
102
134
|
*
|
|
135
|
+
* If `maxWidthOrHeight` or `widthOrHeight` is set, `position` is ignored.
|
|
136
|
+
*
|
|
103
137
|
* @default "center"
|
|
104
138
|
*/
|
|
105
|
-
position?: "center" | "
|
|
139
|
+
position?: "center" | "topLeft";
|
|
106
140
|
/**
|
|
107
141
|
* A multiplier to increase/decrease the frame dimensions
|
|
108
142
|
* (content resolution).
|
|
@@ -150,5 +184,9 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
150
184
|
viewBackgroundColor: string;
|
|
151
185
|
exportWithDarkMode?: boolean;
|
|
152
186
|
exportEmbedScene?: boolean;
|
|
153
|
-
|
|
154
|
-
|
|
187
|
+
renderFrame?: boolean;
|
|
188
|
+
}, files: BinaryFiles | null, opts?: {
|
|
189
|
+
serializeAsJSON?: () => string;
|
|
190
|
+
renderEmbeddables?: boolean;
|
|
191
|
+
}) => Promise<SVGSVGElement>;
|
|
192
|
+
export declare const getCanvasSize: (elements: readonly NonDeletedExcalidrawElement[]) => [minX: number, minY: number, width: number, height: number];
|
package/types/scene/scroll.d.ts
CHANGED
|
@@ -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
|
|
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 {
|
|
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,
|
|
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,11 +1,31 @@
|
|
|
1
1
|
import { ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { AppState, InteractiveCanvasAppState } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Frames and their containing elements are not to be selected at the same time.
|
|
5
|
+
* Given an array of selected elements, if there are frames and their containing elements
|
|
6
|
+
* we only keep the frames.
|
|
7
|
+
* @param selectedElements
|
|
8
|
+
*/
|
|
9
|
+
export declare const excludeElementsInFramesFromSelection: <T extends ExcalidrawElement>(selectedElements: readonly T[]) => T[];
|
|
10
|
+
export declare const getElementsWithinSelection: (elements: readonly NonDeletedExcalidrawElement[], selection: NonDeletedExcalidrawElement, excludeElementsInFrames?: boolean) => NonDeletedExcalidrawElement[];
|
|
11
|
+
export declare const isSomeElementSelected: {
|
|
12
|
+
(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">): boolean;
|
|
13
|
+
clearCache(): void;
|
|
14
|
+
};
|
|
5
15
|
/**
|
|
6
16
|
* Returns common attribute (picked by `getAttribute` callback) of selected
|
|
7
17
|
* elements. If elements don't share the same value, returns `null`.
|
|
8
18
|
*/
|
|
9
|
-
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: AppState, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
10
|
-
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState:
|
|
11
|
-
|
|
19
|
+
export declare const getCommonAttributeOfSelectedElements: <T>(elements: readonly NonDeletedExcalidrawElement[], appState: Pick<AppState, "selectedElementIds">, getAttribute: (element: ExcalidrawElement) => T) => T | null;
|
|
20
|
+
export declare const getSelectedElements: (elements: readonly NonDeletedExcalidrawElement[], appState: Pick<InteractiveCanvasAppState, "selectedElementIds">, opts?: {
|
|
21
|
+
includeBoundTextElement?: boolean;
|
|
22
|
+
includeElementsInFrames?: boolean;
|
|
23
|
+
}) => ExcalidrawElement[];
|
|
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
|
+
}>;
|
package/types/scene/types.d.ts
CHANGED
|
@@ -1,57 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
|
+
import { Drawable } from "roughjs/bin/core";
|
|
3
|
+
import { ExcalidrawTextElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
4
|
+
import { AppClassProperties, InteractiveCanvasAppState, StaticCanvasAppState } from "../types";
|
|
5
|
+
export type RenderConfig = {};
|
|
6
|
+
export type StaticCanvasRenderConfig = {
|
|
7
|
+
imageCache: AppClassProperties["imageCache"];
|
|
8
|
+
renderGrid: boolean;
|
|
9
|
+
/** when exporting the behavior is slightly different (e.g. we can't use
|
|
10
|
+
CSS filters), and we disable render optimizations for best output */
|
|
11
|
+
isExporting: boolean;
|
|
6
12
|
/** null indicates transparent bg */
|
|
7
|
-
canvasBackgroundColor:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* devicePixelRatio. For export, it's the `appState.exportScale`
|
|
14
|
-
* (user setting) or whatever scale you want to use when exporting elsewhere.
|
|
15
|
-
*
|
|
16
|
-
* Bigger the scale, the more pixels (=quality).
|
|
17
|
-
*/
|
|
18
|
-
canvasScale: number;
|
|
13
|
+
canvasBackgroundColor: string | null;
|
|
14
|
+
};
|
|
15
|
+
export type InteractiveCanvasRenderConfig = {
|
|
16
|
+
remoteSelectedElementIds: {
|
|
17
|
+
[elementId: string]: string[];
|
|
18
|
+
};
|
|
19
19
|
remotePointerViewportCoords: {
|
|
20
20
|
[id: string]: {
|
|
21
21
|
x: number;
|
|
22
22
|
y: number;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
[id: string]: string
|
|
27
|
-
};
|
|
28
|
-
remoteSelectedElementIds: {
|
|
29
|
-
[elementId: string]: string[];
|
|
25
|
+
remotePointerUserStates: {
|
|
26
|
+
[id: string]: string;
|
|
30
27
|
};
|
|
31
28
|
remotePointerUsernames: {
|
|
32
29
|
[id: string]: string;
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
[id: string]: string;
|
|
31
|
+
remotePointerButton?: {
|
|
32
|
+
[id: string]: string | undefined;
|
|
36
33
|
};
|
|
37
|
-
imageCache: AppClassProperties["imageCache"];
|
|
38
|
-
renderScrollbars?: boolean;
|
|
39
|
-
renderSelection?: boolean;
|
|
40
|
-
renderGrid?: boolean;
|
|
41
|
-
/** when exporting the behavior is slightly different (e.g. we can't use
|
|
42
|
-
CSS filters), and we disable render optimizations for best output */
|
|
43
|
-
isExporting: boolean;
|
|
44
34
|
selectionColor?: string;
|
|
35
|
+
renderScrollbars?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type RenderInteractiveSceneCallback = {
|
|
38
|
+
atLeastOneVisibleElement: boolean;
|
|
39
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
40
|
+
scrollBars?: ScrollBars;
|
|
45
41
|
};
|
|
46
|
-
export
|
|
42
|
+
export type StaticSceneRenderConfig = {
|
|
43
|
+
canvas: HTMLCanvasElement;
|
|
44
|
+
rc: RoughCanvas;
|
|
45
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
46
|
+
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
47
|
+
/**
|
|
48
|
+
* canvas scale factor. Not related to zoom. In browsers, it's the
|
|
49
|
+
* devicePixelRatio. For export, it's the `appState.exportScale`
|
|
50
|
+
* (user setting) or whatever scale you want to use when exporting elsewhere.
|
|
51
|
+
*
|
|
52
|
+
* Bigger the scale, the more pixels (=quality).
|
|
53
|
+
*/
|
|
54
|
+
scale: number;
|
|
55
|
+
appState: StaticCanvasAppState;
|
|
56
|
+
renderConfig: StaticCanvasRenderConfig;
|
|
57
|
+
};
|
|
58
|
+
export type InteractiveSceneRenderConfig = {
|
|
59
|
+
canvas: HTMLCanvasElement | null;
|
|
60
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
61
|
+
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
62
|
+
selectedElements: readonly NonDeletedExcalidrawElement[];
|
|
63
|
+
scale: number;
|
|
64
|
+
appState: InteractiveCanvasAppState;
|
|
65
|
+
renderConfig: InteractiveCanvasRenderConfig;
|
|
66
|
+
callback: (data: RenderInteractiveSceneCallback) => void;
|
|
67
|
+
};
|
|
68
|
+
export type SceneScroll = {
|
|
47
69
|
scrollX: number;
|
|
48
70
|
scrollY: number;
|
|
49
71
|
};
|
|
50
72
|
export interface Scene {
|
|
51
73
|
elements: ExcalidrawTextElement[];
|
|
52
74
|
}
|
|
53
|
-
export
|
|
54
|
-
export
|
|
75
|
+
export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
|
|
76
|
+
export type ScrollBars = {
|
|
55
77
|
horizontal: {
|
|
56
78
|
x: number;
|
|
57
79
|
y: number;
|
|
@@ -65,3 +87,16 @@ export declare type ScrollBars = {
|
|
|
65
87
|
height: number;
|
|
66
88
|
} | null;
|
|
67
89
|
};
|
|
90
|
+
export type ElementShape = Drawable | Drawable[] | null;
|
|
91
|
+
export type ElementShapes = {
|
|
92
|
+
rectangle: Drawable;
|
|
93
|
+
ellipse: Drawable;
|
|
94
|
+
diamond: Drawable;
|
|
95
|
+
embeddable: Drawable;
|
|
96
|
+
freedraw: Drawable | null;
|
|
97
|
+
arrow: Drawable[];
|
|
98
|
+
line: Drawable[];
|
|
99
|
+
text: null;
|
|
100
|
+
image: null;
|
|
101
|
+
frame: null;
|
|
102
|
+
};
|