@excalidraw/excalidraw 0.17.1-d9bbf1e → 0.17.1-e63dd02
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/CHANGELOG.md +4 -0
- package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-IT7T3AIK.js} +49 -8
- package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-BLEB3M62.js → chunk-RNHSD5AR.js} +7668 -2142
- package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-DNSPZDOZ.js} +66 -32
- package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-XV7OZCPP.js} +8 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js → image-77HZYGLG.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
- package/dist/browser/dev/index.css +610 -180
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +13306 -8006
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-PDYFZJMS.js} +5 -5
- package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +70 -51
- package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/dev/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
- package/dist/dev/index.css +610 -180
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +22165 -16833
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +24 -9
- package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/excalidraw/actions/actionBoundText.d.ts +20 -10
- package/dist/excalidraw/actions/actionBoundText.js +3 -1
- package/dist/excalidraw/actions/actionCanvas.d.ts +100 -40
- package/dist/excalidraw/actions/actionCanvas.js +1 -1
- package/dist/excalidraw/actions/actionClipboard.d.ts +62 -26
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +28 -12
- package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
- package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
- package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
- package/dist/excalidraw/actions/actionElementLock.d.ts +17 -7
- package/dist/excalidraw/actions/actionExport.d.ts +75 -30
- package/dist/excalidraw/actions/actionFinalize.d.ts +17 -7
- package/dist/excalidraw/actions/actionFinalize.js +2 -2
- package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/excalidraw/actions/actionFlip.js +2 -2
- package/dist/excalidraw/actions/actionFrame.d.ts +338 -10
- package/dist/excalidraw/actions/actionGroup.d.ts +324 -4
- package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
- package/dist/excalidraw/actions/actionHistory.js +8 -8
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +12 -5
- package/dist/excalidraw/actions/actionLinearEditor.js +21 -5
- package/dist/excalidraw/actions/actionLink.d.ts +8 -3
- package/dist/excalidraw/actions/actionMenu.d.ts +24 -9
- package/dist/excalidraw/actions/actionNavigate.d.ts +17 -7
- package/dist/excalidraw/actions/actionProperties.d.ts +476 -82
- package/dist/excalidraw/actions/actionProperties.js +384 -59
- package/dist/excalidraw/actions/actionSelectAll.d.ts +9 -4
- package/dist/excalidraw/actions/actionStyles.d.ts +12 -4
- package/dist/excalidraw/actions/actionStyles.js +3 -2
- package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
- package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +9 -4
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionToggleStats.d.ts +9 -3
- package/dist/excalidraw/actions/actionToggleStats.js +4 -3
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionZindex.d.ts +8 -4
- package/dist/excalidraw/actions/actionZindex.js +4 -0
- package/dist/excalidraw/actions/manager.d.ts +3 -3
- package/dist/excalidraw/actions/register.d.ts +1 -1
- package/dist/excalidraw/actions/shortcuts.d.ts +2 -2
- package/dist/excalidraw/actions/types.d.ts +6 -6
- package/dist/excalidraw/align.d.ts +1 -1
- package/dist/excalidraw/analytics.js +9 -7
- package/dist/excalidraw/animated-trail.d.ts +2 -2
- package/dist/excalidraw/appState.d.ts +6 -2
- package/dist/excalidraw/appState.js +14 -3
- package/dist/excalidraw/binaryheap.d.ts +12 -0
- package/dist/excalidraw/binaryheap.js +93 -0
- package/dist/excalidraw/change.d.ts +6 -5
- package/dist/excalidraw/change.js +20 -11
- package/dist/excalidraw/charts.d.ts +1 -1
- package/dist/excalidraw/charts.js +0 -10
- package/dist/excalidraw/clients.d.ts +2 -2
- package/dist/excalidraw/clients.js +1 -1
- package/dist/excalidraw/clipboard.d.ts +3 -3
- package/dist/excalidraw/colors.d.ts +1 -1
- package/dist/excalidraw/components/Actions.d.ts +3 -3
- package/dist/excalidraw/components/Actions.js +14 -9
- package/dist/excalidraw/components/App.d.ts +14 -17
- package/dist/excalidraw/components/App.js +356 -217
- package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
- package/dist/excalidraw/components/ButtonIcon.js +8 -0
- package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
- package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
- package/dist/excalidraw/components/ButtonSeparator.js +7 -0
- package/dist/excalidraw/components/CheckboxItem.js +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorInput.js +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorPicker.d.ts +4 -4
- package/dist/excalidraw/components/ColorPicker/ColorPicker.js +48 -80
- package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
- package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
- package/dist/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
- package/dist/excalidraw/components/ColorPicker/colorPickerUtils.js +1 -1
- package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
- package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.js +1 -1
- package/dist/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
- package/dist/excalidraw/components/CommandPalette/CommandPalette.js +5 -5
- package/dist/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -1
- package/dist/excalidraw/components/CommandPalette/types.d.ts +3 -3
- package/dist/excalidraw/components/ConfirmDialog.d.ts +1 -1
- package/dist/excalidraw/components/ContextMenu.d.ts +2 -2
- package/dist/excalidraw/components/ContextMenu.js +2 -2
- package/dist/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/excalidraw/components/DefaultSidebar.d.ts +2 -2
- package/dist/excalidraw/components/Dialog.js +1 -1
- package/dist/excalidraw/components/DialogActionButton.d.ts +1 -1
- package/dist/excalidraw/components/EyeDropper.d.ts +2 -2
- package/dist/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
- package/dist/excalidraw/components/FollowMode/FollowMode.js +1 -1
- package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
- package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
- package/dist/excalidraw/components/HelpDialog.js +2 -2
- package/dist/excalidraw/components/HintViewer.d.ts +1 -1
- package/dist/excalidraw/components/HintViewer.js +6 -3
- package/dist/excalidraw/components/IconPicker.js +2 -2
- package/dist/excalidraw/components/ImageExportDialog.d.ts +1 -1
- package/dist/excalidraw/components/InitializeApp.d.ts +2 -2
- package/dist/excalidraw/components/JSONExportDialog.d.ts +3 -3
- package/dist/excalidraw/components/LayerUI.d.ts +4 -4
- package/dist/excalidraw/components/LayerUI.js +10 -7
- package/dist/excalidraw/components/LibraryMenu.d.ts +2 -2
- package/dist/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuHeaderContent.d.ts +2 -2
- package/dist/excalidraw/components/LibraryMenuItems.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuSection.d.ts +5 -4
- package/dist/excalidraw/components/LibraryUnit.d.ts +2 -2
- package/dist/excalidraw/components/LoadingMessage.d.ts +1 -1
- package/dist/excalidraw/components/MagicSettings.js +2 -2
- package/dist/excalidraw/components/MobileMenu.d.ts +3 -3
- package/dist/excalidraw/components/MobileMenu.js +2 -6
- package/dist/excalidraw/components/Modal.d.ts +1 -1
- package/dist/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/excalidraw/components/PasteChartDialog.d.ts +1 -1
- package/dist/excalidraw/components/PasteChartDialog.js +1 -1
- package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
- package/dist/excalidraw/components/PropertiesPopover.js +31 -0
- package/dist/excalidraw/components/PublishLibrary.d.ts +1 -1
- package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
- package/dist/excalidraw/components/QuickSearch.js +8 -0
- package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
- package/dist/excalidraw/components/ScrollableList.js +8 -0
- package/dist/excalidraw/components/Sidebar/Sidebar.js +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/common.d.ts +1 -1
- package/dist/excalidraw/components/Stats/Angle.d.ts +12 -0
- package/dist/excalidraw/components/Stats/Angle.js +53 -0
- package/dist/excalidraw/components/Stats/Collapsible.d.ts +9 -0
- package/dist/excalidraw/components/Stats/Collapsible.js +12 -0
- package/dist/excalidraw/components/Stats/Dimension.d.ts +12 -0
- package/dist/excalidraw/components/Stats/Dimension.js +68 -0
- package/dist/excalidraw/components/Stats/DragInput.d.ts +32 -0
- package/dist/excalidraw/components/Stats/DragInput.js +174 -0
- package/dist/excalidraw/components/Stats/FontSize.d.ts +12 -0
- package/dist/excalidraw/components/Stats/FontSize.js +50 -0
- package/dist/excalidraw/components/Stats/MultiAngle.d.ts +12 -0
- package/dist/excalidraw/components/Stats/MultiAngle.js +66 -0
- package/dist/excalidraw/components/Stats/MultiDimension.d.ts +15 -0
- package/dist/excalidraw/components/Stats/MultiDimension.js +199 -0
- package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +13 -0
- package/dist/excalidraw/components/Stats/MultiFontSize.js +72 -0
- package/dist/excalidraw/components/Stats/MultiPosition.d.ts +15 -0
- package/dist/excalidraw/components/Stats/MultiPosition.js +101 -0
- package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
- package/dist/excalidraw/components/Stats/Position.js +40 -0
- package/dist/excalidraw/components/Stats/index.d.ts +16 -0
- package/dist/excalidraw/components/Stats/index.js +79 -0
- package/dist/excalidraw/components/Stats/utils.d.ts +26 -0
- package/dist/excalidraw/components/Stats/utils.js +162 -0
- package/dist/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialog.js +2 -2
- package/dist/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/common.d.ts +5 -5
- package/dist/excalidraw/components/TTDDialog/common.js +3 -7
- package/dist/excalidraw/components/TextField.d.ts +1 -1
- package/dist/excalidraw/components/Toast.d.ts +1 -1
- package/dist/excalidraw/components/ToolButton.d.ts +3 -2
- package/dist/excalidraw/components/Trans.d.ts +1 -1
- package/dist/excalidraw/components/UserList.d.ts +1 -1
- package/dist/excalidraw/components/UserList.js +22 -22
- package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
- package/dist/excalidraw/components/canvases/InteractiveCanvas.js +4 -2
- package/dist/excalidraw/components/canvases/StaticCanvas.d.ts +2 -2
- package/dist/excalidraw/components/canvases/StaticCanvas.js +3 -2
- package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
- package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
- package/dist/excalidraw/components/footer/Footer.d.ts +2 -2
- package/dist/excalidraw/components/hyperlink/Hyperlink.d.ts +2 -2
- package/dist/excalidraw/components/hyperlink/helpers.d.ts +3 -3
- package/dist/excalidraw/components/icons.d.ts +10 -2
- package/dist/excalidraw/components/icons.js +29 -6
- package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
- package/dist/excalidraw/constants.d.ts +24 -3
- package/dist/excalidraw/constants.js +28 -4
- package/dist/excalidraw/context/ui-appState.d.ts +1 -1
- package/dist/excalidraw/cursor.d.ts +1 -1
- package/dist/excalidraw/data/EditorLocalStorage.d.ts +2 -2
- package/dist/excalidraw/data/blob.d.ts +5 -5
- package/dist/excalidraw/data/filesystem.d.ts +2 -1
- package/dist/excalidraw/data/index.d.ts +4 -4
- package/dist/excalidraw/data/json.d.ts +3 -3
- package/dist/excalidraw/data/library.d.ts +3 -3
- package/dist/excalidraw/data/magic.d.ts +3 -3
- package/dist/excalidraw/data/reconcile.d.ts +3 -3
- package/dist/excalidraw/data/reconcile.js +18 -1
- package/dist/excalidraw/data/resave.d.ts +2 -2
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +58 -9
- package/dist/excalidraw/data/transform.d.ts +3 -3
- package/dist/excalidraw/data/transform.js +8 -5
- package/dist/excalidraw/data/types.d.ts +3 -3
- package/dist/excalidraw/element/ElementCanvasButtons.d.ts +1 -1
- package/dist/excalidraw/element/binding.d.ts +29 -10
- package/dist/excalidraw/element/binding.js +303 -71
- package/dist/excalidraw/element/bounds.d.ts +3 -3
- package/dist/excalidraw/element/collision.d.ts +4 -4
- package/dist/excalidraw/element/collision.js +5 -2
- package/dist/excalidraw/element/containerCache.d.ts +1 -1
- package/dist/excalidraw/element/dragElements.d.ts +6 -6
- package/dist/excalidraw/element/dragElements.js +39 -5
- package/dist/excalidraw/element/embeddable.d.ts +11 -6
- package/dist/excalidraw/element/heading.d.ts +11 -0
- package/dist/excalidraw/element/heading.js +81 -0
- package/dist/excalidraw/element/image.d.ts +2 -2
- package/dist/excalidraw/element/index.d.ts +2 -2
- package/dist/excalidraw/element/index.js +1 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +27 -16
- package/dist/excalidraw/element/linearElementEditor.js +133 -56
- package/dist/excalidraw/element/mutateElement.d.ts +3 -3
- package/dist/excalidraw/element/mutateElement.js +5 -3
- package/dist/excalidraw/element/newElement.d.ts +12 -10
- package/dist/excalidraw/element/newElement.js +31 -16
- package/dist/excalidraw/element/resizeElements.d.ts +15 -6
- package/dist/excalidraw/element/resizeElements.js +122 -46
- package/dist/excalidraw/element/resizeTest.d.ts +4 -4
- package/dist/excalidraw/element/resizeTest.js +2 -4
- package/dist/excalidraw/element/routing.d.ts +13 -0
- package/dist/excalidraw/element/routing.js +641 -0
- package/dist/excalidraw/element/showSelectedShapeActions.d.ts +2 -2
- package/dist/excalidraw/element/sizeHelpers.d.ts +2 -2
- package/dist/excalidraw/element/sortElements.d.ts +1 -1
- package/dist/excalidraw/element/textElement.d.ts +6 -28
- package/dist/excalidraw/element/textElement.js +64 -112
- package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
- package/dist/excalidraw/element/textWysiwyg.js +75 -62
- package/dist/excalidraw/element/transformHandles.d.ts +3 -3
- package/dist/excalidraw/element/transformHandles.js +7 -12
- package/dist/excalidraw/element/typeChecks.d.ts +7 -4
- package/dist/excalidraw/element/typeChecks.js +17 -0
- package/dist/excalidraw/element/types.d.ts +22 -4
- package/dist/excalidraw/emitter.d.ts +1 -1
- package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
- package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
- package/dist/excalidraw/fonts/index.d.ts +58 -0
- package/dist/excalidraw/fonts/index.js +240 -0
- package/dist/excalidraw/fonts/metadata.d.ts +36 -0
- package/dist/excalidraw/fonts/metadata.js +91 -0
- package/dist/excalidraw/fractionalIndex.d.ts +12 -5
- package/dist/excalidraw/fractionalIndex.js +40 -10
- package/dist/excalidraw/frame.d.ts +4 -4
- package/dist/excalidraw/frame.js +3 -3
- package/dist/excalidraw/gatransforms.d.ts +1 -1
- package/dist/excalidraw/gesture.d.ts +1 -1
- package/dist/excalidraw/groups.d.ts +4 -4
- package/dist/excalidraw/history.d.ts +8 -7
- package/dist/excalidraw/history.js +8 -8
- package/dist/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/excalidraw/i18n.d.ts +1 -1
- package/dist/excalidraw/index.d.ts +2 -2
- package/dist/excalidraw/index.js +3 -3
- package/dist/excalidraw/jotai.d.ts +1 -1
- package/dist/excalidraw/laser-trails.d.ts +3 -2
- package/dist/excalidraw/locales/en.json +42 -7
- package/dist/excalidraw/math.d.ts +47 -2
- package/dist/excalidraw/math.js +116 -0
- package/dist/excalidraw/mermaid.d.ts +2 -0
- package/dist/excalidraw/mermaid.js +29 -0
- package/dist/excalidraw/points.d.ts +1 -1
- package/dist/excalidraw/queue.d.ts +1 -1
- package/dist/excalidraw/renderer/helpers.d.ts +2 -2
- package/dist/excalidraw/renderer/interactiveScene.d.ts +2 -2
- package/dist/excalidraw/renderer/interactiveScene.js +64 -22
- package/dist/excalidraw/renderer/renderElement.d.ts +6 -4
- package/dist/excalidraw/renderer/renderElement.js +78 -58
- package/dist/excalidraw/renderer/renderSnaps.d.ts +1 -1
- package/dist/excalidraw/renderer/staticScene.d.ts +1 -1
- package/dist/excalidraw/renderer/staticSvgScene.d.ts +4 -4
- package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
- package/dist/excalidraw/scene/Renderer.d.ts +4 -4
- package/dist/excalidraw/scene/Renderer.js +2 -3
- package/dist/excalidraw/scene/Scene.d.ts +16 -7
- package/dist/excalidraw/scene/Scene.js +26 -11
- package/dist/excalidraw/scene/Shape.d.ts +1 -1
- package/dist/excalidraw/scene/Shape.js +56 -5
- package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
- package/dist/excalidraw/scene/comparisons.d.ts +3 -2
- package/dist/excalidraw/scene/comparisons.js +1 -1
- package/dist/excalidraw/scene/export.d.ts +4 -3
- package/dist/excalidraw/scene/export.js +34 -36
- package/dist/excalidraw/scene/scroll.d.ts +2 -2
- package/dist/excalidraw/scene/scrollbars.d.ts +3 -3
- package/dist/excalidraw/scene/selection.d.ts +2 -2
- package/dist/excalidraw/scene/types.d.ts +6 -8
- package/dist/excalidraw/scene/zoom.d.ts +1 -1
- package/dist/excalidraw/shapes.d.ts +8 -0
- package/dist/excalidraw/shapes.js +57 -0
- package/dist/excalidraw/snapping.d.ts +4 -4
- package/dist/excalidraw/snapping.js +2 -1
- package/dist/excalidraw/store.d.ts +34 -4
- package/dist/excalidraw/store.js +27 -0
- package/dist/excalidraw/types.d.ts +32 -21
- package/dist/excalidraw/utils.d.ts +15 -5
- package/dist/excalidraw/utils.js +22 -0
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/prod/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +49 -53
- package/dist/utils/bbox.d.ts +2 -2
- package/dist/utils/collision.d.ts +1 -1
- package/dist/utils/export.d.ts +4 -3
- package/dist/utils/export.js +2 -1
- package/dist/utils/geometry/geometry.d.ts +3 -2
- package/dist/utils/geometry/geometry.js +5 -1
- package/dist/utils/geometry/shape.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/withinBounds.d.ts +1 -1
- package/history.ts +13 -6
- package/package.json +2 -2
- package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-BLEB3M62.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-XOM7LNOU.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/dist-ITJNUBZF.js.map +0 -7
- package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-UWBW5SR2.js +0 -55
- package/dist/browser/prod/excalidraw-assets/dist-54276HPL.js +0 -6
- package/dist/browser/prod/excalidraw-assets/en-7GPZE2Y2.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-35KQQ5EN.js +0 -1
- package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/excalidraw/components/Stats.d.ts +0 -11
- package/dist/excalidraw/components/Stats.js +0 -13
- package/dist/excalidraw/scene/Fonts.d.ts +0 -21
- package/dist/excalidraw/scene/Fonts.js +0 -72
- package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
- /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-XV7OZCPP.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js.map → image-77HZYGLG.js.map} +0 -0
- /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
|
@@ -2,7 +2,7 @@ import { CODES, KEYS } from "../keys";
|
|
|
2
2
|
import { isWritableElement, getFontString, getFontFamilyString, isTestEnv, } from "../utils";
|
|
3
3
|
import Scene from "../scene/Scene";
|
|
4
4
|
import { isArrowElement, isBoundToContainer, isTextElement, } from "./typeChecks";
|
|
5
|
-
import { CLASSES } from "../constants";
|
|
5
|
+
import { CLASSES, isSafari } from "../constants";
|
|
6
6
|
import { bumpVersion, mutateElement } from "./mutateElement";
|
|
7
7
|
import { getBoundTextElementId, getContainerElement, getTextElementAngle, getTextWidth, normalizeText, redrawTextBoundingBox, wrapText, getBoundTextMaxHeight, getBoundTextMaxWidth, computeContainerDimensionForBoundText, computeBoundTextPosition, getBoundTextElement, } from "./textElement";
|
|
8
8
|
import { actionDecreaseFontSize, actionIncreaseFontSize, } from "../actions/actionProperties";
|
|
@@ -23,7 +23,7 @@ const getTransform = (width, height, angle, appState, maxWidth, maxHeight) => {
|
|
|
23
23
|
}
|
|
24
24
|
return `translate(${translateX}px, ${translateY}px) scale(${zoom.value}) rotate(${degree}deg)`;
|
|
25
25
|
};
|
|
26
|
-
export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }) => {
|
|
26
|
+
export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect = true, }) => {
|
|
27
27
|
const textPropertiesUpdated = (updatedTextElement, editable) => {
|
|
28
28
|
if (!editable.style.fontFamily || !editable.style.fontSize) {
|
|
29
29
|
return false;
|
|
@@ -50,12 +50,12 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
50
50
|
let coordX = updatedTextElement.x;
|
|
51
51
|
let coordY = updatedTextElement.y;
|
|
52
52
|
const container = getContainerElement(updatedTextElement, app.scene.getNonDeletedElementsMap());
|
|
53
|
+
let width = updatedTextElement.width;
|
|
54
|
+
// set to element height by default since that's
|
|
55
|
+
// what is going to be used for unbounded text
|
|
56
|
+
let height = updatedTextElement.height;
|
|
53
57
|
let maxWidth = updatedTextElement.width;
|
|
54
58
|
let maxHeight = updatedTextElement.height;
|
|
55
|
-
let textElementWidth = updatedTextElement.width;
|
|
56
|
-
// Set to element height by default since that's
|
|
57
|
-
// what is going to be used for unbounded text
|
|
58
|
-
const textElementHeight = updatedTextElement.height;
|
|
59
59
|
if (container && updatedTextElement.containerId) {
|
|
60
60
|
if (isArrowElement(container)) {
|
|
61
61
|
const boundTextCoords = LinearElementEditor.getBoundTextElementPosition(container, updatedTextElement, elementsMap);
|
|
@@ -76,8 +76,8 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
76
76
|
maxWidth = getBoundTextMaxWidth(container, updatedTextElement);
|
|
77
77
|
maxHeight = getBoundTextMaxHeight(container, updatedTextElement);
|
|
78
78
|
// autogrow container height if text exceeds
|
|
79
|
-
if (!isArrowElement(container) &&
|
|
80
|
-
const targetContainerHeight = computeContainerDimensionForBoundText(
|
|
79
|
+
if (!isArrowElement(container) && height > maxHeight) {
|
|
80
|
+
const targetContainerHeight = computeContainerDimensionForBoundText(height, container.type);
|
|
81
81
|
mutateElement(container, { height: targetContainerHeight });
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
@@ -86,8 +86,8 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
86
86
|
// is reached when text is removed
|
|
87
87
|
!isArrowElement(container) &&
|
|
88
88
|
container.height > originalContainerData.height &&
|
|
89
|
-
|
|
90
|
-
const targetContainerHeight = computeContainerDimensionForBoundText(
|
|
89
|
+
height < maxHeight) {
|
|
90
|
+
const targetContainerHeight = computeContainerDimensionForBoundText(height, container.type);
|
|
91
91
|
mutateElement(container, { height: targetContainerHeight });
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
@@ -111,19 +111,30 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
111
111
|
}
|
|
112
112
|
if (!container) {
|
|
113
113
|
maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;
|
|
114
|
-
|
|
114
|
+
width = Math.min(width, maxWidth);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
width += 0.5;
|
|
115
118
|
}
|
|
119
|
+
// add 5% buffer otherwise it causes wysiwyg to jump
|
|
120
|
+
height *= 1.05;
|
|
121
|
+
const font = getFontString(updatedTextElement);
|
|
122
|
+
// adding left and right padding buffer, so that browser does not cut the glyphs (does not work in Safari)
|
|
123
|
+
const padding = !isSafari
|
|
124
|
+
? Math.ceil(updatedTextElement.fontSize / 2)
|
|
125
|
+
: 0;
|
|
116
126
|
// Make sure text editor height doesn't go beyond viewport
|
|
117
127
|
const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;
|
|
118
128
|
Object.assign(editable.style, {
|
|
119
|
-
font
|
|
129
|
+
font,
|
|
120
130
|
// must be defined *after* font ¯\_(ツ)_/¯
|
|
121
131
|
lineHeight: updatedTextElement.lineHeight,
|
|
122
|
-
width: `${
|
|
123
|
-
height: `${
|
|
124
|
-
left: `${viewportX}px`,
|
|
132
|
+
width: `${width}px`,
|
|
133
|
+
height: `${height}px`,
|
|
134
|
+
left: `${viewportX - padding}px`,
|
|
125
135
|
top: `${viewportY}px`,
|
|
126
|
-
transform: getTransform(
|
|
136
|
+
transform: getTransform(width, height, getTextElementAngle(updatedTextElement, container), appState, maxWidth, editorMaxHeight),
|
|
137
|
+
padding: `0 ${padding}px`,
|
|
127
138
|
textAlign,
|
|
128
139
|
verticalAlign,
|
|
129
140
|
color: updatedTextElement.strokeColor,
|
|
@@ -149,7 +160,7 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
149
160
|
editable.classList.add("excalidraw-wysiwyg");
|
|
150
161
|
let whiteSpace = "pre";
|
|
151
162
|
let wordBreak = "normal";
|
|
152
|
-
if (isBoundToContainer(element)) {
|
|
163
|
+
if (isBoundToContainer(element) || !element.autoResize) {
|
|
153
164
|
whiteSpace = "pre-wrap";
|
|
154
165
|
wordBreak = "break-word";
|
|
155
166
|
}
|
|
@@ -159,7 +170,6 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
159
170
|
minHeight: "1em",
|
|
160
171
|
backfaceVisibility: "hidden",
|
|
161
172
|
margin: 0,
|
|
162
|
-
padding: 0,
|
|
163
173
|
border: 0,
|
|
164
174
|
outline: 0,
|
|
165
175
|
resize: "none",
|
|
@@ -193,7 +203,7 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
193
203
|
if (container) {
|
|
194
204
|
const boundTextElement = getBoundTextElement(container, app.scene.getNonDeletedElementsMap());
|
|
195
205
|
const wrappedText = wrapText(`${editable.value}${data}`, font, getBoundTextMaxWidth(container, boundTextElement));
|
|
196
|
-
const width = getTextWidth(wrappedText, font);
|
|
206
|
+
const width = getTextWidth(wrappedText, font, true);
|
|
197
207
|
editable.style.width = `${width}px`;
|
|
198
208
|
}
|
|
199
209
|
};
|
|
@@ -319,13 +329,20 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
319
329
|
.reverse();
|
|
320
330
|
};
|
|
321
331
|
const stopEvent = (event) => {
|
|
322
|
-
event.
|
|
323
|
-
|
|
332
|
+
if (event.target instanceof HTMLCanvasElement) {
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
event.stopPropagation();
|
|
335
|
+
}
|
|
324
336
|
};
|
|
325
337
|
// using a state variable instead of passing it to the handleSubmit callback
|
|
326
338
|
// so that we don't need to create separate a callback for event handlers
|
|
327
339
|
let submittedViaKeyboard = false;
|
|
328
340
|
const handleSubmit = () => {
|
|
341
|
+
// prevent double submit
|
|
342
|
+
if (isDestroyed) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
isDestroyed = true;
|
|
329
346
|
// cleanup must be run before onSubmit otherwise when app blurs the wysiwyg
|
|
330
347
|
// it'd get stuck in an infinite loop of blur→onSubmit after we re-focus the
|
|
331
348
|
// wysiwyg on update
|
|
@@ -334,10 +351,8 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
334
351
|
if (!updateElement) {
|
|
335
352
|
return;
|
|
336
353
|
}
|
|
337
|
-
let text = editable.value;
|
|
338
354
|
const container = getContainerElement(updateElement, app.scene.getNonDeletedElementsMap());
|
|
339
355
|
if (container) {
|
|
340
|
-
text = updateElement.text;
|
|
341
356
|
if (editable.value.trim()) {
|
|
342
357
|
const boundTextElementId = getBoundTextElementId(container);
|
|
343
358
|
if (!boundTextElementId || boundTextElementId !== element.id) {
|
|
@@ -361,16 +376,11 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
361
376
|
redrawTextBoundingBox(updateElement, container, app.scene.getNonDeletedElementsMap());
|
|
362
377
|
}
|
|
363
378
|
onSubmit({
|
|
364
|
-
text,
|
|
365
379
|
viaKeyboard: submittedViaKeyboard,
|
|
366
|
-
|
|
380
|
+
nextOriginalText: editable.value,
|
|
367
381
|
});
|
|
368
382
|
};
|
|
369
383
|
const cleanup = () => {
|
|
370
|
-
if (isDestroyed) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
isDestroyed = true;
|
|
374
384
|
// remove events to ensure they don't late-fire
|
|
375
385
|
editable.onblur = null;
|
|
376
386
|
editable.oninput = null;
|
|
@@ -394,65 +404,63 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
394
404
|
// Also to handle cases such as picking a color which would trigger a blur
|
|
395
405
|
// in that same tick.
|
|
396
406
|
const target = event?.target;
|
|
397
|
-
const
|
|
398
|
-
target.classList.contains("
|
|
407
|
+
const isPropertiesTrigger = target instanceof HTMLElement &&
|
|
408
|
+
target.classList.contains("properties-trigger");
|
|
399
409
|
setTimeout(() => {
|
|
400
410
|
editable.onblur = handleSubmit;
|
|
401
|
-
if (isTargetPickerTrigger) {
|
|
402
|
-
const callback = (mutationList, observer) => {
|
|
403
|
-
const radixIsRemoved = mutationList.find((mutation) => mutation.removedNodes.length > 0 &&
|
|
404
|
-
mutation.removedNodes[0].dataset
|
|
405
|
-
?.radixPopperContentWrapper !== undefined);
|
|
406
|
-
if (radixIsRemoved) {
|
|
407
|
-
// should work without this in theory
|
|
408
|
-
// and i think it does actually but radix probably somewhere,
|
|
409
|
-
// somehow sets the focus elsewhere
|
|
410
|
-
setTimeout(() => {
|
|
411
|
-
editable.focus();
|
|
412
|
-
});
|
|
413
|
-
observer.disconnect();
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
const observer = new MutationObserver(callback);
|
|
417
|
-
observer.observe(document.querySelector(".excalidraw-container"), {
|
|
418
|
-
childList: true,
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
411
|
// case: clicking on the same property → no change → no update → no focus
|
|
422
|
-
if (!
|
|
412
|
+
if (!isPropertiesTrigger) {
|
|
423
413
|
editable.focus();
|
|
424
414
|
}
|
|
425
415
|
});
|
|
426
416
|
};
|
|
427
417
|
// prevent blur when changing properties from the menu
|
|
428
418
|
const onPointerDown = (event) => {
|
|
429
|
-
const
|
|
430
|
-
|
|
419
|
+
const target = event?.target;
|
|
420
|
+
const isPropertiesTrigger = target instanceof HTMLElement &&
|
|
421
|
+
target.classList.contains("properties-trigger");
|
|
431
422
|
if (((event.target instanceof HTMLElement ||
|
|
432
423
|
event.target instanceof SVGElement) &&
|
|
433
424
|
event.target.closest(`.${CLASSES.SHAPE_ACTIONS_MENU}`) &&
|
|
434
425
|
!isWritableElement(event.target)) ||
|
|
435
|
-
|
|
426
|
+
isPropertiesTrigger) {
|
|
436
427
|
editable.onblur = null;
|
|
437
428
|
window.addEventListener("pointerup", bindBlurEvent);
|
|
438
429
|
// handle edge-case where pointerup doesn't fire e.g. due to user
|
|
439
430
|
// alt-tabbing away
|
|
440
431
|
window.addEventListener("blur", handleSubmit);
|
|
441
432
|
}
|
|
433
|
+
else if (event.target instanceof HTMLElement &&
|
|
434
|
+
event.target instanceof HTMLCanvasElement &&
|
|
435
|
+
// Vitest simply ignores stopPropagation, capture-mode, or rAF
|
|
436
|
+
// so without introducing crazier hacks, nothing we can do
|
|
437
|
+
!isTestEnv()) {
|
|
438
|
+
// On mobile, blur event doesn't seem to always fire correctly,
|
|
439
|
+
// so we want to also submit on pointerdown outside the wysiwyg.
|
|
440
|
+
// Done in the next frame to prevent pointerdown from creating a new text
|
|
441
|
+
// immediately (if tools locked) so that users on mobile have chance
|
|
442
|
+
// to submit first (to hide virtual keyboard).
|
|
443
|
+
// Note: revisit if we want to differ this behavior on Desktop
|
|
444
|
+
requestAnimationFrame(() => {
|
|
445
|
+
handleSubmit();
|
|
446
|
+
});
|
|
447
|
+
}
|
|
442
448
|
};
|
|
443
449
|
// handle updates of textElement properties of editing element
|
|
444
|
-
const unbindUpdate = Scene.getScene(element).
|
|
450
|
+
const unbindUpdate = Scene.getScene(element).onUpdate(() => {
|
|
445
451
|
updateWysiwygStyle();
|
|
446
|
-
const
|
|
447
|
-
if (!
|
|
452
|
+
const isPopupOpened = !!document.activeElement?.closest(".properties-content");
|
|
453
|
+
if (!isPopupOpened) {
|
|
448
454
|
editable.focus();
|
|
449
455
|
}
|
|
450
456
|
});
|
|
451
457
|
// ---------------------------------------------------------------------------
|
|
452
458
|
let isDestroyed = false;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
459
|
+
if (autoSelect) {
|
|
460
|
+
// select on init (focusing is done separately inside the bindBlurEvent()
|
|
461
|
+
// because we need it to happen *after* the blur event from `pointerdown`)
|
|
462
|
+
editable.select();
|
|
463
|
+
}
|
|
456
464
|
bindBlurEvent();
|
|
457
465
|
// reposition wysiwyg in case of canvas is resized. Using ResizeObserver
|
|
458
466
|
// is preferred so we catch changes from host, where window may not resize.
|
|
@@ -466,7 +474,12 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
466
474
|
else {
|
|
467
475
|
window.addEventListener("resize", updateWysiwygStyle);
|
|
468
476
|
}
|
|
469
|
-
|
|
477
|
+
editable.onpointerdown = (event) => event.stopPropagation();
|
|
478
|
+
// rAF (+ capture to by doubly sure) so we don't catch te pointerdown that
|
|
479
|
+
// triggered the wysiwyg
|
|
480
|
+
requestAnimationFrame(() => {
|
|
481
|
+
window.addEventListener("pointerdown", onPointerDown, { capture: true });
|
|
482
|
+
});
|
|
470
483
|
window.addEventListener("wheel", stopEvent, {
|
|
471
484
|
passive: false,
|
|
472
485
|
capture: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
|
-
import { Bounds } from "./bounds";
|
|
3
|
-
import { Device, InteractiveCanvasAppState, Zoom } from "../types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
|
|
2
|
+
import type { Bounds } from "./bounds";
|
|
3
|
+
import type { Device, InteractiveCanvasAppState, Zoom } from "../types";
|
|
4
4
|
export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
|
|
5
5
|
export type TransformHandleType = TransformHandleDirection | "rotation";
|
|
6
6
|
export type TransformHandle = Bounds;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getElementAbsoluteCoords } from "./bounds";
|
|
2
2
|
import { rotate } from "../math";
|
|
3
|
-
import {
|
|
4
|
-
import { isFrameLikeElement, isLinearElement } from "./typeChecks";
|
|
3
|
+
import { isElbowArrow, isFrameLikeElement, isLinearElement, } from "./typeChecks";
|
|
5
4
|
import { DEFAULT_TRANSFORM_HANDLE_SPACING, isAndroid, isIOS, } from "../constants";
|
|
6
5
|
const transformHandleSizes = {
|
|
7
6
|
mouse: 8,
|
|
@@ -28,12 +27,6 @@ export const OMIT_SIDES_FOR_FRAME = {
|
|
|
28
27
|
w: true,
|
|
29
28
|
rotation: true,
|
|
30
29
|
};
|
|
31
|
-
const OMIT_SIDES_FOR_TEXT_ELEMENT = {
|
|
32
|
-
e: true,
|
|
33
|
-
s: true,
|
|
34
|
-
n: true,
|
|
35
|
-
w: true,
|
|
36
|
-
};
|
|
37
30
|
const OMIT_SIDES_FOR_LINE_SLASH = {
|
|
38
31
|
e: true,
|
|
39
32
|
s: true,
|
|
@@ -123,7 +116,9 @@ export const getTransformHandles = (element, zoom, elementsMap, pointerType = "m
|
|
|
123
116
|
// so that when locked element is selected (especially when you toggle lock
|
|
124
117
|
// via keyboard) the locked element is visually distinct, indicating
|
|
125
118
|
// you can't move/resize
|
|
126
|
-
if (element.locked
|
|
119
|
+
if (element.locked ||
|
|
120
|
+
// Elbow arrows cannot be rotated
|
|
121
|
+
isElbowArrow(element)) {
|
|
127
122
|
return {};
|
|
128
123
|
}
|
|
129
124
|
if (element.type === "freedraw" || isLinearElement(element)) {
|
|
@@ -147,9 +142,6 @@ export const getTransformHandles = (element, zoom, elementsMap, pointerType = "m
|
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
|
-
else if (isTextElement(element)) {
|
|
151
|
-
omitSides = OMIT_SIDES_FOR_TEXT_ELEMENT;
|
|
152
|
-
}
|
|
153
145
|
else if (isFrameLikeElement(element)) {
|
|
154
146
|
omitSides = {
|
|
155
147
|
...omitSides,
|
|
@@ -169,6 +161,9 @@ export const shouldShowBoundingBox = (elements, appState) => {
|
|
|
169
161
|
return true;
|
|
170
162
|
}
|
|
171
163
|
const element = elements[0];
|
|
164
|
+
if (isElbowArrow(element)) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
172
167
|
if (!isLinearElement(element)) {
|
|
173
168
|
return true;
|
|
174
169
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ElementOrToolType } from "../types";
|
|
2
|
-
import { MarkNonNullable } from "../utility-types";
|
|
3
|
-
import { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement } from "./types";
|
|
1
|
+
import type { ElementOrToolType } from "../types";
|
|
2
|
+
import type { MarkNonNullable } from "../utility-types";
|
|
3
|
+
import type { ExcalidrawElement, ExcalidrawTextElement, ExcalidrawEmbeddableElement, ExcalidrawLinearElement, ExcalidrawBindableElement, ExcalidrawFreeDrawElement, InitializedExcalidrawImageElement, ExcalidrawImageElement, ExcalidrawTextElementWithContainer, ExcalidrawTextContainer, ExcalidrawFrameElement, RoundnessType, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeElement, ExcalidrawIframeLikeElement, ExcalidrawMagicFrameElement, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, PointBinding, FixedPointBinding } from "./types";
|
|
4
4
|
export declare const isInitializedImageElement: (element: ExcalidrawElement | null) => element is InitializedExcalidrawImageElement;
|
|
5
5
|
export declare const isImageElement: (element: ExcalidrawElement | null) => element is ExcalidrawImageElement;
|
|
6
6
|
export declare const isEmbeddableElement: (element: ExcalidrawElement | null | undefined) => element is ExcalidrawEmbeddableElement;
|
|
@@ -14,10 +14,12 @@ export declare const isFreeDrawElement: (element?: ExcalidrawElement | null) =>
|
|
|
14
14
|
export declare const isFreeDrawElementType: (elementType: ExcalidrawElementType) => boolean;
|
|
15
15
|
export declare const isLinearElement: (element?: ExcalidrawElement | null) => element is ExcalidrawLinearElement;
|
|
16
16
|
export declare const isArrowElement: (element?: ExcalidrawElement | null) => element is ExcalidrawArrowElement;
|
|
17
|
+
export declare const isElbowArrow: (element?: ExcalidrawElement) => element is ExcalidrawElbowArrowElement;
|
|
17
18
|
export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
|
|
18
19
|
export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
|
|
19
20
|
export declare const isBindingElementType: (elementType: ElementOrToolType) => boolean;
|
|
20
|
-
export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
21
|
+
export declare const isBindableElement: (element: ExcalidrawElement | null | undefined, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
22
|
+
export declare const isRectanguloidElement: (element?: ExcalidrawElement | null) => element is ExcalidrawBindableElement;
|
|
21
23
|
export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
|
|
22
24
|
export declare const isExcalidrawElement: (element: any) => element is ExcalidrawElement;
|
|
23
25
|
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
|
|
@@ -30,3 +32,4 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
|
|
|
30
32
|
} | {
|
|
31
33
|
type: 3;
|
|
32
34
|
} | null;
|
|
35
|
+
export declare const isFixedPointBinding: (binding: PointBinding) => binding is FixedPointBinding;
|
|
@@ -40,6 +40,9 @@ export const isLinearElement = (element) => {
|
|
|
40
40
|
export const isArrowElement = (element) => {
|
|
41
41
|
return element != null && element.type === "arrow";
|
|
42
42
|
};
|
|
43
|
+
export const isElbowArrow = (element) => {
|
|
44
|
+
return isArrowElement(element) && element.elbowed;
|
|
45
|
+
};
|
|
43
46
|
export const isLinearElementType = (elementType) => {
|
|
44
47
|
return (elementType === "arrow" || elementType === "line" // || elementType === "freedraw"
|
|
45
48
|
);
|
|
@@ -65,6 +68,17 @@ export const isBindableElement = (element, includeLocked = true) => {
|
|
|
65
68
|
element.type === "magicframe" ||
|
|
66
69
|
(element.type === "text" && !element.containerId)));
|
|
67
70
|
};
|
|
71
|
+
export const isRectanguloidElement = (element) => {
|
|
72
|
+
return (element != null &&
|
|
73
|
+
(element.type === "rectangle" ||
|
|
74
|
+
element.type === "diamond" ||
|
|
75
|
+
element.type === "image" ||
|
|
76
|
+
element.type === "iframe" ||
|
|
77
|
+
element.type === "embeddable" ||
|
|
78
|
+
element.type === "frame" ||
|
|
79
|
+
element.type === "magicframe" ||
|
|
80
|
+
(element.type === "text" && !element.containerId)));
|
|
81
|
+
};
|
|
68
82
|
export const isTextBindableContainer = (element, includeLocked = true) => {
|
|
69
83
|
return (element != null &&
|
|
70
84
|
(!element.locked || includeLocked === true) &&
|
|
@@ -142,3 +156,6 @@ export const getDefaultRoundnessTypeForElement = (element) => {
|
|
|
142
156
|
}
|
|
143
157
|
return null;
|
|
144
158
|
};
|
|
159
|
+
export const isFixedPointBinding = (binding) => {
|
|
160
|
+
return binding.fixedPoint != null;
|
|
161
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Point } from "../types";
|
|
2
|
-
import { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
|
-
import { MakeBrand, MarkNonNullable, ValueOf } from "../utility-types";
|
|
4
|
-
import { MagicCacheData } from "../data/magic";
|
|
1
|
+
import type { Point } from "../types";
|
|
2
|
+
import type { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
|
|
3
|
+
import type { MakeBrand, MarkNonNullable, Merge, ValueOf } from "../utility-types";
|
|
4
|
+
import type { MagicCacheData } from "../data/magic";
|
|
5
5
|
export type ChartType = "bar" | "line";
|
|
6
6
|
export type FillStyle = "hachure" | "cross-hatch" | "solid" | "zigzag";
|
|
7
7
|
export type FontFamilyKeys = keyof typeof FONT_FAMILY;
|
|
@@ -154,6 +154,13 @@ export type ExcalidrawTextElement = _ExcalidrawElementBase & Readonly<{
|
|
|
154
154
|
verticalAlign: VerticalAlign;
|
|
155
155
|
containerId: ExcalidrawGenericElement["id"] | null;
|
|
156
156
|
originalText: string;
|
|
157
|
+
/**
|
|
158
|
+
* If `true` the width will fit the text. If `false`, the text will
|
|
159
|
+
* wrap to fit the width.
|
|
160
|
+
*
|
|
161
|
+
* @default true
|
|
162
|
+
*/
|
|
163
|
+
autoResize: boolean;
|
|
157
164
|
/**
|
|
158
165
|
* Unitless line height (aligned to W3C). To get line height in px, multiply
|
|
159
166
|
* with font size (using `getLineHeightInPx` helper).
|
|
@@ -167,11 +174,16 @@ export type ExcalidrawTextContainer = ExcalidrawRectangleElement | ExcalidrawDia
|
|
|
167
174
|
export type ExcalidrawTextElementWithContainer = {
|
|
168
175
|
containerId: ExcalidrawTextContainer["id"];
|
|
169
176
|
} & ExcalidrawTextElement;
|
|
177
|
+
export type FixedPoint = [number, number];
|
|
170
178
|
export type PointBinding = {
|
|
171
179
|
elementId: ExcalidrawBindableElement["id"];
|
|
172
180
|
focus: number;
|
|
173
181
|
gap: number;
|
|
182
|
+
fixedPoint: FixedPoint | null;
|
|
174
183
|
};
|
|
184
|
+
export type FixedPointBinding = Merge<PointBinding, {
|
|
185
|
+
fixedPoint: FixedPoint;
|
|
186
|
+
}>;
|
|
175
187
|
export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline";
|
|
176
188
|
export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
|
177
189
|
type: "line" | "arrow";
|
|
@@ -184,6 +196,12 @@ export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
|
|
184
196
|
}>;
|
|
185
197
|
export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
|
|
186
198
|
type: "arrow";
|
|
199
|
+
elbowed: boolean;
|
|
200
|
+
}>;
|
|
201
|
+
export type ExcalidrawElbowArrowElement = Merge<ExcalidrawArrowElement, {
|
|
202
|
+
elbowed: true;
|
|
203
|
+
startBinding: FixedPointBinding | null;
|
|
204
|
+
endBinding: FixedPointBinding | null;
|
|
187
205
|
}>;
|
|
188
206
|
export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
|
189
207
|
type: "freedraw";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface Font {
|
|
2
|
+
urls: URL[];
|
|
3
|
+
fontFace: FontFace;
|
|
4
|
+
getContent(): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare const UNPKG_PROD_URL: string;
|
|
7
|
+
export declare class ExcalidrawFont implements Font {
|
|
8
|
+
readonly urls: URL[];
|
|
9
|
+
readonly fontFace: FontFace;
|
|
10
|
+
constructor(family: string, uri: string, descriptors?: FontFaceDescriptors);
|
|
11
|
+
/**
|
|
12
|
+
* Tries to fetch woff2 content, based on the registered urls.
|
|
13
|
+
* Returns last defined url in case of errors.
|
|
14
|
+
*
|
|
15
|
+
* Note: uses browser APIs for base64 encoding - use dataurl outside the browser environment.
|
|
16
|
+
*/
|
|
17
|
+
getContent(): Promise<string>;
|
|
18
|
+
private static createUrls;
|
|
19
|
+
private static getFormat;
|
|
20
|
+
private static normalizeBaseUrl;
|
|
21
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { stringToBase64, toByteString } from "../data/encode";
|
|
2
|
+
import { LOCAL_FONT_PROTOCOL } from "./metadata";
|
|
3
|
+
export const UNPKG_PROD_URL = `https://unpkg.com/${import.meta.env.VITE_PKG_NAME
|
|
4
|
+
? `${import.meta.env.VITE_PKG_NAME}@${import.meta.env.PKG_VERSION}` // should be provided by vite during package build
|
|
5
|
+
: "@excalidraw/excalidraw" // fallback to latest package version (i.e. for app)
|
|
6
|
+
}/dist/prod/`;
|
|
7
|
+
export class ExcalidrawFont {
|
|
8
|
+
urls;
|
|
9
|
+
fontFace;
|
|
10
|
+
constructor(family, uri, descriptors) {
|
|
11
|
+
this.urls = ExcalidrawFont.createUrls(uri);
|
|
12
|
+
const sources = this.urls
|
|
13
|
+
.map((url) => `url(${url}) ${ExcalidrawFont.getFormat(url)}`)
|
|
14
|
+
.join(", ");
|
|
15
|
+
this.fontFace = new FontFace(family, sources, {
|
|
16
|
+
display: "swap",
|
|
17
|
+
style: "normal",
|
|
18
|
+
weight: "400",
|
|
19
|
+
...descriptors,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tries to fetch woff2 content, based on the registered urls.
|
|
24
|
+
* Returns last defined url in case of errors.
|
|
25
|
+
*
|
|
26
|
+
* Note: uses browser APIs for base64 encoding - use dataurl outside the browser environment.
|
|
27
|
+
*/
|
|
28
|
+
async getContent() {
|
|
29
|
+
let i = 0;
|
|
30
|
+
const errorMessages = [];
|
|
31
|
+
while (i < this.urls.length) {
|
|
32
|
+
const url = this.urls[i];
|
|
33
|
+
if (url.protocol === "data:") {
|
|
34
|
+
// it's dataurl, the font is inlined as base64, no need to fetch
|
|
35
|
+
return url.toString();
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
headers: {
|
|
40
|
+
Accept: "font/woff2",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
if (response.ok) {
|
|
44
|
+
const mimeType = await response.headers.get("Content-Type");
|
|
45
|
+
const buffer = await response.arrayBuffer();
|
|
46
|
+
return `data:${mimeType};base64,${await stringToBase64(await toByteString(buffer), true)}`;
|
|
47
|
+
}
|
|
48
|
+
// response not ok, try to continue
|
|
49
|
+
errorMessages.push(`"${url.toString()}" returned status "${response.status}"`);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
errorMessages.push(`"${url.toString()}" returned error "${e}"`);
|
|
53
|
+
}
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
console.error(`Failed to fetch font "${this.fontFace.family}" from urls "${this.urls.toString()}`, JSON.stringify(errorMessages, undefined, 2));
|
|
57
|
+
// in case of issues, at least return the last url as a content
|
|
58
|
+
// defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others
|
|
59
|
+
return this.urls.length ? this.urls[this.urls.length - 1].toString() : "";
|
|
60
|
+
}
|
|
61
|
+
static createUrls(uri) {
|
|
62
|
+
if (uri.startsWith(LOCAL_FONT_PROTOCOL)) {
|
|
63
|
+
// no url for local fonts
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
if (uri.startsWith("http") || uri.startsWith("data")) {
|
|
67
|
+
// one url for http imports or data url
|
|
68
|
+
return [new URL(uri)];
|
|
69
|
+
}
|
|
70
|
+
// absolute assets paths, which are found in tests and excalidraw-app build, won't work with base url, so we are stripping initial slash away
|
|
71
|
+
const assetUrl = uri.replace(/^\/+/, "");
|
|
72
|
+
const urls = [];
|
|
73
|
+
if (typeof window.EXCALIDRAW_ASSET_PATH === "string") {
|
|
74
|
+
const normalizedBaseUrl = this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);
|
|
75
|
+
urls.push(new URL(assetUrl, normalizedBaseUrl));
|
|
76
|
+
}
|
|
77
|
+
else if (Array.isArray(window.EXCALIDRAW_ASSET_PATH)) {
|
|
78
|
+
window.EXCALIDRAW_ASSET_PATH.forEach((path) => {
|
|
79
|
+
const normalizedBaseUrl = this.normalizeBaseUrl(path);
|
|
80
|
+
urls.push(new URL(assetUrl, normalizedBaseUrl));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// fallback url for bundled fonts
|
|
84
|
+
urls.push(new URL(assetUrl, UNPKG_PROD_URL));
|
|
85
|
+
return urls;
|
|
86
|
+
}
|
|
87
|
+
static getFormat(url) {
|
|
88
|
+
try {
|
|
89
|
+
const pathname = new URL(url).pathname;
|
|
90
|
+
const parts = pathname.split(".");
|
|
91
|
+
if (parts.length === 1) {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
return `format('${parts.pop()}')`;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
static normalizeBaseUrl(baseUrl) {
|
|
101
|
+
let result = baseUrl;
|
|
102
|
+
// in case user passed a root-relative url (~absolute path),
|
|
103
|
+
// like "/" or "/some/path", or relative (starts with "./"),
|
|
104
|
+
// prepend it with `location.origin`
|
|
105
|
+
if (/^\.?\//.test(result)) {
|
|
106
|
+
result = new URL(result.replace(/^\.?\/+/, ""), window?.location?.origin).toString();
|
|
107
|
+
}
|
|
108
|
+
// ensure there is a trailing slash, otherwise url won't be correctly concatenated
|
|
109
|
+
result = `${result.replace(/\/+$/, "")}/`;
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
}
|