@excalidraw/math 0.18.0-a9ca16e → 0.18.0-ab0255f
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 +297 -99
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/colors.d.ts +17 -1
- package/dist/types/common/src/constants.d.ts +12 -7
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/utils.d.ts +1 -43
- package/dist/types/element/src/Scene.d.ts +6 -4
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrows/focus.d.ts +5 -2
- package/dist/types/element/src/binding.d.ts +17 -8
- package/dist/types/element/src/bounds.d.ts +22 -7
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +5 -4
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/distribute.d.ts +2 -2
- package/dist/types/element/src/dragElements.d.ts +27 -0
- package/dist/types/element/src/duplicate.d.ts +4 -3
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +7 -7
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +9 -8
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +4 -1
- package/dist/types/element/src/linearElementEditor.d.ts +17 -10
- package/dist/types/element/src/newElement.d.ts +14 -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 +6 -6
- package/dist/types/element/src/shape.d.ts +13 -1
- package/dist/types/element/src/textElement.d.ts +12 -9
- package/dist/types/element/src/transform.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +26 -25
- package/dist/types/element/src/types.d.ts +8 -1
- package/dist/types/element/src/utils.d.ts +1 -1
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +30 -12
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +20 -8
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +132 -926
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -8
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -4
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +32 -13
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionDeselect.d.ts} +24 -33
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -4
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +21 -9
- package/dist/types/excalidraw/actions/actionExport.d.ts +22 -10
- package/dist/types/excalidraw/actions/actionFrame.d.ts +42 -196
- package/dist/types/excalidraw/actions/actionGroup.d.ts +35 -23
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +14 -6
- package/dist/types/excalidraw/actions/actionLink.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -4
- package/dist/types/excalidraw/actions/actionProperties.d.ts +50 -26
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +15 -9
- package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -4
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +14 -9
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +14 -9
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +11 -5
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +11 -5
- package/dist/types/excalidraw/actions/index.d.ts +2 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +7 -5
- package/dist/types/excalidraw/components/Actions.d.ts +17 -12
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +34 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +355 -65
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -3
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +6 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -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/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +4 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- 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/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +146 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +3 -1
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +8 -4
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +24 -12
- package/dist/types/excalidraw/data/index.d.ts +4 -4
- package/dist/types/excalidraw/data/json.d.ts +18 -12
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- 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 +426 -19
- 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 +4 -3
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/types.d.ts +368 -19
- package/dist/types/excalidraw/viewport.d.ts +272 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- 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 +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +4 -1
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +1 -0
- package/dist/types/math/src/polygon.d.ts +25 -1
- 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/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/shapes.d.ts +0 -263
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -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, ExcalidrawArrowElement, 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";
|
|
@@ -84,7 +85,7 @@ export type BinaryFileData = {
|
|
|
84
85
|
};
|
|
85
86
|
export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
|
|
86
87
|
export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
|
|
87
|
-
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
|
|
88
|
+
export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser" | "autoshape" | "bucketfill";
|
|
88
89
|
export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
|
|
89
90
|
export type ActiveTool = {
|
|
90
91
|
type: ToolType;
|
|
@@ -138,7 +139,9 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
138
139
|
newElement: AppState["newElement"];
|
|
139
140
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
140
141
|
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
142
|
+
gridModeEnabled: AppState["gridModeEnabled"];
|
|
141
143
|
suggestedBinding: AppState["suggestedBinding"];
|
|
144
|
+
hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];
|
|
142
145
|
isRotating: AppState["isRotating"];
|
|
143
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
144
147
|
collaborators: AppState["collaborators"];
|
|
@@ -172,6 +175,42 @@ export type ObservedElementsAppState = {
|
|
|
172
175
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
173
176
|
activeLockedId: AppState["activeLockedId"];
|
|
174
177
|
};
|
|
178
|
+
export type BoxSelectionMode = "contain" | "overlap";
|
|
179
|
+
/**
|
|
180
|
+
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
181
|
+
*
|
|
182
|
+
* This is a private type. For public API, only use specific properties,
|
|
183
|
+
* needed.
|
|
184
|
+
*/
|
|
185
|
+
export type ScrollConstraints = {
|
|
186
|
+
x: number;
|
|
187
|
+
y: number;
|
|
188
|
+
width: number;
|
|
189
|
+
height: number;
|
|
190
|
+
/** when set, panning is constrained so the viewport stays within the box */
|
|
191
|
+
lockScroll: boolean;
|
|
192
|
+
/** when set, the viewport cannot zoom out below `zoom` */
|
|
193
|
+
lockZoom: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The zoom resolved after the `setViewport` navigation settled.
|
|
196
|
+
*/
|
|
197
|
+
zoom: number;
|
|
198
|
+
/**
|
|
199
|
+
* Pixel amount the viewport may overscroll past its resting clamp before
|
|
200
|
+
* snapping back (rubberband). Screen pixels, zoom-independent. Resolved
|
|
201
|
+
* from `lock.overscroll` at the time the lock was installed (`true` →
|
|
202
|
+
* default give, `false` → 0).
|
|
203
|
+
*/
|
|
204
|
+
overscroll: number;
|
|
205
|
+
/**
|
|
206
|
+
* Extra scrollable margin around the box (CSS-style), letting the viewport
|
|
207
|
+
* scroll past each box edge to reveal that much empty space. Values are
|
|
208
|
+
* viewport pixels and zoom-independent (a fixed on-screen distance).
|
|
209
|
+
* Resolved from the `offsets` passed to `setViewport` (see
|
|
210
|
+
* {@link ViewportOffsets}) at the time the lock was installed.
|
|
211
|
+
*/
|
|
212
|
+
offsets?: Offsets;
|
|
213
|
+
};
|
|
175
214
|
export interface AppState {
|
|
176
215
|
contextMenu: {
|
|
177
216
|
items: ContextMenuItems;
|
|
@@ -210,15 +249,29 @@ export interface AppState {
|
|
|
210
249
|
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
211
250
|
*/
|
|
212
251
|
isBindingEnabled: boolean;
|
|
252
|
+
/** user box selection preference; defaults to "contain" when unset */
|
|
253
|
+
boxSelectionMode: BoxSelectionMode;
|
|
213
254
|
/** user arrow binding preference */
|
|
214
255
|
bindingPreference: "enabled" | "disabled";
|
|
215
256
|
/** user preference whether arrow snap to midpoints while binding */
|
|
216
257
|
isMidpointSnappingEnabled: boolean;
|
|
217
|
-
|
|
258
|
+
/**
|
|
259
|
+
* The bindable element the UI highlights for the user when an arrow is
|
|
260
|
+
* dragged or otherwise its endpoint being close to said element.
|
|
261
|
+
*/
|
|
218
262
|
suggestedBinding: {
|
|
219
263
|
element: NonDeleted<ExcalidrawBindableElement>;
|
|
220
264
|
midPoint?: GlobalPoint;
|
|
221
265
|
} | null;
|
|
266
|
+
/**
|
|
267
|
+
* Where on a hovered arrow the text tool would attach text if clicked —
|
|
268
|
+
* a free endpoint (binds the arrow to a new text element positioned against
|
|
269
|
+
* that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
|
|
270
|
+
*/
|
|
271
|
+
hoveredArrowTextAnchor: {
|
|
272
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
273
|
+
anchor: "start" | "end" | "label";
|
|
274
|
+
} | null;
|
|
222
275
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
223
276
|
frameRendering: {
|
|
224
277
|
enabled: boolean;
|
|
@@ -226,8 +279,11 @@ export interface AppState {
|
|
|
226
279
|
outline: boolean;
|
|
227
280
|
clip: boolean;
|
|
228
281
|
};
|
|
229
|
-
|
|
230
|
-
|
|
282
|
+
/**
|
|
283
|
+
* frame-like element whose name is currently being edited
|
|
284
|
+
*/
|
|
285
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
286
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
231
287
|
/**
|
|
232
288
|
* set when a new text is created or when an existing text is being edited
|
|
233
289
|
*/
|
|
@@ -254,9 +310,10 @@ export interface AppState {
|
|
|
254
310
|
currentItemStrokeColor: string;
|
|
255
311
|
currentItemBackgroundColor: string;
|
|
256
312
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
257
|
-
|
|
313
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
258
314
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
259
315
|
currentItemRoughness: number;
|
|
316
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
260
317
|
currentItemOpacity: number;
|
|
261
318
|
currentItemFontFamily: FontFamilyValues;
|
|
262
319
|
currentItemFontSize: number;
|
|
@@ -269,6 +326,7 @@ export interface AppState {
|
|
|
269
326
|
viewBackgroundColor: string;
|
|
270
327
|
scrollX: number;
|
|
271
328
|
scrollY: number;
|
|
329
|
+
scrollConstraints: ScrollConstraints | null;
|
|
272
330
|
cursorButton: "up" | "down";
|
|
273
331
|
scrolledOutside: boolean;
|
|
274
332
|
name: string | null;
|
|
@@ -386,7 +444,7 @@ export type SearchMatch = {
|
|
|
386
444
|
showOnCanvas: boolean;
|
|
387
445
|
}[];
|
|
388
446
|
};
|
|
389
|
-
export type UIAppState = Omit<AppState, "
|
|
447
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
|
|
390
448
|
export type NormalizedZoomValue = number & {
|
|
391
449
|
_brand: "normalizedZoom";
|
|
392
450
|
};
|
|
@@ -430,6 +488,9 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
430
488
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
431
489
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
432
490
|
}>;
|
|
491
|
+
export type ExcalidrawInitialState = {
|
|
492
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
493
|
+
};
|
|
433
494
|
export type OnUserFollowedPayload = {
|
|
434
495
|
userToFollow: UserToFollow;
|
|
435
496
|
action: "FOLLOW" | "UNFOLLOW";
|
|
@@ -440,13 +501,120 @@ export type OnExportProgress = {
|
|
|
440
501
|
/** 0-1 range */
|
|
441
502
|
progress?: number;
|
|
442
503
|
};
|
|
504
|
+
export type InteractionConfig = {
|
|
505
|
+
/**
|
|
506
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
507
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
508
|
+
*/
|
|
509
|
+
enabled?: {
|
|
510
|
+
/**
|
|
511
|
+
* Element links render their link icon and stay clickable — clicking
|
|
512
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
513
|
+
* When disabled, link icons are not rendered at all.
|
|
514
|
+
*
|
|
515
|
+
* @default false
|
|
516
|
+
*/
|
|
517
|
+
links?: boolean;
|
|
518
|
+
/**
|
|
519
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
520
|
+
* activates them so their content can be used, same as in view mode.
|
|
521
|
+
*
|
|
522
|
+
* @default false
|
|
523
|
+
*/
|
|
524
|
+
embeds?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
527
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
528
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
529
|
+
* regardless of their individual values.
|
|
530
|
+
*
|
|
531
|
+
* @default false
|
|
532
|
+
*/
|
|
533
|
+
interactiveContent?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
536
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
537
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
538
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
539
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
540
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
541
|
+
* page no longer scrolls over the editor.
|
|
542
|
+
*
|
|
543
|
+
* @default false
|
|
544
|
+
*/
|
|
545
|
+
navigation?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
548
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
549
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
550
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
551
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
552
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
553
|
+
*
|
|
554
|
+
* @default false
|
|
555
|
+
*/
|
|
556
|
+
browserZoom?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
559
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
560
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
561
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
562
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
563
|
+
*
|
|
564
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
565
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
566
|
+
*/
|
|
567
|
+
tools?: {
|
|
568
|
+
/**
|
|
569
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
570
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
571
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
572
|
+
*
|
|
573
|
+
* @default false
|
|
574
|
+
*/
|
|
575
|
+
laser?: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
578
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
579
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
580
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
581
|
+
* after the first pointer interaction.
|
|
582
|
+
*
|
|
583
|
+
* @default false
|
|
584
|
+
*/
|
|
585
|
+
custom?: boolean;
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
export type UIConfig = {
|
|
590
|
+
/**
|
|
591
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
592
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is disabled.
|
|
593
|
+
*/
|
|
594
|
+
enabled: {
|
|
595
|
+
/**
|
|
596
|
+
* The zoom-out, reset-zoom, and zoom-in controls.
|
|
597
|
+
*
|
|
598
|
+
* @default false
|
|
599
|
+
*/
|
|
600
|
+
zoom?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* The button shown when the viewport is scrolled away from all content.
|
|
603
|
+
*
|
|
604
|
+
* @default false
|
|
605
|
+
*/
|
|
606
|
+
scrollBackToContent?: boolean;
|
|
607
|
+
};
|
|
608
|
+
};
|
|
443
609
|
export interface ExcalidrawProps {
|
|
444
610
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
611
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
445
612
|
/**
|
|
446
613
|
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
447
614
|
*/
|
|
448
615
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
449
616
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
617
|
+
initialState?: ExcalidrawInitialState;
|
|
450
618
|
/**
|
|
451
619
|
* Invoked as soon as the Excalidraw API is available
|
|
452
620
|
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
@@ -493,6 +661,70 @@ export interface ExcalidrawProps {
|
|
|
493
661
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
494
662
|
langCode?: Language["code"];
|
|
495
663
|
viewModeEnabled?: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
666
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
667
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
668
|
+
* in any way. Implies view mode.
|
|
669
|
+
*
|
|
670
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
671
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
672
|
+
*
|
|
673
|
+
* ```tsx
|
|
674
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @default true
|
|
678
|
+
*/
|
|
679
|
+
interaction?: boolean | InteractionConfig;
|
|
680
|
+
/**
|
|
681
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
682
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
683
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
684
|
+
* or render props continues to render, together with any supporting dialogs
|
|
685
|
+
* it opens.
|
|
686
|
+
*
|
|
687
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
688
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
689
|
+
* `false`.
|
|
690
|
+
*
|
|
691
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
692
|
+
* rest of the default UI is hidden (see `UIConfig`):
|
|
693
|
+
*
|
|
694
|
+
* ```tsx
|
|
695
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
699
|
+
* may yet change.
|
|
700
|
+
*
|
|
701
|
+
* @default true
|
|
702
|
+
*/
|
|
703
|
+
ui?: boolean | UIConfig;
|
|
704
|
+
/**
|
|
705
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
706
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
707
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
708
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
709
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
710
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
711
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
712
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
713
|
+
* tool control to the editor (the current tool stays active).
|
|
714
|
+
*
|
|
715
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
716
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
717
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
718
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
719
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
720
|
+
* activation opens the file picker).
|
|
721
|
+
*/
|
|
722
|
+
activeTool?: {
|
|
723
|
+
type: Exclude<ToolType, "image">;
|
|
724
|
+
} | {
|
|
725
|
+
type: "custom";
|
|
726
|
+
customType: string;
|
|
727
|
+
};
|
|
496
728
|
zenModeEnabled?: boolean;
|
|
497
729
|
gridModeEnabled?: boolean;
|
|
498
730
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -501,6 +733,10 @@ export interface ExcalidrawProps {
|
|
|
501
733
|
name?: string;
|
|
502
734
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
503
735
|
UIOptions?: Partial<UIOptions>;
|
|
736
|
+
/**
|
|
737
|
+
* dimensions and size constraints for inserted images
|
|
738
|
+
*/
|
|
739
|
+
imageOptions?: ImageOptions;
|
|
504
740
|
detectScroll?: boolean;
|
|
505
741
|
handleKeyboardGlobally?: boolean;
|
|
506
742
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -555,12 +791,21 @@ export type ExportOpts = {
|
|
|
555
791
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
556
792
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
557
793
|
};
|
|
794
|
+
export type ImageOptions = Partial<{
|
|
795
|
+
maxWidthOrHeight: number;
|
|
796
|
+
maxFileSizeBytes: number;
|
|
797
|
+
}>;
|
|
558
798
|
export type CanvasActions = Partial<{
|
|
559
799
|
changeViewBackgroundColor: boolean;
|
|
560
800
|
clearCanvas: boolean;
|
|
561
801
|
export: false | ExportOpts;
|
|
562
802
|
loadScene: boolean;
|
|
563
803
|
saveToActiveFile: boolean;
|
|
804
|
+
/**
|
|
805
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
806
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
807
|
+
* else default to false
|
|
808
|
+
* */
|
|
564
809
|
toggleTheme: boolean | null;
|
|
565
810
|
saveAsImage: boolean;
|
|
566
811
|
}>;
|
|
@@ -584,6 +829,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
584
829
|
export: ExportOpts;
|
|
585
830
|
};
|
|
586
831
|
}>;
|
|
832
|
+
imageOptions: Required<ImageOptions>;
|
|
587
833
|
detectScroll: boolean;
|
|
588
834
|
handleKeyboardGlobally: boolean;
|
|
589
835
|
isCollaborating: boolean;
|
|
@@ -615,8 +861,7 @@ export type AppClassProperties = {
|
|
|
615
861
|
id: App["id"];
|
|
616
862
|
onInsertElements: App["onInsertElements"];
|
|
617
863
|
onExportImage: App["onExportImage"];
|
|
618
|
-
|
|
619
|
-
scrollToContent: App["scrollToContent"];
|
|
864
|
+
viewport: App["viewport"];
|
|
620
865
|
addFiles: App["addFiles"];
|
|
621
866
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
622
867
|
togglePenMode: App["togglePenMode"];
|
|
@@ -627,11 +872,13 @@ export type AppClassProperties = {
|
|
|
627
872
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
628
873
|
getName: App["getName"];
|
|
629
874
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
630
|
-
|
|
875
|
+
flowchart: App["flowchart"];
|
|
876
|
+
drawShape: App["drawShape"];
|
|
877
|
+
cursor: App["cursor"];
|
|
878
|
+
isToolLocked: App["isToolLocked"];
|
|
631
879
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
632
880
|
setPlugins: App["setPlugins"];
|
|
633
881
|
plugins: App["plugins"];
|
|
634
|
-
getEditorUIOffsets: App["getEditorUIOffsets"];
|
|
635
882
|
visibleElements: App["visibleElements"];
|
|
636
883
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
637
884
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
@@ -640,8 +887,11 @@ export type AppClassProperties = {
|
|
|
640
887
|
onEvent: App["onEvent"];
|
|
641
888
|
onStateChange: App["onStateChange"];
|
|
642
889
|
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
890
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
643
891
|
bindModeHandler: App["bindModeHandler"];
|
|
644
892
|
setAppState: App["setAppState"];
|
|
893
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
894
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
645
895
|
};
|
|
646
896
|
export type PointerDownState = Readonly<{
|
|
647
897
|
origin: Readonly<{
|
|
@@ -728,15 +978,16 @@ export interface ExcalidrawImperativeAPI {
|
|
|
728
978
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
729
979
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
730
980
|
getName: InstanceType<typeof App>["getName"];
|
|
731
|
-
|
|
981
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
982
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
732
983
|
registerAction: (action: Action) => void;
|
|
733
984
|
refresh: InstanceType<typeof App>["refresh"];
|
|
734
985
|
setToast: InstanceType<typeof App>["setToast"];
|
|
735
986
|
addFiles: (data: BinaryFileData[]) => void;
|
|
736
987
|
id: string;
|
|
737
988
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
738
|
-
setCursor: InstanceType<typeof App>["
|
|
739
|
-
resetCursor: InstanceType<typeof App>["
|
|
989
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
990
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
740
991
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
741
992
|
getEditorInterface: () => EditorInterface;
|
|
742
993
|
/**
|
|
@@ -759,7 +1010,6 @@ export type FrameNameBounds = {
|
|
|
759
1010
|
y: number;
|
|
760
1011
|
width: number;
|
|
761
1012
|
height: number;
|
|
762
|
-
angle: number;
|
|
763
1013
|
};
|
|
764
1014
|
export type FrameNameBoundsCache = {
|
|
765
1015
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -778,12 +1028,12 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
778
1028
|
export type JSONValue = string | number | boolean | null | object;
|
|
779
1029
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
780
1030
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
781
|
-
export type PendingExcalidrawElements =
|
|
1031
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
782
1032
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
783
1033
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
784
1034
|
export type GenerateDiagramToCode = (props: {
|
|
785
|
-
frame: ExcalidrawMagicFrameElement
|
|
786
|
-
children: readonly
|
|
1035
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
1036
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
787
1037
|
}) => MaybePromise<{
|
|
788
1038
|
html: string;
|
|
789
1039
|
}>;
|
|
@@ -793,3 +1043,102 @@ export type Offsets = Partial<{
|
|
|
793
1043
|
bottom: number;
|
|
794
1044
|
left: number;
|
|
795
1045
|
}>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
1048
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
1049
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
1050
|
+
*
|
|
1051
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
1052
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
1053
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
1054
|
+
* lies in the left half of the viewport it counts against the left
|
|
1055
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
1056
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
1057
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
1058
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
1059
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
1060
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
1061
|
+
* would swallow most of the viewport).
|
|
1062
|
+
*
|
|
1063
|
+
* The attribute should only be present while the surface is actually
|
|
1064
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
1065
|
+
* push the viewport around.
|
|
1066
|
+
*/
|
|
1067
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
1068
|
+
/**
|
|
1069
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
1070
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
1071
|
+
* currently rendered editor UI.
|
|
1072
|
+
*
|
|
1073
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
1074
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
1075
|
+
* reading-direction start side).
|
|
1076
|
+
*/
|
|
1077
|
+
export type ViewportOffsetsOptions = {
|
|
1078
|
+
/** padding added to each measured side (default 24) */
|
|
1079
|
+
padding?: number;
|
|
1080
|
+
paddingTop?: number;
|
|
1081
|
+
paddingRight?: number;
|
|
1082
|
+
paddingBottom?: number;
|
|
1083
|
+
paddingLeft?: number;
|
|
1084
|
+
/** final value for the given side, replacing the measured UI size
|
|
1085
|
+
* (padding is not added on top) */
|
|
1086
|
+
top?: number;
|
|
1087
|
+
bottom?: number;
|
|
1088
|
+
left?: number;
|
|
1089
|
+
right?: number;
|
|
1090
|
+
/**
|
|
1091
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
1092
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
1093
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
1094
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
1095
|
+
* phones (where these surfaces never occlude the canvas).
|
|
1096
|
+
*/
|
|
1097
|
+
reserve?: {
|
|
1098
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
1099
|
+
stylesPanel?: boolean;
|
|
1100
|
+
/** sidebar (e.g. library) */
|
|
1101
|
+
sidebar?: boolean;
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
1106
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
1107
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
1108
|
+
*
|
|
1109
|
+
* Two (combinable) ways to specify:
|
|
1110
|
+
*
|
|
1111
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
1112
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
1113
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
1114
|
+
* set, see below).
|
|
1115
|
+
*
|
|
1116
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
1117
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
1118
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
1119
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
1120
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
1121
|
+
*
|
|
1122
|
+
* When both are given, a static side always wins for that side — it
|
|
1123
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
1124
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
1125
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* { top: 40 } // top 40px, other sides 0
|
|
1129
|
+
* { ui: true } // measured UI + default padding
|
|
1130
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
1131
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
1132
|
+
*/
|
|
1133
|
+
export type ViewportOffsets = Offsets & {
|
|
1134
|
+
ui?: true | ViewportOffsetsOptions;
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1138
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1139
|
+
* `getViewportOffsets` can reserve space for it while it's hidden (see the
|
|
1140
|
+
* `reserve` option). Whenever a named surface is rendered, its measured
|
|
1141
|
+
* footprint is remembered; reserving uses that remembered footprint, or an
|
|
1142
|
+
* approximate default if the surface hasn't been rendered yet.
|
|
1143
|
+
*/
|
|
1144
|
+
export type ViewportUIName = "sidebar" | "stylesPanel";
|