@ggraphic/editor 0.0.0-stage → 0.0.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 +373 -0
- package/NOTICE +2 -0
- package/README.md +8 -2
- package/THIRD_PARTY_NOTICES +7 -0
- package/dist/CanvasEditorProvider.d.ts +214 -0
- package/dist/CanvasEditorProvider.js +10 -0
- package/dist/ai/applyOperation.d.ts +75 -0
- package/dist/ai/applyOperation.js +354 -0
- package/dist/ai/describeCanvasElements.d.ts +17 -0
- package/dist/ai/describeCanvasElements.js +148 -0
- package/dist/ai/illustrationCapability.d.ts +6 -0
- package/dist/ai/illustrationCapability.js +20 -0
- package/dist/ai/types.d.ts +91 -0
- package/dist/ai/types.js +1 -0
- package/dist/blocks/liftedBlock.d.ts +61 -0
- package/dist/blocks/liftedBlock.js +117 -0
- package/dist/brand/bindPick.d.ts +18 -0
- package/dist/brand/bindPick.js +28 -0
- package/dist/brand/bindableFields.d.ts +9 -0
- package/dist/brand/bindableFields.js +61 -0
- package/dist/brand/brandRegistry.d.ts +18 -0
- package/dist/brand/brandRegistry.js +41 -0
- package/dist/brand/composerBrand.d.ts +146 -0
- package/dist/brand/composerBrand.js +6 -0
- package/dist/collab/documentVersion.d.ts +36 -0
- package/dist/collab/documentVersion.js +139 -0
- package/dist/collab/pageElementStateKeys.d.ts +33 -0
- package/dist/collab/pageElementStateKeys.js +148 -0
- package/dist/collab/pagesDoc.d.ts +152 -0
- package/dist/collab/pagesDoc.js +434 -0
- package/dist/collab/useAwarenessState.d.ts +12 -0
- package/dist/collab/useAwarenessState.js +47 -0
- package/dist/collab/useEmitHostStateChanges.d.ts +18 -0
- package/dist/collab/useEmitHostStateChanges.js +40 -0
- package/dist/collab/useSelectionAwareness.d.ts +22 -0
- package/dist/collab/useSelectionAwareness.js +60 -0
- package/dist/collab/useYjsCanvasBinding.d.ts +7 -0
- package/dist/collab/useYjsCanvasBinding.js +21 -0
- package/dist/collab/useYjsPageStateSync.d.ts +20 -0
- package/dist/collab/useYjsPageStateSync.js +49 -0
- package/dist/collab/useYjsPages.d.ts +73 -0
- package/dist/collab/useYjsPages.js +396 -0
- package/dist/collab/wrapCallbacksWithPageSync.d.ts +3 -0
- package/dist/collab/wrapCallbacksWithPageSync.js +62 -0
- package/dist/collab/ydocKeys.d.ts +50 -0
- package/dist/collab/ydocKeys.js +50 -0
- package/dist/collab/yjsBinding.d.ts +27 -0
- package/dist/collab/yjsBinding.js +105 -0
- package/dist/common/Lightbox.d.ts +8 -0
- package/dist/common/Lightbox.js +8 -0
- package/dist/common/imageSourceTypes.d.ts +1 -0
- package/dist/common/imageSourceTypes.js +1 -0
- package/dist/components/AddPageButton.d.ts +13 -0
- package/dist/components/AddPageButton.js +13 -0
- package/dist/components/CanvasAnnouncer.d.ts +8 -0
- package/dist/components/CanvasAnnouncer.js +10 -0
- package/dist/components/CanvasContextMenu/CanvasActionSheet.d.ts +12 -0
- package/dist/components/CanvasContextMenu/CanvasActionSheet.js +145 -0
- package/dist/components/CanvasContextMenu/CanvasContextMenu.d.ts +33 -0
- package/dist/components/CanvasContextMenu/CanvasContextMenu.js +107 -0
- package/dist/components/CanvasContextMenu/canvasMenuModel.d.ts +68 -0
- package/dist/components/CanvasContextMenu/canvasMenuModel.js +203 -0
- package/dist/components/CanvasEditor/CanvasEditorShell.d.ts +32 -0
- package/dist/components/CanvasEditor/CanvasEditorShell.js +1138 -0
- package/dist/components/CanvasEditor/PageWrapper.d.ts +7 -0
- package/dist/components/CanvasEditor/PageWrapper.js +103 -0
- package/dist/components/CanvasEditor/autoSwitchTab.d.ts +11 -0
- package/dist/components/CanvasEditor/autoSwitchTab.js +15 -0
- package/dist/components/CanvasEditor/blockInsertContext.d.ts +22 -0
- package/dist/components/CanvasEditor/blockInsertContext.js +5 -0
- package/dist/components/CanvasEditor/editorShell.d.ts +99 -0
- package/dist/components/CanvasEditor/editorShell.js +20 -0
- package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.d.ts +32 -0
- package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.js +140 -0
- package/dist/components/CanvasEditor/hooks/useLoadedConfigs.d.ts +13 -0
- package/dist/components/CanvasEditor/hooks/useLoadedConfigs.js +29 -0
- package/dist/components/CanvasEditor/hooks/useMobileSheetFit.d.ts +14 -0
- package/dist/components/CanvasEditor/hooks/useMobileSheetFit.js +56 -0
- package/dist/components/CanvasEditor/hooks/usePageRefs.d.ts +18 -0
- package/dist/components/CanvasEditor/hooks/usePageRefs.js +36 -0
- package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.d.ts +25 -0
- package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.js +49 -0
- package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.d.ts +17 -0
- package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.js +70 -0
- package/dist/components/CanvasEditor/hooks/useScrollToAddedPage.d.ts +17 -0
- package/dist/components/CanvasEditor/hooks/useScrollToAddedPage.js +31 -0
- package/dist/components/CanvasEditor/hooks/useToolbarHandlers.d.ts +75 -0
- package/dist/components/CanvasEditor/hooks/useToolbarHandlers.js +69 -0
- package/dist/components/CanvasEditor/hooks/useWorkAreaDeselect.d.ts +6 -0
- package/dist/components/CanvasEditor/hooks/useWorkAreaDeselect.js +56 -0
- package/dist/components/CanvasEditor/layersTab.d.ts +13 -0
- package/dist/components/CanvasEditor/layersTab.js +27 -0
- package/dist/components/CanvasEditor/mobileSelectionArea.d.ts +8 -0
- package/dist/components/CanvasEditor/mobileSelectionArea.js +27 -0
- package/dist/components/CanvasEditor/types.d.ts +202 -0
- package/dist/components/CanvasEditor/types.js +1 -0
- package/dist/components/CanvasEditorSkeleton.d.ts +16 -0
- package/dist/components/CanvasEditorSkeleton.js +24 -0
- package/dist/components/CanvasMetaBar.d.ts +16 -0
- package/dist/components/CanvasMetaBar.js +33 -0
- package/dist/components/CanvasRenderLayer.d.ts +37 -0
- package/dist/components/CanvasRenderLayer.js +54 -0
- package/dist/components/CanvasTextOverlay.d.ts +126 -0
- package/dist/components/CanvasTextOverlay.js +525 -0
- package/dist/components/ConfigCanvas.d.ts +35 -0
- package/dist/components/ConfigCanvas.js +30 -0
- package/dist/components/CropGhostOverlay.d.ts +13 -0
- package/dist/components/CropGhostOverlay.js +56 -0
- package/dist/components/CustomColorSwatch.d.ts +35 -0
- package/dist/components/CustomColorSwatch.js +80 -0
- package/dist/components/DownloadNotice.d.ts +7 -0
- package/dist/components/DownloadNotice.js +7 -0
- package/dist/components/GenericCanvas.d.ts +309 -0
- package/dist/components/GenericCanvas.js +780 -0
- package/dist/components/GenericCanvasElement.d.ts +34 -0
- package/dist/components/GenericCanvasElement.js +267 -0
- package/dist/components/MobileSelectionPill.d.ts +40 -0
- package/dist/components/MobileSelectionPill.js +85 -0
- package/dist/components/MultiSelectionTransformer.d.ts +39 -0
- package/dist/components/MultiSelectionTransformer.js +107 -0
- package/dist/components/PagePreview.d.ts +14 -0
- package/dist/components/PagePreview.js +63 -0
- package/dist/components/PageThumbnailStrip.d.ts +25 -0
- package/dist/components/PageThumbnailStrip.js +46 -0
- package/dist/components/PageToolbar.d.ts +12 -0
- package/dist/components/PageToolbar.js +20 -0
- package/dist/components/PrintGuides.d.ts +13 -0
- package/dist/components/PrintGuides.js +28 -0
- package/dist/components/RemoteSelectionOverlay.d.ts +15 -0
- package/dist/components/RemoteSelectionOverlay.js +29 -0
- package/dist/components/RichTextField.d.ts +34 -0
- package/dist/components/RichTextField.js +212 -0
- package/dist/components/SelectionPill.d.ts +56 -0
- package/dist/components/SelectionPill.js +123 -0
- package/dist/components/SlideNotesPanel.d.ts +13 -0
- package/dist/components/SlideNotesPanel.js +28 -0
- package/dist/components/SlotBudgetStatus.d.ts +12 -0
- package/dist/components/SlotBudgetStatus.js +64 -0
- package/dist/components/StandaloneCanvas.d.ts +33 -0
- package/dist/components/StandaloneCanvas.js +61 -0
- package/dist/components/TextFormatButtons.d.ts +61 -0
- package/dist/components/TextFormatButtons.js +123 -0
- package/dist/components/TextFormatControls.d.ts +26 -0
- package/dist/components/TextFormatControls.js +73 -0
- package/dist/components/Toolbar.d.ts +40 -0
- package/dist/components/Toolbar.js +26 -0
- package/dist/components/ToolbarStateBridge.d.ts +72 -0
- package/dist/components/ToolbarStateBridge.js +298 -0
- package/dist/components/TopBar/AutoSaveIndicator.d.ts +8 -0
- package/dist/components/TopBar/AutoSaveIndicator.js +44 -0
- package/dist/components/TopBar/ContextControls.d.ts +107 -0
- package/dist/components/TopBar/ContextControls.js +319 -0
- package/dist/components/TopBar/ContextToolbar.d.ts +14 -0
- package/dist/components/TopBar/ContextToolbar.js +20 -0
- package/dist/components/TopBar/CropModeControls.d.ts +35 -0
- package/dist/components/TopBar/CropModeControls.js +84 -0
- package/dist/components/TopBar/DownloadSection.d.ts +47 -0
- package/dist/components/TopBar/DownloadSection.js +102 -0
- package/dist/components/TopBar/MobileSelectionBar.d.ts +16 -0
- package/dist/components/TopBar/MobileSelectionBar.js +26 -0
- package/dist/components/TopBar/MobileSelectionControls.d.ts +10 -0
- package/dist/components/TopBar/MobileSelectionControls.js +43 -0
- package/dist/components/TopBar/MultiSelectionToolbar.d.ts +19 -0
- package/dist/components/TopBar/MultiSelectionToolbar.js +30 -0
- package/dist/components/TopBar/ShareDropdown.d.ts +54 -0
- package/dist/components/TopBar/ShareDropdown.js +110 -0
- package/dist/components/TopBar/TopBar.d.ts +6 -0
- package/dist/components/TopBar/TopBar.js +6 -0
- package/dist/components/TopBar/barTiles.d.ts +15 -0
- package/dist/components/TopBar/barTiles.js +34 -0
- package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.d.ts +28 -0
- package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.js +26 -0
- package/dist/components/TopBar/modules/FloatingBackgroundControls.d.ts +38 -0
- package/dist/components/TopBar/modules/FloatingBackgroundControls.js +133 -0
- package/dist/components/TopBar/modules/FloatingColorPicker.d.ts +16 -0
- package/dist/components/TopBar/modules/FloatingColorPicker.js +87 -0
- package/dist/components/TopBar/modules/FloatingFontRoleControl.d.ts +17 -0
- package/dist/components/TopBar/modules/FloatingFontRoleControl.js +37 -0
- package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +7 -0
- package/dist/components/TopBar/modules/FloatingFontSizeControl.js +22 -0
- package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +9 -0
- package/dist/components/TopBar/modules/FloatingGradientControl.js +35 -0
- package/dist/components/TopBar/modules/FloatingHistoryControls.d.ts +11 -0
- package/dist/components/TopBar/modules/FloatingHistoryControls.js +19 -0
- package/dist/components/TopBar/modules/FloatingImageLookControl.d.ts +9 -0
- package/dist/components/TopBar/modules/FloatingImageLookControl.js +15 -0
- package/dist/components/TopBar/modules/FloatingLayerControls.d.ts +9 -0
- package/dist/components/TopBar/modules/FloatingLayerControls.js +9 -0
- package/dist/components/TopBar/modules/FloatingOpacityControl.d.ts +11 -0
- package/dist/components/TopBar/modules/FloatingOpacityControl.js +19 -0
- package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +11 -0
- package/dist/components/TopBar/modules/FloatingOutlineControl.js +31 -0
- package/dist/components/TopBar/modules/FloatingPositionControl.d.ts +38 -0
- package/dist/components/TopBar/modules/FloatingPositionControl.js +74 -0
- package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +12 -0
- package/dist/components/TopBar/modules/FloatingShadowControl.js +40 -0
- package/dist/components/TopBar/modules/FloatingTextAlignControl.d.ts +12 -0
- package/dist/components/TopBar/modules/FloatingTextAlignControl.js +27 -0
- package/dist/components/TransformHud.d.ts +11 -0
- package/dist/components/TransformHud.js +121 -0
- package/dist/components/WholeTextFormatControls.d.ts +10 -0
- package/dist/components/WholeTextFormatControls.js +37 -0
- package/dist/components/ZoomableViewport.d.ts +6 -0
- package/dist/components/ZoomableViewport.js +4 -0
- package/dist/components/accentMark.d.ts +20 -0
- package/dist/components/accentMark.js +24 -0
- package/dist/components/canvasItemLock.d.ts +13 -0
- package/dist/components/canvasItemLock.js +12 -0
- package/dist/components/kindRenderers.d.ts +118 -0
- package/dist/components/kindRenderers.js +151 -0
- package/dist/components/markColor.d.ts +13 -0
- package/dist/components/markColor.js +21 -0
- package/dist/components/markerMark.d.ts +19 -0
- package/dist/components/markerMark.js +26 -0
- package/dist/composer/cardFollowsText.d.ts +17 -0
- package/dist/composer/cardFollowsText.js +34 -0
- package/dist/composer/marks.d.ts +4 -0
- package/dist/composer/marks.js +15 -0
- package/dist/composer/steckbriefLayout.d.ts +147 -0
- package/dist/composer/steckbriefLayout.js +468 -0
- package/dist/composer/textFit.d.ts +31 -0
- package/dist/composer/textFit.js +89 -0
- package/dist/configs/buildSharepicText.d.ts +5 -0
- package/dist/configs/buildSharepicText.js +58 -0
- package/dist/configs/configLoader.d.ts +34 -0
- package/dist/configs/configLoader.js +60 -0
- package/dist/configs/factory/actionFactories.d.ts +172 -0
- package/dist/configs/factory/actionFactories.js +611 -0
- package/dist/configs/factory/baseTypes.d.ts +150 -0
- package/dist/configs/factory/baseTypes.js +8 -0
- package/dist/configs/factory/carryInstanceState.d.ts +82 -0
- package/dist/configs/factory/carryInstanceState.js +121 -0
- package/dist/configs/factory/createTextElement.d.ts +63 -0
- package/dist/configs/factory/createTextElement.js +63 -0
- package/dist/configs/factory/defineSection.d.ts +45 -0
- package/dist/configs/factory/defineSection.js +45 -0
- package/dist/configs/factory/layoutAccessors.d.ts +15 -0
- package/dist/configs/factory/layoutAccessors.js +20 -0
- package/dist/configs/featureInjector.d.ts +40 -0
- package/dist/configs/featureInjector.js +184 -0
- package/dist/configs/pageInheritance.d.ts +8 -0
- package/dist/configs/pageInheritance.js +82 -0
- package/dist/configs/placeholders.d.ts +14 -0
- package/dist/configs/placeholders.js +33 -0
- package/dist/configs/shareSection.d.ts +11 -0
- package/dist/configs/shareSection.js +65 -0
- package/dist/configs/types.d.ts +420 -0
- package/dist/configs/types.js +1 -0
- package/dist/configs/unifiedTabs.d.ts +26 -0
- package/dist/configs/unifiedTabs.js +6 -0
- package/dist/editorSeamTypes.d.ts +41 -0
- package/dist/editorSeamTypes.js +1 -0
- package/dist/export/pptx/buildPptxModel.d.ts +44 -0
- package/dist/export/pptx/buildPptxModel.js +612 -0
- package/dist/export/pptx/exportPptxDeck.d.ts +23 -0
- package/dist/export/pptx/exportPptxDeck.js +77 -0
- package/dist/export/pptx/pptxFonts.d.ts +26 -0
- package/dist/export/pptx/pptxFonts.js +41 -0
- package/dist/export/pptx/pptxUnits.d.ts +27 -0
- package/dist/export/pptx/pptxUnits.js +54 -0
- package/dist/export/pptx/textModel.d.ts +13 -0
- package/dist/export/pptx/textModel.js +115 -0
- package/dist/export/pptx/types.d.ts +161 -0
- package/dist/export/pptx/types.js +11 -0
- package/dist/export/pptx/writePptx.d.ts +40 -0
- package/dist/export/pptx/writePptx.js +206 -0
- package/dist/export/pptx/writeText.d.ts +19 -0
- package/dist/export/pptx/writeText.js +120 -0
- package/dist/export/printExport.d.ts +42 -0
- package/dist/export/printExport.js +94 -0
- package/dist/export/printPdf.d.ts +103 -0
- package/dist/export/printPdf.js +144 -0
- package/dist/export/slidesPdf.d.ts +9 -0
- package/dist/export/slidesPdf.js +31 -0
- package/dist/formats/index.d.ts +115 -0
- package/dist/formats/index.js +287 -0
- package/dist/groups/pageGroups.d.ts +32 -0
- package/dist/groups/pageGroups.js +91 -0
- package/dist/hooks/index.d.ts +29 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/useAiImageGeneration.d.ts +15 -0
- package/dist/hooks/useAiImageGeneration.js +73 -0
- package/dist/hooks/useAnnounce.d.ts +27 -0
- package/dist/hooks/useAnnounce.js +47 -0
- package/dist/hooks/useBoxSnap.d.ts +37 -0
- package/dist/hooks/useBoxSnap.js +49 -0
- package/dist/hooks/useCanvasAutoSave.d.ts +33 -0
- package/dist/hooks/useCanvasAutoSave.js +259 -0
- package/dist/hooks/useCanvasElementHandlers.d.ts +182 -0
- package/dist/hooks/useCanvasElementHandlers.js +326 -0
- package/dist/hooks/useCanvasHistorySetup.d.ts +37 -0
- package/dist/hooks/useCanvasHistorySetup.js +113 -0
- package/dist/hooks/useCanvasInteractions.d.ts +31 -0
- package/dist/hooks/useCanvasInteractions.js +103 -0
- package/dist/hooks/useCanvasKeyboardHandlers.d.ts +37 -0
- package/dist/hooks/useCanvasKeyboardHandlers.js +280 -0
- package/dist/hooks/useCanvasStoreReset.d.ts +25 -0
- package/dist/hooks/useCanvasStoreReset.js +35 -0
- package/dist/hooks/useCanvasUndoRedo.d.ts +34 -0
- package/dist/hooks/useCanvasUndoRedo.js +213 -0
- package/dist/hooks/useContextPress.d.ts +14 -0
- package/dist/hooks/useContextPress.js +45 -0
- package/dist/hooks/useCropSession.d.ts +23 -0
- package/dist/hooks/useCropSession.js +69 -0
- package/dist/hooks/useDebounce.d.ts +1 -0
- package/dist/hooks/useDebounce.js +14 -0
- package/dist/hooks/useDeckAutoSave.d.ts +30 -0
- package/dist/hooks/useDeckAutoSave.js +234 -0
- package/dist/hooks/useDeepSelect.d.ts +18 -0
- package/dist/hooks/useDeepSelect.js +135 -0
- package/dist/hooks/useElementSnapping.d.ts +13 -0
- package/dist/hooks/useElementSnapping.js +26 -0
- package/dist/hooks/useEmojiCatalog.d.ts +3 -0
- package/dist/hooks/useEmojiCatalog.js +13 -0
- package/dist/hooks/useFloatingModuleHandlers.d.ts +52 -0
- package/dist/hooks/useFloatingModuleHandlers.js +285 -0
- package/dist/hooks/useFloatingModuleState.d.ts +83 -0
- package/dist/hooks/useFloatingModuleState.js +250 -0
- package/dist/hooks/useFontGeneration.d.ts +10 -0
- package/dist/hooks/useFontGeneration.js +77 -0
- package/dist/hooks/useFontLoader.d.ts +53 -0
- package/dist/hooks/useFontLoader.js +129 -0
- package/dist/hooks/useGeometryReporter.d.ts +19 -0
- package/dist/hooks/useGeometryReporter.js +41 -0
- package/dist/hooks/useHoverOutline.d.ts +8 -0
- package/dist/hooks/useHoverOutline.js +78 -0
- package/dist/hooks/useIconCatalog.d.ts +12 -0
- package/dist/hooks/useIconCatalog.js +30 -0
- package/dist/hooks/useIconSearch.d.ts +2 -0
- package/dist/hooks/useIconSearch.js +14 -0
- package/dist/hooks/useIconSetsFor.d.ts +8 -0
- package/dist/hooks/useIconSetsFor.js +30 -0
- package/dist/hooks/useImageCoverFit.d.ts +17 -0
- package/dist/hooks/useImageCoverFit.js +35 -0
- package/dist/hooks/useIsCanvasMobile.d.ts +3 -0
- package/dist/hooks/useIsCanvasMobile.js +19 -0
- package/dist/hooks/useMarqueeSelection.d.ts +27 -0
- package/dist/hooks/useMarqueeSelection.js +140 -0
- package/dist/hooks/useMobileSheet.d.ts +48 -0
- package/dist/hooks/useMobileSheet.js +282 -0
- package/dist/hooks/useMultiPageExport.d.ts +30 -0
- package/dist/hooks/useMultiPageExport.js +117 -0
- package/dist/hooks/usePageManager.d.ts +132 -0
- package/dist/hooks/usePageManager.js +399 -0
- package/dist/hooks/usePageThumbnails.d.ts +10 -0
- package/dist/hooks/usePageThumbnails.js +122 -0
- package/dist/hooks/usePaginatedIcons.d.ts +11 -0
- package/dist/hooks/usePaginatedIcons.js +46 -0
- package/dist/hooks/useRovingToolbar.d.ts +17 -0
- package/dist/hooks/useRovingToolbar.js +76 -0
- package/dist/hooks/useSelectionAnnouncement.d.ts +13 -0
- package/dist/hooks/useSelectionAnnouncement.js +68 -0
- package/dist/hooks/useSnapScheduler.d.ts +20 -0
- package/dist/hooks/useSnapScheduler.js +61 -0
- package/dist/hooks/useTrackUnsplashDownload.d.ts +6 -0
- package/dist/hooks/useTrackUnsplashDownload.js +19 -0
- package/dist/hooks/useZoomGestures.d.ts +35 -0
- package/dist/hooks/useZoomGestures.js +185 -0
- package/dist/hostServices.d.ts +308 -0
- package/dist/hostServices.js +107 -0
- package/dist/i18n/de.d.ts +895 -0
- package/dist/i18n/de.js +959 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.js +948 -0
- package/dist/i18n/messages.d.ts +28 -0
- package/dist/i18n/messages.js +66 -0
- package/dist/layouts/CanvasEditorLayout.d.ts +28 -0
- package/dist/layouts/CanvasEditorLayout.js +56 -0
- package/dist/layouts/index.d.ts +2 -0
- package/dist/layouts/index.js +2 -0
- package/dist/primitives/AssetPrimitive.d.ts +24 -0
- package/dist/primitives/AssetPrimitive.js +158 -0
- package/dist/primitives/CanvasBackground.d.ts +33 -0
- package/dist/primitives/CanvasBackground.js +44 -0
- package/dist/primitives/CanvasIcons.d.ts +19 -0
- package/dist/primitives/CanvasIcons.js +46 -0
- package/dist/primitives/CanvasImage.d.ts +73 -0
- package/dist/primitives/CanvasImage.js +460 -0
- package/dist/primitives/CanvasRichText.d.ts +25 -0
- package/dist/primitives/CanvasRichText.js +281 -0
- package/dist/primitives/CanvasStage.d.ts +84 -0
- package/dist/primitives/CanvasStage.js +291 -0
- package/dist/primitives/CanvasText.d.ts +91 -0
- package/dist/primitives/CanvasText.js +293 -0
- package/dist/primitives/ChartPrimitive.d.ts +24 -0
- package/dist/primitives/ChartPrimitive.js +318 -0
- package/dist/primitives/CircleBadge.d.ts +43 -0
- package/dist/primitives/CircleBadge.js +233 -0
- package/dist/primitives/FramePrimitive.d.ts +14 -0
- package/dist/primitives/FramePrimitive.js +406 -0
- package/dist/primitives/IconPrimitive.d.ts +28 -0
- package/dist/primitives/IconPrimitive.js +119 -0
- package/dist/primitives/IllustrationPrimitive.d.ts +16 -0
- package/dist/primitives/IllustrationPrimitive.js +184 -0
- package/dist/primitives/PillBadge.d.ts +45 -0
- package/dist/primitives/PillBadge.js +237 -0
- package/dist/primitives/ShapePrimitive.d.ts +12 -0
- package/dist/primitives/ShapePrimitive.js +521 -0
- package/dist/primitives/SnapGuidelines.d.ts +19 -0
- package/dist/primitives/SnapGuidelines.js +34 -0
- package/dist/primitives/UserImagePrimitive.d.ts +30 -0
- package/dist/primitives/UserImagePrimitive.js +494 -0
- package/dist/primitives/index.d.ts +18 -0
- package/dist/primitives/index.js +11 -0
- package/dist/sidebar/SidebarPanel.d.ts +8 -0
- package/dist/sidebar/SidebarPanel.js +219 -0
- package/dist/sidebar/SidebarTabBar.d.ts +2 -0
- package/dist/sidebar/SidebarTabBar.js +31 -0
- package/dist/sidebar/SubsectionTabBar.d.ts +13 -0
- package/dist/sidebar/SubsectionTabBar.js +30 -0
- package/dist/sidebar/UserUploadsProvider.d.ts +31 -0
- package/dist/sidebar/UserUploadsProvider.js +139 -0
- package/dist/sidebar/components/AltTextField.d.ts +21 -0
- package/dist/sidebar/components/AltTextField.js +60 -0
- package/dist/sidebar/components/SidebarHint.d.ts +7 -0
- package/dist/sidebar/components/SidebarHint.js +38 -0
- package/dist/sidebar/components/SidebarSlider.d.ts +16 -0
- package/dist/sidebar/components/SidebarSlider.js +9 -0
- package/dist/sidebar/components/TextFieldPrimitives.d.ts +26 -0
- package/dist/sidebar/components/TextFieldPrimitives.js +56 -0
- package/dist/sidebar/sections/ChartSettingsSection.d.ts +9 -0
- package/dist/sidebar/sections/ChartSettingsSection.js +75 -0
- package/dist/sidebar/sections/CombinedTextSection.d.ts +16 -0
- package/dist/sidebar/sections/CombinedTextSection.js +42 -0
- package/dist/sidebar/sections/DiagrammeSection.d.ts +9 -0
- package/dist/sidebar/sections/DiagrammeSection.js +41 -0
- package/dist/sidebar/sections/EffectsSection.d.ts +20 -0
- package/dist/sidebar/sections/EffectsSection.js +23 -0
- package/dist/sidebar/sections/FormenSection.d.ts +26 -0
- package/dist/sidebar/sections/FormenSection.js +428 -0
- package/dist/sidebar/sections/FrameSettingsSection.d.ts +8 -0
- package/dist/sidebar/sections/FrameSettingsSection.js +26 -0
- package/dist/sidebar/sections/GenericShareSection.d.ts +26 -0
- package/dist/sidebar/sections/GenericShareSection.js +262 -0
- package/dist/sidebar/sections/IconsSection.d.ts +8 -0
- package/dist/sidebar/sections/IconsSection.js +55 -0
- package/dist/sidebar/sections/IllustrationSettings.d.ts +9 -0
- package/dist/sidebar/sections/IllustrationSettings.js +32 -0
- package/dist/sidebar/sections/IllustrationThumb.d.ts +7 -0
- package/dist/sidebar/sections/IllustrationThumb.js +15 -0
- package/dist/sidebar/sections/ImageAdjustSection.d.ts +13 -0
- package/dist/sidebar/sections/ImageAdjustSection.js +84 -0
- package/dist/sidebar/sections/LayersSection.d.ts +25 -0
- package/dist/sidebar/sections/LayersSection.js +155 -0
- package/dist/sidebar/sections/RahmenSection.d.ts +7 -0
- package/dist/sidebar/sections/RahmenSection.js +18 -0
- package/dist/sidebar/sections/StudioGallery.d.ts +33 -0
- package/dist/sidebar/sections/StudioGallery.js +58 -0
- package/dist/sidebar/sections/UploadsSection.d.ts +11 -0
- package/dist/sidebar/sections/UploadsSection.js +130 -0
- package/dist/sidebar/sections/assets/AssetsSection.d.ts +59 -0
- package/dist/sidebar/sections/assets/AssetsSection.js +27 -0
- package/dist/sidebar/sections/assets/BackgroundCatalog.d.ts +9 -0
- package/dist/sidebar/sections/assets/BackgroundCatalog.js +49 -0
- package/dist/sidebar/sections/assets/CategoryCard.d.ts +14 -0
- package/dist/sidebar/sections/assets/CategoryCard.js +15 -0
- package/dist/sidebar/sections/assets/ElementGrid.d.ts +14 -0
- package/dist/sidebar/sections/assets/ElementGrid.js +34 -0
- package/dist/sidebar/sections/assets/ElementThumb.d.ts +10 -0
- package/dist/sidebar/sections/assets/ElementThumb.js +59 -0
- package/dist/sidebar/sections/assets/ElementTile.d.ts +32 -0
- package/dist/sidebar/sections/assets/ElementTile.js +60 -0
- package/dist/sidebar/sections/assets/ElementsPanel.d.ts +7 -0
- package/dist/sidebar/sections/assets/ElementsPanel.js +249 -0
- package/dist/sidebar/sections/assets/EmojiTonePicker.d.ts +8 -0
- package/dist/sidebar/sections/assets/EmojiTonePicker.js +26 -0
- package/dist/sidebar/sections/assets/FotosCatalog.d.ts +12 -0
- package/dist/sidebar/sections/assets/FotosCatalog.js +41 -0
- package/dist/sidebar/sections/assets/IconifyCatalog.d.ts +14 -0
- package/dist/sidebar/sections/assets/IconifyCatalog.js +133 -0
- package/dist/sidebar/sections/assets/RecentCarousel.d.ts +7 -0
- package/dist/sidebar/sections/assets/RecentCarousel.js +42 -0
- package/dist/sidebar/sections/assets/StickerCatalog.d.ts +14 -0
- package/dist/sidebar/sections/assets/StickerCatalog.js +49 -0
- package/dist/sidebar/sections/assets/constants.d.ts +4 -0
- package/dist/sidebar/sections/assets/constants.js +15 -0
- package/dist/sidebar/sections/assets/elementPanelHost.d.ts +45 -0
- package/dist/sidebar/sections/assets/elementPanelHost.js +1 -0
- package/dist/sidebar/sections/assets/elementSearch.d.ts +10 -0
- package/dist/sidebar/sections/assets/elementSearch.js +38 -0
- package/dist/sidebar/sections/assets/elementTypes.d.ts +67 -0
- package/dist/sidebar/sections/assets/elementTypes.js +24 -0
- package/dist/sidebar/sections/assets/index.d.ts +3 -0
- package/dist/sidebar/sections/assets/index.js +3 -0
- package/dist/sidebar/sections/assets/useElementCatalog.d.ts +42 -0
- package/dist/sidebar/sections/assets/useElementCatalog.js +371 -0
- package/dist/sidebar/sections/assets/useRecentElements.d.ts +21 -0
- package/dist/sidebar/sections/assets/useRecentElements.js +67 -0
- package/dist/sidebar/sections/assets/useStockPhotos.d.ts +22 -0
- package/dist/sidebar/sections/assets/useStockPhotos.js +96 -0
- package/dist/sidebar/sections/effects/EffectCard.d.ts +11 -0
- package/dist/sidebar/sections/effects/EffectCard.js +14 -0
- package/dist/sidebar/sections/effects/GradientSettings.d.ts +10 -0
- package/dist/sidebar/sections/effects/GradientSettings.js +32 -0
- package/dist/sidebar/sections/effects/OutlineSettings.d.ts +12 -0
- package/dist/sidebar/sections/effects/OutlineSettings.js +28 -0
- package/dist/sidebar/sections/effects/ShadowSettings.d.ts +13 -0
- package/dist/sidebar/sections/effects/ShadowSettings.js +37 -0
- package/dist/sidebar/sections/effects/effectsFor.d.ts +16 -0
- package/dist/sidebar/sections/effects/effectsFor.js +24 -0
- package/dist/sidebar/sections/index.d.ts +28 -0
- package/dist/sidebar/sections/index.js +36 -0
- package/dist/sidebar/sections/lazyWithPreload.d.ts +11 -0
- package/dist/sidebar/sections/lazyWithPreload.js +29 -0
- package/dist/sidebar/sections/tools/AiCreateTool.d.ts +4 -0
- package/dist/sidebar/sections/tools/AiCreateTool.js +58 -0
- package/dist/sidebar/sections/tools/AiEditTool.d.ts +4 -0
- package/dist/sidebar/sections/tools/AiEditTool.js +57 -0
- package/dist/sidebar/sections/tools/AltTextTool.d.ts +11 -0
- package/dist/sidebar/sections/tools/AltTextTool.js +78 -0
- package/dist/sidebar/sections/tools/BlobCreatorTool.d.ts +5 -0
- package/dist/sidebar/sections/tools/BlobCreatorTool.js +85 -0
- package/dist/sidebar/sections/tools/GradientTextTool.d.ts +5 -0
- package/dist/sidebar/sections/tools/GradientTextTool.js +102 -0
- package/dist/sidebar/sections/tools/ImageInputPicker.d.ts +7 -0
- package/dist/sidebar/sections/tools/ImageInputPicker.js +68 -0
- package/dist/sidebar/sections/tools/QRCodeTool.d.ts +5 -0
- package/dist/sidebar/sections/tools/QRCodeTool.js +63 -0
- package/dist/sidebar/sections/tools/RemoveBackgroundTool.d.ts +4 -0
- package/dist/sidebar/sections/tools/RemoveBackgroundTool.js +52 -0
- package/dist/sidebar/sections/tools/TextPathCreatorTool.d.ts +5 -0
- package/dist/sidebar/sections/tools/TextPathCreatorTool.js +123 -0
- package/dist/sidebar/sections/tools/ToolPanel.d.ts +26 -0
- package/dist/sidebar/sections/tools/ToolPanel.js +13 -0
- package/dist/sidebar/sections/tools/ToolTiles.d.ts +5 -0
- package/dist/sidebar/sections/tools/ToolTiles.js +76 -0
- package/dist/sidebar/sections/tools/ToolsSection.d.ts +15 -0
- package/dist/sidebar/sections/tools/ToolsSection.js +149 -0
- package/dist/sidebar/sections/tools/UnsplashLimitNotice.d.ts +8 -0
- package/dist/sidebar/sections/tools/UnsplashLimitNotice.js +22 -0
- package/dist/sidebar/sections/tools/UnsplashTool.d.ts +10 -0
- package/dist/sidebar/sections/tools/UnsplashTool.js +47 -0
- package/dist/sidebar/sections/tools/index.d.ts +1 -0
- package/dist/sidebar/sections/tools/index.js +2 -0
- package/dist/sidebar/sections/tools/toolTiles.css +335 -0
- package/dist/sidebar/sections/tools/useToolImagePlacement.d.ts +19 -0
- package/dist/sidebar/sections/tools/useToolImagePlacement.js +23 -0
- package/dist/sidebar/sections/whenIdle.d.ts +2 -0
- package/dist/sidebar/sections/whenIdle.js +10 -0
- package/dist/sidebar/sidebarStyles.d.ts +60 -0
- package/dist/sidebar/sidebarStyles.js +61 -0
- package/dist/sidebar/tabTypes.d.ts +27 -0
- package/dist/sidebar/tabTypes.js +1 -0
- package/dist/sidebar/types.d.ts +43 -0
- package/dist/sidebar/types.js +1 -0
- package/dist/sidebar/useImagePlacement.d.ts +17 -0
- package/dist/sidebar/useImagePlacement.js +28 -0
- package/dist/stores/AutoSaveStoreProvider.d.ts +28 -0
- package/dist/stores/AutoSaveStoreProvider.js +45 -0
- package/dist/stores/CanvasStoreProvider.d.ts +43 -0
- package/dist/stores/CanvasStoreProvider.js +74 -0
- package/dist/stores/createAutoSaveStore.d.ts +50 -0
- package/dist/stores/createAutoSaveStore.js +42 -0
- package/dist/stores/createCanvasEditorStore.d.ts +126 -0
- package/dist/stores/createCanvasEditorStore.js +266 -0
- package/dist/stores/useAutoSaveStore.d.ts +12 -0
- package/dist/stores/useAutoSaveStore.js +12 -0
- package/dist/styles/editor.css +445 -0
- package/dist/styles/index.css +4 -0
- package/dist/styles/tailwind.css +239 -0
- package/dist/styles/tokens.css +199 -0
- package/dist/templates/fontWidths.generated.d.ts +1 -0
- package/dist/templates/fontWidths.generated.js +17 -0
- package/dist/templates/registry.d.ts +59 -0
- package/dist/templates/registry.js +40 -0
- package/dist/templates/templateGeometry.d.ts +32 -0
- package/dist/templates/templateGeometry.js +887 -0
- package/dist/templates/testKinds.d.ts +15 -0
- package/dist/templates/testKinds.js +151 -0
- package/dist/testing/fixtureTemplates.d.ts +13 -0
- package/dist/testing/fixtureTemplates.js +376 -0
- package/dist/testing/stampKind.d.ts +91 -0
- package/dist/testing/stampKind.js +56 -0
- package/dist/types/editorTypes.d.ts +65 -0
- package/dist/types/editorTypes.js +21 -0
- package/dist/ui/alert-dialog.d.ts +18 -0
- package/dist/ui/alert-dialog.js +42 -0
- package/dist/ui/button.d.ts +10 -0
- package/dist/ui/button.js +29 -0
- package/dist/ui/dialog.d.ts +15 -0
- package/dist/ui/dialog.js +53 -0
- package/dist/ui/icon-button.d.ts +18 -0
- package/dist/ui/icon-button.js +54 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +6 -0
- package/dist/ui/label.d.ts +4 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/masonry-grid.d.ts +11 -0
- package/dist/ui/masonry-grid.js +43 -0
- package/dist/ui/popover.d.ts +10 -0
- package/dist/ui/popover.js +26 -0
- package/dist/ui/select.d.ts +15 -0
- package/dist/ui/select.js +38 -0
- package/dist/ui/skeleton.d.ts +2 -0
- package/dist/ui/skeleton.js +7 -0
- package/dist/ui/switch.d.ts +6 -0
- package/dist/ui/switch.js +8 -0
- package/dist/utils/__snapshots__/kindSelection.vitest.ts.snap +1086 -0
- package/dist/utils/alignment.d.ts +21 -0
- package/dist/utils/alignment.js +54 -0
- package/dist/utils/axisLock.d.ts +30 -0
- package/dist/utils/axisLock.js +78 -0
- package/dist/utils/backgroundPhotoCrop.d.ts +28 -0
- package/dist/utils/backgroundPhotoCrop.js +28 -0
- package/dist/utils/balkenUtils.d.ts +22 -0
- package/dist/utils/balkenUtils.js +8 -0
- package/dist/utils/canvasAssets.d.ts +134 -0
- package/dist/utils/canvasAssets.js +121 -0
- package/dist/utils/canvasClipboard.d.ts +51 -0
- package/dist/utils/canvasClipboard.js +37 -0
- package/dist/utils/canvasCommandRegistry.d.ts +207 -0
- package/dist/utils/canvasCommandRegistry.js +124 -0
- package/dist/utils/canvasCommands.d.ts +106 -0
- package/dist/utils/canvasCommands.js +564 -0
- package/dist/utils/canvasFontFamilies.d.ts +12 -0
- package/dist/utils/canvasFontFamilies.js +24 -0
- package/dist/utils/canvasIcons.d.ts +68 -0
- package/dist/utils/canvasIcons.js +293 -0
- package/dist/utils/canvasImageSource.d.ts +12 -0
- package/dist/utils/canvasImageSource.js +19 -0
- package/dist/utils/canvasItem.d.ts +102 -0
- package/dist/utils/canvasItem.js +1 -0
- package/dist/utils/canvasLayerManager.d.ts +51 -0
- package/dist/utils/canvasLayerManager.js +107 -0
- package/dist/utils/canvasValueResolver.d.ts +9 -0
- package/dist/utils/canvasValueResolver.js +13 -0
- package/dist/utils/captureStage.d.ts +59 -0
- package/dist/utils/captureStage.js +152 -0
- package/dist/utils/chartTypes.d.ts +6 -0
- package/dist/utils/chartTypes.js +2 -0
- package/dist/utils/chartUtils.d.ts +49 -0
- package/dist/utils/chartUtils.js +191 -0
- package/dist/utils/circleBadgeUtils.d.ts +28 -0
- package/dist/utils/circleBadgeUtils.js +85 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +66 -0
- package/dist/utils/collectAltTextPages.d.ts +6 -0
- package/dist/utils/collectAltTextPages.js +20 -0
- package/dist/utils/colorLuminance.d.ts +3 -0
- package/dist/utils/colorLuminance.js +14 -0
- package/dist/utils/colorNames.d.ts +2 -0
- package/dist/utils/colorNames.js +8 -0
- package/dist/utils/colorOptions.d.ts +20 -0
- package/dist/utils/colorOptions.js +20 -0
- package/dist/utils/cornerRadius.d.ts +14 -0
- package/dist/utils/cornerRadius.js +27 -0
- package/dist/utils/cornerReservation.d.ts +19 -0
- package/dist/utils/cornerReservation.js +7 -0
- package/dist/utils/coverFit.d.ts +117 -0
- package/dist/utils/coverFit.js +207 -0
- package/dist/utils/cropAspect.d.ts +47 -0
- package/dist/utils/cropAspect.js +53 -0
- package/dist/utils/cropGhost.d.ts +63 -0
- package/dist/utils/cropGhost.js +216 -0
- package/dist/utils/cropSession.d.ts +23 -0
- package/dist/utils/cropSession.js +92 -0
- package/dist/utils/cropTarget.d.ts +22 -0
- package/dist/utils/cropTarget.js +33 -0
- package/dist/utils/deepSelect.d.ts +43 -0
- package/dist/utils/deepSelect.js +74 -0
- package/dist/utils/downloadError.d.ts +2 -0
- package/dist/utils/downloadError.js +13 -0
- package/dist/utils/duplicateElement.d.ts +127 -0
- package/dist/utils/duplicateElement.js +235 -0
- package/dist/utils/editorFocus.d.ts +36 -0
- package/dist/utils/editorFocus.js +67 -0
- package/dist/utils/editorToast.d.ts +21 -0
- package/dist/utils/editorToast.js +7 -0
- package/dist/utils/elementKinds.d.ts +212 -0
- package/dist/utils/elementKinds.js +137 -0
- package/dist/utils/emoji/emojiCatalog.d.ts +12 -0
- package/dist/utils/emoji/emojiCatalog.en.json +9997 -0
- package/dist/utils/emoji/emojiCatalog.js +53 -0
- package/dist/utils/emoji/emojiCatalog.json +9913 -0
- package/dist/utils/ensureFontsReady.d.ts +12 -0
- package/dist/utils/ensureFontsReady.js +23 -0
- package/dist/utils/expandImage.d.ts +17 -0
- package/dist/utils/expandImage.js +76 -0
- package/dist/utils/externalIcons.d.ts +67 -0
- package/dist/utils/externalIcons.js +168 -0
- package/dist/utils/filterCache.d.ts +16 -0
- package/dist/utils/filterCache.js +31 -0
- package/dist/utils/filterUtils.d.ts +2 -0
- package/dist/utils/filterUtils.js +89 -0
- package/dist/utils/followStage.d.ts +2 -0
- package/dist/utils/followStage.js +48 -0
- package/dist/utils/fontAliases.d.ts +14 -0
- package/dist/utils/fontAliases.js +32 -0
- package/dist/utils/fontMarkSupport.d.ts +25 -0
- package/dist/utils/fontMarkSupport.js +26 -0
- package/dist/utils/frameUtils.d.ts +19 -0
- package/dist/utils/frameUtils.js +282 -0
- package/dist/utils/gradientFill.d.ts +55 -0
- package/dist/utils/gradientFill.js +57 -0
- package/dist/utils/gradientHitArea.d.ts +22 -0
- package/dist/utils/gradientHitArea.js +94 -0
- package/dist/utils/grain.d.ts +29 -0
- package/dist/utils/grain.js +103 -0
- package/dist/utils/grainSpec.d.ts +2 -0
- package/dist/utils/grainSpec.js +3 -0
- package/dist/utils/groupSnap.d.ts +27 -0
- package/dist/utils/groupSnap.js +54 -0
- package/dist/utils/handDrawn.d.ts +92 -0
- package/dist/utils/handDrawn.js +523 -0
- package/dist/utils/historyStamp.d.ts +22 -0
- package/dist/utils/historyStamp.js +31 -0
- package/dist/utils/hostStorageKeys.d.ts +16 -0
- package/dist/utils/hostStorageKeys.js +27 -0
- package/dist/utils/iconInstances.d.ts +80 -0
- package/dist/utils/iconInstances.js +109 -0
- package/dist/utils/illustrations/gophers.d.ts +11 -0
- package/dist/utils/illustrations/gophers.js +1236 -0
- package/dist/utils/illustrations/humaaans.d.ts +8 -0
- package/dist/utils/illustrations/humaaans.js +265 -0
- package/dist/utils/illustrations/illlustrations.d.ts +11 -0
- package/dist/utils/illustrations/illlustrations.js +929 -0
- package/dist/utils/illustrations/kawaii.d.ts +6 -0
- package/dist/utils/illustrations/kawaii.js +73 -0
- package/dist/utils/illustrations/opendoodles.d.ts +6 -0
- package/dist/utils/illustrations/opendoodles.js +271 -0
- package/dist/utils/illustrations/openpeeps.d.ts +9 -0
- package/dist/utils/illustrations/openpeeps.js +1522 -0
- package/dist/utils/illustrations/prefetchAnalytics.d.ts +78 -0
- package/dist/utils/illustrations/prefetchAnalytics.js +162 -0
- package/dist/utils/illustrations/registry.d.ts +24 -0
- package/dist/utils/illustrations/registry.js +104 -0
- package/dist/utils/illustrations/svgCache.d.ts +60 -0
- package/dist/utils/illustrations/svgCache.js +342 -0
- package/dist/utils/illustrations/transhumans.d.ts +8 -0
- package/dist/utils/illustrations/transhumans.js +313 -0
- package/dist/utils/illustrations/types.d.ts +25 -0
- package/dist/utils/illustrations/types.js +45 -0
- package/dist/utils/imageElementComparison.d.ts +19 -0
- package/dist/utils/imageElementComparison.js +121 -0
- package/dist/utils/imageFilters.d.ts +92 -0
- package/dist/utils/imageFilters.js +303 -0
- package/dist/utils/imageLook.d.ts +16 -0
- package/dist/utils/imageLook.js +39 -0
- package/dist/utils/keyboardCrop.d.ts +25 -0
- package/dist/utils/keyboardCrop.js +98 -0
- package/dist/utils/keyboardOwnership.d.ts +30 -0
- package/dist/utils/keyboardOwnership.js +93 -0
- package/dist/utils/layerLabels.d.ts +39 -0
- package/dist/utils/layerLabels.js +181 -0
- package/dist/utils/layerLock.d.ts +24 -0
- package/dist/utils/layerLock.js +52 -0
- package/dist/utils/layerSelection.d.ts +24 -0
- package/dist/utils/layerSelection.js +16 -0
- package/dist/utils/markerBoxes.d.ts +23 -0
- package/dist/utils/markerBoxes.js +73 -0
- package/dist/utils/markerColors.d.ts +9 -0
- package/dist/utils/markerColors.js +39 -0
- package/dist/utils/mediaDrop.d.ts +76 -0
- package/dist/utils/mediaDrop.js +95 -0
- package/dist/utils/mediaPlacement.d.ts +6 -0
- package/dist/utils/mediaPlacement.js +17 -0
- package/dist/utils/motifSizes.d.ts +8 -0
- package/dist/utils/motifSizes.js +9 -0
- package/dist/utils/multiSelect.d.ts +44 -0
- package/dist/utils/multiSelect.js +139 -0
- package/dist/utils/notch.d.ts +17 -0
- package/dist/utils/notch.js +23 -0
- package/dist/utils/orientElement.d.ts +46 -0
- package/dist/utils/orientElement.js +108 -0
- package/dist/utils/orientation.d.ts +119 -0
- package/dist/utils/orientation.js +411 -0
- package/dist/utils/pageCounter.d.ts +15 -0
- package/dist/utils/pageCounter.js +17 -0
- package/dist/utils/pendingImages.d.ts +10 -0
- package/dist/utils/pendingImages.js +25 -0
- package/dist/utils/photoCredit.d.ts +9 -0
- package/dist/utils/photoCredit.js +29 -0
- package/dist/utils/photoCredits.d.ts +5 -0
- package/dist/utils/photoCredits.js +17 -0
- package/dist/utils/photoPlaceholder.d.ts +22 -0
- package/dist/utils/photoPlaceholder.js +36 -0
- package/dist/utils/pillBadgeUtils.d.ts +40 -0
- package/dist/utils/pillBadgeUtils.js +94 -0
- package/dist/utils/pixelHitArea.d.ts +13 -0
- package/dist/utils/pixelHitArea.js +33 -0
- package/dist/utils/plainTextLayout.d.ts +11 -0
- package/dist/utils/plainTextLayout.js +64 -0
- package/dist/utils/printImageInfo.d.ts +9 -0
- package/dist/utils/printImageInfo.js +14 -0
- package/dist/utils/recacheNextFrame.d.ts +6 -0
- package/dist/utils/recacheNextFrame.js +15 -0
- package/dist/utils/removeElement.d.ts +17 -0
- package/dist/utils/removeElement.js +47 -0
- package/dist/utils/renderedBoxes.d.ts +19 -0
- package/dist/utils/renderedBoxes.js +67 -0
- package/dist/utils/resolveElementValue.d.ts +44 -0
- package/dist/utils/resolveElementValue.js +72 -0
- package/dist/utils/scrollBehavior.d.ts +6 -0
- package/dist/utils/scrollBehavior.js +17 -0
- package/dist/utils/searchTranslations.d.ts +20 -0
- package/dist/utils/searchTranslations.js +366 -0
- package/dist/utils/selectionCapabilities.d.ts +53 -0
- package/dist/utils/selectionCapabilities.js +52 -0
- package/dist/utils/shade.d.ts +24 -0
- package/dist/utils/shade.js +55 -0
- package/dist/utils/shapeDevices.d.ts +72 -0
- package/dist/utils/shapeDevices.js +100 -0
- package/dist/utils/shapeTransform.d.ts +29 -0
- package/dist/utils/shapeTransform.js +69 -0
- package/dist/utils/shapes.d.ts +62 -0
- package/dist/utils/shapes.js +836 -0
- package/dist/utils/smartCrop.d.ts +30 -0
- package/dist/utils/smartCrop.js +163 -0
- package/dist/utils/snapping.d.ts +116 -0
- package/dist/utils/snapping.js +426 -0
- package/dist/utils/stageCssScale.d.ts +7 -0
- package/dist/utils/stageCssScale.js +11 -0
- package/dist/utils/stateTypeAssertions.d.ts +99 -0
- package/dist/utils/stateTypeAssertions.js +197 -0
- package/dist/utils/straighten.d.ts +51 -0
- package/dist/utils/straighten.js +254 -0
- package/dist/utils/surfaceGlow.d.ts +7 -0
- package/dist/utils/surfaceGlow.js +27 -0
- package/dist/utils/templateElementInstance.d.ts +43 -0
- package/dist/utils/templateElementInstance.js +100 -0
- package/dist/utils/templateRotation.d.ts +24 -0
- package/dist/utils/templateRotation.js +56 -0
- package/dist/utils/textAlign.d.ts +17 -0
- package/dist/utils/textAlign.js +30 -0
- package/dist/utils/textEditorOpeners.d.ts +12 -0
- package/dist/utils/textEditorOpeners.js +40 -0
- package/dist/utils/textRouting.d.ts +17 -0
- package/dist/utils/textRouting.js +22 -0
- package/dist/utils/textUtils.d.ts +102 -0
- package/dist/utils/textUtils.js +250 -0
- package/dist/utils/touchInput.d.ts +7 -0
- package/dist/utils/touchInput.js +19 -0
- package/dist/utils/transformHudLabel.d.ts +3 -0
- package/dist/utils/transformHudLabel.js +12 -0
- package/dist/utils/unsplashLinks.d.ts +2 -0
- package/dist/utils/unsplashLinks.js +7 -0
- package/dist/utils/userFacingError.d.ts +10 -0
- package/dist/utils/userFacingError.js +10 -0
- package/dist/utils/userImageCrop.d.ts +4 -0
- package/dist/utils/userImageCrop.js +26 -0
- package/dist/utils/userImageUtils.d.ts +44 -0
- package/dist/utils/userImageUtils.js +136 -0
- package/dist/utils/viewport.d.ts +16 -0
- package/dist/utils/viewport.js +30 -0
- package/dist/utils/zipPageImages.d.ts +8 -0
- package/dist/utils/zipPageImages.js +29 -0
- package/package.json +105 -3
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
/**
|
|
4
|
+
* CanvasRichText — ein Textblock mit Aufzählung und/oder Inline-Auszeichnung.
|
|
5
|
+
*
|
|
6
|
+
* Warum ein eigener Renderer: Konva.Text kennt weder einen hängenden Einzug
|
|
7
|
+
* noch gemischte Schnitte in einem Knoten. Hier steht je Zeile ein Marker-
|
|
8
|
+
* Knoten am Blockrand und je Lauf ein eigener Textknoten an seiner gemessenen
|
|
9
|
+
* Position — fett, kursiv oder unterstrichen, wie der Lauf es trägt —, und
|
|
10
|
+
* ALLE Zeilen eines Punktes tragen denselben Einzug.
|
|
11
|
+
*
|
|
12
|
+
* Die Zeilen sind vorberechnet (`layoutRichTextBlock`) und werden mit
|
|
13
|
+
* `wrap="none"` gesetzt: derselbe Umbruch, den der Server-Renderer fährt,
|
|
14
|
+
* statt zweier Verfahren, die auseinanderdriften.
|
|
15
|
+
*
|
|
16
|
+
* Die Aufteilung zwischen diesem Renderer und dem gewöhnlichen `CanvasText`
|
|
17
|
+
* entscheidet `CanvasText` selbst — an der Komponentengrenze, nicht in einem
|
|
18
|
+
* Zweig innerhalb einer Komponente, damit die Hook-Reihenfolge stabil bleibt,
|
|
19
|
+
* wenn ein Text seinen ersten Marker bekommt.
|
|
20
|
+
*
|
|
21
|
+
* Bearbeitet wird mit `RichTextField`, das der `CanvasTextEditorProvider`
|
|
22
|
+
* NEBEN der Bühne im DOM aufspannt (siehe `CanvasTextOverlay`) — nicht aus dem
|
|
23
|
+
* Konva-Baum heraus und nicht mit einer nackten Textarea: nur so sieht man beim
|
|
24
|
+
* Tippen Fett statt Sternchen.
|
|
25
|
+
*/
|
|
26
|
+
import { layoutRichTextBlock } from '@ggraphic/schema';
|
|
27
|
+
import { useRef, useEffect, useCallback, useMemo, useState, Fragment } from 'react';
|
|
28
|
+
import { Group, Rect, Text as KonvaText, Transformer } from 'react-konva';
|
|
29
|
+
import { LOCKED_TRANSFORMER, useIsItemLocked } from '@ggraphic/editor/components/canvasItemLock';
|
|
30
|
+
import { overlayBoxForNode, useCanvasTextEditor, } from '@ggraphic/editor/components/CanvasTextOverlay';
|
|
31
|
+
import { useFontGeneration } from '@ggraphic/editor/hooks/useFontGeneration';
|
|
32
|
+
import { useGeometryReporter } from '@ggraphic/editor/hooks/useGeometryReporter';
|
|
33
|
+
import { useSnapScheduler } from '@ggraphic/editor/hooks/useSnapScheduler';
|
|
34
|
+
import { resolveFontFamily } from '../utils/fontAliases.js';
|
|
35
|
+
import { gradientFillProps } from '@ggraphic/editor/utils/gradientFill';
|
|
36
|
+
import { markerBoxes } from '@ggraphic/editor/utils/markerBoxes';
|
|
37
|
+
import { defaultTextMarker, markerInkOn } from '@ggraphic/editor/utils/markerColors';
|
|
38
|
+
import { isGroupDrag } from '@ggraphic/editor/utils/multiSelect';
|
|
39
|
+
import { ELEMENT_TRANSFORMER, normalizeRotation } from '@ggraphic/editor/utils/orientation';
|
|
40
|
+
import { boxFrame, createBoxFrame, frameBounds, snapByBounds, } from '@ggraphic/editor/utils/snapping';
|
|
41
|
+
import { konvaFontStyle, runFont, runMeasurer } from '@ggraphic/editor/utils/textUtils';
|
|
42
|
+
import { isWidthOnlyScale } from './CanvasText.js';
|
|
43
|
+
// Rahmen für Snap und Geometrie-Meldung, pro Aufruf neu beschrieben (synchron, ohne Allokation).
|
|
44
|
+
const dragFrame = createBoxFrame();
|
|
45
|
+
const DEFAULT_TEXT_ANCHORS = ['middle-left', 'middle-right'];
|
|
46
|
+
export function CanvasRichText({ id, text, x, y, width, fontSize = 24, fontFamily = 'Arial', fontStyle = 'normal', fontWeight, letterSpacing, strikethrough = false, fill = '#000000', rotation, opacity = 1, stroke, strokeWidth, shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY, shadowOpacity, fillGradient, align = 'left', accent = null, marker: templateMarker = null, lineHeight = 1.2, padding = 0, draggable = true, selected = false, editable = false, transformConfig, onSelect, onTextChange, onTextPreview, onDragEnd, onTransformEnd, onFontSizeChange, snapToCenter = true, stageWidth, stageHeight, onSnapChange, getSnapTargets, onPositionChange, onGeometryChange, onSnapLinesChange, }) {
|
|
47
|
+
const locked = useIsItemLocked();
|
|
48
|
+
const groupRef = useRef(null);
|
|
49
|
+
const trRef = useRef(null);
|
|
50
|
+
const { open, isEditing } = useCanvasTextEditor(id, editable);
|
|
51
|
+
// Ein nachgeladener Schriftschnitt misst anders. Ohne diese Abhängigkeit
|
|
52
|
+
// bliebe der mit der Ersatzschrift gerechnete Umbruch stehen — siehe
|
|
53
|
+
// `useFontGeneration`, auch dazu, warum der Wert ins Argument muss.
|
|
54
|
+
const fontGeneration = useFontGeneration();
|
|
55
|
+
const measure = useMemo(() => runMeasurer(fontSize, fontFamily, fontStyle, fontGeneration, accent, fontWeight ?? null, letterSpacing ?? null), [fontSize, fontFamily, fontStyle, fontWeight, letterSpacing, fontGeneration, accent]);
|
|
56
|
+
// Ohne gesetzte Breite gibt es nichts zu umbrechen; der Einzug gilt trotzdem,
|
|
57
|
+
// damit die Marker eine Spalte bilden.
|
|
58
|
+
// While a side handle is dragged the block re-wraps at this width; it is
|
|
59
|
+
// committed (and cleared) on transform end.
|
|
60
|
+
const [liveWidth, setLiveWidth] = useState(null);
|
|
61
|
+
const layoutWidth = liveWidth ?? width;
|
|
62
|
+
const innerWidth = layoutWidth != null ? Math.max(layoutWidth - 2 * padding, 1) : Number.POSITIVE_INFINITY;
|
|
63
|
+
const lines = useMemo(() => layoutRichTextBlock(text, innerWidth, measure), [text, innerWidth, measure]);
|
|
64
|
+
const lineHeightPx = fontSize * lineHeight;
|
|
65
|
+
const blockHeight = lines.length * lineHeightPx + 2 * padding;
|
|
66
|
+
// Breite je Zeile: der Marker steht links davor, der letzte Lauf endet rechts.
|
|
67
|
+
const lineWidths = useMemo(() => lines.map((line) => {
|
|
68
|
+
const last = line.runs[line.runs.length - 1];
|
|
69
|
+
return line.indent + (last ? last.x + measure(last.text, last) : 0);
|
|
70
|
+
}), [lines, measure]);
|
|
71
|
+
// Ohne feste Breite die breiteste gesetzte Zeile — der Transformer und die
|
|
72
|
+
// Snap-Ziele brauchen eine Box, eine Gruppe misst sich nicht selbst.
|
|
73
|
+
const blockWidth = layoutWidth ?? Math.max(...lineWidths, 1) + 2 * padding;
|
|
74
|
+
const innerBoxWidth = Math.max(blockWidth - 2 * padding, 1);
|
|
75
|
+
// Die Ausrichtung verschiebt jede Zeile für sich; die Kästen brauchen denselben Versatz.
|
|
76
|
+
const originX = useMemo(() => lines.map((_, index) => padding +
|
|
77
|
+
(align === 'center'
|
|
78
|
+
? (innerBoxWidth - lineWidths[index]) / 2
|
|
79
|
+
: align === 'right'
|
|
80
|
+
? innerBoxWidth - lineWidths[index]
|
|
81
|
+
: 0)), [lines, lineWidths, align, padding, innerBoxWidth]);
|
|
82
|
+
// Ohne Markerstil der Vorlage bekommt ein `++`-Lauf den Standardkasten.
|
|
83
|
+
const marker = templateMarker ?? defaultTextMarker();
|
|
84
|
+
const boxes = useMemo(() => markerBoxes(lines, measure, marker, {
|
|
85
|
+
fontSize,
|
|
86
|
+
lineHeightPx,
|
|
87
|
+
top: padding,
|
|
88
|
+
originX,
|
|
89
|
+
}), [marker, lines, measure, fontSize, lineHeightPx, padding, originX]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (selected && trRef.current && groupRef.current && !isEditing) {
|
|
92
|
+
trRef.current.nodes([groupRef.current]);
|
|
93
|
+
trRef.current.getLayer()?.batchDraw();
|
|
94
|
+
}
|
|
95
|
+
else if (!selected && trRef.current) {
|
|
96
|
+
trRef.current.nodes([]);
|
|
97
|
+
}
|
|
98
|
+
}, [selected, isEditing]);
|
|
99
|
+
const reportGeometry = useGeometryReporter(id, onGeometryChange);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const node = groupRef.current;
|
|
102
|
+
if (!node)
|
|
103
|
+
return;
|
|
104
|
+
const box = frameBounds(boxFrame(dragFrame, node.x(), node.y(), blockWidth * node.scaleX(), blockHeight * node.scaleY(), node.rotation(), 'top-left'));
|
|
105
|
+
reportGeometry(box.x, box.y, box.width, box.height);
|
|
106
|
+
}, [reportGeometry, x, y, blockWidth, blockHeight, rotation]);
|
|
107
|
+
const snap = useSnapScheduler({
|
|
108
|
+
onSnapChange: onSnapChange ?? (() => { }),
|
|
109
|
+
onSnapLinesChange: onSnapLinesChange ?? (() => { }),
|
|
110
|
+
});
|
|
111
|
+
const handleDragMove = useCallback((e) => {
|
|
112
|
+
const node = e.target;
|
|
113
|
+
if (isGroupDrag(node))
|
|
114
|
+
return;
|
|
115
|
+
if (!stageWidth || !stageHeight)
|
|
116
|
+
return;
|
|
117
|
+
const snapTargets = getSnapTargets?.(id ?? '') ?? [];
|
|
118
|
+
if (snapTargets.length > 0 || snapToCenter) {
|
|
119
|
+
const result = snapByBounds(boxFrame(dragFrame, node.x(), node.y(), blockWidth * node.scaleX(), blockHeight * node.scaleY(), node.rotation(), 'top-left'), snapTargets, stageWidth, stageHeight, snap.hysteresis);
|
|
120
|
+
node.position({ x: result.x, y: result.y });
|
|
121
|
+
snap.scheduleSnap(result.snapH, result.snapV, result.snapLines);
|
|
122
|
+
}
|
|
123
|
+
}, [id, snapToCenter, stageWidth, stageHeight, getSnapTargets, snap, blockWidth, blockHeight]);
|
|
124
|
+
const handleDragEnd = useCallback((e) => {
|
|
125
|
+
const node = e.target;
|
|
126
|
+
snap.onDragEnd();
|
|
127
|
+
onDragEnd?.(node.x(), node.y());
|
|
128
|
+
if (id && onPositionChange) {
|
|
129
|
+
onPositionChange(id, node.x(), node.y(), blockWidth, blockHeight);
|
|
130
|
+
// onPositionChange schreibt die ungedrehte Box in dieselben Snap-Ziele;
|
|
131
|
+
// gedreht muss danach die sichtbare Box dort stehen (der Reporter
|
|
132
|
+
// meldet nur bei Prop-Änderung, ein Drag zurück an den Start ändert keine).
|
|
133
|
+
if (node.rotation() !== 0 && onGeometryChange) {
|
|
134
|
+
const box = frameBounds(boxFrame(dragFrame, node.x(), node.y(), blockWidth * node.scaleX(), blockHeight * node.scaleY(), node.rotation(), 'top-left'));
|
|
135
|
+
onGeometryChange(id, box.x, box.y, box.width, box.height);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, [id, onDragEnd, onPositionChange, onGeometryChange, snap, blockWidth, blockHeight]);
|
|
139
|
+
// A ref, not the rendered width: two transform events can arrive before
|
|
140
|
+
// React re-renders, and the second must build on the first.
|
|
141
|
+
const liveWidthRef = useRef(null);
|
|
142
|
+
const handleTransform = useCallback(() => {
|
|
143
|
+
const node = groupRef.current;
|
|
144
|
+
if (!node || !isWidthOnlyScale(node))
|
|
145
|
+
return;
|
|
146
|
+
const next = Math.max(1, (liveWidthRef.current ?? blockWidth) * node.scaleX());
|
|
147
|
+
node.scaleX(1);
|
|
148
|
+
liveWidthRef.current = next;
|
|
149
|
+
setLiveWidth(next);
|
|
150
|
+
}, [blockWidth]);
|
|
151
|
+
const handleTransformEnd = useCallback(() => {
|
|
152
|
+
const node = groupRef.current;
|
|
153
|
+
if (!node)
|
|
154
|
+
return;
|
|
155
|
+
const committedWidth = liveWidthRef.current;
|
|
156
|
+
if (committedWidth != null) {
|
|
157
|
+
liveWidthRef.current = null;
|
|
158
|
+
setLiveWidth(null);
|
|
159
|
+
if (Math.abs(node.scaleY() - 1) < 1e-3) {
|
|
160
|
+
node.scale({ x: 1, y: 1 });
|
|
161
|
+
onTransformEnd?.(node.x(), node.y(), Math.round(committedWidth), 1, 1, normalizeRotation(node.rotation()));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const scaleX = node.scaleX();
|
|
166
|
+
const scaleY = node.scaleY();
|
|
167
|
+
const SCALE_THRESHOLD = 0.03;
|
|
168
|
+
const scaleChanged = Math.abs(scaleX - 1) > SCALE_THRESHOLD || Math.abs(scaleY - 1) > SCALE_THRESHOLD;
|
|
169
|
+
node.scale({ x: 1, y: 1 });
|
|
170
|
+
if (scaleChanged) {
|
|
171
|
+
// Eine Gruppe trägt keine fontSize — anders als beim einfachen Textknoten
|
|
172
|
+
// wird sie aus der Prop und dem Maßstab gerechnet.
|
|
173
|
+
const newFontSize = Math.max(8, Math.round(fontSize * scaleY));
|
|
174
|
+
const newWidth = Math.round(blockWidth * scaleX);
|
|
175
|
+
onFontSizeChange?.(newFontSize);
|
|
176
|
+
onTransformEnd?.(node.x(), node.y(), newWidth, 1, 1, normalizeRotation(node.rotation()));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
onTransformEnd?.(node.x(), node.y(), blockWidth, 1, 1, normalizeRotation(node.rotation()));
|
|
180
|
+
}
|
|
181
|
+
}, [fontSize, blockWidth, onFontSizeChange, onTransformEnd]);
|
|
182
|
+
const handleDblClick = useCallback(() => {
|
|
183
|
+
const node = groupRef.current;
|
|
184
|
+
const box = node && overlayBoxForNode(node, blockWidth, blockHeight);
|
|
185
|
+
if (!editable || !node || !box)
|
|
186
|
+
return;
|
|
187
|
+
open({
|
|
188
|
+
id: id ?? '',
|
|
189
|
+
box,
|
|
190
|
+
anchor: { node, width: blockWidth, height: blockHeight },
|
|
191
|
+
text,
|
|
192
|
+
fontFamily,
|
|
193
|
+
fontSize,
|
|
194
|
+
fontStyle: konvaFontStyle(fontStyle, fontWeight),
|
|
195
|
+
fill,
|
|
196
|
+
align,
|
|
197
|
+
lineHeight,
|
|
198
|
+
letterSpacing,
|
|
199
|
+
opacity,
|
|
200
|
+
accent,
|
|
201
|
+
marker: templateMarker,
|
|
202
|
+
onTextChange,
|
|
203
|
+
onTextPreview,
|
|
204
|
+
});
|
|
205
|
+
}, [
|
|
206
|
+
editable,
|
|
207
|
+
open,
|
|
208
|
+
id,
|
|
209
|
+
text,
|
|
210
|
+
blockWidth,
|
|
211
|
+
blockHeight,
|
|
212
|
+
fontFamily,
|
|
213
|
+
fontSize,
|
|
214
|
+
fontStyle,
|
|
215
|
+
fontWeight,
|
|
216
|
+
fill,
|
|
217
|
+
align,
|
|
218
|
+
lineHeight,
|
|
219
|
+
letterSpacing,
|
|
220
|
+
opacity,
|
|
221
|
+
accent,
|
|
222
|
+
templateMarker,
|
|
223
|
+
onTextChange,
|
|
224
|
+
onTextPreview,
|
|
225
|
+
]);
|
|
226
|
+
const enabledAnchors = transformConfig?.enabledAnchors ?? DEFAULT_TEXT_ANCHORS;
|
|
227
|
+
// One gradient across the whole block: each run node paints it in its own
|
|
228
|
+
// coordinates, so the block box is shifted by the node's position.
|
|
229
|
+
const gradientAt = (nodeX, nodeY) => fillGradient
|
|
230
|
+
? gradientFillProps(fillGradient, {
|
|
231
|
+
x: -nodeX,
|
|
232
|
+
y: -nodeY,
|
|
233
|
+
width: blockWidth,
|
|
234
|
+
height: blockHeight,
|
|
235
|
+
})
|
|
236
|
+
: null;
|
|
237
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Group, { ref: groupRef, id: id, x: x, y: y, width: blockWidth, height: blockHeight, rotation: rotation, opacity: opacity, draggable: draggable && !isEditing && !locked, visible: !isEditing, onMouseDown: onSelect, onTouchStart: onSelect, onDblClick: handleDblClick, onDblTap: handleDblClick, onDragStart: snap.onDragStart, onDragMove: handleDragMove, onDragEnd: handleDragEnd, onTransform: handleTransform, onTransformEnd: handleTransformEnd, children: [_jsx(Rect, { width: blockWidth, height: blockHeight, fill: "transparent" }), boxes.map((box, index) => (_jsx(Rect, { x: box.x, y: box.y, width: box.width, height: box.height, fill: box.fill, listening: false }, `marker-${index}`))), lines.map((line, index) => {
|
|
238
|
+
// Konva zeichnet eine Zeile mittig in ihre Zeilenbox (textBaseline
|
|
239
|
+
// "middle"). Ein Stapel einzeiliger Knoten im Abstand einer Zeilenbox
|
|
240
|
+
// liegt deshalb exakt dort, wo ein mehrzeiliger Textknoten läge.
|
|
241
|
+
const top = padding + index * lineHeightPx;
|
|
242
|
+
// Die Läufe stehen an gemessenen x-Positionen, also richtet sich die
|
|
243
|
+
// Zeile nicht von selbst aus — der Versatz muss hier rein. Ohne ihn
|
|
244
|
+
// rutschten alle zentrierten Vorlagen (die AT-Sujets) nach links,
|
|
245
|
+
// sobald ihr Text einen Marker trägt.
|
|
246
|
+
const offset = originX[index] - padding;
|
|
247
|
+
return (_jsxs(Fragment, { children: [line.marker !== null && (_jsx(KonvaText, { text: line.marker, x: padding + offset, y: top, fontSize: fontSize, fontFamily: resolveFontFamily(fontFamily), fontStyle: konvaFontStyle(fontStyle, fontWeight), letterSpacing: (letterSpacing ?? 0) * fontSize, fill: fill, ...gradientAt(padding + offset, top), lineHeight: lineHeight, wrap: "none", listening: false })), line.runs.map((run, runIndex) => (_jsx(KonvaText, { text: run.text, x: padding + offset + line.indent + run.x, y: top, fontSize: fontSize, ...runFont(fontFamily, fontStyle, run, accent, fontWeight), letterSpacing: (letterSpacing ?? 0) * fontSize, textDecoration: [run.underline && 'underline', strikethrough && 'line-through']
|
|
248
|
+
.filter(Boolean)
|
|
249
|
+
.join(' '), ...(run.marker
|
|
250
|
+
? // Ink chosen for the box: no halo or outline of the photo text.
|
|
251
|
+
{
|
|
252
|
+
fill: run.accentColor ??
|
|
253
|
+
(run.markerColor ? markerInkOn(run.markerColor) : marker.color),
|
|
254
|
+
lineJoin: 'round',
|
|
255
|
+
}
|
|
256
|
+
: {
|
|
257
|
+
fill: run.accentColor ?? (run.accent && accent ? accent.fill : fill),
|
|
258
|
+
// An accent keeps its own colour; only base-coloured runs carry the gradient.
|
|
259
|
+
...(!run.accentColor &&
|
|
260
|
+
!(run.accent && accent) &&
|
|
261
|
+
gradientAt(padding + offset + line.indent + run.x, top)),
|
|
262
|
+
stroke,
|
|
263
|
+
strokeWidth,
|
|
264
|
+
fillAfterStrokeEnabled: !!stroke && (strokeWidth ?? 0) > 0,
|
|
265
|
+
lineJoin: 'round',
|
|
266
|
+
shadowColor,
|
|
267
|
+
shadowBlur,
|
|
268
|
+
shadowOffsetX,
|
|
269
|
+
shadowOffsetY,
|
|
270
|
+
shadowOpacity,
|
|
271
|
+
}), lineHeight: lineHeight, wrap: "none", listening: false }, runIndex)))] }, index));
|
|
272
|
+
})] }), selected && !isEditing && (_jsx(Transformer, { ref: trRef, rotateEnabled: transformConfig?.rotateEnabled ?? false, keepRatio: transformConfig?.keepRatio ?? true, enabledAnchors: enabledAnchors, boundBoxFunc: (oldBox, newBox) => {
|
|
273
|
+
const minWidth = transformConfig?.bounds?.minWidth ?? 50;
|
|
274
|
+
const maxWidth = transformConfig?.bounds?.maxWidth ?? Infinity;
|
|
275
|
+
if (newBox.width < minWidth)
|
|
276
|
+
return oldBox;
|
|
277
|
+
if (newBox.width > maxWidth)
|
|
278
|
+
return oldBox;
|
|
279
|
+
return newBox;
|
|
280
|
+
}, ...ELEMENT_TRANSFORMER, ...(locked ? LOCKED_TRANSFORMER : {}) }))] }));
|
|
281
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CanvasStage - Responsive Konva Stage wrapper
|
|
3
|
+
*
|
|
4
|
+
* Renders a single responsive Konva stage for editing.
|
|
5
|
+
* Uses pixelRatio compensation during export to achieve pixel-perfect exports
|
|
6
|
+
* regardless of display scaling.
|
|
7
|
+
*/
|
|
8
|
+
import Konva from 'konva';
|
|
9
|
+
import { type ReactNode } from 'react';
|
|
10
|
+
import type { ExportOptions } from '@ggraphic/editor/types/editorTypes';
|
|
11
|
+
export interface CanvasStageProps {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/**
|
|
15
|
+
* Logical coordinate space used by layout calculators. Defaults to width/height (no scaling).
|
|
16
|
+
* When different from width/height, children are wrapped in a Konva Group with the
|
|
17
|
+
* appropriate scale so reference-space layouts render proportionally on a different
|
|
18
|
+
* canvas size (e.g. 1080×1350 layouts on a 2480×3508 A4 flyer).
|
|
19
|
+
*/
|
|
20
|
+
logicalWidth?: number;
|
|
21
|
+
logicalHeight?: number;
|
|
22
|
+
responsive?: boolean;
|
|
23
|
+
maxContainerWidth?: number;
|
|
24
|
+
maxContainerHeight?: number;
|
|
25
|
+
onStageClick?: (e: Konva.KonvaEventObject<MouseEvent | TouchEvent>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Hit detection for the whole stage. `false` skips Konva's hit graph — it
|
|
28
|
+
* keeps a second canvas per layer purely to answer "what is under the
|
|
29
|
+
* pointer", which a render-once offscreen snapshot never asks. Defaults to
|
|
30
|
+
* true; only the preview path turns it off.
|
|
31
|
+
*/
|
|
32
|
+
listening?: boolean;
|
|
33
|
+
/** Beschreibt die Bühne für Screenreader (`role="img"`) — siehe `stageSummary`. */
|
|
34
|
+
ariaLabel?: string;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
/** DOM über der Bühne im selben Koordinatensystem (z. B. das Restbild beim Zuschneiden). */
|
|
37
|
+
overlay?: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
style?: React.CSSProperties;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The stage region to hand Konva's `toDataURL` so the PNG is exactly the
|
|
43
|
+
* format size times `pixelRatio`. Deriving the output from the display
|
|
44
|
+
* container instead loses a row or two: the container rounds width and height
|
|
45
|
+
* independently, while the export scale comes from the width alone (#4091).
|
|
46
|
+
* Konva sizes the bitmap as `floor(region * ratio)`, so the region aims half
|
|
47
|
+
* a device pixel past the target — float error can then never floor it short.
|
|
48
|
+
*/
|
|
49
|
+
export declare function stageExportRegion(width: number, height: number, displayScale: number, pixelRatio: number): {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
pixelRatio: number;
|
|
53
|
+
};
|
|
54
|
+
export interface PrintTileRequest {
|
|
55
|
+
/** Format px, as planned by planTiles. */
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
/** Authoritative output size in whole pixels. */
|
|
59
|
+
outWidth: number;
|
|
60
|
+
outHeight: number;
|
|
61
|
+
pixelRatio: number;
|
|
62
|
+
quality: number;
|
|
63
|
+
}
|
|
64
|
+
export interface PrintImageInfo {
|
|
65
|
+
/** Pixels of the source that are actually shown (after the cover crop). */
|
|
66
|
+
naturalWidthPx: number;
|
|
67
|
+
/** Width the photo covers on the canvas, in format px. */
|
|
68
|
+
displayedWidthPx: number;
|
|
69
|
+
}
|
|
70
|
+
export interface CanvasStageRef {
|
|
71
|
+
getStage: () => Konva.Stage | null;
|
|
72
|
+
toDataURL: (options?: Partial<ExportOptions>) => string | undefined;
|
|
73
|
+
toDataURLAsync: (options?: Partial<ExportOptions>) => Promise<string | null>;
|
|
74
|
+
/** One print tile (format px) as JPEG bytes, selection chrome hidden. */
|
|
75
|
+
toTileJpeg: (tile: PrintTileRequest) => Promise<Uint8Array | null>;
|
|
76
|
+
/** User photos on the stage with natural and displayed width (format px). */
|
|
77
|
+
getPrintImages: () => PrintImageInfo[];
|
|
78
|
+
getContainerSize: () => {
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
};
|
|
82
|
+
getDisplayScale: () => number;
|
|
83
|
+
}
|
|
84
|
+
export declare const CanvasStage: import("react").ForwardRefExoticComponent<CanvasStageProps & import("react").RefAttributes<CanvasStageRef>>;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
/**
|
|
4
|
+
* CanvasStage - Responsive Konva Stage wrapper
|
|
5
|
+
*
|
|
6
|
+
* Renders a single responsive Konva stage for editing.
|
|
7
|
+
* Uses pixelRatio compensation during export to achieve pixel-perfect exports
|
|
8
|
+
* regardless of display scaling.
|
|
9
|
+
*/
|
|
10
|
+
import Konva from 'konva';
|
|
11
|
+
import { useRef, useState, useEffect, forwardRef, useImperativeHandle, useCallback, } from 'react';
|
|
12
|
+
import { Stage, Layer, Group, Rect } from 'react-konva';
|
|
13
|
+
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
14
|
+
import { CanvasTextEditorProvider } from '@ggraphic/editor/components/CanvasTextOverlay';
|
|
15
|
+
import { TransformHud } from '@ggraphic/editor/components/TransformHud';
|
|
16
|
+
import { useHoverOutline } from '@ggraphic/editor/hooks/useHoverOutline';
|
|
17
|
+
import { installAxisLock } from '@ggraphic/editor/utils/axisLock';
|
|
18
|
+
import { cn } from '@ggraphic/editor/utils/cn';
|
|
19
|
+
import { MOUSE_DRAG_DISTANCE, TOUCH_DRAG_DISTANCE } from '@ggraphic/editor/utils/touchInput';
|
|
20
|
+
import { USER_PHOTO_NODE_NAME } from '@ggraphic/editor/utils/userImageUtils';
|
|
21
|
+
import { withSelectionChromeHidden } from '../utils/captureStage.js';
|
|
22
|
+
import { BACKGROUND_IMAGE_NODE_ID, printImageInfo } from '../utils/printImageInfo.js';
|
|
23
|
+
/**
|
|
24
|
+
* The stage region to hand Konva's `toDataURL` so the PNG is exactly the
|
|
25
|
+
* format size times `pixelRatio`. Deriving the output from the display
|
|
26
|
+
* container instead loses a row or two: the container rounds width and height
|
|
27
|
+
* independently, while the export scale comes from the width alone (#4091).
|
|
28
|
+
* Konva sizes the bitmap as `floor(region * ratio)`, so the region aims half
|
|
29
|
+
* a device pixel past the target — float error can then never floor it short.
|
|
30
|
+
*/
|
|
31
|
+
export function stageExportRegion(width, height, displayScale, pixelRatio) {
|
|
32
|
+
const ratio = pixelRatio / displayScale;
|
|
33
|
+
return {
|
|
34
|
+
width: (Math.round(width * pixelRatio) + 0.5) / ratio,
|
|
35
|
+
height: (Math.round(height * pixelRatio) + 0.5) / ratio,
|
|
36
|
+
pixelRatio: ratio,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Elements select on press; a click that wobbles a pixel or two must stay a
|
|
40
|
+
// click instead of starting a drag (Konva's default threshold is 0).
|
|
41
|
+
Konva.dragDistance = MOUSE_DRAG_DISTANCE;
|
|
42
|
+
// A press that has not moved past the drag threshold yet is only dropped:
|
|
43
|
+
// `stopDrag` would fire a `dragend` without a `dragstart`.
|
|
44
|
+
// Acts on every stage: a pinch can span pages.
|
|
45
|
+
function cancelDrags() {
|
|
46
|
+
for (const [key, elem] of [...Konva.DD._dragElements]) {
|
|
47
|
+
if (elem.dragStatus !== 'dragging') {
|
|
48
|
+
Konva.DD._dragElements.delete(key);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
elem.node.absolutePosition({
|
|
52
|
+
x: elem.startPointerPos.x - elem.offset.x,
|
|
53
|
+
y: elem.startPointerPos.y - elem.offset.y,
|
|
54
|
+
});
|
|
55
|
+
elem.node.stopDrag();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Taken when the first finger lands, before Konva starts a transform from an
|
|
59
|
+
// anchor; live text reflow changes width during the transform, so all attrs.
|
|
60
|
+
function snapshotTransformerNodes() {
|
|
61
|
+
const snapshot = new Map();
|
|
62
|
+
for (const stage of Konva.stages) {
|
|
63
|
+
for (const tr of stage.find('Transformer')) {
|
|
64
|
+
for (const node of tr.nodes())
|
|
65
|
+
snapshot.set(node, { ...node.getAttrs() });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return snapshot;
|
|
69
|
+
}
|
|
70
|
+
// Restoring first means the single `transformend` that `stopTransform` fires
|
|
71
|
+
// commits the untouched element, matching its `transformstart`.
|
|
72
|
+
function cancelTransforms(before) {
|
|
73
|
+
for (const stage of Konva.stages) {
|
|
74
|
+
for (const tr of stage.find('Transformer')) {
|
|
75
|
+
if (!tr.isTransforming())
|
|
76
|
+
continue;
|
|
77
|
+
for (const node of tr.nodes()) {
|
|
78
|
+
const attrs = before.get(node);
|
|
79
|
+
if (!attrs)
|
|
80
|
+
continue;
|
|
81
|
+
// An attr first set by the transform (e.g. scaleX) goes back to its default.
|
|
82
|
+
for (const key of Object.keys(node.getAttrs())) {
|
|
83
|
+
if (!(key in attrs))
|
|
84
|
+
node._setAttr(key, undefined);
|
|
85
|
+
}
|
|
86
|
+
node.setAttrs(attrs);
|
|
87
|
+
}
|
|
88
|
+
tr.stopTransform();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const exportMimeType = (options) => `image/${options.format || 'png'}`;
|
|
93
|
+
export const CanvasStage = forwardRef(({ width, height, logicalWidth, logicalHeight, responsive = true, maxContainerWidth = 600, maxContainerHeight, onStageClick, listening = true, ariaLabel, children, overlay, className, style, }, ref) => {
|
|
94
|
+
const displayStageRef = useRef(null);
|
|
95
|
+
const containerDivRef = useRef(null);
|
|
96
|
+
const [containerSize, setContainerSize] = useState({ width: 400, height: 400 });
|
|
97
|
+
const aspectRatio = width / height;
|
|
98
|
+
const displayScale = containerSize.width / width;
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!responsive) {
|
|
101
|
+
setContainerSize({ width, height });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const updateSize = () => {
|
|
105
|
+
// Use actual parent container width if available
|
|
106
|
+
const actualContainerWidth = containerDivRef.current?.parentElement?.clientWidth;
|
|
107
|
+
const maxW = actualContainerWidth
|
|
108
|
+
? Math.min(actualContainerWidth, maxContainerWidth)
|
|
109
|
+
: Math.min(window.innerWidth - 48, maxContainerWidth);
|
|
110
|
+
const maxH = maxContainerHeight ?? window.innerHeight - 120;
|
|
111
|
+
let containerW = maxW;
|
|
112
|
+
let containerH = containerW / aspectRatio;
|
|
113
|
+
if (containerH > maxH) {
|
|
114
|
+
containerH = maxH;
|
|
115
|
+
containerW = containerH * aspectRatio;
|
|
116
|
+
}
|
|
117
|
+
const newSize = {
|
|
118
|
+
width: Math.round(containerW),
|
|
119
|
+
height: Math.round(containerH),
|
|
120
|
+
};
|
|
121
|
+
setContainerSize(newSize);
|
|
122
|
+
};
|
|
123
|
+
updateSize();
|
|
124
|
+
// Use ResizeObserver for more accurate container size tracking
|
|
125
|
+
const resizeObserver = new ResizeObserver(updateSize);
|
|
126
|
+
if (containerDivRef.current?.parentElement) {
|
|
127
|
+
resizeObserver.observe(containerDivRef.current.parentElement);
|
|
128
|
+
}
|
|
129
|
+
window.addEventListener('resize', updateSize);
|
|
130
|
+
return () => {
|
|
131
|
+
resizeObserver.disconnect();
|
|
132
|
+
window.removeEventListener('resize', updateSize);
|
|
133
|
+
};
|
|
134
|
+
}, [responsive, width, height, aspectRatio, maxContainerWidth, maxContainerHeight]);
|
|
135
|
+
// Renders `capture` against the export view of the stage: the export
|
|
136
|
+
// region at the requested pixel ratio, selection chrome hidden and — for a
|
|
137
|
+
// transparent export — the background hidden. Selection chrome is hidden
|
|
138
|
+
// HERE rather than at the call sites: this is the single door every export
|
|
139
|
+
// goes through (download, page thumbnails, auto-save snapshots, the
|
|
140
|
+
// imperative ref handles). Leaving it to the caller is what let the
|
|
141
|
+
// download bake the Transformer of the selected element into the PNG.
|
|
142
|
+
const withExportView = useCallback((options, capture) => {
|
|
143
|
+
const stage = displayStageRef.current;
|
|
144
|
+
if (!stage)
|
|
145
|
+
return undefined;
|
|
146
|
+
const format = options.format || 'png';
|
|
147
|
+
const region = stageExportRegion(width, height, displayScale, options.pixelRatio ?? 1);
|
|
148
|
+
// includeBackground === false → transparent export: hide the background
|
|
149
|
+
// node(s) for the capture, then restore. JPEG has no alpha, so the flag
|
|
150
|
+
// is a no-op there (the DownloadSection UI only offers it for PNG/WebP).
|
|
151
|
+
const hideBackground = options.includeBackground === false && format !== 'jpeg';
|
|
152
|
+
const backgroundNodes = hideBackground
|
|
153
|
+
? stage.find('.canvas-background').filter((node) => node.visible())
|
|
154
|
+
: [];
|
|
155
|
+
const run = () => withSelectionChromeHidden(stage, () => capture(stage, region), {
|
|
156
|
+
keepPlaceholders: options.keepPlaceholders,
|
|
157
|
+
});
|
|
158
|
+
if (backgroundNodes.length === 0)
|
|
159
|
+
return run();
|
|
160
|
+
backgroundNodes.forEach((node) => node.hide());
|
|
161
|
+
stage.draw();
|
|
162
|
+
try {
|
|
163
|
+
return run();
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
backgroundNodes.forEach((node) => node.show());
|
|
167
|
+
stage.draw();
|
|
168
|
+
}
|
|
169
|
+
}, [width, height, displayScale]);
|
|
170
|
+
const toDataURL = useCallback((options = {}) => withExportView(options, (stage, region) => stage.toDataURL({
|
|
171
|
+
x: 0,
|
|
172
|
+
y: 0,
|
|
173
|
+
...region,
|
|
174
|
+
mimeType: exportMimeType(options),
|
|
175
|
+
quality: options.quality,
|
|
176
|
+
})), [withExportView]);
|
|
177
|
+
// Same image as toDataURL, but only the scene render is synchronous: the
|
|
178
|
+
// PNG encode (≈200 ms at pixelRatio 2) runs off the main thread via
|
|
179
|
+
// canvas.toBlob, so a background capture no longer freezes the editor.
|
|
180
|
+
const toDataURLAsync = useCallback(async (options = {}) => {
|
|
181
|
+
const canvas = withExportView(options, (stage, region) => stage.toCanvas({ x: 0, y: 0, ...region }));
|
|
182
|
+
if (!canvas)
|
|
183
|
+
return null;
|
|
184
|
+
const blob = await new Promise((resolve) => canvas.toBlob(resolve, exportMimeType(options), options.quality));
|
|
185
|
+
// Safari counts canvas memory against a cap until GC; free it now.
|
|
186
|
+
canvas.width = 0;
|
|
187
|
+
canvas.height = 0;
|
|
188
|
+
if (!blob)
|
|
189
|
+
return null;
|
|
190
|
+
return await new Promise((resolve) => {
|
|
191
|
+
const reader = new FileReader();
|
|
192
|
+
reader.onload = () => resolve(typeof reader.result === 'string' ? reader.result : null);
|
|
193
|
+
reader.onerror = () => resolve(null);
|
|
194
|
+
reader.readAsDataURL(blob);
|
|
195
|
+
});
|
|
196
|
+
}, [withExportView]);
|
|
197
|
+
const toTileJpeg = useCallback(async (tile) => {
|
|
198
|
+
const stage = displayStageRef.current;
|
|
199
|
+
if (!stage)
|
|
200
|
+
return null;
|
|
201
|
+
// Same region maths as stageExportRegion: the stage is shown at
|
|
202
|
+
// displayScale, the half pixel keeps float error from flooring short.
|
|
203
|
+
const ratio = tile.pixelRatio / displayScale;
|
|
204
|
+
const canvas = withSelectionChromeHidden(stage, () => stage.toCanvas({
|
|
205
|
+
x: tile.x * displayScale,
|
|
206
|
+
y: tile.y * displayScale,
|
|
207
|
+
width: (tile.outWidth + 0.5) / ratio,
|
|
208
|
+
height: (tile.outHeight + 0.5) / ratio,
|
|
209
|
+
pixelRatio: ratio,
|
|
210
|
+
}));
|
|
211
|
+
const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/jpeg', tile.quality));
|
|
212
|
+
canvas.width = 0;
|
|
213
|
+
canvas.height = 0;
|
|
214
|
+
return blob ? new Uint8Array(await blob.arrayBuffer()) : null;
|
|
215
|
+
}, [displayScale]);
|
|
216
|
+
const getPrintImages = useCallback(() => {
|
|
217
|
+
const stage = displayStageRef.current;
|
|
218
|
+
if (!stage)
|
|
219
|
+
return [];
|
|
220
|
+
const nodes = [
|
|
221
|
+
...stage.find(`.${USER_PHOTO_NODE_NAME}`),
|
|
222
|
+
...stage.find(`#${BACKGROUND_IMAGE_NODE_ID}`),
|
|
223
|
+
];
|
|
224
|
+
return nodes.flatMap((node) => {
|
|
225
|
+
const info = printImageInfo(node, displayScale);
|
|
226
|
+
return info ? [info] : [];
|
|
227
|
+
});
|
|
228
|
+
}, [displayScale]);
|
|
229
|
+
useHoverOutline(displayStageRef, listening);
|
|
230
|
+
// Konva only has a global drag threshold, read on every move. Capture
|
|
231
|
+
// phase, so it is set before any element's own press handler runs.
|
|
232
|
+
// A second finger makes the gesture a pinch (useZoomGestures): its press
|
|
233
|
+
// never reaches Konva, so it can't select what it lands on, and a drag or
|
|
234
|
+
// resize the first finger started is put back and ended.
|
|
235
|
+
// Umschalt sperrt jeden Zug auf eine Achse — einmal für alle Elemente.
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
const stage = displayStageRef.current;
|
|
238
|
+
return stage ? installAxisLock(stage) : undefined;
|
|
239
|
+
}, []);
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
const stage = displayStageRef.current;
|
|
242
|
+
const container = stage?.container();
|
|
243
|
+
if (!stage || !container)
|
|
244
|
+
return;
|
|
245
|
+
// Listening on the whole canvas region catches a second finger that lands
|
|
246
|
+
// on another page or in the gutter; every stage registers it, which is
|
|
247
|
+
// idempotent.
|
|
248
|
+
const region = container.closest('.canvas-editor-layout__canvas') ?? container;
|
|
249
|
+
let beforeTransform = new Map();
|
|
250
|
+
const useTouch = (e) => {
|
|
251
|
+
Konva.dragDistance = TOUCH_DRAG_DISTANCE;
|
|
252
|
+
if (e.touches.length < 2) {
|
|
253
|
+
beforeTransform = snapshotTransformerNodes();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// Deliberately hidden from bubble listeners too: a second finger is
|
|
257
|
+
// never a tap or a sheet swipe, and the pinch itself runs on pointer
|
|
258
|
+
// events.
|
|
259
|
+
e.stopPropagation();
|
|
260
|
+
cancelTransforms(beforeTransform);
|
|
261
|
+
cancelDrags();
|
|
262
|
+
};
|
|
263
|
+
const useMouse = () => {
|
|
264
|
+
Konva.dragDistance = MOUSE_DRAG_DISTANCE;
|
|
265
|
+
beforeTransform = snapshotTransformerNodes();
|
|
266
|
+
};
|
|
267
|
+
region.addEventListener('touchstart', useTouch, true);
|
|
268
|
+
container.addEventListener('mousedown', useMouse, true);
|
|
269
|
+
return () => {
|
|
270
|
+
region.removeEventListener('touchstart', useTouch, true);
|
|
271
|
+
container.removeEventListener('mousedown', useMouse, true);
|
|
272
|
+
};
|
|
273
|
+
}, []);
|
|
274
|
+
useImperativeHandle(ref, () => ({
|
|
275
|
+
getStage: () => displayStageRef.current,
|
|
276
|
+
toDataURL,
|
|
277
|
+
toDataURLAsync,
|
|
278
|
+
toTileJpeg,
|
|
279
|
+
getPrintImages,
|
|
280
|
+
getContainerSize: () => containerSize,
|
|
281
|
+
getDisplayScale: () => displayScale,
|
|
282
|
+
}), [toDataURL, toDataURLAsync, toTileJpeg, getPrintImages, containerSize, displayScale]);
|
|
283
|
+
return (_jsx(CanvasTextEditorProvider, { children: _jsxs("div", { ref: containerDivRef, role: ariaLabel ? 'img' : undefined, "aria-label": ariaLabel, className: cn('canvas-stage-container relative', className), style: {
|
|
284
|
+
width: containerSize.width,
|
|
285
|
+
height: containerSize.height,
|
|
286
|
+
...style,
|
|
287
|
+
}, children: [_jsx(Stage, { ref: displayStageRef, width: containerSize.width, height: containerSize.height, scale: { x: displayScale, y: displayScale }, listening: listening, onMouseDown: onStageClick, onTouchStart: onStageClick, children: _jsx(Layer, { listening: listening, children: logicalWidth &&
|
|
288
|
+
logicalHeight &&
|
|
289
|
+
(logicalWidth !== width || logicalHeight !== height) ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: activeBrand().colors.surface }), _jsx(Group, { scaleX: width / logicalWidth, scaleY: height / logicalHeight, children: children })] })) : (children) }) }), overlay, _jsx(TransformHud, { stageRef: displayStageRef, enabled: listening })] }) }));
|
|
290
|
+
});
|
|
291
|
+
CanvasStage.displayName = 'CanvasStage';
|