@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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks - Custom React hooks
|
|
3
|
+
*/
|
|
4
|
+
export { useClickOutside } from './useClickOutside';
|
|
5
|
+
export { useArtboards } from './useArtboards';
|
|
6
|
+
export type { ArtboardInfo, UseArtboardsReturn } from './useArtboards';
|
|
7
|
+
export { useLayers } from './useLayers';
|
|
8
|
+
export type { LayerInfo, UseLayersOptions, UseLayersReturn } from './useLayers';
|
|
9
|
+
export { useExport } from './useExport';
|
|
10
|
+
export type { ExportProgress, ContinuousExportOptions, UseExportReturn } from './useExport';
|
|
11
|
+
export { useProjectLoader } from './useProjectLoader';
|
|
12
|
+
export type { ProjectTemplate, ProjectMetadata, UseProjectLoaderReturn } from './useProjectLoader';
|
|
13
|
+
export { useCommands } from './useCommands';
|
|
14
|
+
export type { UseCommandsReturn } from './useCommands';
|
|
15
|
+
export { useBreakpoint } from './useBreakpoint';
|
|
16
|
+
export type { BreakpointConfig, Breakpoint, UseBreakpointReturn } from './useBreakpoint';
|
|
17
|
+
export { usePerformance } from './usePerformance';
|
|
18
|
+
export type { PerformanceMetrics, UsePerformanceReturn } from './usePerformance';
|
|
19
|
+
export { useSelectedElement } from './useSelectedElement';
|
|
20
|
+
export { useElementById } from './useElementById';
|
|
21
|
+
export { useElementByName } from './useElementByName';
|
|
22
|
+
export { useCanvasReady } from './useCanvasReady';
|
|
23
|
+
export { useTextBinding } from './useTextBinding';
|
|
24
|
+
export type { TextBindingResult } from './useTextBinding';
|
|
25
|
+
export { useImageBinding } from './useImageBinding';
|
|
26
|
+
export type { ImageBindingResult, ImageBindingOptions, ImageFitMode } from './useImageBinding';
|
|
27
|
+
export { useViewport } from './useViewport';
|
|
28
|
+
export type { UseViewportReturn } from './useViewport';
|
|
29
|
+
export { useTextToolbar } from './useTextToolbar';
|
|
30
|
+
export type { UseTextToolbarOptions, UseTextToolbarReturn } from './useTextToolbar';
|
|
31
|
+
export { useAutoExport } from './useAutoExport';
|
|
32
|
+
export type { UseAutoExportOptions, UseAutoExportReturn } from './useAutoExport';
|
|
33
|
+
export { useLayerPreview } from './useLayerPreview';
|
|
34
|
+
export type { UseLayerPreviewOptions, UseLayerPreviewReturn } from './useLayerPreview';
|
|
35
|
+
export { useLayerDragDrop } from './useLayerDragDrop';
|
|
36
|
+
export type { UseLayerDragDropOptions, UseLayerDragDropReturn } from './useLayerDragDrop';
|
|
37
|
+
export { useLayerSelection } from './useLayerSelection';
|
|
38
|
+
export type { UseLayerSelectionOptions, UseLayerSelectionReturn } from './useLayerSelection';
|
|
39
|
+
export { useCanvasEvents } from './useCanvasEvents';
|
|
40
|
+
export { useCommandHistory } from './useCommandHistory';
|
|
41
|
+
export { useKeyboardShortcuts } from './useKeyboardShortcuts';
|
|
42
|
+
export { useElementProperties } from './useElementProperties';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ArtboardElement } from '../core/ArtboardElement.js';
|
|
2
|
+
import { ClipShape, ArtboardDistressTexture } from '../types/index.js';
|
|
3
|
+
export interface ArtboardInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
clipShape?: ClipShape;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
elementCount: number;
|
|
14
|
+
}
|
|
15
|
+
export interface UseArtboardsReturn {
|
|
16
|
+
artboards: ArtboardElement[];
|
|
17
|
+
artboardsInfo: ArtboardInfo[];
|
|
18
|
+
activeArtboard: ArtboardElement | null;
|
|
19
|
+
activeArtboardId: string | null;
|
|
20
|
+
activeArtboardInfo: ArtboardInfo | null;
|
|
21
|
+
createArtboard: (width?: number, height?: number, config?: Partial<{
|
|
22
|
+
name: string;
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
backgroundColor: string;
|
|
26
|
+
clipShape: ClipShape;
|
|
27
|
+
}>) => void;
|
|
28
|
+
deleteArtboard: (artboardId: string) => void;
|
|
29
|
+
duplicateArtboard: (artboardId: string) => void;
|
|
30
|
+
renameArtboard: (artboardId: string, newName: string) => void;
|
|
31
|
+
updateArtboard: (artboardId: string, updates: Partial<{
|
|
32
|
+
name: string;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
backgroundColor: string;
|
|
36
|
+
clipShape: ClipShape;
|
|
37
|
+
distressTexture: ArtboardDistressTexture | undefined;
|
|
38
|
+
}>) => void;
|
|
39
|
+
selectArtboard: (artboardId: string) => void;
|
|
40
|
+
reorderArtboards: (fromIndex: number, toIndex: number) => void;
|
|
41
|
+
count: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook to access artboard data and operations
|
|
45
|
+
* Must be used within EditorProvider
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* function ArtboardSwitcher() {
|
|
50
|
+
* const { artboardsInfo, selectArtboard, createArtboard } = useArtboards();
|
|
51
|
+
*
|
|
52
|
+
* return (
|
|
53
|
+
* <div>
|
|
54
|
+
* {artboardsInfo.map(ab => (
|
|
55
|
+
* <button
|
|
56
|
+
* key={ab.id}
|
|
57
|
+
* onClick={() => selectArtboard(ab.id)}
|
|
58
|
+
* className={ab.isActive ? 'active' : ''}
|
|
59
|
+
* >
|
|
60
|
+
* {ab.name} ({ab.width}×{ab.height})
|
|
61
|
+
* </button>
|
|
62
|
+
* ))}
|
|
63
|
+
* <button onClick={() => createArtboard(1200, 1200)}>
|
|
64
|
+
* + New Artboard
|
|
65
|
+
* </button>
|
|
66
|
+
* </div>
|
|
67
|
+
* );
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const useArtboards: () => UseArtboardsReturn;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AutoExportConfig, AutoExportStats } from '../services/AutoExportManager.js';
|
|
2
|
+
import { HybridHistoryManager } from '../core/HybridHistoryManager.js';
|
|
3
|
+
import { ArtboardElement } from '../core/ArtboardElement.js';
|
|
4
|
+
import { TextElement } from '../core/TextElement.js';
|
|
5
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
6
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
7
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
8
|
+
import { PathElement } from '../core/PathElement.js';
|
|
9
|
+
type EditorElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
10
|
+
export interface UseAutoExportOptions {
|
|
11
|
+
/** Auto-export configuration */
|
|
12
|
+
config?: Partial<AutoExportConfig>;
|
|
13
|
+
/** Hybrid history manager to listen to for changes */
|
|
14
|
+
historyManager?: HybridHistoryManager;
|
|
15
|
+
/** Current artboards */
|
|
16
|
+
artboards: ArtboardElement[];
|
|
17
|
+
/** Current elements */
|
|
18
|
+
elements: EditorElement[];
|
|
19
|
+
/** Callback to perform the actual export */
|
|
20
|
+
onExport: () => void | Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Callback fired immediately when an export is scheduled (before debounce).
|
|
23
|
+
* Use this to show loading indicators right away instead of waiting for export to complete.
|
|
24
|
+
*/
|
|
25
|
+
onExportScheduled?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the canvas is mounted and ready for export operations.
|
|
28
|
+
* When false, exports are deferred until canvas becomes ready.
|
|
29
|
+
* This prevents "[useExport] Canvas ref not available" errors.
|
|
30
|
+
*/
|
|
31
|
+
isCanvasReady?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface UseAutoExportReturn {
|
|
34
|
+
/** Current auto-export statistics */
|
|
35
|
+
stats: AutoExportStats;
|
|
36
|
+
/** Update configuration on the fly */
|
|
37
|
+
updateConfig: (config: Partial<AutoExportConfig>) => void;
|
|
38
|
+
/** Force an immediate export (bypassing debounce) */
|
|
39
|
+
forceExport: () => Promise<void>;
|
|
40
|
+
/** Reset statistics */
|
|
41
|
+
resetStats: () => void;
|
|
42
|
+
/** Reset change detection (next export will always trigger) */
|
|
43
|
+
resetChangeDetection: () => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Hook to manage automatic export on state changes
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* const { stats, updateConfig } = useAutoExport({
|
|
51
|
+
* config: {
|
|
52
|
+
* enabled: true,
|
|
53
|
+
* debounceMs: 100,
|
|
54
|
+
* maxWaitMs: 1000,
|
|
55
|
+
* },
|
|
56
|
+
* historyManager,
|
|
57
|
+
* artboards,
|
|
58
|
+
* elements,
|
|
59
|
+
* onExport: async () => {
|
|
60
|
+
* await exportAllArtboards();
|
|
61
|
+
* },
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useAutoExport(options: UseAutoExportOptions): UseAutoExportReturn;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useBreakpoint - Hook for responsive breakpoint detection
|
|
3
|
+
* Provides responsive utilities for building adaptive UIs
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* function ResponsiveLayout() {
|
|
8
|
+
* const { isAtLeast, breakpoint } = useBreakpoint();
|
|
9
|
+
*
|
|
10
|
+
* return (
|
|
11
|
+
* <div>
|
|
12
|
+
* {isAtLeast('md') ? (
|
|
13
|
+
* <div className="desktop-layout">
|
|
14
|
+
* <LayersPanel />
|
|
15
|
+
* <Canvas />
|
|
16
|
+
* <ExportPanel />
|
|
17
|
+
* </div>
|
|
18
|
+
* ) : (
|
|
19
|
+
* <div className="mobile-layout">
|
|
20
|
+
* <Canvas />
|
|
21
|
+
* </div>
|
|
22
|
+
* )}
|
|
23
|
+
* <p>Current breakpoint: {breakpoint}</p>
|
|
24
|
+
* </div>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface BreakpointConfig {
|
|
30
|
+
xs?: number;
|
|
31
|
+
sm?: number;
|
|
32
|
+
md?: number;
|
|
33
|
+
lg?: number;
|
|
34
|
+
xl?: number;
|
|
35
|
+
xxl?: number;
|
|
36
|
+
}
|
|
37
|
+
export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
38
|
+
export interface UseBreakpointReturn {
|
|
39
|
+
breakpoint: Breakpoint;
|
|
40
|
+
width: number;
|
|
41
|
+
isXs: boolean;
|
|
42
|
+
isSm: boolean;
|
|
43
|
+
isMd: boolean;
|
|
44
|
+
isLg: boolean;
|
|
45
|
+
isXl: boolean;
|
|
46
|
+
isXxl: boolean;
|
|
47
|
+
isAtLeast: (bp: Breakpoint) => boolean;
|
|
48
|
+
isAtMost: (bp: Breakpoint) => boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Hook for responsive breakpoint detection
|
|
52
|
+
*/
|
|
53
|
+
export declare function useBreakpoint(config?: BreakpointConfig): UseBreakpointReturn;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CanvasEventBus } from '../core/EventBus.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the singleton {@link CanvasEventBus} instance.
|
|
4
|
+
*
|
|
5
|
+
* The returned reference is stable across renders -- it always points to
|
|
6
|
+
* the same singleton, so it is safe to include in dependency arrays.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCanvasEvents(): CanvasEventBus;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether the canvas is fully initialized and ready for operations.
|
|
3
|
+
*
|
|
4
|
+
* The canvas is not ready until the underlying `<canvas>` element is mounted
|
|
5
|
+
* and the editor has completed its initial setup. Use this to gate operations
|
|
6
|
+
* like export or programmatic element manipulation that require a live canvas.
|
|
7
|
+
*
|
|
8
|
+
* @returns `true` when the canvas is mounted and ready, `false` otherwise.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* function ExportButton() {
|
|
13
|
+
* const ready = useCanvasReady();
|
|
14
|
+
* return (
|
|
15
|
+
* <button disabled={!ready} onClick={handleExport}>
|
|
16
|
+
* Export PNG
|
|
17
|
+
* </button>
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useCanvasReady(): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HybridHistoryManager } from '../core/HybridHistoryManager.js';
|
|
2
|
+
import { TextElement } from '../core/TextElement.js';
|
|
3
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
4
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
5
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
6
|
+
import { PathElement } from '../core/PathElement.js';
|
|
7
|
+
import { ArtboardElement } from '../core/ArtboardElement.js';
|
|
8
|
+
import { ArtboardManager } from '../core/ArtboardManager.js';
|
|
9
|
+
/** Union of all element types */
|
|
10
|
+
type AnyElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
11
|
+
/**
|
|
12
|
+
* Hook to manage hybrid command history for undo/redo
|
|
13
|
+
* Supports both global (artboard) and per-artboard (element) operations
|
|
14
|
+
*/
|
|
15
|
+
export declare function useCommandHistory(elements: AnyElement[], setElements: React.Dispatch<React.SetStateAction<AnyElement[]>>, artboardManager: ArtboardManager, onArtboardsChange?: () => void): {
|
|
16
|
+
executeElementUpdate: (oldElement: AnyElement | undefined | null, newElement: AnyElement) => void;
|
|
17
|
+
executeAddElement: (element: AnyElement, artboardId?: string, insertAfterElementId?: string, insertBeforeElementId?: string) => void;
|
|
18
|
+
executeRemoveElement: (element: AnyElement) => void;
|
|
19
|
+
executeReorderElement: (draggedId: string, targetId: string, position: "before" | "after") => void;
|
|
20
|
+
executeCommandBatch: (commands: Array<{
|
|
21
|
+
execute: () => void;
|
|
22
|
+
undo: () => void;
|
|
23
|
+
}>) => void;
|
|
24
|
+
executeCreateArtboard: (artboard: ArtboardElement) => void;
|
|
25
|
+
executeDeleteArtboard: (artboard: ArtboardElement) => void;
|
|
26
|
+
executeUpdateArtboard: (artboardId: string, oldProperties: Partial<ArtboardElement>, newProperties: Partial<ArtboardElement>) => void;
|
|
27
|
+
undo: () => void;
|
|
28
|
+
redo: () => void;
|
|
29
|
+
undoActiveArtboard: () => void;
|
|
30
|
+
redoActiveArtboard: () => void;
|
|
31
|
+
clearHistory: () => void;
|
|
32
|
+
clearArtboardHistory: (artboardId: string) => void;
|
|
33
|
+
canUndo: boolean;
|
|
34
|
+
canRedo: boolean;
|
|
35
|
+
canUndoActiveArtboard: boolean;
|
|
36
|
+
canRedoActiveArtboard: boolean;
|
|
37
|
+
historyManager: HybridHistoryManager;
|
|
38
|
+
};
|
|
39
|
+
export default useCommandHistory;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEditor } from '../contexts/EditorContext.js';
|
|
2
|
+
export interface UseCommandsReturn {
|
|
3
|
+
undo: () => void;
|
|
4
|
+
redo: () => void;
|
|
5
|
+
canUndo: boolean;
|
|
6
|
+
canRedo: boolean;
|
|
7
|
+
clearHistory: () => void;
|
|
8
|
+
clearArtboardHistory: (artboardId: string) => void;
|
|
9
|
+
executeElementUpdate: ReturnType<typeof useEditor>['executeElementUpdate'];
|
|
10
|
+
executeAddElement: ReturnType<typeof useEditor>['executeAddElement'];
|
|
11
|
+
executeRemoveElement: ReturnType<typeof useEditor>['executeRemoveElement'];
|
|
12
|
+
executeReorderElement: ReturnType<typeof useEditor>['executeReorderElement'];
|
|
13
|
+
executeCreateArtboard: ReturnType<typeof useEditor>['executeCreateArtboard'];
|
|
14
|
+
executeDeleteArtboard: ReturnType<typeof useEditor>['executeDeleteArtboard'];
|
|
15
|
+
executeUpdateArtboard: ReturnType<typeof useEditor>['executeUpdateArtboard'];
|
|
16
|
+
executeCommandBatch: (commands: Array<{
|
|
17
|
+
execute: () => void;
|
|
18
|
+
undo: () => void;
|
|
19
|
+
}>) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook for accessing command history and undo/redo functionality
|
|
23
|
+
* Must be used within EditorProvider
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* function MyComponent() {
|
|
28
|
+
* const { undo, redo, canUndo, canRedo } = useCommands();
|
|
29
|
+
* const { selectedElement } = useEditor();
|
|
30
|
+
*
|
|
31
|
+
* const handleDelete = () => {
|
|
32
|
+
* if (selectedElement) {
|
|
33
|
+
* executeRemoveElement(selectedElement);
|
|
34
|
+
* }
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <div>
|
|
39
|
+
* <button onClick={undo} disabled={!canUndo}>Undo</button>
|
|
40
|
+
* <button onClick={redo} disabled={!canRedo}>Redo</button>
|
|
41
|
+
* <button onClick={handleDelete}>Delete</button>
|
|
42
|
+
* </div>
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function useCommands(): UseCommandsReturn;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TextElement } from '../core/TextElement.js';
|
|
2
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
3
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
4
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
5
|
+
import { PathElement } from '../core/PathElement.js';
|
|
6
|
+
type EditorElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
7
|
+
export interface UseContentReadyOptions {
|
|
8
|
+
/** DOM mounted and artboards initialized */
|
|
9
|
+
isCanvasReady: boolean;
|
|
10
|
+
/** Current elements in the editor */
|
|
11
|
+
elements: EditorElement[];
|
|
12
|
+
/** Were initialElements provided to SnowconeCanvas? */
|
|
13
|
+
hasInitialElements: boolean;
|
|
14
|
+
/** Have initialElements been deserialized into the editor? */
|
|
15
|
+
initialElementsLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function useContentReady(options: UseContentReadyOptions): boolean;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EditorElement } from '../contexts/EditorContext.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a specific element by its ID, or null if not found.
|
|
4
|
+
*
|
|
5
|
+
* Useful for components that need to display or react to a particular
|
|
6
|
+
* element without subscribing to the full editor state.
|
|
7
|
+
*
|
|
8
|
+
* @param id - The element ID to look up, or null to skip the lookup.
|
|
9
|
+
* @returns The matching element, or null if the ID is null or no element matches.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function ElementInspector({ elementId }: { elementId: string }) {
|
|
14
|
+
* const element = useElementById(elementId);
|
|
15
|
+
* if (!element) return <p>Element not found</p>;
|
|
16
|
+
* return <p>Position: ({element.x}, {element.y})</p>;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useElementById(id: string | null): EditorElement | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EditorElement } from '../contexts/EditorContext.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the first element matching the given name, or null.
|
|
4
|
+
*
|
|
5
|
+
* Must be used within an `EditorProvider`.
|
|
6
|
+
*
|
|
7
|
+
* @param name - The element name to look up, or null to skip the lookup.
|
|
8
|
+
* @returns The matching element, or null if no element matches.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useElementByName(name: string | null): EditorElement | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TextElement } from '../core/TextElement.js';
|
|
2
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
3
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
4
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
5
|
+
import { PathElement } from '../core/PathElement.js';
|
|
6
|
+
import { TextAlign } from '../types/index.js';
|
|
7
|
+
type EditorElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
8
|
+
/**
|
|
9
|
+
* Hook to manage element properties and UI synchronization
|
|
10
|
+
* @param selectedElement - Currently selected element
|
|
11
|
+
* @param onElementUpdate - Callback to update element
|
|
12
|
+
* @returns Property getters and setters
|
|
13
|
+
*/
|
|
14
|
+
export declare function useElementProperties(selectedElement: EditorElement | undefined, onElementUpdate: (element: EditorElement) => void): {
|
|
15
|
+
fontSize: number;
|
|
16
|
+
fontColor: string;
|
|
17
|
+
fontFamily: string;
|
|
18
|
+
textAlign: TextAlign;
|
|
19
|
+
setFontSize: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
20
|
+
setFontColor: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
21
|
+
setFontFamily: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
22
|
+
setTextAlign: import('react').Dispatch<import('react').SetStateAction<TextAlign>>;
|
|
23
|
+
updateFontSize: (delta: number) => void;
|
|
24
|
+
setFontSizeValue: (newSize: number) => void;
|
|
25
|
+
updateFontColor: (newColor: string) => void;
|
|
26
|
+
updateFontFamily: (newFontFamily: string) => void;
|
|
27
|
+
updateTextAlign: (alignment: TextAlign) => void;
|
|
28
|
+
};
|
|
29
|
+
export default useElementProperties;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ExportImageOptions } from '../utils/ExportManager.js';
|
|
2
|
+
export interface ExportProgress {
|
|
3
|
+
artboardId: string;
|
|
4
|
+
artboardName: string;
|
|
5
|
+
status: 'pending' | 'rendering' | 'complete' | 'error';
|
|
6
|
+
progress: number;
|
|
7
|
+
dataUrl?: string;
|
|
8
|
+
error?: Error;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ContinuousExportOptions {
|
|
12
|
+
artboardIds?: string[];
|
|
13
|
+
interval?: number;
|
|
14
|
+
scale?: number;
|
|
15
|
+
format?: 'png' | 'jpg';
|
|
16
|
+
onChange?: (results: Record<string, string>) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface UseExportReturn {
|
|
19
|
+
exportArtboard: (artboardId: string, options?: ExportImageOptions) => Promise<string>;
|
|
20
|
+
exportArtboardAsBlob: (artboardId: string, options?: ExportImageOptions) => Promise<Blob>;
|
|
21
|
+
exportAllArtboards: (options?: ExportImageOptions) => Promise<Record<string, string>>;
|
|
22
|
+
exportAllArtboardsAsBlobs: (options?: ExportImageOptions) => Promise<Record<string, Blob>>;
|
|
23
|
+
startContinuousExport: (options: ContinuousExportOptions) => void;
|
|
24
|
+
stopContinuousExport: () => void;
|
|
25
|
+
isExporting: boolean;
|
|
26
|
+
isContinuousExporting: boolean;
|
|
27
|
+
progress: ExportProgress[];
|
|
28
|
+
latestExports: Record<string, string>;
|
|
29
|
+
supportsWorkerExport: boolean;
|
|
30
|
+
workerStats: {
|
|
31
|
+
totalExports: number;
|
|
32
|
+
avgExportTime: number;
|
|
33
|
+
isWorkerActive: boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hook for exporting artboards to images
|
|
38
|
+
* Must be used within EditorProvider
|
|
39
|
+
*
|
|
40
|
+
* @example Single Export
|
|
41
|
+
* ```tsx
|
|
42
|
+
* function ExportButton() {
|
|
43
|
+
* const { exportArtboard, isExporting } = useExport();
|
|
44
|
+
* const { activeArtboardId } = useArtboards();
|
|
45
|
+
*
|
|
46
|
+
* const handleExport = async () => {
|
|
47
|
+
* if (!activeArtboardId) return;
|
|
48
|
+
* const dataUrl = await exportArtboard(activeArtboardId, {
|
|
49
|
+
* scale: 3,
|
|
50
|
+
* format: 'png'
|
|
51
|
+
* });
|
|
52
|
+
* // Download or display dataUrl
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <button onClick={handleExport} disabled={isExporting}>
|
|
57
|
+
* {isExporting ? 'Exporting...' : 'Export'}
|
|
58
|
+
* </button>
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Continuous Export (Sprint 2)
|
|
64
|
+
* ```tsx
|
|
65
|
+
* function LiveMockupPreview() {
|
|
66
|
+
* const { startContinuousExport, stopContinuousExport, latestExports } = useExport();
|
|
67
|
+
* const { artboardsInfo } = useArtboards();
|
|
68
|
+
*
|
|
69
|
+
* useEffect(() => {
|
|
70
|
+
* startContinuousExport({
|
|
71
|
+
* interval: 500,
|
|
72
|
+
* scale: 3,
|
|
73
|
+
* onChange: (exports) => {
|
|
74
|
+
* // Send to mockup API
|
|
75
|
+
* Object.entries(exports).forEach(([artboardId, dataUrl]) => {
|
|
76
|
+
* const artboard = artboardsInfo.find(a => a.id === artboardId);
|
|
77
|
+
* sendToMockupAPI(artboard.name, dataUrl);
|
|
78
|
+
* });
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* return () => stopContinuousExport();
|
|
83
|
+
* }, []);
|
|
84
|
+
*
|
|
85
|
+
* return <div>Mockup preview...</div>;
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function useExport(): UseExportReturn;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EditorElement } from '../contexts/EditorContext.js';
|
|
2
|
+
/** How the image fits the element bounds. */
|
|
3
|
+
export type ImageFitMode = 'cover' | 'contain';
|
|
4
|
+
/** Options for {@link useImageBinding}. */
|
|
5
|
+
export interface ImageBindingOptions {
|
|
6
|
+
/** How the image fits the element bounds. Default: "cover". */
|
|
7
|
+
fit?: ImageFitMode;
|
|
8
|
+
}
|
|
9
|
+
/** Result returned by {@link useImageBinding}. */
|
|
10
|
+
export interface ImageBindingResult {
|
|
11
|
+
/** Current image URL (from first bound element). Empty string if disconnected. */
|
|
12
|
+
imageUrl: string;
|
|
13
|
+
/** Update image URL on all bound elements. No-op if disconnected. */
|
|
14
|
+
setImageUrl: (url: string) => void;
|
|
15
|
+
/** The first bound element, or null if no matching image element exists. */
|
|
16
|
+
element: EditorElement | null;
|
|
17
|
+
/** All bound image elements (empty array if disconnected). */
|
|
18
|
+
elements: readonly EditorElement[];
|
|
19
|
+
/** Whether at least one matching image element exists. */
|
|
20
|
+
isConnected: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Bind an external input to canvas image elements by their `name` property.
|
|
24
|
+
*
|
|
25
|
+
* Multiple elements can share the same name — `setImageUrl` updates all of them.
|
|
26
|
+
* The image URL is read from the first matching element (render order).
|
|
27
|
+
*
|
|
28
|
+
* Must be used within an `EditorProvider`.
|
|
29
|
+
*
|
|
30
|
+
* @param name - The element name to bind to.
|
|
31
|
+
* @param options - Optional configuration (fit mode, etc.).
|
|
32
|
+
* @returns Image URL value, setter, element references, and connection status.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useImageBinding(name: string, options?: ImageBindingOptions): ImageBindingResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useKeyboardShortcuts - Hook for handling keyboard shortcuts in the editor
|
|
3
|
+
* Provides copy/paste and other keyboard shortcuts
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Hook that sets up keyboard shortcuts for the editor
|
|
7
|
+
* Handles copy/paste, delete, undo/redo, and other shortcuts
|
|
8
|
+
*
|
|
9
|
+
* @param options.enabled - Whether keyboard shortcuts are active (default: true)
|
|
10
|
+
*/
|
|
11
|
+
export declare function useKeyboardShortcuts(options?: {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useSensors, DragStartEvent, DragMoveEvent, DragOverEvent, DragEndEvent, DragCancelEvent } from '@dnd-kit/core';
|
|
2
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
3
|
+
import { EditorElement } from '../contexts/EditorContext.js';
|
|
4
|
+
export interface UseLayerDndKitOptions {
|
|
5
|
+
onReorder: (draggedId: string, targetId: string, position: 'before' | 'after') => void;
|
|
6
|
+
onGroupReorder?: (draggedId: string, targetId: string, position: 'before' | 'after', groupId: string) => void;
|
|
7
|
+
onDropIntoGroup?: (draggedId: string, groupId: string) => void;
|
|
8
|
+
onDropIntoGroupAtPosition?: (draggedId: string, groupId: string, targetChildId: string, position: 'before' | 'after') => void;
|
|
9
|
+
onRemoveFromGroup?: (draggedId: string) => void;
|
|
10
|
+
findElement?: (id: string) => EditorElement | null;
|
|
11
|
+
findParentGroup?: (id: string) => GroupElement | null;
|
|
12
|
+
}
|
|
13
|
+
export interface UseLayerDndKitReturn {
|
|
14
|
+
activeId: string | null;
|
|
15
|
+
overId: string | null;
|
|
16
|
+
dropPosition: 'before' | 'after' | 'into' | null;
|
|
17
|
+
sensors: ReturnType<typeof useSensors>;
|
|
18
|
+
onDragStart: (event: DragStartEvent) => void;
|
|
19
|
+
onDragMove: (event: DragMoveEvent) => void;
|
|
20
|
+
onDragOver: (event: DragOverEvent) => void;
|
|
21
|
+
onDragEnd: (event: DragEndEvent) => void;
|
|
22
|
+
onDragCancel: (event: DragCancelEvent) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useLayerDndKit(options: UseLayerDndKitOptions): UseLayerDndKitReturn;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
2
|
+
import { EditorElement } from '../contexts/EditorContext.js';
|
|
3
|
+
export interface UseLayerDragDropOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Called when reordering top-level elements or elements in different groups.
|
|
6
|
+
* Position is already inverted for reversed display order.
|
|
7
|
+
*/
|
|
8
|
+
onReorder: (draggedId: string, targetId: string, position: 'before' | 'after') => void;
|
|
9
|
+
/**
|
|
10
|
+
* Called when reordering elements within the same group.
|
|
11
|
+
* Position is already inverted for reversed display order.
|
|
12
|
+
*/
|
|
13
|
+
onGroupReorder?: (draggedId: string, targetId: string, position: 'before' | 'after', groupId: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Called when dropping an element into a group (center drop zone).
|
|
16
|
+
*/
|
|
17
|
+
onDropIntoGroup?: (draggedId: string, groupId: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Called when dropping a top-level element between children of a group.
|
|
20
|
+
* Position is already inverted for reversed display order.
|
|
21
|
+
*/
|
|
22
|
+
onDropIntoGroupAtPosition?: (draggedId: string, groupId: string, targetChildId: string, position: 'before' | 'after') => void;
|
|
23
|
+
/**
|
|
24
|
+
* Look up an element by ID. Required for determining if a target is a group.
|
|
25
|
+
*/
|
|
26
|
+
findElement?: (id: string) => EditorElement | null;
|
|
27
|
+
/**
|
|
28
|
+
* Find the parent group of an element. Required for intra-group reordering.
|
|
29
|
+
*/
|
|
30
|
+
findParentGroup?: (id: string) => GroupElement | null;
|
|
31
|
+
}
|
|
32
|
+
export interface UseLayerDragDropReturn {
|
|
33
|
+
/** ID of the currently dragged element, or null */
|
|
34
|
+
draggedId: string | null;
|
|
35
|
+
/** ID of the element being dragged over, or null */
|
|
36
|
+
dragOverId: string | null;
|
|
37
|
+
/** Where the dragged element will be dropped relative to the target */
|
|
38
|
+
dropPosition: 'before' | 'after' | 'into' | null;
|
|
39
|
+
/** Event handlers to attach to draggable layer items */
|
|
40
|
+
handlers: {
|
|
41
|
+
onDragStart: (e: React.DragEvent, elementId: string) => void;
|
|
42
|
+
onDragOver: (e: React.DragEvent, elementId: string) => void;
|
|
43
|
+
onDrop: (e: React.DragEvent, targetId: string) => void;
|
|
44
|
+
onDragEnd: () => void;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Hook for managing drag-drop reordering in layer panels.
|
|
49
|
+
*
|
|
50
|
+
* Calculates drop position based on mouse position within the target element:
|
|
51
|
+
* - For groups: top 25% = before, middle 50% = into, bottom 25% = after
|
|
52
|
+
* - For non-groups: top/bottom split at 40%/60%
|
|
53
|
+
*
|
|
54
|
+
* Handles the display-order inversion: layers are displayed in reverse
|
|
55
|
+
* order (topmost layer first), so visual "before" maps to array "after"
|
|
56
|
+
* and vice versa. This inversion is applied before calling the callbacks.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useLayerDragDrop(options: UseLayerDragDropOptions): UseLayerDragDropReturn;
|