@excalidraw/math 0.18.0-0457ac9 → 0.18.0-063e025
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/types/common/src/colors.d.ts +1 -1
- package/dist/types/common/src/constants.d.ts +9 -7
- package/dist/types/common/src/utils.d.ts +0 -42
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/binding.d.ts +6 -6
- package/dist/types/element/src/bounds.d.ts +19 -6
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +1 -0
- package/dist/types/element/src/distribute.d.ts +2 -2
- package/dist/types/element/src/duplicate.d.ts +3 -3
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +3 -3
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +4 -4
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +1 -1
- package/dist/types/element/src/linearElementEditor.d.ts +10 -10
- package/dist/types/element/src/newElement.d.ts +1 -0
- package/dist/types/element/src/renderElement.d.ts +0 -3
- package/dist/types/element/src/resizeElements.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +5 -5
- package/dist/types/element/src/textElement.d.ts +7 -7
- package/dist/types/element/src/transform.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +25 -25
- package/dist/types/element/src/types.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +61 -389
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -7
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +9 -5
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionFrame.d.ts +29 -20
- package/dist/types/excalidraw/actions/actionGroup.d.ts +23 -19
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +7 -4
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +35 -22
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +9 -7
- package/dist/types/excalidraw/actions/actionStyles.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +8 -7
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -7
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -3
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +4 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +2 -3
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +61 -32
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +6 -3
- package/dist/types/excalidraw/data/blob.d.ts +8 -4
- package/dist/types/excalidraw/data/index.d.ts +4 -4
- package/dist/types/excalidraw/data/json.d.ts +10 -8
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
- package/dist/types/excalidraw/scene/Renderer.d.ts +12 -11
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +1 -3
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/types.d.ts +168 -11
- package/dist/types/excalidraw/viewport.d.ts +316 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +35 -0
- package/dist/types/utils/src/export.d.ts +3 -3
- package/dist/types/utils/src/index.d.ts +1 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
1
|
+
import type { ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
2
2
|
import type { AppState, BinaryFiles } from "../types";
|
|
3
3
|
export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, exportingFrame, }: {
|
|
4
4
|
exportBackground: boolean;
|
|
5
5
|
exportPadding?: number;
|
|
6
6
|
viewBackgroundColor: string;
|
|
7
|
-
exportingFrame?: ExcalidrawFrameLikeElement | null;
|
|
7
|
+
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
8
8
|
}, createCanvas?: (width: number, height: number) => {
|
|
9
9
|
canvas: HTMLCanvasElement;
|
|
10
10
|
scale: number;
|
|
@@ -22,7 +22,7 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
|
|
|
22
22
|
* if true, all embeddables passed in will be rendered when possible.
|
|
23
23
|
*/
|
|
24
24
|
renderEmbeddables?: boolean;
|
|
25
|
-
exportingFrame?: ExcalidrawFrameLikeElement | null;
|
|
25
|
+
exportingFrame?: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
26
26
|
skipInliningFonts?: true;
|
|
27
27
|
reuseImages?: boolean;
|
|
28
28
|
}) => Promise<SVGSVGElement>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { isSomeElementSelected, getElementsWithinSelection, getSelectedElements, getTargetElements, } from "@excalidraw/element";
|
|
2
|
-
export {
|
|
3
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
2
|
+
export { getScrollToContentState } from "../viewport";
|
|
3
|
+
export { hasBackground, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
4
4
|
export { getNormalizedZoom, getNormalizedGridSize, getNormalizedGridStep, } from "./normalize";
|
|
@@ -52,8 +52,6 @@ export type InteractiveCanvasRenderConfig = {
|
|
|
52
52
|
renderScrollbars?: boolean;
|
|
53
53
|
};
|
|
54
54
|
export type RenderInteractiveSceneCallback = {
|
|
55
|
-
atLeastOneVisibleElement: boolean;
|
|
56
|
-
elementsMap: RenderableElementsMap;
|
|
57
55
|
scrollBars?: ScrollBars;
|
|
58
56
|
};
|
|
59
57
|
export type StaticSceneRenderConfig = {
|
|
@@ -89,7 +87,7 @@ export type InteractiveSceneRenderConfig = {
|
|
|
89
87
|
export type NewElementSceneRenderConfig = {
|
|
90
88
|
canvas: HTMLCanvasElement | null;
|
|
91
89
|
rc: RoughCanvas;
|
|
92
|
-
newElement:
|
|
90
|
+
newElement: NonDeletedExcalidrawElement | null;
|
|
93
91
|
elementsMap: RenderableElementsMap;
|
|
94
92
|
allElementsMap: NonDeletedSceneElementsMap;
|
|
95
93
|
scale: number;
|
|
@@ -66,19 +66,19 @@ export declare const isGridModeEnabled: (app: AppClassProperties) => boolean;
|
|
|
66
66
|
export declare const isSnappingEnabled: ({ event, app, selectedElements, }: {
|
|
67
67
|
app: AppClassProperties;
|
|
68
68
|
event: KeyboardModifiersObject;
|
|
69
|
-
selectedElements: NonDeletedExcalidrawElement[];
|
|
69
|
+
selectedElements: readonly NonDeletedExcalidrawElement[];
|
|
70
70
|
}) => boolean;
|
|
71
71
|
export declare const areRoughlyEqual: (a: number, b: number, precision?: number) => boolean;
|
|
72
|
-
export declare const getElementsCorners: (elements:
|
|
72
|
+
export declare const getElementsCorners: (elements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, { omitCenter, boundingBoxCorners, dragOffset, }?: {
|
|
73
73
|
omitCenter?: boolean;
|
|
74
74
|
boundingBoxCorners?: boolean;
|
|
75
75
|
dragOffset?: Vector2D;
|
|
76
76
|
}) => GlobalPoint[];
|
|
77
|
-
export declare const getVisibleGaps: (elements: readonly NonDeletedExcalidrawElement[], selectedElements:
|
|
77
|
+
export declare const getVisibleGaps: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => {
|
|
78
78
|
horizontalGaps: Gap[];
|
|
79
79
|
verticalGaps: Gap[];
|
|
80
80
|
};
|
|
81
|
-
export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements:
|
|
81
|
+
export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => GlobalPoint[];
|
|
82
82
|
export declare const snapDraggedElements: (elements: ExcalidrawElement[], dragOffset: Vector2D, app: AppClassProperties, event: KeyboardModifiersObject, elementsMap: ElementsMap) => {
|
|
83
83
|
snapOffset: {
|
|
84
84
|
x: number;
|
|
@@ -86,21 +86,21 @@ export declare const snapDraggedElements: (elements: ExcalidrawElement[], dragOf
|
|
|
86
86
|
};
|
|
87
87
|
snapLines: (PointSnapLine | GapSnapLine)[];
|
|
88
88
|
};
|
|
89
|
-
export declare const snapResizingElements: (selectedElements:
|
|
89
|
+
export declare const snapResizingElements: (selectedElements: readonly NonDeletedExcalidrawElement[], selectedOriginalElements: readonly NonDeletedExcalidrawElement[], app: AppClassProperties, event: KeyboardModifiersObject, dragOffset: Vector2D, transformHandle: MaybeTransformHandleType) => {
|
|
90
90
|
snapOffset: {
|
|
91
91
|
x: number;
|
|
92
92
|
y: number;
|
|
93
93
|
};
|
|
94
94
|
snapLines: PointSnapLine[];
|
|
95
95
|
};
|
|
96
|
-
export declare const snapNewElement: (newElement:
|
|
96
|
+
export declare const snapNewElement: (newElement: NonDeletedExcalidrawElement, app: AppClassProperties, event: KeyboardModifiersObject, origin: Vector2D, dragOffset: Vector2D, elementsMap: ElementsMap) => {
|
|
97
97
|
snapOffset: {
|
|
98
98
|
x: number;
|
|
99
99
|
y: number;
|
|
100
100
|
};
|
|
101
101
|
snapLines: PointSnapLine[];
|
|
102
102
|
};
|
|
103
|
-
export declare const getSnapLinesAtPointer: (elements: readonly
|
|
103
|
+
export declare const getSnapLinesAtPointer: (elements: readonly NonDeletedExcalidrawElement[], app: AppClassProperties, pointer: Vector2D, event: KeyboardModifiersObject, elementsMap: ElementsMap) => {
|
|
104
104
|
originOffset: {
|
|
105
105
|
x: number;
|
|
106
106
|
y: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
|
|
1
|
+
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
|
|
2
2
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
3
3
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
4
|
-
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
4
|
+
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
|
|
5
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
6
6
|
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
7
|
import type { GlobalPoint } from "@excalidraw/math";
|
|
@@ -13,6 +13,7 @@ import type Library from "./data/library";
|
|
|
13
13
|
import type { ContextMenuItems } from "./components/ContextMenu";
|
|
14
14
|
import type { SnapLine } from "./snapping";
|
|
15
15
|
import type { ImportedDataState } from "./data/types";
|
|
16
|
+
import type { SetViewportOptions } from "./viewport";
|
|
16
17
|
import type { Language } from "./i18n";
|
|
17
18
|
import type { isOverScrollBars } from "./scene/scrollbars";
|
|
18
19
|
import type React from "react";
|
|
@@ -173,6 +174,41 @@ export type ObservedElementsAppState = {
|
|
|
173
174
|
activeLockedId: AppState["activeLockedId"];
|
|
174
175
|
};
|
|
175
176
|
export type BoxSelectionMode = "contain" | "overlap";
|
|
177
|
+
/**
|
|
178
|
+
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
179
|
+
*
|
|
180
|
+
* This is a private type. For public API, only use specific properties,
|
|
181
|
+
* needed.
|
|
182
|
+
*/
|
|
183
|
+
export type ScrollConstraints = {
|
|
184
|
+
x: number;
|
|
185
|
+
y: number;
|
|
186
|
+
width: number;
|
|
187
|
+
height: number;
|
|
188
|
+
/** when set, panning is constrained so the viewport stays within the box */
|
|
189
|
+
lockScroll: boolean;
|
|
190
|
+
/** when set, the viewport cannot zoom out below `zoom` */
|
|
191
|
+
lockZoom: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* The zoom resolved after the `setViewport` navigation settled.
|
|
194
|
+
*/
|
|
195
|
+
zoom: number;
|
|
196
|
+
/**
|
|
197
|
+
* Pixel amount the viewport may overscroll past its resting clamp before
|
|
198
|
+
* snapping back (rubberband). Screen pixels, zoom-independent. Resolved
|
|
199
|
+
* from `lock.overscroll` at the time the lock was installed (`true` →
|
|
200
|
+
* default give, `false` → 0).
|
|
201
|
+
*/
|
|
202
|
+
overscroll: number;
|
|
203
|
+
/**
|
|
204
|
+
* Extra scrollable margin around the box (CSS-style), letting the viewport
|
|
205
|
+
* scroll past each box edge to reveal that much empty space. Values are
|
|
206
|
+
* viewport pixels and zoom-independent (a fixed on-screen distance).
|
|
207
|
+
* Resolved from the `offsets` passed to `setViewport` (see
|
|
208
|
+
* {@link ViewportOffsets}) at the time the lock was installed.
|
|
209
|
+
*/
|
|
210
|
+
offsets?: Offsets;
|
|
211
|
+
};
|
|
176
212
|
export interface AppState {
|
|
177
213
|
contextMenu: {
|
|
178
214
|
items: ContextMenuItems;
|
|
@@ -233,7 +269,7 @@ export interface AppState {
|
|
|
233
269
|
clip: boolean;
|
|
234
270
|
};
|
|
235
271
|
editingFrame: string | null;
|
|
236
|
-
elementsToHighlight:
|
|
272
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
237
273
|
/**
|
|
238
274
|
* set when a new text is created or when an existing text is being edited
|
|
239
275
|
*/
|
|
@@ -260,9 +296,10 @@ export interface AppState {
|
|
|
260
296
|
currentItemStrokeColor: string;
|
|
261
297
|
currentItemBackgroundColor: string;
|
|
262
298
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
263
|
-
|
|
299
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
264
300
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
265
301
|
currentItemRoughness: number;
|
|
302
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
266
303
|
currentItemOpacity: number;
|
|
267
304
|
currentItemFontFamily: FontFamilyValues;
|
|
268
305
|
currentItemFontSize: number;
|
|
@@ -275,6 +312,7 @@ export interface AppState {
|
|
|
275
312
|
viewBackgroundColor: string;
|
|
276
313
|
scrollX: number;
|
|
277
314
|
scrollY: number;
|
|
315
|
+
scrollConstraints: ScrollConstraints | null;
|
|
278
316
|
cursorButton: "up" | "down";
|
|
279
317
|
scrolledOutside: boolean;
|
|
280
318
|
name: string | null;
|
|
@@ -392,7 +430,7 @@ export type SearchMatch = {
|
|
|
392
430
|
showOnCanvas: boolean;
|
|
393
431
|
}[];
|
|
394
432
|
};
|
|
395
|
-
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY">;
|
|
433
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "frameToHighlight" | "elementsToHighlight">;
|
|
396
434
|
export type NormalizedZoomValue = number & {
|
|
397
435
|
_brand: "normalizedZoom";
|
|
398
436
|
};
|
|
@@ -436,6 +474,9 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
436
474
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
437
475
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
438
476
|
}>;
|
|
477
|
+
export type ExcalidrawInitialState = {
|
|
478
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
479
|
+
};
|
|
439
480
|
export type OnUserFollowedPayload = {
|
|
440
481
|
userToFollow: UserToFollow;
|
|
441
482
|
action: "FOLLOW" | "UNFOLLOW";
|
|
@@ -448,11 +489,13 @@ export type OnExportProgress = {
|
|
|
448
489
|
};
|
|
449
490
|
export interface ExcalidrawProps {
|
|
450
491
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
492
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
451
493
|
/**
|
|
452
494
|
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
453
495
|
*/
|
|
454
496
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
455
497
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
498
|
+
initialState?: ExcalidrawInitialState;
|
|
456
499
|
/**
|
|
457
500
|
* Invoked as soon as the Excalidraw API is available
|
|
458
501
|
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
@@ -507,6 +550,10 @@ export interface ExcalidrawProps {
|
|
|
507
550
|
name?: string;
|
|
508
551
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
509
552
|
UIOptions?: Partial<UIOptions>;
|
|
553
|
+
/**
|
|
554
|
+
* dimensions and size constraints for inserted images
|
|
555
|
+
*/
|
|
556
|
+
imageOptions?: ImageOptions;
|
|
510
557
|
detectScroll?: boolean;
|
|
511
558
|
handleKeyboardGlobally?: boolean;
|
|
512
559
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -561,12 +608,21 @@ export type ExportOpts = {
|
|
|
561
608
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
562
609
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
563
610
|
};
|
|
611
|
+
export type ImageOptions = Partial<{
|
|
612
|
+
maxWidthOrHeight: number;
|
|
613
|
+
maxFileSizeBytes: number;
|
|
614
|
+
}>;
|
|
564
615
|
export type CanvasActions = Partial<{
|
|
565
616
|
changeViewBackgroundColor: boolean;
|
|
566
617
|
clearCanvas: boolean;
|
|
567
618
|
export: false | ExportOpts;
|
|
568
619
|
loadScene: boolean;
|
|
569
620
|
saveToActiveFile: boolean;
|
|
621
|
+
/**
|
|
622
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
623
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
624
|
+
* else default to false
|
|
625
|
+
* */
|
|
570
626
|
toggleTheme: boolean | null;
|
|
571
627
|
saveAsImage: boolean;
|
|
572
628
|
}>;
|
|
@@ -590,6 +646,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
590
646
|
export: ExportOpts;
|
|
591
647
|
};
|
|
592
648
|
}>;
|
|
649
|
+
imageOptions: Required<ImageOptions>;
|
|
593
650
|
detectScroll: boolean;
|
|
594
651
|
handleKeyboardGlobally: boolean;
|
|
595
652
|
isCollaborating: boolean;
|
|
@@ -622,7 +679,7 @@ export type AppClassProperties = {
|
|
|
622
679
|
onInsertElements: App["onInsertElements"];
|
|
623
680
|
onExportImage: App["onExportImage"];
|
|
624
681
|
lastViewportPosition: App["lastViewportPosition"];
|
|
625
|
-
|
|
682
|
+
setViewport: App["setViewport"];
|
|
626
683
|
addFiles: App["addFiles"];
|
|
627
684
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
628
685
|
togglePenMode: App["togglePenMode"];
|
|
@@ -637,7 +694,7 @@ export type AppClassProperties = {
|
|
|
637
694
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
638
695
|
setPlugins: App["setPlugins"];
|
|
639
696
|
plugins: App["plugins"];
|
|
640
|
-
|
|
697
|
+
getViewportOffsets: App["getViewportOffsets"];
|
|
641
698
|
visibleElements: App["visibleElements"];
|
|
642
699
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
643
700
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
@@ -734,7 +791,8 @@ export interface ExcalidrawImperativeAPI {
|
|
|
734
791
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
735
792
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
736
793
|
getName: InstanceType<typeof App>["getName"];
|
|
737
|
-
|
|
794
|
+
setViewport: InstanceType<typeof App>["setViewport"];
|
|
795
|
+
getViewportOffsets: InstanceType<typeof App>["getViewportOffsets"];
|
|
738
796
|
registerAction: (action: Action) => void;
|
|
739
797
|
refresh: InstanceType<typeof App>["refresh"];
|
|
740
798
|
setToast: InstanceType<typeof App>["setToast"];
|
|
@@ -784,12 +842,12 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
784
842
|
export type JSONValue = string | number | boolean | null | object;
|
|
785
843
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
786
844
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
787
|
-
export type PendingExcalidrawElements =
|
|
845
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
788
846
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
789
847
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
790
848
|
export type GenerateDiagramToCode = (props: {
|
|
791
|
-
frame: ExcalidrawMagicFrameElement
|
|
792
|
-
children: readonly
|
|
849
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
850
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
793
851
|
}) => MaybePromise<{
|
|
794
852
|
html: string;
|
|
795
853
|
}>;
|
|
@@ -799,3 +857,102 @@ export type Offsets = Partial<{
|
|
|
799
857
|
bottom: number;
|
|
800
858
|
left: number;
|
|
801
859
|
}>;
|
|
860
|
+
/**
|
|
861
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
862
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
863
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
864
|
+
*
|
|
865
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
866
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
867
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
868
|
+
* lies in the left half of the viewport it counts against the left
|
|
869
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
870
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
871
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
872
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
873
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
874
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
875
|
+
* would swallow most of the viewport).
|
|
876
|
+
*
|
|
877
|
+
* The attribute should only be present while the surface is actually
|
|
878
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
879
|
+
* push the viewport around.
|
|
880
|
+
*/
|
|
881
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
882
|
+
/**
|
|
883
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
884
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
885
|
+
* currently rendered editor UI.
|
|
886
|
+
*
|
|
887
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
888
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
889
|
+
* reading-direction start side).
|
|
890
|
+
*/
|
|
891
|
+
export type ViewportOffsetsOptions = {
|
|
892
|
+
/** padding added to each measured side (default 24) */
|
|
893
|
+
padding?: number;
|
|
894
|
+
paddingTop?: number;
|
|
895
|
+
paddingRight?: number;
|
|
896
|
+
paddingBottom?: number;
|
|
897
|
+
paddingLeft?: number;
|
|
898
|
+
/** final value for the given side, replacing the measured UI size
|
|
899
|
+
* (padding is not added on top) */
|
|
900
|
+
top?: number;
|
|
901
|
+
bottom?: number;
|
|
902
|
+
left?: number;
|
|
903
|
+
right?: number;
|
|
904
|
+
/**
|
|
905
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
906
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
907
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
908
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
909
|
+
* phones (where these surfaces never occlude the canvas).
|
|
910
|
+
*/
|
|
911
|
+
reserve?: {
|
|
912
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
913
|
+
stylesPanel?: boolean;
|
|
914
|
+
/** sidebar (e.g. library) */
|
|
915
|
+
sidebar?: boolean;
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
920
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
921
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
922
|
+
*
|
|
923
|
+
* Two (combinable) ways to specify:
|
|
924
|
+
*
|
|
925
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
926
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
927
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
928
|
+
* set, see below).
|
|
929
|
+
*
|
|
930
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
931
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
932
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
933
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
934
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
935
|
+
*
|
|
936
|
+
* When both are given, a static side always wins for that side — it
|
|
937
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
938
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
939
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* { top: 40 } // top 40px, other sides 0
|
|
943
|
+
* { ui: true } // measured UI + default padding
|
|
944
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
945
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
946
|
+
*/
|
|
947
|
+
export type ViewportOffsets = Offsets & {
|
|
948
|
+
ui?: true | ViewportOffsetsOptions;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
952
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
953
|
+
* `getViewportOffsets` can reserve space for it while it's hidden (see the
|
|
954
|
+
* `reserve` option). Whenever a named surface is rendered, its measured
|
|
955
|
+
* footprint is remembered; reserving uses that remembered footprint, or an
|
|
956
|
+
* approximate default if the surface hasn't been rendered yet.
|
|
957
|
+
*/
|
|
958
|
+
export type ViewportUIName = "sidebar" | "stylesPanel";
|