@snowcone-app/canvas 0.1.0
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/LICENSE.txt +70 -0
- package/README.md +357 -0
- package/dist/CanvasStateV1-D5GzvmnY.cjs +65 -0
- package/dist/CanvasStateV1-D5GzvmnY.cjs.map +1 -0
- package/dist/CanvasStateV1-ejb4d_LM.js +3692 -0
- package/dist/CanvasStateV1-ejb4d_LM.js.map +1 -0
- package/dist/ElementFactory-B7UOaJSD.cjs +23865 -0
- package/dist/ElementFactory-B7UOaJSD.cjs.map +1 -0
- package/dist/ElementFactory-uJTXU-nP.js +29615 -0
- package/dist/ElementFactory-uJTXU-nP.js.map +1 -0
- package/dist/HybridHistoryManager-BV6XV0nD.js +8048 -0
- package/dist/HybridHistoryManager-BV6XV0nD.js.map +1 -0
- package/dist/HybridHistoryManager-BXD93pp8.cjs +8 -0
- package/dist/HybridHistoryManager-BXD93pp8.cjs.map +1 -0
- package/dist/ImportManager-BYwuK6n4.cjs +2 -0
- package/dist/ImportManager-BYwuK6n4.cjs.map +1 -0
- package/dist/ImportManager-CxiaRg1N.js +222 -0
- package/dist/ImportManager-CxiaRg1N.js.map +1 -0
- package/dist/ThemeContext-4mJ_y0Me.cjs +2 -0
- package/dist/ThemeContext-4mJ_y0Me.cjs.map +1 -0
- package/dist/ThemeContext-H0Z-MqqR.js +1077 -0
- package/dist/ThemeContext-H0Z-MqqR.js.map +1 -0
- package/dist/advanced.d.ts +2 -0
- package/dist/advanced.js +48 -0
- package/dist/advanced.js.map +1 -0
- package/dist/advanced.mjs +15679 -0
- package/dist/advanced.mjs.map +1 -0
- package/dist/api/advanced.d.ts +110 -0
- package/dist/api/internals.d.ts +39 -0
- package/dist/api/stable.d.ts +44 -0
- package/dist/api/testing.d.ts +25 -0
- package/dist/browser-module-D0gHY9rY.cjs +9 -0
- package/dist/browser-module-D0gHY9rY.cjs.map +1 -0
- package/dist/browser-module-DFvKXBUE.js +15474 -0
- package/dist/browser-module-DFvKXBUE.js.map +1 -0
- package/dist/components/ArtboardDistressPanel.d.ts +7 -0
- package/dist/components/ArtboardImageMaskPanel.d.ts +7 -0
- package/dist/components/ArtboardPropertiesToolbar.d.ts +19 -0
- package/dist/components/ArtboardToolbar.d.ts +10 -0
- package/dist/components/BackButton.d.ts +7 -0
- package/dist/components/BackgroundPickerDropdown.d.ts +11 -0
- package/dist/components/BackgroundSwitcher.d.ts +7 -0
- package/dist/components/CanvasA11yFallback.d.ts +62 -0
- package/dist/components/CanvasEditor/CanvasRendererComponent.d.ts +51 -0
- package/dist/components/CanvasEditor/handlers/cropModeHandlers.d.ts +114 -0
- package/dist/components/CanvasEditor/handlers/groupChildHandlers.d.ts +65 -0
- package/dist/components/CanvasEditor/handlers/index.d.ts +10 -0
- package/dist/components/CanvasEditor/handlers/multiSelectionHandlers.d.ts +86 -0
- package/dist/components/CanvasEditor/hooks/buildSpreadClipShape.d.ts +20 -0
- package/dist/components/CanvasEditor/hooks/index.d.ts +24 -0
- package/dist/components/CanvasEditor/hooks/useActiveChild.d.ts +23 -0
- package/dist/components/CanvasEditor/hooks/useAnimatedFocusRect.d.ts +17 -0
- package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +284 -0
- package/dist/components/CanvasEditor/hooks/useCanvasLayout.d.ts +50 -0
- package/dist/components/CanvasEditor/hooks/useCanvasRenderLoop.d.ts +140 -0
- package/dist/components/CanvasEditor/hooks/useCropMode.d.ts +4 -0
- package/dist/components/CanvasEditor/hooks/useHoverState.d.ts +9 -0
- package/dist/components/CanvasEditor/hooks/useInteractionState.d.ts +23 -0
- package/dist/components/CanvasEditor/hooks/useKeyboardHandlers.d.ts +16 -0
- package/dist/components/CanvasEditor/hooks/useMarqueeSelection.d.ts +22 -0
- package/dist/components/CanvasEditor/hooks/useMultiSelection.d.ts +5 -0
- package/dist/components/CanvasEditor/hooks/usePenTool.d.ts +10 -0
- package/dist/components/CanvasEditor/hooks/useRenderState.d.ts +31 -0
- package/dist/components/CanvasEditor/hooks/useSnapAndSpacing.d.ts +42 -0
- package/dist/components/CanvasEditor/hooks/useTextEditing.d.ts +56 -0
- package/dist/components/CanvasEditor/hooks/useTextEditingHandlers.d.ts +75 -0
- package/dist/components/CanvasEditor/renderers/hoverRenderer.d.ts +12 -0
- package/dist/components/CanvasEditor/renderers/index.d.ts +10 -0
- package/dist/components/CanvasEditor/renderers/marqueeRenderer.d.ts +21 -0
- package/dist/components/CanvasEditor/renderers/multiSelectionRenderer.d.ts +52 -0
- package/dist/components/CanvasEditor/renderers/renderingConstants.d.ts +59 -0
- package/dist/components/CanvasEditor/types/index.d.ts +11 -0
- package/dist/components/CanvasEditor.d.ts +102 -0
- package/dist/components/ColorPickerDropdown.d.ts +29 -0
- package/dist/components/CompositingPanel.d.ts +8 -0
- package/dist/components/ContextualToolbars.d.ts +150 -0
- package/dist/components/CropPanel.d.ts +20 -0
- package/dist/components/DistressPanel.d.ts +7 -0
- package/dist/components/DocsPage.d.ts +6 -0
- package/dist/components/Drawer.d.ts +39 -0
- package/dist/components/EffectsPanel.d.ts +14 -0
- package/dist/components/ExportTestPanel.d.ts +16 -0
- package/dist/components/FontBrowserDrawer.d.ts +20 -0
- package/dist/components/FontSizeDropdown.d.ts +12 -0
- package/dist/components/GlyphBrowserDrawer.d.ts +13 -0
- package/dist/components/GlyphPicker.d.ts +14 -0
- package/dist/components/IconMatchTest.d.ts +3 -0
- package/dist/components/IconSizeTest.d.ts +3 -0
- package/dist/components/ImageBrowserDrawer.d.ts +27 -0
- package/dist/components/ImageToolbar.d.ts +47 -0
- package/dist/components/LayerEffects.d.ts +11 -0
- package/dist/components/LayerLeadingChip.d.ts +9 -0
- package/dist/components/LayersPanel.d.ts +30 -0
- package/dist/components/MaskItem.d.ts +12 -0
- package/dist/components/MasksPanel.d.ts +7 -0
- package/dist/components/MonotypeDemoPage.d.ts +2 -0
- package/dist/components/MoreMenu.d.ts +15 -0
- package/dist/components/OpenTypeFeaturesPanel.d.ts +12 -0
- package/dist/components/PathToolbar.d.ts +10 -0
- package/dist/components/PenToolDemo.d.ts +3 -0
- package/dist/components/ProgressiveBlur.d.ts +25 -0
- package/dist/components/RotationHandle.d.ts +47 -0
- package/dist/components/SaveLoadMenu.d.ts +15 -0
- package/dist/components/ShapeToolbar.d.ts +71 -0
- package/dist/components/ShapeTypeDrawer.d.ts +10 -0
- package/dist/components/StrokePanel.d.ts +7 -0
- package/dist/components/TailwindDemo.d.ts +3 -0
- package/dist/components/TextEffectsDropdown.d.ts +14 -0
- package/dist/components/TextToolbar.d.ts +47 -0
- package/dist/components/TextTypeDrawer.d.ts +8 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/TransformControlPanel.d.ts +12 -0
- package/dist/components/VisualGuideOverlay.d.ts +156 -0
- package/dist/components/embed/ArtboardTabs.d.ts +74 -0
- package/dist/components/embed/Canvas.d.ts +72 -0
- package/dist/components/embed/EffectsPanel.d.ts +76 -0
- package/dist/components/embed/ErrorBoundary.d.ts +34 -0
- package/dist/components/embed/ExportPanel.d.ts +51 -0
- package/dist/components/embed/GlyphPanel.d.ts +70 -0
- package/dist/components/embed/ImagePanel.d.ts +58 -0
- package/dist/components/embed/LayersPanel.d.ts +13 -0
- package/dist/components/embed/LoadingStates.d.ts +32 -0
- package/dist/components/embed/MenuButton.d.ts +47 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +844 -0
- package/dist/components/embed/ZoomControls.d.ts +16 -0
- package/dist/components/embed/index.d.ts +129 -0
- package/dist/components/embed/primitives/index.d.ts +42 -0
- package/dist/components/embed/ui/index.d.ts +52 -0
- package/dist/components/embed/utils/index.d.ts +31 -0
- package/dist/components/embedded/ArtboardEmbed.d.ts +70 -0
- package/dist/components/embedded/MerchifyThemeWrapper.d.ts +30 -0
- package/dist/components/embedded/ProductPreviewCard.d.ts +8 -0
- package/dist/components/embedded/index.d.ts +7 -0
- package/dist/components/primitives/ButtonGroup.d.ts +27 -0
- package/dist/components/primitives/ControlGroup.d.ts +15 -0
- package/dist/components/primitives/Dropdown.d.ts +27 -0
- package/dist/components/primitives/DropdownMenu.d.ts +9 -0
- package/dist/components/primitives/MenuItem.d.ts +13 -0
- package/dist/components/primitives/Panel.d.ts +25 -0
- package/dist/components/primitives/SecondaryToolbar.d.ts +9 -0
- package/dist/components/primitives/Switch.d.ts +10 -0
- package/dist/components/primitives/Toggle.d.ts +17 -0
- package/dist/components/primitives/index.d.ts +22 -0
- package/dist/components/stories/utils/MockEditorProvider.d.ts +32 -0
- package/dist/components/stories/utils/QACanvasCard.d.ts +41 -0
- package/dist/components/stories/utils/VisualQACard.d.ts +24 -0
- package/dist/components/stories/utils/element-factories.d.ts +188 -0
- package/dist/components/stories/utils/spec-to-elements.d.ts +74 -0
- package/dist/components/stories/utils/themeDecorator.d.ts +45 -0
- package/dist/components/stories/utils/unified-test-cases.d.ts +27 -0
- package/dist/components/text-toolbar/BoldButton.d.ts +5 -0
- package/dist/components/text-toolbar/FontColorButton.d.ts +6 -0
- package/dist/components/text-toolbar/FontSizeGroup.d.ts +5 -0
- package/dist/components/text-toolbar/ItalicButton.d.ts +5 -0
- package/dist/components/text-toolbar/TextAlignButton.d.ts +5 -0
- package/dist/components/text-toolbar/TextMoreMenu.d.ts +7 -0
- package/dist/components/text-toolbar/UnderlineButton.d.ts +5 -0
- package/dist/components/text-toolbar/UppercaseButton.d.ts +5 -0
- package/dist/components/text-toolbar/index.d.ts +25 -0
- package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +49 -0
- package/dist/components/toolbars/ExpandedPanelIcon.d.ts +13 -0
- package/dist/components/toolbars/FloatingPanels.d.ts +23 -0
- package/dist/components/toolbars/GroupElementToolbar.d.ts +35 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +125 -0
- package/dist/components/toolbars/index.d.ts +18 -0
- package/dist/components/toolbars/shared/ColorPanelWrapper.d.ts +9 -0
- package/dist/components/toolbars/shared/SecondaryPanelWrapper.d.ts +9 -0
- package/dist/components/ui/PresetCarousel.d.ts +21 -0
- package/dist/components/ui/SecondaryPanel.d.ts +28 -0
- package/dist/components/ui/SliderRow.d.ts +30 -0
- package/dist/components/ui/collapsed-toolbar-header.d.ts +14 -0
- package/dist/components/ui/custom-icons.d.ts +25 -0
- package/dist/components/ui/icons.d.ts +100 -0
- package/dist/components/ui/index.d.ts +48 -0
- package/dist/components/ui/normalized-icon.d.ts +63 -0
- package/dist/components/ui/toolbar-button.d.ts +24 -0
- package/dist/compose-Bo108juW.cjs +33 -0
- package/dist/compose-Bo108juW.cjs.map +1 -0
- package/dist/compose-DQ1FZS3O.js +7690 -0
- package/dist/compose-DQ1FZS3O.js.map +1 -0
- package/dist/constants.d.ts +121 -0
- package/dist/contexts/CommandContext.d.ts +87 -0
- package/dist/contexts/EditorContext.d.ts +190 -0
- package/dist/contexts/ElementsContext.d.ts +104 -0
- package/dist/contexts/HistoryContext.d.ts +60 -0
- package/dist/contexts/KitContext.d.ts +50 -0
- package/dist/contexts/SelectionContext.d.ts +51 -0
- package/dist/contexts/ThemeContext.d.ts +55 -0
- package/dist/contexts/ToolStateContext.d.ts +60 -0
- package/dist/contexts/ViewportContext.d.ts +87 -0
- package/dist/core/AlignmentSnapSystem.d.ts +270 -0
- package/dist/core/ArtboardElement.d.ts +106 -0
- package/dist/core/ArtboardManager.d.ts +130 -0
- package/dist/core/ArtboardRenderer.d.ts +97 -0
- package/dist/core/BaseElement.d.ts +94 -0
- package/dist/core/CanvasRenderer.d.ts +237 -0
- package/dist/core/CommandHistory.d.ts +173 -0
- package/dist/core/CoordinateTransform.d.ts +69 -0
- package/dist/core/CropModeController.d.ts +90 -0
- package/dist/core/EditModeRenderer.d.ts +51 -0
- package/dist/core/ElementFactory.d.ts +73 -0
- package/dist/core/ElementStore.d.ts +69 -0
- package/dist/core/EventBus.d.ts +163 -0
- package/dist/core/GeometryUtils.d.ts +247 -0
- package/dist/core/GroupElement.d.ts +134 -0
- package/dist/core/HoverRenderer.d.ts +103 -0
- package/dist/core/HybridHistoryManager.d.ts +137 -0
- package/dist/core/ImageCache.d.ts +63 -0
- package/dist/core/ImageElement.d.ts +226 -0
- package/dist/core/ImageLoadEvents.d.ts +23 -0
- package/dist/core/InteractionFeedbackRenderer.d.ts +15 -0
- package/dist/core/InteractionStateMachine.d.ts +199 -0
- package/dist/core/PathElement.d.ts +84 -0
- package/dist/core/PenToolManager.d.ts +112 -0
- package/dist/core/PinchHandler.d.ts +32 -0
- package/dist/core/ResizeHandler.d.ts +51 -0
- package/dist/core/ResizePipeline.d.ts +83 -0
- package/dist/core/ResizeUtils.d.ts +17 -0
- package/dist/core/RotationAnchorResolver.d.ts +60 -0
- package/dist/core/RotationUtils.d.ts +28 -0
- package/dist/core/SelectionRenderer.d.ts +24 -0
- package/dist/core/ShapeElement.d.ts +121 -0
- package/dist/core/SpacingSystem.d.ts +73 -0
- package/dist/core/SpatialGrid.d.ts +53 -0
- package/dist/core/TextElement.d.ts +80 -0
- package/dist/core/TextMetrics.d.ts +117 -0
- package/dist/core/Transform.d.ts +158 -0
- package/dist/core/TransformConverter.d.ts +16 -0
- package/dist/core/TransformHandles.d.ts +55 -0
- package/dist/core/artboardReducer.d.ts +46 -0
- package/dist/effects/DistressGenerator.d.ts +26 -0
- package/dist/effects/DistressTextureCache.d.ts +49 -0
- package/dist/effects/distress-presets.d.ts +86 -0
- package/dist/effects/distress-textures.d.ts +34 -0
- package/dist/effects/distress-utils.d.ts +39 -0
- package/dist/effects/mask-presets.d.ts +36 -0
- package/dist/fonts/google-fonts.d.ts +48 -0
- package/dist/google-fonts.json +1 -0
- package/dist/hooks/index.d.ts +42 -0
- package/dist/hooks/useArtboards.d.ts +71 -0
- package/dist/hooks/useAutoExport.d.ts +66 -0
- package/dist/hooks/useBreakpoint.d.ts +53 -0
- package/dist/hooks/useCanvasEvents.d.ts +8 -0
- package/dist/hooks/useCanvasReady.d.ts +22 -0
- package/dist/hooks/useClickOutside.d.ts +3 -0
- package/dist/hooks/useCommandHistory.d.ts +39 -0
- package/dist/hooks/useCommands.d.ts +47 -0
- package/dist/hooks/useContentReady.d.ts +18 -0
- package/dist/hooks/useElementById.d.ts +20 -0
- package/dist/hooks/useElementByName.d.ts +10 -0
- package/dist/hooks/useElementProperties.d.ts +29 -0
- package/dist/hooks/useExport.d.ts +89 -0
- package/dist/hooks/useImageBinding.d.ts +34 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +13 -0
- package/dist/hooks/useLayerDndKit.d.ts +24 -0
- package/dist/hooks/useLayerDragDrop.d.ts +58 -0
- package/dist/hooks/useLayerPreview.d.ts +31 -0
- package/dist/hooks/useLayerSelection.d.ts +76 -0
- package/dist/hooks/useLayers.d.ts +91 -0
- package/dist/hooks/usePerformance.d.ts +48 -0
- package/dist/hooks/useProjectLoader.d.ts +64 -0
- package/dist/hooks/useSelectedElement.d.ts +17 -0
- package/dist/hooks/useTextBinding.d.ts +26 -0
- package/dist/hooks/useTextToolbar.d.ts +61 -0
- package/dist/hooks/useViewport.d.ts +46 -0
- package/dist/icons/icon-data.d.ts +2 -0
- package/dist/icons/registry.d.ts +28 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1138 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internals.d.ts +2 -0
- package/dist/internals.js +2 -0
- package/dist/internals.js.map +1 -0
- package/dist/internals.mjs +219 -0
- package/dist/internals.mjs.map +1 -0
- package/dist/kits/compose.d.ts +69 -0
- package/dist/kits/index.d.ts +21 -0
- package/dist/kits/presets.d.ts +40 -0
- package/dist/kits/registry.d.ts +33 -0
- package/dist/kits/sections.d.ts +119 -0
- package/dist/kits/serialization.d.ts +78 -0
- package/dist/kits/types.d.ts +129 -0
- package/dist/kits/validation.d.ts +36 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/plugins/ElementTypePlugin.d.ts +90 -0
- package/dist/presets/artboard-color-presets.d.ts +22 -0
- package/dist/presets/tshirt-presets.d.ts +60 -0
- package/dist/rendering/CompositingRenderer.d.ts +33 -0
- package/dist/rendering/DistressTextureRenderer.d.ts +39 -0
- package/dist/rendering/ElementRenderUtils.d.ts +17 -0
- package/dist/rendering/MaskRenderer.d.ts +41 -0
- package/dist/rendering/PieceGuideRenderer.d.ts +177 -0
- package/dist/rendering/StrokeRenderer.d.ts +24 -0
- package/dist/rendering/canvas-renderer.d.ts +18 -0
- package/dist/rendering/element-serializer.d.ts +143 -0
- package/dist/rendering/image-renderer.d.ts +6 -0
- package/dist/rendering/knockout-utils.d.ts +48 -0
- package/dist/rendering/mask-utils.d.ts +65 -0
- package/dist/rendering/renderer-types.d.ts +79 -0
- package/dist/rendering/rich-text-renderer.d.ts +43 -0
- package/dist/rendering/serialize-for-server.d.ts +45 -0
- package/dist/rendering/shape-renderer.d.ts +6 -0
- package/dist/rendering/stroke-utils.d.ts +18 -0
- package/dist/rendering/text-renderer.d.ts +71 -0
- package/dist/rendering/transform-renderer.d.ts +33 -0
- package/dist/services/AutoExportManager.d.ts +107 -0
- package/dist/services/falApi.d.ts +63 -0
- package/dist/services/nounProjectApi.d.ts +90 -0
- package/dist/services/recraftApi.d.ts +65 -0
- package/dist/services/runwareApi.d.ts +69 -0
- package/dist/state/CanvasStateV1.d.ts +373 -0
- package/dist/state/index.d.ts +10 -0
- package/dist/style.css +1 -0
- package/dist/taco-reference-cropped.jpg +0 -0
- package/dist/testing/MockEditorProvider.d.ts +49 -0
- package/dist/testing/index.d.ts +25 -0
- package/dist/testing/utils.d.ts +128 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.mjs +140 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/textures/glass-frame.svg +32 -0
- package/dist/theme.d.ts +99 -0
- package/dist/themes/index.d.ts +23 -0
- package/dist/transforms/ArchTransform.d.ts +14 -0
- package/dist/transforms/AscendTransform.d.ts +14 -0
- package/dist/transforms/CircleTransform.d.ts +51 -0
- package/dist/transforms/CustomTransform.d.ts +81 -0
- package/dist/transforms/FlagTransform.d.ts +14 -0
- package/dist/transforms/LeanTransform.d.ts +14 -0
- package/dist/transforms/WaveTransform.d.ts +16 -0
- package/dist/transforms/defaults.d.ts +33 -0
- package/dist/transforms/index.d.ts +10 -0
- package/dist/transforms/registry.d.ts +51 -0
- package/dist/types/capabilities.d.ts +50 -0
- package/dist/types/guards.d.ts +31 -0
- package/dist/types/index.d.ts +765 -0
- package/dist/types/public.d.ts +31 -0
- package/dist/types/react.d.ts +132 -0
- package/dist/utils/ArtworkPlacement.d.ts +97 -0
- package/dist/utils/ElementPreviewRenderer.d.ts +19 -0
- package/dist/utils/ExportManager.d.ts +208 -0
- package/dist/utils/FontAnalyzer.d.ts +137 -0
- package/dist/utils/GlyphRenderer.d.ts +55 -0
- package/dist/utils/GoogleFontsService.d.ts +37 -0
- package/dist/utils/ImageLoader.d.ts +124 -0
- package/dist/utils/ImportManager.d.ts +72 -0
- package/dist/utils/MonotypeCategoryMapping.d.ts +36 -0
- package/dist/utils/MonotypeService.d.ts +148 -0
- package/dist/utils/PerformanceMonitor.d.ts +54 -0
- package/dist/utils/TextureManager.d.ts +60 -0
- package/dist/utils/UnifiedFontService.d.ts +117 -0
- package/dist/utils/WorkerExportManager.d.ts +185 -0
- package/dist/utils/clickProtection.d.ts +39 -0
- package/dist/utils/cn.d.ts +4 -0
- package/dist/utils/colorConversion.d.ts +101 -0
- package/dist/utils/documentColors.d.ts +108 -0
- package/dist/utils/featureApplied.d.ts +14 -0
- package/dist/utils/google-fonts-loader.d.ts +67 -0
- package/dist/utils/logger.d.ts +66 -0
- package/dist/utils/selectionPreservation.d.ts +42 -0
- package/dist/utils/textCursorUtils.d.ts +39 -0
- package/dist/utils/textUtils.d.ts +11 -0
- package/dist/workers/export-protocol.d.ts +119 -0
- package/dist/workers/export-worker.bundle.string.d.ts +2 -0
- package/dist/workers/export-worker.d.ts +5 -0
- package/package.json +201 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
export type Theme = 'light' | 'dark' | 'axis' | 'ocean' | 'sunset' | 'auto';
|
|
3
|
+
type ResolvedTheme = 'light' | 'dark' | 'axis-light' | 'axis-dark' | 'ocean-light' | 'ocean-dark' | 'sunset-light' | 'sunset-dark';
|
|
4
|
+
interface ThemeContextValue {
|
|
5
|
+
theme: Theme;
|
|
6
|
+
resolvedTheme: ResolvedTheme;
|
|
7
|
+
setTheme: (theme: Theme) => void;
|
|
8
|
+
isDark: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ThemeProviderProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
defaultTheme?: Theme;
|
|
13
|
+
/**
|
|
14
|
+
* When true, the provider reads theme from the document but doesn't modify it.
|
|
15
|
+
* Use this when embedding in an app that already manages themes.
|
|
16
|
+
* This prevents the canvas from overriding the parent app's theme.
|
|
17
|
+
*/
|
|
18
|
+
passive?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Provides theme state to all descendant components.
|
|
22
|
+
*
|
|
23
|
+
* In **active** mode (default), applies theme to `document.documentElement` and
|
|
24
|
+
* persists the choice to `localStorage`. In **passive** mode, reads the theme
|
|
25
|
+
* from the document without modifying it -- use this when embedding inside a
|
|
26
|
+
* host app that already manages themes.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Active mode (standalone)
|
|
31
|
+
* <ThemeProvider defaultTheme="auto">
|
|
32
|
+
* <App />
|
|
33
|
+
* </ThemeProvider>
|
|
34
|
+
*
|
|
35
|
+
* // Passive mode (embedded in host app)
|
|
36
|
+
* <ThemeProvider passive>
|
|
37
|
+
* <SnowconeCanvasInner />
|
|
38
|
+
* </ThemeProvider>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access theme context
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const { theme, setTheme, isDark } = useTheme();
|
|
47
|
+
*
|
|
48
|
+
* // Change theme
|
|
49
|
+
* setTheme('dark');
|
|
50
|
+
*
|
|
51
|
+
* // Check current theme
|
|
52
|
+
* if (isDark) { ... }
|
|
53
|
+
*/
|
|
54
|
+
export declare const useTheme: () => ThemeContextValue;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
/** Expanded panel types for contextual toolbars */
|
|
3
|
+
export type ExpandedPanelType = 'cornerRadius' | 'effects' | 'crop' | 'rotation' | null;
|
|
4
|
+
/** Value exposed by ToolStateContext. */
|
|
5
|
+
export interface ToolStateContextValue {
|
|
6
|
+
/** Which contextual panel is currently expanded, or null */
|
|
7
|
+
expandedPanelType: ExpandedPanelType;
|
|
8
|
+
/** Set the expanded panel type */
|
|
9
|
+
setExpandedPanelType: React.Dispatch<React.SetStateAction<ExpandedPanelType>>;
|
|
10
|
+
/** Whether any toolbar dropdown/menu/panel is open */
|
|
11
|
+
isToolbarMenuOpen: boolean;
|
|
12
|
+
/** Set toolbar menu open state */
|
|
13
|
+
setIsToolbarMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
/** Version counter for text selection changes (forces re-render on selection) */
|
|
15
|
+
textSelectionVersion: number;
|
|
16
|
+
/** Increment text selection version */
|
|
17
|
+
setTextSelectionVersion: React.Dispatch<React.SetStateAction<number>>;
|
|
18
|
+
/** Whether the canvas has mounted and is ready for operations */
|
|
19
|
+
isCanvasReady: boolean;
|
|
20
|
+
/** Set the canvas ready state */
|
|
21
|
+
setCanvasReady: (ready: boolean) => void;
|
|
22
|
+
/** Whether the user is currently rotating an element */
|
|
23
|
+
isRotating: boolean;
|
|
24
|
+
/** Set the rotation state */
|
|
25
|
+
setIsRotating: React.Dispatch<React.SetStateAction<boolean>>;
|
|
26
|
+
}
|
|
27
|
+
/** Props for {@link ToolStateProvider}. */
|
|
28
|
+
export interface ToolStateProviderProps {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Provides UI tool state to all descendants.
|
|
33
|
+
*
|
|
34
|
+
* Manages which panel is expanded, whether toolbar menus are open,
|
|
35
|
+
* text selection tracking, canvas readiness, and rotation state.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ToolStateProvider: React.FC<ToolStateProviderProps>;
|
|
38
|
+
/**
|
|
39
|
+
* Access UI tool state: expanded panels, toolbar menus, canvas readiness, etc.
|
|
40
|
+
*
|
|
41
|
+
* Prefer this over `useEditor()` in components that only need tool UI state
|
|
42
|
+
* (e.g., contextual toolbars checking which panel is expanded).
|
|
43
|
+
*
|
|
44
|
+
* @throws {Error} If called outside of a `ToolStateProvider` (or `EditorProvider`)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* function PanelToggle() {
|
|
49
|
+
* const { expandedPanelType, setExpandedPanelType } = useToolStateContext();
|
|
50
|
+
* return (
|
|
51
|
+
* <button onClick={() => setExpandedPanelType(
|
|
52
|
+
* expandedPanelType === 'effects' ? null : 'effects'
|
|
53
|
+
* )}>
|
|
54
|
+
* {expandedPanelType === 'effects' ? 'Close' : 'Effects'}
|
|
55
|
+
* </button>
|
|
56
|
+
* );
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function useToolStateContext(): ToolStateContextValue;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { ArtboardManager } from '../core/ArtboardManager.js';
|
|
3
|
+
/** Pan offset for infinite canvas viewport */
|
|
4
|
+
export interface PanOffset {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
/** Value exposed by ViewportContext. */
|
|
9
|
+
export interface ViewportContextValue {
|
|
10
|
+
/** Current zoom level (1.0 = 100%) */
|
|
11
|
+
zoom: number;
|
|
12
|
+
/** Current pan offset in world coordinates */
|
|
13
|
+
panOffset: PanOffset;
|
|
14
|
+
/** Whether the user is currently panning */
|
|
15
|
+
isPanning: boolean;
|
|
16
|
+
/** Increment zoom by one step */
|
|
17
|
+
zoomIn: () => void;
|
|
18
|
+
/** Decrement zoom by one step */
|
|
19
|
+
zoomOut: () => void;
|
|
20
|
+
/** Zoom to fit the active artboard in the viewport */
|
|
21
|
+
zoomToFit: () => void;
|
|
22
|
+
/** Reset zoom to 100% and pan offset to origin */
|
|
23
|
+
resetView: () => void;
|
|
24
|
+
/** Set zoom to an exact value */
|
|
25
|
+
setZoom: React.Dispatch<React.SetStateAction<number>>;
|
|
26
|
+
/** Set pan offset to an exact value */
|
|
27
|
+
setPanOffset: React.Dispatch<React.SetStateAction<PanOffset>>;
|
|
28
|
+
/** Set whether the user is currently panning */
|
|
29
|
+
setIsPanning: React.Dispatch<React.SetStateAction<boolean>>;
|
|
30
|
+
/**
|
|
31
|
+
* User-driven zoom multiplier applied on top of the auto-fit zoom
|
|
32
|
+
* the embedded canvas computes from container size. 1.0 = exactly
|
|
33
|
+
* fit-zoom (no extra zoom). >1 = zoomed in for fine-detail editing.
|
|
34
|
+
* Composes with `zoom` (which is the *effective* zoom = fit × user)
|
|
35
|
+
* so legacy consumers reading `zoom` see one value.
|
|
36
|
+
*/
|
|
37
|
+
userZoom: number;
|
|
38
|
+
setUserZoom: React.Dispatch<React.SetStateAction<number>>;
|
|
39
|
+
/** Reset userZoom to 1.0 and panOffset to origin (returns to fit). */
|
|
40
|
+
resetUserView: () => void;
|
|
41
|
+
}
|
|
42
|
+
/** Props for {@link ViewportProvider}. */
|
|
43
|
+
export interface ViewportProviderProps {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
/** ArtboardManager instance, used by zoomToFit to read active artboard dimensions. */
|
|
46
|
+
artboardManager: ArtboardManager;
|
|
47
|
+
/** Ref to the canvas element, used by zoomToFit to measure the container. */
|
|
48
|
+
canvasRef: React.RefObject<HTMLCanvasElement | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Controls how much of the container the artboard fills when using zoomToFit.
|
|
51
|
+
* Value between 0 and 1, where 1 means the artboard fills 100% of the container.
|
|
52
|
+
* Default is 0.9 (90%), leaving 5% padding on each side.
|
|
53
|
+
*/
|
|
54
|
+
viewPadding?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Provides viewport state (zoom, pan) and control functions to all descendants.
|
|
58
|
+
*
|
|
59
|
+
* Must be composed inside EditorProvider or used standalone for viewport-only
|
|
60
|
+
* scenarios. Most consumers should use the `useViewport()` hook.
|
|
61
|
+
*/
|
|
62
|
+
export declare const ViewportProvider: React.FC<ViewportProviderProps>;
|
|
63
|
+
/**
|
|
64
|
+
* Access viewport state: zoom, pan, and control functions.
|
|
65
|
+
*
|
|
66
|
+
* Prefer this over `useEditor()` in components that only need viewport information
|
|
67
|
+
* (e.g., zoom controls, minimap overlays). Changes to non-viewport state won't
|
|
68
|
+
* trigger re-renders in components using this hook.
|
|
69
|
+
*
|
|
70
|
+
* @throws {Error} If called outside of a `ViewportProvider` (or `EditorProvider`)
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* function ZoomBar() {
|
|
75
|
+
* const { zoom, zoomIn, zoomOut, zoomToFit } = useViewportContext();
|
|
76
|
+
* return (
|
|
77
|
+
* <div>
|
|
78
|
+
* <button onClick={zoomOut}>-</button>
|
|
79
|
+
* <span>{Math.round(zoom * 100)}%</span>
|
|
80
|
+
* <button onClick={zoomIn}>+</button>
|
|
81
|
+
* <button onClick={zoomToFit}>Fit</button>
|
|
82
|
+
* </div>
|
|
83
|
+
* );
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function useViewportContext(): ViewportContextValue;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { Point, SnapGuide, ResizeAnchor, AnyTransformData } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents an element with the properties accessed during snap operations.
|
|
5
|
+
* Extends BaseElement with optional text/image-specific properties that the
|
|
6
|
+
* snap system reads via duck-typing.
|
|
7
|
+
*/
|
|
8
|
+
interface SnapElement extends BaseElement {
|
|
9
|
+
/** Font size (present on TextElement and its subclasses) */
|
|
10
|
+
fontSize?: number;
|
|
11
|
+
/** Direct width property (present on some element types) */
|
|
12
|
+
width?: number;
|
|
13
|
+
/** Direct height property (present on some element types) */
|
|
14
|
+
height?: number;
|
|
15
|
+
/** Image aspect ratio (present on ImageElement) */
|
|
16
|
+
imageAspectRatio?: number;
|
|
17
|
+
/** Whether the image is in crop mode (present on ImageElement) */
|
|
18
|
+
isCropping?: boolean;
|
|
19
|
+
/** Override clone to return SnapElement */
|
|
20
|
+
clone(): SnapElement;
|
|
21
|
+
}
|
|
22
|
+
/** Named anchor points returned by RotationAnchorResolver.getSnapAnchors() */
|
|
23
|
+
type SnapAnchors = Record<string, Point>;
|
|
24
|
+
/** Resize handle info passed through the resize pipeline */
|
|
25
|
+
interface SnapHandleInfo {
|
|
26
|
+
anchor: ResizeAnchor | string;
|
|
27
|
+
type?: string;
|
|
28
|
+
cursor?: string;
|
|
29
|
+
x?: number;
|
|
30
|
+
y?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Start data captured at the beginning of a resize operation */
|
|
33
|
+
interface ResizeStartData {
|
|
34
|
+
fontSize?: number;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
visualWidth?: number;
|
|
38
|
+
visualHeight?: number;
|
|
39
|
+
x?: number;
|
|
40
|
+
y?: number;
|
|
41
|
+
rotation?: number;
|
|
42
|
+
transformData?: Partial<AnyTransformData>;
|
|
43
|
+
}
|
|
44
|
+
/** Result from the resize pipeline, passed into snapDimensions */
|
|
45
|
+
interface ResizeResult {
|
|
46
|
+
element: SnapElement;
|
|
47
|
+
handle: SnapHandleInfo;
|
|
48
|
+
startData: ResizeStartData | null;
|
|
49
|
+
isFrozen?: boolean;
|
|
50
|
+
unfrozenDimensions?: {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
snapAdjustment?: {
|
|
55
|
+
dx: number;
|
|
56
|
+
dy: number;
|
|
57
|
+
};
|
|
58
|
+
isInStickySnap?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** A detected snap on either X or Y axis during resize snap */
|
|
61
|
+
interface ResizeSnap {
|
|
62
|
+
distance: number;
|
|
63
|
+
snapTo: number;
|
|
64
|
+
currentValue: number;
|
|
65
|
+
guide: SnapGuideExtended;
|
|
66
|
+
}
|
|
67
|
+
/** Extended guide info including movingKey and otherKey for tracking */
|
|
68
|
+
interface SnapGuideExtended {
|
|
69
|
+
type: string;
|
|
70
|
+
x?: number;
|
|
71
|
+
y?: number;
|
|
72
|
+
y1?: number;
|
|
73
|
+
y2?: number;
|
|
74
|
+
x1?: number;
|
|
75
|
+
x2?: number;
|
|
76
|
+
movingKey: string;
|
|
77
|
+
otherKey: string;
|
|
78
|
+
}
|
|
79
|
+
/** Result from _processStickySnap */
|
|
80
|
+
interface StickySnapResult {
|
|
81
|
+
snapDelta: number;
|
|
82
|
+
bestSnap: ResizeSnap | null;
|
|
83
|
+
}
|
|
84
|
+
interface SnapState {
|
|
85
|
+
snapTo: number;
|
|
86
|
+
anchorKey: string;
|
|
87
|
+
frozenFontSize: number;
|
|
88
|
+
frozenWidth: number;
|
|
89
|
+
frozenHeight: number;
|
|
90
|
+
frozenPosition: Point;
|
|
91
|
+
isPositionBasedSnap: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface AlignmentSnapSystemOptions {
|
|
94
|
+
snapThreshold?: number;
|
|
95
|
+
enabled?: boolean;
|
|
96
|
+
showGuides?: boolean;
|
|
97
|
+
stickyThreshold?: number;
|
|
98
|
+
}
|
|
99
|
+
export declare class AlignmentSnapSystem {
|
|
100
|
+
snapThreshold: number;
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
showGuides: boolean;
|
|
103
|
+
guides: SnapGuide[];
|
|
104
|
+
activeSnaps: {
|
|
105
|
+
x: SnapState | null;
|
|
106
|
+
y: SnapState | null;
|
|
107
|
+
};
|
|
108
|
+
stickyThreshold: number;
|
|
109
|
+
/** Spatial grid for O(1) amortized snap candidate lookup */
|
|
110
|
+
private _spatialGrid;
|
|
111
|
+
/** Map from grid item compound key to anchor metadata */
|
|
112
|
+
private _anchorMetadata;
|
|
113
|
+
/**
|
|
114
|
+
* ADR-0060: extra rectangular regions injected as snap targets in
|
|
115
|
+
* addition to the canvas elements. Used by spread-mode focused-piece
|
|
116
|
+
* editing so dragged elements snap to the FOCUSED PIECE'S center /
|
|
117
|
+
* edges / corners instead of the full artboard. Each rect produces
|
|
118
|
+
* 9 anchor points (corners, edge midpoints, center) — exactly the
|
|
119
|
+
* shape `RotationAnchorResolver.getSnapAnchors` produces for an
|
|
120
|
+
* un-rotated element. The id is used to scope the synthetic
|
|
121
|
+
* "element id" so grid-item keys stay unique.
|
|
122
|
+
*/
|
|
123
|
+
private _extraSnapRects;
|
|
124
|
+
constructor(options?: AlignmentSnapSystemOptions);
|
|
125
|
+
/**
|
|
126
|
+
* Enable or disable snapping
|
|
127
|
+
*/
|
|
128
|
+
setEnabled(enabled: boolean): void;
|
|
129
|
+
/**
|
|
130
|
+
* Set snap threshold in pixels
|
|
131
|
+
*/
|
|
132
|
+
setSnapThreshold(threshold: number): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get current snap guides for rendering
|
|
135
|
+
*/
|
|
136
|
+
getGuides(): SnapGuide[];
|
|
137
|
+
/**
|
|
138
|
+
* Clear all snap guides
|
|
139
|
+
*/
|
|
140
|
+
clearGuides(): void;
|
|
141
|
+
/**
|
|
142
|
+
* Clear sticky snap state
|
|
143
|
+
*/
|
|
144
|
+
clearSnapState(): void;
|
|
145
|
+
/**
|
|
146
|
+
* ADR-0060: replace the set of extra snap rects (focused-piece bounds
|
|
147
|
+
* etc.). Pass `[]` to clear. Effective on the next snap operation.
|
|
148
|
+
*/
|
|
149
|
+
setExtraSnapRects(rects: Array<{
|
|
150
|
+
id: string;
|
|
151
|
+
x: number;
|
|
152
|
+
y: number;
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
}>): void;
|
|
156
|
+
/**
|
|
157
|
+
* Populate the spatial grid with anchor points from the given elements.
|
|
158
|
+
* Each element produces ~9 anchor points (corners, edge midpoints, center).
|
|
159
|
+
* The grid enables O(1) amortized lookup of nearby anchors by axis.
|
|
160
|
+
*
|
|
161
|
+
* Also folds in `_extraSnapRects` (set via `setExtraSnapRects`) so
|
|
162
|
+
* a focused piece in spread mode contributes its corners / edges /
|
|
163
|
+
* center as snap targets even though there's no real BaseElement.
|
|
164
|
+
*/
|
|
165
|
+
private _populateSpatialGrid;
|
|
166
|
+
/**
|
|
167
|
+
* Snap a position during drag operation
|
|
168
|
+
*/
|
|
169
|
+
snapPosition(position: Point, element: BaseElement, allElements: BaseElement[] | null): Point;
|
|
170
|
+
/**
|
|
171
|
+
* Calculate what the frozen font size should be at the snap point
|
|
172
|
+
* This ensures consistent font size regardless of which side of threshold you enter from
|
|
173
|
+
*/
|
|
174
|
+
_calculateFrozenFontSizeAtSnap(element: SnapElement, snapDeltaX: number, _snapDeltaY: number, handle: SnapHandleInfo | null, startData: ResizeStartData | null): number;
|
|
175
|
+
/**
|
|
176
|
+
* Check if this will be a position-based snap (vs dimension-based)
|
|
177
|
+
* Position-based snaps adjust position to align edges when dimensions can't be modified
|
|
178
|
+
* Used for text elements where height is derived, not settable
|
|
179
|
+
*/
|
|
180
|
+
_isPositionBasedSnap(element: SnapElement, axis: 'x' | 'y'): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Determine which snap keys to use based on the resize handle
|
|
183
|
+
*/
|
|
184
|
+
_getSnapKeysForHandle(handle: SnapHandleInfo | null): string[];
|
|
185
|
+
/**
|
|
186
|
+
* Get all possible target snap keys (corners only, no center points)
|
|
187
|
+
*/
|
|
188
|
+
_getTargetSnapKeys(): string[];
|
|
189
|
+
/**
|
|
190
|
+
* Find all X-axis snaps within threshold.
|
|
191
|
+
* Uses the spatial grid (pre-populated via _populateSpatialGrid) for
|
|
192
|
+
* O(1) amortized lookup instead of scanning all other elements.
|
|
193
|
+
*/
|
|
194
|
+
_findXSnaps(movingAnchors: SnapAnchors, _otherElements: BaseElement[], snapKeys: string[], targetSnapKeys: string[]): ResizeSnap[];
|
|
195
|
+
/**
|
|
196
|
+
* Find all Y-axis snaps within threshold.
|
|
197
|
+
* Uses the spatial grid (pre-populated via _populateSpatialGrid) for
|
|
198
|
+
* O(1) amortized lookup instead of scanning all other elements.
|
|
199
|
+
*/
|
|
200
|
+
_findYSnaps(movingAnchors: SnapAnchors, _otherElements: BaseElement[], snapKeys: string[], targetSnapKeys: string[]): ResizeSnap[];
|
|
201
|
+
/**
|
|
202
|
+
* Sort snaps by distance and prioritize based on handle anchor
|
|
203
|
+
*/
|
|
204
|
+
_prioritizeSnaps(snaps: ResizeSnap[], handle: SnapHandleInfo | null, axis: 'x' | 'y'): void;
|
|
205
|
+
/**
|
|
206
|
+
* Create a guide visualization for an active snap
|
|
207
|
+
*/
|
|
208
|
+
_createGuideForSnap(snap: SnapState, anchorKey: string, movingAnchors: SnapAnchors, otherElements: BaseElement[], axis: 'x' | 'y'): ResizeSnap | null;
|
|
209
|
+
/**
|
|
210
|
+
* Calculate aspect-ratio-aware sticky threshold for a given axis
|
|
211
|
+
* Wide elements move faster horizontally, tall elements move faster vertically
|
|
212
|
+
* Adjust threshold to compensate for this velocity difference
|
|
213
|
+
*/
|
|
214
|
+
_getAdjustedStickyThreshold(axis: 'x' | 'y', element: SnapElement): number;
|
|
215
|
+
/**
|
|
216
|
+
* Calculate what dimensions should be when edge reaches snap point
|
|
217
|
+
* This ensures frozen dimensions match the geometry at the snap position
|
|
218
|
+
*
|
|
219
|
+
* The key insight: When a snap is first detected (edge within 5px of guideline),
|
|
220
|
+
* we need to freeze dimensions at what they WILL BE when the edge reaches the snap point,
|
|
221
|
+
* not what they ARE at the moment of detection. This prevents visual "jumps" during
|
|
222
|
+
* corner resize because position compensation expects dimensions to match the snap point.
|
|
223
|
+
*
|
|
224
|
+
* @param element - The element being resized
|
|
225
|
+
* @param axis - 'x' or 'y' axis of the snap
|
|
226
|
+
* @param snapDelta - Distance to move to reach snap point (can be positive or negative)
|
|
227
|
+
* @param anchorKey - Which anchor is snapping (e.g., 'topRight', 'bottomLeft', etc.)
|
|
228
|
+
* @param handle - The resize handle being dragged
|
|
229
|
+
* @returns {Object} { frozenWidth, frozenHeight } - Dimensions at snap point
|
|
230
|
+
*/
|
|
231
|
+
_calculateFrozenDimensionsAtSnap(element: SnapElement, axis: 'x' | 'y', snapDelta: number, anchorKey: string, _handle: SnapHandleInfo | null): {
|
|
232
|
+
frozenWidth: number;
|
|
233
|
+
frozenHeight: number;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Process sticky snapping for a single axis
|
|
237
|
+
* @returns {Object} { snapDelta, bestSnap }
|
|
238
|
+
*/
|
|
239
|
+
_processStickySnap(axis: 'x' | 'y', movingAnchors: SnapAnchors, snaps: ResizeSnap[], element: SnapElement, handle: SnapHandleInfo | null, startData: ResizeStartData | null, otherElements: BaseElement[]): StickySnapResult;
|
|
240
|
+
/**
|
|
241
|
+
* Adjust element for right edge resize
|
|
242
|
+
*/
|
|
243
|
+
_adjustElementForRightResize(element: SnapElement, snapDeltaX: number, handle: SnapHandleInfo): void;
|
|
244
|
+
/**
|
|
245
|
+
* Adjust element for left edge resize
|
|
246
|
+
*/
|
|
247
|
+
_adjustElementForLeftResize(element: SnapElement, snapDeltaX: number, handle: SnapHandleInfo): void;
|
|
248
|
+
/**
|
|
249
|
+
* Adjust element for bottom edge resize
|
|
250
|
+
*/
|
|
251
|
+
_adjustElementForBottomResize(element: SnapElement, snapDeltaY: number, handle: SnapHandleInfo): void;
|
|
252
|
+
/**
|
|
253
|
+
* Adjust element for top edge resize
|
|
254
|
+
*/
|
|
255
|
+
_adjustElementForTopResize(element: SnapElement, snapDeltaY: number, handle: SnapHandleInfo): void;
|
|
256
|
+
/**
|
|
257
|
+
* Snap dimensions during resize operation
|
|
258
|
+
*
|
|
259
|
+
* @param {object} result - Resize result AFTER ResizeHandler processes it
|
|
260
|
+
* @param {array} allElements - All elements in the scene
|
|
261
|
+
* @param {object} startData - Original data from when resize started (for font size preservation)
|
|
262
|
+
* @returns {object} Modified resize result with adjusted element
|
|
263
|
+
*/
|
|
264
|
+
snapDimensions(result: ResizeResult, allElements: BaseElement[] | null, startData?: ResizeStartData | null): ResizeResult;
|
|
265
|
+
/**
|
|
266
|
+
* Snap rotation (for future implementation)
|
|
267
|
+
*/
|
|
268
|
+
snapRotation(rotation: number, _element: BaseElement, _allElements?: BaseElement[]): number;
|
|
269
|
+
}
|
|
270
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { TextElement } from './TextElement.js';
|
|
2
|
+
import { ImageElement } from './ImageElement.js';
|
|
3
|
+
import { GroupElement } from './GroupElement.js';
|
|
4
|
+
import { BoundingBox, Point, ArtboardConfig, ArtboardBackgroundType, ArtboardDistressTexture, ArtboardImageMask, ClipShape } from '../types/index.js';
|
|
5
|
+
export declare class ArtboardElement {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
backgroundColor: string;
|
|
13
|
+
backgroundType: ArtboardBackgroundType;
|
|
14
|
+
backgroundTexture?: string;
|
|
15
|
+
exportBackground: boolean;
|
|
16
|
+
transformType: 'artboard';
|
|
17
|
+
clipShape?: ClipShape;
|
|
18
|
+
previewBackgroundColor?: string;
|
|
19
|
+
distressTexture?: ArtboardDistressTexture;
|
|
20
|
+
imageMask?: ArtboardImageMask;
|
|
21
|
+
private elementIds;
|
|
22
|
+
constructor(config?: Partial<ArtboardConfig>);
|
|
23
|
+
/**
|
|
24
|
+
* Get bounding box of the artboard
|
|
25
|
+
*/
|
|
26
|
+
getBoundingBox(): BoundingBox;
|
|
27
|
+
/**
|
|
28
|
+
* Get center point of the artboard
|
|
29
|
+
*/
|
|
30
|
+
getCenter(): Point;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a point is within artboard bounds
|
|
33
|
+
*/
|
|
34
|
+
containsPoint(px: number, py: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if an element's bounding box is within artboard bounds
|
|
37
|
+
*/
|
|
38
|
+
containsElement(element: TextElement | ImageElement | GroupElement): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Add an element ID to this artboard
|
|
41
|
+
*/
|
|
42
|
+
addElementId(elementId: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Remove an element ID from this artboard
|
|
45
|
+
*/
|
|
46
|
+
removeElementId(elementId: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Check if artboard contains an element ID
|
|
49
|
+
*/
|
|
50
|
+
hasElementId(elementId: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get all element IDs in this artboard
|
|
53
|
+
*/
|
|
54
|
+
getElementIds(): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Get number of elements in artboard
|
|
57
|
+
*/
|
|
58
|
+
getElementCount(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Clear all element IDs
|
|
61
|
+
*/
|
|
62
|
+
clearElementIds(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Test if a point hits the artboard border (for selection)
|
|
65
|
+
* Returns true if point is near the border (within tolerance)
|
|
66
|
+
*/
|
|
67
|
+
hitTestBorder(px: number, py: number, tolerance?: number): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Clone the artboard
|
|
70
|
+
*/
|
|
71
|
+
clone(): ArtboardElement;
|
|
72
|
+
/**
|
|
73
|
+
* Serialize to JSON
|
|
74
|
+
*/
|
|
75
|
+
toJSON(): ArtboardConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Create from JSON
|
|
78
|
+
*/
|
|
79
|
+
static fromJSON(config: ArtboardConfig): ArtboardElement;
|
|
80
|
+
/**
|
|
81
|
+
* Update artboard properties
|
|
82
|
+
*/
|
|
83
|
+
updateProperties(updates: Partial<{
|
|
84
|
+
name: string;
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
backgroundColor: string;
|
|
90
|
+
backgroundType: ArtboardBackgroundType;
|
|
91
|
+
backgroundTexture: string;
|
|
92
|
+
exportBackground: boolean;
|
|
93
|
+
clipShape: ClipShape;
|
|
94
|
+
distressTexture: ArtboardDistressTexture | undefined;
|
|
95
|
+
imageMask: ArtboardImageMask | undefined;
|
|
96
|
+
}>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Resize artboard (with constraints)
|
|
99
|
+
*/
|
|
100
|
+
resize(newWidth: number, newHeight: number): void;
|
|
101
|
+
/**
|
|
102
|
+
* Move artboard
|
|
103
|
+
*/
|
|
104
|
+
move(newX: number, newY: number): void;
|
|
105
|
+
}
|
|
106
|
+
export default ArtboardElement;
|