@excalidraw/math 0.18.0-508de2f3a → 0.18.0-51ca8ab
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 +96 -65
- package/dist/dev/index.js.map +3 -3
- 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 +59 -39
- package/dist/types/common/src/constants.d.ts +46 -33
- 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 +1 -1
- package/dist/types/common/src/utility-types.d.ts +0 -1
- package/dist/types/common/src/utils.d.ts +46 -76
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +10 -6
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +27 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +67 -48
- package/dist/types/element/src/bounds.d.ts +25 -18
- package/dist/types/element/src/collision.d.ts +7 -2
- package/dist/types/element/src/comparisons.d.ts +8 -7
- package/dist/types/element/src/delta.d.ts +4 -5
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/dragElements.d.ts +3 -3
- package/dist/types/element/src/duplicate.d.ts +4 -3
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +12 -7
- 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 +5 -3
- package/dist/types/element/src/linearElementEditor.d.ts +23 -22
- package/dist/types/element/src/mutateElement.d.ts +5 -2
- package/dist/types/element/src/newElement.d.ts +7 -6
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -7
- package/dist/types/element/src/resizeElements.d.ts +10 -10
- package/dist/types/element/src/resizeTest.d.ts +6 -5
- package/dist/types/element/src/selection.d.ts +10 -10
- package/dist/types/element/src/shape.d.ts +9 -8
- package/dist/types/element/src/store.d.ts +5 -0
- package/dist/types/element/src/textElement.d.ts +2 -2
- 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 +3 -3
- package/dist/types/element/src/transformHandles.d.ts +8 -27
- package/dist/types/element/src/typeChecks.d.ts +5 -7
- package/dist/types/element/src/types.d.ts +18 -13
- package/dist/types/element/src/utils.d.ts +9 -4
- package/dist/types/element/src/zindex.d.ts +7 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +176 -210
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -7
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +100 -123
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +520 -1193
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +129 -893
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +48 -60
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +157 -195
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +161 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +56 -74
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +98 -121
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionExport.d.ts +179 -1407
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionFrame.d.ts +278 -360
- package/dist/types/excalidraw/actions/actionGroup.d.ts +103 -134
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +142 -191
- package/dist/types/excalidraw/actions/actionLink.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionMenu.d.ts +51 -435
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -359
- package/dist/types/excalidraw/actions/actionProperties.d.ts +166 -2510
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +51 -67
- package/dist/types/excalidraw/actions/actionStyles.d.ts +48 -59
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +174 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +174 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +50 -68
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +61 -73
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +62 -74
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
- package/dist/types/excalidraw/actions/index.d.ts +5 -2
- 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 +4 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +31 -22
- 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 +57 -19
- package/dist/types/excalidraw/components/Actions.d.ts +22 -5
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +168 -103
- 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 +0 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
- 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 +3 -3
- 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/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -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/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/LayerUI.d.ts +2 -1
- 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/MobileMenu.d.ts +3 -5
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +10 -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/Popover.d.ts +2 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
- 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/CanvasGrid.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +0 -1
- 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 +25 -0
- package/dist/types/excalidraw/components/Trans.d.ts +2 -2
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +8 -4
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/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/hoc/withInternalFallback.d.ts +1 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +1 -1
- package/dist/types/excalidraw/components/icons.d.ts +51 -21
- 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/shapes.d.ts +209 -1
- package/dist/types/excalidraw/data/blob.d.ts +331 -12
- 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 +4 -5
- package/dist/types/excalidraw/data/json.d.ts +172 -4
- 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/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/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 +14 -0
- 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/renderer/animation.d.ts +16 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -8
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +8 -14
- package/dist/types/excalidraw/scene/Renderer.d.ts +428 -18
- package/dist/types/excalidraw/scene/export.d.ts +2 -2
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +22 -5
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/snapping.d.ts +5 -5
- 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 +290 -40
- package/dist/types/excalidraw/viewport.d.ts +316 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +7 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +35 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +4 -1
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/polygon.d.ts +2 -2
- package/dist/types/math/src/range.d.ts +1 -3
- package/dist/types/math/src/segment.d.ts +4 -3
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/export.d.ts +5 -5
- package/dist/types/utils/src/index.d.ts +1 -2
- package/dist/types/utils/src/shape.d.ts +6 -6
- package/package.json +2 -2
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
- 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/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
- 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/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/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 { ApplyToOptions, 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, Arrowhead,
|
|
4
|
+
import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, 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
|
};
|
|
@@ -125,16 +126,20 @@ 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
|
+
suggestedBinding: AppState["suggestedBinding"];
|
|
138
143
|
isRotating: AppState["isRotating"];
|
|
139
144
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
140
145
|
collaborators: AppState["collaborators"];
|
|
@@ -145,6 +150,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
145
150
|
croppingElementId: AppState["croppingElementId"];
|
|
146
151
|
searchMatches: AppState["searchMatches"];
|
|
147
152
|
activeLockedId: AppState["activeLockedId"];
|
|
153
|
+
hoveredElementIds: AppState["hoveredElementIds"];
|
|
154
|
+
frameRendering: AppState["frameRendering"];
|
|
155
|
+
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
156
|
+
exportScale: AppState["exportScale"];
|
|
157
|
+
currentItemArrowType: AppState["currentItemArrowType"];
|
|
148
158
|
}>;
|
|
149
159
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
150
160
|
export type ObservedStandaloneAppState = {
|
|
@@ -163,6 +173,42 @@ export type ObservedElementsAppState = {
|
|
|
163
173
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
164
174
|
activeLockedId: AppState["activeLockedId"];
|
|
165
175
|
};
|
|
176
|
+
export type BoxSelectionMode = "contain" | "overlap";
|
|
177
|
+
/**
|
|
178
|
+
* A box, in scene coordinates, that pan & zoom are constrained to.
|
|
179
|
+
*
|
|
180
|
+
* This is a private type. For public API, only use specific properties,
|
|
181
|
+
* needed.
|
|
182
|
+
*/
|
|
183
|
+
export type ScrollConstraints = {
|
|
184
|
+
x: number;
|
|
185
|
+
y: number;
|
|
186
|
+
width: number;
|
|
187
|
+
height: number;
|
|
188
|
+
/** when set, panning is constrained so the viewport stays within the box */
|
|
189
|
+
lockScroll: boolean;
|
|
190
|
+
/** when set, the viewport cannot zoom out below `zoom` */
|
|
191
|
+
lockZoom: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* The zoom resolved after the `setViewport` navigation settled.
|
|
194
|
+
*/
|
|
195
|
+
zoom: number;
|
|
196
|
+
/**
|
|
197
|
+
* Pixel amount the viewport may overscroll past its resting clamp before
|
|
198
|
+
* snapping back (rubberband). Screen pixels, zoom-independent. Resolved
|
|
199
|
+
* from `lock.overscroll` at the time the lock was installed (`true` →
|
|
200
|
+
* default give, `false` → 0).
|
|
201
|
+
*/
|
|
202
|
+
overscroll: number;
|
|
203
|
+
/**
|
|
204
|
+
* Extra scrollable margin around the box (CSS-style), letting the viewport
|
|
205
|
+
* scroll past each box edge to reveal that much empty space. Values are
|
|
206
|
+
* viewport pixels and zoom-independent (a fixed on-screen distance).
|
|
207
|
+
* Resolved from the `offsets` passed to `setViewport` (see
|
|
208
|
+
* {@link ViewportOffsets}) at the time the lock was installed.
|
|
209
|
+
*/
|
|
210
|
+
offsets?: Offsets;
|
|
211
|
+
};
|
|
166
212
|
export interface AppState {
|
|
167
213
|
contextMenu: {
|
|
168
214
|
items: ContextMenuItems;
|
|
@@ -196,9 +242,25 @@ export interface AppState {
|
|
|
196
242
|
* - set on pointer down, updated during pointer move
|
|
197
243
|
*/
|
|
198
244
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
245
|
+
/**
|
|
246
|
+
* tracking current arrow binding editor state (takes into account
|
|
247
|
+
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
248
|
+
*/
|
|
199
249
|
isBindingEnabled: boolean;
|
|
200
|
-
|
|
201
|
-
|
|
250
|
+
/** user box selection preference; defaults to "contain" when unset */
|
|
251
|
+
boxSelectionMode: BoxSelectionMode;
|
|
252
|
+
/** user arrow binding preference */
|
|
253
|
+
bindingPreference: "enabled" | "disabled";
|
|
254
|
+
/** user preference whether arrow snap to midpoints while binding */
|
|
255
|
+
isMidpointSnappingEnabled: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* The bindable element the UI highlights for the user when an arrow is
|
|
258
|
+
* dragged or otherwise its endpoint being close to said element.
|
|
259
|
+
*/
|
|
260
|
+
suggestedBinding: {
|
|
261
|
+
element: NonDeleted<ExcalidrawBindableElement>;
|
|
262
|
+
midPoint?: GlobalPoint;
|
|
263
|
+
} | null;
|
|
202
264
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
203
265
|
frameRendering: {
|
|
204
266
|
enabled: boolean;
|
|
@@ -211,7 +273,7 @@ export interface AppState {
|
|
|
211
273
|
/**
|
|
212
274
|
* set when a new text is created or when an existing text is being edited
|
|
213
275
|
*/
|
|
214
|
-
editingTextElement:
|
|
276
|
+
editingTextElement: ExcalidrawTextElement | null;
|
|
215
277
|
activeTool: {
|
|
216
278
|
/**
|
|
217
279
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -221,6 +283,10 @@ export interface AppState {
|
|
|
221
283
|
locked: boolean;
|
|
222
284
|
fromSelection: boolean;
|
|
223
285
|
} & ActiveTool;
|
|
286
|
+
preferredSelectionTool: {
|
|
287
|
+
type: "selection" | "lasso";
|
|
288
|
+
initialized: boolean;
|
|
289
|
+
};
|
|
224
290
|
penMode: boolean;
|
|
225
291
|
penDetected: boolean;
|
|
226
292
|
exportBackground: boolean;
|
|
@@ -230,9 +296,10 @@ export interface AppState {
|
|
|
230
296
|
currentItemStrokeColor: string;
|
|
231
297
|
currentItemBackgroundColor: string;
|
|
232
298
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
233
|
-
|
|
299
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
234
300
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
235
301
|
currentItemRoughness: number;
|
|
302
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
236
303
|
currentItemOpacity: number;
|
|
237
304
|
currentItemFontFamily: FontFamilyValues;
|
|
238
305
|
currentItemFontSize: number;
|
|
@@ -245,14 +312,15 @@ export interface AppState {
|
|
|
245
312
|
viewBackgroundColor: string;
|
|
246
313
|
scrollX: number;
|
|
247
314
|
scrollY: number;
|
|
315
|
+
scrollConstraints: ScrollConstraints | null;
|
|
248
316
|
cursorButton: "up" | "down";
|
|
249
317
|
scrolledOutside: boolean;
|
|
250
318
|
name: string | null;
|
|
251
319
|
isResizing: boolean;
|
|
252
320
|
isRotating: boolean;
|
|
253
321
|
zoom: Zoom;
|
|
254
|
-
openMenu: "canvas" |
|
|
255
|
-
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | null;
|
|
322
|
+
openMenu: "canvas" | null;
|
|
323
|
+
openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
|
|
256
324
|
openSidebar: {
|
|
257
325
|
name: SidebarName;
|
|
258
326
|
tab?: SidebarTabName;
|
|
@@ -264,9 +332,15 @@ export interface AppState {
|
|
|
264
332
|
tab: "text-to-diagram" | "mermaid";
|
|
265
333
|
} | {
|
|
266
334
|
name: "commandPalette";
|
|
335
|
+
} | {
|
|
336
|
+
name: "settings";
|
|
267
337
|
} | {
|
|
268
338
|
name: "elementLinkSelector";
|
|
269
339
|
sourceElementId: ExcalidrawElement["id"];
|
|
340
|
+
} | {
|
|
341
|
+
name: "charts";
|
|
342
|
+
data: Spreadsheet;
|
|
343
|
+
rawText: string;
|
|
270
344
|
};
|
|
271
345
|
/**
|
|
272
346
|
* Reflects user preference for whether the default sidebar should be docked.
|
|
@@ -289,7 +363,7 @@ export interface AppState {
|
|
|
289
363
|
selectedElementsAreBeingDragged: boolean;
|
|
290
364
|
shouldCacheIgnoreZoom: boolean;
|
|
291
365
|
toast: {
|
|
292
|
-
message:
|
|
366
|
+
message: React.ReactNode;
|
|
293
367
|
closable?: boolean;
|
|
294
368
|
duration?: number;
|
|
295
369
|
} | null;
|
|
@@ -311,21 +385,13 @@ export interface AppState {
|
|
|
311
385
|
height: number;
|
|
312
386
|
offsetTop: number;
|
|
313
387
|
offsetLeft: number;
|
|
314
|
-
fileHandle:
|
|
388
|
+
fileHandle: FileSystemFileHandle | null;
|
|
315
389
|
collaborators: Map<SocketId, Collaborator>;
|
|
316
390
|
stats: {
|
|
317
391
|
open: boolean;
|
|
318
392
|
/** bitmap. Use `STATS_PANELS` bit values */
|
|
319
393
|
panels: number;
|
|
320
394
|
};
|
|
321
|
-
currentChartType: ChartType;
|
|
322
|
-
pasteDialog: {
|
|
323
|
-
shown: false;
|
|
324
|
-
data: null;
|
|
325
|
-
} | {
|
|
326
|
-
shown: true;
|
|
327
|
-
data: Spreadsheet;
|
|
328
|
-
};
|
|
329
395
|
showHyperlinkPopup: false | "info" | "editor";
|
|
330
396
|
selectedLinearElement: LinearElementEditor | null;
|
|
331
397
|
snapLines: readonly SnapLine[];
|
|
@@ -351,6 +417,7 @@ export interface AppState {
|
|
|
351
417
|
lockedMultiSelections: {
|
|
352
418
|
[groupId: string]: true;
|
|
353
419
|
};
|
|
420
|
+
bindMode: BindMode;
|
|
354
421
|
}
|
|
355
422
|
export type SearchMatch = {
|
|
356
423
|
id: string;
|
|
@@ -363,7 +430,7 @@ export type SearchMatch = {
|
|
|
363
430
|
showOnCanvas: boolean;
|
|
364
431
|
}[];
|
|
365
432
|
};
|
|
366
|
-
export type UIAppState = Omit<AppState, "
|
|
433
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY">;
|
|
367
434
|
export type NormalizedZoomValue = number & {
|
|
368
435
|
_brand: "normalizedZoom";
|
|
369
436
|
};
|
|
@@ -407,15 +474,45 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
407
474
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
408
475
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
409
476
|
}>;
|
|
477
|
+
export type ExcalidrawInitialState = {
|
|
478
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
479
|
+
};
|
|
410
480
|
export type OnUserFollowedPayload = {
|
|
411
481
|
userToFollow: UserToFollow;
|
|
412
482
|
action: "FOLLOW" | "UNFOLLOW";
|
|
413
483
|
};
|
|
484
|
+
export type OnExportProgress = {
|
|
485
|
+
type: "progress";
|
|
486
|
+
message?: React.ReactNode;
|
|
487
|
+
/** 0-1 range */
|
|
488
|
+
progress?: number;
|
|
489
|
+
};
|
|
414
490
|
export interface ExcalidrawProps {
|
|
415
491
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
492
|
+
onThemeChange?: (theme: Theme | "system") => void;
|
|
493
|
+
/**
|
|
494
|
+
* note: only subscribes if the props.onIncrement is defined on initial render
|
|
495
|
+
*/
|
|
416
496
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
417
497
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
418
|
-
|
|
498
|
+
initialState?: ExcalidrawInitialState;
|
|
499
|
+
/**
|
|
500
|
+
* Invoked as soon as the Excalidraw API is available
|
|
501
|
+
* NOTE editor is not yet mounted, and state is not yet initialized
|
|
502
|
+
*/
|
|
503
|
+
onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
|
|
504
|
+
/**
|
|
505
|
+
* Invoked once the editor root is mounted.
|
|
506
|
+
*/
|
|
507
|
+
onMount?: (payload: ExcalidrawMountPayload) => void;
|
|
508
|
+
/**
|
|
509
|
+
* Invoked when the editor root is unmounted.
|
|
510
|
+
*/
|
|
511
|
+
onUnmount?: () => void;
|
|
512
|
+
/**
|
|
513
|
+
* Invoked once the initial scene is loaded.
|
|
514
|
+
*/
|
|
515
|
+
onInitialize?: (api: ExcalidrawImperativeAPI) => void;
|
|
419
516
|
isCollaborating?: boolean;
|
|
420
517
|
onPointerUpdate?: (payload: {
|
|
421
518
|
pointer: {
|
|
@@ -441,6 +538,7 @@ export interface ExcalidrawProps {
|
|
|
441
538
|
onDuplicate?: (nextElements: readonly ExcalidrawElement[],
|
|
442
539
|
/** excludes the duplicated elements */
|
|
443
540
|
prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
|
|
541
|
+
renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
444
542
|
renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
|
|
445
543
|
langCode?: Language["code"];
|
|
446
544
|
viewModeEnabled?: boolean;
|
|
@@ -452,6 +550,10 @@ export interface ExcalidrawProps {
|
|
|
452
550
|
name?: string;
|
|
453
551
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
454
552
|
UIOptions?: Partial<UIOptions>;
|
|
553
|
+
/**
|
|
554
|
+
* dimensions and size constraints for inserted images
|
|
555
|
+
*/
|
|
556
|
+
imageOptions?: ImageOptions;
|
|
455
557
|
detectScroll?: boolean;
|
|
456
558
|
handleKeyboardGlobally?: boolean;
|
|
457
559
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -471,6 +573,29 @@ export interface ExcalidrawProps {
|
|
|
471
573
|
aiEnabled?: boolean;
|
|
472
574
|
showDeprecatedFonts?: boolean;
|
|
473
575
|
renderScrollbars?: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Called before exporting to a file.
|
|
578
|
+
*
|
|
579
|
+
* Allows the host app to intercept and delay saving until async operations
|
|
580
|
+
* (e.g., images are loaded) complete.
|
|
581
|
+
*
|
|
582
|
+
* If Promise/AsyncGenerator is returned, a progress toast will be shown
|
|
583
|
+
* until the operation completes. Generator can yield progress updates.
|
|
584
|
+
*/
|
|
585
|
+
onExport?: (
|
|
586
|
+
/** type of export. Currently we only call for JSON exports or
|
|
587
|
+
* JSON-embedded PNG (which is also identified as `json` type here)*/
|
|
588
|
+
type: "json", data: {
|
|
589
|
+
elements: readonly ExcalidrawElement[];
|
|
590
|
+
appState: AppState;
|
|
591
|
+
files: BinaryFiles;
|
|
592
|
+
}, options: {
|
|
593
|
+
/** signal that gets aborted if user cancels the export (e.g. closes
|
|
594
|
+
* the native file picker dialog). In that case, you can either
|
|
595
|
+
* return immediately, or throw AbortError.
|
|
596
|
+
*/
|
|
597
|
+
signal: AbortSignal;
|
|
598
|
+
}) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
|
|
474
599
|
}
|
|
475
600
|
export type SceneData = {
|
|
476
601
|
elements?: ImportedDataState["elements"];
|
|
@@ -478,18 +603,26 @@ export type SceneData = {
|
|
|
478
603
|
collaborators?: Map<SocketId, Collaborator>;
|
|
479
604
|
captureUpdate?: CaptureUpdateActionType;
|
|
480
605
|
};
|
|
481
|
-
export type ApplyDeltasOptions = Omit<ApplyToOptions, "skipRedraw">;
|
|
482
606
|
export type ExportOpts = {
|
|
483
607
|
saveFileToDisk?: boolean;
|
|
484
608
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
485
609
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
486
610
|
};
|
|
611
|
+
export type ImageOptions = Partial<{
|
|
612
|
+
maxWidthOrHeight: number;
|
|
613
|
+
maxFileSizeBytes: number;
|
|
614
|
+
}>;
|
|
487
615
|
export type CanvasActions = Partial<{
|
|
488
616
|
changeViewBackgroundColor: boolean;
|
|
489
617
|
clearCanvas: boolean;
|
|
490
618
|
export: false | ExportOpts;
|
|
491
619
|
loadScene: boolean;
|
|
492
620
|
saveToActiveFile: boolean;
|
|
621
|
+
/**
|
|
622
|
+
* defaults to true if `props.theme` is omitted or `props.onThemeChange`
|
|
623
|
+
* is supplied (at which point the theme is considered as host-app controlled),
|
|
624
|
+
* else default to false
|
|
625
|
+
* */
|
|
493
626
|
toggleTheme: boolean | null;
|
|
494
627
|
saveAsImage: boolean;
|
|
495
628
|
}>;
|
|
@@ -499,6 +632,11 @@ export type UIOptions = Partial<{
|
|
|
499
632
|
tools: {
|
|
500
633
|
image: boolean;
|
|
501
634
|
};
|
|
635
|
+
/**
|
|
636
|
+
* Optionally control the editor form factor and desktop UI mode from the host app.
|
|
637
|
+
* If not provided, we will take care of it internally.
|
|
638
|
+
*/
|
|
639
|
+
getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
|
|
502
640
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
503
641
|
welcomeScreen?: boolean;
|
|
504
642
|
}>;
|
|
@@ -508,6 +646,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
508
646
|
export: ExportOpts;
|
|
509
647
|
};
|
|
510
648
|
}>;
|
|
649
|
+
imageOptions: Required<ImageOptions>;
|
|
511
650
|
detectScroll: boolean;
|
|
512
651
|
handleKeyboardGlobally: boolean;
|
|
513
652
|
isCollaborating: boolean;
|
|
@@ -519,6 +658,8 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
519
658
|
export type AppClassProperties = {
|
|
520
659
|
props: AppProps;
|
|
521
660
|
state: AppState;
|
|
661
|
+
api: App["api"];
|
|
662
|
+
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
522
663
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
523
664
|
/** static canvas */
|
|
524
665
|
canvas: HTMLCanvasElement;
|
|
@@ -529,7 +670,7 @@ export type AppClassProperties = {
|
|
|
529
670
|
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
|
530
671
|
}>;
|
|
531
672
|
files: BinaryFiles;
|
|
532
|
-
|
|
673
|
+
editorInterface: App["editorInterface"];
|
|
533
674
|
scene: App["scene"];
|
|
534
675
|
syncActionResult: App["syncActionResult"];
|
|
535
676
|
fonts: App["fonts"];
|
|
@@ -538,7 +679,7 @@ export type AppClassProperties = {
|
|
|
538
679
|
onInsertElements: App["onInsertElements"];
|
|
539
680
|
onExportImage: App["onExportImage"];
|
|
540
681
|
lastViewportPosition: App["lastViewportPosition"];
|
|
541
|
-
|
|
682
|
+
setViewport: App["setViewport"];
|
|
542
683
|
addFiles: App["addFiles"];
|
|
543
684
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
544
685
|
togglePenMode: App["togglePenMode"];
|
|
@@ -553,11 +694,17 @@ export type AppClassProperties = {
|
|
|
553
694
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
554
695
|
setPlugins: App["setPlugins"];
|
|
555
696
|
plugins: App["plugins"];
|
|
556
|
-
|
|
697
|
+
getViewportOffsets: App["getViewportOffsets"];
|
|
557
698
|
visibleElements: App["visibleElements"];
|
|
558
699
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
559
700
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
560
701
|
updateEditorAtom: App["updateEditorAtom"];
|
|
702
|
+
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
703
|
+
onEvent: App["onEvent"];
|
|
704
|
+
onStateChange: App["onStateChange"];
|
|
705
|
+
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
706
|
+
bindModeHandler: App["bindModeHandler"];
|
|
707
|
+
setAppState: App["setAppState"];
|
|
561
708
|
};
|
|
562
709
|
export type PointerDownState = Readonly<{
|
|
563
710
|
origin: Readonly<{
|
|
@@ -605,6 +752,7 @@ export type PointerDownState = Readonly<{
|
|
|
605
752
|
x: number;
|
|
606
753
|
y: number;
|
|
607
754
|
};
|
|
755
|
+
blockDragging: boolean;
|
|
608
756
|
};
|
|
609
757
|
eventListeners: {
|
|
610
758
|
onMove: null | ReturnType<typeof throttleRAF>;
|
|
@@ -617,7 +765,18 @@ export type PointerDownState = Readonly<{
|
|
|
617
765
|
};
|
|
618
766
|
}>;
|
|
619
767
|
export type UnsubscribeCallback = () => void;
|
|
768
|
+
export type ExcalidrawMountPayload = {
|
|
769
|
+
excalidrawAPI: ExcalidrawImperativeAPI;
|
|
770
|
+
container: HTMLDivElement | null;
|
|
771
|
+
};
|
|
772
|
+
export type ExcalidrawImperativeAPIEventMap = {
|
|
773
|
+
"editor:mount": [payload: ExcalidrawMountPayload];
|
|
774
|
+
"editor:initialize": [api: ExcalidrawImperativeAPI];
|
|
775
|
+
"editor:unmount": [];
|
|
776
|
+
};
|
|
620
777
|
export interface ExcalidrawImperativeAPI {
|
|
778
|
+
/** Whether the editor has been unmounted and the API is no longer usable. */
|
|
779
|
+
isDestroyed: boolean;
|
|
621
780
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
622
781
|
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
623
782
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
@@ -632,7 +791,8 @@ export interface ExcalidrawImperativeAPI {
|
|
|
632
791
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
633
792
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
634
793
|
getName: InstanceType<typeof App>["getName"];
|
|
635
|
-
|
|
794
|
+
setViewport: InstanceType<typeof App>["setViewport"];
|
|
795
|
+
getViewportOffsets: InstanceType<typeof App>["getViewportOffsets"];
|
|
636
796
|
registerAction: (action: Action) => void;
|
|
637
797
|
refresh: InstanceType<typeof App>["refresh"];
|
|
638
798
|
setToast: InstanceType<typeof App>["setToast"];
|
|
@@ -642,6 +802,7 @@ export interface ExcalidrawImperativeAPI {
|
|
|
642
802
|
setCursor: InstanceType<typeof App>["setCursor"];
|
|
643
803
|
resetCursor: InstanceType<typeof App>["resetCursor"];
|
|
644
804
|
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
|
805
|
+
getEditorInterface: () => EditorInterface;
|
|
645
806
|
/**
|
|
646
807
|
* Disables rendering of frames (including element clipping), but currently
|
|
647
808
|
* the frames are still interactive in edit mode. As such, this API should be
|
|
@@ -654,18 +815,9 @@ export interface ExcalidrawImperativeAPI {
|
|
|
654
815
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
655
816
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
656
817
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
818
|
+
onStateChange: InstanceType<typeof App>["onStateChange"];
|
|
819
|
+
onEvent: InstanceType<typeof App>["onEvent"];
|
|
657
820
|
}
|
|
658
|
-
export type Device = Readonly<{
|
|
659
|
-
viewport: {
|
|
660
|
-
isMobile: boolean;
|
|
661
|
-
isLandscape: boolean;
|
|
662
|
-
};
|
|
663
|
-
editor: {
|
|
664
|
-
isMobile: boolean;
|
|
665
|
-
canFitSidebar: boolean;
|
|
666
|
-
};
|
|
667
|
-
isTouchScreen: boolean;
|
|
668
|
-
}>;
|
|
669
821
|
export type FrameNameBounds = {
|
|
670
822
|
x: number;
|
|
671
823
|
y: number;
|
|
@@ -705,4 +857,102 @@ export type Offsets = Partial<{
|
|
|
705
857
|
bottom: number;
|
|
706
858
|
left: number;
|
|
707
859
|
}>;
|
|
708
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Value of the `data-viewport-ui` attribute, marking a DOM node as a UI
|
|
862
|
+
* surface that occludes the canvas. Such nodes are measured by
|
|
863
|
+
* `getViewportOffsets` to compute the default per-side viewport offsets:
|
|
864
|
+
*
|
|
865
|
+
* - `top` / `bottom` — offsets that side by the node's bottom/top edge
|
|
866
|
+
* - `side` — a panel hugging the left or right edge. Which side is not
|
|
867
|
+
* declared but resolved geometrically: if the node's horizontal center
|
|
868
|
+
* lies in the left half of the viewport it counts against the left
|
|
869
|
+
* offset (by its right edge), otherwise against the right offset (by
|
|
870
|
+
* `viewportWidth - left edge`). Measuring the rendered position instead
|
|
871
|
+
* of declaring a side means RTL layouts and host-configurable docking
|
|
872
|
+
* (e.g. sidebar side) are handled for free — but it assumes the surface
|
|
873
|
+
* actually hugs one edge; don't mark a centered/near-full-width node as
|
|
874
|
+
* `side` (its midpoint would classify it to one side and the offset
|
|
875
|
+
* would swallow most of the viewport).
|
|
876
|
+
*
|
|
877
|
+
* The attribute should only be present while the surface is actually
|
|
878
|
+
* rendered — omit it (don't just hide the node) when the surface shouldn't
|
|
879
|
+
* push the viewport around.
|
|
880
|
+
*/
|
|
881
|
+
export type ViewportUIDock = "top" | "bottom" | "side";
|
|
882
|
+
/**
|
|
883
|
+
* Options for `getViewportOffsets` (and the `ui` key of
|
|
884
|
+
* {@link ViewportOffsets}), controlling how offsets are derived from the
|
|
885
|
+
* currently rendered editor UI.
|
|
886
|
+
*
|
|
887
|
+
* NOTE unlike the physical sides of {@link Offsets}, the horizontal values
|
|
888
|
+
* here are logical, i.e. flipped in RTL layouts (`left` refers to the
|
|
889
|
+
* reading-direction start side).
|
|
890
|
+
*/
|
|
891
|
+
export type ViewportOffsetsOptions = {
|
|
892
|
+
/** padding added to each measured side (default 24) */
|
|
893
|
+
padding?: number;
|
|
894
|
+
paddingTop?: number;
|
|
895
|
+
paddingRight?: number;
|
|
896
|
+
paddingBottom?: number;
|
|
897
|
+
paddingLeft?: number;
|
|
898
|
+
/** final value for the given side, replacing the measured UI size
|
|
899
|
+
* (padding is not added on top) */
|
|
900
|
+
top?: number;
|
|
901
|
+
bottom?: number;
|
|
902
|
+
left?: number;
|
|
903
|
+
right?: number;
|
|
904
|
+
/**
|
|
905
|
+
* Reserve space for the given conditionally-rendered surfaces even while
|
|
906
|
+
* they're hidden, so the resulting offsets don't shift when they
|
|
907
|
+
* (dis)appear. Uses the surface's last-measured footprint, falling back
|
|
908
|
+
* to an approximate default if it hasn't been rendered yet. Ignored on
|
|
909
|
+
* phones (where these surfaces never occlude the canvas).
|
|
910
|
+
*/
|
|
911
|
+
reserve?: {
|
|
912
|
+
/** styles panel (rendered when a tool or selection is active) */
|
|
913
|
+
stylesPanel?: boolean;
|
|
914
|
+
/** sidebar (e.g. library) */
|
|
915
|
+
sidebar?: boolean;
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Viewport offsets accepted by the `setViewport`-family APIs (`setViewport`,
|
|
920
|
+
* `props.initialState.viewport`), insetting the usable viewport area per
|
|
921
|
+
* side so the target isn't fitted/centered underneath overlaid UI.
|
|
922
|
+
*
|
|
923
|
+
* Two (combinable) ways to specify:
|
|
924
|
+
*
|
|
925
|
+
* - **Static sides** (`top`/`right`/`bottom`/`left`) — absolute pixel
|
|
926
|
+
* values, used as-is: physical (not flipped in RTL), zoom-independent,
|
|
927
|
+
* no padding added. Sides not specified default to `0` (unless `ui` is
|
|
928
|
+
* set, see below).
|
|
929
|
+
*
|
|
930
|
+
* - **`ui`** — derive the offsets from the editor UI (toolbar, styles
|
|
931
|
+
* panel, sidebar...) as rendered at the time the viewport is set,
|
|
932
|
+
* equivalent to calling `getViewportOffsets()`. Pass `true` for the
|
|
933
|
+
* defaults, or options ({@link ViewportOffsetsOptions}) to customize
|
|
934
|
+
* padding or reserve space for currently-hidden surfaces.
|
|
935
|
+
*
|
|
936
|
+
* When both are given, a static side always wins for that side — it
|
|
937
|
+
* replaces whatever `ui` would yield (including `ui`'s own side overrides,
|
|
938
|
+
* which — unlike the physical static sides — are RTL-relative). The
|
|
939
|
+
* remaining sides fall back to the `ui`-derived values.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* { top: 40 } // top 40px, other sides 0
|
|
943
|
+
* { ui: true } // measured UI + default padding
|
|
944
|
+
* { ui: { reserve: { stylesPanel: true } } } // + keep space for hidden panel
|
|
945
|
+
* { top: 40, ui: true } // top exactly 40px, rest from UI
|
|
946
|
+
*/
|
|
947
|
+
export type ViewportOffsets = Offsets & {
|
|
948
|
+
ui?: true | ViewportOffsetsOptions;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* Value of the `data-viewport-ui-name` attribute, identifying a
|
|
952
|
+
* conditionally-rendered surface (marked with `data-viewport-ui`) so that
|
|
953
|
+
* `getViewportOffsets` can reserve space for it while it's hidden (see the
|
|
954
|
+
* `reserve` option). Whenever a named surface is rendered, its measured
|
|
955
|
+
* footprint is remembered; reserving uses that remembered footprint, or an
|
|
956
|
+
* approximate default if the surface hasn't been rendered yet.
|
|
957
|
+
*/
|
|
958
|
+
export type ViewportUIName = "sidebar" | "stylesPanel";
|