@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,867 @@
|
|
|
1
|
+
import { distance2d, rotate, isPathALoop, getGridPoint, rotatePoint, centerPoint, getControlPointsForBezierCurve, getBezierXY, getBezierCurveLength, mapIntervalToBezierT, arePointsEqual, } from "../math";
|
|
2
|
+
import { getElementAbsoluteCoords, getLockedLinearCursorAlignSize } from ".";
|
|
3
|
+
import { getCurvePathOps, getElementPointsCoords, getMinMaxXYFromCurvePathOps, } from "./bounds";
|
|
4
|
+
import { mutateElement } from "./mutateElement";
|
|
5
|
+
import Scene from "../scene/Scene";
|
|
6
|
+
import { bindOrUnbindLinearElement, getHoveredElementForBinding, isBindingEnabled, } from "./binding";
|
|
7
|
+
import { tupleToCoors } from "../utils";
|
|
8
|
+
import { isBindingElement } from "./typeChecks";
|
|
9
|
+
import { KEYS, shouldRotateWithDiscreteAngle } from "../keys";
|
|
10
|
+
import { getBoundTextElement, handleBindTextResize } from "./textElement";
|
|
11
|
+
import { DRAGGING_THRESHOLD } from "../constants";
|
|
12
|
+
import { ShapeCache } from "../scene/ShapeCache";
|
|
13
|
+
const editorMidPointsCache = { version: null, points: [], zoom: null };
|
|
14
|
+
export class LinearElementEditor {
|
|
15
|
+
elementId;
|
|
16
|
+
/** indices */
|
|
17
|
+
selectedPointsIndices;
|
|
18
|
+
pointerDownState;
|
|
19
|
+
/** whether you're dragging a point */
|
|
20
|
+
isDragging;
|
|
21
|
+
lastUncommittedPoint;
|
|
22
|
+
pointerOffset;
|
|
23
|
+
startBindingElement;
|
|
24
|
+
endBindingElement;
|
|
25
|
+
hoverPointIndex;
|
|
26
|
+
segmentMidPointHoveredCoords;
|
|
27
|
+
constructor(element, scene) {
|
|
28
|
+
this.elementId = element.id;
|
|
29
|
+
Scene.mapElementToScene(this.elementId, scene);
|
|
30
|
+
LinearElementEditor.normalizePoints(element);
|
|
31
|
+
this.selectedPointsIndices = null;
|
|
32
|
+
this.lastUncommittedPoint = null;
|
|
33
|
+
this.isDragging = false;
|
|
34
|
+
this.pointerOffset = { x: 0, y: 0 };
|
|
35
|
+
this.startBindingElement = "keep";
|
|
36
|
+
this.endBindingElement = "keep";
|
|
37
|
+
this.pointerDownState = {
|
|
38
|
+
prevSelectedPointsIndices: null,
|
|
39
|
+
lastClickedPoint: -1,
|
|
40
|
+
origin: null,
|
|
41
|
+
segmentMidpoint: {
|
|
42
|
+
value: null,
|
|
43
|
+
index: null,
|
|
44
|
+
added: false,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
this.hoverPointIndex = -1;
|
|
48
|
+
this.segmentMidPointHoveredCoords = null;
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// static methods
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
static POINT_HANDLE_SIZE = 10;
|
|
54
|
+
/**
|
|
55
|
+
* @param id the `elementId` from the instance of this class (so that we can
|
|
56
|
+
* statically guarantee this method returns an ExcalidrawLinearElement)
|
|
57
|
+
*/
|
|
58
|
+
static getElement(id) {
|
|
59
|
+
const element = Scene.getScene(id)?.getNonDeletedElement(id);
|
|
60
|
+
if (element) {
|
|
61
|
+
return element;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
static handleBoxSelection(event, appState, setState) {
|
|
66
|
+
if (!appState.editingLinearElement ||
|
|
67
|
+
appState.draggingElement?.type !== "selection") {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const { editingLinearElement } = appState;
|
|
71
|
+
const { selectedPointsIndices, elementId } = editingLinearElement;
|
|
72
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
73
|
+
if (!element) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const [selectionX1, selectionY1, selectionX2, selectionY2] = getElementAbsoluteCoords(appState.draggingElement);
|
|
77
|
+
const pointsSceneCoords = LinearElementEditor.getPointsGlobalCoordinates(element);
|
|
78
|
+
const nextSelectedPoints = pointsSceneCoords.reduce((acc, point, index) => {
|
|
79
|
+
if ((point[0] >= selectionX1 &&
|
|
80
|
+
point[0] <= selectionX2 &&
|
|
81
|
+
point[1] >= selectionY1 &&
|
|
82
|
+
point[1] <= selectionY2) ||
|
|
83
|
+
(event.shiftKey && selectedPointsIndices?.includes(index))) {
|
|
84
|
+
acc.push(index);
|
|
85
|
+
}
|
|
86
|
+
return acc;
|
|
87
|
+
}, []);
|
|
88
|
+
setState({
|
|
89
|
+
editingLinearElement: {
|
|
90
|
+
...editingLinearElement,
|
|
91
|
+
selectedPointsIndices: nextSelectedPoints.length
|
|
92
|
+
? nextSelectedPoints
|
|
93
|
+
: null,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** @returns whether point was dragged */
|
|
98
|
+
static handlePointDragging(event, appState, scenePointerX, scenePointerY, maybeSuggestBinding, linearElementEditor) {
|
|
99
|
+
if (!linearElementEditor) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const { selectedPointsIndices, elementId } = linearElementEditor;
|
|
103
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
104
|
+
if (!element) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
// point that's being dragged (out of all selected points)
|
|
108
|
+
const draggingPoint = element.points[linearElementEditor.pointerDownState.lastClickedPoint];
|
|
109
|
+
if (selectedPointsIndices && draggingPoint) {
|
|
110
|
+
if (shouldRotateWithDiscreteAngle(event) &&
|
|
111
|
+
selectedPointsIndices.length === 1 &&
|
|
112
|
+
element.points.length > 1) {
|
|
113
|
+
const selectedIndex = selectedPointsIndices[0];
|
|
114
|
+
const referencePoint = element.points[selectedIndex === 0 ? 1 : selectedIndex - 1];
|
|
115
|
+
const [width, height] = LinearElementEditor._getShiftLockedDelta(element, referencePoint, [scenePointerX, scenePointerY], event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize);
|
|
116
|
+
LinearElementEditor.movePoints(element, [
|
|
117
|
+
{
|
|
118
|
+
index: selectedIndex,
|
|
119
|
+
point: [width + referencePoint[0], height + referencePoint[1]],
|
|
120
|
+
isDragging: selectedIndex ===
|
|
121
|
+
linearElementEditor.pointerDownState.lastClickedPoint,
|
|
122
|
+
},
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const newDraggingPointPosition = LinearElementEditor.createPointAt(element, scenePointerX - linearElementEditor.pointerOffset.x, scenePointerY - linearElementEditor.pointerOffset.y, event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize);
|
|
127
|
+
const deltaX = newDraggingPointPosition[0] - draggingPoint[0];
|
|
128
|
+
const deltaY = newDraggingPointPosition[1] - draggingPoint[1];
|
|
129
|
+
LinearElementEditor.movePoints(element, selectedPointsIndices.map((pointIndex) => {
|
|
130
|
+
const newPointPosition = pointIndex ===
|
|
131
|
+
linearElementEditor.pointerDownState.lastClickedPoint
|
|
132
|
+
? LinearElementEditor.createPointAt(element, scenePointerX - linearElementEditor.pointerOffset.x, scenePointerY - linearElementEditor.pointerOffset.y, event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize)
|
|
133
|
+
: [
|
|
134
|
+
element.points[pointIndex][0] + deltaX,
|
|
135
|
+
element.points[pointIndex][1] + deltaY,
|
|
136
|
+
];
|
|
137
|
+
return {
|
|
138
|
+
index: pointIndex,
|
|
139
|
+
point: newPointPosition,
|
|
140
|
+
isDragging: pointIndex ===
|
|
141
|
+
linearElementEditor.pointerDownState.lastClickedPoint,
|
|
142
|
+
};
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
const boundTextElement = getBoundTextElement(element);
|
|
146
|
+
if (boundTextElement) {
|
|
147
|
+
handleBindTextResize(element, false);
|
|
148
|
+
}
|
|
149
|
+
// suggest bindings for first and last point if selected
|
|
150
|
+
if (isBindingElement(element, false)) {
|
|
151
|
+
const coords = [];
|
|
152
|
+
const firstSelectedIndex = selectedPointsIndices[0];
|
|
153
|
+
if (firstSelectedIndex === 0) {
|
|
154
|
+
coords.push(tupleToCoors(LinearElementEditor.getPointGlobalCoordinates(element, element.points[0])));
|
|
155
|
+
}
|
|
156
|
+
const lastSelectedIndex = selectedPointsIndices[selectedPointsIndices.length - 1];
|
|
157
|
+
if (lastSelectedIndex === element.points.length - 1) {
|
|
158
|
+
coords.push(tupleToCoors(LinearElementEditor.getPointGlobalCoordinates(element, element.points[lastSelectedIndex])));
|
|
159
|
+
}
|
|
160
|
+
if (coords.length) {
|
|
161
|
+
maybeSuggestBinding(element, coords);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
static handlePointerUp(event, editingLinearElement, appState) {
|
|
169
|
+
const { elementId, selectedPointsIndices, isDragging, pointerDownState } = editingLinearElement;
|
|
170
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
171
|
+
if (!element) {
|
|
172
|
+
return editingLinearElement;
|
|
173
|
+
}
|
|
174
|
+
const bindings = {};
|
|
175
|
+
if (isDragging && selectedPointsIndices) {
|
|
176
|
+
for (const selectedPoint of selectedPointsIndices) {
|
|
177
|
+
if (selectedPoint === 0 ||
|
|
178
|
+
selectedPoint === element.points.length - 1) {
|
|
179
|
+
if (isPathALoop(element.points, appState.zoom.value)) {
|
|
180
|
+
LinearElementEditor.movePoints(element, [
|
|
181
|
+
{
|
|
182
|
+
index: selectedPoint,
|
|
183
|
+
point: selectedPoint === 0
|
|
184
|
+
? element.points[element.points.length - 1]
|
|
185
|
+
: element.points[0],
|
|
186
|
+
},
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
const bindingElement = isBindingEnabled(appState)
|
|
190
|
+
? getHoveredElementForBinding(tupleToCoors(LinearElementEditor.getPointAtIndexGlobalCoordinates(element, selectedPoint)), Scene.getScene(element))
|
|
191
|
+
: null;
|
|
192
|
+
bindings[selectedPoint === 0 ? "startBindingElement" : "endBindingElement"] = bindingElement;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
...editingLinearElement,
|
|
198
|
+
...bindings,
|
|
199
|
+
// if clicking without previously dragging a point(s), and not holding
|
|
200
|
+
// shift, deselect all points except the one clicked. If holding shift,
|
|
201
|
+
// toggle the point.
|
|
202
|
+
selectedPointsIndices: isDragging || event.shiftKey
|
|
203
|
+
? !isDragging &&
|
|
204
|
+
event.shiftKey &&
|
|
205
|
+
pointerDownState.prevSelectedPointsIndices?.includes(pointerDownState.lastClickedPoint)
|
|
206
|
+
? selectedPointsIndices &&
|
|
207
|
+
selectedPointsIndices.filter((pointIndex) => pointIndex !== pointerDownState.lastClickedPoint)
|
|
208
|
+
: selectedPointsIndices
|
|
209
|
+
: selectedPointsIndices?.includes(pointerDownState.lastClickedPoint)
|
|
210
|
+
? [pointerDownState.lastClickedPoint]
|
|
211
|
+
: selectedPointsIndices,
|
|
212
|
+
isDragging: false,
|
|
213
|
+
pointerOffset: { x: 0, y: 0 },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
static getEditorMidPoints = (element, appState) => {
|
|
217
|
+
const boundText = getBoundTextElement(element);
|
|
218
|
+
// Since its not needed outside editor unless 2 pointer lines or bound text
|
|
219
|
+
if (!appState.editingLinearElement &&
|
|
220
|
+
element.points.length > 2 &&
|
|
221
|
+
!boundText) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
if (editorMidPointsCache.version === element.version &&
|
|
225
|
+
editorMidPointsCache.zoom === appState.zoom.value) {
|
|
226
|
+
return editorMidPointsCache.points;
|
|
227
|
+
}
|
|
228
|
+
LinearElementEditor.updateEditorMidPointsCache(element, appState);
|
|
229
|
+
return editorMidPointsCache.points;
|
|
230
|
+
};
|
|
231
|
+
static updateEditorMidPointsCache = (element, appState) => {
|
|
232
|
+
const points = LinearElementEditor.getPointsGlobalCoordinates(element);
|
|
233
|
+
let index = 0;
|
|
234
|
+
const midpoints = [];
|
|
235
|
+
while (index < points.length - 1) {
|
|
236
|
+
if (LinearElementEditor.isSegmentTooShort(element, element.points[index], element.points[index + 1], appState.zoom)) {
|
|
237
|
+
midpoints.push(null);
|
|
238
|
+
index++;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const segmentMidPoint = LinearElementEditor.getSegmentMidPoint(element, points[index], points[index + 1], index + 1);
|
|
242
|
+
midpoints.push(segmentMidPoint);
|
|
243
|
+
index++;
|
|
244
|
+
}
|
|
245
|
+
editorMidPointsCache.points = midpoints;
|
|
246
|
+
editorMidPointsCache.version = element.version;
|
|
247
|
+
editorMidPointsCache.zoom = appState.zoom.value;
|
|
248
|
+
};
|
|
249
|
+
static getSegmentMidpointHitCoords = (linearElementEditor, scenePointer, appState) => {
|
|
250
|
+
const { elementId } = linearElementEditor;
|
|
251
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
252
|
+
if (!element) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(element, appState.zoom, scenePointer.x, scenePointer.y);
|
|
256
|
+
if (clickedPointIndex >= 0) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const points = LinearElementEditor.getPointsGlobalCoordinates(element);
|
|
260
|
+
if (points.length >= 3 && !appState.editingLinearElement) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
const threshold = LinearElementEditor.POINT_HANDLE_SIZE / appState.zoom.value;
|
|
264
|
+
const existingSegmentMidpointHitCoords = linearElementEditor.segmentMidPointHoveredCoords;
|
|
265
|
+
if (existingSegmentMidpointHitCoords) {
|
|
266
|
+
const distance = distance2d(existingSegmentMidpointHitCoords[0], existingSegmentMidpointHitCoords[1], scenePointer.x, scenePointer.y);
|
|
267
|
+
if (distance <= threshold) {
|
|
268
|
+
return existingSegmentMidpointHitCoords;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
let index = 0;
|
|
272
|
+
const midPoints = LinearElementEditor.getEditorMidPoints(element, appState);
|
|
273
|
+
while (index < midPoints.length) {
|
|
274
|
+
if (midPoints[index] !== null) {
|
|
275
|
+
const distance = distance2d(midPoints[index][0], midPoints[index][1], scenePointer.x, scenePointer.y);
|
|
276
|
+
if (distance <= threshold) {
|
|
277
|
+
return midPoints[index];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
index++;
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
};
|
|
284
|
+
static isSegmentTooShort(element, startPoint, endPoint, zoom) {
|
|
285
|
+
let distance = distance2d(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
286
|
+
if (element.points.length > 2 && element.roundness) {
|
|
287
|
+
distance = getBezierCurveLength(element, endPoint);
|
|
288
|
+
}
|
|
289
|
+
return distance * zoom.value < LinearElementEditor.POINT_HANDLE_SIZE * 4;
|
|
290
|
+
}
|
|
291
|
+
static getSegmentMidPoint(element, startPoint, endPoint, endPointIndex) {
|
|
292
|
+
let segmentMidPoint = centerPoint(startPoint, endPoint);
|
|
293
|
+
if (element.points.length > 2 && element.roundness) {
|
|
294
|
+
const controlPoints = getControlPointsForBezierCurve(element, element.points[endPointIndex]);
|
|
295
|
+
if (controlPoints) {
|
|
296
|
+
const t = mapIntervalToBezierT(element, element.points[endPointIndex], 0.5);
|
|
297
|
+
const [tx, ty] = getBezierXY(controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3], t);
|
|
298
|
+
segmentMidPoint = LinearElementEditor.getPointGlobalCoordinates(element, [tx, ty]);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return segmentMidPoint;
|
|
302
|
+
}
|
|
303
|
+
static getSegmentMidPointIndex(linearElementEditor, appState, midPoint) {
|
|
304
|
+
const element = LinearElementEditor.getElement(linearElementEditor.elementId);
|
|
305
|
+
if (!element) {
|
|
306
|
+
return -1;
|
|
307
|
+
}
|
|
308
|
+
const midPoints = LinearElementEditor.getEditorMidPoints(element, appState);
|
|
309
|
+
let index = 0;
|
|
310
|
+
while (index < midPoints.length) {
|
|
311
|
+
if (LinearElementEditor.arePointsEqual(midPoint, midPoints[index])) {
|
|
312
|
+
return index + 1;
|
|
313
|
+
}
|
|
314
|
+
index++;
|
|
315
|
+
}
|
|
316
|
+
return -1;
|
|
317
|
+
}
|
|
318
|
+
static handlePointerDown(event, appState, history, scenePointer, linearElementEditor) {
|
|
319
|
+
const ret = {
|
|
320
|
+
didAddPoint: false,
|
|
321
|
+
hitElement: null,
|
|
322
|
+
linearElementEditor: null,
|
|
323
|
+
};
|
|
324
|
+
if (!linearElementEditor) {
|
|
325
|
+
return ret;
|
|
326
|
+
}
|
|
327
|
+
const { elementId } = linearElementEditor;
|
|
328
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
329
|
+
if (!element) {
|
|
330
|
+
return ret;
|
|
331
|
+
}
|
|
332
|
+
const segmentMidpoint = LinearElementEditor.getSegmentMidpointHitCoords(linearElementEditor, scenePointer, appState);
|
|
333
|
+
let segmentMidpointIndex = null;
|
|
334
|
+
if (segmentMidpoint) {
|
|
335
|
+
segmentMidpointIndex = LinearElementEditor.getSegmentMidPointIndex(linearElementEditor, appState, segmentMidpoint);
|
|
336
|
+
}
|
|
337
|
+
if (event.altKey && appState.editingLinearElement) {
|
|
338
|
+
if (linearElementEditor.lastUncommittedPoint == null) {
|
|
339
|
+
mutateElement(element, {
|
|
340
|
+
points: [
|
|
341
|
+
...element.points,
|
|
342
|
+
LinearElementEditor.createPointAt(element, scenePointer.x, scenePointer.y, event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize),
|
|
343
|
+
],
|
|
344
|
+
});
|
|
345
|
+
ret.didAddPoint = true;
|
|
346
|
+
}
|
|
347
|
+
history.resumeRecording();
|
|
348
|
+
ret.linearElementEditor = {
|
|
349
|
+
...linearElementEditor,
|
|
350
|
+
pointerDownState: {
|
|
351
|
+
prevSelectedPointsIndices: linearElementEditor.selectedPointsIndices,
|
|
352
|
+
lastClickedPoint: -1,
|
|
353
|
+
origin: { x: scenePointer.x, y: scenePointer.y },
|
|
354
|
+
segmentMidpoint: {
|
|
355
|
+
value: segmentMidpoint,
|
|
356
|
+
index: segmentMidpointIndex,
|
|
357
|
+
added: false,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
selectedPointsIndices: [element.points.length - 1],
|
|
361
|
+
lastUncommittedPoint: null,
|
|
362
|
+
endBindingElement: getHoveredElementForBinding(scenePointer, Scene.getScene(element)),
|
|
363
|
+
};
|
|
364
|
+
ret.didAddPoint = true;
|
|
365
|
+
return ret;
|
|
366
|
+
}
|
|
367
|
+
const clickedPointIndex = LinearElementEditor.getPointIndexUnderCursor(element, appState.zoom, scenePointer.x, scenePointer.y);
|
|
368
|
+
// if we clicked on a point, set the element as hitElement otherwise
|
|
369
|
+
// it would get deselected if the point is outside the hitbox area
|
|
370
|
+
if (clickedPointIndex >= 0 || segmentMidpoint) {
|
|
371
|
+
ret.hitElement = element;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
// You might be wandering why we are storing the binding elements on
|
|
375
|
+
// LinearElementEditor and passing them in, instead of calculating them
|
|
376
|
+
// from the end points of the `linearElement` - this is to allow disabling
|
|
377
|
+
// binding (which needs to happen at the point the user finishes moving
|
|
378
|
+
// the point).
|
|
379
|
+
const { startBindingElement, endBindingElement } = linearElementEditor;
|
|
380
|
+
if (isBindingEnabled(appState) && isBindingElement(element)) {
|
|
381
|
+
bindOrUnbindLinearElement(element, startBindingElement, endBindingElement);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
385
|
+
const cx = (x1 + x2) / 2;
|
|
386
|
+
const cy = (y1 + y2) / 2;
|
|
387
|
+
const targetPoint = clickedPointIndex > -1 &&
|
|
388
|
+
rotate(element.x + element.points[clickedPointIndex][0], element.y + element.points[clickedPointIndex][1], cx, cy, element.angle);
|
|
389
|
+
const nextSelectedPointsIndices = clickedPointIndex > -1 || event.shiftKey
|
|
390
|
+
? event.shiftKey ||
|
|
391
|
+
linearElementEditor.selectedPointsIndices?.includes(clickedPointIndex)
|
|
392
|
+
? normalizeSelectedPoints([
|
|
393
|
+
...(linearElementEditor.selectedPointsIndices || []),
|
|
394
|
+
clickedPointIndex,
|
|
395
|
+
])
|
|
396
|
+
: [clickedPointIndex]
|
|
397
|
+
: null;
|
|
398
|
+
ret.linearElementEditor = {
|
|
399
|
+
...linearElementEditor,
|
|
400
|
+
pointerDownState: {
|
|
401
|
+
prevSelectedPointsIndices: linearElementEditor.selectedPointsIndices,
|
|
402
|
+
lastClickedPoint: clickedPointIndex,
|
|
403
|
+
origin: { x: scenePointer.x, y: scenePointer.y },
|
|
404
|
+
segmentMidpoint: {
|
|
405
|
+
value: segmentMidpoint,
|
|
406
|
+
index: segmentMidpointIndex,
|
|
407
|
+
added: false,
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
selectedPointsIndices: nextSelectedPointsIndices,
|
|
411
|
+
pointerOffset: targetPoint
|
|
412
|
+
? {
|
|
413
|
+
x: scenePointer.x - targetPoint[0],
|
|
414
|
+
y: scenePointer.y - targetPoint[1],
|
|
415
|
+
}
|
|
416
|
+
: { x: 0, y: 0 },
|
|
417
|
+
};
|
|
418
|
+
return ret;
|
|
419
|
+
}
|
|
420
|
+
static arePointsEqual(point1, point2) {
|
|
421
|
+
if (!point1 && !point2) {
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
if (!point1 || !point2) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
return arePointsEqual(point1, point2);
|
|
428
|
+
}
|
|
429
|
+
static handlePointerMove(event, scenePointerX, scenePointerY, appState) {
|
|
430
|
+
if (!appState.editingLinearElement) {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
const { elementId, lastUncommittedPoint } = appState.editingLinearElement;
|
|
434
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
435
|
+
if (!element) {
|
|
436
|
+
return appState.editingLinearElement;
|
|
437
|
+
}
|
|
438
|
+
const { points } = element;
|
|
439
|
+
const lastPoint = points[points.length - 1];
|
|
440
|
+
if (!event.altKey) {
|
|
441
|
+
if (lastPoint === lastUncommittedPoint) {
|
|
442
|
+
LinearElementEditor.deletePoints(element, [points.length - 1]);
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
...appState.editingLinearElement,
|
|
446
|
+
lastUncommittedPoint: null,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
let newPoint;
|
|
450
|
+
if (shouldRotateWithDiscreteAngle(event) && points.length >= 2) {
|
|
451
|
+
const lastCommittedPoint = points[points.length - 2];
|
|
452
|
+
const [width, height] = LinearElementEditor._getShiftLockedDelta(element, lastCommittedPoint, [scenePointerX, scenePointerY], event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize);
|
|
453
|
+
newPoint = [
|
|
454
|
+
width + lastCommittedPoint[0],
|
|
455
|
+
height + lastCommittedPoint[1],
|
|
456
|
+
];
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
newPoint = LinearElementEditor.createPointAt(element, scenePointerX - appState.editingLinearElement.pointerOffset.x, scenePointerY - appState.editingLinearElement.pointerOffset.y, event[KEYS.CTRL_OR_CMD] ? null : appState.gridSize);
|
|
460
|
+
}
|
|
461
|
+
if (lastPoint === lastUncommittedPoint) {
|
|
462
|
+
LinearElementEditor.movePoints(element, [
|
|
463
|
+
{
|
|
464
|
+
index: element.points.length - 1,
|
|
465
|
+
point: newPoint,
|
|
466
|
+
},
|
|
467
|
+
]);
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
LinearElementEditor.addPoints(element, appState, [{ point: newPoint }]);
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
...appState.editingLinearElement,
|
|
474
|
+
lastUncommittedPoint: element.points[element.points.length - 1],
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/** scene coords */
|
|
478
|
+
static getPointGlobalCoordinates(element, point) {
|
|
479
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
480
|
+
const cx = (x1 + x2) / 2;
|
|
481
|
+
const cy = (y1 + y2) / 2;
|
|
482
|
+
let { x, y } = element;
|
|
483
|
+
[x, y] = rotate(x + point[0], y + point[1], cx, cy, element.angle);
|
|
484
|
+
return [x, y];
|
|
485
|
+
}
|
|
486
|
+
/** scene coords */
|
|
487
|
+
static getPointsGlobalCoordinates(element) {
|
|
488
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
489
|
+
const cx = (x1 + x2) / 2;
|
|
490
|
+
const cy = (y1 + y2) / 2;
|
|
491
|
+
return element.points.map((point) => {
|
|
492
|
+
let { x, y } = element;
|
|
493
|
+
[x, y] = rotate(x + point[0], y + point[1], cx, cy, element.angle);
|
|
494
|
+
return [x, y];
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
static getPointAtIndexGlobalCoordinates(element, indexMaybeFromEnd) {
|
|
498
|
+
const index = indexMaybeFromEnd < 0
|
|
499
|
+
? element.points.length + indexMaybeFromEnd
|
|
500
|
+
: indexMaybeFromEnd;
|
|
501
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
502
|
+
const cx = (x1 + x2) / 2;
|
|
503
|
+
const cy = (y1 + y2) / 2;
|
|
504
|
+
const point = element.points[index];
|
|
505
|
+
const { x, y } = element;
|
|
506
|
+
return point
|
|
507
|
+
? rotate(x + point[0], y + point[1], cx, cy, element.angle)
|
|
508
|
+
: rotate(x, y, cx, cy, element.angle);
|
|
509
|
+
}
|
|
510
|
+
static pointFromAbsoluteCoords(element, absoluteCoords) {
|
|
511
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
512
|
+
const cx = (x1 + x2) / 2;
|
|
513
|
+
const cy = (y1 + y2) / 2;
|
|
514
|
+
const [x, y] = rotate(absoluteCoords[0], absoluteCoords[1], cx, cy, -element.angle);
|
|
515
|
+
return [x - element.x, y - element.y];
|
|
516
|
+
}
|
|
517
|
+
static getPointIndexUnderCursor(element, zoom, x, y) {
|
|
518
|
+
const pointHandles = LinearElementEditor.getPointsGlobalCoordinates(element);
|
|
519
|
+
let idx = pointHandles.length;
|
|
520
|
+
// loop from right to left because points on the right are rendered over
|
|
521
|
+
// points on the left, thus should take precedence when clicking, if they
|
|
522
|
+
// overlap
|
|
523
|
+
while (--idx > -1) {
|
|
524
|
+
const point = pointHandles[idx];
|
|
525
|
+
if (distance2d(x, y, point[0], point[1]) * zoom.value <
|
|
526
|
+
// +1px to account for outline stroke
|
|
527
|
+
LinearElementEditor.POINT_HANDLE_SIZE + 1) {
|
|
528
|
+
return idx;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return -1;
|
|
532
|
+
}
|
|
533
|
+
static createPointAt(element, scenePointerX, scenePointerY, gridSize) {
|
|
534
|
+
const pointerOnGrid = getGridPoint(scenePointerX, scenePointerY, gridSize);
|
|
535
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
536
|
+
const cx = (x1 + x2) / 2;
|
|
537
|
+
const cy = (y1 + y2) / 2;
|
|
538
|
+
const [rotatedX, rotatedY] = rotate(pointerOnGrid[0], pointerOnGrid[1], cx, cy, -element.angle);
|
|
539
|
+
return [rotatedX - element.x, rotatedY - element.y];
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Normalizes line points so that the start point is at [0,0]. This is
|
|
543
|
+
* expected in various parts of the codebase. Also returns new x/y to account
|
|
544
|
+
* for the potential normalization.
|
|
545
|
+
*/
|
|
546
|
+
static getNormalizedPoints(element) {
|
|
547
|
+
const { points } = element;
|
|
548
|
+
const offsetX = points[0][0];
|
|
549
|
+
const offsetY = points[0][1];
|
|
550
|
+
return {
|
|
551
|
+
points: points.map((point, _idx) => {
|
|
552
|
+
return [point[0] - offsetX, point[1] - offsetY];
|
|
553
|
+
}),
|
|
554
|
+
x: element.x + offsetX,
|
|
555
|
+
y: element.y + offsetY,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
// element-mutating methods
|
|
559
|
+
// ---------------------------------------------------------------------------
|
|
560
|
+
static normalizePoints(element) {
|
|
561
|
+
mutateElement(element, LinearElementEditor.getNormalizedPoints(element));
|
|
562
|
+
}
|
|
563
|
+
static duplicateSelectedPoints(appState) {
|
|
564
|
+
if (!appState.editingLinearElement) {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
const { selectedPointsIndices, elementId } = appState.editingLinearElement;
|
|
568
|
+
const element = LinearElementEditor.getElement(elementId);
|
|
569
|
+
if (!element || selectedPointsIndices === null) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
const { points } = element;
|
|
573
|
+
const nextSelectedIndices = [];
|
|
574
|
+
let pointAddedToEnd = false;
|
|
575
|
+
let indexCursor = -1;
|
|
576
|
+
const nextPoints = points.reduce((acc, point, index) => {
|
|
577
|
+
++indexCursor;
|
|
578
|
+
acc.push(point);
|
|
579
|
+
const isSelected = selectedPointsIndices.includes(index);
|
|
580
|
+
if (isSelected) {
|
|
581
|
+
const nextPoint = points[index + 1];
|
|
582
|
+
if (!nextPoint) {
|
|
583
|
+
pointAddedToEnd = true;
|
|
584
|
+
}
|
|
585
|
+
acc.push(nextPoint
|
|
586
|
+
? [(point[0] + nextPoint[0]) / 2, (point[1] + nextPoint[1]) / 2]
|
|
587
|
+
: [point[0], point[1]]);
|
|
588
|
+
nextSelectedIndices.push(indexCursor + 1);
|
|
589
|
+
++indexCursor;
|
|
590
|
+
}
|
|
591
|
+
return acc;
|
|
592
|
+
}, []);
|
|
593
|
+
mutateElement(element, { points: nextPoints });
|
|
594
|
+
// temp hack to ensure the line doesn't move when adding point to the end,
|
|
595
|
+
// potentially expanding the bounding box
|
|
596
|
+
if (pointAddedToEnd) {
|
|
597
|
+
const lastPoint = element.points[element.points.length - 1];
|
|
598
|
+
LinearElementEditor.movePoints(element, [
|
|
599
|
+
{
|
|
600
|
+
index: element.points.length - 1,
|
|
601
|
+
point: [lastPoint[0] + 30, lastPoint[1] + 30],
|
|
602
|
+
},
|
|
603
|
+
]);
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
appState: {
|
|
607
|
+
...appState,
|
|
608
|
+
editingLinearElement: {
|
|
609
|
+
...appState.editingLinearElement,
|
|
610
|
+
selectedPointsIndices: nextSelectedIndices,
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
static deletePoints(element, pointIndices) {
|
|
616
|
+
let offsetX = 0;
|
|
617
|
+
let offsetY = 0;
|
|
618
|
+
const isDeletingOriginPoint = pointIndices.includes(0);
|
|
619
|
+
// if deleting first point, make the next to be [0,0] and recalculate
|
|
620
|
+
// positions of the rest with respect to it
|
|
621
|
+
if (isDeletingOriginPoint) {
|
|
622
|
+
const firstNonDeletedPoint = element.points.find((point, idx) => {
|
|
623
|
+
return !pointIndices.includes(idx);
|
|
624
|
+
});
|
|
625
|
+
if (firstNonDeletedPoint) {
|
|
626
|
+
offsetX = firstNonDeletedPoint[0];
|
|
627
|
+
offsetY = firstNonDeletedPoint[1];
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
const nextPoints = element.points.reduce((acc, point, idx) => {
|
|
631
|
+
if (!pointIndices.includes(idx)) {
|
|
632
|
+
acc.push(!acc.length ? [0, 0] : [point[0] - offsetX, point[1] - offsetY]);
|
|
633
|
+
}
|
|
634
|
+
return acc;
|
|
635
|
+
}, []);
|
|
636
|
+
LinearElementEditor._updatePoints(element, nextPoints, offsetX, offsetY);
|
|
637
|
+
}
|
|
638
|
+
static addPoints(element, appState, targetPoints) {
|
|
639
|
+
const offsetX = 0;
|
|
640
|
+
const offsetY = 0;
|
|
641
|
+
const nextPoints = [...element.points, ...targetPoints.map((x) => x.point)];
|
|
642
|
+
LinearElementEditor._updatePoints(element, nextPoints, offsetX, offsetY);
|
|
643
|
+
}
|
|
644
|
+
static movePoints(element, targetPoints, otherUpdates) {
|
|
645
|
+
const { points } = element;
|
|
646
|
+
// in case we're moving start point, instead of modifying its position
|
|
647
|
+
// which would break the invariant of it being at [0,0], we move
|
|
648
|
+
// all the other points in the opposite direction by delta to
|
|
649
|
+
// offset it. We do the same with actual element.x/y position, so
|
|
650
|
+
// this hacks are completely transparent to the user.
|
|
651
|
+
let offsetX = 0;
|
|
652
|
+
let offsetY = 0;
|
|
653
|
+
const selectedOriginPoint = targetPoints.find(({ index }) => index === 0);
|
|
654
|
+
if (selectedOriginPoint) {
|
|
655
|
+
offsetX =
|
|
656
|
+
selectedOriginPoint.point[0] + points[selectedOriginPoint.index][0];
|
|
657
|
+
offsetY =
|
|
658
|
+
selectedOriginPoint.point[1] + points[selectedOriginPoint.index][1];
|
|
659
|
+
}
|
|
660
|
+
const nextPoints = points.map((point, idx) => {
|
|
661
|
+
const selectedPointData = targetPoints.find((p) => p.index === idx);
|
|
662
|
+
if (selectedPointData) {
|
|
663
|
+
if (selectedOriginPoint) {
|
|
664
|
+
return point;
|
|
665
|
+
}
|
|
666
|
+
const deltaX = selectedPointData.point[0] - points[selectedPointData.index][0];
|
|
667
|
+
const deltaY = selectedPointData.point[1] - points[selectedPointData.index][1];
|
|
668
|
+
return [point[0] + deltaX, point[1] + deltaY];
|
|
669
|
+
}
|
|
670
|
+
return offsetX || offsetY
|
|
671
|
+
? [point[0] - offsetX, point[1] - offsetY]
|
|
672
|
+
: point;
|
|
673
|
+
});
|
|
674
|
+
LinearElementEditor._updatePoints(element, nextPoints, offsetX, offsetY, otherUpdates);
|
|
675
|
+
}
|
|
676
|
+
static shouldAddMidpoint(linearElementEditor, pointerCoords, appState) {
|
|
677
|
+
const element = LinearElementEditor.getElement(linearElementEditor.elementId);
|
|
678
|
+
if (!element) {
|
|
679
|
+
return false;
|
|
680
|
+
}
|
|
681
|
+
const { segmentMidpoint } = linearElementEditor.pointerDownState;
|
|
682
|
+
if (segmentMidpoint.added ||
|
|
683
|
+
segmentMidpoint.value === null ||
|
|
684
|
+
segmentMidpoint.index === null ||
|
|
685
|
+
linearElementEditor.pointerDownState.origin === null) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
const origin = linearElementEditor.pointerDownState.origin;
|
|
689
|
+
const dist = distance2d(origin.x, origin.y, pointerCoords.x, pointerCoords.y);
|
|
690
|
+
if (!appState.editingLinearElement &&
|
|
691
|
+
dist < DRAGGING_THRESHOLD / appState.zoom.value) {
|
|
692
|
+
return false;
|
|
693
|
+
}
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
static addMidpoint(linearElementEditor, pointerCoords, appState, snapToGrid) {
|
|
697
|
+
const element = LinearElementEditor.getElement(linearElementEditor.elementId);
|
|
698
|
+
if (!element) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const { segmentMidpoint } = linearElementEditor.pointerDownState;
|
|
702
|
+
const ret = {
|
|
703
|
+
pointerDownState: linearElementEditor.pointerDownState,
|
|
704
|
+
selectedPointsIndices: linearElementEditor.selectedPointsIndices,
|
|
705
|
+
};
|
|
706
|
+
const midpoint = LinearElementEditor.createPointAt(element, pointerCoords.x, pointerCoords.y, snapToGrid ? appState.gridSize : null);
|
|
707
|
+
const points = [
|
|
708
|
+
...element.points.slice(0, segmentMidpoint.index),
|
|
709
|
+
midpoint,
|
|
710
|
+
...element.points.slice(segmentMidpoint.index),
|
|
711
|
+
];
|
|
712
|
+
mutateElement(element, {
|
|
713
|
+
points,
|
|
714
|
+
});
|
|
715
|
+
ret.pointerDownState = {
|
|
716
|
+
...linearElementEditor.pointerDownState,
|
|
717
|
+
segmentMidpoint: {
|
|
718
|
+
...linearElementEditor.pointerDownState.segmentMidpoint,
|
|
719
|
+
added: true,
|
|
720
|
+
},
|
|
721
|
+
lastClickedPoint: segmentMidpoint.index,
|
|
722
|
+
};
|
|
723
|
+
ret.selectedPointsIndices = [segmentMidpoint.index];
|
|
724
|
+
return ret;
|
|
725
|
+
}
|
|
726
|
+
static _updatePoints(element, nextPoints, offsetX, offsetY, otherUpdates) {
|
|
727
|
+
const nextCoords = getElementPointsCoords(element, nextPoints);
|
|
728
|
+
const prevCoords = getElementPointsCoords(element, element.points);
|
|
729
|
+
const nextCenterX = (nextCoords[0] + nextCoords[2]) / 2;
|
|
730
|
+
const nextCenterY = (nextCoords[1] + nextCoords[3]) / 2;
|
|
731
|
+
const prevCenterX = (prevCoords[0] + prevCoords[2]) / 2;
|
|
732
|
+
const prevCenterY = (prevCoords[1] + prevCoords[3]) / 2;
|
|
733
|
+
const dX = prevCenterX - nextCenterX;
|
|
734
|
+
const dY = prevCenterY - nextCenterY;
|
|
735
|
+
const rotated = rotate(offsetX, offsetY, dX, dY, element.angle);
|
|
736
|
+
mutateElement(element, {
|
|
737
|
+
...otherUpdates,
|
|
738
|
+
points: nextPoints,
|
|
739
|
+
x: element.x + rotated[0],
|
|
740
|
+
y: element.y + rotated[1],
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
static _getShiftLockedDelta(element, referencePoint, scenePointer, gridSize) {
|
|
744
|
+
const referencePointCoords = LinearElementEditor.getPointGlobalCoordinates(element, referencePoint);
|
|
745
|
+
const [gridX, gridY] = getGridPoint(scenePointer[0], scenePointer[1], gridSize);
|
|
746
|
+
const { width, height } = getLockedLinearCursorAlignSize(referencePointCoords[0], referencePointCoords[1], gridX, gridY);
|
|
747
|
+
return rotatePoint([width, height], [0, 0], -element.angle);
|
|
748
|
+
}
|
|
749
|
+
static getBoundTextElementPosition = (element, boundTextElement) => {
|
|
750
|
+
const points = LinearElementEditor.getPointsGlobalCoordinates(element);
|
|
751
|
+
if (points.length < 2) {
|
|
752
|
+
mutateElement(boundTextElement, { isDeleted: true });
|
|
753
|
+
}
|
|
754
|
+
let x = 0;
|
|
755
|
+
let y = 0;
|
|
756
|
+
if (element.points.length % 2 === 1) {
|
|
757
|
+
const index = Math.floor(element.points.length / 2);
|
|
758
|
+
const midPoint = LinearElementEditor.getPointGlobalCoordinates(element, element.points[index]);
|
|
759
|
+
x = midPoint[0] - boundTextElement.width / 2;
|
|
760
|
+
y = midPoint[1] - boundTextElement.height / 2;
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
const index = element.points.length / 2 - 1;
|
|
764
|
+
let midSegmentMidpoint = editorMidPointsCache.points[index];
|
|
765
|
+
if (element.points.length === 2) {
|
|
766
|
+
midSegmentMidpoint = centerPoint(points[0], points[1]);
|
|
767
|
+
}
|
|
768
|
+
if (!midSegmentMidpoint ||
|
|
769
|
+
editorMidPointsCache.version !== element.version) {
|
|
770
|
+
midSegmentMidpoint = LinearElementEditor.getSegmentMidPoint(element, points[index], points[index + 1], index + 1);
|
|
771
|
+
}
|
|
772
|
+
x = midSegmentMidpoint[0] - boundTextElement.width / 2;
|
|
773
|
+
y = midSegmentMidpoint[1] - boundTextElement.height / 2;
|
|
774
|
+
}
|
|
775
|
+
return { x, y };
|
|
776
|
+
};
|
|
777
|
+
static getMinMaxXYWithBoundText = (element, elementBounds, boundTextElement) => {
|
|
778
|
+
let [x1, y1, x2, y2] = elementBounds;
|
|
779
|
+
const cx = (x1 + x2) / 2;
|
|
780
|
+
const cy = (y1 + y2) / 2;
|
|
781
|
+
const { x: boundTextX1, y: boundTextY1 } = LinearElementEditor.getBoundTextElementPosition(element, boundTextElement);
|
|
782
|
+
const boundTextX2 = boundTextX1 + boundTextElement.width;
|
|
783
|
+
const boundTextY2 = boundTextY1 + boundTextElement.height;
|
|
784
|
+
const topLeftRotatedPoint = rotatePoint([x1, y1], [cx, cy], element.angle);
|
|
785
|
+
const topRightRotatedPoint = rotatePoint([x2, y1], [cx, cy], element.angle);
|
|
786
|
+
const counterRotateBoundTextTopLeft = rotatePoint([boundTextX1, boundTextY1], [cx, cy], -element.angle);
|
|
787
|
+
const counterRotateBoundTextTopRight = rotatePoint([boundTextX2, boundTextY1], [cx, cy], -element.angle);
|
|
788
|
+
const counterRotateBoundTextBottomLeft = rotatePoint([boundTextX1, boundTextY2], [cx, cy], -element.angle);
|
|
789
|
+
const counterRotateBoundTextBottomRight = rotatePoint([boundTextX2, boundTextY2], [cx, cy], -element.angle);
|
|
790
|
+
if (topLeftRotatedPoint[0] < topRightRotatedPoint[0] &&
|
|
791
|
+
topLeftRotatedPoint[1] >= topRightRotatedPoint[1]) {
|
|
792
|
+
x1 = Math.min(x1, counterRotateBoundTextBottomLeft[0]);
|
|
793
|
+
x2 = Math.max(x2, Math.max(counterRotateBoundTextTopRight[0], counterRotateBoundTextBottomRight[0]));
|
|
794
|
+
y1 = Math.min(y1, counterRotateBoundTextTopLeft[1]);
|
|
795
|
+
y2 = Math.max(y2, counterRotateBoundTextBottomRight[1]);
|
|
796
|
+
}
|
|
797
|
+
else if (topLeftRotatedPoint[0] >= topRightRotatedPoint[0] &&
|
|
798
|
+
topLeftRotatedPoint[1] > topRightRotatedPoint[1]) {
|
|
799
|
+
x1 = Math.min(x1, counterRotateBoundTextBottomRight[0]);
|
|
800
|
+
x2 = Math.max(x2, Math.max(counterRotateBoundTextTopLeft[0], counterRotateBoundTextTopRight[0]));
|
|
801
|
+
y1 = Math.min(y1, counterRotateBoundTextBottomLeft[1]);
|
|
802
|
+
y2 = Math.max(y2, counterRotateBoundTextTopRight[1]);
|
|
803
|
+
}
|
|
804
|
+
else if (topLeftRotatedPoint[0] >= topRightRotatedPoint[0]) {
|
|
805
|
+
x1 = Math.min(x1, counterRotateBoundTextTopRight[0]);
|
|
806
|
+
x2 = Math.max(x2, counterRotateBoundTextBottomLeft[0]);
|
|
807
|
+
y1 = Math.min(y1, counterRotateBoundTextBottomRight[1]);
|
|
808
|
+
y2 = Math.max(y2, counterRotateBoundTextTopLeft[1]);
|
|
809
|
+
}
|
|
810
|
+
else if (topLeftRotatedPoint[1] <= topRightRotatedPoint[1]) {
|
|
811
|
+
x1 = Math.min(x1, Math.min(counterRotateBoundTextTopRight[0], counterRotateBoundTextTopLeft[0]));
|
|
812
|
+
x2 = Math.max(x2, counterRotateBoundTextBottomRight[0]);
|
|
813
|
+
y1 = Math.min(y1, counterRotateBoundTextTopRight[1]);
|
|
814
|
+
y2 = Math.max(y2, counterRotateBoundTextBottomLeft[1]);
|
|
815
|
+
}
|
|
816
|
+
return [x1, y1, x2, y2, cx, cy];
|
|
817
|
+
};
|
|
818
|
+
static getElementAbsoluteCoords = (element, includeBoundText = false) => {
|
|
819
|
+
let coords;
|
|
820
|
+
let x1;
|
|
821
|
+
let y1;
|
|
822
|
+
let x2;
|
|
823
|
+
let y2;
|
|
824
|
+
if (element.points.length < 2 || !ShapeCache.get(element)) {
|
|
825
|
+
// XXX this is just a poor estimate and not very useful
|
|
826
|
+
const { minX, minY, maxX, maxY } = element.points.reduce((limits, [x, y]) => {
|
|
827
|
+
limits.minY = Math.min(limits.minY, y);
|
|
828
|
+
limits.minX = Math.min(limits.minX, x);
|
|
829
|
+
limits.maxX = Math.max(limits.maxX, x);
|
|
830
|
+
limits.maxY = Math.max(limits.maxY, y);
|
|
831
|
+
return limits;
|
|
832
|
+
}, { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity });
|
|
833
|
+
x1 = minX + element.x;
|
|
834
|
+
y1 = minY + element.y;
|
|
835
|
+
x2 = maxX + element.x;
|
|
836
|
+
y2 = maxY + element.y;
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
const shape = ShapeCache.generateElementShape(element, null);
|
|
840
|
+
// first element is always the curve
|
|
841
|
+
const ops = getCurvePathOps(shape[0]);
|
|
842
|
+
const [minX, minY, maxX, maxY] = getMinMaxXYFromCurvePathOps(ops);
|
|
843
|
+
x1 = minX + element.x;
|
|
844
|
+
y1 = minY + element.y;
|
|
845
|
+
x2 = maxX + element.x;
|
|
846
|
+
y2 = maxY + element.y;
|
|
847
|
+
}
|
|
848
|
+
const cx = (x1 + x2) / 2;
|
|
849
|
+
const cy = (y1 + y2) / 2;
|
|
850
|
+
coords = [x1, y1, x2, y2, cx, cy];
|
|
851
|
+
if (!includeBoundText) {
|
|
852
|
+
return coords;
|
|
853
|
+
}
|
|
854
|
+
const boundTextElement = getBoundTextElement(element);
|
|
855
|
+
if (boundTextElement) {
|
|
856
|
+
coords = LinearElementEditor.getMinMaxXYWithBoundText(element, [x1, y1, x2, y2], boundTextElement);
|
|
857
|
+
}
|
|
858
|
+
return coords;
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
const normalizeSelectedPoints = (points) => {
|
|
862
|
+
let nextPoints = [
|
|
863
|
+
...new Set(points.filter((p) => p !== null && p !== -1)),
|
|
864
|
+
];
|
|
865
|
+
nextPoints = nextPoints.sort((a, b) => a - b);
|
|
866
|
+
return nextPoints.length ? nextPoints : null;
|
|
867
|
+
};
|