@excalidraw/excalidraw 0.17.1-7441-0269e5a → 0.17.1-7441-4c9a6f4
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/browser/excalidraw-assets/{chunk-V52YQ6TH.js → chunk-LZCCI7PN.js} +1181 -1675
- package/dist/browser/excalidraw-assets/{image-MZHH7VY4.js → image-CG4AV2NT.js} +1 -1
- package/dist/browser/excalidraw-assets/{image-2MHILQWB.css → image-EO7USLQY.css} +1 -1
- package/dist/browser/index.css +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/packages/excalidraw/actions/actionAddToLibrary.js +59 -0
- package/dist/packages/excalidraw/actions/actionAlign.js +124 -0
- package/dist/packages/excalidraw/actions/actionBoundText.js +213 -0
- package/dist/packages/excalidraw/actions/actionCanvas.js +354 -0
- package/dist/packages/excalidraw/actions/actionClipboard.js +221 -0
- package/dist/packages/excalidraw/actions/actionDeleteSelected.js +129 -0
- package/dist/packages/excalidraw/actions/actionDistribute.js +56 -0
- package/dist/packages/excalidraw/actions/actionDuplicateSelection.js +181 -0
- package/dist/packages/excalidraw/actions/actionElementLock.js +89 -0
- package/dist/packages/excalidraw/actions/actionExport.js +195 -0
- package/dist/packages/excalidraw/actions/actionFinalize.js +150 -0
- package/dist/packages/excalidraw/actions/actionFlip.js +52 -0
- package/dist/packages/excalidraw/actions/actionFrame.js +113 -0
- package/dist/packages/excalidraw/actions/actionGroup.js +162 -0
- package/dist/packages/excalidraw/actions/actionHistory.js +57 -0
- package/dist/packages/excalidraw/actions/actionLinearEditor.js +41 -0
- package/dist/packages/excalidraw/actions/actionMenu.js +53 -0
- package/dist/packages/excalidraw/actions/actionNavigate.js +43 -0
- package/dist/packages/excalidraw/actions/actionProperties.js +683 -0
- package/dist/packages/excalidraw/actions/actionSelectAll.js +40 -0
- package/dist/packages/excalidraw/actions/actionStyles.js +118 -0
- package/dist/packages/excalidraw/actions/actionToggleGridMode.js +27 -0
- package/dist/packages/excalidraw/actions/actionToggleObjectsSnapMode.js +26 -0
- package/dist/packages/excalidraw/actions/actionToggleStats.js +19 -0
- package/dist/packages/excalidraw/actions/actionToggleViewMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionToggleZenMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionZindex.js +86 -0
- package/dist/packages/excalidraw/actions/index.js +25 -0
- package/dist/packages/excalidraw/actions/manager.js +110 -0
- package/dist/packages/excalidraw/actions/register.js +5 -0
- package/dist/packages/excalidraw/actions/shortcuts.js +52 -0
- package/dist/packages/excalidraw/align.js +36 -0
- package/dist/packages/excalidraw/analytics.js +30 -0
- package/dist/packages/excalidraw/appState.js +222 -0
- package/dist/packages/excalidraw/charts.js +365 -0
- package/dist/packages/excalidraw/clients.js +34 -0
- package/dist/packages/excalidraw/clipboard.js +351 -0
- package/dist/packages/excalidraw/colors.js +124 -0
- package/dist/packages/excalidraw/components/Actions.js +127 -0
- package/dist/packages/excalidraw/components/Actions.scss +92 -0
- package/dist/packages/excalidraw/components/ActiveConfirmDialog.js +22 -0
- package/dist/packages/excalidraw/components/App.js +6177 -0
- package/dist/packages/excalidraw/components/Avatar.js +15 -0
- package/dist/packages/excalidraw/components/Avatar.scss +7 -0
- package/dist/packages/excalidraw/components/BraveMeasureTextError.js +6 -0
- package/dist/packages/excalidraw/components/Button.js +14 -0
- package/dist/packages/excalidraw/components/Button.scss +7 -0
- package/dist/packages/excalidraw/components/ButtonIconCycle.js +11 -0
- package/dist/packages/excalidraw/components/ButtonIconSelect.js +6 -0
- package/dist/packages/excalidraw/components/ButtonSelect.js +3 -0
- package/dist/packages/excalidraw/components/Card.js +14 -0
- package/dist/packages/excalidraw/components/Card.scss +57 -0
- package/dist/packages/excalidraw/components/CheckboxItem.js +10 -0
- package/dist/packages/excalidraw/components/CheckboxItem.scss +91 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorInput.js +67 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.js +138 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.scss +441 -0
- package/dist/packages/excalidraw/components/ColorPicker/CustomColorList.js +24 -0
- package/dist/packages/excalidraw/components/ColorPicker/HotkeyLabel.js +8 -0
- package/dist/packages/excalidraw/components/ColorPicker/Picker.js +86 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerColorList.js +33 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerHeading.js +3 -0
- package/dist/packages/excalidraw/components/ColorPicker/ShadeList.js +44 -0
- package/dist/packages/excalidraw/components/ColorPicker/TopPicks.js +27 -0
- package/dist/packages/excalidraw/components/ColorPicker/colorPickerUtils.js +83 -0
- package/dist/packages/excalidraw/components/ColorPicker/keyboardNavHandlers.js +174 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.js +27 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.scss +11 -0
- package/dist/packages/excalidraw/components/ContextMenu.js +56 -0
- package/dist/packages/excalidraw/components/ContextMenu.scss +98 -0
- package/dist/packages/excalidraw/components/DarkModeToggle.js +16 -0
- package/dist/packages/excalidraw/components/DefaultSidebar.js +48 -0
- package/dist/packages/excalidraw/components/Dialog.js +74 -0
- package/dist/packages/excalidraw/components/Dialog.scss +48 -0
- package/dist/packages/excalidraw/components/DialogActionButton.js +9 -0
- package/dist/packages/excalidraw/components/DialogActionButton.scss +47 -0
- package/dist/packages/excalidraw/components/ErrorDialog.js +18 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.js +7 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.scss +73 -0
- package/dist/packages/excalidraw/components/ExportDialog.scss +129 -0
- package/dist/packages/excalidraw/components/EyeDropper.js +130 -0
- package/dist/packages/excalidraw/components/EyeDropper.scss +48 -0
- package/dist/packages/excalidraw/components/FilledButton.js +7 -0
- package/dist/packages/excalidraw/components/FilledButton.scss +191 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.js +4 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.scss +40 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.js +7 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.scss +59 -0
- package/dist/packages/excalidraw/components/HandButton.js +9 -0
- package/dist/packages/excalidraw/components/HelpButton.js +4 -0
- package/dist/packages/excalidraw/components/HelpDialog.js +79 -0
- package/dist/packages/excalidraw/components/HelpDialog.scss +130 -0
- package/dist/packages/excalidraw/components/HintViewer.js +97 -0
- package/dist/packages/excalidraw/components/HintViewer.scss +37 -0
- package/dist/packages/excalidraw/components/IconPicker.js +99 -0
- package/dist/packages/excalidraw/components/IconPicker.scss +143 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.js +127 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.scss +173 -0
- package/dist/packages/excalidraw/components/InitializeApp.js +16 -0
- package/dist/packages/excalidraw/components/InlineIcon.js +10 -0
- package/dist/packages/excalidraw/components/Island.js +5 -0
- package/dist/packages/excalidraw/components/Island.scss +16 -0
- package/dist/packages/excalidraw/components/JSONExportDialog.js +35 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPathManager.js +225 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPointerButton.js +10 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserTool.js +15 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserToolOverlay.scss +20 -0
- package/dist/packages/excalidraw/components/LayerUI.js +189 -0
- package/dist/packages/excalidraw/components/LayerUI.scss +112 -0
- package/dist/packages/excalidraw/components/LibraryMenu.js +99 -0
- package/dist/packages/excalidraw/components/LibraryMenu.scss +150 -0
- package/dist/packages/excalidraw/components/LibraryMenuBrowseButton.js +8 -0
- package/dist/packages/excalidraw/components/LibraryMenuControlButtons.js +6 -0
- package/dist/packages/excalidraw/components/LibraryMenuHeaderContent.js +126 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.js +138 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.scss +99 -0
- package/dist/packages/excalidraw/components/LibraryMenuSection.js +21 -0
- package/dist/packages/excalidraw/components/LibraryUnit.js +52 -0
- package/dist/packages/excalidraw/components/LibraryUnit.scss +185 -0
- package/dist/packages/excalidraw/components/LoadingMessage.js +24 -0
- package/dist/packages/excalidraw/components/LockButton.js +14 -0
- package/dist/packages/excalidraw/components/MagicButton.js +9 -0
- package/dist/packages/excalidraw/components/MagicSettings.js +46 -0
- package/dist/packages/excalidraw/components/MagicSettings.scss +18 -0
- package/dist/packages/excalidraw/components/MobileMenu.js +45 -0
- package/dist/packages/excalidraw/components/Modal.js +23 -0
- package/dist/packages/excalidraw/components/Modal.scss +121 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.js +31 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss +126 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.js +32 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.js +19 -0
- package/dist/packages/excalidraw/components/Paragraph.js +4 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.js +63 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.scss +46 -0
- package/dist/packages/excalidraw/components/PenModeButton.js +13 -0
- package/dist/packages/excalidraw/components/Popover.js +111 -0
- package/dist/packages/excalidraw/components/Popover.scss +8 -0
- package/dist/packages/excalidraw/components/ProjectName.js +30 -0
- package/dist/packages/excalidraw/components/ProjectName.scss +25 -0
- package/dist/packages/excalidraw/components/PublishLibrary.js +214 -0
- package/dist/packages/excalidraw/components/PublishLibrary.scss +172 -0
- package/dist/packages/excalidraw/components/RadioGroup.js +8 -0
- package/dist/packages/excalidraw/components/RadioGroup.scss +91 -0
- package/dist/packages/excalidraw/components/Section.js +8 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.js +33 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.scss +91 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.js +145 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.scss +176 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarHeader.js +16 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTab.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabs.js +17 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.js +18 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.scss +37 -0
- package/dist/packages/excalidraw/components/Sidebar/common.js +2 -0
- package/dist/packages/excalidraw/components/Spinner.js +14 -0
- package/dist/packages/excalidraw/components/Spinner.scss +49 -0
- package/dist/packages/excalidraw/components/Stack.js +24 -0
- package/dist/packages/excalidraw/components/Stack.scss +19 -0
- package/dist/packages/excalidraw/components/Stats.js +13 -0
- package/dist/packages/excalidraw/components/Stats.scss +54 -0
- package/dist/packages/excalidraw/components/Switch.js +10 -0
- package/dist/packages/excalidraw/components/Switch.scss +118 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.js +58 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.scss +10 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.js +194 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.scss +315 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogInput.js +28 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogOutput.js +8 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanel.js +11 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanels.js +4 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.js +5 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTab.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabs.js +39 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTrigger.js +16 -0
- package/dist/packages/excalidraw/components/TTDDialog/common.js +88 -0
- package/dist/packages/excalidraw/components/TextField.js +25 -0
- package/dist/packages/excalidraw/components/TextField.scss +109 -0
- package/dist/packages/excalidraw/components/TextInput.scss +7 -0
- package/dist/packages/excalidraw/components/Toast.js +30 -0
- package/dist/packages/excalidraw/components/Toast.scss +49 -0
- package/dist/packages/excalidraw/components/ToolButton.js +72 -0
- package/dist/packages/excalidraw/components/ToolIcon.scss +184 -0
- package/dist/packages/excalidraw/components/Toolbar.scss +50 -0
- package/dist/packages/excalidraw/components/Tooltip.js +60 -0
- package/dist/packages/excalidraw/components/Tooltip.scss +47 -0
- package/dist/packages/excalidraw/components/Trans.js +139 -0
- package/dist/packages/excalidraw/components/UserList.js +96 -0
- package/dist/packages/excalidraw/components/UserList.scss +136 -0
- package/dist/packages/excalidraw/components/canvases/InteractiveCanvas.js +120 -0
- package/dist/packages/excalidraw/components/canvases/StaticCanvas.js +85 -0
- package/dist/packages/excalidraw/components/canvases/index.js +3 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.js +24 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.scss +148 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuContent.js +21 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuGroup.js +6 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItem.js +23 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +7 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.js +5 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemLink.js +9 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuSeparator.js +8 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuTrigger.js +12 -0
- package/dist/packages/excalidraw/components/dropdownMenu/common.js +20 -0
- package/dist/packages/excalidraw/components/dropdownMenu/dropdownMenuUtils.js +27 -0
- package/dist/packages/excalidraw/components/footer/Footer.js +25 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.js +14 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.scss +11 -0
- package/dist/packages/excalidraw/components/hoc/withInternalFallback.js +57 -0
- package/dist/packages/excalidraw/components/icons.js +220 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.js +13 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss +72 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.js +116 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.scss +21 -0
- package/dist/packages/excalidraw/components/main-menu/MainMenu.js +36 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +69 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +20 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.js +11 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.scss +285 -0
- package/dist/packages/excalidraw/constants.js +312 -0
- package/dist/packages/excalidraw/context/tunnels.js +21 -0
- package/dist/packages/excalidraw/context/ui-appState.js +3 -0
- package/dist/packages/excalidraw/css/app.scss +39 -0
- package/dist/packages/excalidraw/css/styles.scss +757 -0
- package/dist/packages/excalidraw/css/theme.scss +252 -0
- package/dist/packages/excalidraw/css/variables.module.scss +174 -0
- package/dist/packages/excalidraw/cursor.js +72 -0
- package/dist/packages/excalidraw/data/EditorLocalStorage.js +42 -0
- package/dist/packages/excalidraw/data/ai/types.js +1 -0
- package/dist/packages/excalidraw/data/blob.js +378 -0
- package/dist/packages/excalidraw/data/encode.js +231 -0
- package/dist/packages/excalidraw/data/encryption.js +53 -0
- package/dist/packages/excalidraw/data/filesystem.js +65 -0
- package/dist/packages/excalidraw/data/image.js +91 -0
- package/dist/packages/excalidraw/data/index.js +120 -0
- package/dist/packages/excalidraw/data/json.js +93 -0
- package/dist/packages/excalidraw/data/library.js +376 -0
- package/dist/packages/excalidraw/data/magic.js +73 -0
- package/dist/packages/excalidraw/data/resave.js +22 -0
- package/dist/packages/excalidraw/data/restore.js +438 -0
- package/dist/packages/excalidraw/data/transform.js +442 -0
- package/dist/packages/excalidraw/data/types.js +1 -0
- package/dist/packages/excalidraw/data/url.js +30 -0
- package/dist/packages/excalidraw/distribute.js +58 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.js +31 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.scss +14 -0
- package/dist/packages/excalidraw/element/Hyperlink.js +350 -0
- package/dist/packages/excalidraw/element/Hyperlink.scss +70 -0
- package/dist/packages/excalidraw/element/binding.js +412 -0
- package/dist/packages/excalidraw/element/bounds.js +613 -0
- package/dist/packages/excalidraw/element/collision.js +727 -0
- package/dist/packages/excalidraw/element/dragElements.js +119 -0
- package/dist/packages/excalidraw/element/embeddable.js +305 -0
- package/dist/packages/excalidraw/element/image.js +91 -0
- package/dist/packages/excalidraw/element/index.js +24 -0
- package/dist/packages/excalidraw/element/linearElementEditor.js +867 -0
- package/dist/packages/excalidraw/element/mutateElement.js +112 -0
- package/dist/packages/excalidraw/element/newElement.js +389 -0
- package/dist/packages/excalidraw/element/resizeElements.js +597 -0
- package/dist/packages/excalidraw/element/resizeTest.js +95 -0
- package/dist/packages/excalidraw/element/showSelectedShapeActions.js +9 -0
- package/dist/packages/excalidraw/element/sizeHelpers.js +131 -0
- package/dist/packages/excalidraw/element/sortElements.js +104 -0
- package/dist/packages/excalidraw/element/textElement.js +716 -0
- package/dist/packages/excalidraw/element/textWysiwyg.js +500 -0
- package/dist/packages/excalidraw/element/transformHandles.js +155 -0
- package/dist/packages/excalidraw/element/typeChecks.js +141 -0
- package/dist/packages/excalidraw/element/types.js +1 -0
- package/dist/packages/excalidraw/emitter.js +36 -0
- package/dist/packages/excalidraw/errors.js +20 -0
- package/dist/packages/excalidraw/frame.js +373 -0
- package/dist/packages/excalidraw/ga.js +268 -0
- package/dist/packages/excalidraw/gadirections.js +18 -0
- package/dist/packages/excalidraw/galines.js +32 -0
- package/dist/packages/excalidraw/gapoints.js +30 -0
- package/dist/packages/excalidraw/gatransforms.js +23 -0
- package/dist/packages/excalidraw/gesture.js +9 -0
- package/dist/packages/excalidraw/groups.js +225 -0
- package/dist/packages/excalidraw/history.js +190 -0
- package/dist/packages/excalidraw/hooks/useCallbackRefState.js +6 -0
- package/dist/packages/excalidraw/hooks/useCreatePortalContainer.js +32 -0
- package/dist/packages/excalidraw/hooks/useLibraryItemSvg.js +62 -0
- package/dist/packages/excalidraw/hooks/useOutsideClick.js +67 -0
- package/dist/packages/excalidraw/hooks/useScrollPosition.js +23 -0
- package/dist/packages/excalidraw/hooks/useStable.js +6 -0
- package/dist/packages/excalidraw/hooks/useTransition.js +7 -0
- package/dist/packages/excalidraw/i18n.js +137 -0
- package/dist/packages/excalidraw/index-node.d.ts +1 -0
- package/dist/packages/excalidraw/index-node.js +73 -0
- package/{types → dist/packages}/excalidraw/index.d.ts +1 -1
- package/dist/packages/excalidraw/index.js +116 -0
- package/dist/packages/excalidraw/jotai.js +18 -0
- package/dist/packages/excalidraw/keys.js +84 -0
- package/dist/packages/excalidraw/locales/ar-SA.json +525 -0
- package/dist/packages/excalidraw/locales/az-AZ.json +525 -0
- package/dist/packages/excalidraw/locales/bg-BG.json +525 -0
- package/dist/packages/excalidraw/locales/bn-BD.json +525 -0
- package/dist/packages/excalidraw/locales/ca-ES.json +525 -0
- package/dist/packages/excalidraw/locales/cs-CZ.json +525 -0
- package/dist/packages/excalidraw/locales/da-DK.json +525 -0
- package/dist/packages/excalidraw/locales/de-DE.json +525 -0
- package/dist/packages/excalidraw/locales/el-GR.json +525 -0
- package/dist/packages/excalidraw/locales/en.json +535 -0
- package/dist/packages/excalidraw/locales/es-ES.json +525 -0
- package/dist/packages/excalidraw/locales/eu-ES.json +525 -0
- package/dist/packages/excalidraw/locales/fa-IR.json +525 -0
- package/dist/packages/excalidraw/locales/fi-FI.json +525 -0
- package/dist/packages/excalidraw/locales/fr-FR.json +525 -0
- package/dist/packages/excalidraw/locales/gl-ES.json +525 -0
- package/dist/packages/excalidraw/locales/he-IL.json +525 -0
- package/dist/packages/excalidraw/locales/hi-IN.json +525 -0
- package/dist/packages/excalidraw/locales/hu-HU.json +525 -0
- package/dist/packages/excalidraw/locales/id-ID.json +525 -0
- package/dist/packages/excalidraw/locales/it-IT.json +525 -0
- package/dist/packages/excalidraw/locales/ja-JP.json +525 -0
- package/dist/packages/excalidraw/locales/kaa.json +525 -0
- package/dist/packages/excalidraw/locales/kab-KAB.json +525 -0
- package/dist/packages/excalidraw/locales/kk-KZ.json +525 -0
- package/dist/packages/excalidraw/locales/km-KH.json +525 -0
- package/dist/packages/excalidraw/locales/ko-KR.json +525 -0
- package/dist/packages/excalidraw/locales/ku-TR.json +525 -0
- package/dist/packages/excalidraw/locales/lt-LT.json +525 -0
- package/dist/packages/excalidraw/locales/lv-LV.json +525 -0
- package/dist/packages/excalidraw/locales/mr-IN.json +525 -0
- package/dist/packages/excalidraw/locales/my-MM.json +525 -0
- package/dist/packages/excalidraw/locales/nb-NO.json +525 -0
- package/dist/packages/excalidraw/locales/nl-NL.json +525 -0
- package/dist/packages/excalidraw/locales/nn-NO.json +525 -0
- package/dist/packages/excalidraw/locales/oc-FR.json +525 -0
- package/dist/packages/excalidraw/locales/pa-IN.json +525 -0
- package/dist/packages/excalidraw/locales/percentages.json +56 -0
- package/dist/packages/excalidraw/locales/pl-PL.json +525 -0
- package/dist/packages/excalidraw/locales/pt-BR.json +525 -0
- package/dist/packages/excalidraw/locales/pt-PT.json +525 -0
- package/dist/packages/excalidraw/locales/ro-RO.json +525 -0
- package/dist/packages/excalidraw/locales/ru-RU.json +525 -0
- package/dist/packages/excalidraw/locales/si-LK.json +525 -0
- package/dist/packages/excalidraw/locales/sk-SK.json +525 -0
- package/dist/packages/excalidraw/locales/sl-SI.json +525 -0
- package/dist/packages/excalidraw/locales/sv-SE.json +525 -0
- package/dist/packages/excalidraw/locales/ta-IN.json +525 -0
- package/dist/packages/excalidraw/locales/th-TH.json +525 -0
- package/dist/packages/excalidraw/locales/tr-TR.json +525 -0
- package/dist/packages/excalidraw/locales/uk-UA.json +525 -0
- package/dist/packages/excalidraw/locales/vi-VN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-CN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-HK.json +525 -0
- package/dist/packages/excalidraw/locales/zh-TW.json +525 -0
- package/dist/packages/excalidraw/math.js +364 -0
- package/dist/packages/excalidraw/points.js +38 -0
- package/dist/packages/excalidraw/polyfill.js +32 -0
- package/dist/packages/excalidraw/random.js +11 -0
- package/dist/packages/excalidraw/renderer/renderElement.js +871 -0
- package/dist/packages/excalidraw/renderer/renderScene.js +859 -0
- package/dist/packages/excalidraw/renderer/renderSnaps.js +114 -0
- package/dist/packages/excalidraw/renderer/roundRect.js +28 -0
- package/dist/packages/excalidraw/scene/Fonts.js +71 -0
- package/dist/packages/excalidraw/scene/Renderer.js +65 -0
- package/dist/packages/excalidraw/scene/Scene.js +230 -0
- package/dist/packages/excalidraw/scene/Shape.js +322 -0
- package/dist/packages/excalidraw/scene/ShapeCache.js +42 -0
- package/dist/packages/excalidraw/scene/comparisons.js +67 -0
- package/dist/packages/excalidraw/scene/export.js +304 -0
- package/dist/packages/excalidraw/scene/index.js +5 -0
- package/dist/packages/excalidraw/scene/scroll.js +35 -0
- package/dist/packages/excalidraw/scene/scrollbars.js +85 -0
- package/dist/packages/excalidraw/scene/selection.js +134 -0
- package/dist/packages/excalidraw/scene/types.js +1 -0
- package/dist/packages/excalidraw/scene/zoom.js +22 -0
- package/dist/packages/excalidraw/shapes.js +84 -0
- package/dist/packages/excalidraw/snapping.js +838 -0
- package/dist/packages/excalidraw/types.js +6 -0
- package/dist/packages/excalidraw/utility-types.js +1 -0
- package/dist/packages/excalidraw/utils.js +668 -0
- package/dist/packages/excalidraw/zindex.js +349 -0
- package/dist/packages/utils/bbox.js +42 -0
- package/dist/packages/utils/export.js +109 -0
- package/dist/packages/utils/withinBounds.js +125 -0
- package/dist/public/fonts/Assistant-Bold.woff2 +0 -0
- package/dist/public/fonts/Assistant-Medium.woff2 +0 -0
- package/dist/public/fonts/Assistant-Regular.woff2 +0 -0
- package/dist/public/fonts/Assistant-SemiBold.woff2 +0 -0
- package/dist/public/fonts/Cascadia.ttf +0 -0
- package/dist/public/fonts/Cascadia.woff2 +0 -0
- package/dist/public/fonts/FG_Virgil.ttf +0 -0
- package/dist/public/fonts/FG_Virgil.woff2 +0 -0
- package/dist/public/fonts/Virgil.woff2 +0 -0
- package/dist/public/fonts/fonts.css +38 -0
- package/package.json +8 -5
- package/dist/index.css +0 -5796
- package/dist/index.js +0 -71898
- /package/{types → dist/packages}/excalidraw/actions/actionAddToLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionAlign.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionBoundText.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionClipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDeleteSelected.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDistribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDuplicateSelection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionElementLock.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionExport.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFinalize.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFlip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFrame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionHistory.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionLinearEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionNavigate.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionProperties.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionSelectAll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionStyles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleGridMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleStats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleViewMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleZenMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionZindex.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/manager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/register.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/shortcuts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/types.d.ts +0 -0
- /package/{types/excalidraw/index-node.d.ts → dist/packages/excalidraw/actions/types.js} +0 -0
- /package/{types → dist/packages}/excalidraw/align.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/analytics.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/charts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clients.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/colors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Actions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ActiveConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/App.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Avatar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/BraveMeasureTextError.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Button.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconCycle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Card.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/CheckboxItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/CustomColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/Picker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerHeading.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ShadeList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/TopPicks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ContextMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DarkModeToggle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DefaultSidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Dialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DialogActionButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ErrorDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ExcalidrawLogo.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/EyeDropper.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FilledButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FixedSideContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FollowMode/FollowMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HandButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HintViewer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/IconPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ImageExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InitializeApp.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InlineIcon.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Island.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/JSONExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserTool.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LayerUI.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuBrowseButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuControlButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuHeaderContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuSection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryUnit.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LoadingMessage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LockButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicSettings.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MobileMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Modal.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Paragraph.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PasteChartDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PenModeButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Popover.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ProjectName.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PublishLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/RadioGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Section.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ShareableLinkDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/Sidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarHeader.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Spinner.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stack.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Switch.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TextField.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Toast.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ToolButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Tooltip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Trans.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/UserList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/StaticCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/Footer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/FooterCenter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/hoc/withInternalFallback.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/icons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/DefaultItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/MainMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/constants.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/tunnels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/ui-appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/cursor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/EditorLocalStorage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/ai/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/blob.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encryption.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/filesystem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/json.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/library.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/magic.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/resave.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/restore.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/transform.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/url.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/distribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/ElementCanvasButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/Hyperlink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/binding.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/bounds.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/collision.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/dragElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/embeddable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/linearElementEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/mutateElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/newElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeTest.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/showSelectedShapeActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sizeHelpers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sortElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textWysiwyg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/transformHandles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/typeChecks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/emitter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/errors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/frame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/ga.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gadirections.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/galines.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gapoints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gatransforms.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gesture.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/groups.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/history.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCallbackRefState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCreatePortalContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useLibraryItemSvg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useOutsideClick.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useScrollPosition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useStable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useTransition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/i18n.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/jotai.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/keys.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/math.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/points.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/polyfill.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/random.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderScene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderSnaps.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/roundRect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Fonts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Renderer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Scene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Shape.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/ShapeCache.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/comparisons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/export.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scroll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scrollbars.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/selection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/zoom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/shapes.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/snapping.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utility-types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/zindex.d.ts +0 -0
- /package/{types → dist/packages}/utils/bbox.d.ts +0 -0
- /package/{types → dist/packages}/utils/export.d.ts +0 -0
- /package/{types → dist/packages}/utils/withinBounds.d.ts +0 -0
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
import { TOOL_TYPE } from "./constants";
|
|
2
|
+
import { getCommonBounds, getDraggedElementsBounds, getElementAbsoluteCoords, } from "./element/bounds";
|
|
3
|
+
import { isBoundToContainer, isFrameLikeElement } from "./element/typeChecks";
|
|
4
|
+
import { getMaximumGroups } from "./groups";
|
|
5
|
+
import { KEYS } from "./keys";
|
|
6
|
+
import { rangeIntersection, rangesOverlap, rotatePoint } from "./math";
|
|
7
|
+
import { getVisibleAndNonSelectedElements } from "./scene/selection";
|
|
8
|
+
const SNAP_DISTANCE = 8;
|
|
9
|
+
// do not comput more gaps per axis than this limit
|
|
10
|
+
// TODO increase or remove once we optimize
|
|
11
|
+
const VISIBLE_GAPS_LIMIT_PER_AXIS = 99999;
|
|
12
|
+
// snap distance with zoom value taken into consideration
|
|
13
|
+
export const getSnapDistance = (zoomValue) => {
|
|
14
|
+
return SNAP_DISTANCE / zoomValue;
|
|
15
|
+
};
|
|
16
|
+
// -----------------------------------------------------------------------------
|
|
17
|
+
export class SnapCache {
|
|
18
|
+
static referenceSnapPoints = null;
|
|
19
|
+
static visibleGaps = null;
|
|
20
|
+
static setReferenceSnapPoints = (snapPoints) => {
|
|
21
|
+
SnapCache.referenceSnapPoints = snapPoints;
|
|
22
|
+
};
|
|
23
|
+
static getReferenceSnapPoints = () => {
|
|
24
|
+
return SnapCache.referenceSnapPoints;
|
|
25
|
+
};
|
|
26
|
+
static setVisibleGaps = (gaps) => {
|
|
27
|
+
SnapCache.visibleGaps = gaps;
|
|
28
|
+
};
|
|
29
|
+
static getVisibleGaps = () => {
|
|
30
|
+
return SnapCache.visibleGaps;
|
|
31
|
+
};
|
|
32
|
+
static destroy = () => {
|
|
33
|
+
SnapCache.referenceSnapPoints = null;
|
|
34
|
+
SnapCache.visibleGaps = null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// -----------------------------------------------------------------------------
|
|
38
|
+
export const isSnappingEnabled = ({ event, appState, selectedElements, }) => {
|
|
39
|
+
if (event) {
|
|
40
|
+
return ((appState.objectsSnapModeEnabled && !event[KEYS.CTRL_OR_CMD]) ||
|
|
41
|
+
(!appState.objectsSnapModeEnabled &&
|
|
42
|
+
event[KEYS.CTRL_OR_CMD] &&
|
|
43
|
+
appState.gridSize === null));
|
|
44
|
+
}
|
|
45
|
+
// do not suggest snaps for an arrow to give way to binding
|
|
46
|
+
if (selectedElements.length === 1 && selectedElements[0].type === "arrow") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return appState.objectsSnapModeEnabled;
|
|
50
|
+
};
|
|
51
|
+
export const areRoughlyEqual = (a, b, precision = 0.01) => {
|
|
52
|
+
return Math.abs(a - b) <= precision;
|
|
53
|
+
};
|
|
54
|
+
export const getElementsCorners = (elements, { omitCenter, boundingBoxCorners, dragOffset, } = {
|
|
55
|
+
omitCenter: false,
|
|
56
|
+
boundingBoxCorners: false,
|
|
57
|
+
}) => {
|
|
58
|
+
let result = [];
|
|
59
|
+
if (elements.length === 1) {
|
|
60
|
+
const element = elements[0];
|
|
61
|
+
let [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords(element);
|
|
62
|
+
if (dragOffset) {
|
|
63
|
+
x1 += dragOffset.x;
|
|
64
|
+
x2 += dragOffset.x;
|
|
65
|
+
cx += dragOffset.x;
|
|
66
|
+
y1 += dragOffset.y;
|
|
67
|
+
y2 += dragOffset.y;
|
|
68
|
+
cy += dragOffset.y;
|
|
69
|
+
}
|
|
70
|
+
const halfWidth = (x2 - x1) / 2;
|
|
71
|
+
const halfHeight = (y2 - y1) / 2;
|
|
72
|
+
if ((element.type === "diamond" || element.type === "ellipse") &&
|
|
73
|
+
!boundingBoxCorners) {
|
|
74
|
+
const leftMid = rotatePoint([x1, y1 + halfHeight], [cx, cy], element.angle);
|
|
75
|
+
const topMid = rotatePoint([x1 + halfWidth, y1], [cx, cy], element.angle);
|
|
76
|
+
const rightMid = rotatePoint([x2, y1 + halfHeight], [cx, cy], element.angle);
|
|
77
|
+
const bottomMid = rotatePoint([x1 + halfWidth, y2], [cx, cy], element.angle);
|
|
78
|
+
const center = [cx, cy];
|
|
79
|
+
result = omitCenter
|
|
80
|
+
? [leftMid, topMid, rightMid, bottomMid]
|
|
81
|
+
: [leftMid, topMid, rightMid, bottomMid, center];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const topLeft = rotatePoint([x1, y1], [cx, cy], element.angle);
|
|
85
|
+
const topRight = rotatePoint([x2, y1], [cx, cy], element.angle);
|
|
86
|
+
const bottomLeft = rotatePoint([x1, y2], [cx, cy], element.angle);
|
|
87
|
+
const bottomRight = rotatePoint([x2, y2], [cx, cy], element.angle);
|
|
88
|
+
const center = [cx, cy];
|
|
89
|
+
result = omitCenter
|
|
90
|
+
? [topLeft, topRight, bottomLeft, bottomRight]
|
|
91
|
+
: [topLeft, topRight, bottomLeft, bottomRight, center];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (elements.length > 1) {
|
|
95
|
+
const [minX, minY, maxX, maxY] = getDraggedElementsBounds(elements, dragOffset ?? { x: 0, y: 0 });
|
|
96
|
+
const width = maxX - minX;
|
|
97
|
+
const height = maxY - minY;
|
|
98
|
+
const topLeft = [minX, minY];
|
|
99
|
+
const topRight = [maxX, minY];
|
|
100
|
+
const bottomLeft = [minX, maxY];
|
|
101
|
+
const bottomRight = [maxX, maxY];
|
|
102
|
+
const center = [minX + width / 2, minY + height / 2];
|
|
103
|
+
result = omitCenter
|
|
104
|
+
? [topLeft, topRight, bottomLeft, bottomRight]
|
|
105
|
+
: [topLeft, topRight, bottomLeft, bottomRight, center];
|
|
106
|
+
}
|
|
107
|
+
return result.map((point) => [round(point[0]), round(point[1])]);
|
|
108
|
+
};
|
|
109
|
+
const getReferenceElements = (elements, selectedElements, appState) => {
|
|
110
|
+
const selectedFrames = selectedElements
|
|
111
|
+
.filter((element) => isFrameLikeElement(element))
|
|
112
|
+
.map((frame) => frame.id);
|
|
113
|
+
return getVisibleAndNonSelectedElements(elements, selectedElements, appState).filter((element) => !(element.frameId && selectedFrames.includes(element.frameId)));
|
|
114
|
+
};
|
|
115
|
+
export const getVisibleGaps = (elements, selectedElements, appState) => {
|
|
116
|
+
const referenceElements = getReferenceElements(elements, selectedElements, appState);
|
|
117
|
+
const referenceBounds = getMaximumGroups(referenceElements)
|
|
118
|
+
.filter((elementsGroup) => !(elementsGroup.length === 1 && isBoundToContainer(elementsGroup[0])))
|
|
119
|
+
.map((group) => getCommonBounds(group).map((bound) => round(bound)));
|
|
120
|
+
const horizontallySorted = referenceBounds.sort((a, b) => a[0] - b[0]);
|
|
121
|
+
const horizontalGaps = [];
|
|
122
|
+
let c = 0;
|
|
123
|
+
horizontal: for (let i = 0; i < horizontallySorted.length; i++) {
|
|
124
|
+
const startBounds = horizontallySorted[i];
|
|
125
|
+
for (let j = i + 1; j < horizontallySorted.length; j++) {
|
|
126
|
+
if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {
|
|
127
|
+
break horizontal;
|
|
128
|
+
}
|
|
129
|
+
const endBounds = horizontallySorted[j];
|
|
130
|
+
const [, startMinY, startMaxX, startMaxY] = startBounds;
|
|
131
|
+
const [endMinX, endMinY, , endMaxY] = endBounds;
|
|
132
|
+
if (startMaxX < endMinX &&
|
|
133
|
+
rangesOverlap([startMinY, startMaxY], [endMinY, endMaxY])) {
|
|
134
|
+
horizontalGaps.push({
|
|
135
|
+
startBounds,
|
|
136
|
+
endBounds,
|
|
137
|
+
startSide: [
|
|
138
|
+
[startMaxX, startMinY],
|
|
139
|
+
[startMaxX, startMaxY],
|
|
140
|
+
],
|
|
141
|
+
endSide: [
|
|
142
|
+
[endMinX, endMinY],
|
|
143
|
+
[endMinX, endMaxY],
|
|
144
|
+
],
|
|
145
|
+
length: endMinX - startMaxX,
|
|
146
|
+
overlap: rangeIntersection([startMinY, startMaxY], [endMinY, endMaxY]),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const verticallySorted = referenceBounds.sort((a, b) => a[1] - b[1]);
|
|
152
|
+
const verticalGaps = [];
|
|
153
|
+
c = 0;
|
|
154
|
+
vertical: for (let i = 0; i < verticallySorted.length; i++) {
|
|
155
|
+
const startBounds = verticallySorted[i];
|
|
156
|
+
for (let j = i + 1; j < verticallySorted.length; j++) {
|
|
157
|
+
if (++c > VISIBLE_GAPS_LIMIT_PER_AXIS) {
|
|
158
|
+
break vertical;
|
|
159
|
+
}
|
|
160
|
+
const endBounds = verticallySorted[j];
|
|
161
|
+
const [startMinX, , startMaxX, startMaxY] = startBounds;
|
|
162
|
+
const [endMinX, endMinY, endMaxX] = endBounds;
|
|
163
|
+
if (startMaxY < endMinY &&
|
|
164
|
+
rangesOverlap([startMinX, startMaxX], [endMinX, endMaxX])) {
|
|
165
|
+
verticalGaps.push({
|
|
166
|
+
startBounds,
|
|
167
|
+
endBounds,
|
|
168
|
+
startSide: [
|
|
169
|
+
[startMinX, startMaxY],
|
|
170
|
+
[startMaxX, startMaxY],
|
|
171
|
+
],
|
|
172
|
+
endSide: [
|
|
173
|
+
[endMinX, endMinY],
|
|
174
|
+
[endMaxX, endMinY],
|
|
175
|
+
],
|
|
176
|
+
length: endMinY - startMaxY,
|
|
177
|
+
overlap: rangeIntersection([startMinX, startMaxX], [endMinX, endMaxX]),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
horizontalGaps,
|
|
184
|
+
verticalGaps,
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
const getGapSnaps = (selectedElements, dragOffset, appState, event, nearestSnapsX, nearestSnapsY, minOffset) => {
|
|
188
|
+
if (!isSnappingEnabled({ appState, event, selectedElements })) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
if (selectedElements.length === 0) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
const visibleGaps = SnapCache.getVisibleGaps();
|
|
195
|
+
if (visibleGaps) {
|
|
196
|
+
const { horizontalGaps, verticalGaps } = visibleGaps;
|
|
197
|
+
const [minX, minY, maxX, maxY] = getDraggedElementsBounds(selectedElements, dragOffset).map((bound) => round(bound));
|
|
198
|
+
const centerX = (minX + maxX) / 2;
|
|
199
|
+
const centerY = (minY + maxY) / 2;
|
|
200
|
+
for (const gap of horizontalGaps) {
|
|
201
|
+
if (!rangesOverlap([minY, maxY], gap.overlap)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
// center gap
|
|
205
|
+
const gapMidX = gap.startSide[0][0] + gap.length / 2;
|
|
206
|
+
const centerOffset = round(gapMidX - centerX);
|
|
207
|
+
const gapIsLargerThanSelection = gap.length > maxX - minX;
|
|
208
|
+
if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.x) {
|
|
209
|
+
if (Math.abs(centerOffset) < minOffset.x) {
|
|
210
|
+
nearestSnapsX.length = 0;
|
|
211
|
+
}
|
|
212
|
+
minOffset.x = Math.abs(centerOffset);
|
|
213
|
+
const snap = {
|
|
214
|
+
type: "gap",
|
|
215
|
+
direction: "center_horizontal",
|
|
216
|
+
gap,
|
|
217
|
+
offset: centerOffset,
|
|
218
|
+
};
|
|
219
|
+
nearestSnapsX.push(snap);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
// side gap, from the right
|
|
223
|
+
const [, , endMaxX] = gap.endBounds;
|
|
224
|
+
const distanceToEndElementX = minX - endMaxX;
|
|
225
|
+
const sideOffsetRight = round(gap.length - distanceToEndElementX);
|
|
226
|
+
if (Math.abs(sideOffsetRight) <= minOffset.x) {
|
|
227
|
+
if (Math.abs(sideOffsetRight) < minOffset.x) {
|
|
228
|
+
nearestSnapsX.length = 0;
|
|
229
|
+
}
|
|
230
|
+
minOffset.x = Math.abs(sideOffsetRight);
|
|
231
|
+
const snap = {
|
|
232
|
+
type: "gap",
|
|
233
|
+
direction: "side_right",
|
|
234
|
+
gap,
|
|
235
|
+
offset: sideOffsetRight,
|
|
236
|
+
};
|
|
237
|
+
nearestSnapsX.push(snap);
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
// side gap, from the left
|
|
241
|
+
const [startMinX, , ,] = gap.startBounds;
|
|
242
|
+
const distanceToStartElementX = startMinX - maxX;
|
|
243
|
+
const sideOffsetLeft = round(distanceToStartElementX - gap.length);
|
|
244
|
+
if (Math.abs(sideOffsetLeft) <= minOffset.x) {
|
|
245
|
+
if (Math.abs(sideOffsetLeft) < minOffset.x) {
|
|
246
|
+
nearestSnapsX.length = 0;
|
|
247
|
+
}
|
|
248
|
+
minOffset.x = Math.abs(sideOffsetLeft);
|
|
249
|
+
const snap = {
|
|
250
|
+
type: "gap",
|
|
251
|
+
direction: "side_left",
|
|
252
|
+
gap,
|
|
253
|
+
offset: sideOffsetLeft,
|
|
254
|
+
};
|
|
255
|
+
nearestSnapsX.push(snap);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const gap of verticalGaps) {
|
|
260
|
+
if (!rangesOverlap([minX, maxX], gap.overlap)) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
// center gap
|
|
264
|
+
const gapMidY = gap.startSide[0][1] + gap.length / 2;
|
|
265
|
+
const centerOffset = round(gapMidY - centerY);
|
|
266
|
+
const gapIsLargerThanSelection = gap.length > maxY - minY;
|
|
267
|
+
if (gapIsLargerThanSelection && Math.abs(centerOffset) <= minOffset.y) {
|
|
268
|
+
if (Math.abs(centerOffset) < minOffset.y) {
|
|
269
|
+
nearestSnapsY.length = 0;
|
|
270
|
+
}
|
|
271
|
+
minOffset.y = Math.abs(centerOffset);
|
|
272
|
+
const snap = {
|
|
273
|
+
type: "gap",
|
|
274
|
+
direction: "center_vertical",
|
|
275
|
+
gap,
|
|
276
|
+
offset: centerOffset,
|
|
277
|
+
};
|
|
278
|
+
nearestSnapsY.push(snap);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
// side gap, from the top
|
|
282
|
+
const [, startMinY, ,] = gap.startBounds;
|
|
283
|
+
const distanceToStartElementY = startMinY - maxY;
|
|
284
|
+
const sideOffsetTop = round(distanceToStartElementY - gap.length);
|
|
285
|
+
if (Math.abs(sideOffsetTop) <= minOffset.y) {
|
|
286
|
+
if (Math.abs(sideOffsetTop) < minOffset.y) {
|
|
287
|
+
nearestSnapsY.length = 0;
|
|
288
|
+
}
|
|
289
|
+
minOffset.y = Math.abs(sideOffsetTop);
|
|
290
|
+
const snap = {
|
|
291
|
+
type: "gap",
|
|
292
|
+
direction: "side_top",
|
|
293
|
+
gap,
|
|
294
|
+
offset: sideOffsetTop,
|
|
295
|
+
};
|
|
296
|
+
nearestSnapsY.push(snap);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
// side gap, from the bottom
|
|
300
|
+
const [, , , endMaxY] = gap.endBounds;
|
|
301
|
+
const distanceToEndElementY = round(minY - endMaxY);
|
|
302
|
+
const sideOffsetBottom = gap.length - distanceToEndElementY;
|
|
303
|
+
if (Math.abs(sideOffsetBottom) <= minOffset.y) {
|
|
304
|
+
if (Math.abs(sideOffsetBottom) < minOffset.y) {
|
|
305
|
+
nearestSnapsY.length = 0;
|
|
306
|
+
}
|
|
307
|
+
minOffset.y = Math.abs(sideOffsetBottom);
|
|
308
|
+
const snap = {
|
|
309
|
+
type: "gap",
|
|
310
|
+
direction: "side_bottom",
|
|
311
|
+
gap,
|
|
312
|
+
offset: sideOffsetBottom,
|
|
313
|
+
};
|
|
314
|
+
nearestSnapsY.push(snap);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
export const getReferenceSnapPoints = (elements, selectedElements, appState) => {
|
|
321
|
+
const referenceElements = getReferenceElements(elements, selectedElements, appState);
|
|
322
|
+
return getMaximumGroups(referenceElements)
|
|
323
|
+
.filter((elementsGroup) => !(elementsGroup.length === 1 && isBoundToContainer(elementsGroup[0])))
|
|
324
|
+
.flatMap((elementGroup) => getElementsCorners(elementGroup));
|
|
325
|
+
};
|
|
326
|
+
const getPointSnaps = (selectedElements, selectionSnapPoints, appState, event, nearestSnapsX, nearestSnapsY, minOffset) => {
|
|
327
|
+
if (!isSnappingEnabled({ appState, event, selectedElements }) ||
|
|
328
|
+
(selectedElements.length === 0 && selectionSnapPoints.length === 0)) {
|
|
329
|
+
return [];
|
|
330
|
+
}
|
|
331
|
+
const referenceSnapPoints = SnapCache.getReferenceSnapPoints();
|
|
332
|
+
if (referenceSnapPoints) {
|
|
333
|
+
for (const thisSnapPoint of selectionSnapPoints) {
|
|
334
|
+
for (const otherSnapPoint of referenceSnapPoints) {
|
|
335
|
+
const offsetX = otherSnapPoint[0] - thisSnapPoint[0];
|
|
336
|
+
const offsetY = otherSnapPoint[1] - thisSnapPoint[1];
|
|
337
|
+
if (Math.abs(offsetX) <= minOffset.x) {
|
|
338
|
+
if (Math.abs(offsetX) < minOffset.x) {
|
|
339
|
+
nearestSnapsX.length = 0;
|
|
340
|
+
}
|
|
341
|
+
nearestSnapsX.push({
|
|
342
|
+
type: "point",
|
|
343
|
+
points: [thisSnapPoint, otherSnapPoint],
|
|
344
|
+
offset: offsetX,
|
|
345
|
+
});
|
|
346
|
+
minOffset.x = Math.abs(offsetX);
|
|
347
|
+
}
|
|
348
|
+
if (Math.abs(offsetY) <= minOffset.y) {
|
|
349
|
+
if (Math.abs(offsetY) < minOffset.y) {
|
|
350
|
+
nearestSnapsY.length = 0;
|
|
351
|
+
}
|
|
352
|
+
nearestSnapsY.push({
|
|
353
|
+
type: "point",
|
|
354
|
+
points: [thisSnapPoint, otherSnapPoint],
|
|
355
|
+
offset: offsetY,
|
|
356
|
+
});
|
|
357
|
+
minOffset.y = Math.abs(offsetY);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
export const snapDraggedElements = (selectedElements, dragOffset, appState, event) => {
|
|
364
|
+
if (!isSnappingEnabled({ appState, event, selectedElements }) ||
|
|
365
|
+
selectedElements.length === 0) {
|
|
366
|
+
return {
|
|
367
|
+
snapOffset: {
|
|
368
|
+
x: 0,
|
|
369
|
+
y: 0,
|
|
370
|
+
},
|
|
371
|
+
snapLines: [],
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
dragOffset.x = round(dragOffset.x);
|
|
375
|
+
dragOffset.y = round(dragOffset.y);
|
|
376
|
+
const nearestSnapsX = [];
|
|
377
|
+
const nearestSnapsY = [];
|
|
378
|
+
const snapDistance = getSnapDistance(appState.zoom.value);
|
|
379
|
+
const minOffset = {
|
|
380
|
+
x: snapDistance,
|
|
381
|
+
y: snapDistance,
|
|
382
|
+
};
|
|
383
|
+
const selectionPoints = getElementsCorners(selectedElements, {
|
|
384
|
+
dragOffset,
|
|
385
|
+
});
|
|
386
|
+
// get the nearest horizontal and vertical point and gap snaps
|
|
387
|
+
getPointSnaps(selectedElements, selectionPoints, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
388
|
+
getGapSnaps(selectedElements, dragOffset, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
389
|
+
// using the nearest snaps to figure out how
|
|
390
|
+
// much the elements need to be offset to be snapped
|
|
391
|
+
// to some reference elements
|
|
392
|
+
const snapOffset = {
|
|
393
|
+
x: nearestSnapsX[0]?.offset ?? 0,
|
|
394
|
+
y: nearestSnapsY[0]?.offset ?? 0,
|
|
395
|
+
};
|
|
396
|
+
// once the elements are snapped
|
|
397
|
+
// and moved to the snapped position
|
|
398
|
+
// we want to use the element's snapped position
|
|
399
|
+
// to update nearest snaps so that we can create
|
|
400
|
+
// point and gap snap lines correctly without any shifting
|
|
401
|
+
minOffset.x = 0;
|
|
402
|
+
minOffset.y = 0;
|
|
403
|
+
nearestSnapsX.length = 0;
|
|
404
|
+
nearestSnapsY.length = 0;
|
|
405
|
+
const newDragOffset = {
|
|
406
|
+
x: round(dragOffset.x + snapOffset.x),
|
|
407
|
+
y: round(dragOffset.y + snapOffset.y),
|
|
408
|
+
};
|
|
409
|
+
getPointSnaps(selectedElements, getElementsCorners(selectedElements, {
|
|
410
|
+
dragOffset: newDragOffset,
|
|
411
|
+
}), appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
412
|
+
getGapSnaps(selectedElements, newDragOffset, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
413
|
+
const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);
|
|
414
|
+
const gapSnapLines = createGapSnapLines(selectedElements, newDragOffset, [...nearestSnapsX, ...nearestSnapsY].filter((snap) => snap.type === "gap"));
|
|
415
|
+
return {
|
|
416
|
+
snapOffset,
|
|
417
|
+
snapLines: [...pointSnapLines, ...gapSnapLines],
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
const round = (x) => {
|
|
421
|
+
const decimalPlaces = 6;
|
|
422
|
+
return Math.round(x * 10 ** decimalPlaces) / 10 ** decimalPlaces;
|
|
423
|
+
};
|
|
424
|
+
const dedupePoints = (points) => {
|
|
425
|
+
const map = new Map();
|
|
426
|
+
for (const point of points) {
|
|
427
|
+
const key = point.join(",");
|
|
428
|
+
if (!map.has(key)) {
|
|
429
|
+
map.set(key, point);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return Array.from(map.values());
|
|
433
|
+
};
|
|
434
|
+
const createPointSnapLines = (nearestSnapsX, nearestSnapsY) => {
|
|
435
|
+
const snapsX = {};
|
|
436
|
+
const snapsY = {};
|
|
437
|
+
if (nearestSnapsX.length > 0) {
|
|
438
|
+
for (const snap of nearestSnapsX) {
|
|
439
|
+
if (snap.type === "point") {
|
|
440
|
+
// key = thisPoint.x
|
|
441
|
+
const key = round(snap.points[0][0]);
|
|
442
|
+
if (!snapsX[key]) {
|
|
443
|
+
snapsX[key] = [];
|
|
444
|
+
}
|
|
445
|
+
snapsX[key].push(...snap.points.map((point) => [round(point[0]), round(point[1])]));
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (nearestSnapsY.length > 0) {
|
|
450
|
+
for (const snap of nearestSnapsY) {
|
|
451
|
+
if (snap.type === "point") {
|
|
452
|
+
// key = thisPoint.y
|
|
453
|
+
const key = round(snap.points[0][1]);
|
|
454
|
+
if (!snapsY[key]) {
|
|
455
|
+
snapsY[key] = [];
|
|
456
|
+
}
|
|
457
|
+
snapsY[key].push(...snap.points.map((point) => [round(point[0]), round(point[1])]));
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return Object.entries(snapsX)
|
|
462
|
+
.map(([key, points]) => {
|
|
463
|
+
return {
|
|
464
|
+
type: "points",
|
|
465
|
+
points: dedupePoints(points
|
|
466
|
+
.map((point) => {
|
|
467
|
+
return [Number(key), point[1]];
|
|
468
|
+
})
|
|
469
|
+
.sort((a, b) => a[1] - b[1])),
|
|
470
|
+
};
|
|
471
|
+
})
|
|
472
|
+
.concat(Object.entries(snapsY).map(([key, points]) => {
|
|
473
|
+
return {
|
|
474
|
+
type: "points",
|
|
475
|
+
points: dedupePoints(points
|
|
476
|
+
.map((point) => {
|
|
477
|
+
return [point[0], Number(key)];
|
|
478
|
+
})
|
|
479
|
+
.sort((a, b) => a[0] - b[0])),
|
|
480
|
+
};
|
|
481
|
+
}));
|
|
482
|
+
};
|
|
483
|
+
const dedupeGapSnapLines = (gapSnapLines) => {
|
|
484
|
+
const map = new Map();
|
|
485
|
+
for (const gapSnapLine of gapSnapLines) {
|
|
486
|
+
const key = gapSnapLine.points
|
|
487
|
+
.flat()
|
|
488
|
+
.map((point) => [round(point)])
|
|
489
|
+
.join(",");
|
|
490
|
+
if (!map.has(key)) {
|
|
491
|
+
map.set(key, gapSnapLine);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return Array.from(map.values());
|
|
495
|
+
};
|
|
496
|
+
const createGapSnapLines = (selectedElements, dragOffset, gapSnaps) => {
|
|
497
|
+
const [minX, minY, maxX, maxY] = getDraggedElementsBounds(selectedElements, dragOffset);
|
|
498
|
+
const gapSnapLines = [];
|
|
499
|
+
for (const gapSnap of gapSnaps) {
|
|
500
|
+
const [startMinX, startMinY, startMaxX, startMaxY] = gapSnap.gap.startBounds;
|
|
501
|
+
const [endMinX, endMinY, endMaxX, endMaxY] = gapSnap.gap.endBounds;
|
|
502
|
+
const verticalIntersection = rangeIntersection([minY, maxY], gapSnap.gap.overlap);
|
|
503
|
+
const horizontalGapIntersection = rangeIntersection([minX, maxX], gapSnap.gap.overlap);
|
|
504
|
+
switch (gapSnap.direction) {
|
|
505
|
+
case "center_horizontal": {
|
|
506
|
+
if (verticalIntersection) {
|
|
507
|
+
const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;
|
|
508
|
+
gapSnapLines.push({
|
|
509
|
+
type: "gap",
|
|
510
|
+
direction: "horizontal",
|
|
511
|
+
points: [
|
|
512
|
+
[gapSnap.gap.startSide[0][0], gapLineY],
|
|
513
|
+
[minX, gapLineY],
|
|
514
|
+
],
|
|
515
|
+
}, {
|
|
516
|
+
type: "gap",
|
|
517
|
+
direction: "horizontal",
|
|
518
|
+
points: [
|
|
519
|
+
[maxX, gapLineY],
|
|
520
|
+
[gapSnap.gap.endSide[0][0], gapLineY],
|
|
521
|
+
],
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
case "center_vertical": {
|
|
527
|
+
if (horizontalGapIntersection) {
|
|
528
|
+
const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;
|
|
529
|
+
gapSnapLines.push({
|
|
530
|
+
type: "gap",
|
|
531
|
+
direction: "vertical",
|
|
532
|
+
points: [
|
|
533
|
+
[gapLineX, gapSnap.gap.startSide[0][1]],
|
|
534
|
+
[gapLineX, minY],
|
|
535
|
+
],
|
|
536
|
+
}, {
|
|
537
|
+
type: "gap",
|
|
538
|
+
direction: "vertical",
|
|
539
|
+
points: [
|
|
540
|
+
[gapLineX, maxY],
|
|
541
|
+
[gapLineX, gapSnap.gap.endSide[0][1]],
|
|
542
|
+
],
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
case "side_right": {
|
|
548
|
+
if (verticalIntersection) {
|
|
549
|
+
const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;
|
|
550
|
+
gapSnapLines.push({
|
|
551
|
+
type: "gap",
|
|
552
|
+
direction: "horizontal",
|
|
553
|
+
points: [
|
|
554
|
+
[startMaxX, gapLineY],
|
|
555
|
+
[endMinX, gapLineY],
|
|
556
|
+
],
|
|
557
|
+
}, {
|
|
558
|
+
type: "gap",
|
|
559
|
+
direction: "horizontal",
|
|
560
|
+
points: [
|
|
561
|
+
[endMaxX, gapLineY],
|
|
562
|
+
[minX, gapLineY],
|
|
563
|
+
],
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
case "side_left": {
|
|
569
|
+
if (verticalIntersection) {
|
|
570
|
+
const gapLineY = (verticalIntersection[0] + verticalIntersection[1]) / 2;
|
|
571
|
+
gapSnapLines.push({
|
|
572
|
+
type: "gap",
|
|
573
|
+
direction: "horizontal",
|
|
574
|
+
points: [
|
|
575
|
+
[maxX, gapLineY],
|
|
576
|
+
[startMinX, gapLineY],
|
|
577
|
+
],
|
|
578
|
+
}, {
|
|
579
|
+
type: "gap",
|
|
580
|
+
direction: "horizontal",
|
|
581
|
+
points: [
|
|
582
|
+
[startMaxX, gapLineY],
|
|
583
|
+
[endMinX, gapLineY],
|
|
584
|
+
],
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
case "side_top": {
|
|
590
|
+
if (horizontalGapIntersection) {
|
|
591
|
+
const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;
|
|
592
|
+
gapSnapLines.push({
|
|
593
|
+
type: "gap",
|
|
594
|
+
direction: "vertical",
|
|
595
|
+
points: [
|
|
596
|
+
[gapLineX, maxY],
|
|
597
|
+
[gapLineX, startMinY],
|
|
598
|
+
],
|
|
599
|
+
}, {
|
|
600
|
+
type: "gap",
|
|
601
|
+
direction: "vertical",
|
|
602
|
+
points: [
|
|
603
|
+
[gapLineX, startMaxY],
|
|
604
|
+
[gapLineX, endMinY],
|
|
605
|
+
],
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
case "side_bottom": {
|
|
611
|
+
if (horizontalGapIntersection) {
|
|
612
|
+
const gapLineX = (horizontalGapIntersection[0] + horizontalGapIntersection[1]) / 2;
|
|
613
|
+
gapSnapLines.push({
|
|
614
|
+
type: "gap",
|
|
615
|
+
direction: "vertical",
|
|
616
|
+
points: [
|
|
617
|
+
[gapLineX, startMaxY],
|
|
618
|
+
[gapLineX, endMinY],
|
|
619
|
+
],
|
|
620
|
+
}, {
|
|
621
|
+
type: "gap",
|
|
622
|
+
direction: "vertical",
|
|
623
|
+
points: [
|
|
624
|
+
[gapLineX, endMaxY],
|
|
625
|
+
[gapLineX, minY],
|
|
626
|
+
],
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return dedupeGapSnapLines(gapSnapLines.map((gapSnapLine) => {
|
|
634
|
+
return {
|
|
635
|
+
...gapSnapLine,
|
|
636
|
+
points: gapSnapLine.points.map((point) => [round(point[0]), round(point[1])]),
|
|
637
|
+
};
|
|
638
|
+
}));
|
|
639
|
+
};
|
|
640
|
+
export const snapResizingElements = (
|
|
641
|
+
// use the latest elements to create snap lines
|
|
642
|
+
selectedElements,
|
|
643
|
+
// while using the original elements to appy dragOffset to calculate snaps
|
|
644
|
+
selectedOriginalElements, appState, event, dragOffset, transformHandle) => {
|
|
645
|
+
if (!isSnappingEnabled({ event, selectedElements, appState }) ||
|
|
646
|
+
selectedElements.length === 0 ||
|
|
647
|
+
(selectedElements.length === 1 &&
|
|
648
|
+
!areRoughlyEqual(selectedElements[0].angle, 0))) {
|
|
649
|
+
return {
|
|
650
|
+
snapOffset: { x: 0, y: 0 },
|
|
651
|
+
snapLines: [],
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
let [minX, minY, maxX, maxY] = getCommonBounds(selectedOriginalElements);
|
|
655
|
+
if (transformHandle) {
|
|
656
|
+
if (transformHandle.includes("e")) {
|
|
657
|
+
maxX += dragOffset.x;
|
|
658
|
+
}
|
|
659
|
+
else if (transformHandle.includes("w")) {
|
|
660
|
+
minX += dragOffset.x;
|
|
661
|
+
}
|
|
662
|
+
if (transformHandle.includes("n")) {
|
|
663
|
+
minY += dragOffset.y;
|
|
664
|
+
}
|
|
665
|
+
else if (transformHandle.includes("s")) {
|
|
666
|
+
maxY += dragOffset.y;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const selectionSnapPoints = [];
|
|
670
|
+
if (transformHandle) {
|
|
671
|
+
switch (transformHandle) {
|
|
672
|
+
case "e": {
|
|
673
|
+
selectionSnapPoints.push([maxX, minY], [maxX, maxY]);
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
case "w": {
|
|
677
|
+
selectionSnapPoints.push([minX, minY], [minX, maxY]);
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
case "n": {
|
|
681
|
+
selectionSnapPoints.push([minX, minY], [maxX, minY]);
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
case "s": {
|
|
685
|
+
selectionSnapPoints.push([minX, maxY], [maxX, maxY]);
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case "ne": {
|
|
689
|
+
selectionSnapPoints.push([maxX, minY]);
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
case "nw": {
|
|
693
|
+
selectionSnapPoints.push([minX, minY]);
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
case "se": {
|
|
697
|
+
selectionSnapPoints.push([maxX, maxY]);
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
case "sw": {
|
|
701
|
+
selectionSnapPoints.push([minX, maxY]);
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
const snapDistance = getSnapDistance(appState.zoom.value);
|
|
707
|
+
const minOffset = {
|
|
708
|
+
x: snapDistance,
|
|
709
|
+
y: snapDistance,
|
|
710
|
+
};
|
|
711
|
+
const nearestSnapsX = [];
|
|
712
|
+
const nearestSnapsY = [];
|
|
713
|
+
getPointSnaps(selectedOriginalElements, selectionSnapPoints, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
714
|
+
const snapOffset = {
|
|
715
|
+
x: nearestSnapsX[0]?.offset ?? 0,
|
|
716
|
+
y: nearestSnapsY[0]?.offset ?? 0,
|
|
717
|
+
};
|
|
718
|
+
// again, once snap offset is calculated
|
|
719
|
+
// reset to recompute for creating snap lines to be rendered
|
|
720
|
+
minOffset.x = 0;
|
|
721
|
+
minOffset.y = 0;
|
|
722
|
+
nearestSnapsX.length = 0;
|
|
723
|
+
nearestSnapsY.length = 0;
|
|
724
|
+
const [x1, y1, x2, y2] = getCommonBounds(selectedElements).map((bound) => round(bound));
|
|
725
|
+
const corners = [
|
|
726
|
+
[x1, y1],
|
|
727
|
+
[x1, y2],
|
|
728
|
+
[x2, y1],
|
|
729
|
+
[x2, y2],
|
|
730
|
+
];
|
|
731
|
+
getPointSnaps(selectedElements, corners, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
732
|
+
const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);
|
|
733
|
+
return {
|
|
734
|
+
snapOffset,
|
|
735
|
+
snapLines: pointSnapLines,
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
export const snapNewElement = (draggingElement, appState, event, origin, dragOffset) => {
|
|
739
|
+
if (!isSnappingEnabled({ event, selectedElements: [draggingElement], appState })) {
|
|
740
|
+
return {
|
|
741
|
+
snapOffset: { x: 0, y: 0 },
|
|
742
|
+
snapLines: [],
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
const selectionSnapPoints = [
|
|
746
|
+
[origin.x + dragOffset.x, origin.y + dragOffset.y],
|
|
747
|
+
];
|
|
748
|
+
const snapDistance = getSnapDistance(appState.zoom.value);
|
|
749
|
+
const minOffset = {
|
|
750
|
+
x: snapDistance,
|
|
751
|
+
y: snapDistance,
|
|
752
|
+
};
|
|
753
|
+
const nearestSnapsX = [];
|
|
754
|
+
const nearestSnapsY = [];
|
|
755
|
+
getPointSnaps([draggingElement], selectionSnapPoints, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
756
|
+
const snapOffset = {
|
|
757
|
+
x: nearestSnapsX[0]?.offset ?? 0,
|
|
758
|
+
y: nearestSnapsY[0]?.offset ?? 0,
|
|
759
|
+
};
|
|
760
|
+
minOffset.x = 0;
|
|
761
|
+
minOffset.y = 0;
|
|
762
|
+
nearestSnapsX.length = 0;
|
|
763
|
+
nearestSnapsY.length = 0;
|
|
764
|
+
const corners = getElementsCorners([draggingElement], {
|
|
765
|
+
boundingBoxCorners: true,
|
|
766
|
+
omitCenter: true,
|
|
767
|
+
});
|
|
768
|
+
getPointSnaps([draggingElement], corners, appState, event, nearestSnapsX, nearestSnapsY, minOffset);
|
|
769
|
+
const pointSnapLines = createPointSnapLines(nearestSnapsX, nearestSnapsY);
|
|
770
|
+
return {
|
|
771
|
+
snapOffset,
|
|
772
|
+
snapLines: pointSnapLines,
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
export const getSnapLinesAtPointer = (elements, appState, pointer, event) => {
|
|
776
|
+
if (!isSnappingEnabled({ event, selectedElements: [], appState })) {
|
|
777
|
+
return {
|
|
778
|
+
originOffset: { x: 0, y: 0 },
|
|
779
|
+
snapLines: [],
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
const referenceElements = getVisibleAndNonSelectedElements(elements, [], appState);
|
|
783
|
+
const snapDistance = getSnapDistance(appState.zoom.value);
|
|
784
|
+
const minOffset = {
|
|
785
|
+
x: snapDistance,
|
|
786
|
+
y: snapDistance,
|
|
787
|
+
};
|
|
788
|
+
const horizontalSnapLines = [];
|
|
789
|
+
const verticalSnapLines = [];
|
|
790
|
+
for (const referenceElement of referenceElements) {
|
|
791
|
+
const corners = getElementsCorners([referenceElement]);
|
|
792
|
+
for (const corner of corners) {
|
|
793
|
+
const offsetX = corner[0] - pointer.x;
|
|
794
|
+
if (Math.abs(offsetX) <= Math.abs(minOffset.x)) {
|
|
795
|
+
if (Math.abs(offsetX) < Math.abs(minOffset.x)) {
|
|
796
|
+
verticalSnapLines.length = 0;
|
|
797
|
+
}
|
|
798
|
+
verticalSnapLines.push({
|
|
799
|
+
type: "pointer",
|
|
800
|
+
points: [corner, [corner[0], pointer.y]],
|
|
801
|
+
direction: "vertical",
|
|
802
|
+
});
|
|
803
|
+
minOffset.x = offsetX;
|
|
804
|
+
}
|
|
805
|
+
const offsetY = corner[1] - pointer.y;
|
|
806
|
+
if (Math.abs(offsetY) <= Math.abs(minOffset.y)) {
|
|
807
|
+
if (Math.abs(offsetY) < Math.abs(minOffset.y)) {
|
|
808
|
+
horizontalSnapLines.length = 0;
|
|
809
|
+
}
|
|
810
|
+
horizontalSnapLines.push({
|
|
811
|
+
type: "pointer",
|
|
812
|
+
points: [corner, [pointer.x, corner[1]]],
|
|
813
|
+
direction: "horizontal",
|
|
814
|
+
});
|
|
815
|
+
minOffset.y = offsetY;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
originOffset: {
|
|
821
|
+
x: verticalSnapLines.length > 0
|
|
822
|
+
? verticalSnapLines[0].points[0][0] - pointer.x
|
|
823
|
+
: 0,
|
|
824
|
+
y: horizontalSnapLines.length > 0
|
|
825
|
+
? horizontalSnapLines[0].points[0][1] - pointer.y
|
|
826
|
+
: 0,
|
|
827
|
+
},
|
|
828
|
+
snapLines: [...verticalSnapLines, ...horizontalSnapLines],
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
export const isActiveToolNonLinearSnappable = (activeToolType) => {
|
|
832
|
+
return (activeToolType === TOOL_TYPE.rectangle ||
|
|
833
|
+
activeToolType === TOOL_TYPE.ellipse ||
|
|
834
|
+
activeToolType === TOOL_TYPE.diamond ||
|
|
835
|
+
activeToolType === TOOL_TYPE.frame ||
|
|
836
|
+
activeToolType === TOOL_TYPE.magicframe ||
|
|
837
|
+
activeToolType === TOOL_TYPE.image);
|
|
838
|
+
};
|