@excalidraw/math 0.18.0-ac0d305 → 0.18.0-afa3a65
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 +353 -171
- 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 +81 -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 +47 -78
- 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 +218 -222
- package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +130 -133
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +474 -1577
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +157 -905
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +63 -65
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +204 -211
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +169 -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 +70 -78
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +129 -132
- package/dist/types/excalidraw/actions/actionExport.d.ts +208 -1423
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +11 -396
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionFrame.d.ts +330 -508
- package/dist/types/excalidraw/actions/actionGroup.d.ts +140 -151
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +209 -197
- package/dist/types/excalidraw/actions/actionLink.d.ts +76 -78
- package/dist/types/excalidraw/actions/actionMenu.d.ts +65 -441
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -361
- package/dist/types/excalidraw/actions/actionProperties.d.ts +221 -2560
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +70 -76
- package/dist/types/excalidraw/actions/actionStyles.d.ts +64 -65
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +185 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +78 -81
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +185 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +77 -79
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +66 -75
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +76 -78
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +77 -79
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +77 -79
- 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 +5 -3
- 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 +43 -26
- 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 -36
- package/dist/types/excalidraw/components/Actions.d.ts +26 -11
- 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 +546 -124
- 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/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 +5 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +10 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +5 -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/CommandPalette.d.ts +1 -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/FontPickerTrigger.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 +3 -1
- 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 +6 -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/LibraryMenuSection.d.ts +1 -1
- 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 +5 -7
- 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 +2 -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/TextField.d.ts +1 -0
- package/dist/types/excalidraw/components/Toast.d.ts +11 -7
- package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
- 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 +47 -35
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
- 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 -23
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -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 +353 -8
- 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 +182 -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/data/types.d.ts +4 -1
- 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 +2 -2
- 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/shortcut.d.ts +1 -0
- 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 +561 -57
- package/dist/types/excalidraw/viewport.d.ts +279 -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 -186
- 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/TTDDialog/TTDDialogTrigger.d.ts +0 -9
- 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,42 @@ export type ObservedElementsAppState = {
|
|
|
163
175
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
164
176
|
activeLockedId: AppState["activeLockedId"];
|
|
165
177
|
};
|
|
178
|
+
export type BoxSelectionMode = "contain" | "overlap";
|
|
179
|
+
/**
|
|
180
|
+
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
181
|
+
*
|
|
182
|
+
* This is a private type. For public API, only use specific properties,
|
|
183
|
+
* needed.
|
|
184
|
+
*/
|
|
185
|
+
export type ScrollConstraints = {
|
|
186
|
+
x: number;
|
|
187
|
+
y: number;
|
|
188
|
+
width: number;
|
|
189
|
+
height: number;
|
|
190
|
+
/** when set, panning is constrained so the viewport stays within the box */
|
|
191
|
+
lockScroll: boolean;
|
|
192
|
+
/** when set, the viewport cannot zoom out below `zoom` */
|
|
193
|
+
lockZoom: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The zoom resolved after the `setViewport` navigation settled.
|
|
196
|
+
*/
|
|
197
|
+
zoom: number;
|
|
198
|
+
/**
|
|
199
|
+
* Pixel amount the viewport may overscroll past its resting clamp before
|
|
200
|
+
* snapping back (rubberband). Screen pixels, zoom-independent. Resolved
|
|
201
|
+
* from `lock.overscroll` at the time the lock was installed (`true` →
|
|
202
|
+
* default give, `false` → 0).
|
|
203
|
+
*/
|
|
204
|
+
overscroll: number;
|
|
205
|
+
/**
|
|
206
|
+
* Extra scrollable margin around the box (CSS-style), letting the viewport
|
|
207
|
+
* scroll past each box edge to reveal that much empty space. Values are
|
|
208
|
+
* viewport pixels and zoom-independent (a fixed on-screen distance).
|
|
209
|
+
* Resolved from the `offsets` passed to `setViewport` (see
|
|
210
|
+
* {@link ViewportOffsets}) at the time the lock was installed.
|
|
211
|
+
*/
|
|
212
|
+
offsets?: Offsets;
|
|
213
|
+
};
|
|
166
214
|
export interface AppState {
|
|
167
215
|
contextMenu: {
|
|
168
216
|
items: ContextMenuItems;
|
|
@@ -196,9 +244,34 @@ export interface AppState {
|
|
|
196
244
|
* - set on pointer down, updated during pointer move
|
|
197
245
|
*/
|
|
198
246
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
247
|
+
/**
|
|
248
|
+
* tracking current arrow binding editor state (takes into account
|
|
249
|
+
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
250
|
+
*/
|
|
199
251
|
isBindingEnabled: boolean;
|
|
200
|
-
|
|
201
|
-
|
|
252
|
+
/** user box selection preference; defaults to "contain" when unset */
|
|
253
|
+
boxSelectionMode: BoxSelectionMode;
|
|
254
|
+
/** user arrow binding preference */
|
|
255
|
+
bindingPreference: "enabled" | "disabled";
|
|
256
|
+
/** user preference whether arrow snap to midpoints while binding */
|
|
257
|
+
isMidpointSnappingEnabled: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* The bindable element the UI highlights for the user when an arrow is
|
|
260
|
+
* dragged or otherwise its endpoint being close to said element.
|
|
261
|
+
*/
|
|
262
|
+
suggestedBinding: {
|
|
263
|
+
element: NonDeleted<ExcalidrawBindableElement>;
|
|
264
|
+
midPoint?: GlobalPoint;
|
|
265
|
+
} | null;
|
|
266
|
+
/**
|
|
267
|
+
* Where on a hovered arrow the text tool would attach text if clicked —
|
|
268
|
+
* a free endpoint (binds the arrow to a new text element positioned against
|
|
269
|
+
* that endpoint) or the arrow's midpoint (adds a label bound to the arrow).
|
|
270
|
+
*/
|
|
271
|
+
hoveredArrowTextAnchor: {
|
|
272
|
+
elementId: ExcalidrawArrowElement["id"];
|
|
273
|
+
anchor: "start" | "end" | "label";
|
|
274
|
+
} | null;
|
|
202
275
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
203
276
|
frameRendering: {
|
|
204
277
|
enabled: boolean;
|
|
@@ -206,12 +279,15 @@ export interface AppState {
|
|
|
206
279
|
outline: boolean;
|
|
207
280
|
clip: boolean;
|
|
208
281
|
};
|
|
209
|
-
|
|
210
|
-
|
|
282
|
+
/**
|
|
283
|
+
* frame-like element whose name is currently being edited
|
|
284
|
+
*/
|
|
285
|
+
editingFrame: ExcalidrawFrameLikeElement["id"] | null;
|
|
286
|
+
elementsToHighlight: readonly NonDeletedExcalidrawElement[] | null;
|
|
211
287
|
/**
|
|
212
288
|
* set when a new text is created or when an existing text is being edited
|
|
213
289
|
*/
|
|
214
|
-
editingTextElement:
|
|
290
|
+
editingTextElement: ExcalidrawTextElement | null;
|
|
215
291
|
activeTool: {
|
|
216
292
|
/**
|
|
217
293
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -221,6 +297,10 @@ export interface AppState {
|
|
|
221
297
|
locked: boolean;
|
|
222
298
|
fromSelection: boolean;
|
|
223
299
|
} & ActiveTool;
|
|
300
|
+
preferredSelectionTool: {
|
|
301
|
+
type: "selection" | "lasso";
|
|
302
|
+
initialized: boolean;
|
|
303
|
+
};
|
|
224
304
|
penMode: boolean;
|
|
225
305
|
penDetected: boolean;
|
|
226
306
|
exportBackground: boolean;
|
|
@@ -228,11 +308,14 @@ export interface AppState {
|
|
|
228
308
|
exportWithDarkMode: boolean;
|
|
229
309
|
exportScale: number;
|
|
230
310
|
currentItemStrokeColor: string;
|
|
311
|
+
currentItemStickynoteStrokeColor: string;
|
|
312
|
+
currentItemStickynoteBackgroundColor: string;
|
|
231
313
|
currentItemBackgroundColor: string;
|
|
232
314
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
233
|
-
|
|
315
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
234
316
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
235
317
|
currentItemRoughness: number;
|
|
318
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
236
319
|
currentItemOpacity: number;
|
|
237
320
|
currentItemFontFamily: FontFamilyValues;
|
|
238
321
|
currentItemFontSize: number;
|
|
@@ -245,13 +328,14 @@ export interface AppState {
|
|
|
245
328
|
viewBackgroundColor: string;
|
|
246
329
|
scrollX: number;
|
|
247
330
|
scrollY: number;
|
|
331
|
+
scrollConstraints: ScrollConstraints | null;
|
|
248
332
|
cursorButton: "up" | "down";
|
|
249
333
|
scrolledOutside: boolean;
|
|
250
334
|
name: string | null;
|
|
251
335
|
isResizing: boolean;
|
|
252
336
|
isRotating: boolean;
|
|
253
337
|
zoom: Zoom;
|
|
254
|
-
openMenu: "canvas" |
|
|
338
|
+
openMenu: "canvas" | null;
|
|
255
339
|
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
|
|
256
340
|
openSidebar: {
|
|
257
341
|
name: SidebarName;
|
|
@@ -264,9 +348,15 @@ export interface AppState {
|
|
|
264
348
|
tab: "text-to-diagram" | "mermaid";
|
|
265
349
|
} | {
|
|
266
350
|
name: "commandPalette";
|
|
351
|
+
} | {
|
|
352
|
+
name: "settings";
|
|
267
353
|
} | {
|
|
268
354
|
name: "elementLinkSelector";
|
|
269
355
|
sourceElementId: ExcalidrawElement["id"];
|
|
356
|
+
} | {
|
|
357
|
+
name: "charts";
|
|
358
|
+
data: Spreadsheet;
|
|
359
|
+
rawText: string;
|
|
270
360
|
};
|
|
271
361
|
/**
|
|
272
362
|
* Reflects user preference for whether the default sidebar should be docked.
|
|
@@ -289,7 +379,7 @@ export interface AppState {
|
|
|
289
379
|
selectedElementsAreBeingDragged: boolean;
|
|
290
380
|
shouldCacheIgnoreZoom: boolean;
|
|
291
381
|
toast: {
|
|
292
|
-
message:
|
|
382
|
+
message: React.ReactNode;
|
|
293
383
|
closable?: boolean;
|
|
294
384
|
duration?: number;
|
|
295
385
|
} | null;
|
|
@@ -311,21 +401,13 @@ export interface AppState {
|
|
|
311
401
|
height: number;
|
|
312
402
|
offsetTop: number;
|
|
313
403
|
offsetLeft: number;
|
|
314
|
-
fileHandle:
|
|
404
|
+
fileHandle: FileSystemFileHandle | null;
|
|
315
405
|
collaborators: Map<SocketId, Collaborator>;
|
|
316
406
|
stats: {
|
|
317
407
|
open: boolean;
|
|
318
408
|
/** bitmap. Use `STATS_PANELS` bit values */
|
|
319
409
|
panels: number;
|
|
320
410
|
};
|
|
321
|
-
currentChartType: ChartType;
|
|
322
|
-
pasteDialog: {
|
|
323
|
-
shown: false;
|
|
324
|
-
data: null;
|
|
325
|
-
} | {
|
|
326
|
-
shown: true;
|
|
327
|
-
data: Spreadsheet;
|
|
328
|
-
};
|
|
329
411
|
showHyperlinkPopup: false | "info" | "editor";
|
|
330
412
|
selectedLinearElement: LinearElementEditor | null;
|
|
331
413
|
snapLines: readonly SnapLine[];
|
|
@@ -334,10 +416,6 @@ export interface AppState {
|
|
|
334
416
|
y: number;
|
|
335
417
|
} | null;
|
|
336
418
|
objectsSnapModeEnabled: boolean;
|
|
337
|
-
/** the user's socket id & username who is being followed on the canvas */
|
|
338
|
-
userToFollow: UserToFollow | null;
|
|
339
|
-
/** the socket ids of the users following the current user */
|
|
340
|
-
followedBy: Set<SocketId>;
|
|
341
419
|
/** image cropping */
|
|
342
420
|
isCropping: boolean;
|
|
343
421
|
croppingElementId: ExcalidrawElement["id"] | null;
|
|
@@ -351,8 +429,21 @@ export interface AppState {
|
|
|
351
429
|
lockedMultiSelections: {
|
|
352
430
|
[groupId: string]: true;
|
|
353
431
|
};
|
|
354
|
-
|
|
355
|
-
|
|
432
|
+
bindMode: BindMode;
|
|
433
|
+
/** user-customized color-picker top picks (pinned via drag & drop from the
|
|
434
|
+
* color picker popup). `null` means no customization (defaults, or
|
|
435
|
+
* host-supplied `topPicks`, are used). Kept per picker. */
|
|
436
|
+
colorTopPicks: {
|
|
437
|
+
elementStroke: readonly string[] | null;
|
|
438
|
+
elementBackground: readonly string[] | null;
|
|
439
|
+
/** the bucket-fill tool keeps a list separate from `elementBackground`
|
|
440
|
+
* even though both drive `currentItemBackgroundColor` (its defaults and
|
|
441
|
+
* use case differ — no transparent) */
|
|
442
|
+
bucketFill: readonly string[] | null;
|
|
443
|
+
/** sticky notes are their own color domain (own defaults, own picks) */
|
|
444
|
+
stickyNoteStroke: readonly string[] | null;
|
|
445
|
+
stickyNoteBackground: readonly string[] | null;
|
|
446
|
+
};
|
|
356
447
|
}
|
|
357
448
|
export type SearchMatch = {
|
|
358
449
|
id: string;
|
|
@@ -365,7 +456,7 @@ export type SearchMatch = {
|
|
|
365
456
|
showOnCanvas: boolean;
|
|
366
457
|
}[];
|
|
367
458
|
};
|
|
368
|
-
export type UIAppState = Omit<AppState, "
|
|
459
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY" | "zoom" | "shouldCacheIgnoreZoom" | "snapLines" | "originSnapOffset" | "suggestedBinding" | "hoveredArrowTextAnchor" | "frameToHighlight" | "elementsToHighlight">;
|
|
369
460
|
export type NormalizedZoomValue = number & {
|
|
370
461
|
_brand: "normalizedZoom";
|
|
371
462
|
};
|
|
@@ -409,15 +500,178 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
409
500
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
410
501
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
411
502
|
}>;
|
|
503
|
+
export type ExcalidrawInitialState = {
|
|
504
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
505
|
+
};
|
|
412
506
|
export type OnUserFollowedPayload = {
|
|
413
507
|
userToFollow: UserToFollow;
|
|
414
508
|
action: "FOLLOW" | "UNFOLLOW";
|
|
415
509
|
};
|
|
510
|
+
export type ViewportStatusFrame = {
|
|
511
|
+
/** the badge (bottom-center pill) */
|
|
512
|
+
label?: {
|
|
513
|
+
label: React.ReactNode;
|
|
514
|
+
icon?: React.ReactNode;
|
|
515
|
+
/** badge background; defaults to var(--color-primary-hover) */
|
|
516
|
+
background?: string;
|
|
517
|
+
/** badge text color; defaults to var(--color-primary-light) */
|
|
518
|
+
color?: string;
|
|
519
|
+
/** makes the badge label interactive */
|
|
520
|
+
onClick?: () => void;
|
|
521
|
+
/** renders a close button when set */
|
|
522
|
+
onClose?: () => void;
|
|
523
|
+
};
|
|
524
|
+
/** viewport-edge border: CSS color, or `false` for none */
|
|
525
|
+
border: false | string;
|
|
526
|
+
};
|
|
527
|
+
export type OnExportProgress = {
|
|
528
|
+
type: "progress";
|
|
529
|
+
message?: React.ReactNode;
|
|
530
|
+
/** 0-1 range */
|
|
531
|
+
progress?: number;
|
|
532
|
+
};
|
|
533
|
+
export type InteractionConfig = {
|
|
534
|
+
/**
|
|
535
|
+
* Interactions that stay enabled while the editor is otherwise
|
|
536
|
+
* non-interactive. Opt-in: anything omitted or `false` is disabled.
|
|
537
|
+
*/
|
|
538
|
+
enabled?: {
|
|
539
|
+
/**
|
|
540
|
+
* Element links render their link icon and stay clickable — clicking
|
|
541
|
+
* anywhere on a linked element opens the link, same as in view mode.
|
|
542
|
+
* When disabled, link icons are not rendered at all.
|
|
543
|
+
*
|
|
544
|
+
* @default false
|
|
545
|
+
*/
|
|
546
|
+
links?: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Embeddable & iframe elements stay interactive — hovering & clicking
|
|
549
|
+
* activates them so their content can be used, same as in view mode.
|
|
550
|
+
*
|
|
551
|
+
* @default false
|
|
552
|
+
*/
|
|
553
|
+
embeds?: boolean;
|
|
554
|
+
/**
|
|
555
|
+
* Umbrella for all interactive content on canvas — shorthand for
|
|
556
|
+
* enabling `links` & `embeds` (and future interactive content kinds)
|
|
557
|
+
* together. Additive: `interactiveContent: true` enables them
|
|
558
|
+
* regardless of their individual values.
|
|
559
|
+
*
|
|
560
|
+
* @default false
|
|
561
|
+
*/
|
|
562
|
+
interactiveContent?: boolean;
|
|
563
|
+
/**
|
|
564
|
+
* Canvas navigation — panning (pointer drag, wheel, PageUp/PageDown)
|
|
565
|
+
* and zooming (ctrl/cmd + wheel, pinch, and the canvas zoom &
|
|
566
|
+
* zoom-to-fit shortcuts: ctrl/cmd +/-/0, shift+1/2/3), same as in view
|
|
567
|
+
* mode. Respects `appState.scrollConstraints` if set, so it composes
|
|
568
|
+
* with viewport locking. The rest of the keyboard stays disabled. Note
|
|
569
|
+
* the editor consumes wheel & touch input again when enabled, so the
|
|
570
|
+
* page no longer scrolls over the editor.
|
|
571
|
+
*
|
|
572
|
+
* @default false
|
|
573
|
+
*/
|
|
574
|
+
navigation?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Whether the browser's own zoom remains available over the editor —
|
|
577
|
+
* ctrl/cmd + wheel, pinch, and (while the editor has focus)
|
|
578
|
+
* ctrl/cmd +/-/0 shortcuts. Prevented by default, mirroring the
|
|
579
|
+
* interactive editor. Regular page scrolling stays available either way.
|
|
580
|
+
* With `navigation` enabled, the zoom input (wheel, pinch, keyboard
|
|
581
|
+
* shortcuts) zooms the canvas instead either way, making this moot.
|
|
582
|
+
*
|
|
583
|
+
* @default false
|
|
584
|
+
*/
|
|
585
|
+
browserZoom?: boolean;
|
|
586
|
+
/**
|
|
587
|
+
* Tools that stay user-driven while the editor is otherwise
|
|
588
|
+
* non-interactive: pointer input keeps driving the listed tool when it's
|
|
589
|
+
* the active tool. Does not enable user-driven tool *switching* — the
|
|
590
|
+
* keyboard stays disabled and tool selection remains host-driven
|
|
591
|
+
* (`ExcalidrawAPI.setActiveTool`).
|
|
592
|
+
*
|
|
593
|
+
* Composes with `navigation`: the enabled tool wins the primary-pointer
|
|
594
|
+
* drag, while wheel input (and wheel-button drag) still pans/zooms.
|
|
595
|
+
*/
|
|
596
|
+
tools?: {
|
|
597
|
+
/**
|
|
598
|
+
* The laser pointer stays usable — pointer strokes draw laser trails
|
|
599
|
+
* and pointer positions keep broadcasting via `onPointerUpdate`, so
|
|
600
|
+
* e.g. collaborators see a presenter's laser & cursor.
|
|
601
|
+
*
|
|
602
|
+
* @default false
|
|
603
|
+
*/
|
|
604
|
+
laser?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Custom tools (`activeTool.type === "custom"`) stay usable — the
|
|
607
|
+
* editor keeps dispatching `onPointerDown` / `onPointerUp` for them.
|
|
608
|
+
* Tool behavior is host-implemented; activate custom tools with
|
|
609
|
+
* `locked: true` or they revert to the selection tool (and go inert)
|
|
610
|
+
* after the first pointer interaction.
|
|
611
|
+
*
|
|
612
|
+
* @default false
|
|
613
|
+
*/
|
|
614
|
+
custom?: boolean;
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
export type UIConfig = {
|
|
619
|
+
/**
|
|
620
|
+
* Default UI controls that stay enabled while the rest of Excalidraw's
|
|
621
|
+
* default UI is hidden. Opt-in: anything omitted or `false` is disabled.
|
|
622
|
+
*/
|
|
623
|
+
enabled: {
|
|
624
|
+
/**
|
|
625
|
+
* The zoom-out, reset-zoom, and zoom-in controls.
|
|
626
|
+
*
|
|
627
|
+
* @default false
|
|
628
|
+
*/
|
|
629
|
+
zoom?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* The button shown when the viewport is scrolled away from all content.
|
|
632
|
+
*
|
|
633
|
+
* @default false
|
|
634
|
+
*/
|
|
635
|
+
scrollBackToContent?: boolean;
|
|
636
|
+
};
|
|
637
|
+
};
|
|
416
638
|
export interface ExcalidrawProps {
|
|
639
|
+
className?: string;
|
|
640
|
+
/**
|
|
641
|
+
* Document that owns Excalidraw's mounted DOM.
|
|
642
|
+
*
|
|
643
|
+
* Set only when it differs from the global `document`, such as when code
|
|
644
|
+
* executing in a parent window mounts Excalidraw into an iframe document.
|
|
645
|
+
* The value must remain stable for the editor's lifetime.
|
|
646
|
+
*
|
|
647
|
+
* @default document
|
|
648
|
+
*/
|
|
649
|
+
ownerDocument?: Document;
|
|
417
650
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
651
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
652
|
+
/**
|
|
653
|
+
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
654
|
+
*/
|
|
418
655
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
419
656
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
420
|
-
|
|
657
|
+
initialState?: ExcalidrawInitialState;
|
|
658
|
+
/**
|
|
659
|
+
* Invoked as soon as the Excalidraw API is available
|
|
660
|
+
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
661
|
+
*/
|
|
662
|
+
onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
|
|
663
|
+
/**
|
|
664
|
+
* Invoked once the editor root is mounted.
|
|
665
|
+
*/
|
|
666
|
+
onMount?: (payload: ExcalidrawMountPayload) => void;
|
|
667
|
+
/**
|
|
668
|
+
* Invoked when the editor root is unmounted.
|
|
669
|
+
*/
|
|
670
|
+
onUnmount?: () => void;
|
|
671
|
+
/**
|
|
672
|
+
* Invoked once the initial scene is loaded.
|
|
673
|
+
*/
|
|
674
|
+
onInitialize?: (api: ExcalidrawImperativeAPI) => void;
|
|
421
675
|
isCollaborating?: boolean;
|
|
422
676
|
onPointerUpdate?: (payload: {
|
|
423
677
|
pointer: {
|
|
@@ -443,9 +697,74 @@ export interface ExcalidrawProps {
|
|
|
443
697
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
444
698
|
/** excludes the duplicated elements */
|
|
445
699
|
prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
|
|
700
|
+
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
446
701
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
447
702
|
langCode?: Language["code"];
|
|
448
703
|
viewModeEnabled?: boolean;
|
|
704
|
+
/**
|
|
705
|
+
* Whether the editor accepts user input (pointer, keyboard, wheel, touch,
|
|
706
|
+
* clipboard, drag&drop). When `false`, the scene still renders and reacts
|
|
707
|
+
* to programmatic updates (imperative API), but the user cannot affect it
|
|
708
|
+
* in any way. Implies view mode.
|
|
709
|
+
*
|
|
710
|
+
* Pass a config object to keep specific interactions enabled while the
|
|
711
|
+
* editor is otherwise non-interactive (see `InteractionConfig`):
|
|
712
|
+
*
|
|
713
|
+
* ```tsx
|
|
714
|
+
* <Excalidraw interaction={{ enabled: { links: true } }} />
|
|
715
|
+
* ```
|
|
716
|
+
*
|
|
717
|
+
* @default true
|
|
718
|
+
*/
|
|
719
|
+
interaction?: boolean | InteractionConfig;
|
|
720
|
+
/**
|
|
721
|
+
* Whether Excalidraw's default UI is rendered — toolbar, default menus,
|
|
722
|
+
* footer controls, sidebars, and canvas popups. Host UI passed through
|
|
723
|
+
* children (including exported components such as `MainMenu` and `Footer`)
|
|
724
|
+
* or render props continues to render, together with any supporting dialogs
|
|
725
|
+
* it opens.
|
|
726
|
+
*
|
|
727
|
+
* Canvas content (elements, text editing surface, frame names, embeds) still
|
|
728
|
+
* renders, and the editor remains interactive unless `interaction` is set to
|
|
729
|
+
* `false`.
|
|
730
|
+
*
|
|
731
|
+
* Pass a config object to keep specific default controls rendered while the
|
|
732
|
+
* rest of the default UI is hidden (see `UIConfig`):
|
|
733
|
+
*
|
|
734
|
+
* ```tsx
|
|
735
|
+
* <Excalidraw ui={{ enabled: { zoom: true } }} />
|
|
736
|
+
* ```
|
|
737
|
+
*
|
|
738
|
+
* NOTE: this is WIP and what default UI is/is not rendered when ui=false
|
|
739
|
+
* may yet change.
|
|
740
|
+
*
|
|
741
|
+
* @default true
|
|
742
|
+
*/
|
|
743
|
+
ui?: boolean | UIConfig;
|
|
744
|
+
/**
|
|
745
|
+
* Forces the active editor tool (controlled). While set, user- and
|
|
746
|
+
* API-driven tool switching is ignored — `setActiveTool` refuses with a
|
|
747
|
+
* console warning, non-forced toolbar buttons render disabled — and the
|
|
748
|
+
* editor snaps back if internal flows reset the tool. The forced tool
|
|
749
|
+
* behaves as if locked (see the tool lock / padlock): it doesn't revert to
|
|
750
|
+
* the selection tool after use, and elements drawn with it aren't
|
|
751
|
+
* auto-selected — without mutating `appState.activeTool.locked`, so the
|
|
752
|
+
* user's persisted padlock preference stays untouched. Unset to return
|
|
753
|
+
* tool control to the editor (the current tool stays active).
|
|
754
|
+
*
|
|
755
|
+
* The forced tool must be activatable to take effect: not disabled via
|
|
756
|
+
* `UIOptions.tools`, and — while the editor is non-interactive — allowed
|
|
757
|
+
* via `interaction.enabled.tools`. Otherwise the editor stays on (or, when
|
|
758
|
+
* non-interactive, resets to) the `selection` tool, and the forced tool is
|
|
759
|
+
* applied once it becomes activatable. `image` cannot be forced (its
|
|
760
|
+
* activation opens the file picker).
|
|
761
|
+
*/
|
|
762
|
+
activeTool?: {
|
|
763
|
+
type: Exclude<ToolType, "image">;
|
|
764
|
+
} | {
|
|
765
|
+
type: "custom";
|
|
766
|
+
customType: string;
|
|
767
|
+
};
|
|
449
768
|
zenModeEnabled?: boolean;
|
|
450
769
|
gridModeEnabled?: boolean;
|
|
451
770
|
objectsSnapModeEnabled?: boolean;
|
|
@@ -454,6 +773,10 @@ export interface ExcalidrawProps {
|
|
|
454
773
|
name?: string;
|
|
455
774
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
456
775
|
UIOptions?: Partial<UIOptions>;
|
|
776
|
+
/**
|
|
777
|
+
* dimensions and size constraints for inserted images
|
|
778
|
+
*/
|
|
779
|
+
imageOptions?: ImageOptions;
|
|
457
780
|
detectScroll?: boolean;
|
|
458
781
|
handleKeyboardGlobally?: boolean;
|
|
459
782
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -473,9 +796,48 @@ export interface ExcalidrawProps {
|
|
|
473
796
|
aiEnabled?: boolean;
|
|
474
797
|
showDeprecatedFonts?: boolean;
|
|
475
798
|
renderScrollbars?: boolean;
|
|
799
|
+
viewportStatusFrame?: ViewportStatusFrame | null;
|
|
800
|
+
/**
|
|
801
|
+
* Rendered inside the UserList "who's here" dropdown (desktop) and inline
|
|
802
|
+
* in the mobile menu's collaborators section, below a divider. Accepts a
|
|
803
|
+
* render function — called with `isMobile` so hosts can render different
|
|
804
|
+
* UI for each surface — in addition to a plain node.
|
|
805
|
+
*/
|
|
806
|
+
currentUserControls?: React.ReactNode | ((isMobile: boolean) => React.ReactNode);
|
|
807
|
+
/**
|
|
808
|
+
* The user being followed on the canvas, if any. Controlled by the host —
|
|
809
|
+
* the editor never sets it; it emits follow/unfollow intents via
|
|
810
|
+
* `onUserFollow` (prop or imperative API) and renders the followed
|
|
811
|
+
* user's avatar highlight from this value.
|
|
812
|
+
*/
|
|
813
|
+
userToFollow?: UserToFollow | null;
|
|
814
|
+
/**
|
|
815
|
+
* Called before exporting to a file.
|
|
816
|
+
*
|
|
817
|
+
* Allows the host app to intercept and delay saving until async operations
|
|
818
|
+
* (e.g., images are loaded) complete.
|
|
819
|
+
*
|
|
820
|
+
* If Promise/AsyncGenerator is returned, a progress toast will be shown
|
|
821
|
+
* until the operation completes. Generator can yield progress updates.
|
|
822
|
+
*/
|
|
823
|
+
onExport?: (
|
|
824
|
+
/** type of export. Currently we only call for JSON exports or
|
|
825
|
+
* JSON-embedded PNG (which is also identified as `json` type here)*/
|
|
826
|
+
type: "json", data: {
|
|
827
|
+
elements: readonly ExcalidrawElement[];
|
|
828
|
+
appState: AppState;
|
|
829
|
+
files: BinaryFiles;
|
|
830
|
+
}, options: {
|
|
831
|
+
/** signal that gets aborted if user cancels the export (e.g. closes
|
|
832
|
+
* the native file picker dialog). In that case, you can either
|
|
833
|
+
* return immediately, or throw AbortError.
|
|
834
|
+
*/
|
|
835
|
+
signal: AbortSignal;
|
|
836
|
+
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
476
837
|
}
|
|
477
838
|
export type SceneData = {
|
|
478
|
-
|
|
839
|
+
/** Expects normalized elements; restore imported data before updating the scene. */
|
|
840
|
+
elements?: readonly ExcalidrawElement[] | null;
|
|
479
841
|
appState?: ImportedDataState["appState"];
|
|
480
842
|
collaborators?: Map<SocketId, Collaborator>;
|
|
481
843
|
captureUpdate?: CaptureUpdateActionType;
|
|
@@ -485,12 +847,21 @@ export type ExportOpts = {
|
|
|
485
847
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
486
848
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
487
849
|
};
|
|
850
|
+
export type ImageOptions = Partial<{
|
|
851
|
+
maxWidthOrHeight: number;
|
|
852
|
+
maxFileSizeBytes: number;
|
|
853
|
+
}>;
|
|
488
854
|
export type CanvasActions = Partial<{
|
|
489
855
|
changeViewBackgroundColor: boolean;
|
|
490
856
|
clearCanvas: boolean;
|
|
491
857
|
export: false | ExportOpts;
|
|
492
858
|
loadScene: boolean;
|
|
493
859
|
saveToActiveFile: boolean;
|
|
860
|
+
/**
|
|
861
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
862
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
863
|
+
* else default to false
|
|
864
|
+
* */
|
|
494
865
|
toggleTheme: boolean | null;
|
|
495
866
|
saveAsImage: boolean;
|
|
496
867
|
}>;
|
|
@@ -500,6 +871,11 @@ export type UIOptions = Partial<{
|
|
|
500
871
|
tools: {
|
|
501
872
|
image: boolean;
|
|
502
873
|
};
|
|
874
|
+
/**
|
|
875
|
+
* Optionally control the editor form factor and desktop UI mode from the host app.
|
|
876
|
+
* If not provided, we will take care of it internally.
|
|
877
|
+
*/
|
|
878
|
+
getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
|
|
503
879
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
504
880
|
welcomeScreen?: boolean;
|
|
505
881
|
}>;
|
|
@@ -509,6 +885,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
509
885
|
export: ExportOpts;
|
|
510
886
|
};
|
|
511
887
|
}>;
|
|
888
|
+
imageOptions: Required<ImageOptions>;
|
|
512
889
|
detectScroll: boolean;
|
|
513
890
|
handleKeyboardGlobally: boolean;
|
|
514
891
|
isCollaborating: boolean;
|
|
@@ -520,6 +897,10 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
520
897
|
export type AppClassProperties = {
|
|
521
898
|
props: AppProps;
|
|
522
899
|
state: AppState;
|
|
900
|
+
readonly ownerDocument: Document;
|
|
901
|
+
readonly ownerWindow: Window & typeof globalThis;
|
|
902
|
+
api: App["api"];
|
|
903
|
+
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
523
904
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
524
905
|
/** static canvas */
|
|
525
906
|
canvas: HTMLCanvasElement;
|
|
@@ -530,7 +911,7 @@ export type AppClassProperties = {
|
|
|
530
911
|
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
531
912
|
}>;
|
|
532
913
|
files: BinaryFiles;
|
|
533
|
-
|
|
914
|
+
editorInterface: App["editorInterface"];
|
|
534
915
|
scene: App["scene"];
|
|
535
916
|
syncActionResult: App["syncActionResult"];
|
|
536
917
|
fonts: App["fonts"];
|
|
@@ -538,8 +919,7 @@ export type AppClassProperties = {
|
|
|
538
919
|
id: App["id"];
|
|
539
920
|
onInsertElements: App["onInsertElements"];
|
|
540
921
|
onExportImage: App["onExportImage"];
|
|
541
|
-
|
|
542
|
-
scrollToContent: App["scrollToContent"];
|
|
922
|
+
viewport: App["viewport"];
|
|
543
923
|
addFiles: App["addFiles"];
|
|
544
924
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
545
925
|
togglePenMode: App["togglePenMode"];
|
|
@@ -550,16 +930,32 @@ export type AppClassProperties = {
|
|
|
550
930
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
551
931
|
getName: App["getName"];
|
|
552
932
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
553
|
-
|
|
933
|
+
flowchart: App["flowchart"];
|
|
934
|
+
drawShape: App["drawShape"];
|
|
935
|
+
arrowText: App["arrowText"];
|
|
936
|
+
cursor: App["cursor"];
|
|
937
|
+
bucketFill: App["bucketFill"];
|
|
938
|
+
toolDrag: App["toolDrag"];
|
|
939
|
+
activeResizeHandle: App["activeResizeHandle"];
|
|
940
|
+
isToolLocked: App["isToolLocked"];
|
|
554
941
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
555
942
|
setPlugins: App["setPlugins"];
|
|
556
943
|
plugins: App["plugins"];
|
|
557
|
-
getEditorUIOffsets: App["getEditorUIOffsets"];
|
|
558
944
|
visibleElements: App["visibleElements"];
|
|
559
945
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
560
946
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
561
947
|
updateEditorAtom: App["updateEditorAtom"];
|
|
562
|
-
|
|
948
|
+
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
949
|
+
onEvent: App["onEvent"];
|
|
950
|
+
onStateChange: App["onStateChange"];
|
|
951
|
+
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
952
|
+
lastPointerMoveEvent: App["lastPointerMoveEvent"];
|
|
953
|
+
bindModeHandler: App["bindModeHandler"];
|
|
954
|
+
emitUserFollowIntent: App["emitUserFollowIntent"];
|
|
955
|
+
requestUnfollow: App["requestUnfollow"];
|
|
956
|
+
setAppState: App["setAppState"];
|
|
957
|
+
isInteractionEnabled: App["isInteractionEnabled"];
|
|
958
|
+
isNavigationEnabled: App["isNavigationEnabled"];
|
|
563
959
|
};
|
|
564
960
|
export type PointerDownState = Readonly<{
|
|
565
961
|
origin: Readonly<{
|
|
@@ -595,6 +991,7 @@ export type PointerDownState = Readonly<{
|
|
|
595
991
|
wasAddedToSelection: boolean;
|
|
596
992
|
hasBeenDuplicated: boolean;
|
|
597
993
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
994
|
+
arrowLabel: boolean;
|
|
598
995
|
};
|
|
599
996
|
withCmdOrCtrl: boolean;
|
|
600
997
|
drag: {
|
|
@@ -620,7 +1017,18 @@ export type PointerDownState = Readonly<{
|
|
|
620
1017
|
};
|
|
621
1018
|
}>;
|
|
622
1019
|
export type UnsubscribeCallback = () => void;
|
|
1020
|
+
export type ExcalidrawMountPayload = {
|
|
1021
|
+
excalidrawAPI: ExcalidrawImperativeAPI;
|
|
1022
|
+
container: HTMLDivElement | null;
|
|
1023
|
+
};
|
|
1024
|
+
export type ExcalidrawImperativeAPIEventMap = {
|
|
1025
|
+
"editor:mount": [payload: ExcalidrawMountPayload];
|
|
1026
|
+
"editor:initialize": [api: ExcalidrawImperativeAPI];
|
|
1027
|
+
"editor:unmount": [];
|
|
1028
|
+
};
|
|
623
1029
|
export interface ExcalidrawImperativeAPI {
|
|
1030
|
+
/** Whether the editor has been unmounted and the API is no longer usable. */
|
|
1031
|
+
isDestroyed: boolean;
|
|
624
1032
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
625
1033
|
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
626
1034
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
@@ -635,16 +1043,18 @@ export interface ExcalidrawImperativeAPI {
|
|
|
635
1043
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
636
1044
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
637
1045
|
getName: InstanceType<typeof App>["getName"];
|
|
638
|
-
|
|
1046
|
+
setViewport: InstanceType<typeof App>["viewport"]["setViewport"];
|
|
1047
|
+
getViewportOffsets: InstanceType<typeof App>["viewport"]["getOffsets"];
|
|
639
1048
|
registerAction: (action: Action) => void;
|
|
640
1049
|
refresh: InstanceType<typeof App>["refresh"];
|
|
641
1050
|
setToast: InstanceType<typeof App>["setToast"];
|
|
642
1051
|
addFiles: (data: BinaryFileData[]) => void;
|
|
643
1052
|
id: string;
|
|
644
1053
|
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
|
645
|
-
setCursor: InstanceType<typeof App>["
|
|
646
|
-
resetCursor: InstanceType<typeof App>["
|
|
1054
|
+
setCursor: InstanceType<typeof App>["cursor"]["set"];
|
|
1055
|
+
resetCursor: InstanceType<typeof App>["cursor"]["reset"];
|
|
647
1056
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
1057
|
+
getEditorInterface: () => EditorInterface;
|
|
648
1058
|
/**
|
|
649
1059
|
* Disables rendering of frames (including element clipping), but currently
|
|
650
1060
|
* the frames are still interactive in edit mode. As such, this API should be
|
|
@@ -657,24 +1067,14 @@ export interface ExcalidrawImperativeAPI {
|
|
|
657
1067
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
658
1068
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
659
1069
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
1070
|
+
onStateChange: InstanceType<typeof App>["onStateChange"];
|
|
1071
|
+
onEvent: InstanceType<typeof App>["onEvent"];
|
|
660
1072
|
}
|
|
661
|
-
export type Device = Readonly<{
|
|
662
|
-
viewport: {
|
|
663
|
-
isMobile: boolean;
|
|
664
|
-
isLandscape: boolean;
|
|
665
|
-
};
|
|
666
|
-
editor: {
|
|
667
|
-
isMobile: boolean;
|
|
668
|
-
canFitSidebar: boolean;
|
|
669
|
-
};
|
|
670
|
-
isTouchScreen: boolean;
|
|
671
|
-
}>;
|
|
672
1073
|
export type FrameNameBounds = {
|
|
673
1074
|
x: number;
|
|
674
1075
|
y: number;
|
|
675
1076
|
width: number;
|
|
676
1077
|
height: number;
|
|
677
|
-
angle: number;
|
|
678
1078
|
};
|
|
679
1079
|
export type FrameNameBoundsCache = {
|
|
680
1080
|
get: (frameElement: ExcalidrawFrameLikeElement | ExcalidrawMagicFrameElement) => FrameNameBounds | null;
|
|
@@ -693,12 +1093,18 @@ export type Primitive = number | string | boolean | bigint | symbol | null | und
|
|
|
693
1093
|
export type JSONValue = string | number | boolean | null | object;
|
|
694
1094
|
export type EmbedsValidationStatus = Map<ExcalidrawIframeLikeElement["id"], boolean>;
|
|
695
1095
|
export type ElementsPendingErasure = Set<ExcalidrawElement["id"]>;
|
|
696
|
-
export type PendingExcalidrawElements =
|
|
1096
|
+
export type PendingExcalidrawElements = NonDeletedExcalidrawElement[];
|
|
697
1097
|
/** Runtime gridSize value. Null indicates disabled grid. */
|
|
698
1098
|
export type NullableGridSize = (AppState["gridSize"] & MakeBrand<"NullableGridSize">) | null;
|
|
699
1099
|
export type GenerateDiagramToCode = (props: {
|
|
700
|
-
frame: ExcalidrawMagicFrameElement
|
|
701
|
-
children: readonly
|
|
1100
|
+
frame: NonDeleted<ExcalidrawMagicFrameElement>;
|
|
1101
|
+
children: readonly NonDeletedExcalidrawElement[];
|
|
1102
|
+
/**
|
|
1103
|
+
* Optional streaming hook. Call with the accumulated response text as it
|
|
1104
|
+
* streams in so the editor can progressively render the partial HTML
|
|
1105
|
+
* inside the generated frame.
|
|
1106
|
+
*/
|
|
1107
|
+
onPartial?: (html: string) => void;
|
|
702
1108
|
}) => MaybePromise<{
|
|
703
1109
|
html: string;
|
|
704
1110
|
}>;
|
|
@@ -708,4 +1114,102 @@ export type Offsets = Partial<{
|
|
|
708
1114
|
bottom: number;
|
|
709
1115
|
left: number;
|
|
710
1116
|
}>;
|
|
711
|
-
|
|
1117
|
+
/**
|
|
1118
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
1119
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
1120
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
1121
|
+
*
|
|
1122
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
1123
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
1124
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
1125
|
+
* lies in the left half of the viewport it counts against the left
|
|
1126
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
1127
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
1128
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
1129
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
1130
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
1131
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
1132
|
+
* would swallow most of the viewport).
|
|
1133
|
+
*
|
|
1134
|
+
* The attribute should only be present while the surface is actually
|
|
1135
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
1136
|
+
* push the viewport around.
|
|
1137
|
+
*/
|
|
1138
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
1139
|
+
/**
|
|
1140
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
1141
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
1142
|
+
* currently rendered editor UI.
|
|
1143
|
+
*
|
|
1144
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
1145
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
1146
|
+
* reading-direction start side).
|
|
1147
|
+
*/
|
|
1148
|
+
export type ViewportOffsetsOptions = {
|
|
1149
|
+
/** padding added to each measured side (default 24) */
|
|
1150
|
+
padding?: number;
|
|
1151
|
+
paddingTop?: number;
|
|
1152
|
+
paddingRight?: number;
|
|
1153
|
+
paddingBottom?: number;
|
|
1154
|
+
paddingLeft?: number;
|
|
1155
|
+
/** final value for the given side, replacing the measured UI size
|
|
1156
|
+
* (padding is not added on top) */
|
|
1157
|
+
top?: number;
|
|
1158
|
+
bottom?: number;
|
|
1159
|
+
left?: number;
|
|
1160
|
+
right?: number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
1163
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
1164
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
1165
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
1166
|
+
* phones (where these surfaces never occlude the canvas).
|
|
1167
|
+
*/
|
|
1168
|
+
reserve?: {
|
|
1169
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
1170
|
+
stylesPanel?: boolean;
|
|
1171
|
+
/** sidebar (e.g. library) */
|
|
1172
|
+
sidebar?: boolean;
|
|
1173
|
+
};
|
|
1174
|
+
};
|
|
1175
|
+
/**
|
|
1176
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
1177
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
1178
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
1179
|
+
*
|
|
1180
|
+
* Two (combinable) ways to specify:
|
|
1181
|
+
*
|
|
1182
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
1183
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
1184
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
1185
|
+
* set, see below).
|
|
1186
|
+
*
|
|
1187
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
1188
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
1189
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
1190
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
1191
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
1192
|
+
*
|
|
1193
|
+
* When both are given, a static side always wins for that side — it
|
|
1194
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
1195
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
1196
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* { top: 40 } // top 40px, other sides 0
|
|
1200
|
+
* { ui: true } // measured UI + default padding
|
|
1201
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
1202
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
1203
|
+
*/
|
|
1204
|
+
export type ViewportOffsets = Offsets & {
|
|
1205
|
+
ui?: true | ViewportOffsetsOptions;
|
|
1206
|
+
};
|
|
1207
|
+
/**
|
|
1208
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
1209
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
1210
|
+
* `getViewportOffsets` can reserve space for it while it's hidden (see the
|
|
1211
|
+
* `reserve` option). Whenever a named surface is rendered, its measured
|
|
1212
|
+
* footprint is remembered; reserving uses that remembered footprint, or an
|
|
1213
|
+
* approximate default if the surface hasn't been rendered yet.
|
|
1214
|
+
*/
|
|
1215
|
+
export type ViewportUIName = "sidebar" | "stylesPanel";
|