@excalidraw/math 0.18.0-4e0441e → 0.18.0-4e758db
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 +313 -116
- 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/bounds.d.ts +10 -0
- package/dist/types/common/src/colors.d.ts +81 -39
- package/dist/types/common/src/constants.d.ts +75 -34
- package/dist/types/common/src/editorInterface.d.ts +34 -0
- package/dist/types/common/src/font-metadata.d.ts +1 -3
- package/dist/types/common/src/index.d.ts +5 -0
- package/dist/types/common/src/keys.d.ts +5 -1
- 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/utility-types.d.ts +0 -1
- package/dist/types/common/src/utils.d.ts +45 -77
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +12 -8
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +30 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +79 -51
- package/dist/types/element/src/bounds.d.ts +25 -18
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +7 -2
- package/dist/types/element/src/comparisons.d.ts +10 -7
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/delta.d.ts +23 -1
- package/dist/types/element/src/distribute.d.ts +3 -2
- package/dist/types/element/src/dragElements.d.ts +30 -3
- package/dist/types/element/src/duplicate.d.ts +7 -6
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +11 -7
- package/dist/types/element/src/fractionalIndex.d.ts +4 -4
- package/dist/types/element/src/frame.d.ts +16 -11
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/heading.d.ts +2 -1
- package/dist/types/element/src/image.d.ts +1 -11
- package/dist/types/element/src/index.d.ts +9 -4
- package/dist/types/element/src/linearElementEditor.d.ts +48 -30
- package/dist/types/element/src/mutateElement.d.ts +6 -2
- package/dist/types/element/src/newElement.d.ts +44 -8
- package/dist/types/element/src/renderElement.d.ts +1 -10
- package/dist/types/element/src/resizeElements.d.ts +12 -12
- package/dist/types/element/src/resizeTest.d.ts +6 -5
- package/dist/types/element/src/selection.d.ts +14 -14
- package/dist/types/element/src/shape.d.ts +21 -8
- 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 +183 -0
- package/dist/types/element/src/textElement.d.ts +14 -10
- package/dist/types/element/src/textMeasurements.d.ts +1 -3
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/{excalidraw/data → element/src}/transform.d.ts +27 -8
- package/dist/types/element/src/transformHandles.d.ts +8 -27
- package/dist/types/element/src/typeChecks.d.ts +30 -31
- package/dist/types/element/src/types.d.ts +55 -20
- package/dist/types/element/src/utils.d.ts +15 -6
- package/dist/types/element/src/zindex.d.ts +7 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +206 -219
- package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +122 -131
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +446 -1594
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +149 -919
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +59 -64
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +192 -208
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +170 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +66 -77
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +121 -130
- package/dist/types/excalidraw/actions/actionExport.d.ts +200 -1449
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +11 -404
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionFrame.d.ts +318 -509
- package/dist/types/excalidraw/actions/actionGroup.d.ts +132 -149
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +205 -196
- package/dist/types/excalidraw/actions/actionLink.d.ts +73 -78
- package/dist/types/excalidraw/actions/actionMenu.d.ts +60 -71
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -369
- package/dist/types/excalidraw/actions/actionProperties.d.ts +213 -2610
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +66 -75
- package/dist/types/excalidraw/actions/actionStyles.d.ts +60 -64
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +186 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +74 -80
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +186 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +73 -78
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +72 -77
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +73 -78
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +73 -78
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
- 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/register.d.ts +2 -2
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +11 -7
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +50 -25
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +13 -38
- package/dist/types/excalidraw/components/Actions.d.ts +22 -14
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +104 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +552 -125
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/App.wheel.d.ts +33 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- package/dist/types/excalidraw/components/Card.d.ts +1 -3
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -5
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -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 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -4
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
- package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
- package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
- 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/InlineIcon.d.ts +2 -2
- 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/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
- package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/Modal.d.ts +0 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
- 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/PropertiesPopover.d.ts +1 -1
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
- package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
- 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/ScrollableList.d.ts +0 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
- package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
- package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
- 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/index.d.ts +7 -8
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
- package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
- package/dist/types/excalidraw/components/Toast.d.ts +11 -7
- 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/Trans.d.ts +2 -2
- 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 +10 -4
- 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/DropdownMenu.d.ts +48 -38
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
- package/dist/types/excalidraw/components/icons.d.ts +51 -22
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +25 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
- 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 +354 -7
- package/dist/types/excalidraw/data/encode.d.ts +4 -4
- package/dist/types/excalidraw/data/encryption.d.ts +5 -5
- package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
- package/dist/types/excalidraw/data/index.d.ts +8 -9
- package/dist/types/excalidraw/data/json.d.ts +183 -3
- package/dist/types/excalidraw/data/library.d.ts +25 -10
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/data/restore.d.ts +25 -10
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/errors.d.ts +14 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
- 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/useOutsideClick.d.ts +4 -3
- package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/i18n.d.ts +2 -2
- 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/renderer/animation.d.ts +16 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +31 -8
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
- package/dist/types/excalidraw/scene/Renderer.d.ts +477 -18
- package/dist/types/excalidraw/scene/export.d.ts +4 -4
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +27 -8
- package/dist/types/excalidraw/snapping.d.ts +12 -12
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
- package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
- package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +566 -55
- package/dist/types/excalidraw/viewport.d.ts +280 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +8 -5
- 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 +26 -2
- package/dist/types/math/src/range.d.ts +1 -3
- package/dist/types/math/src/segment.d.ts +9 -3
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/export.d.ts +9 -8
- package/dist/types/utils/src/index.d.ts +1 -2
- package/dist/types/utils/src/shape.d.ts +8 -8
- package/package.json +2 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -190
- 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 -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/InitializeApp.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -11
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
- 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 -10
- 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 -85
- 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 -23
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
|
|
2
|
-
import type { SuggestedBinding } from "@excalidraw/element";
|
|
1
|
+
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
|
|
3
2
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
4
3
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
5
|
-
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement,
|
|
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";
|
|
6
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
7
6
|
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
|
+
import type { GlobalPoint } from "@excalidraw/math";
|
|
8
8
|
import type { Action } from "./actions/types";
|
|
9
9
|
import type { Spreadsheet } from "./charts";
|
|
10
10
|
import type { ClipboardData } from "./clipboard";
|
|
11
11
|
import type App from "./components/App";
|
|
12
12
|
import type Library from "./data/library";
|
|
13
|
-
import type { FileSystemHandle } from "./data/filesystem";
|
|
14
13
|
import type { ContextMenuItems } from "./components/ContextMenu";
|
|
15
14
|
import type { SnapLine } from "./snapping";
|
|
16
15
|
import type { ImportedDataState } from "./data/types";
|
|
16
|
+
import type { SetViewportOptions } from "./viewport";
|
|
17
17
|
import type { Language } from "./i18n";
|
|
18
18
|
import type { isOverScrollBars } from "./scene/scrollbars";
|
|
19
19
|
import type React from "react";
|
|
20
20
|
import type { JSX } from "react";
|
|
21
|
+
export type { App };
|
|
21
22
|
export type SocketId = string & {
|
|
22
23
|
_brand: "SocketId";
|
|
23
24
|
};
|
|
@@ -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;
|
|
@@ -125,16 +126,22 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
125
126
|
frameRendering: AppState["frameRendering"];
|
|
126
127
|
currentHoveredFontFamily: AppState["currentHoveredFontFamily"];
|
|
127
128
|
hoveredElementIds: AppState["hoveredElementIds"];
|
|
129
|
+
suggestedBinding: AppState["suggestedBinding"];
|
|
128
130
|
croppingElementId: AppState["croppingElementId"];
|
|
129
131
|
}>;
|
|
130
132
|
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
133
|
+
activeTool: AppState["activeTool"];
|
|
131
134
|
activeEmbeddable: AppState["activeEmbeddable"];
|
|
132
135
|
selectionElement: AppState["selectionElement"];
|
|
133
136
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
134
137
|
selectedLinearElement: AppState["selectedLinearElement"];
|
|
135
138
|
multiElement: AppState["multiElement"];
|
|
139
|
+
newElement: AppState["newElement"];
|
|
136
140
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
137
|
-
|
|
141
|
+
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
142
|
+
gridModeEnabled: AppState["gridModeEnabled"];
|
|
143
|
+
suggestedBinding: AppState["suggestedBinding"];
|
|
144
|
+
hoveredArrowTextAnchor: AppState["hoveredArrowTextAnchor"];
|
|
138
145
|
isRotating: AppState["isRotating"];
|
|
139
146
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
140
147
|
collaborators: AppState["collaborators"];
|
|
@@ -145,6 +152,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
145
152
|
croppingElementId: AppState["croppingElementId"];
|
|
146
153
|
searchMatches: AppState["searchMatches"];
|
|
147
154
|
activeLockedId: AppState["activeLockedId"];
|
|
155
|
+
hoveredElementIds: AppState["hoveredElementIds"];
|
|
156
|
+
frameRendering: AppState["frameRendering"];
|
|
157
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
158
|
+
exportScale: AppState["exportScale"];
|
|
159
|
+
currentItemArrowType: AppState["currentItemArrowType"];
|
|
148
160
|
}>;
|
|
149
161
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
150
162
|
export type ObservedStandaloneAppState = {
|
|
@@ -163,6 +175,47 @@ export type ObservedElementsAppState = {
|
|
|
163
175
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
164
176
|
activeLockedId: AppState["activeLockedId"];
|
|
165
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
|
+
};
|
|
166
219
|
export interface AppState {
|
|
167
220
|
contextMenu: {
|
|
168
221
|
items: ContextMenuItems;
|
|
@@ -196,9 +249,41 @@ export interface AppState {
|
|
|
196
249
|
* - set on pointer down, updated during pointer move
|
|
197
250
|
*/
|
|
198
251
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
252
|
+
/**
|
|
253
|
+
* tracking current arrow binding editor state (takes into account
|
|
254
|
+
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
255
|
+
*/
|
|
199
256
|
isBindingEnabled: boolean;
|
|
200
|
-
|
|
201
|
-
|
|
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
|
+
/**
|
|
264
|
+
* user preference for what the wheel does: with a `trackpad` a plain wheel
|
|
265
|
+
* pans and ctrl/cmd+wheel (how a pinch is delivered) zooms; with a `mouse`
|
|
266
|
+
* a plain wheel zooms and ctrl/cmd+wheel pans vertically. `auto` resolves
|
|
267
|
+
* to `trackpad` until device detection exists — see `resolveInputDevice`
|
|
268
|
+
*/
|
|
269
|
+
inputDevice: InputDevice;
|
|
270
|
+
/**
|
|
271
|
+
* The bindable element the UI highlights for the user when an arrow is
|
|
272
|
+
* dragged or otherwise its endpoint being close to said element.
|
|
273
|
+
*/
|
|
274
|
+
suggestedBinding: {
|
|
275
|
+
element: NonDeleted<ExcalidrawBindableElement>;
|
|
276
|
+
midPoint?: GlobalPoint;
|
|
277
|
+
} | null;
|
|
278
|
+
/**
|
|
279
|
+
* Where on a hovered arrow the text tool would attach text if clicked —
|
|
280
|
+
* a free endpoint (binds the arrow to a new text element positioned against
|
|
281
|
+
* that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
|
|
282
|
+
*/
|
|
283
|
+
hoveredArrowTextAnchor: {
|
|
284
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
285
|
+
anchor: "start" | "end" | "label";
|
|
286
|
+
} | null;
|
|
202
287
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
203
288
|
frameRendering: {
|
|
204
289
|
enabled: boolean;
|
|
@@ -206,12 +291,15 @@ export interface AppState {
|
|
|
206
291
|
outline: boolean;
|
|
207
292
|
clip: boolean;
|
|
208
293
|
};
|
|
209
|
-
|
|
210
|
-
|
|
294
|
+
/**
|
|
295
|
+
* frame-like element whose name is currently being edited
|
|
296
|
+
*/
|
|
297
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
298
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
211
299
|
/**
|
|
212
300
|
* set when a new text is created or when an existing text is being edited
|
|
213
301
|
*/
|
|
214
|
-
editingTextElement:
|
|
302
|
+
editingTextElement: ExcalidrawTextElement | null;
|
|
215
303
|
activeTool: {
|
|
216
304
|
/**
|
|
217
305
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -232,11 +320,14 @@ export interface AppState {
|
|
|
232
320
|
exportWithDarkMode: boolean;
|
|
233
321
|
exportScale: number;
|
|
234
322
|
currentItemStrokeColor: string;
|
|
323
|
+
currentItemStickynoteStrokeColor: string;
|
|
324
|
+
currentItemStickynoteBackgroundColor: string;
|
|
235
325
|
currentItemBackgroundColor: string;
|
|
236
326
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
237
|
-
|
|
327
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
238
328
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
239
329
|
currentItemRoughness: number;
|
|
330
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
240
331
|
currentItemOpacity: number;
|
|
241
332
|
currentItemFontFamily: FontFamilyValues;
|
|
242
333
|
currentItemFontSize: number;
|
|
@@ -249,6 +340,7 @@ export interface AppState {
|
|
|
249
340
|
viewBackgroundColor: string;
|
|
250
341
|
scrollX: number;
|
|
251
342
|
scrollY: number;
|
|
343
|
+
scrollConstraints: ScrollConstraints | null;
|
|
252
344
|
cursorButton: "up" | "down";
|
|
253
345
|
scrolledOutside: boolean;
|
|
254
346
|
name: string | null;
|
|
@@ -268,9 +360,15 @@ export interface AppState {
|
|
|
268
360
|
tab: "text-to-diagram" | "mermaid";
|
|
269
361
|
} | {
|
|
270
362
|
name: "commandPalette";
|
|
363
|
+
} | {
|
|
364
|
+
name: "settings";
|
|
271
365
|
} | {
|
|
272
366
|
name: "elementLinkSelector";
|
|
273
367
|
sourceElementId: ExcalidrawElement["id"];
|
|
368
|
+
} | {
|
|
369
|
+
name: "charts";
|
|
370
|
+
data: Spreadsheet;
|
|
371
|
+
rawText: string;
|
|
274
372
|
};
|
|
275
373
|
/**
|
|
276
374
|
* Reflects user preference for whether the default sidebar should be docked.
|
|
@@ -293,7 +391,7 @@ export interface AppState {
|
|
|
293
391
|
selectedElementsAreBeingDragged: boolean;
|
|
294
392
|
shouldCacheIgnoreZoom: boolean;
|
|
295
393
|
toast: {
|
|
296
|
-
message:
|
|
394
|
+
message: React.ReactNode;
|
|
297
395
|
closable?: boolean;
|
|
298
396
|
duration?: number;
|
|
299
397
|
} | null;
|
|
@@ -315,21 +413,13 @@ export interface AppState {
|
|
|
315
413
|
height: number;
|
|
316
414
|
offsetTop: number;
|
|
317
415
|
offsetLeft: number;
|
|
318
|
-
fileHandle:
|
|
416
|
+
fileHandle: FileSystemFileHandle | null;
|
|
319
417
|
collaborators: Map<SocketId, Collaborator>;
|
|
320
418
|
stats: {
|
|
321
419
|
open: boolean;
|
|
322
420
|
/** bitmap. Use `STATS_PANELS` bit values */
|
|
323
421
|
panels: number;
|
|
324
422
|
};
|
|
325
|
-
currentChartType: ChartType;
|
|
326
|
-
pasteDialog: {
|
|
327
|
-
shown: false;
|
|
328
|
-
data: null;
|
|
329
|
-
} | {
|
|
330
|
-
shown: true;
|
|
331
|
-
data: Spreadsheet;
|
|
332
|
-
};
|
|
333
423
|
showHyperlinkPopup: false | "info" | "editor";
|
|
334
424
|
selectedLinearElement: LinearElementEditor | null;
|
|
335
425
|
snapLines: readonly SnapLine[];
|
|
@@ -338,10 +428,6 @@ export interface AppState {
|
|
|
338
428
|
y: number;
|
|
339
429
|
} | null;
|
|
340
430
|
objectsSnapModeEnabled: boolean;
|
|
341
|
-
/** the user's socket id & username who is being followed on the canvas */
|
|
342
|
-
userToFollow: UserToFollow | null;
|
|
343
|
-
/** the socket ids of the users following the current user */
|
|
344
|
-
followedBy: Set<SocketId>;
|
|
345
431
|
/** image cropping */
|
|
346
432
|
isCropping: boolean;
|
|
347
433
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
@@ -355,8 +441,21 @@ export interface AppState {
|
|
|
355
441
|
lockedMultiSelections: {
|
|
356
442
|
[groupId: string]: true;
|
|
357
443
|
};
|
|
358
|
-
|
|
359
|
-
|
|
444
|
+
bindMode: BindMode;
|
|
445
|
+
/** user-customized color-picker top picks (pinned via drag & drop from the
|
|
446
|
+
* color picker popup). `null` means no customization (defaults, or
|
|
447
|
+
* host-supplied `topPicks`, are used). Kept per picker. */
|
|
448
|
+
colorTopPicks: {
|
|
449
|
+
elementStroke: readonly string[] | null;
|
|
450
|
+
elementBackground: readonly string[] | null;
|
|
451
|
+
/** the bucket-fill tool keeps a list separate from `elementBackground`
|
|
452
|
+
* even though both drive `currentItemBackgroundColor` (its defaults and
|
|
453
|
+
* use case differ — no transparent) */
|
|
454
|
+
bucketFill: readonly string[] | null;
|
|
455
|
+
/** sticky notes are their own color domain (own defaults, own picks) */
|
|
456
|
+
stickyNoteStroke: readonly string[] | null;
|
|
457
|
+
stickyNoteBackground: readonly string[] | null;
|
|
458
|
+
};
|
|
360
459
|
}
|
|
361
460
|
export type SearchMatch = {
|
|
362
461
|
id: string;
|
|
@@ -369,7 +468,7 @@ export type SearchMatch = {
|
|
|
369
468
|
showOnCanvas: boolean;
|
|
370
469
|
}[];
|
|
371
470
|
};
|
|
372
|
-
export type UIAppState = Omit<AppState, "
|
|
471
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
|
|
373
472
|
export type NormalizedZoomValue = number & {
|
|
374
473
|
_brand: "normalizedZoom";
|
|
375
474
|
};
|
|
@@ -413,15 +512,178 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
413
512
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
414
513
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
415
514
|
}>;
|
|
515
|
+
export type ExcalidrawInitialState = {
|
|
516
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
517
|
+
};
|
|
416
518
|
export type OnUserFollowedPayload = {
|
|
417
519
|
userToFollow: UserToFollow;
|
|
418
520
|
action: "FOLLOW" | "UNFOLLOW";
|
|
419
521
|
};
|
|
522
|
+
export type ViewportStatusFrame = {
|
|
523
|
+
/** the badge (bottom-center pill) */
|
|
524
|
+
label?: {
|
|
525
|
+
label: React.ReactNode;
|
|
526
|
+
icon?: React.ReactNode;
|
|
527
|
+
/** badge background; defaults to var(--color-primary-hover) */
|
|
528
|
+
background?: string;
|
|
529
|
+
/** badge text color; defaults to var(--color-primary-light) */
|
|
530
|
+
color?: string;
|
|
531
|
+
/** makes the badge label interactive */
|
|
532
|
+
onClick?: () => void;
|
|
533
|
+
/** renders a close button when set */
|
|
534
|
+
onClose?: () => void;
|
|
535
|
+
};
|
|
536
|
+
/** viewport-edge border: CSS color, or `false` for none */
|
|
537
|
+
border: false | string;
|
|
538
|
+
};
|
|
539
|
+
export type OnExportProgress = {
|
|
540
|
+
type: "progress";
|
|
541
|
+
message?: React.ReactNode;
|
|
542
|
+
/** 0-1 range */
|
|
543
|
+
progress?: number;
|
|
544
|
+
};
|
|
545
|
+
export type InteractionConfig = {
|
|
546
|
+
/**
|
|
547
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
548
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
549
|
+
*/
|
|
550
|
+
enabled?: {
|
|
551
|
+
/**
|
|
552
|
+
* Element links render their link icon and stay clickable — clicking
|
|
553
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
554
|
+
* When disabled, link icons are not rendered at all.
|
|
555
|
+
*
|
|
556
|
+
* @default false
|
|
557
|
+
*/
|
|
558
|
+
links?: boolean;
|
|
559
|
+
/**
|
|
560
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
561
|
+
* activates them so their content can be used, same as in view mode.
|
|
562
|
+
*
|
|
563
|
+
* @default false
|
|
564
|
+
*/
|
|
565
|
+
embeds?: boolean;
|
|
566
|
+
/**
|
|
567
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
568
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
569
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
570
|
+
* regardless of their individual values.
|
|
571
|
+
*
|
|
572
|
+
* @default false
|
|
573
|
+
*/
|
|
574
|
+
interactiveContent?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
577
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
578
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
579
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
580
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
581
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
582
|
+
* page no longer scrolls over the editor.
|
|
583
|
+
*
|
|
584
|
+
* @default false
|
|
585
|
+
*/
|
|
586
|
+
navigation?: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
589
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
590
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
591
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
592
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
593
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
594
|
+
*
|
|
595
|
+
* @default false
|
|
596
|
+
*/
|
|
597
|
+
browserZoom?: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
600
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
601
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
602
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
603
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
604
|
+
*
|
|
605
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
606
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
607
|
+
*/
|
|
608
|
+
tools?: {
|
|
609
|
+
/**
|
|
610
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
611
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
612
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
613
|
+
*
|
|
614
|
+
* @default false
|
|
615
|
+
*/
|
|
616
|
+
laser?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
619
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
620
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
621
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
622
|
+
* after the first pointer interaction.
|
|
623
|
+
*
|
|
624
|
+
* @default false
|
|
625
|
+
*/
|
|
626
|
+
custom?: boolean;
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
export type UIConfig = {
|
|
631
|
+
/**
|
|
632
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
633
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is disabled.
|
|
634
|
+
*/
|
|
635
|
+
enabled: {
|
|
636
|
+
/**
|
|
637
|
+
* The zoom-out, reset-zoom, and zoom-in controls.
|
|
638
|
+
*
|
|
639
|
+
* @default false
|
|
640
|
+
*/
|
|
641
|
+
zoom?: boolean;
|
|
642
|
+
/**
|
|
643
|
+
* The button shown when the viewport is scrolled away from all content.
|
|
644
|
+
*
|
|
645
|
+
* @default false
|
|
646
|
+
*/
|
|
647
|
+
scrollBackToContent?: boolean;
|
|
648
|
+
};
|
|
649
|
+
};
|
|
420
650
|
export interface ExcalidrawProps {
|
|
651
|
+
className?: string;
|
|
652
|
+
/**
|
|
653
|
+
* Document that owns Excalidraw's mounted DOM.
|
|
654
|
+
*
|
|
655
|
+
* Set only when it differs from the global `document`, such as when code
|
|
656
|
+
* executing in a parent window mounts Excalidraw into an iframe document.
|
|
657
|
+
* The value must remain stable for the editor's lifetime.
|
|
658
|
+
*
|
|
659
|
+
* @default document
|
|
660
|
+
*/
|
|
661
|
+
ownerDocument?: Document;
|
|
421
662
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
663
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
664
|
+
/**
|
|
665
|
+
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
666
|
+
*/
|
|
422
667
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
423
668
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
424
|
-
|
|
669
|
+
initialState?: ExcalidrawInitialState;
|
|
670
|
+
/**
|
|
671
|
+
* Invoked as soon as the Excalidraw API is available
|
|
672
|
+
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
673
|
+
*/
|
|
674
|
+
onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
|
|
675
|
+
/**
|
|
676
|
+
* Invoked once the editor root is mounted.
|
|
677
|
+
*/
|
|
678
|
+
onMount?: (payload: ExcalidrawMountPayload) => void;
|
|
679
|
+
/**
|
|
680
|
+
* Invoked when the editor root is unmounted.
|
|
681
|
+
*/
|
|
682
|
+
onUnmount?: () => void;
|
|
683
|
+
/**
|
|
684
|
+
* Invoked once the initial scene is loaded.
|
|
685
|
+
*/
|
|
686
|
+
onInitialize?: (api: ExcalidrawImperativeAPI) => void;
|
|
425
687
|
isCollaborating?: boolean;
|
|
426
688
|
onPointerUpdate?: (payload: {
|
|
427
689
|
pointer: {
|
|
@@ -451,6 +713,70 @@ export interface ExcalidrawProps {
|
|
|
451
713
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
452
714
|
langCode?: Language["code"];
|
|
453
715
|
viewModeEnabled?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
718
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
719
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
720
|
+
* in any way. Implies view mode.
|
|
721
|
+
*
|
|
722
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
723
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
724
|
+
*
|
|
725
|
+
* ```tsx
|
|
726
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* @default true
|
|
730
|
+
*/
|
|
731
|
+
interaction?: boolean | InteractionConfig;
|
|
732
|
+
/**
|
|
733
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
734
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
735
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
736
|
+
* or render props continues to render, together with any supporting dialogs
|
|
737
|
+
* it opens.
|
|
738
|
+
*
|
|
739
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
740
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
741
|
+
* `false`.
|
|
742
|
+
*
|
|
743
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
744
|
+
* rest of the default UI is hidden (see `UIConfig`):
|
|
745
|
+
*
|
|
746
|
+
* ```tsx
|
|
747
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
748
|
+
* ```
|
|
749
|
+
*
|
|
750
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
751
|
+
* may yet change.
|
|
752
|
+
*
|
|
753
|
+
* @default true
|
|
754
|
+
*/
|
|
755
|
+
ui?: boolean | UIConfig;
|
|
756
|
+
/**
|
|
757
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
758
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
759
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
760
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
761
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
762
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
763
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
764
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
765
|
+
* tool control to the editor (the current tool stays active).
|
|
766
|
+
*
|
|
767
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
768
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
769
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
770
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
771
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
772
|
+
* activation opens the file picker).
|
|
773
|
+
*/
|
|
774
|
+
activeTool?: {
|
|
775
|
+
type: Exclude<ToolType, "image">;
|
|
776
|
+
} | {
|
|
777
|
+
type: "custom";
|
|
778
|
+
customType: string;
|
|
779
|
+
};
|
|
454
780
|
zenModeEnabled?: boolean;
|
|
455
781
|
gridModeEnabled?: boolean;
|
|
456
782
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -459,6 +785,10 @@ export interface ExcalidrawProps {
|
|
|
459
785
|
name?: string;
|
|
460
786
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
461
787
|
UIOptions?: Partial<UIOptions>;
|
|
788
|
+
/**
|
|
789
|
+
* dimensions and size constraints for inserted images
|
|
790
|
+
*/
|
|
791
|
+
imageOptions?: ImageOptions;
|
|
462
792
|
detectScroll?: boolean;
|
|
463
793
|
handleKeyboardGlobally?: boolean;
|
|
464
794
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -478,9 +808,48 @@ export interface ExcalidrawProps {
|
|
|
478
808
|
aiEnabled?: boolean;
|
|
479
809
|
showDeprecatedFonts?: boolean;
|
|
480
810
|
renderScrollbars?: boolean;
|
|
811
|
+
viewportStatusFrame?: ViewportStatusFrame | null;
|
|
812
|
+
/**
|
|
813
|
+
* Rendered inside the UserList "who's here" dropdown (desktop) and inline
|
|
814
|
+
* in the mobile menu's collaborators section, below a divider. Accepts a
|
|
815
|
+
* render function — called with `isMobile` so hosts can render different
|
|
816
|
+
* UI for each surface — in addition to a plain node.
|
|
817
|
+
*/
|
|
818
|
+
currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
|
|
819
|
+
/**
|
|
820
|
+
* The user being followed on the canvas, if any. Controlled by the host —
|
|
821
|
+
* the editor never sets it; it emits follow/unfollow intents via
|
|
822
|
+
* `onUserFollow` (prop or imperative API) and renders the followed
|
|
823
|
+
* user's avatar highlight from this value.
|
|
824
|
+
*/
|
|
825
|
+
userToFollow?: UserToFollow | null;
|
|
826
|
+
/**
|
|
827
|
+
* Called before exporting to a file.
|
|
828
|
+
*
|
|
829
|
+
* Allows the host app to intercept and delay saving until async operations
|
|
830
|
+
* (e.g., images are loaded) complete.
|
|
831
|
+
*
|
|
832
|
+
* If Promise/AsyncGenerator is returned, a progress toast will be shown
|
|
833
|
+
* until the operation completes. Generator can yield progress updates.
|
|
834
|
+
*/
|
|
835
|
+
onExport?: (
|
|
836
|
+
/** type of export. Currently we only call for JSON exports or
|
|
837
|
+
* JSON-embedded PNG (which is also identified as `json` type here)*/
|
|
838
|
+
type: "json", data: {
|
|
839
|
+
elements: readonly ExcalidrawElement[];
|
|
840
|
+
appState: AppState;
|
|
841
|
+
files: BinaryFiles;
|
|
842
|
+
}, options: {
|
|
843
|
+
/** signal that gets aborted if user cancels the export (e.g. closes
|
|
844
|
+
* the native file picker dialog). In that case, you can either
|
|
845
|
+
* return immediately, or throw AbortError.
|
|
846
|
+
*/
|
|
847
|
+
signal: AbortSignal;
|
|
848
|
+
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
481
849
|
}
|
|
482
850
|
export type SceneData = {
|
|
483
|
-
|
|
851
|
+
/** Expects normalized elements; restore imported data before updating the scene. */
|
|
852
|
+
elements?: readonly ExcalidrawElement[] | null;
|
|
484
853
|
appState?: ImportedDataState["appState"];
|
|
485
854
|
collaborators?: Map<SocketId, Collaborator>;
|
|
486
855
|
captureUpdate?: CaptureUpdateActionType;
|
|
@@ -490,12 +859,21 @@ export type ExportOpts = {
|
|
|
490
859
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
491
860
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
492
861
|
};
|
|
862
|
+
export type ImageOptions = Partial<{
|
|
863
|
+
maxWidthOrHeight: number;
|
|
864
|
+
maxFileSizeBytes: number;
|
|
865
|
+
}>;
|
|
493
866
|
export type CanvasActions = Partial<{
|
|
494
867
|
changeViewBackgroundColor: boolean;
|
|
495
868
|
clearCanvas: boolean;
|
|
496
869
|
export: false | ExportOpts;
|
|
497
870
|
loadScene: boolean;
|
|
498
871
|
saveToActiveFile: boolean;
|
|
872
|
+
/**
|
|
873
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
874
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
875
|
+
* else default to false
|
|
876
|
+
* */
|
|
499
877
|
toggleTheme: boolean | null;
|
|
500
878
|
saveAsImage: boolean;
|
|
501
879
|
}>;
|
|
@@ -505,6 +883,11 @@ export type UIOptions = Partial<{
|
|
|
505
883
|
tools: {
|
|
506
884
|
image: boolean;
|
|
507
885
|
};
|
|
886
|
+
/**
|
|
887
|
+
* Optionally control the editor form factor and desktop UI mode from the host app.
|
|
888
|
+
* If not provided, we will take care of it internally.
|
|
889
|
+
*/
|
|
890
|
+
getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
|
|
508
891
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
509
892
|
welcomeScreen?: boolean;
|
|
510
893
|
}>;
|
|
@@ -514,6 +897,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
514
897
|
export: ExportOpts;
|
|
515
898
|
};
|
|
516
899
|
}>;
|
|
900
|
+
imageOptions: Required<ImageOptions>;
|
|
517
901
|
detectScroll: boolean;
|
|
518
902
|
handleKeyboardGlobally: boolean;
|
|
519
903
|
isCollaborating: boolean;
|
|
@@ -525,6 +909,10 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
525
909
|
export type AppClassProperties = {
|
|
526
910
|
props: AppProps;
|
|
527
911
|
state: AppState;
|
|
912
|
+
readonly ownerDocument: Document;
|
|
913
|
+
readonly ownerWindow: Window & typeof globalThis;
|
|
914
|
+
api: App["api"];
|
|
915
|
+
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
528
916
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
529
917
|
/** static canvas */
|
|
530
918
|
canvas: HTMLCanvasElement;
|
|
@@ -535,7 +923,7 @@ export type AppClassProperties = {
|
|
|
535
923
|
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
536
924
|
}>;
|
|
537
925
|
files: BinaryFiles;
|
|
538
|
-
|
|
926
|
+
editorInterface: App["editorInterface"];
|
|
539
927
|
scene: App["scene"];
|
|
540
928
|
syncActionResult: App["syncActionResult"];
|
|
541
929
|
fonts: App["fonts"];
|
|
@@ -543,8 +931,7 @@ export type AppClassProperties = {
|
|
|
543
931
|
id: App["id"];
|
|
544
932
|
onInsertElements: App["onInsertElements"];
|
|
545
933
|
onExportImage: App["onExportImage"];
|
|
546
|
-
|
|
547
|
-
scrollToContent: App["scrollToContent"];
|
|
934
|
+
viewport: App["viewport"];
|
|
548
935
|
addFiles: App["addFiles"];
|
|
549
936
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
550
937
|
togglePenMode: App["togglePenMode"];
|
|
@@ -555,16 +942,32 @@ export type AppClassProperties = {
|
|
|
555
942
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
556
943
|
getName: App["getName"];
|
|
557
944
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
558
|
-
|
|
945
|
+
flowchart: App["flowchart"];
|
|
946
|
+
drawShape: App["drawShape"];
|
|
947
|
+
arrowText: App["arrowText"];
|
|
948
|
+
cursor: App["cursor"];
|
|
949
|
+
bucketFill: App["bucketFill"];
|
|
950
|
+
toolDrag: App["toolDrag"];
|
|
951
|
+
activeResizeHandle: App["activeResizeHandle"];
|
|
952
|
+
isToolLocked: App["isToolLocked"];
|
|
559
953
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
560
954
|
setPlugins: App["setPlugins"];
|
|
561
955
|
plugins: App["plugins"];
|
|
562
|
-
getEditorUIOffsets: App["getEditorUIOffsets"];
|
|
563
956
|
visibleElements: App["visibleElements"];
|
|
564
957
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
565
958
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
566
959
|
updateEditorAtom: App["updateEditorAtom"];
|
|
567
960
|
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
961
|
+
onEvent: App["onEvent"];
|
|
962
|
+
onStateChange: App["onStateChange"];
|
|
963
|
+
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
964
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
965
|
+
bindModeHandler: App["bindModeHandler"];
|
|
966
|
+
emitUserFollowIntent: App["emitUserFollowIntent"];
|
|
967
|
+
requestUnfollow: App["requestUnfollow"];
|
|
968
|
+
setAppState: App["setAppState"];
|
|
969
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
970
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
568
971
|
};
|
|
569
972
|
export type PointerDownState = Readonly<{
|
|
570
973
|
origin: Readonly<{
|
|
@@ -600,6 +1003,7 @@ export type PointerDownState = Readonly<{
|
|
|
600
1003
|
wasAddedToSelection: boolean;
|
|
601
1004
|
hasBeenDuplicated: boolean;
|
|
602
1005
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
1006
|
+
arrowLabel: boolean;
|
|
603
1007
|
};
|
|
604
1008
|
withCmdOrCtrl: boolean;
|
|
605
1009
|
drag: {
|
|
@@ -625,7 +1029,18 @@ export type PointerDownState = Readonly<{
|
|
|
625
1029
|
};
|
|
626
1030
|
}>;
|
|
627
1031
|
export type UnsubscribeCallback = () => void;
|
|
1032
|
+
export type ExcalidrawMountPayload = {
|
|
1033
|
+
excalidrawAPI: ExcalidrawImperativeAPI;
|
|
1034
|
+
container: HTMLDivElement | null;
|
|
1035
|
+
};
|
|
1036
|
+
export type ExcalidrawImperativeAPIEventMap = {
|
|
1037
|
+
"editor:mount": [payload: ExcalidrawMountPayload];
|
|
1038
|
+
"editor:initialize": [api: ExcalidrawImperativeAPI];
|
|
1039
|
+
"editor:unmount": [];
|
|
1040
|
+
};
|
|
628
1041
|
export interface ExcalidrawImperativeAPI {
|
|
1042
|
+
/** Whether the editor has been unmounted and the API is no longer usable. */
|
|
1043
|
+
isDestroyed: boolean;
|
|
629
1044
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
630
1045
|
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
631
1046
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
@@ -640,16 +1055,18 @@ export interface ExcalidrawImperativeAPI {
|
|
|
640
1055
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
641
1056
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
642
1057
|
getName: InstanceType<typeof App>["getName"];
|
|
643
|
-
|
|
1058
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
1059
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
644
1060
|
registerAction: (action: Action) => void;
|
|
645
1061
|
refresh: InstanceType<typeof App>["refresh"];
|
|
646
1062
|
setToast: InstanceType<typeof App>["setToast"];
|
|
647
1063
|
addFiles: (data: BinaryFileData[]) => void;
|
|
648
1064
|
id: string;
|
|
649
1065
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
650
|
-
setCursor: InstanceType<typeof App>["
|
|
651
|
-
resetCursor: InstanceType<typeof App>["
|
|
1066
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
1067
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
652
1068
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
1069
|
+
getEditorInterface: () => EditorInterface;
|
|
653
1070
|
/**
|
|
654
1071
|
* Disables rendering of frames (including element clipping), but currently
|
|
655
1072
|
* the frames are still interactive in edit mode. As such, this API should be
|
|
@@ -662,24 +1079,14 @@ export interface ExcalidrawImperativeAPI {
|
|
|
662
1079
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
663
1080
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
664
1081
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
1082
|
+
onStateChange: InstanceType<typeof App>["onStateChange"];
|
|
1083
|
+
onEvent: InstanceType<typeof App>["onEvent"];
|
|
665
1084
|
}
|
|
666
|
-
export type Device = Readonly<{
|
|
667
|
-
viewport: {
|
|
668
|
-
isMobile: boolean;
|
|
669
|
-
isLandscape: boolean;
|
|
670
|
-
};
|
|
671
|
-
editor: {
|
|
672
|
-
isMobile: boolean;
|
|
673
|
-
canFitSidebar: boolean;
|
|
674
|
-
};
|
|
675
|
-
isTouchScreen: boolean;
|
|
676
|
-
}>;
|
|
677
1085
|
export type FrameNameBounds = {
|
|
678
1086
|
x: number;
|
|
679
1087
|
y: number;
|
|
680
1088
|
width: number;
|
|
681
1089
|
height: number;
|
|
682
|
-
angle: number;
|
|
683
1090
|
};
|
|
684
1091
|
export type FrameNameBoundsCache = {
|
|
685
1092
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -698,12 +1105,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
698
1105
|
export type JSONValue = string | number | boolean | null | object;
|
|
699
1106
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
700
1107
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
701
|
-
export type PendingExcalidrawElements =
|
|
1108
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
702
1109
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
703
1110
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
704
1111
|
export type GenerateDiagramToCode = (props: {
|
|
705
|
-
frame: ExcalidrawMagicFrameElement
|
|
706
|
-
children: readonly
|
|
1112
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
1113
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
1114
|
+
/**
|
|
1115
|
+
* Optional streaming hook. Call with the accumulated response text as it
|
|
1116
|
+
* streams in so the editor can progressively render the partial HTML
|
|
1117
|
+
* inside the generated frame.
|
|
1118
|
+
*/
|
|
1119
|
+
onPartial?: (html: string) => void;
|
|
707
1120
|
}) => MaybePromise<{
|
|
708
1121
|
html: string;
|
|
709
1122
|
}>;
|
|
@@ -713,4 +1126,102 @@ export type Offsets = Partial<{
|
|
|
713
1126
|
bottom: number;
|
|
714
1127
|
left: number;
|
|
715
1128
|
}>;
|
|
716
|
-
|
|
1129
|
+
/**
|
|
1130
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
1131
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
1132
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
1133
|
+
*
|
|
1134
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
1135
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
1136
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
1137
|
+
* lies in the left half of the viewport it counts against the left
|
|
1138
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
1139
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
1140
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
1141
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
1142
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
1143
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
1144
|
+
* would swallow most of the viewport).
|
|
1145
|
+
*
|
|
1146
|
+
* The attribute should only be present while the surface is actually
|
|
1147
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
1148
|
+
* push the viewport around.
|
|
1149
|
+
*/
|
|
1150
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
1151
|
+
/**
|
|
1152
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
1153
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
1154
|
+
* currently rendered editor UI.
|
|
1155
|
+
*
|
|
1156
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
1157
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
1158
|
+
* reading-direction start side).
|
|
1159
|
+
*/
|
|
1160
|
+
export type ViewportOffsetsOptions = {
|
|
1161
|
+
/** padding added to each measured side (default 24) */
|
|
1162
|
+
padding?: number;
|
|
1163
|
+
paddingTop?: number;
|
|
1164
|
+
paddingRight?: number;
|
|
1165
|
+
paddingBottom?: number;
|
|
1166
|
+
paddingLeft?: number;
|
|
1167
|
+
/** final value for the given side, replacing the measured UI size
|
|
1168
|
+
* (padding is not added on top) */
|
|
1169
|
+
top?: number;
|
|
1170
|
+
bottom?: number;
|
|
1171
|
+
left?: number;
|
|
1172
|
+
right?: number;
|
|
1173
|
+
/**
|
|
1174
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
1175
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
1176
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
1177
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
1178
|
+
* phones (where these surfaces never occlude the canvas).
|
|
1179
|
+
*/
|
|
1180
|
+
reserve?: {
|
|
1181
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
1182
|
+
stylesPanel?: boolean;
|
|
1183
|
+
/** sidebar (e.g. library) */
|
|
1184
|
+
sidebar?: boolean;
|
|
1185
|
+
};
|
|
1186
|
+
};
|
|
1187
|
+
/**
|
|
1188
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
1189
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
1190
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
1191
|
+
*
|
|
1192
|
+
* Two (combinable) ways to specify:
|
|
1193
|
+
*
|
|
1194
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
1195
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
1196
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
1197
|
+
* set, see below).
|
|
1198
|
+
*
|
|
1199
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
1200
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
1201
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
1202
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
1203
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
1204
|
+
*
|
|
1205
|
+
* When both are given, a static side always wins for that side — it
|
|
1206
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
1207
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
1208
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* { top: 40 } // top 40px, other sides 0
|
|
1212
|
+
* { ui: true } // measured UI + default padding
|
|
1213
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
1214
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
1215
|
+
*/
|
|
1216
|
+
export type ViewportOffsets = Offsets & {
|
|
1217
|
+
ui?: true | ViewportOffsetsOptions;
|
|
1218
|
+
};
|
|
1219
|
+
/**
|
|
1220
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1221
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1222
|
+
* `getViewportOffsets` can reserve space for it while it's hidden (see the
|
|
1223
|
+
* `reserve` option). Whenever a named surface is rendered, its measured
|
|
1224
|
+
* footprint is remembered; reserving uses that remembered footprint, or an
|
|
1225
|
+
* approximate default if the surface hasn't been rendered yet.
|
|
1226
|
+
*/
|
|
1227
|
+
export type ViewportUIName = "sidebar" | "stylesPanel";
|