@excalidraw/excalidraw 0.17.1-88812e0 → 0.17.1-96eeec5
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 +2 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-47LVF2XL.js → chunk-DEYXWPUO.js} +4933 -1520
- package/dist/browser/dev/excalidraw-assets-dev/chunk-DEYXWPUO.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-EM6LVGFW.js} +27 -4
- package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-6QVAH5JA.js} +36 -14
- package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-AZFA5HJJ.js} +4 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js → image-5XCR4WHS.js} +2 -2
- package/dist/browser/dev/index.css +157 -62
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +12016 -7663
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-7DXALCB2.js} +5 -5
- package/dist/browser/prod/excalidraw-assets/chunk-ODWTVSS7.js +68 -0
- package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-LQAMCFQI.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +69 -51
- package/dist/dev/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
- package/dist/dev/index.css +157 -62
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +18250 -16114
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
- package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/excalidraw/actions/actionBoundText.d.ts +14 -8
- package/dist/excalidraw/actions/actionBoundText.js +3 -1
- package/dist/excalidraw/actions/actionCanvas.d.ts +64 -28
- package/dist/excalidraw/actions/actionCanvas.js +1 -1
- package/dist/excalidraw/actions/actionClipboard.d.ts +40 -19
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +17 -8
- package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
- package/dist/excalidraw/actions/actionElementLock.d.ts +11 -5
- package/dist/excalidraw/actions/actionExport.d.ts +48 -21
- package/dist/excalidraw/actions/actionFinalize.d.ts +11 -5
- package/dist/excalidraw/actions/actionFinalize.js +1 -1
- package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/excalidraw/actions/actionFlip.js +5 -6
- package/dist/excalidraw/actions/actionFrame.d.ts +328 -8
- package/dist/excalidraw/actions/actionGroup.d.ts +320 -4
- package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
- package/dist/excalidraw/actions/actionHistory.js +4 -4
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +9 -4
- package/dist/excalidraw/actions/actionLinearEditor.js +19 -4
- package/dist/excalidraw/actions/actionLink.d.ts +5 -2
- package/dist/excalidraw/actions/actionMenu.d.ts +15 -6
- package/dist/excalidraw/actions/actionNavigate.d.ts +11 -5
- package/dist/excalidraw/actions/actionProperties.d.ts +67 -28
- package/dist/excalidraw/actions/actionProperties.js +1 -1
- package/dist/excalidraw/actions/actionSelectAll.d.ts +6 -3
- package/dist/excalidraw/actions/actionStyles.d.ts +9 -3
- package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
- package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +6 -3
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
- package/dist/excalidraw/actions/actionToggleStats.d.ts +6 -2
- package/dist/excalidraw/actions/actionToggleStats.js +4 -3
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
- 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/animated-trail.d.ts +2 -2
- package/dist/excalidraw/appState.d.ts +5 -2
- package/dist/excalidraw/appState.js +6 -3
- package/dist/excalidraw/change.d.ts +4 -4
- package/dist/excalidraw/change.js +14 -7
- package/dist/excalidraw/charts.d.ts +1 -1
- 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 +9 -6
- package/dist/excalidraw/components/App.d.ts +10 -16
- package/dist/excalidraw/components/App.js +190 -142
- package/dist/excalidraw/components/ButtonIconSelect.js +1 -1
- 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 +1 -1
- package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
- 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/HelpDialog.js +1 -1
- package/dist/excalidraw/components/HintViewer.d.ts +1 -1
- 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/PublishLibrary.d.ts +1 -1
- package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
- 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 +52 -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 +67 -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 +197 -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 +100 -0
- package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
- package/dist/excalidraw/components/Stats/Position.js +39 -0
- package/dist/excalidraw/components/Stats/index.d.ts +16 -0
- package/dist/excalidraw/components/Stats/index.js +78 -0
- package/dist/excalidraw/components/Stats/utils.d.ts +25 -0
- package/dist/excalidraw/components/Stats/utils.js +158 -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 +4 -4
- 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/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 +2 -2
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +2 -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 +6 -2
- package/dist/excalidraw/components/icons.js +22 -6
- package/dist/excalidraw/constants.d.ts +8 -2
- package/dist/excalidraw/constants.js +8 -1
- 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/resave.d.ts +2 -2
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +16 -1
- package/dist/excalidraw/data/transform.d.ts +3 -3
- 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 +7 -21
- package/dist/excalidraw/element/binding.js +127 -102
- package/dist/excalidraw/element/bounds.d.ts +3 -3
- package/dist/excalidraw/element/collision.d.ts +3 -3
- package/dist/excalidraw/element/collision.js +1 -1
- package/dist/excalidraw/element/containerCache.d.ts +1 -1
- package/dist/excalidraw/element/dragElements.d.ts +4 -4
- package/dist/excalidraw/element/dragElements.js +27 -3
- package/dist/excalidraw/element/embeddable.d.ts +8 -5
- 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 +8 -5
- package/dist/excalidraw/element/linearElementEditor.js +7 -4
- package/dist/excalidraw/element/mutateElement.d.ts +2 -2
- package/dist/excalidraw/element/mutateElement.js +1 -1
- package/dist/excalidraw/element/newElement.d.ts +5 -8
- package/dist/excalidraw/element/newElement.js +16 -14
- package/dist/excalidraw/element/resizeElements.d.ts +11 -3
- package/dist/excalidraw/element/resizeElements.js +75 -23
- package/dist/excalidraw/element/resizeTest.d.ts +4 -4
- package/dist/excalidraw/element/resizeTest.js +2 -4
- 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 +5 -4
- package/dist/excalidraw/element/textElement.js +11 -3
- package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
- package/dist/excalidraw/element/textWysiwyg.js +38 -17
- package/dist/excalidraw/element/transformHandles.d.ts +3 -3
- package/dist/excalidraw/element/transformHandles.js +0 -10
- package/dist/excalidraw/element/typeChecks.d.ts +4 -4
- package/dist/excalidraw/element/types.d.ts +11 -4
- package/dist/excalidraw/emitter.d.ts +1 -1
- package/dist/excalidraw/fractionalIndex.d.ts +1 -1
- package/dist/excalidraw/fractionalIndex.js +2 -4
- package/dist/excalidraw/frame.d.ts +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 +4 -4
- 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 +1 -1
- package/dist/excalidraw/jotai.d.ts +1 -1
- package/dist/excalidraw/laser-trails.d.ts +3 -2
- package/dist/excalidraw/locales/en.json +24 -3
- package/dist/excalidraw/math.d.ts +4 -2
- package/dist/excalidraw/math.js +6 -0
- package/dist/excalidraw/mermaid.d.ts +2 -0
- package/dist/excalidraw/mermaid.js +28 -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 +32 -6
- package/dist/excalidraw/renderer/renderElement.d.ts +4 -4
- package/dist/excalidraw/renderer/renderElement.js +5 -5
- 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/scene/Fonts.d.ts +2 -4
- package/dist/excalidraw/scene/Fonts.js +12 -15
- 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 +17 -8
- package/dist/excalidraw/scene/Shape.d.ts +1 -1
- package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
- package/dist/excalidraw/scene/comparisons.d.ts +2 -2
- package/dist/excalidraw/scene/export.d.ts +2 -2
- package/dist/excalidraw/scene/export.js +2 -2
- 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 +7 -0
- package/dist/excalidraw/shapes.js +40 -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 +25 -20
- package/dist/excalidraw/utils.d.ts +4 -4
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/prod/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +39 -39
- package/dist/utils/bbox.d.ts +2 -2
- package/dist/utils/collision.d.ts +1 -1
- package/dist/utils/export.d.ts +2 -2
- package/dist/utils/geometry/geometry.d.ts +1 -1
- package/dist/utils/geometry/shape.d.ts +1 -1
- package/dist/utils/withinBounds.d.ts +1 -1
- package/history.ts +4 -4
- package/package.json +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/chunk-47LVF2XL.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/excalidraw-assets/chunk-4SNEEDZH.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-ISQJGWLB.js +0 -1
- package/dist/excalidraw/components/Stats.d.ts +0 -11
- package/dist/excalidraw/components/Stats.js +0 -13
- /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-AZFA5HJJ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js.map → image-5XCR4WHS.js.map} +0 -0
|
@@ -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;
|
|
@@ -53,8 +53,6 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
53
53
|
let maxWidth = updatedTextElement.width;
|
|
54
54
|
let maxHeight = updatedTextElement.height;
|
|
55
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
56
|
const textElementHeight = updatedTextElement.height;
|
|
59
57
|
if (container && updatedTextElement.containerId) {
|
|
60
58
|
if (isArrowElement(container)) {
|
|
@@ -113,6 +111,9 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
113
111
|
maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value;
|
|
114
112
|
textElementWidth = Math.min(textElementWidth, maxWidth);
|
|
115
113
|
}
|
|
114
|
+
else {
|
|
115
|
+
textElementWidth += 0.5;
|
|
116
|
+
}
|
|
116
117
|
// Make sure text editor height doesn't go beyond viewport
|
|
117
118
|
const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;
|
|
118
119
|
Object.assign(editable.style, {
|
|
@@ -149,7 +150,7 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
149
150
|
editable.classList.add("excalidraw-wysiwyg");
|
|
150
151
|
let whiteSpace = "pre";
|
|
151
152
|
let wordBreak = "normal";
|
|
152
|
-
if (isBoundToContainer(element)) {
|
|
153
|
+
if (isBoundToContainer(element) || !element.autoResize) {
|
|
153
154
|
whiteSpace = "pre-wrap";
|
|
154
155
|
wordBreak = "break-word";
|
|
155
156
|
}
|
|
@@ -326,6 +327,11 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
326
327
|
// so that we don't need to create separate a callback for event handlers
|
|
327
328
|
let submittedViaKeyboard = false;
|
|
328
329
|
const handleSubmit = () => {
|
|
330
|
+
// prevent double submit
|
|
331
|
+
if (isDestroyed) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
isDestroyed = true;
|
|
329
335
|
// cleanup must be run before onSubmit otherwise when app blurs the wysiwyg
|
|
330
336
|
// it'd get stuck in an infinite loop of blur→onSubmit after we re-focus the
|
|
331
337
|
// wysiwyg on update
|
|
@@ -334,10 +340,8 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
334
340
|
if (!updateElement) {
|
|
335
341
|
return;
|
|
336
342
|
}
|
|
337
|
-
let text = editable.value;
|
|
338
343
|
const container = getContainerElement(updateElement, app.scene.getNonDeletedElementsMap());
|
|
339
344
|
if (container) {
|
|
340
|
-
text = updateElement.text;
|
|
341
345
|
if (editable.value.trim()) {
|
|
342
346
|
const boundTextElementId = getBoundTextElementId(container);
|
|
343
347
|
if (!boundTextElementId || boundTextElementId !== element.id) {
|
|
@@ -361,16 +365,11 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
361
365
|
redrawTextBoundingBox(updateElement, container, app.scene.getNonDeletedElementsMap());
|
|
362
366
|
}
|
|
363
367
|
onSubmit({
|
|
364
|
-
text,
|
|
365
368
|
viaKeyboard: submittedViaKeyboard,
|
|
366
|
-
|
|
369
|
+
nextOriginalText: editable.value,
|
|
367
370
|
});
|
|
368
371
|
};
|
|
369
372
|
const cleanup = () => {
|
|
370
|
-
if (isDestroyed) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
isDestroyed = true;
|
|
374
373
|
// remove events to ensure they don't late-fire
|
|
375
374
|
editable.onblur = null;
|
|
376
375
|
editable.oninput = null;
|
|
@@ -439,9 +438,24 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
439
438
|
// alt-tabbing away
|
|
440
439
|
window.addEventListener("blur", handleSubmit);
|
|
441
440
|
}
|
|
441
|
+
else if (event.target instanceof HTMLElement &&
|
|
442
|
+
!event.target.contains(editable) &&
|
|
443
|
+
// Vitest simply ignores stopPropagation, capture-mode, or rAF
|
|
444
|
+
// so without introducing crazier hacks, nothing we can do
|
|
445
|
+
!isTestEnv()) {
|
|
446
|
+
// On mobile, blur event doesn't seem to always fire correctly,
|
|
447
|
+
// so we want to also submit on pointerdown outside the wysiwyg.
|
|
448
|
+
// Done in the next frame to prevent pointerdown from creating a new text
|
|
449
|
+
// immediately (if tools locked) so that users on mobile have chance
|
|
450
|
+
// to submit first (to hide virtual keyboard).
|
|
451
|
+
// Note: revisit if we want to differ this behavior on Desktop
|
|
452
|
+
requestAnimationFrame(() => {
|
|
453
|
+
handleSubmit();
|
|
454
|
+
});
|
|
455
|
+
}
|
|
442
456
|
};
|
|
443
457
|
// handle updates of textElement properties of editing element
|
|
444
|
-
const unbindUpdate = Scene.getScene(element).
|
|
458
|
+
const unbindUpdate = Scene.getScene(element).onUpdate(() => {
|
|
445
459
|
updateWysiwygStyle();
|
|
446
460
|
const isColorPickerActive = !!document.activeElement?.closest(".color-picker-content");
|
|
447
461
|
if (!isColorPickerActive) {
|
|
@@ -450,9 +464,11 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
450
464
|
});
|
|
451
465
|
// ---------------------------------------------------------------------------
|
|
452
466
|
let isDestroyed = false;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
467
|
+
if (autoSelect) {
|
|
468
|
+
// select on init (focusing is done separately inside the bindBlurEvent()
|
|
469
|
+
// because we need it to happen *after* the blur event from `pointerdown`)
|
|
470
|
+
editable.select();
|
|
471
|
+
}
|
|
456
472
|
bindBlurEvent();
|
|
457
473
|
// reposition wysiwyg in case of canvas is resized. Using ResizeObserver
|
|
458
474
|
// is preferred so we catch changes from host, where window may not resize.
|
|
@@ -466,7 +482,12 @@ export const textWysiwyg = ({ id, onChange, onSubmit, getViewportCoords, element
|
|
|
466
482
|
else {
|
|
467
483
|
window.addEventListener("resize", updateWysiwygStyle);
|
|
468
484
|
}
|
|
469
|
-
|
|
485
|
+
editable.onpointerdown = (event) => event.stopPropagation();
|
|
486
|
+
// rAF (+ capture to by doubly sure) so we don't catch te pointerdown that
|
|
487
|
+
// triggered the wysiwyg
|
|
488
|
+
requestAnimationFrame(() => {
|
|
489
|
+
window.addEventListener("pointerdown", onPointerDown, { capture: true });
|
|
490
|
+
});
|
|
470
491
|
window.addEventListener("wheel", stopEvent, {
|
|
471
492
|
passive: false,
|
|
472
493
|
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,6 +1,5 @@
|
|
|
1
1
|
import { getElementAbsoluteCoords } from "./bounds";
|
|
2
2
|
import { rotate } from "../math";
|
|
3
|
-
import { isTextElement } from ".";
|
|
4
3
|
import { isFrameLikeElement, isLinearElement } from "./typeChecks";
|
|
5
4
|
import { DEFAULT_TRANSFORM_HANDLE_SPACING, isAndroid, isIOS, } from "../constants";
|
|
6
5
|
const transformHandleSizes = {
|
|
@@ -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,
|
|
@@ -147,9 +140,6 @@ export const getTransformHandles = (element, zoom, elementsMap, pointerType = "m
|
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
}
|
|
150
|
-
else if (isTextElement(element)) {
|
|
151
|
-
omitSides = OMIT_SIDES_FOR_TEXT_ELEMENT;
|
|
152
|
-
}
|
|
153
143
|
else if (isFrameLikeElement(element)) {
|
|
154
144
|
omitSides = {
|
|
155
145
|
...omitSides,
|
|
@@ -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 } 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;
|
|
@@ -17,7 +17,7 @@ export declare const isArrowElement: (element?: ExcalidrawElement | null) => ele
|
|
|
17
17
|
export declare const isLinearElementType: (elementType: ElementOrToolType) => boolean;
|
|
18
18
|
export declare const isBindingElement: (element?: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawLinearElement;
|
|
19
19
|
export declare const isBindingElementType: (elementType: ElementOrToolType) => boolean;
|
|
20
|
-
export declare const isBindableElement: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
20
|
+
export declare const isBindableElement: (element: ExcalidrawElement | null | undefined, includeLocked?: boolean) => element is ExcalidrawBindableElement;
|
|
21
21
|
export declare const isTextBindableContainer: (element: ExcalidrawElement | null, includeLocked?: boolean) => element is ExcalidrawTextContainer;
|
|
22
22
|
export declare const isExcalidrawElement: (element: any) => element is ExcalidrawElement;
|
|
23
23
|
export declare const hasBoundTextElement: (element: ExcalidrawElement | null) => element is MarkNonNullable<ExcalidrawBindableElement, "boundElements">;
|
|
@@ -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, 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).
|
|
@@ -97,12 +97,10 @@ const getMovedIndicesGroups = (elements, movedElements) => {
|
|
|
97
97
|
const indicesGroups = [];
|
|
98
98
|
let i = 0;
|
|
99
99
|
while (i < elements.length) {
|
|
100
|
-
if (movedElements.has(elements[i].id)
|
|
101
|
-
!isValidFractionalIndex(elements[i]?.index, elements[i - 1]?.index, elements[i + 1]?.index)) {
|
|
100
|
+
if (movedElements.has(elements[i].id)) {
|
|
102
101
|
const indicesGroup = [i - 1, i]; // push the lower bound index as the first item
|
|
103
102
|
while (++i < elements.length) {
|
|
104
|
-
if (!
|
|
105
|
-
!isValidFractionalIndex(elements[i]?.index, elements[i - 1]?.index, elements[i + 1]?.index))) {
|
|
103
|
+
if (!movedElements.has(elements[i].id)) {
|
|
106
104
|
break;
|
|
107
105
|
}
|
|
108
106
|
indicesGroup.push(i);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
-
import { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
|
|
1
|
+
import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./element/types";
|
|
2
|
+
import type { AppClassProperties, AppState, StaticCanvasAppState } from "./types";
|
|
3
3
|
import type { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
|
|
4
|
-
import { ReadonlySetLike } from "./utility-types";
|
|
4
|
+
import type { ReadonlySetLike } from "./utility-types";
|
|
5
5
|
export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], oldElements: readonly ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
6
6
|
export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
|
|
7
7
|
export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ElementsMapOrArray, ElementsMap } from "./element/types";
|
|
2
|
-
import { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
|
|
3
|
-
import { Mutable } from "./utility-types";
|
|
1
|
+
import type { GroupId, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ElementsMapOrArray, ElementsMap } from "./element/types";
|
|
2
|
+
import type { AppClassProperties, AppState, InteractiveCanvasAppState } from "./types";
|
|
3
|
+
import type { Mutable } from "./utility-types";
|
|
4
4
|
export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeleted<ExcalidrawElement>[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
|
|
5
5
|
export declare const selectGroupsForSelectedElements: {
|
|
6
6
|
(appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
|
|
@@ -29,5 +29,5 @@ export declare const removeFromSelectedGroups: (groupIds: ExcalidrawElement["gro
|
|
|
29
29
|
}) => string[];
|
|
30
30
|
export declare const getMaximumGroups: (elements: ExcalidrawElement[], elementsMap: ElementsMap) => ExcalidrawElement[][];
|
|
31
31
|
export declare const getNonDeletedGroupIds: (elements: ElementsMap) => Set<string>;
|
|
32
|
-
export declare const elementsAreInSameGroup: (elements: ExcalidrawElement[]) => boolean;
|
|
32
|
+
export declare const elementsAreInSameGroup: (elements: readonly ExcalidrawElement[]) => boolean;
|
|
33
33
|
export declare const isInGroup: (element: NonDeletedExcalidrawElement) => boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AppStateChange, ElementsChange } from "./change";
|
|
2
|
-
import { SceneElementsMap } from "./element/types";
|
|
1
|
+
import type { AppStateChange, ElementsChange } from "./change";
|
|
2
|
+
import type { SceneElementsMap } from "./element/types";
|
|
3
3
|
import { Emitter } from "./emitter";
|
|
4
|
-
import { Snapshot } from "./store";
|
|
5
|
-
import { AppState } from "./types";
|
|
4
|
+
import type { Snapshot } from "./store";
|
|
5
|
+
import type { AppState } from "./types";
|
|
6
6
|
export declare class HistoryChangedEvent {
|
|
7
7
|
readonly isUndoStackEmpty: boolean;
|
|
8
8
|
readonly isRedoStackEmpty: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Emitter } from "../emitter";
|
|
1
|
+
import type { Emitter } from "../emitter";
|
|
2
2
|
export declare const useEmitter: <TEvent extends unknown>(emitter: Emitter<[TEvent]>, initialState: TEvent) => TEvent;
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import "./css/app.scss";
|
|
3
3
|
import "./css/styles.scss";
|
|
4
4
|
import "../../public/fonts/fonts.css";
|
|
5
|
-
import { ExcalidrawProps } from "./types";
|
|
5
|
+
import type { ExcalidrawProps } from "./types";
|
|
6
6
|
import Footer from "./components/footer/FooterCenter";
|
|
7
7
|
import MainMenu from "./components/main-menu/MainMenu";
|
|
8
8
|
import WelcomeScreen from "./components/welcome-screen/WelcomeScreen";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Trail } from "./animated-trail";
|
|
2
|
+
import { AnimatedTrail } from "./animated-trail";
|
|
3
|
+
import type { AnimationFrameHandler } from "./animation-frame-handler";
|
|
3
4
|
import type App from "./components/App";
|
|
4
5
|
export declare class LaserTrails implements Trail {
|
|
5
6
|
private animationFrameHandler;
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
},
|
|
130
130
|
"lineEditor": {
|
|
131
131
|
"edit": "Edit line",
|
|
132
|
-
"
|
|
132
|
+
"editArrow": "Edit arrow"
|
|
133
133
|
},
|
|
134
134
|
"elementLock": {
|
|
135
135
|
"lock": "Lock",
|
|
@@ -148,7 +148,9 @@
|
|
|
148
148
|
"discordChat": "Discord chat",
|
|
149
149
|
"zoomToFitViewport": "Zoom to fit in viewport",
|
|
150
150
|
"zoomToFitSelection": "Zoom to fit selection",
|
|
151
|
-
"zoomToFit": "Zoom to fit all elements"
|
|
151
|
+
"zoomToFit": "Zoom to fit all elements",
|
|
152
|
+
"installPWA": "Install Excalidraw locally (PWA)",
|
|
153
|
+
"autoResize": "Enable text auto-resizing"
|
|
152
154
|
},
|
|
153
155
|
"library": {
|
|
154
156
|
"noItems": "No items added yet...",
|
|
@@ -268,6 +270,22 @@
|
|
|
268
270
|
"mermaidToExcalidraw": "Mermaid to Excalidraw",
|
|
269
271
|
"magicSettings": "AI settings"
|
|
270
272
|
},
|
|
273
|
+
"element": {
|
|
274
|
+
"rectangle": "Rectangle",
|
|
275
|
+
"diamond": "Diamond",
|
|
276
|
+
"ellipse": "Ellipse",
|
|
277
|
+
"arrow": "Arrow",
|
|
278
|
+
"line": "Line",
|
|
279
|
+
"freedraw": "Freedraw",
|
|
280
|
+
"text": "Text",
|
|
281
|
+
"image": "Image",
|
|
282
|
+
"group": "Group",
|
|
283
|
+
"frame": "Frame",
|
|
284
|
+
"magicframe": "Wireframe to code",
|
|
285
|
+
"embeddable": "Web Embed",
|
|
286
|
+
"selection": "Selection",
|
|
287
|
+
"iframe": "IFrame"
|
|
288
|
+
},
|
|
271
289
|
"headings": {
|
|
272
290
|
"canvasActions": "Canvas actions",
|
|
273
291
|
"selectedShapeActions": "Selected shape actions",
|
|
@@ -441,7 +459,10 @@
|
|
|
441
459
|
"scene": "Scene",
|
|
442
460
|
"selected": "Selected",
|
|
443
461
|
"storage": "Storage",
|
|
444
|
-
"
|
|
462
|
+
"fullTitle": "Stats & Element properties",
|
|
463
|
+
"title": "Stats",
|
|
464
|
+
"generalStats": "General stats",
|
|
465
|
+
"elementProperties": "Element properties",
|
|
445
466
|
"total": "Total",
|
|
446
467
|
"version": "Version",
|
|
447
468
|
"versionCopy": "Click to copy",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Point, Zoom } from "./types";
|
|
2
|
-
import { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./element/types";
|
|
1
|
+
import type { Point, Zoom } from "./types";
|
|
2
|
+
import type { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./element/types";
|
|
3
3
|
export declare const rotate: (x: number, y: number, cx: number, cy: number, angle: number) => [number, number];
|
|
4
4
|
export declare const rotatePoint: (point: readonly [number, number], center: readonly [number, number], angle: number) => [number, number];
|
|
5
5
|
export declare const adjustXYWithRotation: (sides: {
|
|
@@ -28,6 +28,8 @@ export declare const getBezierCurveLength: (element: NonDeleted<ExcalidrawLinear
|
|
|
28
28
|
export declare const mapIntervalToBezierT: (element: NonDeleted<ExcalidrawLinearElement>, endPoint: readonly [number, number], interval: number) => number;
|
|
29
29
|
export declare const arePointsEqual: (p1: readonly [number, number], p2: readonly [number, number]) => boolean;
|
|
30
30
|
export declare const isRightAngle: (angle: number) => boolean;
|
|
31
|
+
export declare const radianToDegree: (r: number) => number;
|
|
32
|
+
export declare const degreeToRadian: (d: number) => number;
|
|
31
33
|
export declare const rangesOverlap: ([a0, a1]: [number, number], [b0, b1]: [number, number]) => boolean;
|
|
32
34
|
export declare const rangeIntersection: (rangeA: [number, number], rangeB: [number, number]) => [number, number] | null;
|
|
33
35
|
export declare const isValueInRange: (value: number, min: number, max: number) => boolean;
|
package/dist/excalidraw/math.js
CHANGED
|
@@ -338,6 +338,12 @@ export const isRightAngle = (angle) => {
|
|
|
338
338
|
// angle, which we can check with modulo after rounding.
|
|
339
339
|
return Math.round((angle / Math.PI) * 10000) % 5000 === 0;
|
|
340
340
|
};
|
|
341
|
+
export const radianToDegree = (r) => {
|
|
342
|
+
return (r * 180) / Math.PI;
|
|
343
|
+
};
|
|
344
|
+
export const degreeToRadian = (d) => {
|
|
345
|
+
return (d / 180) * Math.PI;
|
|
346
|
+
};
|
|
341
347
|
// Given two ranges, return if the two ranges overlap with each other
|
|
342
348
|
// e.g. [1, 3] overlaps with [2, 4] while [1, 3] does not overlap with [4, 5]
|
|
343
349
|
export const rangesOverlap = ([a0, a1], [b0, b1]) => {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** heuristically checks whether the text may be a mermaid diagram definition */
|
|
2
|
+
export const isMaybeMermaidDefinition = (text) => {
|
|
3
|
+
const chartTypes = [
|
|
4
|
+
"flowchart",
|
|
5
|
+
"sequenceDiagram",
|
|
6
|
+
"classDiagram",
|
|
7
|
+
"stateDiagram",
|
|
8
|
+
"stateDiagram-v2",
|
|
9
|
+
"erDiagram",
|
|
10
|
+
"journey",
|
|
11
|
+
"gantt",
|
|
12
|
+
"pie",
|
|
13
|
+
"quadrantChart",
|
|
14
|
+
"requirementDiagram",
|
|
15
|
+
"gitGraph",
|
|
16
|
+
"C4Context",
|
|
17
|
+
"mindmap",
|
|
18
|
+
"timeline",
|
|
19
|
+
"zenuml",
|
|
20
|
+
"sankey",
|
|
21
|
+
"xychart",
|
|
22
|
+
"block",
|
|
23
|
+
];
|
|
24
|
+
const re = new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b${chartTypes
|
|
25
|
+
.map((x) => `${x}(-beta)?`)
|
|
26
|
+
.join("|")}\\b`);
|
|
27
|
+
return re.test(text.trim());
|
|
28
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StaticCanvasAppState, AppState } from "../types";
|
|
2
|
-
import { StaticCanvasRenderConfig } from "../scene/types";
|
|
1
|
+
import type { StaticCanvasAppState, AppState } from "../types";
|
|
2
|
+
import type { StaticCanvasRenderConfig } from "../scene/types";
|
|
3
3
|
export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke?: boolean) => void;
|
|
4
4
|
export declare const getNormalizedCanvasDimensions: (canvas: HTMLCanvasElement, scale: number) => [number, number];
|
|
5
5
|
export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normalizedHeight, theme, isExporting, viewBackgroundColor, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InteractiveSceneRenderConfig, RenderableElementsMap } from "../scene/types";
|
|
1
|
+
import type { InteractiveSceneRenderConfig, RenderableElementsMap } from "../scene/types";
|
|
2
2
|
/** throttled to animation framerate */
|
|
3
3
|
export declare const renderInteractiveSceneThrottled: {
|
|
4
4
|
(config: InteractiveSceneRenderConfig): void;
|
|
@@ -9,7 +9,7 @@ export declare const renderInteractiveSceneThrottled: {
|
|
|
9
9
|
* Interactive scene is the ui-canvas where we render bounding boxes, selections
|
|
10
10
|
* and other ui stuff.
|
|
11
11
|
*/
|
|
12
|
-
export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, scale, appState, renderConfig, device, }: InteractiveSceneRenderConfig) => {
|
|
12
|
+
export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, device, }: InteractiveSceneRenderConfig) => {
|
|
13
13
|
atLeastOneVisibleElement: boolean;
|
|
14
14
|
elementsMap: RenderableElementsMap;
|
|
15
15
|
scrollBars?: undefined;
|
|
@@ -8,11 +8,11 @@ import { getOmitSidesForDevice, shouldShowBoundingBox, } from "../element/transf
|
|
|
8
8
|
import { arrayToMap, throttleRAF } from "../utils";
|
|
9
9
|
import { DEFAULT_TRANSFORM_HANDLE_SPACING, FRAME_STYLE } from "../constants";
|
|
10
10
|
import { renderSnaps } from "../renderer/renderSnaps";
|
|
11
|
-
import { maxBindingGap
|
|
11
|
+
import { maxBindingGap } from "../element/binding";
|
|
12
12
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
13
13
|
import { bootstrapCanvas, fillCircle, getNormalizedCanvasDimensions, } from "./helpers";
|
|
14
14
|
import oc from "open-color";
|
|
15
|
-
import { isFrameLikeElement, isLinearElement } from "../element/typeChecks";
|
|
15
|
+
import { isFrameLikeElement, isLinearElement, isTextElement, } from "../element/typeChecks";
|
|
16
16
|
const renderLinearElementPointHighlight = (context, appState, elementsMap) => {
|
|
17
17
|
const { elementId, hoverPointIndex } = appState.selectedLinearElement;
|
|
18
18
|
if (appState.editingLinearElement?.selectedPointsIndices?.includes(hoverPointIndex)) {
|
|
@@ -124,10 +124,11 @@ const renderBindingHighlightForSuggestedPointBinding = (context, suggestedBindin
|
|
|
124
124
|
fillCircle(context, x, y, threshold);
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
|
-
const renderSelectionBorder = (context, appState, elementProperties
|
|
127
|
+
const renderSelectionBorder = (context, appState, elementProperties) => {
|
|
128
128
|
const { angle, elementX1, elementY1, elementX2, elementY2, selectionColors, cx, cy, dashed, activeEmbeddable, } = elementProperties;
|
|
129
129
|
const elementWidth = elementX2 - elementX1;
|
|
130
130
|
const elementHeight = elementY2 - elementY1;
|
|
131
|
+
const padding = DEFAULT_TRANSFORM_HANDLE_SPACING * 2;
|
|
131
132
|
const linePadding = padding / appState.zoom.value;
|
|
132
133
|
const lineWidth = 8 / appState.zoom.value;
|
|
133
134
|
const spaceWidth = 4 / appState.zoom.value;
|
|
@@ -264,7 +265,23 @@ const renderTransformHandles = (context, renderConfig, appState, transformHandle
|
|
|
264
265
|
}
|
|
265
266
|
});
|
|
266
267
|
};
|
|
267
|
-
const
|
|
268
|
+
const renderTextBox = (text, context, appState, selectionColor) => {
|
|
269
|
+
context.save();
|
|
270
|
+
const padding = (DEFAULT_TRANSFORM_HANDLE_SPACING * 2) / appState.zoom.value;
|
|
271
|
+
const width = text.width + padding * 2;
|
|
272
|
+
const height = text.height + padding * 2;
|
|
273
|
+
const cx = text.x + width / 2;
|
|
274
|
+
const cy = text.y + height / 2;
|
|
275
|
+
const shiftX = -(width / 2 + padding);
|
|
276
|
+
const shiftY = -(height / 2 + padding);
|
|
277
|
+
context.translate(cx + appState.scrollX, cy + appState.scrollY);
|
|
278
|
+
context.rotate(text.angle);
|
|
279
|
+
context.lineWidth = 1 / appState.zoom.value;
|
|
280
|
+
context.strokeStyle = selectionColor;
|
|
281
|
+
context.strokeRect(shiftX, shiftY, width, height);
|
|
282
|
+
context.restore();
|
|
283
|
+
};
|
|
284
|
+
const _renderInteractiveScene = ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, device, }) => {
|
|
268
285
|
if (canvas === null) {
|
|
269
286
|
return { atLeastOneVisibleElement: false, elementsMap };
|
|
270
287
|
}
|
|
@@ -295,12 +312,18 @@ const _renderInteractiveScene = ({ canvas, elementsMap, visibleElements, selecte
|
|
|
295
312
|
// Paint selection element
|
|
296
313
|
if (appState.selectionElement) {
|
|
297
314
|
try {
|
|
298
|
-
renderSelectionElement(appState.selectionElement, context, appState);
|
|
315
|
+
renderSelectionElement(appState.selectionElement, context, appState, renderConfig.selectionColor);
|
|
299
316
|
}
|
|
300
317
|
catch (error) {
|
|
301
318
|
console.error(error);
|
|
302
319
|
}
|
|
303
320
|
}
|
|
321
|
+
if (appState.editingElement && isTextElement(appState.editingElement)) {
|
|
322
|
+
const textElement = allElementsMap.get(appState.editingElement.id);
|
|
323
|
+
if (textElement && !textElement.autoResize) {
|
|
324
|
+
renderTextBox(textElement, context, appState, renderConfig.selectionColor);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
304
327
|
if (appState.isBindingEnabled) {
|
|
305
328
|
appState.suggestedBindings
|
|
306
329
|
.filter((binding) => binding != null)
|
|
@@ -405,7 +428,10 @@ const _renderInteractiveScene = ({ canvas, elementsMap, visibleElements, selecte
|
|
|
405
428
|
context.fillStyle = oc.white;
|
|
406
429
|
const transformHandles = getTransformHandles(selectedElements[0], appState.zoom, elementsMap, "mouse", // when we render we don't know which pointer type so use mouse,
|
|
407
430
|
getOmitSidesForDevice(device));
|
|
408
|
-
if (!appState.viewModeEnabled &&
|
|
431
|
+
if (!appState.viewModeEnabled &&
|
|
432
|
+
showBoundingBox &&
|
|
433
|
+
// do not show transform handles when text is being edited
|
|
434
|
+
!isTextElement(appState.editingElement)) {
|
|
409
435
|
renderTransformHandles(context, renderConfig, appState, transformHandles, selectedElements[0].angle);
|
|
410
436
|
}
|
|
411
437
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, NonDeletedSceneElementsMap } from "../element/types";
|
|
2
2
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
3
|
-
import { StaticCanvasRenderConfig, RenderableElementsMap } from "../scene/types";
|
|
4
|
-
import { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure } from "../types";
|
|
3
|
+
import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "../scene/types";
|
|
4
|
+
import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementsPendingErasure } from "../types";
|
|
5
5
|
export declare const IMAGE_INVERT_FILTER = "invert(100%) hue-rotate(180deg) saturate(1.25)";
|
|
6
6
|
export declare const getRenderOpacity: (element: ExcalidrawElement, containingFrame: ExcalidrawFrameLikeElement | null, elementsPendingErasure: ElementsPendingErasure) => number;
|
|
7
7
|
export interface ExcalidrawElementWithCanvas {
|
|
@@ -17,7 +17,7 @@ export interface ExcalidrawElementWithCanvas {
|
|
|
17
17
|
}
|
|
18
18
|
export declare const DEFAULT_LINK_SIZE = 14;
|
|
19
19
|
export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
|
|
20
|
-
export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
|
|
20
|
+
export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState, selectionColor: InteractiveCanvasRenderConfig["selectionColor"]) => void;
|
|
21
21
|
export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState) => void;
|
|
22
22
|
export declare const pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
|
|
23
23
|
export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
|