@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
|
@@ -24,7 +24,7 @@ const shouldResetImageFilter = (element, renderConfig, appState) => {
|
|
|
24
24
|
!isPendingImageElement(element, renderConfig) &&
|
|
25
25
|
renderConfig.imageCache.get(element.fileId)?.mimeType !== MIME_TYPES.svg);
|
|
26
26
|
};
|
|
27
|
-
const getCanvasPadding = (element) => element.type === "freedraw" ? element.strokeWidth * 12 :
|
|
27
|
+
const getCanvasPadding = (element) => element.type === "freedraw" ? element.strokeWidth * 12 : 200;
|
|
28
28
|
export const getRenderOpacity = (element, containingFrame, elementsPendingErasure) => {
|
|
29
29
|
// multiplying frame opacity with element opacity to combine them
|
|
30
30
|
// (e.g. frame 50% and element 50% opacity should result in 25% opacity)
|
|
@@ -119,7 +119,7 @@ const IMAGE_PLACEHOLDER_IMG = document.createElement("img");
|
|
|
119
119
|
IMAGE_PLACEHOLDER_IMG.src = `data:${MIME_TYPES.svg},${encodeURIComponent(`<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>`)}`;
|
|
120
120
|
const IMAGE_ERROR_PLACEHOLDER_IMG = document.createElement("img");
|
|
121
121
|
IMAGE_ERROR_PLACEHOLDER_IMG.src = `data:${MIME_TYPES.svg},${encodeURIComponent(`<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>`)}`;
|
|
122
|
-
const drawImagePlaceholder = (element, context
|
|
122
|
+
const drawImagePlaceholder = (element, context) => {
|
|
123
123
|
context.fillStyle = "#E7E7E7";
|
|
124
124
|
context.fillRect(0, 0, element.width, element.height);
|
|
125
125
|
const imageMinWidthOrHeight = Math.min(element.width, element.height);
|
|
@@ -176,7 +176,7 @@ const drawElementOnCanvas = (element, rc, context, renderConfig, appState) => {
|
|
|
176
176
|
context.drawImage(img, 0 /* hardcoded for the selection box*/, 0, element.width, element.height);
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
|
-
drawImagePlaceholder(element, context
|
|
179
|
+
drawImagePlaceholder(element, context);
|
|
180
180
|
}
|
|
181
181
|
break;
|
|
182
182
|
}
|
|
@@ -323,7 +323,7 @@ const drawElementFromCanvas = (elementWithCanvas, context, renderConfig, appStat
|
|
|
323
323
|
context.restore();
|
|
324
324
|
// Clear the nested element we appended to the DOM
|
|
325
325
|
};
|
|
326
|
-
export const renderSelectionElement = (element, context, appState) => {
|
|
326
|
+
export const renderSelectionElement = (element, context, appState, selectionColor) => {
|
|
327
327
|
context.save();
|
|
328
328
|
context.translate(element.x + appState.scrollX, element.y + appState.scrollY);
|
|
329
329
|
context.fillStyle = "rgba(0, 0, 200, 0.04)";
|
|
@@ -334,7 +334,7 @@ export const renderSelectionElement = (element, context, appState) => {
|
|
|
334
334
|
const offset = 0.5 / appState.zoom.value;
|
|
335
335
|
context.fillRect(offset, offset, element.width, element.height);
|
|
336
336
|
context.lineWidth = 1 / appState.zoom.value;
|
|
337
|
-
context.strokeStyle =
|
|
337
|
+
context.strokeStyle = selectionColor;
|
|
338
338
|
context.strokeRect(offset, offset, element.width, element.height);
|
|
339
339
|
context.restore();
|
|
340
340
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { InteractiveCanvasAppState } from "../types";
|
|
1
|
+
import type { InteractiveCanvasAppState } from "../types";
|
|
2
2
|
export declare const renderSnaps: (context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RoughSVG } from "roughjs/bin/svg";
|
|
2
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
3
|
-
import { RenderableElementsMap, SVGRenderConfig } from "../scene/types";
|
|
4
|
-
import { BinaryFiles } from "../types";
|
|
1
|
+
import type { RoughSVG } from "roughjs/bin/svg";
|
|
2
|
+
import type { NonDeletedExcalidrawElement } from "../element/types";
|
|
3
|
+
import type { RenderableElementsMap, SVGRenderConfig } from "../scene/types";
|
|
4
|
+
import type { BinaryFiles } from "../types";
|
|
5
5
|
export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], elementsMap: RenderableElementsMap, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, renderConfig: SVGRenderConfig) => void;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ExcalidrawElement } from "../element/types";
|
|
1
|
+
import type { ExcalidrawElement } from "../element/types";
|
|
2
2
|
import type Scene from "./Scene";
|
|
3
3
|
export declare class Fonts {
|
|
4
4
|
private scene;
|
|
5
|
-
|
|
6
|
-
constructor({ scene, onSceneUpdated, }: {
|
|
5
|
+
constructor({ scene }: {
|
|
7
6
|
scene: Scene;
|
|
8
|
-
onSceneUpdated: () => void;
|
|
9
7
|
});
|
|
10
8
|
private static loadedFontFaces;
|
|
11
9
|
/**
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { isTextElement
|
|
2
|
-
import { newElementWith } from "../element/mutateElement";
|
|
1
|
+
import { isTextElement } from "../element";
|
|
3
2
|
import { getContainerElement } from "../element/textElement";
|
|
4
|
-
import { isBoundToContainer } from "../element/typeChecks";
|
|
5
3
|
import { getFontString } from "../utils";
|
|
6
4
|
import { ShapeCache } from "./ShapeCache";
|
|
7
5
|
export class Fonts {
|
|
8
6
|
scene;
|
|
9
|
-
|
|
10
|
-
constructor({ scene, onSceneUpdated, }) {
|
|
7
|
+
constructor({ scene }) {
|
|
11
8
|
this.scene = scene;
|
|
12
|
-
this.onSceneUpdated = onSceneUpdated;
|
|
13
9
|
}
|
|
14
10
|
// it's ok to track fonts across multiple instances only once, so let's use
|
|
15
11
|
// a static member to reduce memory footprint
|
|
@@ -38,18 +34,19 @@ export class Fonts {
|
|
|
38
34
|
return false;
|
|
39
35
|
}
|
|
40
36
|
let didUpdate = false;
|
|
41
|
-
this.scene.
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const elementsMap = this.scene.getNonDeletedElementsMap();
|
|
38
|
+
for (const element of this.scene.getNonDeletedElements()) {
|
|
39
|
+
if (isTextElement(element)) {
|
|
44
40
|
didUpdate = true;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
ShapeCache.delete(element);
|
|
42
|
+
const container = getContainerElement(element, elementsMap);
|
|
43
|
+
if (container) {
|
|
44
|
+
ShapeCache.delete(container);
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
});
|
|
47
|
+
}
|
|
51
48
|
if (didUpdate) {
|
|
52
|
-
this.
|
|
49
|
+
this.scene.triggerUpdate();
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
52
|
loadFontsForElements = async (elements) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState } from "../types";
|
|
3
|
-
import Scene from "./Scene";
|
|
1
|
+
import type { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
+
import type { AppState } from "../types";
|
|
3
|
+
import type Scene from "./Scene";
|
|
4
4
|
export declare class Renderer {
|
|
5
5
|
private scene;
|
|
6
6
|
constructor(scene: Scene);
|
|
@@ -14,7 +14,7 @@ export declare class Renderer {
|
|
|
14
14
|
width: AppState["width"];
|
|
15
15
|
editingElement: AppState["editingElement"];
|
|
16
16
|
pendingImageElementId: AppState["pendingImageElementId"];
|
|
17
|
-
|
|
17
|
+
sceneNonce: ReturnType<InstanceType<typeof Scene>["getSceneNonce"]>;
|
|
18
18
|
}) => {
|
|
19
19
|
elementsMap: Map<string, NonDeletedExcalidrawElement> & import("../utility-types").MakeBrand<"NonDeletedElementsMap"> & import("../utility-types").MakeBrand<"RenderableElementsMap">;
|
|
20
20
|
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
@@ -45,9 +45,8 @@ export class Renderer {
|
|
|
45
45
|
return elementsMap;
|
|
46
46
|
};
|
|
47
47
|
return memoize(({ zoom, offsetLeft, offsetTop, scrollX, scrollY, height, width, editingElement, pendingImageElementId,
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
versionNonce: _versionNonce, }) => {
|
|
48
|
+
// cache-invalidation nonce
|
|
49
|
+
sceneNonce: _sceneNonce, }) => {
|
|
51
50
|
const elements = this.scene.getNonDeletedElements();
|
|
52
51
|
const elementsMap = getRenderableElements({
|
|
53
52
|
elements,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement, ElementsMapOrArray, OrderedExcalidrawElement, Ordered } from "../element/types";
|
|
2
|
-
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
3
|
-
import { AppState } from "../types";
|
|
1
|
+
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, ExcalidrawFrameLikeElement, ElementsMapOrArray, OrderedExcalidrawElement, Ordered } from "../element/types";
|
|
2
|
+
import type { LinearElementEditor } from "../element/linearElementEditor";
|
|
3
|
+
import type { AppState } from "../types";
|
|
4
4
|
type ElementIdKey = InstanceType<typeof LinearElementEditor>["elementId"];
|
|
5
5
|
type ElementKey = ExcalidrawElement | ElementIdKey;
|
|
6
6
|
type SceneStateCallback = () => void;
|
|
@@ -10,6 +10,9 @@ declare class Scene {
|
|
|
10
10
|
private static sceneMapByElement;
|
|
11
11
|
private static sceneMapById;
|
|
12
12
|
static mapElementToScene(elementKey: ElementKey, scene: Scene): void;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated pass down `app.scene` and use it directly
|
|
15
|
+
*/
|
|
13
16
|
static getScene(elementKey: ElementKey): Scene | null;
|
|
14
17
|
private callbacks;
|
|
15
18
|
private nonDeletedElements;
|
|
@@ -19,7 +22,14 @@ declare class Scene {
|
|
|
19
22
|
private frames;
|
|
20
23
|
private elementsMap;
|
|
21
24
|
private selectedElementsCache;
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Random integer regenerated each scene update.
|
|
27
|
+
*
|
|
28
|
+
* Does not relate to elements versions, it's only a renderer
|
|
29
|
+
* cache-invalidation nonce at the moment.
|
|
30
|
+
*/
|
|
31
|
+
private sceneNonce;
|
|
32
|
+
getSceneNonce(): number | undefined;
|
|
23
33
|
getNonDeletedElementsMap(): Map<string, Ordered<NonDeletedExcalidrawElement>> & import("../utility-types").MakeBrand<"NonDeletedSceneElementsMap">;
|
|
24
34
|
getElementsIncludingDeleted(): readonly OrderedExcalidrawElement[];
|
|
25
35
|
getElementsMapIncludingDeleted(): Map<string, Ordered<ExcalidrawElement>> & import("../utility-types").MakeBrand<"SceneElementsMap">;
|
|
@@ -38,7 +48,6 @@ declare class Scene {
|
|
|
38
48
|
}): NonDeleted<ExcalidrawElement>[];
|
|
39
49
|
getNonDeletedFramesLikes(): readonly NonDeleted<ExcalidrawFrameLikeElement>[];
|
|
40
50
|
getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
|
|
41
|
-
getVersionNonce(): number | undefined;
|
|
42
51
|
getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
|
|
43
52
|
/**
|
|
44
53
|
* A utility method to help with updating all scene elements, with the added
|
|
@@ -54,8 +63,8 @@ declare class Scene {
|
|
|
54
63
|
*/
|
|
55
64
|
mapElements(iteratee: (element: ExcalidrawElement) => ExcalidrawElement): boolean;
|
|
56
65
|
replaceAllElements(nextElements: ElementsMapOrArray): void;
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
triggerUpdate(): void;
|
|
67
|
+
onUpdate(cb: SceneStateCallback): SceneStateCallbackRemover;
|
|
59
68
|
destroy(): void;
|
|
60
69
|
insertElementAtIndex(element: ExcalidrawElement, index: number): void;
|
|
61
70
|
insertElementsAtIndex(elements: ExcalidrawElement[], index: number): void;
|
|
@@ -50,6 +50,9 @@ class Scene {
|
|
|
50
50
|
this.sceneMapById.set(elementKey.id, scene);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated pass down `app.scene` and use it directly
|
|
55
|
+
*/
|
|
53
56
|
static getScene(elementKey) {
|
|
54
57
|
if (isIdKey(elementKey)) {
|
|
55
58
|
return this.sceneMapById.get(elementKey) || null;
|
|
@@ -72,7 +75,16 @@ class Scene {
|
|
|
72
75
|
elements: null,
|
|
73
76
|
cache: new Map(),
|
|
74
77
|
};
|
|
75
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Random integer regenerated each scene update.
|
|
80
|
+
*
|
|
81
|
+
* Does not relate to elements versions, it's only a renderer
|
|
82
|
+
* cache-invalidation nonce at the moment.
|
|
83
|
+
*/
|
|
84
|
+
sceneNonce;
|
|
85
|
+
getSceneNonce() {
|
|
86
|
+
return this.sceneNonce;
|
|
87
|
+
}
|
|
76
88
|
getNonDeletedElementsMap() {
|
|
77
89
|
return this.nonDeletedElementsMap;
|
|
78
90
|
}
|
|
@@ -118,9 +130,6 @@ class Scene {
|
|
|
118
130
|
getElement(id) {
|
|
119
131
|
return this.elementsMap.get(id) || null;
|
|
120
132
|
}
|
|
121
|
-
getVersionNonce() {
|
|
122
|
-
return this.versionNonce;
|
|
123
|
-
}
|
|
124
133
|
getNonDeletedElement(id) {
|
|
125
134
|
const element = this.getElement(id);
|
|
126
135
|
if (element && isNonDeletedElement(element)) {
|
|
@@ -179,15 +188,15 @@ class Scene {
|
|
|
179
188
|
this.nonDeletedElementsMap = nonDeletedElements.elementsMap;
|
|
180
189
|
this.frames = nextFrameLikes;
|
|
181
190
|
this.nonDeletedFramesLikes = getNonDeletedElements(this.frames).elements;
|
|
182
|
-
this.
|
|
191
|
+
this.triggerUpdate();
|
|
183
192
|
}
|
|
184
|
-
|
|
185
|
-
this.
|
|
193
|
+
triggerUpdate() {
|
|
194
|
+
this.sceneNonce = randomInteger();
|
|
186
195
|
for (const callback of Array.from(this.callbacks)) {
|
|
187
196
|
callback();
|
|
188
197
|
}
|
|
189
198
|
}
|
|
190
|
-
|
|
199
|
+
onUpdate(cb) {
|
|
191
200
|
if (this.callbacks.has(cb)) {
|
|
192
201
|
throw new Error();
|
|
193
202
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Drawable, Options } from "roughjs/bin/core";
|
|
2
2
|
import type { RoughGenerator } from "roughjs/bin/generator";
|
|
3
3
|
import type { ExcalidrawElement, NonDeletedExcalidrawElement, ExcalidrawSelectionElement } from "../element/types";
|
|
4
|
-
import { EmbedsValidationStatus } from "../types";
|
|
4
|
+
import type { EmbedsValidationStatus } from "../types";
|
|
5
5
|
export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
|
|
6
6
|
/**
|
|
7
7
|
* Generates the roughjs shape for given element.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Drawable } from "roughjs/bin/core";
|
|
2
|
-
import { ExcalidrawElement } from "../element/types";
|
|
3
|
-
import { ElementShape, ElementShapes } from "./types";
|
|
4
|
-
import { AppState, EmbedsValidationStatus } from "../types";
|
|
1
|
+
import type { Drawable } from "roughjs/bin/core";
|
|
2
|
+
import type { ExcalidrawElement } from "../element/types";
|
|
3
|
+
import type { ElementShape, ElementShapes } from "./types";
|
|
4
|
+
import type { AppState, EmbedsValidationStatus } from "../types";
|
|
5
5
|
export declare class ShapeCache {
|
|
6
6
|
private static rg;
|
|
7
7
|
private static cache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { ElementOrToolType } from "../types";
|
|
1
|
+
import type { NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
+
import type { ElementOrToolType } from "../types";
|
|
3
3
|
export declare const hasBackground: (type: ElementOrToolType) => boolean;
|
|
4
4
|
export declare const hasStrokeColor: (type: ElementOrToolType) => boolean;
|
|
5
5
|
export declare const hasStrokeWidth: (type: ElementOrToolType) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState, BinaryFiles } from "../types";
|
|
1
|
+
import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
+
import type { AppState, BinaryFiles } from "../types";
|
|
3
3
|
export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, exportingFrame, }: {
|
|
4
4
|
exportBackground: boolean;
|
|
5
5
|
exportPadding?: number | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import rough from "roughjs/bin/rough";
|
|
2
|
-
import { getCommonBounds, getElementAbsoluteCoords
|
|
2
|
+
import { getCommonBounds, getElementAbsoluteCoords } from "../element/bounds";
|
|
3
3
|
import { renderSceneToSvg } from "../renderer/staticSvgScene";
|
|
4
4
|
import { arrayToMap, distance, getFontString, toBrandedType } from "../utils";
|
|
5
5
|
import { DEFAULT_EXPORT_PADDING, FONT_FAMILY, FRAME_STYLE, SVG_NS, THEME, THEME_FILTER, } from "../constants";
|
|
@@ -200,7 +200,7 @@ export const exportToSvg = async (elements, appState, files, opts) => {
|
|
|
200
200
|
if (import.meta.env.VITE_IS_EXCALIDRAW_NPM_PACKAGE) {
|
|
201
201
|
assetPath =
|
|
202
202
|
window.EXCALIDRAW_ASSET_PATH ||
|
|
203
|
-
`https://unpkg.com/${import.meta.env.VITE_PKG_NAME}@${import.meta.env.
|
|
203
|
+
`https://unpkg.com/${import.meta.env.VITE_PKG_NAME}@${import.meta.env.VITE_PKG_VERSION}`;
|
|
204
204
|
if (assetPath?.startsWith("/")) {
|
|
205
205
|
assetPath = assetPath.replace("/", `${window.location.origin}/`);
|
|
206
206
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppState, PointerCoords, Zoom } from "../types";
|
|
2
|
-
import { ExcalidrawElement } from "../element/types";
|
|
1
|
+
import type { AppState, PointerCoords, Zoom } from "../types";
|
|
2
|
+
import type { ExcalidrawElement } from "../element/types";
|
|
3
3
|
export declare const centerScrollOn: ({ scenePoint, viewportDimensions, zoom, }: {
|
|
4
4
|
scenePoint: PointerCoords;
|
|
5
5
|
viewportDimensions: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InteractiveCanvasAppState } from "../types";
|
|
2
|
-
import { ScrollBars } from "./types";
|
|
3
|
-
import { ExcalidrawElement } from "../element/types";
|
|
1
|
+
import type { InteractiveCanvasAppState } from "../types";
|
|
2
|
+
import type { ScrollBars } from "./types";
|
|
3
|
+
import type { ExcalidrawElement } from "../element/types";
|
|
4
4
|
export declare const SCROLLBAR_MARGIN = 4;
|
|
5
5
|
export declare const SCROLLBAR_WIDTH = 6;
|
|
6
6
|
export declare const SCROLLBAR_COLOR = "rgba(0,0,0,0.3)";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
-
import { AppState, InteractiveCanvasAppState } from "../types";
|
|
1
|
+
import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, NonDeletedExcalidrawElement } from "../element/types";
|
|
2
|
+
import type { AppState, InteractiveCanvasAppState } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Frames and their containing elements are not to be selected at the same time.
|
|
5
5
|
* Given an array of selected elements, if there are frames and their containing elements
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
2
|
-
import { Drawable } from "roughjs/bin/core";
|
|
3
|
-
import { ExcalidrawElement,
|
|
4
|
-
import { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, UserIdleState, Device } from "../types";
|
|
5
|
-
import { MakeBrand } from "../utility-types";
|
|
2
|
+
import type { Drawable } from "roughjs/bin/core";
|
|
3
|
+
import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "../element/types";
|
|
4
|
+
import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, UserIdleState, Device } from "../types";
|
|
5
|
+
import type { MakeBrand } from "../utility-types";
|
|
6
6
|
export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
|
|
7
7
|
export type StaticCanvasRenderConfig = {
|
|
8
8
|
canvasBackgroundColor: AppState["viewBackgroundColor"];
|
|
@@ -33,7 +33,7 @@ export type InteractiveCanvasRenderConfig = {
|
|
|
33
33
|
remotePointerUserStates: Map<SocketId, UserIdleState>;
|
|
34
34
|
remotePointerUsernames: Map<SocketId, string>;
|
|
35
35
|
remotePointerButton: Map<SocketId, string | undefined>;
|
|
36
|
-
selectionColor
|
|
36
|
+
selectionColor: string;
|
|
37
37
|
renderScrollbars?: boolean;
|
|
38
38
|
};
|
|
39
39
|
export type RenderInteractiveSceneCallback = {
|
|
@@ -56,6 +56,7 @@ export type InteractiveSceneRenderConfig = {
|
|
|
56
56
|
elementsMap: RenderableElementsMap;
|
|
57
57
|
visibleElements: readonly NonDeletedExcalidrawElement[];
|
|
58
58
|
selectedElements: readonly NonDeletedExcalidrawElement[];
|
|
59
|
+
allElementsMap: NonDeletedSceneElementsMap;
|
|
59
60
|
scale: number;
|
|
60
61
|
appState: InteractiveCanvasAppState;
|
|
61
62
|
renderConfig: InteractiveCanvasRenderConfig;
|
|
@@ -66,9 +67,6 @@ export type SceneScroll = {
|
|
|
66
67
|
scrollX: number;
|
|
67
68
|
scrollY: number;
|
|
68
69
|
};
|
|
69
|
-
export interface Scene {
|
|
70
|
-
elements: ExcalidrawTextElement[];
|
|
71
|
-
}
|
|
72
70
|
export type ExportType = "png" | "clipboard" | "clipboard-svg" | "backend" | "svg";
|
|
73
71
|
export type ScrollBars = {
|
|
74
72
|
horizontal: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppState, NormalizedZoomValue } from "../types";
|
|
1
|
+
import type { AppState, NormalizedZoomValue } from "../types";
|
|
2
2
|
export declare const getNormalizedZoom: (zoom: number) => NormalizedZoomValue;
|
|
3
3
|
export declare const getStateForZoom: ({ viewportX, viewportY, nextZoom, }: {
|
|
4
4
|
viewportX: number;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type GeometricShape } from "../utils/geometry/shape";
|
|
3
|
+
import type { ElementsMap, ExcalidrawElement } from "./element/types";
|
|
2
4
|
export declare const SHAPES: readonly [{
|
|
3
5
|
readonly icon: JSX.Element;
|
|
4
6
|
readonly value: "selection";
|
|
@@ -61,3 +63,8 @@ export declare const SHAPES: readonly [{
|
|
|
61
63
|
readonly fillable: false;
|
|
62
64
|
}];
|
|
63
65
|
export declare const findShapeByKey: (key: string) => "text" | "image" | "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "eraser" | null;
|
|
66
|
+
/**
|
|
67
|
+
* get the pure geometric shape of an excalidraw element
|
|
68
|
+
* which is then used for hit detection
|
|
69
|
+
*/
|
|
70
|
+
export declare const getElementShape: (element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { getClosedCurveShape, getCurveShape, getEllipseShape, getFreedrawShape, getPolygonShape, } from "../utils/geometry/shape";
|
|
1
2
|
import { ArrowIcon, DiamondIcon, EllipseIcon, EraserIcon, FreedrawIcon, ImageIcon, LineIcon, RectangleIcon, SelectionIcon, TextIcon, } from "./components/icons";
|
|
3
|
+
import { getElementAbsoluteCoords } from "./element";
|
|
4
|
+
import { shouldTestInside } from "./element/collision";
|
|
2
5
|
import { KEYS } from "./keys";
|
|
6
|
+
import { ShapeCache } from "./scene/ShapeCache";
|
|
3
7
|
export const SHAPES = [
|
|
4
8
|
{
|
|
5
9
|
icon: SelectionIcon,
|
|
@@ -82,3 +86,39 @@ export const findShapeByKey = (key) => {
|
|
|
82
86
|
});
|
|
83
87
|
return shape?.value || null;
|
|
84
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* get the pure geometric shape of an excalidraw element
|
|
91
|
+
* which is then used for hit detection
|
|
92
|
+
*/
|
|
93
|
+
export const getElementShape = (element, elementsMap) => {
|
|
94
|
+
switch (element.type) {
|
|
95
|
+
case "rectangle":
|
|
96
|
+
case "diamond":
|
|
97
|
+
case "frame":
|
|
98
|
+
case "magicframe":
|
|
99
|
+
case "embeddable":
|
|
100
|
+
case "image":
|
|
101
|
+
case "iframe":
|
|
102
|
+
case "text":
|
|
103
|
+
case "selection":
|
|
104
|
+
return getPolygonShape(element);
|
|
105
|
+
case "arrow":
|
|
106
|
+
case "line": {
|
|
107
|
+
const roughShape = ShapeCache.get(element)?.[0] ??
|
|
108
|
+
ShapeCache.generateElementShape(element, null)[0];
|
|
109
|
+
const [, , , , cx, cy] = getElementAbsoluteCoords(element, elementsMap);
|
|
110
|
+
return shouldTestInside(element)
|
|
111
|
+
? getClosedCurveShape(element, roughShape, [element.x, element.y], element.angle, [cx, cy])
|
|
112
|
+
: getCurveShape(roughShape, [element.x, element.y], element.angle, [
|
|
113
|
+
cx,
|
|
114
|
+
cy,
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
case "ellipse":
|
|
118
|
+
return getEllipseShape(element);
|
|
119
|
+
case "freedraw": {
|
|
120
|
+
const [, , , , cx, cy] = getElementAbsoluteCoords(element, elementsMap);
|
|
121
|
+
return getFreedrawShape(element, [cx, cy], shouldTestInside(element));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bounds } from "./element/bounds";
|
|
2
|
-
import { MaybeTransformHandleType } from "./element/transformHandles";
|
|
3
|
-
import { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
|
|
4
|
-
import { AppState, KeyboardModifiersObject, Point } from "./types";
|
|
1
|
+
import type { Bounds } from "./element/bounds";
|
|
2
|
+
import type { MaybeTransformHandleType } from "./element/transformHandles";
|
|
3
|
+
import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
|
|
4
|
+
import type { AppState, KeyboardModifiersObject, Point } from "./types";
|
|
5
5
|
export declare const getSnapDistance: (zoomValue: number) => number;
|
|
6
6
|
type Vector2D = {
|
|
7
7
|
x: number;
|
|
@@ -835,5 +835,6 @@ export const isActiveToolNonLinearSnappable = (activeToolType) => {
|
|
|
835
835
|
activeToolType === TOOL_TYPE.diamond ||
|
|
836
836
|
activeToolType === TOOL_TYPE.frame ||
|
|
837
837
|
activeToolType === TOOL_TYPE.magicframe ||
|
|
838
|
-
activeToolType === TOOL_TYPE.image
|
|
838
|
+
activeToolType === TOOL_TYPE.image ||
|
|
839
|
+
activeToolType === TOOL_TYPE.text);
|
|
839
840
|
};
|
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
import { AppStateChange, ElementsChange } from "./change";
|
|
2
|
-
import { OrderedExcalidrawElement } from "./element/types";
|
|
2
|
+
import type { OrderedExcalidrawElement } from "./element/types";
|
|
3
3
|
import { Emitter } from "./emitter";
|
|
4
|
-
import { AppState, ObservedAppState } from "./types";
|
|
4
|
+
import type { AppState, ObservedAppState } from "./types";
|
|
5
|
+
import type { ValueOf } from "./utility-types";
|
|
5
6
|
export declare const getObservedAppState: (appState: AppState) => ObservedAppState;
|
|
6
|
-
export type StoreActionType = "capture" | "update" | "none";
|
|
7
7
|
export declare const StoreAction: {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Immediately undoable.
|
|
10
|
+
*
|
|
11
|
+
* Use for updates which should be captured.
|
|
12
|
+
* Should be used for most of the local updates.
|
|
13
|
+
*
|
|
14
|
+
* These updates will _immediately_ make it to the local undo / redo stacks.
|
|
15
|
+
*/
|
|
16
|
+
readonly CAPTURE: "capture";
|
|
17
|
+
/**
|
|
18
|
+
* Never undoable.
|
|
19
|
+
*
|
|
20
|
+
* Use for updates which should never be recorded, such as remote updates
|
|
21
|
+
* or scene initialization.
|
|
22
|
+
*
|
|
23
|
+
* These updates will _never_ make it to the local undo / redo stacks.
|
|
24
|
+
*/
|
|
25
|
+
readonly UPDATE: "update";
|
|
26
|
+
/**
|
|
27
|
+
* Eventually undoable.
|
|
28
|
+
*
|
|
29
|
+
* Use for updates which should not be captured immediately - likely
|
|
30
|
+
* exceptions which are part of some async multi-step process. Otherwise, all
|
|
31
|
+
* such updates would end up being captured with the next
|
|
32
|
+
* `StoreAction.CAPTURE` - triggered either by the next `updateScene`
|
|
33
|
+
* or internally by the editor.
|
|
34
|
+
*
|
|
35
|
+
* These updates will _eventually_ make it to the local undo / redo stacks.
|
|
36
|
+
*/
|
|
37
|
+
readonly NONE: "none";
|
|
9
38
|
};
|
|
39
|
+
export type StoreActionType = ValueOf<typeof StoreAction>;
|
|
10
40
|
/**
|
|
11
41
|
* Represent an increment to the Store.
|
|
12
42
|
*/
|
package/dist/excalidraw/store.js
CHANGED
|
@@ -25,8 +25,35 @@ export const getObservedAppState = (appState) => {
|
|
|
25
25
|
};
|
|
26
26
|
const isObservedAppState = (appState) => !!Reflect.get(appState, hiddenObservedAppStateProp);
|
|
27
27
|
export const StoreAction = {
|
|
28
|
+
/**
|
|
29
|
+
* Immediately undoable.
|
|
30
|
+
*
|
|
31
|
+
* Use for updates which should be captured.
|
|
32
|
+
* Should be used for most of the local updates.
|
|
33
|
+
*
|
|
34
|
+
* These updates will _immediately_ make it to the local undo / redo stacks.
|
|
35
|
+
*/
|
|
28
36
|
CAPTURE: "capture",
|
|
37
|
+
/**
|
|
38
|
+
* Never undoable.
|
|
39
|
+
*
|
|
40
|
+
* Use for updates which should never be recorded, such as remote updates
|
|
41
|
+
* or scene initialization.
|
|
42
|
+
*
|
|
43
|
+
* These updates will _never_ make it to the local undo / redo stacks.
|
|
44
|
+
*/
|
|
29
45
|
UPDATE: "update",
|
|
46
|
+
/**
|
|
47
|
+
* Eventually undoable.
|
|
48
|
+
*
|
|
49
|
+
* Use for updates which should not be captured immediately - likely
|
|
50
|
+
* exceptions which are part of some async multi-step process. Otherwise, all
|
|
51
|
+
* such updates would end up being captured with the next
|
|
52
|
+
* `StoreAction.CAPTURE` - triggered either by the next `updateScene`
|
|
53
|
+
* or internally by the editor.
|
|
54
|
+
*
|
|
55
|
+
* These updates will _eventually_ make it to the local undo / redo stacks.
|
|
56
|
+
*/
|
|
30
57
|
NONE: "none",
|
|
31
58
|
};
|
|
32
59
|
/**
|