@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,51 @@
|
|
|
1
|
+
import { TextElement } from './TextElement.js';
|
|
2
|
+
import { Point, ResizeAnchor, TransformStartData } from '../types/index.js';
|
|
3
|
+
interface HandleInfo {
|
|
4
|
+
anchor: ResizeAnchor;
|
|
5
|
+
type?: string;
|
|
6
|
+
cursor?: string;
|
|
7
|
+
x?: number;
|
|
8
|
+
y?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class ResizeHandler {
|
|
11
|
+
/**
|
|
12
|
+
* Calculate new dimensions and position for a resize operation
|
|
13
|
+
*/
|
|
14
|
+
static calculateResize({ element, handle, dx, dy, startData, snapSystem, }: {
|
|
15
|
+
element: TextElement;
|
|
16
|
+
handle: HandleInfo;
|
|
17
|
+
dx: number;
|
|
18
|
+
dy: number;
|
|
19
|
+
startData: TransformStartData;
|
|
20
|
+
snapSystem?: {
|
|
21
|
+
activeSnaps?: {
|
|
22
|
+
x?: unknown;
|
|
23
|
+
y?: unknown;
|
|
24
|
+
};
|
|
25
|
+
} | null;
|
|
26
|
+
}): {
|
|
27
|
+
element: TextElement;
|
|
28
|
+
isFrozen?: boolean;
|
|
29
|
+
unfrozenDimensions?: {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Calculate position offset to keep opposite corner fixed
|
|
36
|
+
* Uses visual bounding box and rotation anchor for proper rotated resize
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
static _calculateFixedCornerOffset({ element, updatedElement, handle, rotationAnchor, }: {
|
|
40
|
+
element: TextElement;
|
|
41
|
+
updatedElement: TextElement;
|
|
42
|
+
handle: HandleInfo;
|
|
43
|
+
rotationAnchor: Point;
|
|
44
|
+
}): Point;
|
|
45
|
+
/**
|
|
46
|
+
* Get local coordinates of the fixed point for a given handle
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
static _getFixedLocalCoords(anchor: ResizeAnchor, width: number, height: number): Point;
|
|
50
|
+
}
|
|
51
|
+
export default ResizeHandler;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { TextElement } from './TextElement.js';
|
|
3
|
+
import { TransformStartData, ResizeAnchor } from '../types/index.js';
|
|
4
|
+
type HookStage = 'beforeResize' | 'afterResize' | 'beforePositionUpdate' | 'afterPositionUpdate';
|
|
5
|
+
interface HandleInfo {
|
|
6
|
+
anchor: ResizeAnchor;
|
|
7
|
+
type?: string;
|
|
8
|
+
cursor?: string;
|
|
9
|
+
x?: number;
|
|
10
|
+
y?: number;
|
|
11
|
+
}
|
|
12
|
+
interface ResizeParams {
|
|
13
|
+
element: TextElement;
|
|
14
|
+
handle: HandleInfo;
|
|
15
|
+
dx: number;
|
|
16
|
+
dy: number;
|
|
17
|
+
startData: TransformStartData;
|
|
18
|
+
allElements?: BaseElement[] | null;
|
|
19
|
+
snapSystem?: {
|
|
20
|
+
activeSnaps?: {
|
|
21
|
+
x?: unknown;
|
|
22
|
+
y?: unknown;
|
|
23
|
+
};
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
interface ResizeResult {
|
|
27
|
+
element: TextElement;
|
|
28
|
+
isFrozen?: boolean;
|
|
29
|
+
unfrozenDimensions?: {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
handle?: HandleInfo;
|
|
34
|
+
startData?: TransformStartData;
|
|
35
|
+
}
|
|
36
|
+
type HookFn<T> = (data: T) => T | undefined;
|
|
37
|
+
export declare class ResizePipeline {
|
|
38
|
+
hooks: Record<HookStage, HookFn<unknown>[]>;
|
|
39
|
+
constructor();
|
|
40
|
+
/**
|
|
41
|
+
* Add a hook at a specific stage
|
|
42
|
+
* @param stage - 'beforeResize', 'afterResize', 'beforePositionUpdate', 'afterPositionUpdate'
|
|
43
|
+
* @param fn - Hook function
|
|
44
|
+
*/
|
|
45
|
+
addHook(stage: HookStage, fn: HookFn<unknown>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Remove a hook
|
|
48
|
+
*/
|
|
49
|
+
removeHook(stage: HookStage, fn: HookFn<unknown>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Clear all hooks at a stage
|
|
52
|
+
*/
|
|
53
|
+
clearHooks(stage: HookStage): void;
|
|
54
|
+
/**
|
|
55
|
+
* Clear all hooks
|
|
56
|
+
*/
|
|
57
|
+
clearAllHooks(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Run hooks at a specific stage
|
|
60
|
+
*/
|
|
61
|
+
runHooks<T>(stage: HookStage, data: T): T;
|
|
62
|
+
/**
|
|
63
|
+
* Execute resize with hooks
|
|
64
|
+
*/
|
|
65
|
+
executeResize(params: ResizeParams): ResizeResult;
|
|
66
|
+
/**
|
|
67
|
+
* Execute position update with hooks
|
|
68
|
+
* Used for drag operations
|
|
69
|
+
*/
|
|
70
|
+
executePositionUpdate(position: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
}, element: BaseElement): {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Singleton instance for the application
|
|
80
|
+
* This allows hooking into resize operations globally
|
|
81
|
+
*/
|
|
82
|
+
export declare const globalResizePipeline: ResizePipeline;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TextElement } from './TextElement.js';
|
|
2
|
+
import { TransformStartData } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handle corner resize (uniform scaling)
|
|
5
|
+
* Corner handles scale both fontSize and width proportionally
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleCornerResize(element: TextElement, newWidth: number, startData: TransformStartData): void;
|
|
8
|
+
/**
|
|
9
|
+
* Handle side resize (width only, no fontSize change)
|
|
10
|
+
* Side handles only change width while keeping fontSize constant
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleSideResize(element: TextElement, anchor: string, newWidth: number, startData: TransformStartData): void;
|
|
13
|
+
/**
|
|
14
|
+
* Standard resize implementation for transforms with width-based containers
|
|
15
|
+
* Handles both corner (uniform scale) and side (width only) handles
|
|
16
|
+
*/
|
|
17
|
+
export declare function standardResize(element: TextElement, anchor: string, newWidth: number, _newHeight: number, startData: TransformStartData): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { Point } from '../types/index.js';
|
|
3
|
+
/** Named anchor points for snap alignment */
|
|
4
|
+
interface SnapAnchors {
|
|
5
|
+
topLeft: Point;
|
|
6
|
+
topRight: Point;
|
|
7
|
+
bottomLeft: Point;
|
|
8
|
+
bottomRight: Point;
|
|
9
|
+
topCenter: Point;
|
|
10
|
+
rightCenter: Point;
|
|
11
|
+
bottomCenter: Point;
|
|
12
|
+
leftCenter: Point;
|
|
13
|
+
center: Point;
|
|
14
|
+
rotation: Point;
|
|
15
|
+
[key: string]: Point;
|
|
16
|
+
}
|
|
17
|
+
/** Edge line represented by start and end points */
|
|
18
|
+
interface EdgeLine {
|
|
19
|
+
start: Point;
|
|
20
|
+
end: Point;
|
|
21
|
+
}
|
|
22
|
+
export declare class RotationAnchorResolver {
|
|
23
|
+
/**
|
|
24
|
+
* Resolve rotation anchor with clear precedence:
|
|
25
|
+
* 1. Transform's getRotationAnchor() if overridden
|
|
26
|
+
* 2. Center of visual bounding box (default)
|
|
27
|
+
*/
|
|
28
|
+
static resolve(element: BaseElement): Point;
|
|
29
|
+
/**
|
|
30
|
+
* Get all snap-able anchor points for an element
|
|
31
|
+
* Used for alignment snapping feature
|
|
32
|
+
*
|
|
33
|
+
* Returns 9 standard anchor points plus the rotation anchor:
|
|
34
|
+
* - 4 corners (top-left, top-right, bottom-left, bottom-right)
|
|
35
|
+
* - 4 edge midpoints (top, right, bottom, left)
|
|
36
|
+
* - 1 center
|
|
37
|
+
* - 1 rotation anchor (may be same as center)
|
|
38
|
+
*/
|
|
39
|
+
static getSnapAnchors(element: BaseElement): SnapAnchors;
|
|
40
|
+
/**
|
|
41
|
+
* Get edge lines for an element (for edge-to-edge snapping)
|
|
42
|
+
*
|
|
43
|
+
* Returns 4 lines representing the element's edges:
|
|
44
|
+
* - top: left to right
|
|
45
|
+
* - right: top to bottom
|
|
46
|
+
* - bottom: right to left
|
|
47
|
+
* - left: bottom to top
|
|
48
|
+
*/
|
|
49
|
+
static getEdgeLines(element: BaseElement): Record<string, EdgeLine>;
|
|
50
|
+
/**
|
|
51
|
+
* Get all anchor types as array (for iteration)
|
|
52
|
+
*/
|
|
53
|
+
static getAnchorTypes(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Check if an element has a custom rotation anchor
|
|
56
|
+
* (different from center of visual bbox)
|
|
57
|
+
*/
|
|
58
|
+
static hasCustomRotationAnchor(element: BaseElement): boolean;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RotationUtils - Centralized rotation convention utilities
|
|
3
|
+
*
|
|
4
|
+
* Convention: Clockwise rotations in UI are represented as positive degrees,
|
|
5
|
+
* but canvas rendering uses counter-clockwise rotation (hence the negative sign).
|
|
6
|
+
*/
|
|
7
|
+
export declare const RotationUtils: {
|
|
8
|
+
/**
|
|
9
|
+
* Forward transform (local → world, for rendering)
|
|
10
|
+
* Converts degrees to radians with the canvas convention (negative = clockwise)
|
|
11
|
+
* @param {number} degrees - Rotation in degrees (positive = clockwise in UI)
|
|
12
|
+
* @returns {number} Rotation in radians for canvas context
|
|
13
|
+
*/
|
|
14
|
+
toRadians(degrees: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Inverse transform (world → local, for hit testing)
|
|
17
|
+
* Converts degrees to radians without negation
|
|
18
|
+
* @param {number} degrees - Rotation in degrees
|
|
19
|
+
* @returns {number} Rotation in radians
|
|
20
|
+
*/
|
|
21
|
+
toRadiansInverse(degrees: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize angle to -180 to +180 range
|
|
24
|
+
* @param {number} degrees - Angle in degrees
|
|
25
|
+
* @returns {number} Normalized angle in range [-180, 180]
|
|
26
|
+
*/
|
|
27
|
+
normalize(degrees: number): number;
|
|
28
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { TransformHandles } from './TransformHandles.js';
|
|
3
|
+
import { InteractionStateMachine } from './InteractionStateMachine.js';
|
|
4
|
+
import { HandleInfo } from '../types/index.js';
|
|
5
|
+
interface HoverState {
|
|
6
|
+
type: 'element' | 'resize-handle' | 'rotation-handle' | null;
|
|
7
|
+
data?: BaseElement | HandleInfo | null;
|
|
8
|
+
}
|
|
9
|
+
export declare class SelectionRenderer {
|
|
10
|
+
/**
|
|
11
|
+
* Render selection box layer
|
|
12
|
+
*/
|
|
13
|
+
static renderSelectionLayer(ctx: CanvasRenderingContext2D, selectedElement: BaseElement | null, stateMachine: InteractionStateMachine, zoom?: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Render position and size info below the selected element
|
|
16
|
+
* Only shows dimensions (width x height) while resizing
|
|
17
|
+
*/
|
|
18
|
+
static renderPositionSizeInfo(ctx: CanvasRenderingContext2D, selectedElement: BaseElement | null, transformHandles: TransformHandles | null, stateMachine: InteractionStateMachine | null, zoom?: number): void;
|
|
19
|
+
/**
|
|
20
|
+
* Render transform handles layer
|
|
21
|
+
*/
|
|
22
|
+
static renderHandlesLayer(ctx: CanvasRenderingContext2D, selectedElement: BaseElement | null, transformHandles: TransformHandles, currentRotation: number, isRotating: boolean, hoverState: HoverState, stateMachine: InteractionStateMachine, zoom?: number, showRotationHandle?: boolean): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { ShapeTransformData, ShapeElementConfig, ResizeAnchor, BoundingBox, Point, TransformStartData } from '../types/index.js';
|
|
3
|
+
export declare class ShapeElement extends BaseElement {
|
|
4
|
+
transformType: 'shape';
|
|
5
|
+
transformData: ShapeTransformData;
|
|
6
|
+
constructor(config?: Partial<ShapeElementConfig>);
|
|
7
|
+
/**
|
|
8
|
+
* Get bounding box in world coordinates
|
|
9
|
+
* Returns the unrotated dimensions - rotation is handled by the renderer
|
|
10
|
+
*/
|
|
11
|
+
getBoundingBox(): BoundingBox;
|
|
12
|
+
/**
|
|
13
|
+
* Tight visual bounding box for selection chrome.
|
|
14
|
+
*
|
|
15
|
+
* `getBoundingBox()` returns the conceptual `width × height` rect
|
|
16
|
+
* the resize handles act on. Many shape types (circle, polygon,
|
|
17
|
+
* star) render *inscribed* in that rect — their visible extent is
|
|
18
|
+
* smaller than the box, leaving empty corners. The selection
|
|
19
|
+
* border / handles use this tighter bbox so it hugs what the user
|
|
20
|
+
* actually sees instead of including the empty padding.
|
|
21
|
+
*
|
|
22
|
+
* For shapes that fill their box (rectangle, ellipse, triangle,
|
|
23
|
+
* line) this falls through to `getBoundingBox()`.
|
|
24
|
+
*
|
|
25
|
+
* Stroke is intentionally excluded — same convention as
|
|
26
|
+
* `getBoundingBox()`. The chrome aligns with the *fill* edge.
|
|
27
|
+
*/
|
|
28
|
+
getVisualBoundingBox(): BoundingBox;
|
|
29
|
+
/**
|
|
30
|
+
* Get rotation anchor point (center of the shape)
|
|
31
|
+
*/
|
|
32
|
+
getRotationAnchor(): Point;
|
|
33
|
+
/**
|
|
34
|
+
* Render the shape
|
|
35
|
+
*/
|
|
36
|
+
render(ctx: CanvasRenderingContext2D, _isSelected?: boolean, _isHovered?: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Render fill+stroke to a temporary canvas at full opacity, then composite
|
|
39
|
+
* at element opacity. Prevents fill/stroke overlap from compounding.
|
|
40
|
+
*/
|
|
41
|
+
private renderWithOffscreen;
|
|
42
|
+
/**
|
|
43
|
+
* Direct render (no offscreen) — used as fallback
|
|
44
|
+
*/
|
|
45
|
+
private renderDirect;
|
|
46
|
+
/**
|
|
47
|
+
* Trace the shape path without filling or stroking — used by offscreen render
|
|
48
|
+
*/
|
|
49
|
+
private traceShapePath;
|
|
50
|
+
/**
|
|
51
|
+
* Render the stroke for this shape element
|
|
52
|
+
*/
|
|
53
|
+
private renderStroke;
|
|
54
|
+
/**
|
|
55
|
+
* Render the specific shape based on shapeType
|
|
56
|
+
*/
|
|
57
|
+
private renderShape;
|
|
58
|
+
/**
|
|
59
|
+
* Render a rectangle (with optional border radius)
|
|
60
|
+
*/
|
|
61
|
+
private renderRectangle;
|
|
62
|
+
/**
|
|
63
|
+
* Render a circle
|
|
64
|
+
*/
|
|
65
|
+
private renderCircle;
|
|
66
|
+
/**
|
|
67
|
+
* Render an ellipse
|
|
68
|
+
*/
|
|
69
|
+
private renderEllipse;
|
|
70
|
+
/**
|
|
71
|
+
* Render a triangle (isosceles, pointing up)
|
|
72
|
+
*/
|
|
73
|
+
private renderTriangle;
|
|
74
|
+
/**
|
|
75
|
+
* Render a regular polygon
|
|
76
|
+
*/
|
|
77
|
+
private renderPolygon;
|
|
78
|
+
/**
|
|
79
|
+
* Render a star
|
|
80
|
+
*/
|
|
81
|
+
private renderStar;
|
|
82
|
+
/**
|
|
83
|
+
* Render a line
|
|
84
|
+
*/
|
|
85
|
+
private renderLine;
|
|
86
|
+
/**
|
|
87
|
+
* Handle resize - maintain aspect ratio for circles, free resize for others
|
|
88
|
+
*/
|
|
89
|
+
resize(anchor: ResizeAnchor, newWidth: number, newHeight: number, startData: TransformStartData): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Get the opposite anchor (the one that should stay fixed during resize)
|
|
92
|
+
*/
|
|
93
|
+
private getOppositeAnchor;
|
|
94
|
+
/**
|
|
95
|
+
* Get the position of the fixed corner (opposite of dragged anchor)
|
|
96
|
+
*/
|
|
97
|
+
private getFixedCorner;
|
|
98
|
+
/**
|
|
99
|
+
* Get the offset of a corner from the center
|
|
100
|
+
*/
|
|
101
|
+
private getCornerOffset;
|
|
102
|
+
/**
|
|
103
|
+
* Get enabled anchors - all 8 anchors for most shapes, only corners for circles/polygons
|
|
104
|
+
*/
|
|
105
|
+
getEnabledAnchors(): ResizeAnchor[];
|
|
106
|
+
/**
|
|
107
|
+
* Clone this element
|
|
108
|
+
*/
|
|
109
|
+
clone(): ShapeElement;
|
|
110
|
+
/**
|
|
111
|
+
* Serialize to JSON
|
|
112
|
+
*/
|
|
113
|
+
toJSON(): ShapeElementConfig & {
|
|
114
|
+
id: string;
|
|
115
|
+
type: 'shape';
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
rotation: number;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export default ShapeElement;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { SpacingIndicator } from '../types/index.js';
|
|
3
|
+
interface SpacingSystemOptions {
|
|
4
|
+
detectionThreshold?: number;
|
|
5
|
+
minDistance?: number;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
showLabels?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class SpacingSystem {
|
|
10
|
+
detectionThreshold: number;
|
|
11
|
+
minDistance: number;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
showLabels: boolean;
|
|
14
|
+
indicators: SpacingIndicator[];
|
|
15
|
+
lastSnapTarget: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
} | null;
|
|
19
|
+
constructor(options?: SpacingSystemOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Enable or disable spacing detection
|
|
22
|
+
*/
|
|
23
|
+
setEnabled(enabled: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set detection threshold in pixels
|
|
26
|
+
*/
|
|
27
|
+
setDetectionThreshold(threshold: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get current spacing indicators for rendering
|
|
30
|
+
*/
|
|
31
|
+
getIndicators(): SpacingIndicator[];
|
|
32
|
+
/**
|
|
33
|
+
* Clear all spacing indicators
|
|
34
|
+
*/
|
|
35
|
+
clearIndicators(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Snap position to match consistent spacing patterns
|
|
38
|
+
* Returns adjusted position if spacing snap is detected, otherwise returns original position
|
|
39
|
+
*/
|
|
40
|
+
snapToSpacing(position: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}, movingElement: BaseElement, allElements: BaseElement[] | null): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Detect spacing between a moving element and other elements
|
|
49
|
+
* Returns spacing indicators for the closest elements in each direction
|
|
50
|
+
* Also detects consistent spacing patterns (e.g., evenly spaced rows/columns)
|
|
51
|
+
* @param showAllMeasurements - When true (Alt key held), shows all spacing measurements, not just to moving element
|
|
52
|
+
*/
|
|
53
|
+
detectSpacing(movingElement: BaseElement, allElements: BaseElement[] | null, showAllMeasurements?: boolean): SpacingIndicator[];
|
|
54
|
+
/**
|
|
55
|
+
* Detect spacing from hovered element to ALL nearby elements (when Alt key is held)
|
|
56
|
+
* Shows measurements from the hovered element to other elements within detection threshold
|
|
57
|
+
*/
|
|
58
|
+
private detectAllMeasurements;
|
|
59
|
+
/**
|
|
60
|
+
* Detect consistent spacing patterns (e.g., evenly spaced rows/columns)
|
|
61
|
+
* and create indicators for all matching spacings
|
|
62
|
+
*/
|
|
63
|
+
private detectConsistentSpacing;
|
|
64
|
+
/**
|
|
65
|
+
* Check if spacing would snap to a pattern
|
|
66
|
+
*/
|
|
67
|
+
private checkIfWouldSnap;
|
|
68
|
+
/**
|
|
69
|
+
* Helper method to add a spacing indicator in a specific direction
|
|
70
|
+
*/
|
|
71
|
+
private addIndicatorForDirection;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpatialGrid - Grid-based spatial index for O(1) amortized position lookups.
|
|
3
|
+
*
|
|
4
|
+
* Used by AlignmentSnapSystem to avoid scanning all elements when looking
|
|
5
|
+
* for snap candidates. Points are bucketed into grid cells of fixed size.
|
|
6
|
+
* Queries check only the cells that overlap the search radius, giving
|
|
7
|
+
* O(1) amortized lookup when the number of results is small relative to
|
|
8
|
+
* the total item count.
|
|
9
|
+
*/
|
|
10
|
+
/** An item stored in the spatial grid. */
|
|
11
|
+
export interface SpatialGridItem {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
id: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class SpatialGrid {
|
|
17
|
+
private cellSize;
|
|
18
|
+
private cells;
|
|
19
|
+
/** Reverse index: id -> set of cell keys that contain items with that id */
|
|
20
|
+
private idIndex;
|
|
21
|
+
constructor(cellSize: number);
|
|
22
|
+
/** Clear all entries */
|
|
23
|
+
clear(): void;
|
|
24
|
+
/** Insert a point into the grid */
|
|
25
|
+
insert(item: SpatialGridItem): void;
|
|
26
|
+
/** Remove all items with matching id */
|
|
27
|
+
removeById(id: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Query all items within `radius` of point (x, y), excluding given id.
|
|
30
|
+
*
|
|
31
|
+
* Checks all cells that overlap the axis-aligned bounding box
|
|
32
|
+
* [x - radius, x + radius] x [y - radius, y + radius].
|
|
33
|
+
* Each candidate is then distance-checked against the radius.
|
|
34
|
+
*/
|
|
35
|
+
queryNear(x: number, y: number, radius: number, excludeId?: string): SpatialGridItem[];
|
|
36
|
+
/**
|
|
37
|
+
* Query all items whose coordinate on `axis` is within `radius` of the
|
|
38
|
+
* given value, excluding a given id. Unlike `queryNear` (Euclidean),
|
|
39
|
+
* this checks only one axis -- essential for alignment snapping where
|
|
40
|
+
* two anchors may be far apart on one axis but perfectly aligned on
|
|
41
|
+
* the other.
|
|
42
|
+
*
|
|
43
|
+
* For axis='x': finds items where |item.x - value| <= radius
|
|
44
|
+
* For axis='y': finds items where |item.y - value| <= radius
|
|
45
|
+
*
|
|
46
|
+
* Scans all cells in the band along the target axis.
|
|
47
|
+
*/
|
|
48
|
+
queryNearAxis(axis: 'x' | 'y', value: number, radius: number, excludeId?: string): SpatialGridItem[];
|
|
49
|
+
/** Rebuild from a full list of items (clears existing data first) */
|
|
50
|
+
rebuild(items: SpatialGridItem[]): void;
|
|
51
|
+
/** Get the cell key for a given world-space coordinate */
|
|
52
|
+
private getCellKey;
|
|
53
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { TextAlign, BoundingBox, BaseTextElementConfig, ResizeAnchor, GlyphOverride, OpenTypeFeatures, CharacterStyle, TransformStartData, RichText } from '../types/index.js';
|
|
3
|
+
export declare class TextElement extends BaseElement {
|
|
4
|
+
richText?: RichText;
|
|
5
|
+
text: string;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
color: string;
|
|
9
|
+
textAlign: TextAlign;
|
|
10
|
+
bold: boolean;
|
|
11
|
+
italic: boolean;
|
|
12
|
+
underline: boolean;
|
|
13
|
+
strikethrough: boolean;
|
|
14
|
+
glyphOverrides?: GlyphOverride[];
|
|
15
|
+
openTypeFeatures?: OpenTypeFeatures;
|
|
16
|
+
constructor(config?: Partial<BaseTextElementConfig>);
|
|
17
|
+
/**
|
|
18
|
+
* Get bounding box in world coordinates
|
|
19
|
+
* Must be implemented by subclasses
|
|
20
|
+
*/
|
|
21
|
+
getBoundingBox(): BoundingBox;
|
|
22
|
+
/**
|
|
23
|
+
* Render the element
|
|
24
|
+
* Must be implemented by subclasses
|
|
25
|
+
*/
|
|
26
|
+
render(_ctx: CanvasRenderingContext2D, _isSelected?: boolean, _isHovered?: boolean): void;
|
|
27
|
+
/**
|
|
28
|
+
* Serialize to JSON
|
|
29
|
+
*/
|
|
30
|
+
toJSON(): BaseTextElementConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Clone this element
|
|
33
|
+
*/
|
|
34
|
+
clone(): TextElement;
|
|
35
|
+
/**
|
|
36
|
+
* Update text content
|
|
37
|
+
* @param newText - Plain text to set (resets to element defaults)
|
|
38
|
+
*/
|
|
39
|
+
setText(newText: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get the plain text content
|
|
42
|
+
*/
|
|
43
|
+
getText(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get the rich text object
|
|
46
|
+
*/
|
|
47
|
+
getRichText(): RichText;
|
|
48
|
+
/**
|
|
49
|
+
* Set the rich text object
|
|
50
|
+
*/
|
|
51
|
+
setRichText(newRichText: RichText): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get the element-level default style
|
|
54
|
+
*/
|
|
55
|
+
getDefaultStyle(): CharacterStyle;
|
|
56
|
+
/**
|
|
57
|
+
* Apply character-level formatting to a text range
|
|
58
|
+
*/
|
|
59
|
+
applyFormatting(start: number, end: number, style: CharacterStyle): void;
|
|
60
|
+
/**
|
|
61
|
+
* Update font size
|
|
62
|
+
*/
|
|
63
|
+
setFontSize(newFontSize: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Update color
|
|
66
|
+
* Updates both element-level default and all rich text spans that currently match the old color
|
|
67
|
+
*/
|
|
68
|
+
setColor(newColor: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Handle resize transform
|
|
71
|
+
* Must be implemented by subclasses
|
|
72
|
+
*/
|
|
73
|
+
resize(_anchor: ResizeAnchor, _newWidth: number, _newHeight: number, _startData: TransformStartData): void | boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Called when transform starts
|
|
76
|
+
* Returns data to be passed to resize()
|
|
77
|
+
*/
|
|
78
|
+
getTransformStartData(): TransformStartData;
|
|
79
|
+
}
|
|
80
|
+
export default TextElement;
|