@excalidraw/math 0.18.0-3a5ef40 → 0.18.0-3c916c5
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 +321 -118
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +1 -1
- package/dist/types/common/debug.d.ts +21 -0
- package/dist/types/common/src/appEventBus.d.ts +27 -0
- package/dist/types/common/src/colors.d.ts +24 -2
- package/dist/types/common/src/constants.d.ts +66 -7
- package/dist/types/common/src/index.d.ts +3 -0
- package/dist/types/common/src/keys.d.ts +4 -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 +16 -50
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +9 -5
- 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/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +6 -3
- package/dist/types/element/src/binding.d.ts +94 -17
- package/dist/types/element/src/bounds.d.ts +32 -9
- 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 +64 -3
- package/dist/types/element/src/elbowArrow.d.ts +7 -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 +30 -11
- 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 +8 -1
- package/dist/types/element/src/linearElementEditor.d.ts +34 -11
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +3 -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 +11 -13
- package/dist/types/element/src/shape.d.ts +30 -2
- 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 +23 -11
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +28 -1
- package/dist/types/element/src/transform.d.ts +31 -8
- package/dist/types/element/src/typeChecks.d.ts +29 -27
- package/dist/types/element/src/types.d.ts +48 -9
- package/dist/types/element/src/utils.d.ts +19 -6
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +125 -53
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +86 -213
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +361 -1024
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +84 -36
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +42 -18
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -515
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +182 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +85 -37
- package/dist/types/excalidraw/actions/actionExport.d.ts +138 -364
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +151 -684
- package/dist/types/excalidraw/actions/actionGroup.d.ts +100 -52
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +97 -21
- package/dist/types/excalidraw/actions/actionLink.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionMenu.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionProperties.d.ts +120 -56
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +47 -23
- package/dist/types/excalidraw/actions/actionStyles.d.ts +43 -18
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleArrowBinding.d.ts} +57 -32
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +46 -23
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +195 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +42 -23
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +44 -20
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +6 -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 +43 -17
- package/dist/types/excalidraw/charts/charts.bar.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +33 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +8 -0
- package/dist/types/excalidraw/clipboard.d.ts +2 -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 +70 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +372 -116
- 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 +93 -0
- package/dist/types/excalidraw/components/App.text.d.ts +146 -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 +123 -0
- package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -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/CommandPalette/types.d.ts +1 -1
- 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/IconPicker.d.ts +14 -9
- 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/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/PasteChartDialog.d.ts +4 -5
- 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/Range.d.ts +10 -4
- 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/CodeMirrorEditor.d.ts +11 -0
- 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/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +8 -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/mermaid-lang-lite.d.ts +2 -0
- 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/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +26 -0
- package/dist/types/excalidraw/components/Toast.d.ts +8 -4
- 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 +4 -2
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -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/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +15 -4
- package/dist/types/excalidraw/components/icons.d.ts +27 -10
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -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 +117 -70
- package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
- package/dist/types/excalidraw/data/index.d.ts +9 -10
- package/dist/types/excalidraw/data/json.d.ts +67 -35
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- 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 +490 -21
- 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/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +670 -43
- package/dist/types/excalidraw/viewport.d.ts +302 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +17 -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 +23 -13
- 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 +8 -2
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/index.d.ts +4 -3
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
- 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/InitializeApp.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
- package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
- package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
- package/dist/types/excalidraw/index.d.ts +0 -47
- package/dist/types/excalidraw/polyfill.d.ts +0 -2
- 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,18 +1,19 @@
|
|
|
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,
|
|
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
|
+
import type { GlobalPoint } from "@excalidraw/math";
|
|
7
8
|
import type { Action } from "./actions/types";
|
|
8
9
|
import type { Spreadsheet } from "./charts";
|
|
9
10
|
import type { ClipboardData } from "./clipboard";
|
|
10
11
|
import type App from "./components/App";
|
|
11
12
|
import type Library from "./data/library";
|
|
12
|
-
import type { FileSystemHandle } from "./data/filesystem";
|
|
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;
|
|
@@ -129,6 +130,7 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
129
130
|
croppingElementId: AppState["croppingElementId"];
|
|
130
131
|
}>;
|
|
131
132
|
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
133
|
+
activeTool: AppState["activeTool"];
|
|
132
134
|
activeEmbeddable: AppState["activeEmbeddable"];
|
|
133
135
|
selectionElement: AppState["selectionElement"];
|
|
134
136
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
@@ -136,7 +138,10 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
136
138
|
multiElement: AppState["multiElement"];
|
|
137
139
|
newElement: AppState["newElement"];
|
|
138
140
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
141
|
+
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
142
|
+
gridModeEnabled: AppState["gridModeEnabled"];
|
|
139
143
|
suggestedBinding: AppState["suggestedBinding"];
|
|
144
|
+
textToolHover: AppState["textToolHover"];
|
|
140
145
|
isRotating: AppState["isRotating"];
|
|
141
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
142
147
|
collaborators: AppState["collaborators"];
|
|
@@ -151,6 +156,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
151
156
|
frameRendering: AppState["frameRendering"];
|
|
152
157
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
153
158
|
exportScale: AppState["exportScale"];
|
|
159
|
+
currentItemArrowType: AppState["currentItemArrowType"];
|
|
154
160
|
}>;
|
|
155
161
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
156
162
|
export type ObservedStandaloneAppState = {
|
|
@@ -169,6 +175,47 @@ export type ObservedElementsAppState = {
|
|
|
169
175
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
170
176
|
activeLockedId: AppState["activeLockedId"];
|
|
171
177
|
};
|
|
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
|
+
};
|
|
172
219
|
export interface AppState {
|
|
173
220
|
contextMenu: {
|
|
174
221
|
items: ContextMenuItems;
|
|
@@ -202,9 +249,53 @@ export interface AppState {
|
|
|
202
249
|
* - set on pointer down, updated during pointer move
|
|
203
250
|
*/
|
|
204
251
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
252
|
+
/**
|
|
253
|
+
* tracking current arrow binding editor state (takes into account
|
|
254
|
+
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
255
|
+
*/
|
|
205
256
|
isBindingEnabled: boolean;
|
|
206
|
-
|
|
207
|
-
|
|
257
|
+
/** user box selection preference; defaults to "contain" when unset */
|
|
258
|
+
boxSelectionMode: BoxSelectionMode;
|
|
259
|
+
/** user arrow binding preference */
|
|
260
|
+
bindingPreference: "enabled" | "disabled";
|
|
261
|
+
/** user preference whether arrow snap to midpoints while binding */
|
|
262
|
+
isMidpointSnappingEnabled: boolean;
|
|
263
|
+
/** user preference whether to show contextual hints above the toolbar */
|
|
264
|
+
showHints: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* user preference for what the wheel does: with a `trackpad` a plain wheel
|
|
267
|
+
* pans; with a `mouse` a plain wheel zooms. Ctrl/cmd+wheel (how a pinch is
|
|
268
|
+
* delivered) zooms with either device. Shift+wheel pans horizontally;
|
|
269
|
+
* ctrl/cmd+shift+wheel pans vertically. `auto` resolves to `trackpad` until
|
|
270
|
+
* device detection exists — see `resolveInputDevice`
|
|
271
|
+
*/
|
|
272
|
+
inputDevice: InputDevice;
|
|
273
|
+
/**
|
|
274
|
+
* The bindable element the UI highlights for the user when an arrow is
|
|
275
|
+
* dragged or otherwise its endpoint being close to said element.
|
|
276
|
+
*/
|
|
277
|
+
suggestedBinding: {
|
|
278
|
+
element: NonDeleted<ExcalidrawBindableElement>;
|
|
279
|
+
midPoint?: GlobalPoint;
|
|
280
|
+
} | null;
|
|
281
|
+
/**
|
|
282
|
+
* What a text-tool click at the hovered position would act on — the text
|
|
283
|
+
* it would edit, the empty container it would label, or the arrow anchor
|
|
284
|
+
* (a free endpoint, or the midpoint for a label) it would attach text to.
|
|
285
|
+
* `null` when the click would create free text, or the tool isn't active.
|
|
286
|
+
* Drives the hover affordance only.
|
|
287
|
+
*/
|
|
288
|
+
textToolHover: {
|
|
289
|
+
type: "text";
|
|
290
|
+
elementId: ExcalidrawElement["id"];
|
|
291
|
+
} | {
|
|
292
|
+
type: "container";
|
|
293
|
+
elementId: ExcalidrawElement["id"];
|
|
294
|
+
} | {
|
|
295
|
+
type: "arrow";
|
|
296
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
297
|
+
anchor: "start" | "end" | "label";
|
|
298
|
+
} | null;
|
|
208
299
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
209
300
|
frameRendering: {
|
|
210
301
|
enabled: boolean;
|
|
@@ -212,12 +303,19 @@ export interface AppState {
|
|
|
212
303
|
outline: boolean;
|
|
213
304
|
clip: boolean;
|
|
214
305
|
};
|
|
215
|
-
|
|
216
|
-
|
|
306
|
+
/**
|
|
307
|
+
* frame-like element whose name is currently being edited
|
|
308
|
+
*/
|
|
309
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
310
|
+
/**
|
|
311
|
+
* Elements the UI highlights with a bounding-box outline — those that
|
|
312
|
+
* would get added to a frame being dragged/resized.
|
|
313
|
+
*/
|
|
314
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
217
315
|
/**
|
|
218
316
|
* set when a new text is created or when an existing text is being edited
|
|
219
317
|
*/
|
|
220
|
-
editingTextElement:
|
|
318
|
+
editingTextElement: ExcalidrawTextElement | null;
|
|
221
319
|
activeTool: {
|
|
222
320
|
/**
|
|
223
321
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -238,11 +336,14 @@ export interface AppState {
|
|
|
238
336
|
exportWithDarkMode: boolean;
|
|
239
337
|
exportScale: number;
|
|
240
338
|
currentItemStrokeColor: string;
|
|
339
|
+
currentItemStickynoteStrokeColor: string;
|
|
340
|
+
currentItemStickynoteBackgroundColor: string;
|
|
241
341
|
currentItemBackgroundColor: string;
|
|
242
342
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
243
|
-
|
|
343
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
244
344
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
245
345
|
currentItemRoughness: number;
|
|
346
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
246
347
|
currentItemOpacity: number;
|
|
247
348
|
currentItemFontFamily: FontFamilyValues;
|
|
248
349
|
currentItemFontSize: number;
|
|
@@ -255,6 +356,7 @@ export interface AppState {
|
|
|
255
356
|
viewBackgroundColor: string;
|
|
256
357
|
scrollX: number;
|
|
257
358
|
scrollY: number;
|
|
359
|
+
scrollConstraints: ScrollConstraints | null;
|
|
258
360
|
cursorButton: "up" | "down";
|
|
259
361
|
scrolledOutside: boolean;
|
|
260
362
|
name: string | null;
|
|
@@ -279,6 +381,10 @@ export interface AppState {
|
|
|
279
381
|
} | {
|
|
280
382
|
name: "elementLinkSelector";
|
|
281
383
|
sourceElementId: ExcalidrawElement["id"];
|
|
384
|
+
} | {
|
|
385
|
+
name: "charts";
|
|
386
|
+
data: Spreadsheet;
|
|
387
|
+
rawText: string;
|
|
282
388
|
};
|
|
283
389
|
/**
|
|
284
390
|
* Reflects user preference for whether the default sidebar should be docked.
|
|
@@ -301,7 +407,7 @@ export interface AppState {
|
|
|
301
407
|
selectedElementsAreBeingDragged: boolean;
|
|
302
408
|
shouldCacheIgnoreZoom: boolean;
|
|
303
409
|
toast: {
|
|
304
|
-
message:
|
|
410
|
+
message: React.ReactNode;
|
|
305
411
|
closable?: boolean;
|
|
306
412
|
duration?: number;
|
|
307
413
|
} | null;
|
|
@@ -323,21 +429,13 @@ export interface AppState {
|
|
|
323
429
|
height: number;
|
|
324
430
|
offsetTop: number;
|
|
325
431
|
offsetLeft: number;
|
|
326
|
-
fileHandle:
|
|
432
|
+
fileHandle: FileSystemFileHandle | null;
|
|
327
433
|
collaborators: Map<SocketId, Collaborator>;
|
|
328
434
|
stats: {
|
|
329
435
|
open: boolean;
|
|
330
436
|
/** bitmap. Use `STATS_PANELS` bit values */
|
|
331
437
|
panels: number;
|
|
332
438
|
};
|
|
333
|
-
currentChartType: ChartType;
|
|
334
|
-
pasteDialog: {
|
|
335
|
-
shown: false;
|
|
336
|
-
data: null;
|
|
337
|
-
} | {
|
|
338
|
-
shown: true;
|
|
339
|
-
data: Spreadsheet;
|
|
340
|
-
};
|
|
341
439
|
showHyperlinkPopup: false | "info" | "editor";
|
|
342
440
|
selectedLinearElement: LinearElementEditor | null;
|
|
343
441
|
snapLines: readonly SnapLine[];
|
|
@@ -346,10 +444,6 @@ export interface AppState {
|
|
|
346
444
|
y: number;
|
|
347
445
|
} | null;
|
|
348
446
|
objectsSnapModeEnabled: boolean;
|
|
349
|
-
/** the user's socket id & username who is being followed on the canvas */
|
|
350
|
-
userToFollow: UserToFollow | null;
|
|
351
|
-
/** the socket ids of the users following the current user */
|
|
352
|
-
followedBy: Set<SocketId>;
|
|
353
447
|
/** image cropping */
|
|
354
448
|
isCropping: boolean;
|
|
355
449
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
@@ -364,6 +458,23 @@ export interface AppState {
|
|
|
364
458
|
[groupId: string]: true;
|
|
365
459
|
};
|
|
366
460
|
bindMode: BindMode;
|
|
461
|
+
/** user-customized color-picker top picks (pinned via drag & drop from the
|
|
462
|
+
* color picker popup). `null` means no customization (defaults, or
|
|
463
|
+
* host-supplied `topPicks`, are used). Kept per picker. */
|
|
464
|
+
colorTopPicks: {
|
|
465
|
+
elementStroke: readonly string[] | null;
|
|
466
|
+
elementBackground: readonly string[] | null;
|
|
467
|
+
/** the bucket-fill tool keeps a list separate from `elementBackground`
|
|
468
|
+
* even though both drive `currentItemBackgroundColor` (its defaults and
|
|
469
|
+
* use case differ — no transparent) */
|
|
470
|
+
bucketFill: readonly string[] | null;
|
|
471
|
+
/** sticky notes are their own color domain (own defaults, own picks) */
|
|
472
|
+
stickyNoteStroke: readonly string[] | null;
|
|
473
|
+
stickyNoteBackground: readonly string[] | null;
|
|
474
|
+
};
|
|
475
|
+
/** user-customized font-picker top picks (pinned via drag & drop from the
|
|
476
|
+
* font picker popup). `null` means no customization (defaults are used) */
|
|
477
|
+
fontTopPicks: readonly FontFamilyValues[] | null;
|
|
367
478
|
}
|
|
368
479
|
export type SearchMatch = {
|
|
369
480
|
id: string;
|
|
@@ -376,7 +487,7 @@ export type SearchMatch = {
|
|
|
376
487
|
showOnCanvas: boolean;
|
|
377
488
|
}[];
|
|
378
489
|
};
|
|
379
|
-
export type UIAppState = Omit<AppState, "
|
|
490
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "textToolHover" | "frameToHighlight" | "elementsToHighlight">;
|
|
380
491
|
export type NormalizedZoomValue = number & {
|
|
381
492
|
_brand: "normalizedZoom";
|
|
382
493
|
};
|
|
@@ -420,15 +531,216 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
420
531
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
421
532
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
422
533
|
}>;
|
|
534
|
+
export type ExcalidrawInitialState = {
|
|
535
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
536
|
+
};
|
|
423
537
|
export type OnUserFollowedPayload = {
|
|
424
538
|
userToFollow: UserToFollow;
|
|
425
539
|
action: "FOLLOW" | "UNFOLLOW";
|
|
426
540
|
};
|
|
541
|
+
export type ViewportStatusFrame = {
|
|
542
|
+
/** the badge (bottom-center pill) */
|
|
543
|
+
label?: {
|
|
544
|
+
label: React.ReactNode;
|
|
545
|
+
icon?: React.ReactNode;
|
|
546
|
+
/** badge background; defaults to var(--color-primary-hover) */
|
|
547
|
+
background?: string;
|
|
548
|
+
/** badge text color; defaults to var(--color-primary-light) */
|
|
549
|
+
color?: string;
|
|
550
|
+
/** makes the badge label interactive */
|
|
551
|
+
onClick?: () => void;
|
|
552
|
+
/** renders a close button when set */
|
|
553
|
+
onClose?: () => void;
|
|
554
|
+
};
|
|
555
|
+
/** viewport-edge border: CSS color, or `false` for none */
|
|
556
|
+
border: false | string;
|
|
557
|
+
};
|
|
558
|
+
export type OnExportProgress = {
|
|
559
|
+
type: "progress";
|
|
560
|
+
message?: React.ReactNode;
|
|
561
|
+
/** 0-1 range */
|
|
562
|
+
progress?: number;
|
|
563
|
+
};
|
|
564
|
+
export type InteractionConfig = {
|
|
565
|
+
/**
|
|
566
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
567
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
568
|
+
*/
|
|
569
|
+
enabled?: {
|
|
570
|
+
/**
|
|
571
|
+
* Element links render their link icon and stay clickable — clicking
|
|
572
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
573
|
+
* When disabled, link icons are not rendered at all.
|
|
574
|
+
*
|
|
575
|
+
* @default false
|
|
576
|
+
*/
|
|
577
|
+
links?: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
580
|
+
* activates them so their content can be used, same as in view mode.
|
|
581
|
+
*
|
|
582
|
+
* @default false
|
|
583
|
+
*/
|
|
584
|
+
embeds?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
587
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
588
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
589
|
+
* regardless of their individual values.
|
|
590
|
+
*
|
|
591
|
+
* @default false
|
|
592
|
+
*/
|
|
593
|
+
interactiveContent?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
596
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
597
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
598
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
599
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
600
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
601
|
+
* page no longer scrolls over the editor.
|
|
602
|
+
*
|
|
603
|
+
* @default false
|
|
604
|
+
*/
|
|
605
|
+
navigation?: boolean;
|
|
606
|
+
/**
|
|
607
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
608
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
609
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
610
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
611
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
612
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
613
|
+
*
|
|
614
|
+
* @default false
|
|
615
|
+
*/
|
|
616
|
+
browserZoom?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
619
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
620
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
621
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
622
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
623
|
+
*
|
|
624
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
625
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
626
|
+
*/
|
|
627
|
+
tools?: {
|
|
628
|
+
/**
|
|
629
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
630
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
631
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
632
|
+
*
|
|
633
|
+
* @default false
|
|
634
|
+
*/
|
|
635
|
+
laser?: boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
638
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
639
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
640
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
641
|
+
* after the first pointer interaction.
|
|
642
|
+
*
|
|
643
|
+
* @default false
|
|
644
|
+
*/
|
|
645
|
+
custom?: boolean;
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
export type UIConfig = {
|
|
650
|
+
/**
|
|
651
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
652
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is disabled.
|
|
653
|
+
*/
|
|
654
|
+
enabled: {
|
|
655
|
+
/**
|
|
656
|
+
* The zoom-out, reset-zoom, and zoom-in controls.
|
|
657
|
+
*
|
|
658
|
+
* @default false
|
|
659
|
+
*/
|
|
660
|
+
zoom?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* The button shown when the viewport is scrolled away from all content.
|
|
663
|
+
*
|
|
664
|
+
* @default false
|
|
665
|
+
*/
|
|
666
|
+
scrollBackToContent?: boolean;
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
/** Supported visual changes. Geometry, content, bindings and styles are not overridable. */
|
|
670
|
+
export type ElementRenderOverride = Readonly<{
|
|
671
|
+
/** Absolute render opacity (0–100, clamped). Omitted: use element.opacity. */
|
|
672
|
+
opacity?: number;
|
|
673
|
+
/** Translation in scene units. Bound labels inherit their container's offset and ignore this field. */
|
|
674
|
+
offset?: Readonly<{
|
|
675
|
+
x: number;
|
|
676
|
+
y: number;
|
|
677
|
+
}>;
|
|
678
|
+
}>;
|
|
679
|
+
/** see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details */
|
|
680
|
+
export type ElementRenderOverrides = ReadonlyMap<ExcalidrawElement["id"], ElementRenderOverride>;
|
|
681
|
+
/** The translation part of a snapshot: only the entries that carry an offset. */
|
|
682
|
+
export type ElementRenderOffsets = ReadonlyMap<ExcalidrawElement["id"], NonNullable<ElementRenderOverride["offset"]>>;
|
|
427
683
|
export interface ExcalidrawProps {
|
|
684
|
+
className?: string;
|
|
685
|
+
/**
|
|
686
|
+
* Document that owns Excalidraw's mounted DOM.
|
|
687
|
+
*
|
|
688
|
+
* Set only when it differs from the global `document`, such as when code
|
|
689
|
+
* executing in a parent window mounts Excalidraw into an iframe document.
|
|
690
|
+
* The value must remain stable for the editor's lifetime.
|
|
691
|
+
*
|
|
692
|
+
* @default document
|
|
693
|
+
*/
|
|
694
|
+
ownerDocument?: Document;
|
|
695
|
+
/**
|
|
696
|
+
* Host environment used by the renderer and export pipeline to create
|
|
697
|
+
* canvases and images. Supply a custom implementation to redirect canvas
|
|
698
|
+
* creation and image decoding to e.g. a host canvas pool, an
|
|
699
|
+
* `OffscreenCanvas`, or a non-DOM image decoder. When omitted, canvas and
|
|
700
|
+
* image creation fall back to `ownerDocument` / `ownerWindow`.
|
|
701
|
+
*
|
|
702
|
+
* The value must be referentially stable -- every render cache (element
|
|
703
|
+
* canvases, text metrics, char widths, link icons) is keyed by this
|
|
704
|
+
* object's identity, so a new identity is a full cache miss. Passing an
|
|
705
|
+
* inline object literal mints a fresh identity on every React render,
|
|
706
|
+
* which silently re-rasterizes every element on every frame; hoist it to a
|
|
707
|
+
* module constant or memoize it (e.g. `useMemo`) instead.
|
|
708
|
+
*
|
|
709
|
+
* Only `createCanvas` and `createImage` are required. `createPath` (used to
|
|
710
|
+
* fill freedraw strokes) falls back to the global `Path2D`, which every
|
|
711
|
+
* browser has -- a non-browser host without one must supply it. Pass
|
|
712
|
+
* `document` (the owner document) for SVG exports to be built in it rather
|
|
713
|
+
* than in the global `document`, and `textMetrics` to measure the editor's
|
|
714
|
+
* text with your own provider.
|
|
715
|
+
*
|
|
716
|
+
* @default { createCanvas: () => ownerDocument.createElement("canvas"), createImage: () => new ownerWindow.Image(), createPath: (d) => new ownerWindow.Path2D(d), document: ownerDocument }
|
|
717
|
+
*/
|
|
718
|
+
renderEnvironment?: RenderEnvironment;
|
|
428
719
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
720
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
721
|
+
/**
|
|
722
|
+
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
723
|
+
*/
|
|
429
724
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
430
725
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
431
|
-
|
|
726
|
+
initialState?: ExcalidrawInitialState;
|
|
727
|
+
/**
|
|
728
|
+
* Invoked as soon as the Excalidraw API is available
|
|
729
|
+
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
730
|
+
*/
|
|
731
|
+
onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
|
|
732
|
+
/**
|
|
733
|
+
* Invoked once the editor root is mounted.
|
|
734
|
+
*/
|
|
735
|
+
onMount?: (payload: ExcalidrawMountPayload) => void;
|
|
736
|
+
/**
|
|
737
|
+
* Invoked when the editor root is unmounted.
|
|
738
|
+
*/
|
|
739
|
+
onUnmount?: () => void;
|
|
740
|
+
/**
|
|
741
|
+
* Invoked once the initial scene is loaded.
|
|
742
|
+
*/
|
|
743
|
+
onInitialize?: (api: ExcalidrawImperativeAPI) => void;
|
|
432
744
|
isCollaborating?: boolean;
|
|
433
745
|
onPointerUpdate?: (payload: {
|
|
434
746
|
pointer: {
|
|
@@ -449,15 +761,95 @@ export interface ExcalidrawProps {
|
|
|
449
761
|
*
|
|
450
762
|
* Returned elements will be used in place of the next elements
|
|
451
763
|
* (you should return all elements, including deleted, and not mutate
|
|
452
|
-
* the element if changes are made)
|
|
764
|
+
* the element if changes are made).
|
|
765
|
+
*
|
|
766
|
+
* The duplicates are the elements in `nextElements` which are not in
|
|
767
|
+
* `prevElements` (see also `data.duplicateElements`). When pasting or
|
|
768
|
+
* inserting onto a frame, their `frameId` is already set. To change a
|
|
769
|
+
* duplicate, return a new object with the same `id`. It is shallow-merged
|
|
770
|
+
* into the duplicate (omitted properties are kept), and your changes are
|
|
771
|
+
* part of the duplication itself (same undo entry, same durable increment).
|
|
772
|
+
*
|
|
773
|
+
* To prevent an element from being duplicated, omit its duplicate from the
|
|
774
|
+
* returned array. References to it from the remaining duplicates are
|
|
775
|
+
* cleared, and a bound text isn't duplicated without its container. To
|
|
776
|
+
* prevent the duplication as a whole, return `false`. If no duplicate
|
|
777
|
+
* remains, the duplication is cancelled and the returned elements are
|
|
778
|
+
* ignored (alt-drag then moves the original elements instead).
|
|
453
779
|
*/
|
|
454
780
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
455
781
|
/** excludes the duplicated elements */
|
|
456
|
-
prevElements: readonly ExcalidrawElement[]
|
|
782
|
+
prevElements: readonly ExcalidrawElement[],
|
|
783
|
+
/** lookups covering just the elements taking part in the duplication */
|
|
784
|
+
data: OnDuplicateData) => ExcalidrawElement[] | void | false;
|
|
457
785
|
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
458
786
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
459
787
|
langCode?: Language["code"];
|
|
460
788
|
viewModeEnabled?: boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
791
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
792
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
793
|
+
* in any way. Implies view mode.
|
|
794
|
+
*
|
|
795
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
796
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
797
|
+
*
|
|
798
|
+
* ```tsx
|
|
799
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
800
|
+
* ```
|
|
801
|
+
*
|
|
802
|
+
* @default true
|
|
803
|
+
*/
|
|
804
|
+
interaction?: boolean | InteractionConfig;
|
|
805
|
+
/**
|
|
806
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
807
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
808
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
809
|
+
* or render props continues to render, together with any supporting dialogs
|
|
810
|
+
* it opens.
|
|
811
|
+
*
|
|
812
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
813
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
814
|
+
* `false`.
|
|
815
|
+
*
|
|
816
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
817
|
+
* rest of the default UI is hidden (see `UIConfig`):
|
|
818
|
+
*
|
|
819
|
+
* ```tsx
|
|
820
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
821
|
+
* ```
|
|
822
|
+
*
|
|
823
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
824
|
+
* may yet change.
|
|
825
|
+
*
|
|
826
|
+
* @default true
|
|
827
|
+
*/
|
|
828
|
+
ui?: boolean | UIConfig;
|
|
829
|
+
/**
|
|
830
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
831
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
832
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
833
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
834
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
835
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
836
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
837
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
838
|
+
* tool control to the editor (the current tool stays active).
|
|
839
|
+
*
|
|
840
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
841
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
842
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
843
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
844
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
845
|
+
* activation opens the file picker).
|
|
846
|
+
*/
|
|
847
|
+
activeTool?: {
|
|
848
|
+
type: Exclude<ToolType, "image">;
|
|
849
|
+
} | {
|
|
850
|
+
type: "custom";
|
|
851
|
+
customType: string;
|
|
852
|
+
};
|
|
461
853
|
zenModeEnabled?: boolean;
|
|
462
854
|
gridModeEnabled?: boolean;
|
|
463
855
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -466,6 +858,10 @@ export interface ExcalidrawProps {
|
|
|
466
858
|
name?: string;
|
|
467
859
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
468
860
|
UIOptions?: Partial<UIOptions>;
|
|
861
|
+
/**
|
|
862
|
+
* dimensions and size constraints for inserted images
|
|
863
|
+
*/
|
|
864
|
+
imageOptions?: ImageOptions;
|
|
469
865
|
detectScroll?: boolean;
|
|
470
866
|
handleKeyboardGlobally?: boolean;
|
|
471
867
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -485,9 +881,48 @@ export interface ExcalidrawProps {
|
|
|
485
881
|
aiEnabled?: boolean;
|
|
486
882
|
showDeprecatedFonts?: boolean;
|
|
487
883
|
renderScrollbars?: boolean;
|
|
884
|
+
viewportStatusFrame?: ViewportStatusFrame | null;
|
|
885
|
+
/**
|
|
886
|
+
* Rendered inside the UserList "who's here" dropdown (desktop) and inline
|
|
887
|
+
* in the mobile menu's collaborators section, below a divider. Accepts a
|
|
888
|
+
* render function — called with `isMobile` so hosts can render different
|
|
889
|
+
* UI for each surface — in addition to a plain node.
|
|
890
|
+
*/
|
|
891
|
+
currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
|
|
892
|
+
/**
|
|
893
|
+
* The user being followed on the canvas, if any. Controlled by the host —
|
|
894
|
+
* the editor never sets it; it emits follow/unfollow intents via
|
|
895
|
+
* `onUserFollow` (prop or imperative API) and renders the followed
|
|
896
|
+
* user's avatar highlight from this value.
|
|
897
|
+
*/
|
|
898
|
+
userToFollow?: UserToFollow | null;
|
|
899
|
+
/**
|
|
900
|
+
* Called before exporting to a file.
|
|
901
|
+
*
|
|
902
|
+
* Allows the host app to intercept and delay saving until async operations
|
|
903
|
+
* (e.g., images are loaded) complete.
|
|
904
|
+
*
|
|
905
|
+
* If Promise/AsyncGenerator is returned, a progress toast will be shown
|
|
906
|
+
* until the operation completes. Generator can yield progress updates.
|
|
907
|
+
*/
|
|
908
|
+
onExport?: (
|
|
909
|
+
/** type of export. Currently we only call for JSON exports or
|
|
910
|
+
* JSON-embedded PNG (which is also identified as `json` type here)*/
|
|
911
|
+
type: "json", data: {
|
|
912
|
+
elements: readonly ExcalidrawElement[];
|
|
913
|
+
appState: AppState;
|
|
914
|
+
files: BinaryFiles;
|
|
915
|
+
}, options: {
|
|
916
|
+
/** signal that gets aborted if user cancels the export (e.g. closes
|
|
917
|
+
* the native file picker dialog). In that case, you can either
|
|
918
|
+
* return immediately, or throw AbortError.
|
|
919
|
+
*/
|
|
920
|
+
signal: AbortSignal;
|
|
921
|
+
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
488
922
|
}
|
|
489
923
|
export type SceneData = {
|
|
490
|
-
|
|
924
|
+
/** Expects normalized elements; restore imported data before updating the scene. */
|
|
925
|
+
elements?: readonly ExcalidrawElement[] | null;
|
|
491
926
|
appState?: ImportedDataState["appState"];
|
|
492
927
|
collaborators?: Map<SocketId, Collaborator>;
|
|
493
928
|
captureUpdate?: CaptureUpdateActionType;
|
|
@@ -497,12 +932,21 @@ export type ExportOpts = {
|
|
|
497
932
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
498
933
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
499
934
|
};
|
|
935
|
+
export type ImageOptions = Partial<{
|
|
936
|
+
maxWidthOrHeight: number;
|
|
937
|
+
maxFileSizeBytes: number;
|
|
938
|
+
}>;
|
|
500
939
|
export type CanvasActions = Partial<{
|
|
501
940
|
changeViewBackgroundColor: boolean;
|
|
502
941
|
clearCanvas: boolean;
|
|
503
942
|
export: false | ExportOpts;
|
|
504
943
|
loadScene: boolean;
|
|
505
944
|
saveToActiveFile: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
947
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
948
|
+
* else default to false
|
|
949
|
+
* */
|
|
506
950
|
toggleTheme: boolean | null;
|
|
507
951
|
saveAsImage: boolean;
|
|
508
952
|
}>;
|
|
@@ -526,6 +970,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
526
970
|
export: ExportOpts;
|
|
527
971
|
};
|
|
528
972
|
}>;
|
|
973
|
+
imageOptions: Required<ImageOptions>;
|
|
529
974
|
detectScroll: boolean;
|
|
530
975
|
handleKeyboardGlobally: boolean;
|
|
531
976
|
isCollaborating: boolean;
|
|
@@ -537,6 +982,11 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
537
982
|
export type AppClassProperties = {
|
|
538
983
|
props: AppProps;
|
|
539
984
|
state: AppState;
|
|
985
|
+
readonly ownerDocument: Document;
|
|
986
|
+
readonly ownerWindow: Window & typeof globalThis;
|
|
987
|
+
renderEnvironment: RenderEnvironment;
|
|
988
|
+
api: App["api"];
|
|
989
|
+
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
540
990
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
541
991
|
/** static canvas */
|
|
542
992
|
canvas: HTMLCanvasElement;
|
|
@@ -551,12 +1001,11 @@ export type AppClassProperties = {
|
|
|
551
1001
|
scene: App["scene"];
|
|
552
1002
|
syncActionResult: App["syncActionResult"];
|
|
553
1003
|
fonts: App["fonts"];
|
|
554
|
-
|
|
1004
|
+
clipboard: App["clipboard"];
|
|
555
1005
|
id: App["id"];
|
|
556
1006
|
onInsertElements: App["onInsertElements"];
|
|
557
1007
|
onExportImage: App["onExportImage"];
|
|
558
|
-
|
|
559
|
-
scrollToContent: App["scrollToContent"];
|
|
1008
|
+
viewport: App["viewport"];
|
|
560
1009
|
addFiles: App["addFiles"];
|
|
561
1010
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
562
1011
|
togglePenMode: App["togglePenMode"];
|
|
@@ -567,17 +1016,37 @@ export type AppClassProperties = {
|
|
|
567
1016
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
568
1017
|
getName: App["getName"];
|
|
569
1018
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
570
|
-
|
|
1019
|
+
flowchart: App["flowchart"];
|
|
1020
|
+
drawShape: App["drawShape"];
|
|
1021
|
+
arrowText: App["arrowText"];
|
|
1022
|
+
textTool: App["textTool"];
|
|
1023
|
+
cursor: App["cursor"];
|
|
1024
|
+
bucketFill: App["bucketFill"];
|
|
1025
|
+
duplicate: App["duplicate"];
|
|
1026
|
+
toolDrag: App["toolDrag"];
|
|
1027
|
+
activeResizeHandle: App["activeResizeHandle"];
|
|
1028
|
+
selectionTool: App["selectionTool"];
|
|
1029
|
+
wrap: App["wrap"];
|
|
1030
|
+
modifiers: App["modifiers"];
|
|
1031
|
+
isToolLocked: App["isToolLocked"];
|
|
571
1032
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
572
1033
|
setPlugins: App["setPlugins"];
|
|
573
1034
|
plugins: App["plugins"];
|
|
574
|
-
getEditorUIOffsets: App["getEditorUIOffsets"];
|
|
575
1035
|
visibleElements: App["visibleElements"];
|
|
576
1036
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
577
1037
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
578
1038
|
updateEditorAtom: App["updateEditorAtom"];
|
|
579
1039
|
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
1040
|
+
onEvent: App["onEvent"];
|
|
1041
|
+
onStateChange: App["onStateChange"];
|
|
1042
|
+
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
1043
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
580
1044
|
bindModeHandler: App["bindModeHandler"];
|
|
1045
|
+
emitUserFollowIntent: App["emitUserFollowIntent"];
|
|
1046
|
+
requestUnfollow: App["requestUnfollow"];
|
|
1047
|
+
setAppState: App["setAppState"];
|
|
1048
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
1049
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
581
1050
|
};
|
|
582
1051
|
export type PointerDownState = Readonly<{
|
|
583
1052
|
origin: Readonly<{
|
|
@@ -611,8 +1080,12 @@ export type PointerDownState = Readonly<{
|
|
|
611
1080
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
612
1081
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
613
1082
|
wasAddedToSelection: boolean;
|
|
1083
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
614
1084
|
hasBeenDuplicated: boolean;
|
|
1085
|
+
advancedListMarkers: readonly ListMarkerAdvance[];
|
|
1086
|
+
editedTextId: ExcalidrawTextElement["id"] | null;
|
|
615
1087
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
1088
|
+
arrowLabel: boolean;
|
|
616
1089
|
};
|
|
617
1090
|
withCmdOrCtrl: boolean;
|
|
618
1091
|
drag: {
|
|
@@ -625,6 +1098,10 @@ export type PointerDownState = Readonly<{
|
|
|
625
1098
|
x: number;
|
|
626
1099
|
y: number;
|
|
627
1100
|
};
|
|
1101
|
+
lastOffset: {
|
|
1102
|
+
x: number;
|
|
1103
|
+
y: number;
|
|
1104
|
+
};
|
|
628
1105
|
blockDragging: boolean;
|
|
629
1106
|
};
|
|
630
1107
|
eventListeners: {
|
|
@@ -638,7 +1115,18 @@ export type PointerDownState = Readonly<{
|
|
|
638
1115
|
};
|
|
639
1116
|
}>;
|
|
640
1117
|
export type UnsubscribeCallback = () => void;
|
|
1118
|
+
export type ExcalidrawMountPayload = {
|
|
1119
|
+
excalidrawAPI: ExcalidrawImperativeAPI;
|
|
1120
|
+
container: HTMLDivElement | null;
|
|
1121
|
+
};
|
|
1122
|
+
export type ExcalidrawImperativeAPIEventMap = {
|
|
1123
|
+
"editor:mount": [payload: ExcalidrawMountPayload];
|
|
1124
|
+
"editor:initialize": [api: ExcalidrawImperativeAPI];
|
|
1125
|
+
"editor:unmount": [];
|
|
1126
|
+
};
|
|
641
1127
|
export interface ExcalidrawImperativeAPI {
|
|
1128
|
+
/** Whether the editor has been unmounted and the API is no longer usable. */
|
|
1129
|
+
isDestroyed: boolean;
|
|
642
1130
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
643
1131
|
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
644
1132
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
@@ -649,19 +1137,51 @@ export interface ExcalidrawImperativeAPI {
|
|
|
649
1137
|
history: {
|
|
650
1138
|
clear: InstanceType<typeof App>["resetHistory"];
|
|
651
1139
|
};
|
|
1140
|
+
/**
|
|
1141
|
+
* Selects elements (or their ids — one or many), adds them to or removes
|
|
1142
|
+
* them from the selection, or clears it — as the editor does: an element is
|
|
1143
|
+
* selected with its group (unless `deep`), a frame and its children aren't
|
|
1144
|
+
* selected at the same time, and locked elements are skipped (unless
|
|
1145
|
+
* `includeLocked`). Text editing and cropping end, and the link popup of a
|
|
1146
|
+
* lone selected element shows. Missing and deleted elements are skipped.
|
|
1147
|
+
*
|
|
1148
|
+
* By default the change is recorded for undo along with the next undoable
|
|
1149
|
+
* change — pass `captureUpdate` as for `updateScene()` otherwise. Like
|
|
1150
|
+
* `updateScene()`, it applies on the next render: read it back through
|
|
1151
|
+
* `onChange()` or `getAppState()` after that. Works in view mode too, where
|
|
1152
|
+
* the selection shows without transform handles.
|
|
1153
|
+
*/
|
|
1154
|
+
selection: Pick<InstanceType<typeof App>["selection"], "select" | "add" | "remove" | "clear">;
|
|
652
1155
|
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
|
653
1156
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
654
1157
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
655
1158
|
getName: InstanceType<typeof App>["getName"];
|
|
656
|
-
|
|
1159
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
1160
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
1161
|
+
/**
|
|
1162
|
+
* Atomically replaces all transient visual overrides. Values are copied;
|
|
1163
|
+
* omitted IDs/fields use document values, except for inherited label offsets.
|
|
1164
|
+
* null clears the snapshot.
|
|
1165
|
+
* Repaints without document changes, history entries or onChange events;
|
|
1166
|
+
* an equivalent snapshot may still repaint (clearing an already clear
|
|
1167
|
+
* snapshot does not), so submit only when something changed.
|
|
1168
|
+
* Finite opacity is clamped to 0–100; non-finite values reject the snapshot.
|
|
1169
|
+
* Unknown/deleted IDs are ignored when rendering. Reset/unmount clears it.
|
|
1170
|
+
* Bound labels inherit their container's offset; offsets targeting them are
|
|
1171
|
+
* ignored. Label opacity remains independent. Target frame children explicitly.
|
|
1172
|
+
* Frame opacity still multiplies child opacity. Decorations follow their owner.
|
|
1173
|
+
* Exports and interactive geometry (hit tests, selection, editing) use document
|
|
1174
|
+
* values, including while authoring an animation preview in edit mode.
|
|
1175
|
+
*/
|
|
1176
|
+
setElementRenderOverrides: InstanceType<typeof App>["setElementRenderOverrides"];
|
|
657
1177
|
registerAction: (action: Action) => void;
|
|
658
1178
|
refresh: InstanceType<typeof App>["refresh"];
|
|
659
1179
|
setToast: InstanceType<typeof App>["setToast"];
|
|
660
1180
|
addFiles: (data: BinaryFileData[]) => void;
|
|
661
1181
|
id: string;
|
|
662
1182
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
663
|
-
setCursor: InstanceType<typeof App>["
|
|
664
|
-
resetCursor: InstanceType<typeof App>["
|
|
1183
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
1184
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
665
1185
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
666
1186
|
getEditorInterface: () => EditorInterface;
|
|
667
1187
|
/**
|
|
@@ -676,13 +1196,14 @@ export interface ExcalidrawImperativeAPI {
|
|
|
676
1196
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
677
1197
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
678
1198
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
1199
|
+
onStateChange: InstanceType<typeof App>["onStateChange"];
|
|
1200
|
+
onEvent: InstanceType<typeof App>["onEvent"];
|
|
679
1201
|
}
|
|
680
1202
|
export type FrameNameBounds = {
|
|
681
1203
|
x: number;
|
|
682
1204
|
y: number;
|
|
683
1205
|
width: number;
|
|
684
1206
|
height: number;
|
|
685
|
-
angle: number;
|
|
686
1207
|
};
|
|
687
1208
|
export type FrameNameBoundsCache = {
|
|
688
1209
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -701,12 +1222,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
701
1222
|
export type JSONValue = string | number | boolean | null | object;
|
|
702
1223
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
703
1224
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
704
|
-
export type PendingExcalidrawElements =
|
|
1225
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
705
1226
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
706
1227
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
707
1228
|
export type GenerateDiagramToCode = (props: {
|
|
708
|
-
frame: ExcalidrawMagicFrameElement
|
|
709
|
-
children: readonly
|
|
1229
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
1230
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
1231
|
+
/**
|
|
1232
|
+
* Optional streaming hook. Call with the accumulated response text as it
|
|
1233
|
+
* streams in so the editor can progressively render the partial HTML
|
|
1234
|
+
* inside the generated frame.
|
|
1235
|
+
*/
|
|
1236
|
+
onPartial?: (html: string) => void;
|
|
710
1237
|
}) => MaybePromise<{
|
|
711
1238
|
html: string;
|
|
712
1239
|
}>;
|
|
@@ -716,3 +1243,103 @@ export type Offsets = Partial<{
|
|
|
716
1243
|
bottom: number;
|
|
717
1244
|
left: number;
|
|
718
1245
|
}>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
1248
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
1249
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
1250
|
+
*
|
|
1251
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
1252
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
1253
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
1254
|
+
* lies in the left half of the viewport it counts against the left
|
|
1255
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
1256
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
1257
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
1258
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
1259
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
1260
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
1261
|
+
* would swallow most of the viewport).
|
|
1262
|
+
*
|
|
1263
|
+
* The attribute should only be present while the surface is actually
|
|
1264
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
1265
|
+
* push the viewport around.
|
|
1266
|
+
*/
|
|
1267
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
1268
|
+
/**
|
|
1269
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
1270
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
1271
|
+
* currently rendered editor UI.
|
|
1272
|
+
*
|
|
1273
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
1274
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
1275
|
+
* reading-direction start side).
|
|
1276
|
+
*/
|
|
1277
|
+
export type ViewportOffsetsOptions = {
|
|
1278
|
+
/** padding added to each measured side (default 24) */
|
|
1279
|
+
padding?: number;
|
|
1280
|
+
paddingTop?: number;
|
|
1281
|
+
paddingRight?: number;
|
|
1282
|
+
paddingBottom?: number;
|
|
1283
|
+
paddingLeft?: number;
|
|
1284
|
+
/** final value for the given side, replacing the measured UI size
|
|
1285
|
+
* (padding is not added on top) */
|
|
1286
|
+
top?: number;
|
|
1287
|
+
bottom?: number;
|
|
1288
|
+
left?: number;
|
|
1289
|
+
right?: number;
|
|
1290
|
+
/**
|
|
1291
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
1292
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
1293
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
1294
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
1295
|
+
* phones (where these surfaces never occlude the canvas).
|
|
1296
|
+
*/
|
|
1297
|
+
reserve?: {
|
|
1298
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
1299
|
+
stylesPanel?: boolean;
|
|
1300
|
+
/** sidebar (e.g. library) */
|
|
1301
|
+
sidebar?: boolean;
|
|
1302
|
+
};
|
|
1303
|
+
};
|
|
1304
|
+
/**
|
|
1305
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
1306
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
1307
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
1308
|
+
*
|
|
1309
|
+
* Two (combinable) ways to specify:
|
|
1310
|
+
*
|
|
1311
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
1312
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
1313
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
1314
|
+
* set, see below).
|
|
1315
|
+
*
|
|
1316
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
1317
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
1318
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
1319
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
1320
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
1321
|
+
*
|
|
1322
|
+
* When both are given, a static side always wins for that side — it
|
|
1323
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
1324
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
1325
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* { top: 40 } // top 40px, other sides 0
|
|
1329
|
+
* { ui: true } // measured UI + default padding
|
|
1330
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
1331
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
1332
|
+
*/
|
|
1333
|
+
export type ViewportOffsets = Offsets & {
|
|
1334
|
+
ui?: true | ViewportOffsetsOptions;
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1338
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1339
|
+
* it can be measured on its own, and so that `getViewportOffsets` can
|
|
1340
|
+
* reserve space for it while it's hidden (see the `reserve` option).
|
|
1341
|
+
* Whenever a named surface is rendered, its measured footprint is
|
|
1342
|
+
* remembered; reserving uses that remembered footprint, or an approximate
|
|
1343
|
+
* default if the surface hasn't been rendered yet.
|
|
1344
|
+
*/
|
|
1345
|
+
export type ViewportUIName = "sidebar" | "stylesPanel" | "stats";
|