@excalidraw/math 0.18.0-51ad895 → 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 +44 -10
- package/dist/dev/index.js.map +2 -2
- 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 +26 -18
- package/dist/types/common/src/editorInterface.d.ts +1 -1
- package/dist/types/common/src/font-metadata.d.ts +1 -3
- package/dist/types/common/src/index.d.ts +4 -1
- 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 +40 -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 +19 -12
- package/dist/types/element/src/bounds.d.ts +24 -17
- package/dist/types/element/src/collision.d.ts +4 -3
- package/dist/types/element/src/comparisons.d.ts +8 -7
- 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 +4 -0
- package/dist/types/element/src/linearElementEditor.d.ts +8 -4
- package/dist/types/element/src/mutateElement.d.ts +5 -1
- package/dist/types/element/src/newElement.d.ts +7 -6
- package/dist/types/element/src/renderElement.d.ts +0 -6
- package/dist/types/element/src/resizeElements.d.ts +10 -10
- package/dist/types/element/src/resizeTest.d.ts +1 -1
- 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/textElement.d.ts +1 -1
- 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 +3 -23
- package/dist/types/element/src/typeChecks.d.ts +3 -4
- package/dist/types/element/src/types.d.ts +11 -2
- package/dist/types/element/src/utils.d.ts +9 -5
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +152 -207
- package/dist/types/excalidraw/actions/actionAlign.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +79 -116
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +413 -977
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +111 -148
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +38 -57
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +121 -178
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +161 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +50 -73
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +79 -116
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +54 -73
- package/dist/types/excalidraw/actions/actionExport.d.ts +116 -469
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionFlip.d.ts +0 -1
- package/dist/types/excalidraw/actions/actionFrame.d.ts +236 -344
- package/dist/types/excalidraw/actions/actionGroup.d.ts +83 -128
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +122 -174
- package/dist/types/excalidraw/actions/actionLink.d.ts +56 -75
- package/dist/types/excalidraw/actions/actionMenu.d.ts +44 -67
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionProperties.d.ts +104 -132
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +41 -64
- package/dist/types/excalidraw/actions/actionStyles.d.ts +37 -55
- 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 +54 -73
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +174 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +54 -73
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +44 -67
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +53 -72
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +54 -73
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +54 -73
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
- package/dist/types/excalidraw/actions/index.d.ts +4 -1
- package/dist/types/excalidraw/actions/manager.d.ts +1 -1
- 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 +1 -1
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +23 -19
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +13 -38
- package/dist/types/excalidraw/components/Actions.d.ts +1 -1
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.d.ts +135 -79
- 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/colorPickerUtils.d.ts +1 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -2
- 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 +1 -0
- 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/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/InlineIcon.d.ts +2 -2
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
- package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -1
- 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/PropertiesPopover.d.ts +1 -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/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
- package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
- package/dist/types/excalidraw/components/Toast.d.ts +11 -7
- package/dist/types/excalidraw/components/Trans.d.ts +2 -2
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
- 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 +48 -38
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/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 +41 -21
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -32
- package/dist/types/excalidraw/components/shapes.d.ts +81 -1
- package/dist/types/excalidraw/data/blob.d.ts +330 -7
- package/dist/types/excalidraw/data/encode.d.ts +4 -4
- package/dist/types/excalidraw/data/encryption.d.ts +5 -5
- package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
- package/dist/types/excalidraw/data/index.d.ts +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/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 +1 -1
- package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +1 -2
- package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
- 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 +5 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -4
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +8 -6
- 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 +7 -2
- 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 +264 -25
- 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 +3 -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/common/src/visualdebug.d.ts +0 -41
- 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 -8
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -22
- 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 -46
- 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,22 +1,24 @@
|
|
|
1
|
-
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
|
|
1
|
+
import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
|
|
2
2
|
import type { LinearElementEditor } from "@excalidraw/element";
|
|
3
3
|
import type { MaybeTransformHandleType } from "@excalidraw/element";
|
|
4
|
-
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";
|
|
5
5
|
import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
|
|
6
6
|
import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
7
|
+
import type { GlobalPoint } from "@excalidraw/math";
|
|
7
8
|
import type { Action } from "./actions/types";
|
|
8
9
|
import type { Spreadsheet } from "./charts";
|
|
9
10
|
import type { ClipboardData } from "./clipboard";
|
|
10
11
|
import type App from "./components/App";
|
|
11
12
|
import type Library from "./data/library";
|
|
12
|
-
import type { FileSystemHandle } from "./data/filesystem";
|
|
13
13
|
import type { ContextMenuItems } from "./components/ContextMenu";
|
|
14
14
|
import type { SnapLine } from "./snapping";
|
|
15
15
|
import type { ImportedDataState } from "./data/types";
|
|
16
|
+
import type { SetViewportOptions } from "./viewport";
|
|
16
17
|
import type { Language } from "./i18n";
|
|
17
18
|
import type { isOverScrollBars } from "./scene/scrollbars";
|
|
18
19
|
import type React from "react";
|
|
19
20
|
import type { JSX } from "react";
|
|
21
|
+
export type { App };
|
|
20
22
|
export type SocketId = string & {
|
|
21
23
|
_brand: "SocketId";
|
|
22
24
|
};
|
|
@@ -128,6 +130,7 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
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"];
|
|
@@ -135,6 +138,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
135
138
|
multiElement: AppState["multiElement"];
|
|
136
139
|
newElement: AppState["newElement"];
|
|
137
140
|
isBindingEnabled: AppState["isBindingEnabled"];
|
|
141
|
+
isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
|
|
138
142
|
suggestedBinding: AppState["suggestedBinding"];
|
|
139
143
|
isRotating: AppState["isRotating"];
|
|
140
144
|
elementsToHighlight: AppState["elementsToHighlight"];
|
|
@@ -150,6 +154,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
|
|
150
154
|
frameRendering: AppState["frameRendering"];
|
|
151
155
|
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
|
152
156
|
exportScale: AppState["exportScale"];
|
|
157
|
+
currentItemArrowType: AppState["currentItemArrowType"];
|
|
153
158
|
}>;
|
|
154
159
|
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
|
155
160
|
export type ObservedStandaloneAppState = {
|
|
@@ -168,6 +173,42 @@ export type ObservedElementsAppState = {
|
|
|
168
173
|
lockedMultiSelections: AppState["lockedMultiSelections"];
|
|
169
174
|
activeLockedId: AppState["activeLockedId"];
|
|
170
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
|
+
};
|
|
171
212
|
export interface AppState {
|
|
172
213
|
contextMenu: {
|
|
173
214
|
items: ContextMenuItems;
|
|
@@ -201,9 +242,25 @@ export interface AppState {
|
|
|
201
242
|
* - set on pointer down, updated during pointer move
|
|
202
243
|
*/
|
|
203
244
|
selectionElement: NonDeletedExcalidrawElement | null;
|
|
245
|
+
/**
|
|
246
|
+
* tracking current arrow binding editor state (takes into account
|
|
247
|
+
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
|
248
|
+
*/
|
|
204
249
|
isBindingEnabled: boolean;
|
|
205
|
-
|
|
206
|
-
|
|
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;
|
|
207
264
|
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
|
208
265
|
frameRendering: {
|
|
209
266
|
enabled: boolean;
|
|
@@ -216,7 +273,7 @@ export interface AppState {
|
|
|
216
273
|
/**
|
|
217
274
|
* set when a new text is created or when an existing text is being edited
|
|
218
275
|
*/
|
|
219
|
-
editingTextElement:
|
|
276
|
+
editingTextElement: ExcalidrawTextElement | null;
|
|
220
277
|
activeTool: {
|
|
221
278
|
/**
|
|
222
279
|
* indicates a previous tool we should revert back to if we deselect the
|
|
@@ -239,9 +296,10 @@ export interface AppState {
|
|
|
239
296
|
currentItemStrokeColor: string;
|
|
240
297
|
currentItemBackgroundColor: string;
|
|
241
298
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
242
|
-
|
|
299
|
+
currentItemStrokeWidthKey: StrokeWidthKey;
|
|
243
300
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
|
244
301
|
currentItemRoughness: number;
|
|
302
|
+
currentItemStrokeVariability: StrokeVariability;
|
|
245
303
|
currentItemOpacity: number;
|
|
246
304
|
currentItemFontFamily: FontFamilyValues;
|
|
247
305
|
currentItemFontSize: number;
|
|
@@ -254,6 +312,7 @@ export interface AppState {
|
|
|
254
312
|
viewBackgroundColor: string;
|
|
255
313
|
scrollX: number;
|
|
256
314
|
scrollY: number;
|
|
315
|
+
scrollConstraints: ScrollConstraints | null;
|
|
257
316
|
cursorButton: "up" | "down";
|
|
258
317
|
scrolledOutside: boolean;
|
|
259
318
|
name: string | null;
|
|
@@ -278,6 +337,10 @@ export interface AppState {
|
|
|
278
337
|
} | {
|
|
279
338
|
name: "elementLinkSelector";
|
|
280
339
|
sourceElementId: ExcalidrawElement["id"];
|
|
340
|
+
} | {
|
|
341
|
+
name: "charts";
|
|
342
|
+
data: Spreadsheet;
|
|
343
|
+
rawText: string;
|
|
281
344
|
};
|
|
282
345
|
/**
|
|
283
346
|
* Reflects user preference for whether the default sidebar should be docked.
|
|
@@ -300,7 +363,7 @@ export interface AppState {
|
|
|
300
363
|
selectedElementsAreBeingDragged: boolean;
|
|
301
364
|
shouldCacheIgnoreZoom: boolean;
|
|
302
365
|
toast: {
|
|
303
|
-
message:
|
|
366
|
+
message: React.ReactNode;
|
|
304
367
|
closable?: boolean;
|
|
305
368
|
duration?: number;
|
|
306
369
|
} | null;
|
|
@@ -322,21 +385,13 @@ export interface AppState {
|
|
|
322
385
|
height: number;
|
|
323
386
|
offsetTop: number;
|
|
324
387
|
offsetLeft: number;
|
|
325
|
-
fileHandle:
|
|
388
|
+
fileHandle: FileSystemFileHandle | null;
|
|
326
389
|
collaborators: Map<SocketId, Collaborator>;
|
|
327
390
|
stats: {
|
|
328
391
|
open: boolean;
|
|
329
392
|
/** bitmap. Use `STATS_PANELS` bit values */
|
|
330
393
|
panels: number;
|
|
331
394
|
};
|
|
332
|
-
currentChartType: ChartType;
|
|
333
|
-
pasteDialog: {
|
|
334
|
-
shown: false;
|
|
335
|
-
data: null;
|
|
336
|
-
} | {
|
|
337
|
-
shown: true;
|
|
338
|
-
data: Spreadsheet;
|
|
339
|
-
};
|
|
340
395
|
showHyperlinkPopup: false | "info" | "editor";
|
|
341
396
|
selectedLinearElement: LinearElementEditor | null;
|
|
342
397
|
snapLines: readonly SnapLine[];
|
|
@@ -375,7 +430,7 @@ export type SearchMatch = {
|
|
|
375
430
|
showOnCanvas: boolean;
|
|
376
431
|
}[];
|
|
377
432
|
};
|
|
378
|
-
export type UIAppState = Omit<AppState, "
|
|
433
|
+
export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY">;
|
|
379
434
|
export type NormalizedZoomValue = number & {
|
|
380
435
|
_brand: "normalizedZoom";
|
|
381
436
|
};
|
|
@@ -419,15 +474,45 @@ export type LibraryItemsSource = ((currentLibraryItems: LibraryItems) => MaybePr
|
|
|
419
474
|
export type ExcalidrawInitialDataState = Merge<ImportedDataState, {
|
|
420
475
|
libraryItems?: MaybePromise<Required<ImportedDataState>["libraryItems"]>;
|
|
421
476
|
}>;
|
|
477
|
+
export type ExcalidrawInitialState = {
|
|
478
|
+
viewport?: Omit<SetViewportOptions, "animation">;
|
|
479
|
+
};
|
|
422
480
|
export type OnUserFollowedPayload = {
|
|
423
481
|
userToFollow: UserToFollow;
|
|
424
482
|
action: "FOLLOW" | "UNFOLLOW";
|
|
425
483
|
};
|
|
484
|
+
export type OnExportProgress = {
|
|
485
|
+
type: "progress";
|
|
486
|
+
message?: React.ReactNode;
|
|
487
|
+
/** 0-1 range */
|
|
488
|
+
progress?: number;
|
|
489
|
+
};
|
|
426
490
|
export interface ExcalidrawProps {
|
|
427
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
|
+
*/
|
|
428
496
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
429
497
|
initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
|
|
430
|
-
|
|
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;
|
|
431
516
|
isCollaborating?: boolean;
|
|
432
517
|
onPointerUpdate?: (payload: {
|
|
433
518
|
pointer: {
|
|
@@ -465,6 +550,10 @@ export interface ExcalidrawProps {
|
|
|
465
550
|
name?: string;
|
|
466
551
|
renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
|
|
467
552
|
UIOptions?: Partial<UIOptions>;
|
|
553
|
+
/**
|
|
554
|
+
* dimensions and size constraints for inserted images
|
|
555
|
+
*/
|
|
556
|
+
imageOptions?: ImageOptions;
|
|
468
557
|
detectScroll?: boolean;
|
|
469
558
|
handleKeyboardGlobally?: boolean;
|
|
470
559
|
onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
|
|
@@ -484,6 +573,29 @@ export interface ExcalidrawProps {
|
|
|
484
573
|
aiEnabled?: boolean;
|
|
485
574
|
showDeprecatedFonts?: boolean;
|
|
486
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>;
|
|
487
599
|
}
|
|
488
600
|
export type SceneData = {
|
|
489
601
|
elements?: ImportedDataState["elements"];
|
|
@@ -496,12 +608,21 @@ export type ExportOpts = {
|
|
|
496
608
|
onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
|
|
497
609
|
renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
|
|
498
610
|
};
|
|
611
|
+
export type ImageOptions = Partial<{
|
|
612
|
+
maxWidthOrHeight: number;
|
|
613
|
+
maxFileSizeBytes: number;
|
|
614
|
+
}>;
|
|
499
615
|
export type CanvasActions = Partial<{
|
|
500
616
|
changeViewBackgroundColor: boolean;
|
|
501
617
|
clearCanvas: boolean;
|
|
502
618
|
export: false | ExportOpts;
|
|
503
619
|
loadScene: boolean;
|
|
504
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
|
+
* */
|
|
505
626
|
toggleTheme: boolean | null;
|
|
506
627
|
saveAsImage: boolean;
|
|
507
628
|
}>;
|
|
@@ -515,8 +636,7 @@ export type UIOptions = Partial<{
|
|
|
515
636
|
* Optionally control the editor form factor and desktop UI mode from the host app.
|
|
516
637
|
* If not provided, we will take care of it internally.
|
|
517
638
|
*/
|
|
518
|
-
|
|
519
|
-
desktopUIMode?: EditorInterface["desktopUIMode"];
|
|
639
|
+
getFormFactor?: (editorWidth: number, editorHeight: number) => EditorInterface["formFactor"];
|
|
520
640
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
|
521
641
|
welcomeScreen?: boolean;
|
|
522
642
|
}>;
|
|
@@ -526,6 +646,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
526
646
|
export: ExportOpts;
|
|
527
647
|
};
|
|
528
648
|
}>;
|
|
649
|
+
imageOptions: Required<ImageOptions>;
|
|
529
650
|
detectScroll: boolean;
|
|
530
651
|
handleKeyboardGlobally: boolean;
|
|
531
652
|
isCollaborating: boolean;
|
|
@@ -537,6 +658,8 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
537
658
|
export type AppClassProperties = {
|
|
538
659
|
props: AppProps;
|
|
539
660
|
state: AppState;
|
|
661
|
+
api: App["api"];
|
|
662
|
+
sessionExportThemeOverride: App["sessionExportThemeOverride"];
|
|
540
663
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
541
664
|
/** static canvas */
|
|
542
665
|
canvas: HTMLCanvasElement;
|
|
@@ -556,7 +679,7 @@ export type AppClassProperties = {
|
|
|
556
679
|
onInsertElements: App["onInsertElements"];
|
|
557
680
|
onExportImage: App["onExportImage"];
|
|
558
681
|
lastViewportPosition: App["lastViewportPosition"];
|
|
559
|
-
|
|
682
|
+
setViewport: App["setViewport"];
|
|
560
683
|
addFiles: App["addFiles"];
|
|
561
684
|
addElementsFromPasteOrLibrary: App["addElementsFromPasteOrLibrary"];
|
|
562
685
|
togglePenMode: App["togglePenMode"];
|
|
@@ -571,13 +694,17 @@ export type AppClassProperties = {
|
|
|
571
694
|
getEffectiveGridSize: App["getEffectiveGridSize"];
|
|
572
695
|
setPlugins: App["setPlugins"];
|
|
573
696
|
plugins: App["plugins"];
|
|
574
|
-
|
|
697
|
+
getViewportOffsets: App["getViewportOffsets"];
|
|
575
698
|
visibleElements: App["visibleElements"];
|
|
576
699
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
577
700
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
578
701
|
updateEditorAtom: App["updateEditorAtom"];
|
|
579
702
|
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
703
|
+
onEvent: App["onEvent"];
|
|
704
|
+
onStateChange: App["onStateChange"];
|
|
705
|
+
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
580
706
|
bindModeHandler: App["bindModeHandler"];
|
|
707
|
+
setAppState: App["setAppState"];
|
|
581
708
|
};
|
|
582
709
|
export type PointerDownState = Readonly<{
|
|
583
710
|
origin: Readonly<{
|
|
@@ -638,7 +765,18 @@ export type PointerDownState = Readonly<{
|
|
|
638
765
|
};
|
|
639
766
|
}>;
|
|
640
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
|
+
};
|
|
641
777
|
export interface ExcalidrawImperativeAPI {
|
|
778
|
+
/** Whether the editor has been unmounted and the API is no longer usable. */
|
|
779
|
+
isDestroyed: boolean;
|
|
642
780
|
updateScene: InstanceType<typeof App>["updateScene"];
|
|
643
781
|
applyDeltas: InstanceType<typeof App>["applyDeltas"];
|
|
644
782
|
mutateElement: InstanceType<typeof App>["mutateElement"];
|
|
@@ -653,7 +791,8 @@ export interface ExcalidrawImperativeAPI {
|
|
|
653
791
|
getAppState: () => InstanceType<typeof App>["state"];
|
|
654
792
|
getFiles: () => InstanceType<typeof App>["files"];
|
|
655
793
|
getName: InstanceType<typeof App>["getName"];
|
|
656
|
-
|
|
794
|
+
setViewport: InstanceType<typeof App>["setViewport"];
|
|
795
|
+
getViewportOffsets: InstanceType<typeof App>["getViewportOffsets"];
|
|
657
796
|
registerAction: (action: Action) => void;
|
|
658
797
|
refresh: InstanceType<typeof App>["refresh"];
|
|
659
798
|
setToast: InstanceType<typeof App>["setToast"];
|
|
@@ -676,6 +815,8 @@ export interface ExcalidrawImperativeAPI {
|
|
|
676
815
|
onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
|
|
677
816
|
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
|
678
817
|
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
|
818
|
+
onStateChange: InstanceType<typeof App>["onStateChange"];
|
|
819
|
+
onEvent: InstanceType<typeof App>["onEvent"];
|
|
679
820
|
}
|
|
680
821
|
export type FrameNameBounds = {
|
|
681
822
|
x: number;
|
|
@@ -716,4 +857,102 @@ export type Offsets = Partial<{
|
|
|
716
857
|
bottom: number;
|
|
717
858
|
left: number;
|
|
718
859
|
}>;
|
|
719
|
-
|
|
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";
|