@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer,
|
|
2
|
-
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
-
import { AppState } from "../types";
|
|
4
|
-
import { ExtractSetType
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
|
+
import type { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
+
import type { AppState } from "../types";
|
|
4
|
+
import type { ExtractSetType } from "../utility-types";
|
|
5
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
6
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
|
|
7
7
|
export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
@@ -26,12 +26,8 @@ export declare const detectLineHeight: (textElement: ExcalidrawTextElement) => n
|
|
|
26
26
|
* aligning with the W3C spec.
|
|
27
27
|
*/
|
|
28
28
|
export declare const getLineHeightInPx: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
29
|
-
/**
|
|
30
|
-
* Calculates vertical offset for a text with alphabetic baseline.
|
|
31
|
-
*/
|
|
32
|
-
export declare const getVerticalOffset: (fontFamily: ExcalidrawTextElement["fontFamily"], fontSize: ExcalidrawTextElement["fontSize"], lineHeightPx: number) => number;
|
|
33
29
|
export declare const getApproxMinLineHeight: (fontSize: ExcalidrawTextElement["fontSize"], lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
34
|
-
export declare const getTextWidth: (text: string, font: FontString) => number;
|
|
30
|
+
export declare const getTextWidth: (text: string, font: FontString, forceAdvanceWidth?: true) => number;
|
|
35
31
|
export declare const getTextHeight: (text: string, fontSize: number, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
36
32
|
export declare const parseTokens: (text: string) => string[];
|
|
37
33
|
export declare const wrapText: (text: string, font: FontString, maxWidth: number) => string;
|
|
@@ -42,7 +38,6 @@ export declare const charWidth: {
|
|
|
42
38
|
export declare const getApproxMinLineWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
43
39
|
export declare const getMinCharWidth: (font: FontString) => number;
|
|
44
40
|
export declare const getMaxCharWidth: (font: FontString) => number;
|
|
45
|
-
export declare const getApproxCharsToFitInWidth: (font: FontString, width: number) => number;
|
|
46
41
|
export declare const getBoundTextElementId: (container: ExcalidrawElement | null) => string | null;
|
|
47
42
|
export declare const getBoundTextElement: (element: ExcalidrawElement | null, elementsMap: ElementsMap) => ExcalidrawTextElementWithContainer | null;
|
|
48
43
|
export declare const getContainerElement: (element: ExcalidrawTextElement | null, elementsMap: ElementsMap) => ExcalidrawTextContainer | null;
|
|
@@ -69,22 +64,5 @@ export declare const computeContainerDimensionForBoundText: (dimension: number,
|
|
|
69
64
|
export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElement | null) => number;
|
|
70
65
|
export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
|
|
71
66
|
export declare const isMeasureTextSupported: () => boolean;
|
|
72
|
-
|
|
73
|
-
type sTypoAscender = number & MakeBrand<"sTypoAscender">;
|
|
74
|
-
/** OS/2 sTypoDescender, https://learn.microsoft.com/en-us/typography/opentype/spec/os2#stypodescender */
|
|
75
|
-
type sTypoDescender = number & MakeBrand<"sTypoDescender">;
|
|
76
|
-
/**
|
|
77
|
-
* Hardcoded metrics for default fonts, read by https://opentype.js.org/font-inspector.html.
|
|
78
|
-
* For custom fonts, read these metrics from OS/2 table and extend this object.
|
|
79
|
-
*
|
|
80
|
-
* WARN: opentype does NOT open WOFF2 correctly, make sure to convert WOFF2 to TTF first.
|
|
81
|
-
*/
|
|
82
|
-
export declare const FONT_METRICS: Record<number, {
|
|
83
|
-
unitsPerEm: number;
|
|
84
|
-
ascender: sTypoAscender;
|
|
85
|
-
descender: sTypoDescender;
|
|
86
|
-
}>;
|
|
87
|
-
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
88
|
-
_brand: "unitlessLineHeight";
|
|
89
|
-
};
|
|
67
|
+
export declare const getMinTextElementWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
90
68
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getFontString, arrayToMap, isTestEnv, normalizeEOL } from "../utils";
|
|
2
2
|
import { mutateElement } from "./mutateElement";
|
|
3
|
-
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE,
|
|
3
|
+
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, TEXT_ALIGN, VERTICAL_ALIGN, } from "../constants";
|
|
4
4
|
import { isTextElement } from ".";
|
|
5
5
|
import { isBoundToContainer, isArrowElement } from "./typeChecks";
|
|
6
6
|
import { LinearElementEditor } from "./linearElementEditor";
|
|
@@ -24,12 +24,17 @@ export const redrawTextBoundingBox = (textElement, container, elementsMap, infor
|
|
|
24
24
|
angle: container?.angle ?? textElement.angle,
|
|
25
25
|
};
|
|
26
26
|
boundTextUpdates.text = textElement.text;
|
|
27
|
-
if (container) {
|
|
28
|
-
maxWidth =
|
|
27
|
+
if (container || !textElement.autoResize) {
|
|
28
|
+
maxWidth = container
|
|
29
|
+
? getBoundTextMaxWidth(container, textElement)
|
|
30
|
+
: textElement.width;
|
|
29
31
|
boundTextUpdates.text = wrapText(textElement.originalText, getFontString(textElement), maxWidth);
|
|
30
32
|
}
|
|
31
33
|
const metrics = measureText(boundTextUpdates.text, getFontString(textElement), textElement.lineHeight);
|
|
32
|
-
|
|
34
|
+
// Note: only update width for unwrapped text and bound texts (which always have autoResize set to true)
|
|
35
|
+
if (textElement.autoResize) {
|
|
36
|
+
boundTextUpdates.width = metrics.width;
|
|
37
|
+
}
|
|
33
38
|
boundTextUpdates.height = metrics.height;
|
|
34
39
|
if (container) {
|
|
35
40
|
const maxContainerHeight = getBoundTextMaxHeight(container, textElement);
|
|
@@ -196,41 +201,58 @@ export const detectLineHeight = (textElement) => {
|
|
|
196
201
|
export const getLineHeightInPx = (fontSize, lineHeight) => {
|
|
197
202
|
return fontSize * lineHeight;
|
|
198
203
|
};
|
|
199
|
-
/**
|
|
200
|
-
* Calculates vertical offset for a text with alphabetic baseline.
|
|
201
|
-
*/
|
|
202
|
-
export const getVerticalOffset = (fontFamily, fontSize, lineHeightPx) => {
|
|
203
|
-
const { unitsPerEm, ascender, descender } = FONT_METRICS[fontFamily] || FONT_METRICS[FONT_FAMILY.Helvetica];
|
|
204
|
-
const fontSizeEm = fontSize / unitsPerEm;
|
|
205
|
-
const lineGap = lineHeightPx - fontSizeEm * ascender + fontSizeEm * descender;
|
|
206
|
-
const verticalOffset = fontSizeEm * ascender + lineGap;
|
|
207
|
-
return verticalOffset;
|
|
208
|
-
};
|
|
209
204
|
// FIXME rename to getApproxMinContainerHeight
|
|
210
205
|
export const getApproxMinLineHeight = (fontSize, lineHeight) => {
|
|
211
206
|
return getLineHeightInPx(fontSize, lineHeight) + BOUND_TEXT_PADDING * 2;
|
|
212
207
|
};
|
|
213
208
|
let canvas;
|
|
214
|
-
|
|
209
|
+
/**
|
|
210
|
+
* @param forceAdvanceWidth use to force retrieve the "advance width" ~ `metrics.width`, instead of the actual boundind box width.
|
|
211
|
+
*
|
|
212
|
+
* > The advance width is the distance between the glyph's initial pen position and the next glyph's initial pen position.
|
|
213
|
+
*
|
|
214
|
+
* We need to use the advance width as that's the closest thing to the browser wrapping algo, hence using it for:
|
|
215
|
+
* - text wrapping
|
|
216
|
+
* - wysiwyg editor (+padding)
|
|
217
|
+
*
|
|
218
|
+
* Everything else should be based on the actual bounding box width.
|
|
219
|
+
*
|
|
220
|
+
* `Math.ceil` of the final width adds additional buffer which stabilizes slight wrapping incosistencies.
|
|
221
|
+
*/
|
|
222
|
+
const getLineWidth = (text, font, forceAdvanceWidth) => {
|
|
215
223
|
if (!canvas) {
|
|
216
224
|
canvas = document.createElement("canvas");
|
|
217
225
|
}
|
|
218
226
|
const canvas2dContext = canvas.getContext("2d");
|
|
219
227
|
canvas2dContext.font = font;
|
|
220
|
-
const
|
|
228
|
+
const metrics = canvas2dContext.measureText(text);
|
|
229
|
+
const advanceWidth = metrics.width;
|
|
230
|
+
// retrieve the actual bounding box width if these metrics are available (as of now > 95% coverage)
|
|
231
|
+
if (!forceAdvanceWidth &&
|
|
232
|
+
window.TextMetrics &&
|
|
233
|
+
"actualBoundingBoxLeft" in window.TextMetrics.prototype &&
|
|
234
|
+
"actualBoundingBoxRight" in window.TextMetrics.prototype) {
|
|
235
|
+
// could be negative, therefore getting the absolute value
|
|
236
|
+
const actualWidth = Math.abs(metrics.actualBoundingBoxLeft) +
|
|
237
|
+
Math.abs(metrics.actualBoundingBoxRight);
|
|
238
|
+
// fallback to advance width if the actual width is zero, i.e. on text editing start
|
|
239
|
+
// or when actual width does not respect whitespace chars, i.e. spaces
|
|
240
|
+
// otherwise actual width should always be bigger
|
|
241
|
+
return Math.max(actualWidth, advanceWidth);
|
|
242
|
+
}
|
|
221
243
|
// since in test env the canvas measureText algo
|
|
222
244
|
// doesn't measure text and instead just returns number of
|
|
223
245
|
// characters hence we assume that each letteris 10px
|
|
224
246
|
if (isTestEnv()) {
|
|
225
|
-
return
|
|
247
|
+
return advanceWidth * 10;
|
|
226
248
|
}
|
|
227
|
-
return
|
|
249
|
+
return advanceWidth;
|
|
228
250
|
};
|
|
229
|
-
export const getTextWidth = (text, font) => {
|
|
251
|
+
export const getTextWidth = (text, font, forceAdvanceWidth) => {
|
|
230
252
|
const lines = splitIntoLines(text);
|
|
231
253
|
let width = 0;
|
|
232
254
|
lines.forEach((line) => {
|
|
233
|
-
width = Math.max(width, getLineWidth(line, font));
|
|
255
|
+
width = Math.max(width, getLineWidth(line, font, forceAdvanceWidth));
|
|
234
256
|
});
|
|
235
257
|
return width;
|
|
236
258
|
};
|
|
@@ -264,7 +286,7 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
264
286
|
}
|
|
265
287
|
const lines = [];
|
|
266
288
|
const originalLines = text.split("\n");
|
|
267
|
-
const
|
|
289
|
+
const spaceAdvanceWidth = getLineWidth(" ", font, true);
|
|
268
290
|
let currentLine = "";
|
|
269
291
|
let currentLineWidthTillNow = 0;
|
|
270
292
|
const push = (str) => {
|
|
@@ -276,18 +298,18 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
276
298
|
currentLine = "";
|
|
277
299
|
currentLineWidthTillNow = 0;
|
|
278
300
|
};
|
|
279
|
-
|
|
280
|
-
const currentLineWidth =
|
|
301
|
+
for (const originalLine of originalLines) {
|
|
302
|
+
const currentLineWidth = getLineWidth(originalLine, font, true);
|
|
281
303
|
// Push the line if its <= maxWidth
|
|
282
304
|
if (currentLineWidth <= maxWidth) {
|
|
283
305
|
lines.push(originalLine);
|
|
284
|
-
|
|
306
|
+
continue;
|
|
285
307
|
}
|
|
286
308
|
const words = parseTokens(originalLine);
|
|
287
309
|
resetParams();
|
|
288
310
|
let index = 0;
|
|
289
311
|
while (index < words.length) {
|
|
290
|
-
const currentWordWidth = getLineWidth(words[index], font);
|
|
312
|
+
const currentWordWidth = getLineWidth(words[index], font, true);
|
|
291
313
|
// This will only happen when single word takes entire width
|
|
292
314
|
if (currentWordWidth === maxWidth) {
|
|
293
315
|
push(words[index]);
|
|
@@ -301,20 +323,24 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
301
323
|
resetParams();
|
|
302
324
|
while (words[index].length > 0) {
|
|
303
325
|
const currentChar = String.fromCodePoint(words[index].codePointAt(0));
|
|
304
|
-
const
|
|
305
|
-
|
|
326
|
+
const line = currentLine + currentChar;
|
|
327
|
+
// use advance width instead of the actual width as it's closest to the browser wapping algo
|
|
328
|
+
// use width of the whole line instead of calculating individual chars to accomodate for kerning
|
|
329
|
+
const lineAdvanceWidth = getLineWidth(line, font, true);
|
|
330
|
+
const charAdvanceWidth = charWidth.calculate(currentChar, font);
|
|
331
|
+
currentLineWidthTillNow = lineAdvanceWidth;
|
|
306
332
|
words[index] = words[index].slice(currentChar.length);
|
|
307
333
|
if (currentLineWidthTillNow >= maxWidth) {
|
|
308
334
|
push(currentLine);
|
|
309
335
|
currentLine = currentChar;
|
|
310
|
-
currentLineWidthTillNow =
|
|
336
|
+
currentLineWidthTillNow = charAdvanceWidth;
|
|
311
337
|
}
|
|
312
338
|
else {
|
|
313
|
-
currentLine
|
|
339
|
+
currentLine = line;
|
|
314
340
|
}
|
|
315
341
|
}
|
|
316
342
|
// push current line if appending space exceeds max width
|
|
317
|
-
if (currentLineWidthTillNow +
|
|
343
|
+
if (currentLineWidthTillNow + spaceAdvanceWidth >= maxWidth) {
|
|
318
344
|
push(currentLine);
|
|
319
345
|
resetParams();
|
|
320
346
|
// space needs to be appended before next word
|
|
@@ -324,7 +350,7 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
324
350
|
}
|
|
325
351
|
else if (!currentLine.endsWith("-")) {
|
|
326
352
|
currentLine += " ";
|
|
327
|
-
currentLineWidthTillNow +=
|
|
353
|
+
currentLineWidthTillNow += spaceAdvanceWidth;
|
|
328
354
|
}
|
|
329
355
|
index++;
|
|
330
356
|
}
|
|
@@ -332,7 +358,7 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
332
358
|
// Start appending words in a line till max width reached
|
|
333
359
|
while (currentLineWidthTillNow < maxWidth && index < words.length) {
|
|
334
360
|
const word = words[index];
|
|
335
|
-
currentLineWidthTillNow = getLineWidth(currentLine + word, font);
|
|
361
|
+
currentLineWidthTillNow = getLineWidth(currentLine + word, font, true);
|
|
336
362
|
if (currentLineWidthTillNow > maxWidth) {
|
|
337
363
|
push(currentLine);
|
|
338
364
|
resetParams();
|
|
@@ -347,7 +373,7 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
347
373
|
currentLine += " ";
|
|
348
374
|
}
|
|
349
375
|
// Push the word if appending space exceeds max width
|
|
350
|
-
if (currentLineWidthTillNow +
|
|
376
|
+
if (currentLineWidthTillNow + spaceAdvanceWidth >= maxWidth) {
|
|
351
377
|
if (shouldAppendSpace) {
|
|
352
378
|
lines.push(currentLine.slice(0, -1));
|
|
353
379
|
}
|
|
@@ -365,7 +391,7 @@ export const wrapText = (text, font, maxWidth) => {
|
|
|
365
391
|
currentLine = currentLine.slice(0, -1);
|
|
366
392
|
push(currentLine);
|
|
367
393
|
}
|
|
368
|
-
}
|
|
394
|
+
}
|
|
369
395
|
return lines.join("\n");
|
|
370
396
|
};
|
|
371
397
|
export const charWidth = (() => {
|
|
@@ -376,7 +402,7 @@ export const charWidth = (() => {
|
|
|
376
402
|
cachedCharWidth[font] = [];
|
|
377
403
|
}
|
|
378
404
|
if (!cachedCharWidth[font][ascii]) {
|
|
379
|
-
const width = getLineWidth(char, font);
|
|
405
|
+
const width = getLineWidth(char, font, true);
|
|
380
406
|
cachedCharWidth[font][ascii] = width;
|
|
381
407
|
}
|
|
382
408
|
return cachedCharWidth[font][ascii];
|
|
@@ -415,32 +441,9 @@ export const getMaxCharWidth = (font) => {
|
|
|
415
441
|
const cacheWithOutEmpty = cache.filter((val) => val !== undefined);
|
|
416
442
|
return Math.max(...cacheWithOutEmpty);
|
|
417
443
|
};
|
|
418
|
-
export const getApproxCharsToFitInWidth = (font, width) => {
|
|
419
|
-
// Generally lower case is used so converting to lower case
|
|
420
|
-
const dummyText = DUMMY_TEXT.toLocaleLowerCase();
|
|
421
|
-
const batchLength = 6;
|
|
422
|
-
let index = 0;
|
|
423
|
-
let widthTillNow = 0;
|
|
424
|
-
let str = "";
|
|
425
|
-
while (widthTillNow <= width) {
|
|
426
|
-
const batch = dummyText.substr(index, index + batchLength);
|
|
427
|
-
str += batch;
|
|
428
|
-
widthTillNow += getLineWidth(str, font);
|
|
429
|
-
if (index === dummyText.length - 1) {
|
|
430
|
-
index = 0;
|
|
431
|
-
}
|
|
432
|
-
index = index + batchLength;
|
|
433
|
-
}
|
|
434
|
-
while (widthTillNow > width) {
|
|
435
|
-
str = str.substr(0, str.length - 1);
|
|
436
|
-
widthTillNow = getLineWidth(str, font);
|
|
437
|
-
}
|
|
438
|
-
return str.length;
|
|
439
|
-
};
|
|
440
444
|
export const getBoundTextElementId = (container) => {
|
|
441
445
|
return container?.boundElements?.length
|
|
442
|
-
? container?.boundElements?.
|
|
443
|
-
null
|
|
446
|
+
? container?.boundElements?.find((ele) => ele.type === "text")?.id || null
|
|
444
447
|
: null;
|
|
445
448
|
};
|
|
446
449
|
export const getBoundTextElement = (element, elementsMap) => {
|
|
@@ -607,57 +610,6 @@ export const isMeasureTextSupported = () => {
|
|
|
607
610
|
}));
|
|
608
611
|
return width > 0;
|
|
609
612
|
};
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
*
|
|
613
|
-
* In previous versions we used `normal` line height, which browsers interpret
|
|
614
|
-
* differently, and based on font-family and font-size.
|
|
615
|
-
*
|
|
616
|
-
* To make line heights consistent across browsers we hardcode the values for
|
|
617
|
-
* each of our fonts based on most common average line-heights.
|
|
618
|
-
* See https://github.com/excalidraw/excalidraw/pull/6360#issuecomment-1477635971
|
|
619
|
-
* where the values come from.
|
|
620
|
-
*/
|
|
621
|
-
const DEFAULT_LINE_HEIGHT = {
|
|
622
|
-
// ~1.25 is the average for Virgil in WebKit and Blink.
|
|
623
|
-
// Gecko (FF) uses ~1.28.
|
|
624
|
-
[FONT_FAMILY.Virgil]: 1.25,
|
|
625
|
-
// ~1.15 is the average for Helvetica in WebKit and Blink.
|
|
626
|
-
[FONT_FAMILY.Helvetica]: 1.15,
|
|
627
|
-
// ~1.2 is the average for Cascadia in WebKit and Blink, and kinda Gecko too
|
|
628
|
-
[FONT_FAMILY.Cascadia]: 1.2,
|
|
629
|
-
};
|
|
630
|
-
/**
|
|
631
|
-
* Hardcoded metrics for default fonts, read by https://opentype.js.org/font-inspector.html.
|
|
632
|
-
* For custom fonts, read these metrics from OS/2 table and extend this object.
|
|
633
|
-
*
|
|
634
|
-
* WARN: opentype does NOT open WOFF2 correctly, make sure to convert WOFF2 to TTF first.
|
|
635
|
-
*/
|
|
636
|
-
export const FONT_METRICS = {
|
|
637
|
-
[FONT_FAMILY.Virgil]: {
|
|
638
|
-
unitsPerEm: 1000,
|
|
639
|
-
ascender: 886,
|
|
640
|
-
descender: -374,
|
|
641
|
-
},
|
|
642
|
-
[FONT_FAMILY.Helvetica]: {
|
|
643
|
-
unitsPerEm: 2048,
|
|
644
|
-
ascender: 1577,
|
|
645
|
-
descender: -471,
|
|
646
|
-
},
|
|
647
|
-
[FONT_FAMILY.Cascadia]: {
|
|
648
|
-
unitsPerEm: 2048,
|
|
649
|
-
ascender: 1977,
|
|
650
|
-
descender: -480,
|
|
651
|
-
},
|
|
652
|
-
[FONT_FAMILY.Assistant]: {
|
|
653
|
-
unitsPerEm: 1000,
|
|
654
|
-
ascender: 1021,
|
|
655
|
-
descender: -287,
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
export const getDefaultLineHeight = (fontFamily) => {
|
|
659
|
-
if (fontFamily in DEFAULT_LINE_HEIGHT) {
|
|
660
|
-
return DEFAULT_LINE_HEIGHT[fontFamily];
|
|
661
|
-
}
|
|
662
|
-
return DEFAULT_LINE_HEIGHT[DEFAULT_FONT_FAMILY];
|
|
613
|
+
export const getMinTextElementWidth = (font, lineHeight) => {
|
|
614
|
+
return measureText("", font, lineHeight).width + BOUND_TEXT_PADDING * 2;
|
|
663
615
|
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
2
|
-
import App from "../components/App";
|
|
3
|
-
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
2
|
+
import type App from "../components/App";
|
|
3
|
+
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
|
|
4
4
|
id: ExcalidrawElement["id"];
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* textWysiwyg only deals with `originalText`
|
|
7
|
+
*
|
|
8
|
+
* Note: `text`, which can be wrapped and therefore different from `originalText`,
|
|
9
|
+
* is derived from `originalText`
|
|
10
|
+
*/
|
|
11
|
+
onChange?: ((nextOriginalText: string) => void) | undefined;
|
|
6
12
|
onSubmit: (data: {
|
|
7
|
-
text: string;
|
|
8
13
|
viaKeyboard: boolean;
|
|
9
|
-
|
|
14
|
+
nextOriginalText: string;
|
|
10
15
|
}) => void;
|
|
11
16
|
getViewportCoords: (x: number, y: number) => [number, number];
|
|
12
17
|
element: ExcalidrawTextElement;
|
|
13
18
|
canvas: HTMLCanvasElement;
|
|
14
19
|
excalidrawContainer: HTMLDivElement | null;
|
|
15
20
|
app: App;
|
|
21
|
+
autoSelect?: boolean | undefined;
|
|
16
22
|
}) => void;
|