@excalidraw/common 0.18.0-d255747 → 0.18.0-dabd83c
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 +237 -104
- package/dist/dev/index.js.map +3 -3
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/colors.d.ts +23 -1
- package/dist/types/common/src/constants.d.ts +68 -7
- package/dist/types/common/src/keys.d.ts +6 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +13 -44
- package/dist/types/element/src/Scene.d.ts +2 -2
- package/dist/types/element/src/align.d.ts +5 -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 +90 -13
- package/dist/types/element/src/bounds.d.ts +28 -7
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +21 -5
- package/dist/types/element/src/comparisons.d.ts +8 -5
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/cropElement.d.ts +36 -4
- package/dist/types/element/src/delta.d.ts +30 -2
- package/dist/types/element/src/distribute.d.ts +5 -2
- package/dist/types/element/src/dragElements.d.ts +34 -2
- package/dist/types/element/src/duplicate.d.ts +63 -3
- package/dist/types/element/src/elbowArrow.d.ts +5 -0
- package/dist/types/element/src/embeddable.d.ts +3 -2
- package/dist/types/element/src/flowchart.d.ts +9 -11
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +25 -7
- package/dist/types/element/src/groups.d.ts +10 -15
- package/dist/types/element/src/image.d.ts +5 -2
- package/dist/types/element/src/index.d.ts +7 -1
- package/dist/types/element/src/linearElementEditor.d.ts +31 -11
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +55 -3
- package/dist/types/element/src/renderElement.d.ts +31 -7
- package/dist/types/element/src/renderEnvironment.d.ts +66 -0
- package/dist/types/element/src/resizeElements.d.ts +14 -4
- package/dist/types/element/src/selection.d.ts +7 -13
- package/dist/types/element/src/shape.d.ts +29 -1
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/stickyNote.d.ts +191 -0
- package/dist/types/element/src/textElement.d.ts +22 -10
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +3 -2
- package/dist/types/element/src/transform.d.ts +31 -8
- package/dist/types/element/src/typeChecks.d.ts +28 -27
- package/dist/types/element/src/types.d.ts +43 -7
- package/dist/types/element/src/utils.d.ts +15 -4
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +98 -15
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +79 -202
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +306 -939
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +68 -10
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +34 -5
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -518
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +34 -5
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +34 -5
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +69 -11
- package/dist/types/excalidraw/actions/actionExport.d.ts +76 -18
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +132 -648
- package/dist/types/excalidraw/actions/actionGroup.d.ts +83 -25
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +89 -8
- package/dist/types/excalidraw/actions/actionLink.d.ts +35 -6
- package/dist/types/excalidraw/actions/actionMenu.d.ts +34 -5
- package/dist/types/excalidraw/actions/actionProperties.d.ts +106 -32
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +39 -10
- package/dist/types/excalidraw/actions/actionStyles.d.ts +31 -6
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +35 -6
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +38 -10
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +35 -6
- package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +206 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +35 -6
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +38 -10
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleShowHints.d.ts} +50 -18
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +35 -6
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +36 -7
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +35 -6
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +4 -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 +37 -12
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
- package/dist/types/excalidraw/charts/index.d.ts +2 -1
- package/dist/types/excalidraw/components/Actions.d.ts +26 -13
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.clipboard.d.ts +59 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +329 -114
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.host.d.ts +102 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
- package/dist/types/excalidraw/components/App.text.d.ts +194 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +133 -0
- package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- 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 +4 -3
- 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/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
- 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 +5 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
- package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
- package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
- package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
- package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
- package/dist/types/excalidraw/components/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 +4 -2
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
- package/dist/types/excalidraw/components/Toast.d.ts +12 -1
- 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 +151 -0
- package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +5 -1
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +15 -4
- package/dist/types/excalidraw/components/icons.d.ts +8 -1
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +10 -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 +84 -26
- package/dist/types/excalidraw/data/index.d.ts +7 -7
- package/dist/types/excalidraw/data/json.d.ts +48 -19
- 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/fonts/Fonts.d.ts +12 -8
- package/dist/types/excalidraw/history.d.ts +10 -4
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- 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/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/mermaid.d.ts +7 -0
- package/dist/types/excalidraw/reactUtils.d.ts +1 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +15 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +76 -13
- package/dist/types/excalidraw/scene/export.d.ts +344 -21
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +30 -5
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/types.d.ts +613 -28
- package/dist/types/excalidraw/viewport.d.ts +308 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +13 -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 +36 -0
- package/dist/types/math/src/curve.d.ts +19 -12
- 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/math/src/segment.d.ts +6 -0
- package/dist/types/utils/src/index.d.ts +4 -3
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- 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/ToolButton.d.ts +0 -49
- 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/export.d.ts +0 -35
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
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";
|
|
3
|
+
import type { ListMarkerAdvance, MaybeTransformHandleType } from "@excalidraw/element";
|
|
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
|
-
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
6
|
+
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement, RenderEnvironment, OnDuplicateData } from "@excalidraw/element";
|
|
7
7
|
import type { GlobalPoint } from "@excalidraw/math";
|
|
8
8
|
import type { Action } from "./actions/types";
|
|
9
9
|
import type { Spreadsheet } from "./charts";
|
|
@@ -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" | "stickynote" | "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
|
+
textToolHover: AppState["textToolHover"];
|
|
142
145
|
isRotating: AppState["isRotating"];
|
|
143
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
144
147
|
collaborators: AppState["collaborators"];
|
|
@@ -173,6 +176,46 @@ export type ObservedElementsAppState = {
|
|
|
173
176
|
activeLockedId: AppState["activeLockedId"];
|
|
174
177
|
};
|
|
175
178
|
export type BoxSelectionMode = "contain" | "overlap";
|
|
179
|
+
/**
|
|
180
|
+
* The pointing device the wheel mappings are tuned for. `auto` is reserved
|
|
181
|
+
* for detecting it from the wheel events; see `resolveInputDevice`.
|
|
182
|
+
*/
|
|
183
|
+
export type InputDevice = "auto" | "mouse" | "trackpad";
|
|
184
|
+
/**
|
|
185
|
+
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
186
|
+
*
|
|
187
|
+
* This is a private type. For public API, only use specific properties,
|
|
188
|
+
* needed.
|
|
189
|
+
*/
|
|
190
|
+
export type ScrollConstraints = {
|
|
191
|
+
x: number;
|
|
192
|
+
y: number;
|
|
193
|
+
width: number;
|
|
194
|
+
height: number;
|
|
195
|
+
/** when set, panning is constrained so the viewport stays within the box */
|
|
196
|
+
lockScroll: boolean;
|
|
197
|
+
/** when set, the viewport cannot zoom out below `zoom` */
|
|
198
|
+
lockZoom: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* The zoom resolved after the `setViewport` navigation settled.
|
|
201
|
+
*/
|
|
202
|
+
zoom: number;
|
|
203
|
+
/**
|
|
204
|
+
* Pixel amount the viewport may overscroll past its resting clamp before
|
|
205
|
+
* snapping back (rubberband). Screen pixels, zoom-independent. Resolved
|
|
206
|
+
* from `lock.overscroll` at the time the lock was installed (`true` →
|
|
207
|
+
* default give, `false` → 0).
|
|
208
|
+
*/
|
|
209
|
+
overscroll: number;
|
|
210
|
+
/**
|
|
211
|
+
* Extra scrollable margin around the box (CSS-style), letting the viewport
|
|
212
|
+
* scroll past each box edge to reveal that much empty space. Values are
|
|
213
|
+
* viewport pixels and zoom-independent (a fixed on-screen distance).
|
|
214
|
+
* Resolved from the `offsets` passed to `setViewport` (see
|
|
215
|
+
* {@link ViewportOffsets}) at the time the lock was installed.
|
|
216
|
+
*/
|
|
217
|
+
offsets?: Offsets;
|
|
218
|
+
};
|
|
176
219
|
export interface AppState {
|
|
177
220
|
contextMenu: {
|
|
178
221
|
items: ContextMenuItems;
|
|
@@ -217,6 +260,21 @@ export interface AppState {
|
|
|
217
260
|
bindingPreference: "enabled" | "disabled";
|
|
218
261
|
/** user preference whether arrow snap to midpoints while binding */
|
|
219
262
|
isMidpointSnappingEnabled: boolean;
|
|
263
|
+
/** user preference whether to show contextual hints above the toolbar */
|
|
264
|
+
showHints: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* user preference whether multiline text is pasted split into a text
|
|
267
|
+
* element per line (set from the toast shown after such a paste)
|
|
268
|
+
*/
|
|
269
|
+
splitOnPaste: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* user preference for what the wheel does: with a `trackpad` a plain wheel
|
|
272
|
+
* pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
|
|
273
|
+
* delivered) zooms with either device. Shift+wheel pans horizontally;
|
|
274
|
+
* ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
|
|
275
|
+
* device detection exists — see `resolveInputDevice`
|
|
276
|
+
*/
|
|
277
|
+
inputDevice: InputDevice;
|
|
220
278
|
/**
|
|
221
279
|
* The bindable element the UI highlights for the user when an arrow is
|
|
222
280
|
* dragged or otherwise its endpoint being close to said element.
|
|
@@ -225,6 +283,24 @@ export interface AppState {
|
|
|
225
283
|
element: NonDeleted<ExcalidrawBindableElement>;
|
|
226
284
|
midPoint?: GlobalPoint;
|
|
227
285
|
} | null;
|
|
286
|
+
/**
|
|
287
|
+
* What a text-tool click at the hovered position would act on — the text
|
|
288
|
+
* it would edit, the empty container it would label, or the arrow anchor
|
|
289
|
+
* (a free endpoint, or the midpoint for a label) it would attach text to.
|
|
290
|
+
* `null` when the click would create free text, or the tool isn't active.
|
|
291
|
+
* Drives the hover affordance only.
|
|
292
|
+
*/
|
|
293
|
+
textToolHover: {
|
|
294
|
+
type: "text";
|
|
295
|
+
elementId: ExcalidrawElement["id"];
|
|
296
|
+
} | {
|
|
297
|
+
type: "container";
|
|
298
|
+
elementId: ExcalidrawElement["id"];
|
|
299
|
+
} | {
|
|
300
|
+
type: "arrow";
|
|
301
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
302
|
+
anchor: "start" | "end" | "label";
|
|
303
|
+
} | null;
|
|
228
304
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
229
305
|
frameRendering: {
|
|
230
306
|
enabled: boolean;
|
|
@@ -232,8 +308,15 @@ export interface AppState {
|
|
|
232
308
|
outline: boolean;
|
|
233
309
|
clip: boolean;
|
|
234
310
|
};
|
|
235
|
-
|
|
236
|
-
|
|
311
|
+
/**
|
|
312
|
+
* frame-like element whose name is currently being edited
|
|
313
|
+
*/
|
|
314
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
315
|
+
/**
|
|
316
|
+
* Elements the UI highlights with a bounding-box outline — those that
|
|
317
|
+
* would get added to a frame being dragged/resized.
|
|
318
|
+
*/
|
|
319
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
237
320
|
/**
|
|
238
321
|
* set when a new text is created or when an existing text is being edited
|
|
239
322
|
*/
|
|
@@ -258,11 +341,14 @@ export interface AppState {
|
|
|
258
341
|
exportWithDarkMode: boolean;
|
|
259
342
|
exportScale: number;
|
|
260
343
|
currentItemStrokeColor: string;
|
|
344
|
+
currentItemStickynoteStrokeColor: string;
|
|
345
|
+
currentItemStickynoteBackgroundColor: string;
|
|
261
346
|
currentItemBackgroundColor: string;
|
|
262
347
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
263
|
-
|
|
348
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
264
349
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
265
350
|
currentItemRoughness: number;
|
|
351
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
266
352
|
currentItemOpacity: number;
|
|
267
353
|
currentItemFontFamily: FontFamilyValues;
|
|
268
354
|
currentItemFontSize: number;
|
|
@@ -275,6 +361,7 @@ export interface AppState {
|
|
|
275
361
|
viewBackgroundColor: string;
|
|
276
362
|
scrollX: number;
|
|
277
363
|
scrollY: number;
|
|
364
|
+
scrollConstraints: ScrollConstraints | null;
|
|
278
365
|
cursorButton: "up" | "down";
|
|
279
366
|
scrolledOutside: boolean;
|
|
280
367
|
name: string | null;
|
|
@@ -328,8 +415,14 @@ export interface AppState {
|
|
|
328
415
|
message: React.ReactNode;
|
|
329
416
|
closable?: boolean;
|
|
330
417
|
duration?: number;
|
|
418
|
+
/** a link-like button after the message; it closes the toast, too */
|
|
419
|
+
action?: {
|
|
420
|
+
label: string;
|
|
421
|
+
onClick: () => void;
|
|
422
|
+
};
|
|
331
423
|
} | null;
|
|
332
424
|
zenModeEnabled: boolean;
|
|
425
|
+
minimapEnabled: boolean;
|
|
333
426
|
theme: Theme;
|
|
334
427
|
/** grid cell px size */
|
|
335
428
|
gridSize: number;
|
|
@@ -362,10 +455,6 @@ export interface AppState {
|
|
|
362
455
|
y: number;
|
|
363
456
|
} | null;
|
|
364
457
|
objectsSnapModeEnabled: boolean;
|
|
365
|
-
/** the user's socket id & username who is being followed on the canvas */
|
|
366
|
-
userToFollow: UserToFollow | null;
|
|
367
|
-
/** the socket ids of the users following the current user */
|
|
368
|
-
followedBy: Set<SocketId>;
|
|
369
458
|
/** image cropping */
|
|
370
459
|
isCropping: boolean;
|
|
371
460
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
@@ -380,6 +469,23 @@ export interface AppState {
|
|
|
380
469
|
[groupId: string]: true;
|
|
381
470
|
};
|
|
382
471
|
bindMode: BindMode;
|
|
472
|
+
/** user-customized color-picker top picks (pinned via drag & drop from the
|
|
473
|
+
* color picker popup). `null` means no customization (defaults, or
|
|
474
|
+
* host-supplied `topPicks`, are used). Kept per picker. */
|
|
475
|
+
colorTopPicks: {
|
|
476
|
+
elementStroke: readonly string[] | null;
|
|
477
|
+
elementBackground: readonly string[] | null;
|
|
478
|
+
/** the bucket-fill tool keeps a list separate from `elementBackground`
|
|
479
|
+
* even though both drive `currentItemBackgroundColor` (its defaults and
|
|
480
|
+
* use case differ — no transparent) */
|
|
481
|
+
bucketFill: readonly string[] | null;
|
|
482
|
+
/** sticky notes are their own color domain (own defaults, own picks) */
|
|
483
|
+
stickyNoteStroke: readonly string[] | null;
|
|
484
|
+
stickyNoteBackground: readonly string[] | null;
|
|
485
|
+
};
|
|
486
|
+
/** user-customized font-picker top picks (pinned via drag & drop from the
|
|
487
|
+
* font picker popup). `null` means no customization (defaults are used) */
|
|
488
|
+
fontTopPicks: readonly FontFamilyValues[] | null;
|
|
383
489
|
}
|
|
384
490
|
export type SearchMatch = {
|
|
385
491
|
id: string;
|
|
@@ -392,7 +498,7 @@ export type SearchMatch = {
|
|
|
392
498
|
showOnCanvas: boolean;
|
|
393
499
|
}[];
|
|
394
500
|
};
|
|
395
|
-
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY">;
|
|
501
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
|
|
396
502
|
export type NormalizedZoomValue = number & {
|
|
397
503
|
_brand: "normalizedZoom";
|
|
398
504
|
};
|
|
@@ -436,23 +542,224 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
436
542
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
437
543
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
438
544
|
}>;
|
|
545
|
+
export type ExcalidrawInitialState = {
|
|
546
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
547
|
+
};
|
|
439
548
|
export type OnUserFollowedPayload = {
|
|
440
549
|
userToFollow: UserToFollow;
|
|
441
550
|
action: "FOLLOW" | "UNFOLLOW";
|
|
442
551
|
};
|
|
552
|
+
export type ViewportStatusFrame = {
|
|
553
|
+
/** the badge (bottom-center pill) */
|
|
554
|
+
label?: {
|
|
555
|
+
label: React.ReactNode;
|
|
556
|
+
icon?: React.ReactNode;
|
|
557
|
+
/** badge background; defaults to var(--color-primary-hover) */
|
|
558
|
+
background?: string;
|
|
559
|
+
/** badge text color; defaults to var(--color-primary-light) */
|
|
560
|
+
color?: string;
|
|
561
|
+
/** makes the badge label interactive */
|
|
562
|
+
onClick?: () => void;
|
|
563
|
+
/** renders a close button when set */
|
|
564
|
+
onClose?: () => void;
|
|
565
|
+
};
|
|
566
|
+
/** viewport-edge border: CSS color, or `false` for none */
|
|
567
|
+
border: false | string;
|
|
568
|
+
};
|
|
443
569
|
export type OnExportProgress = {
|
|
444
570
|
type: "progress";
|
|
445
571
|
message?: React.ReactNode;
|
|
446
572
|
/** 0-1 range */
|
|
447
573
|
progress?: number;
|
|
448
574
|
};
|
|
575
|
+
export type InteractionConfig = {
|
|
576
|
+
/**
|
|
577
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
578
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
579
|
+
*/
|
|
580
|
+
enabled?: {
|
|
581
|
+
/**
|
|
582
|
+
* Element links render their link icon and stay clickable — clicking
|
|
583
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
584
|
+
* When disabled, link icons are not rendered at all.
|
|
585
|
+
*
|
|
586
|
+
* @default false
|
|
587
|
+
*/
|
|
588
|
+
links?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
591
|
+
* activates them so their content can be used, same as in view mode.
|
|
592
|
+
*
|
|
593
|
+
* @default false
|
|
594
|
+
*/
|
|
595
|
+
embeds?: boolean;
|
|
596
|
+
/**
|
|
597
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
598
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
599
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
600
|
+
* regardless of their individual values.
|
|
601
|
+
*
|
|
602
|
+
* @default false
|
|
603
|
+
*/
|
|
604
|
+
interactiveContent?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
607
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
608
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
609
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
610
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
611
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
612
|
+
* page no longer scrolls over the editor.
|
|
613
|
+
*
|
|
614
|
+
* @default false
|
|
615
|
+
*/
|
|
616
|
+
navigation?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
619
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
620
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
621
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
622
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
623
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
624
|
+
*
|
|
625
|
+
* @default false
|
|
626
|
+
*/
|
|
627
|
+
browserZoom?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
630
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
631
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
632
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
633
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
634
|
+
*
|
|
635
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
636
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
637
|
+
*/
|
|
638
|
+
tools?: {
|
|
639
|
+
/**
|
|
640
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
641
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
642
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
643
|
+
*
|
|
644
|
+
* @default false
|
|
645
|
+
*/
|
|
646
|
+
laser?: boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
649
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
650
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
651
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
652
|
+
* after the first pointer interaction.
|
|
653
|
+
*
|
|
654
|
+
* @default false
|
|
655
|
+
*/
|
|
656
|
+
custom?: boolean;
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
export type UIConfig = {
|
|
661
|
+
/**
|
|
662
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
663
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is
|
|
664
|
+
* disabled.
|
|
665
|
+
*/
|
|
666
|
+
enabled: {
|
|
667
|
+
/**
|
|
668
|
+
* The zoom controls (zoom out, the zoom level resetting it, zoom in).
|
|
669
|
+
*
|
|
670
|
+
* @default false
|
|
671
|
+
*/
|
|
672
|
+
zoom?: boolean;
|
|
673
|
+
/**
|
|
674
|
+
* The button shown when the viewport is scrolled away from all
|
|
675
|
+
* content.
|
|
676
|
+
*
|
|
677
|
+
* @default false
|
|
678
|
+
*/
|
|
679
|
+
scrollBackToContent?: boolean;
|
|
680
|
+
};
|
|
681
|
+
} | {
|
|
682
|
+
/**
|
|
683
|
+
* Default UI controls that are removed while the rest of Excalidraw's
|
|
684
|
+
* default UI is rendered. Opt-out: anything omitted or `false` stays.
|
|
685
|
+
*/
|
|
686
|
+
disabled: {
|
|
687
|
+
/**
|
|
688
|
+
* The minimap, and every way to toggle it (its footer button, the
|
|
689
|
+
* Preferences menu item, and the command palette and context menu
|
|
690
|
+
* entries). Without the minimap toggle next to them, the zoom
|
|
691
|
+
* controls are the zoom out / zoom level / zoom in buttons instead of
|
|
692
|
+
* the zoom menu.
|
|
693
|
+
*
|
|
694
|
+
* @default false
|
|
695
|
+
*/
|
|
696
|
+
minimap?: boolean;
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
/** A default UI control that `UIConfig` can keep or remove. */
|
|
700
|
+
export type UIControl = keyof Extract<UIConfig, {
|
|
701
|
+
enabled: unknown;
|
|
702
|
+
}>["enabled"] | keyof Extract<UIConfig, {
|
|
703
|
+
disabled: unknown;
|
|
704
|
+
}>["disabled"];
|
|
705
|
+
/** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
|
|
706
|
+
export type ElementRenderOverride = Readonly<{
|
|
707
|
+
/** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
|
|
708
|
+
opacity?: number;
|
|
709
|
+
/** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
|
|
710
|
+
offset?: Readonly<{
|
|
711
|
+
x: number;
|
|
712
|
+
y: number;
|
|
713
|
+
}>;
|
|
714
|
+
}>;
|
|
715
|
+
/** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
|
|
716
|
+
export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
|
|
717
|
+
/** The translation part of a snapshot: only the entries that carry an offset. */
|
|
718
|
+
export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
|
|
449
719
|
export interface ExcalidrawProps {
|
|
720
|
+
className?: string;
|
|
721
|
+
/**
|
|
722
|
+
* Document that owns Excalidraw's mounted DOM.
|
|
723
|
+
*
|
|
724
|
+
* Set only when it differs from the global `document`, such as when code
|
|
725
|
+
* executing in a parent window mounts Excalidraw into an iframe document.
|
|
726
|
+
* The value must remain stable for the editor's lifetime.
|
|
727
|
+
*
|
|
728
|
+
* @default document
|
|
729
|
+
*/
|
|
730
|
+
ownerDocument?: Document;
|
|
731
|
+
/**
|
|
732
|
+
* Host environment used by the renderer and export pipeline to create
|
|
733
|
+
* canvases and images. Supply a custom implementation to redirect canvas
|
|
734
|
+
* creation and image decoding to e.g. a host canvas pool, an
|
|
735
|
+
* `OffscreenCanvas`, or a non-DOM image decoder. When omitted, canvas and
|
|
736
|
+
* image creation fall back to `ownerDocument` / `ownerWindow`.
|
|
737
|
+
*
|
|
738
|
+
* The value must be referentially stable -- every render cache (element
|
|
739
|
+
* canvases, text metrics, char widths, link icons) is keyed by this
|
|
740
|
+
* object's identity, so a new identity is a full cache miss. Passing an
|
|
741
|
+
* inline object literal mints a fresh identity on every React render,
|
|
742
|
+
* which silently re-rasterizes every element on every frame; hoist it to a
|
|
743
|
+
* module constant or memoize it (e.g. `useMemo`) instead.
|
|
744
|
+
*
|
|
745
|
+
* Only `createCanvas` and `createImage` are required. `createPath` (used to
|
|
746
|
+
* fill freedraw strokes) falls back to the global `Path2D`, which every
|
|
747
|
+
* browser has -- a non-browser host without one must supply it. Pass
|
|
748
|
+
* `document` (the owner document) for SVG exports to be built in it rather
|
|
749
|
+
* than in the global `document`, and `textMetrics` to measure the editor's
|
|
750
|
+
* text with your own provider.
|
|
751
|
+
*
|
|
752
|
+
* @default { createCanvas: () => ownerDocument.createElement("canvas"), createImage: () => new ownerWindow.Image(), createPath: (d) => new ownerWindow.Path2D(d), document: ownerDocument }
|
|
753
|
+
*/
|
|
754
|
+
renderEnvironment?: RenderEnvironment;
|
|
450
755
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
756
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
451
757
|
/**
|
|
452
758
|
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
453
759
|
*/
|
|
454
760
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
455
761
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
762
|
+
initialState?: ExcalidrawInitialState;
|
|
456
763
|
/**
|
|
457
764
|
* Invoked as soon as the Excalidraw API is available
|
|
458
765
|
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
@@ -490,15 +797,97 @@ export interface ExcalidrawProps {
|
|
|
490
797
|
*
|
|
491
798
|
* Returned elements will be used in place of the next elements
|
|
492
799
|
* (you should return all elements, including deleted, and not mutate
|
|
493
|
-
* the element if changes are made)
|
|
800
|
+
* the element if changes are made).
|
|
801
|
+
*
|
|
802
|
+
* The duplicates are the elements in `nextElements` which are not in
|
|
803
|
+
* `prevElements` (see also `data.duplicateElements`). When pasting or
|
|
804
|
+
* inserting onto a frame, their `frameId` is already set. To change a
|
|
805
|
+
* duplicate, return a new object with the same `id`. It is shallow-merged
|
|
806
|
+
* into the duplicate (omitted properties are kept), and your changes are
|
|
807
|
+
* part of the duplication itself (same undo entry, same durable increment).
|
|
808
|
+
*
|
|
809
|
+
* To prevent an element from being duplicated, omit its duplicate from the
|
|
810
|
+
* returned array. References to it from the remaining duplicates are
|
|
811
|
+
* cleared, and a bound text isn't duplicated without its container. To
|
|
812
|
+
* prevent the duplication as a whole, return `false`. If no duplicate
|
|
813
|
+
* remains, the duplication is cancelled and the returned elements are
|
|
814
|
+
* ignored (alt-drag then moves the original elements instead).
|
|
494
815
|
*/
|
|
495
816
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
496
817
|
/** excludes the duplicated elements */
|
|
497
|
-
prevElements: readonly ExcalidrawElement[]
|
|
818
|
+
prevElements: readonly ExcalidrawElement[],
|
|
819
|
+
/** lookups covering just the elements taking part in the duplication */
|
|
820
|
+
data: OnDuplicateData) => ExcalidrawElement[] | void | false;
|
|
498
821
|
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
499
822
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
500
823
|
langCode?: Language["code"];
|
|
501
824
|
viewModeEnabled?: boolean;
|
|
825
|
+
/**
|
|
826
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
827
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
828
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
829
|
+
* in any way. Implies view mode.
|
|
830
|
+
*
|
|
831
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
832
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
833
|
+
*
|
|
834
|
+
* ```tsx
|
|
835
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
836
|
+
* ```
|
|
837
|
+
*
|
|
838
|
+
* @default true
|
|
839
|
+
*/
|
|
840
|
+
interaction?: boolean | InteractionConfig;
|
|
841
|
+
/**
|
|
842
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
843
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
844
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
845
|
+
* or render props continues to render, together with any supporting dialogs
|
|
846
|
+
* it opens.
|
|
847
|
+
*
|
|
848
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
849
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
850
|
+
* `false`.
|
|
851
|
+
*
|
|
852
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
853
|
+
* rest of the default UI is hidden, or to remove specific controls from the
|
|
854
|
+
* otherwise full default UI (see `UIConfig`):
|
|
855
|
+
*
|
|
856
|
+
* ```tsx
|
|
857
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
858
|
+
* <Excalidraw ui={{ disabled: { minimap: true } }} />
|
|
859
|
+
* ```
|
|
860
|
+
*
|
|
861
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
862
|
+
* may yet change.
|
|
863
|
+
*
|
|
864
|
+
* @default true
|
|
865
|
+
*/
|
|
866
|
+
ui?: boolean | UIConfig;
|
|
867
|
+
/**
|
|
868
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
869
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
870
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
871
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
872
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
873
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
874
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
875
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
876
|
+
* tool control to the editor (the current tool stays active).
|
|
877
|
+
*
|
|
878
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
879
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
880
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
881
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
882
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
883
|
+
* activation opens the file picker).
|
|
884
|
+
*/
|
|
885
|
+
activeTool?: {
|
|
886
|
+
type: Exclude<ToolType, "image">;
|
|
887
|
+
} | {
|
|
888
|
+
type: "custom";
|
|
889
|
+
customType: string;
|
|
890
|
+
};
|
|
502
891
|
zenModeEnabled?: boolean;
|
|
503
892
|
gridModeEnabled?: boolean;
|
|
504
893
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -507,6 +896,10 @@ export interface ExcalidrawProps {
|
|
|
507
896
|
name?: string;
|
|
508
897
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
509
898
|
UIOptions?: Partial<UIOptions>;
|
|
899
|
+
/**
|
|
900
|
+
* dimensions and size constraints for inserted images
|
|
901
|
+
*/
|
|
902
|
+
imageOptions?: ImageOptions;
|
|
510
903
|
detectScroll?: boolean;
|
|
511
904
|
handleKeyboardGlobally?: boolean;
|
|
512
905
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -526,6 +919,21 @@ export interface ExcalidrawProps {
|
|
|
526
919
|
aiEnabled?: boolean;
|
|
527
920
|
showDeprecatedFonts?: boolean;
|
|
528
921
|
renderScrollbars?: boolean;
|
|
922
|
+
viewportStatusFrame?: ViewportStatusFrame | null;
|
|
923
|
+
/**
|
|
924
|
+
* Rendered inside the UserList "who's here" dropdown (desktop) and inline
|
|
925
|
+
* in the mobile menu's collaborators section, below a divider. Accepts a
|
|
926
|
+
* render function — called with `isMobile` so hosts can render different
|
|
927
|
+
* UI for each surface — in addition to a plain node.
|
|
928
|
+
*/
|
|
929
|
+
currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
|
|
930
|
+
/**
|
|
931
|
+
* The user being followed on the canvas, if any. Controlled by the host —
|
|
932
|
+
* the editor never sets it; it emits follow/unfollow intents via
|
|
933
|
+
* `onUserFollow` (prop or imperative API) and renders the followed
|
|
934
|
+
* user's avatar highlight from this value.
|
|
935
|
+
*/
|
|
936
|
+
userToFollow?: UserToFollow | null;
|
|
529
937
|
/**
|
|
530
938
|
* Called before exporting to a file.
|
|
531
939
|
*
|
|
@@ -551,7 +959,8 @@ export interface ExcalidrawProps {
|
|
|
551
959
|
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
552
960
|
}
|
|
553
961
|
export type SceneData = {
|
|
554
|
-
|
|
962
|
+
/** Expects normalized elements; restore imported data before updating the scene. */
|
|
963
|
+
elements?: readonly ExcalidrawElement[] | null;
|
|
555
964
|
appState?: ImportedDataState["appState"];
|
|
556
965
|
collaborators?: Map<SocketId, Collaborator>;
|
|
557
966
|
captureUpdate?: CaptureUpdateActionType;
|
|
@@ -561,12 +970,21 @@ export type ExportOpts = {
|
|
|
561
970
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
562
971
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
563
972
|
};
|
|
973
|
+
export type ImageOptions = Partial<{
|
|
974
|
+
maxWidthOrHeight: number;
|
|
975
|
+
maxFileSizeBytes: number;
|
|
976
|
+
}>;
|
|
564
977
|
export type CanvasActions = Partial<{
|
|
565
978
|
changeViewBackgroundColor: boolean;
|
|
566
979
|
clearCanvas: boolean;
|
|
567
980
|
export: false | ExportOpts;
|
|
568
981
|
loadScene: boolean;
|
|
569
982
|
saveToActiveFile: boolean;
|
|
983
|
+
/**
|
|
984
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
985
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
986
|
+
* else default to false
|
|
987
|
+
* */
|
|
570
988
|
toggleTheme: boolean | null;
|
|
571
989
|
saveAsImage: boolean;
|
|
572
990
|
}>;
|
|
@@ -590,6 +1008,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
590
1008
|
export: ExportOpts;
|
|
591
1009
|
};
|
|
592
1010
|
}>;
|
|
1011
|
+
imageOptions: Required<ImageOptions>;
|
|
593
1012
|
detectScroll: boolean;
|
|
594
1013
|
handleKeyboardGlobally: boolean;
|
|
595
1014
|
isCollaborating: boolean;
|
|
@@ -601,6 +1020,9 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
601
1020
|
export type AppClassProperties = {
|
|
602
1021
|
props: AppProps;
|
|
603
1022
|
state: AppState;
|
|
1023
|
+
readonly ownerDocument: Document;
|
|
1024
|
+
readonly ownerWindow: Window & typeof globalThis;
|
|
1025
|
+
renderEnvironment: RenderEnvironment;
|
|
604
1026
|
api: App["api"];
|
|
605
1027
|
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
606
1028
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
@@ -617,12 +1039,12 @@ export type AppClassProperties = {
|
|
|
617
1039
|
scene: App["scene"];
|
|
618
1040
|
syncActionResult: App["syncActionResult"];
|
|
619
1041
|
fonts: App["fonts"];
|
|
620
|
-
|
|
1042
|
+
clipboard: App["clipboard"];
|
|
621
1043
|
id: App["id"];
|
|
622
1044
|
onInsertElements: App["onInsertElements"];
|
|
623
1045
|
onExportImage: App["onExportImage"];
|
|
624
|
-
|
|
625
|
-
|
|
1046
|
+
viewport: App["viewport"];
|
|
1047
|
+
wheel: App["wheel"];
|
|
626
1048
|
addFiles: App["addFiles"];
|
|
627
1049
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
628
1050
|
togglePenMode: App["togglePenMode"];
|
|
@@ -633,11 +1055,23 @@ export type AppClassProperties = {
|
|
|
633
1055
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
634
1056
|
getName: App["getName"];
|
|
635
1057
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
636
|
-
|
|
1058
|
+
flowchart: App["flowchart"];
|
|
1059
|
+
drawShape: App["drawShape"];
|
|
1060
|
+
arrowText: App["arrowText"];
|
|
1061
|
+
text: App["text"];
|
|
1062
|
+
textTool: App["textTool"];
|
|
1063
|
+
cursor: App["cursor"];
|
|
1064
|
+
bucketFill: App["bucketFill"];
|
|
1065
|
+
duplicate: App["duplicate"];
|
|
1066
|
+
toolDrag: App["toolDrag"];
|
|
1067
|
+
activeResizeHandle: App["activeResizeHandle"];
|
|
1068
|
+
selectionTool: App["selectionTool"];
|
|
1069
|
+
wrap: App["wrap"];
|
|
1070
|
+
modifiers: App["modifiers"];
|
|
1071
|
+
isToolLocked: App["isToolLocked"];
|
|
637
1072
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
638
1073
|
setPlugins: App["setPlugins"];
|
|
639
1074
|
plugins: App["plugins"];
|
|
640
|
-
getEditorUIOffsets: App["getEditorUIOffsets"];
|
|
641
1075
|
visibleElements: App["visibleElements"];
|
|
642
1076
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
643
1077
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
@@ -646,8 +1080,14 @@ export type AppClassProperties = {
|
|
|
646
1080
|
onEvent: App["onEvent"];
|
|
647
1081
|
onStateChange: App["onStateChange"];
|
|
648
1082
|
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
1083
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
649
1084
|
bindModeHandler: App["bindModeHandler"];
|
|
1085
|
+
emitUserFollowIntent: App["emitUserFollowIntent"];
|
|
1086
|
+
requestUnfollow: App["requestUnfollow"];
|
|
650
1087
|
setAppState: App["setAppState"];
|
|
1088
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
1089
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
1090
|
+
isUIControlEnabled: App["isUIControlEnabled"];
|
|
651
1091
|
};
|
|
652
1092
|
export type PointerDownState = Readonly<{
|
|
653
1093
|
origin: Readonly<{
|
|
@@ -681,8 +1121,12 @@ export type PointerDownState = Readonly<{
|
|
|
681
1121
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
682
1122
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
683
1123
|
wasAddedToSelection: boolean;
|
|
1124
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
684
1125
|
hasBeenDuplicated: boolean;
|
|
1126
|
+
advancedListMarkers: readonly ListMarkerAdvance[];
|
|
1127
|
+
editedTextId: ExcalidrawTextElement["id"] | null;
|
|
685
1128
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
1129
|
+
arrowLabel: boolean;
|
|
686
1130
|
};
|
|
687
1131
|
withCmdOrCtrl: boolean;
|
|
688
1132
|
drag: {
|
|
@@ -695,6 +1139,10 @@ export type PointerDownState = Readonly<{
|
|
|
695
1139
|
x: number;
|
|
696
1140
|
y: number;
|
|
697
1141
|
};
|
|
1142
|
+
lastOffset: {
|
|
1143
|
+
x: number;
|
|
1144
|
+
y: number;
|
|
1145
|
+
};
|
|
698
1146
|
blockDragging: boolean;
|
|
699
1147
|
};
|
|
700
1148
|
eventListeners: {
|
|
@@ -730,19 +1178,51 @@ export interface ExcalidrawImperativeAPI {
|
|
|
730
1178
|
history: {
|
|
731
1179
|
clear: InstanceType<typeof App>["resetHistory"];
|
|
732
1180
|
};
|
|
1181
|
+
/**
|
|
1182
|
+
* Selects elements (or their ids — one or many), adds them to or removes
|
|
1183
|
+
* them from the selection, or clears it — as the editor does: an element is
|
|
1184
|
+
* selected with its group (unless `deep`), a frame and its children aren't
|
|
1185
|
+
* selected at the same time, and locked elements are skipped (unless
|
|
1186
|
+
* `includeLocked`). Text editing and cropping end, and the link popup of a
|
|
1187
|
+
* lone selected element shows. Missing and deleted elements are skipped.
|
|
1188
|
+
*
|
|
1189
|
+
* By default the change is recorded for undo along with the next undoable
|
|
1190
|
+
* change — pass `captureUpdate` as for `updateScene()` otherwise. Like
|
|
1191
|
+
* `updateScene()`, it applies on the next render: read it back through
|
|
1192
|
+
* `onChange()` or `getAppState()` after that. Works in view mode too, where
|
|
1193
|
+
* the selection shows without transform handles.
|
|
1194
|
+
*/
|
|
1195
|
+
selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
|
|
733
1196
|
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
|
734
1197
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
735
1198
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
736
1199
|
getName: InstanceType<typeof App>["getName"];
|
|
737
|
-
|
|
1200
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
1201
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
1202
|
+
/**
|
|
1203
|
+
* Atomically replaces all transient visual overrides. Values are copied;
|
|
1204
|
+
* omitted IDs/fields use document values, except for inherited label offsets.
|
|
1205
|
+
* null clears the snapshot.
|
|
1206
|
+
* Repaints without document changes, history entries or onChange events;
|
|
1207
|
+
* an equivalent snapshot may still repaint (clearing an already clear
|
|
1208
|
+
* snapshot does not), so submit only when something changed.
|
|
1209
|
+
* Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
|
|
1210
|
+
* Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
|
|
1211
|
+
* Bound labels inherit their container's offset; offsets targeting them are
|
|
1212
|
+
* ignored. Label opacity remains independent. Target frame children explicitly.
|
|
1213
|
+
* Frame opacity still multiplies child opacity. Decorations follow their owner.
|
|
1214
|
+
* Exports and interactive geometry (hit tests, selection, editing) use document
|
|
1215
|
+
* values, including while authoring an animation preview in edit mode.
|
|
1216
|
+
*/
|
|
1217
|
+
setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
|
|
738
1218
|
registerAction: (action: Action) => void;
|
|
739
1219
|
refresh: InstanceType<typeof App>["refresh"];
|
|
740
1220
|
setToast: InstanceType<typeof App>["setToast"];
|
|
741
1221
|
addFiles: (data: BinaryFileData[]) => void;
|
|
742
1222
|
id: string;
|
|
743
1223
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
744
|
-
setCursor: InstanceType<typeof App>["
|
|
745
|
-
resetCursor: InstanceType<typeof App>["
|
|
1224
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
1225
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
746
1226
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
747
1227
|
getEditorInterface: () => EditorInterface;
|
|
748
1228
|
/**
|
|
@@ -765,7 +1245,6 @@ export type FrameNameBounds = {
|
|
|
765
1245
|
y: number;
|
|
766
1246
|
width: number;
|
|
767
1247
|
height: number;
|
|
768
|
-
angle: number;
|
|
769
1248
|
};
|
|
770
1249
|
export type FrameNameBoundsCache = {
|
|
771
1250
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -784,12 +1263,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
784
1263
|
export type JSONValue = string | number | boolean | null | object;
|
|
785
1264
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
786
1265
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
787
|
-
export type PendingExcalidrawElements =
|
|
1266
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
788
1267
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
789
1268
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
790
1269
|
export type GenerateDiagramToCode = (props: {
|
|
791
|
-
frame: ExcalidrawMagicFrameElement
|
|
792
|
-
children: readonly
|
|
1270
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
1271
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
1272
|
+
/**
|
|
1273
|
+
* Optional streaming hook. Call with the accumulated response text as it
|
|
1274
|
+
* streams in so the editor can progressively render the partial HTML
|
|
1275
|
+
* inside the generated frame.
|
|
1276
|
+
*/
|
|
1277
|
+
onPartial?: (html: string) => void;
|
|
793
1278
|
}) => MaybePromise<{
|
|
794
1279
|
html: string;
|
|
795
1280
|
}>;
|
|
@@ -799,3 +1284,103 @@ export type Offsets = Partial<{
|
|
|
799
1284
|
bottom: number;
|
|
800
1285
|
left: number;
|
|
801
1286
|
}>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
1289
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
1290
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
1291
|
+
*
|
|
1292
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
1293
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
1294
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
1295
|
+
* lies in the left half of the viewport it counts against the left
|
|
1296
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
1297
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
1298
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
1299
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
1300
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
1301
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
1302
|
+
* would swallow most of the viewport).
|
|
1303
|
+
*
|
|
1304
|
+
* The attribute should only be present while the surface is actually
|
|
1305
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
1306
|
+
* push the viewport around.
|
|
1307
|
+
*/
|
|
1308
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
1309
|
+
/**
|
|
1310
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
1311
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
1312
|
+
* currently rendered editor UI.
|
|
1313
|
+
*
|
|
1314
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
1315
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
1316
|
+
* reading-direction start side).
|
|
1317
|
+
*/
|
|
1318
|
+
export type ViewportOffsetsOptions = {
|
|
1319
|
+
/** padding added to each measured side (default 24) */
|
|
1320
|
+
padding?: number;
|
|
1321
|
+
paddingTop?: number;
|
|
1322
|
+
paddingRight?: number;
|
|
1323
|
+
paddingBottom?: number;
|
|
1324
|
+
paddingLeft?: number;
|
|
1325
|
+
/** final value for the given side, replacing the measured UI size
|
|
1326
|
+
* (padding is not added on top) */
|
|
1327
|
+
top?: number;
|
|
1328
|
+
bottom?: number;
|
|
1329
|
+
left?: number;
|
|
1330
|
+
right?: number;
|
|
1331
|
+
/**
|
|
1332
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
1333
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
1334
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
1335
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
1336
|
+
* phones (where these surfaces never occlude the canvas).
|
|
1337
|
+
*/
|
|
1338
|
+
reserve?: {
|
|
1339
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
1340
|
+
stylesPanel?: boolean;
|
|
1341
|
+
/** sidebar (e.g. library) */
|
|
1342
|
+
sidebar?: boolean;
|
|
1343
|
+
};
|
|
1344
|
+
};
|
|
1345
|
+
/**
|
|
1346
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
1347
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
1348
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
1349
|
+
*
|
|
1350
|
+
* Two (combinable) ways to specify:
|
|
1351
|
+
*
|
|
1352
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
1353
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
1354
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
1355
|
+
* set, see below).
|
|
1356
|
+
*
|
|
1357
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
1358
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
1359
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
1360
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
1361
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
1362
|
+
*
|
|
1363
|
+
* When both are given, a static side always wins for that side — it
|
|
1364
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
1365
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
1366
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* { top: 40 } // top 40px, other sides 0
|
|
1370
|
+
* { ui: true } // measured UI + default padding
|
|
1371
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
1372
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
1373
|
+
*/
|
|
1374
|
+
export type ViewportOffsets = Offsets & {
|
|
1375
|
+
ui?: true | ViewportOffsetsOptions;
|
|
1376
|
+
};
|
|
1377
|
+
/**
|
|
1378
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1379
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1380
|
+
* it can be measured on its own, and so that `getViewportOffsets` can
|
|
1381
|
+
* reserve space for it while it's hidden (see the `reserve` option).
|
|
1382
|
+
* Whenever a named surface is rendered, its measured footprint is
|
|
1383
|
+
* remembered; reserving uses that remembered footprint, or an approximate
|
|
1384
|
+
* default if the surface hasn't been rendered yet.
|
|
1385
|
+
*/
|
|
1386
|
+
export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";
|