@ggraphic/editor 0.0.0-stage → 0.1.0-alpha.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 +26 -0
- package/dist/brand/brandRegistry.js +56 -0
- package/dist/brand/composerBrand.d.ts +146 -0
- package/dist/brand/composerBrand.js +6 -0
- package/dist/brand/documentBrand.d.ts +16 -0
- package/dist/brand/documentBrand.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 +1144 -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 +527 -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 +81 -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 +787 -0
- package/dist/components/GenericCanvasElement.d.ts +34 -0
- package/dist/components/GenericCanvasElement.js +267 -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 +216 -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 +107 -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 +321 -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 +89 -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/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/FloatingPositionControl.d.ts +38 -0
- package/dist/components/TopBar/modules/FloatingPositionControl.js +74 -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 +24 -0
- package/dist/components/markerMark.js +22 -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 +201 -0
- package/dist/configs/factory/actionFactories.js +628 -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 +431 -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 +47 -0
- package/dist/export/pptx/buildPptxModel.js +612 -0
- package/dist/export/pptx/exportPptxDeck.d.ts +26 -0
- package/dist/export/pptx/exportPptxDeck.js +80 -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 +17 -0
- package/dist/export/pptx/textModel.js +118 -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 +897 -0
- package/dist/i18n/de.js +961 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.js +949 -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 +284 -0
- package/dist/primitives/CanvasStage.d.ts +84 -0
- package/dist/primitives/CanvasStage.js +292 -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 +496 -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 +78 -0
- package/dist/sidebar/sections/CombinedTextSection.d.ts +16 -0
- package/dist/sidebar/sections/CombinedTextSection.js +43 -0
- package/dist/sidebar/sections/DiagrammeSection.d.ts +9 -0
- package/dist/sidebar/sections/DiagrammeSection.js +40 -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 +28 -0
- package/dist/sidebar/sections/FormenSection.js +440 -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 +33 -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 +85 -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 +61 -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 +43 -0
- package/dist/sidebar/sections/assets/useElementCatalog.js +386 -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 +34 -0
- package/dist/sidebar/sections/effects/OutlineSettings.d.ts +12 -0
- package/dist/sidebar/sections/effects/OutlineSettings.js +29 -0
- package/dist/sidebar/sections/effects/ShadowSettings.d.ts +13 -0
- package/dist/sidebar/sections/effects/ShadowSettings.js +38 -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 +90 -0
- package/dist/sidebar/sections/tools/GradientTextTool.d.ts +5 -0
- package/dist/sidebar/sections/tools/GradientTextTool.js +104 -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 +125 -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 +151 -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/documentBrandConfig.d.ts +14 -0
- package/dist/testing/documentBrandConfig.js +60 -0
- package/dist/testing/documentBrandPacks.d.ts +10 -0
- package/dist/testing/documentBrandPacks.js +45 -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/canvasAssets.d.ts +140 -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 +30 -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 +7 -0
- package/dist/utils/colorNames.js +17 -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 +26 -0
- package/dist/utils/fontMarkSupport.js +32 -0
- package/dist/utils/frameUtils.d.ts +20 -0
- package/dist/utils/frameUtils.js +283 -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 +27 -0
- package/dist/utils/illustrations/registry.js +106 -0
- package/dist/utils/illustrations/svgCache.d.ts +60 -0
- package/dist/utils/illustrations/svgCache.js +349 -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 +94 -0
- package/dist/utils/imageFilters.js +304 -0
- package/dist/utils/imageLook.d.ts +18 -0
- package/dist/utils/imageLook.js +41 -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 +38 -0
- package/dist/utils/markerBoxes.js +60 -0
- package/dist/utils/markerColors.d.ts +16 -0
- package/dist/utils/markerColors.js +32 -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 +25 -0
- package/dist/utils/photoPlaceholder.js +38 -0
- package/dist/utils/pillBadgeUtils.d.ts +41 -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 +64 -0
- package/dist/utils/shapes.js +838 -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 +254 -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 +9 -0
- package/dist/utils/zipPageImages.js +30 -0
- package/package.json +105 -3
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
/**
|
|
4
|
+
* GenericCanvas - Unified config-driven canvas component
|
|
5
|
+
*
|
|
6
|
+
* Renders any canvas type based on FullCanvasConfig.
|
|
7
|
+
* Manages state, history, interactions, and sidebar.
|
|
8
|
+
*
|
|
9
|
+
* Refactored to use extracted hooks, utilities, and components for better maintainability.
|
|
10
|
+
*/
|
|
11
|
+
import Konva from 'konva';
|
|
12
|
+
import { useRef, useState, useEffect, useCallback, useMemo, memo, useContext, useImperativeHandle, useLayoutEffect, } from 'react';
|
|
13
|
+
import { DocumentBrandContext } from '@ggraphic/editor/brand/documentBrand';
|
|
14
|
+
import { useEmitHostStateChanges } from '@ggraphic/editor/collab/useEmitHostStateChanges';
|
|
15
|
+
import { useYjsCanvasBinding } from '@ggraphic/editor/collab/useYjsCanvasBinding';
|
|
16
|
+
import { stateKeyOfCallback } from '@ggraphic/editor/collab/wrapCallbacksWithPageSync';
|
|
17
|
+
import { CropGhostOverlay } from '@ggraphic/editor/components/CropGhostOverlay';
|
|
18
|
+
import { PrintGuides } from '@ggraphic/editor/components/PrintGuides';
|
|
19
|
+
import { SlotBudgetStatus } from '@ggraphic/editor/components/SlotBudgetStatus';
|
|
20
|
+
import { getCanvasFormatOrDefault } from '@ggraphic/editor/formats/index';
|
|
21
|
+
import { useAnnounce } from '@ggraphic/editor/hooks/useAnnounce';
|
|
22
|
+
import { useSelectionAnnouncement } from '@ggraphic/editor/hooks/useSelectionAnnouncement';
|
|
23
|
+
import { messages } from '@ggraphic/editor/i18n/messages';
|
|
24
|
+
import { CanvasStoreProvider, useCanvasStore, useCanvasStoreSelector, } from '@ggraphic/editor/stores/CanvasStoreProvider';
|
|
25
|
+
import { useAutoSaveStore } from '@ggraphic/editor/stores/useAutoSaveStore';
|
|
26
|
+
import { itemBodyRect } from '@ggraphic/editor/utils/deepSelect';
|
|
27
|
+
import { ensureFontsReady } from '@ggraphic/editor/utils/ensureFontsReady';
|
|
28
|
+
import { applyLayerSelection, } from '@ggraphic/editor/utils/layerSelection';
|
|
29
|
+
import { locateDrop, } from '@ggraphic/editor/utils/mediaDrop';
|
|
30
|
+
import { selectableItemIds } from '@ggraphic/editor/utils/multiSelect';
|
|
31
|
+
import { rotaterRects, visibleArea } from '@ggraphic/editor/utils/orientation';
|
|
32
|
+
import { PendingImagesContext } from '@ggraphic/editor/utils/pendingImages';
|
|
33
|
+
import { PreviewRenderContext } from '../utils/filterCache.js';
|
|
34
|
+
import { stageCssScale } from '@ggraphic/editor/utils/stageCssScale';
|
|
35
|
+
import { getOptimalContainerWidth } from '@ggraphic/editor/utils/viewport';
|
|
36
|
+
import { blockElementIds, placeBlock } from '../blocks/liftedBlock.js';
|
|
37
|
+
import { hostEmittedStateKeys } from '../collab/pageElementStateKeys.js';
|
|
38
|
+
import { useSelectionAwareness } from '../collab/useSelectionAwareness.js';
|
|
39
|
+
import { useYjsPageStateSync } from '../collab/useYjsPageStateSync.js';
|
|
40
|
+
import { readGroups } from '../groups/pageGroups.js';
|
|
41
|
+
import { useCanvasInteractions, useCanvasStoreReset, useCanvasHistorySetup, useFontGeneration, useFontLoader, } from '../hooks/index.js';
|
|
42
|
+
import { useCanvasAutoSave } from '../hooks/useCanvasAutoSave.js';
|
|
43
|
+
import { useCanvasElementHandlers } from '../hooks/useCanvasElementHandlers.js';
|
|
44
|
+
import { useCanvasKeyboardHandlers } from '../hooks/useCanvasKeyboardHandlers.js';
|
|
45
|
+
import { useContextPress } from '../hooks/useContextPress.js';
|
|
46
|
+
import { useCropSession } from '../hooks/useCropSession.js';
|
|
47
|
+
import { useDeepSelect } from '../hooks/useDeepSelect.js';
|
|
48
|
+
import { floatingModuleFor } from '../hooks/useFloatingModuleState.js';
|
|
49
|
+
import { CanvasStage, SnapGuidelines } from '../primitives/index.js';
|
|
50
|
+
import { createCanvasCommands, } from '../utils/canvasCommands.js';
|
|
51
|
+
import { canvasFontFamilies } from '../utils/canvasFontFamilies.js';
|
|
52
|
+
import { buildCanvasItems, buildSortedRenderList } from '../utils/canvasLayerManager.js';
|
|
53
|
+
import { addHostElement, fromHostKinds } from '../utils/elementKinds.js';
|
|
54
|
+
import { captureStageImage, captureStageImageAsync, rasterizeStageElement, visibleStageTexts, } from '../utils/captureStage.js';
|
|
55
|
+
import { MAX_ICON_SELECTIONS, selectedCatalogIconIds } from '../utils/iconInstances.js';
|
|
56
|
+
import { layerLabel, pageLayerLabels, stageSummary } from '../utils/layerLabels.js';
|
|
57
|
+
import { findTemplateEntry } from '../utils/templateElementInstance.js';
|
|
58
|
+
import { CanvasRenderLayer } from './CanvasRenderLayer.js';
|
|
59
|
+
import { ToolbarStateBridge } from './ToolbarStateBridge.js';
|
|
60
|
+
const EMPTY_CALLBACKS = {};
|
|
61
|
+
const hostLayoutKeys = fromHostKinds((kinds) => kinds.flatMap((k) => k.layoutStateKeys ?? []));
|
|
62
|
+
/** Canvas px between blocks clicked in one after another. */
|
|
63
|
+
const BLOCK_CASCADE = 40;
|
|
64
|
+
// Generic component with forwardRef - uses type assertion pattern for TypeScript compatibility
|
|
65
|
+
function GenericCanvasWithRef(props) {
|
|
66
|
+
const { config, initialProps, callbacks = EMPTY_CALLBACKS, onDelete, forwardedRef, onToolbarStateChange, onAutoSaveShareToken, preview = false, previewCaptureRatio, isActivePage = true, pageNumber, readOnly = false, } = props;
|
|
67
|
+
const interactive = !preview && !readOnly;
|
|
68
|
+
const shortcutsEnabled = interactive && isActivePage;
|
|
69
|
+
const stageRef = useRef(null);
|
|
70
|
+
const getStage = useCallback(() => stageRef.current?.getStage() ?? null, []);
|
|
71
|
+
const [pendingImages] = useState(() => new Set());
|
|
72
|
+
// Export state (used by auto-save and attribution overlay)
|
|
73
|
+
const [exportedImage, setExportedImage] = useState(null);
|
|
74
|
+
const exportedImageRef = useRef(null);
|
|
75
|
+
useCanvasStoreReset(preview ? null : config.id);
|
|
76
|
+
// Dynamic maxContainerWidth for responsive rendering
|
|
77
|
+
const [maxWidth, setMaxWidth] = useState(getOptimalContainerWidth());
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const handleResize = () => setMaxWidth(getOptimalContainerWidth());
|
|
80
|
+
window.addEventListener('resize', handleResize);
|
|
81
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
82
|
+
}, []);
|
|
83
|
+
// Track config ID to detect actual config changes (not just reference changes)
|
|
84
|
+
const configIdRef = useRef(config.id);
|
|
85
|
+
const [state, setStateRaw] = useState(() => config.createInitialState(initialProps));
|
|
86
|
+
// The text edit in progress as it will look once committed (`TextPreview.overrides`). Kept apart
|
|
87
|
+
// from `state` on purpose: `state` reaches the page document, the history and the auto-save on
|
|
88
|
+
// every change, and a draft is none of their business until it is committed.
|
|
89
|
+
const [textPreview, setTextPreview] = useState(null);
|
|
90
|
+
// Only reset state when the config ID actually changes (different canvas type)
|
|
91
|
+
// This prevents state reset when parent re-renders with same config but new object references
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (configIdRef.current !== config.id) {
|
|
94
|
+
configIdRef.current = config.id;
|
|
95
|
+
setStateRaw(config.createInitialState(initialProps));
|
|
96
|
+
}
|
|
97
|
+
}, [config, initialProps]);
|
|
98
|
+
// Push background-image fields and free-element collections back to the host.
|
|
99
|
+
// The config stores change both only in local component state (unlike text
|
|
100
|
+
// fields, which sync through their own callbacks), so without this the chosen
|
|
101
|
+
// background image and every added element is lost on reload (#3416).
|
|
102
|
+
useEmitHostStateChanges(state, callbacks, hostEmittedStateKeys());
|
|
103
|
+
const fontFamilies = useMemo(() => canvasFontFamilies(config), [config]);
|
|
104
|
+
// Font loading - non-blocking! Renders immediately with fallback, swaps to custom font when ready
|
|
105
|
+
const { isFontAvailable } = useFontLoader(config.fonts?.requireFontLoad !== false && fontFamilies.length > 0
|
|
106
|
+
? {
|
|
107
|
+
fontFamily: fontFamilies,
|
|
108
|
+
fontSize: config.fonts?.fontSize ?? 60,
|
|
109
|
+
maxAttempts: 30,
|
|
110
|
+
pollInterval: 50,
|
|
111
|
+
}
|
|
112
|
+
: null);
|
|
113
|
+
const setStateWrapper = useCallback((partial) => {
|
|
114
|
+
setStateRaw((prev) => {
|
|
115
|
+
if (typeof partial === 'function') {
|
|
116
|
+
return partial(prev);
|
|
117
|
+
}
|
|
118
|
+
return { ...prev, ...partial };
|
|
119
|
+
});
|
|
120
|
+
}, []);
|
|
121
|
+
// External edits to this page's `state` Y.Map (chat sharepic editing via
|
|
122
|
+
// the Hocuspocus internal API) merge into the live component state.
|
|
123
|
+
// Rebuilding through createInitialState recomputes the derived fields.
|
|
124
|
+
//
|
|
125
|
+
// Nothing is withheld from the merge. This used to delete a host kind's list
|
|
126
|
+
// so a template-derived entry would regenerate from the new text — but that
|
|
127
|
+
// entry sits in a collection users also add to by hand, and dropping the whole
|
|
128
|
+
// array took every hand-added one with it (#3421). Which entry a template
|
|
129
|
+
// derives is the template's own knowledge, and `createInitialState` is where
|
|
130
|
+
// it already lives.
|
|
131
|
+
const [remoteStateCount, setRemoteStateCount] = useState(0);
|
|
132
|
+
const handleRemotePageState = useCallback((partial) => {
|
|
133
|
+
setStateRaw((prev) => config.createInitialState({ ...prev, ...partial }));
|
|
134
|
+
setRemoteStateCount((n) => n + 1);
|
|
135
|
+
}, [config]);
|
|
136
|
+
// Measured fits need the brand fonts, so normalization waits for them. The
|
|
137
|
+
// result reaches the page through useEmitHostStateChanges like any edit; a
|
|
138
|
+
// preview has no writers and only renders it.
|
|
139
|
+
const normalizeLoadedState = config.normalizeLoadedState;
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!normalizeLoadedState)
|
|
142
|
+
return undefined;
|
|
143
|
+
let cancelled = false;
|
|
144
|
+
void ensureFontsReady().then(() => {
|
|
145
|
+
if (!cancelled)
|
|
146
|
+
setStateRaw((prev) => normalizeLoadedState(prev) ?? prev);
|
|
147
|
+
});
|
|
148
|
+
return () => {
|
|
149
|
+
cancelled = true;
|
|
150
|
+
};
|
|
151
|
+
}, [normalizeLoadedState, remoteStateCount]);
|
|
152
|
+
useYjsPageStateSync({
|
|
153
|
+
pageYMap: props.pageBinding?.pageYMap ?? null,
|
|
154
|
+
isSynced: props.pageBinding?.isSynced ?? false,
|
|
155
|
+
onRemoteState: handleRemotePageState,
|
|
156
|
+
});
|
|
157
|
+
const collectState = useCallback(() => state, [state]);
|
|
158
|
+
const committedStateRef = useRef(state);
|
|
159
|
+
useLayoutEffect(() => {
|
|
160
|
+
committedStateRef.current = state;
|
|
161
|
+
}, [state]);
|
|
162
|
+
// Text fields reach the page document only through their `on<Key>Change`
|
|
163
|
+
// callback, so a restore reports each one it changed (#4247). The emitted
|
|
164
|
+
// keys are left to useEmitHostStateChanges, which already reports them.
|
|
165
|
+
const handleRestore = useCallback((restoredState) => {
|
|
166
|
+
const prev = committedStateRef.current;
|
|
167
|
+
// Every entry snapshots the whole state, so a key it lacks did not exist
|
|
168
|
+
// yet — the position a first drag or turn of a template text wrote.
|
|
169
|
+
// Merging alone kept that key: one undo turned the text back but left
|
|
170
|
+
// it shifted. Only host-emitted keys are dropped: useEmitHostStateChanges
|
|
171
|
+
// reports their removal to the page document, whereas any other deleted
|
|
172
|
+
// key would never reach it and canvas and document would diverge.
|
|
173
|
+
const emitted = new Set(hostEmittedStateKeys());
|
|
174
|
+
setStateRaw((p) => {
|
|
175
|
+
const next = { ...p, ...restoredState };
|
|
176
|
+
for (const key of Object.keys(p)) {
|
|
177
|
+
if (!(key in restoredState) && emitted.has(key))
|
|
178
|
+
delete next[key];
|
|
179
|
+
}
|
|
180
|
+
return next;
|
|
181
|
+
});
|
|
182
|
+
for (const [name, callback] of Object.entries(callbacks)) {
|
|
183
|
+
const key = stateKeyOfCallback(name);
|
|
184
|
+
if (!key || !(key in restoredState) || emitted.has(key))
|
|
185
|
+
continue;
|
|
186
|
+
if (JSON.stringify(restoredState[key]) === JSON.stringify(prev[key]))
|
|
187
|
+
continue;
|
|
188
|
+
callback?.(restoredState[key]);
|
|
189
|
+
}
|
|
190
|
+
}, [callbacks]);
|
|
191
|
+
const { saveToHistory, debouncedSaveToHistory, runHistoryBatch, checkpoint, flushPendingSaves, undo, redo, canUndo, canRedo, } = useCanvasHistorySetup(collectState, handleRestore, 500, shortcutsEnabled);
|
|
192
|
+
// Read through the ref so `actions` keeps its identity across edits; every
|
|
193
|
+
// action calls getState() when it runs, so it still sees the latest state.
|
|
194
|
+
const getState = useCallback(() => committedStateRef.current, []);
|
|
195
|
+
const cropSession = useCropSession({
|
|
196
|
+
elements: config.elements,
|
|
197
|
+
readState: getState,
|
|
198
|
+
restore: handleRestore,
|
|
199
|
+
checkpoint,
|
|
200
|
+
});
|
|
201
|
+
// `runHistoryBatch` rides on the actions so the AI bridge (built from the
|
|
202
|
+
// page's live actions) coalesces one op batch into one undo step.
|
|
203
|
+
const actions = useMemo(() => ({
|
|
204
|
+
...config.createActions(getState, setStateWrapper, saveToHistory, debouncedSaveToHistory, callbacks),
|
|
205
|
+
runHistoryBatch,
|
|
206
|
+
}), [
|
|
207
|
+
config,
|
|
208
|
+
getState,
|
|
209
|
+
setStateWrapper,
|
|
210
|
+
saveToHistory,
|
|
211
|
+
debouncedSaveToHistory,
|
|
212
|
+
runHistoryBatch,
|
|
213
|
+
callbacks,
|
|
214
|
+
]);
|
|
215
|
+
// Allowlist of state fields that calculateLayout reads across all canvas configs.
|
|
216
|
+
// New fields must be added here if a new config's calculateLayout reads them.
|
|
217
|
+
const layoutKey = useMemo(() => {
|
|
218
|
+
const s = state;
|
|
219
|
+
return JSON.stringify([
|
|
220
|
+
// Text content
|
|
221
|
+
s.line1,
|
|
222
|
+
s.line2,
|
|
223
|
+
s.line3,
|
|
224
|
+
s.headline,
|
|
225
|
+
s.subtext,
|
|
226
|
+
s.subtext2,
|
|
227
|
+
s.header,
|
|
228
|
+
s.body,
|
|
229
|
+
s.quote,
|
|
230
|
+
s.eventTitle,
|
|
231
|
+
s.beschreibung,
|
|
232
|
+
s.label,
|
|
233
|
+
// Font sizes
|
|
234
|
+
s.fontSize,
|
|
235
|
+
s.customPrimaryFontSize,
|
|
236
|
+
s.customSecondaryFontSize,
|
|
237
|
+
s.customEventTitleFontSize,
|
|
238
|
+
s.customBeschreibungFontSize,
|
|
239
|
+
s.customLabelFontSize,
|
|
240
|
+
s.customHeadlineFontSize,
|
|
241
|
+
s.customSubtextFontSize,
|
|
242
|
+
s.customSubtext2FontSize,
|
|
243
|
+
// Colors & styling
|
|
244
|
+
s.colorSchemeId,
|
|
245
|
+
s.colorScheme,
|
|
246
|
+
s.backgroundColor,
|
|
247
|
+
// Variants
|
|
248
|
+
s.slideVariant,
|
|
249
|
+
// What the layouts of the host kinds' templates read (`layoutStateKeys`).
|
|
250
|
+
...hostLayoutKeys().map((key) => s[key]),
|
|
251
|
+
]);
|
|
252
|
+
}, [state]);
|
|
253
|
+
// `isFontAvailable` schlägt genau einmal um, und zwar sobald die
|
|
254
|
+
// GRUNDSCHNITTE da sind — bei Instrument Sans ist das schon beim Seitenaufbau der
|
|
255
|
+
// Fall, weil der Fließtext ihn benutzt. Fett und Kursiv treffen danach ein.
|
|
256
|
+
// `calculateLayout` misst aber mit (Auto-Fit-Schriftgrad, Y-Stapelung), also
|
|
257
|
+
// braucht es den Zähler zusätzlich, sonst stünde ein Slider-Untertext für
|
|
258
|
+
// immer in der Größe, die gegen den synthetisch gefetteten Regular passte.
|
|
259
|
+
const fontGeneration = useFontGeneration();
|
|
260
|
+
const layout = useMemo(() => {
|
|
261
|
+
return config.calculateLayout(state);
|
|
262
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- layoutKey is a stable string derived from layout-relevant state fields
|
|
263
|
+
}, [config, layoutKey, isFontAvailable, fontGeneration]);
|
|
264
|
+
const stateForGroups = useRef(state);
|
|
265
|
+
stateForGroups.current = state;
|
|
266
|
+
const getGroups = useCallback(() => readGroups(stateForGroups.current), []);
|
|
267
|
+
const { setSelectedElement, selectElement, beginMarquee, handleStageClick, handleSnapChange, getSnapTargets, } = useCanvasInteractions({ stageRef, marqueeEnabled: interactive, getGroups });
|
|
268
|
+
const store = useCanvasStore();
|
|
269
|
+
const { setSnapLines, updateElementPosition } = store.getState();
|
|
270
|
+
// Before the deep select: a ⌃-click on a Mac is a right-click, not a pick.
|
|
271
|
+
useContextPress(stageRef, interactive);
|
|
272
|
+
useDeepSelect(stageRef, interactive);
|
|
273
|
+
// One selection across all pages: leaving the active page drops its own.
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
if (!isActivePage)
|
|
276
|
+
setSelectedElement(null);
|
|
277
|
+
}, [isActivePage, setSelectedElement]);
|
|
278
|
+
// Output canvas dimensions are driven by the chosen format. Layout calculators
|
|
279
|
+
// continue to operate in the template's reference space (config.canvas.{width,height});
|
|
280
|
+
// CanvasStage scales them up to the format dims via a Konva Group when they differ.
|
|
281
|
+
const formatId = useCanvasStoreSelector((s) => s.formatId);
|
|
282
|
+
const format = getCanvasFormatOrDefault(formatId);
|
|
283
|
+
const stageWidth = format.width;
|
|
284
|
+
const stageHeight = format.height;
|
|
285
|
+
const referenceWidth = config.canvas.width;
|
|
286
|
+
const referenceHeight = config.canvas.height;
|
|
287
|
+
// Auto-save hook for gallery integration. The multi-page editor passes an
|
|
288
|
+
// explicit value (off in collab — Hocuspocus persists server-side — and off
|
|
289
|
+
// beyond one page, where deck-level autosave takes over); standalone
|
|
290
|
+
// consumers keep the historical default of on.
|
|
291
|
+
const autoSaveEnabled = !preview && (props.autoSave ?? true);
|
|
292
|
+
// Fresh capture for the unmount-flush path — transformer hiding makes the
|
|
293
|
+
// shot clean even while an element is still selected.
|
|
294
|
+
const captureForAutoSaveFlush = useCallback(() => captureStageImage(stageRef.current), []);
|
|
295
|
+
const describeForShare = config.shareMetadata;
|
|
296
|
+
useCanvasAutoSave(exportedImage, {
|
|
297
|
+
canvasType: config.id,
|
|
298
|
+
canvasState: state,
|
|
299
|
+
// The hook hands back the `state` passed beside it, typed as its default.
|
|
300
|
+
shareMetadata: describeForShare && ((s) => describeForShare(s)),
|
|
301
|
+
enabled: autoSaveEnabled,
|
|
302
|
+
captureImage: captureForAutoSaveFlush,
|
|
303
|
+
onShareToken: onAutoSaveShareToken,
|
|
304
|
+
});
|
|
305
|
+
// History-synced auto-save: capture canvas whenever undo/redo history changes
|
|
306
|
+
const historyIndex = useCanvasStoreSelector((s) => s.historyIndex);
|
|
307
|
+
const setAutoSaveDirty = useAutoSaveStore((s) => s.setDirty);
|
|
308
|
+
const lastAutoSaveHistoryIndexRef = useRef(-1);
|
|
309
|
+
const textPreviewing = textPreview !== null;
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
if (historyIndex < 0)
|
|
312
|
+
return;
|
|
313
|
+
// historyIndex 0 is the initial mount snapshot — an untouched canvas is not dirty
|
|
314
|
+
if (autoSaveEnabled &&
|
|
315
|
+
historyIndex > 0 &&
|
|
316
|
+
lastAutoSaveHistoryIndexRef.current !== historyIndex) {
|
|
317
|
+
setAutoSaveDirty(true);
|
|
318
|
+
}
|
|
319
|
+
// The capture only feeds useCanvasAutoSave — without auto-save it is a
|
|
320
|
+
// wasted pixelRatio-2 PNG encode on the main thread after every edit.
|
|
321
|
+
// A text being typed is drawn on the stage but not part of the page yet: the shot waits for
|
|
322
|
+
// the edit to end (the effect runs again then) instead of keeping the draft's plates.
|
|
323
|
+
if (!autoSaveEnabled || textPreviewing || lastAutoSaveHistoryIndexRef.current === historyIndex)
|
|
324
|
+
return;
|
|
325
|
+
// Debounce screenshot capture — toDataURL at pixelRatio:2 is expensive (~100-200ms).
|
|
326
|
+
// 1500ms ensures we only capture after the user stops editing. Transformer
|
|
327
|
+
// hiding inside captureStageImage keeps the shot clean even while an
|
|
328
|
+
// element is selected, so edits made with a live selection auto-save too.
|
|
329
|
+
const timer = setTimeout(() => {
|
|
330
|
+
const dataUrl = captureStageImage(stageRef.current);
|
|
331
|
+
if (dataUrl) {
|
|
332
|
+
setExportedImage(dataUrl);
|
|
333
|
+
exportedImageRef.current = dataUrl;
|
|
334
|
+
lastAutoSaveHistoryIndexRef.current = historyIndex;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
console.warn('[AutoSave] capture failed: stage toDataURL returned null');
|
|
338
|
+
}
|
|
339
|
+
}, 1500);
|
|
340
|
+
return () => clearTimeout(timer);
|
|
341
|
+
}, [historyIndex, autoSaveEnabled, setAutoSaveDirty, textPreviewing]);
|
|
342
|
+
// Push live state/actions/selection up to the shared sidebar. Replaces the
|
|
343
|
+
// old 200ms poll in PageWrapper: updates land synchronously with edits.
|
|
344
|
+
const onLiveState = props.onLiveState;
|
|
345
|
+
const liveStateRef = useRef({ state, actions });
|
|
346
|
+
const clickedBlocksRef = useRef(0);
|
|
347
|
+
liveStateRef.current = { state, actions };
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
if (!onLiveState)
|
|
350
|
+
return;
|
|
351
|
+
onLiveState(state, actions, store.getState().selectedElement);
|
|
352
|
+
}, [onLiveState, state, actions, store]);
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
if (!onLiveState)
|
|
355
|
+
return undefined;
|
|
356
|
+
let prev = store.getState().selectedElement;
|
|
357
|
+
return store.subscribe((s) => {
|
|
358
|
+
if (s.selectedElement === prev)
|
|
359
|
+
return;
|
|
360
|
+
prev = s.selectedElement;
|
|
361
|
+
const { state: liveState, actions: liveActions } = liveStateRef.current;
|
|
362
|
+
onLiveState(liveState, liveActions, s.selectedElement);
|
|
363
|
+
});
|
|
364
|
+
}, [onLiveState, store]);
|
|
365
|
+
// Live remote selections (collab mode). Publishes the local selection to
|
|
366
|
+
// awareness (active page only) and maps remote peers' selections on this
|
|
367
|
+
// page to element ids for the render layer's outlines.
|
|
368
|
+
const collabPageId = props.pageBinding?.pageId ?? null;
|
|
369
|
+
const remoteSelectionsRaw = useSelectionAwareness(props.pageBinding?.provider ?? null, {
|
|
370
|
+
activePageId: collabPageId,
|
|
371
|
+
publish: props.pageBinding?.publishSelection ?? true,
|
|
372
|
+
});
|
|
373
|
+
const remoteSelections = useMemo(() => {
|
|
374
|
+
if (remoteSelectionsRaw.length === 0)
|
|
375
|
+
return undefined;
|
|
376
|
+
const map = new Map();
|
|
377
|
+
for (const peer of remoteSelectionsRaw) {
|
|
378
|
+
if (peer.activePageId !== collabPageId)
|
|
379
|
+
continue;
|
|
380
|
+
for (const id of peer.selectedLayerIds) {
|
|
381
|
+
if (!map.has(id))
|
|
382
|
+
map.set(id, { userName: peer.userName, color: peer.color });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return map.size > 0 ? map : undefined;
|
|
386
|
+
}, [remoteSelectionsRaw, collabPageId]);
|
|
387
|
+
const elementHandlers = useCanvasElementHandlers({
|
|
388
|
+
config,
|
|
389
|
+
state,
|
|
390
|
+
setState: setStateWrapper,
|
|
391
|
+
actions,
|
|
392
|
+
layout,
|
|
393
|
+
callbacks,
|
|
394
|
+
selectElement,
|
|
395
|
+
updateElementPosition,
|
|
396
|
+
saveToHistory,
|
|
397
|
+
debouncedSaveToHistory,
|
|
398
|
+
setTextPreview,
|
|
399
|
+
});
|
|
400
|
+
// The page as the canvas draws it: the text edit in progress laid over `state`. Only drawing
|
|
401
|
+
// reads this; everything that persists, emits, records or measures the page reads `state`.
|
|
402
|
+
const drawnState = useMemo(() => (textPreview ? { ...state, ...textPreview } : state), [state, textPreview]);
|
|
403
|
+
const canvasItems = useMemo(() => buildCanvasItems(config, drawnState), [config, drawnState]);
|
|
404
|
+
const sortedRenderList = useMemo(() => buildSortedRenderList(canvasItems, state.layerOrder ?? []), [canvasItems, state.layerOrder]);
|
|
405
|
+
const stageLabel = useMemo(() => stageSummary(pageLayerLabels(sortedRenderList, state), pageNumber ? messages().common.page(pageNumber) : messages().layers.stageCanvas), [sortedRenderList, state, pageNumber]);
|
|
406
|
+
// The doors read the page at call time, not from a render closure: a menu
|
|
407
|
+
// or key acts on what is on screen now.
|
|
408
|
+
const commandInputsRef = useRef({ layout, sortedRenderList, actions });
|
|
409
|
+
useLayoutEffect(() => {
|
|
410
|
+
commandInputsRef.current = { layout, sortedRenderList, actions };
|
|
411
|
+
}, [layout, sortedRenderList, actions]);
|
|
412
|
+
const logicalScale = stageWidth / referenceWidth;
|
|
413
|
+
const announce = useAnnounce();
|
|
414
|
+
const commands = useMemo(() => createCanvasCommands({
|
|
415
|
+
store,
|
|
416
|
+
getState: () => committedStateRef.current,
|
|
417
|
+
setState: setStateWrapper,
|
|
418
|
+
saveToHistory,
|
|
419
|
+
runHistoryBatch,
|
|
420
|
+
getActions: () => commandInputsRef.current.actions,
|
|
421
|
+
template: (id) => findTemplateEntry(config.elements, committedStateRef.current, commandInputsRef.current.layout, id),
|
|
422
|
+
getRenderList: () => commandInputsRef.current.sortedRenderList,
|
|
423
|
+
getStage: () => stageRef.current?.getStage() ?? null,
|
|
424
|
+
logicalScale: () => logicalScale,
|
|
425
|
+
// Die Tür liest nur id, Typ und Positionsschlüssel; der Zustandstyp der Config spielt dort keine Rolle.
|
|
426
|
+
getElements: () => config.elements,
|
|
427
|
+
getLayout: () => commandInputsRef.current.layout,
|
|
428
|
+
isReadOnly: () => !interactive,
|
|
429
|
+
getPageSize: () => ({ width: referenceWidth, height: referenceHeight }),
|
|
430
|
+
announce,
|
|
431
|
+
}), [
|
|
432
|
+
store,
|
|
433
|
+
setStateWrapper,
|
|
434
|
+
saveToHistory,
|
|
435
|
+
runHistoryBatch,
|
|
436
|
+
config.elements,
|
|
437
|
+
logicalScale,
|
|
438
|
+
interactive,
|
|
439
|
+
referenceWidth,
|
|
440
|
+
referenceHeight,
|
|
441
|
+
announce,
|
|
442
|
+
]);
|
|
443
|
+
// Selection changes are announced from the page's own store (debounced).
|
|
444
|
+
useSelectionAnnouncement(store, (id) => {
|
|
445
|
+
const item = commandInputsRef.current.sortedRenderList.find((entry) => entry.id === id);
|
|
446
|
+
return item ? layerLabel(item, committedStateRef.current) : null;
|
|
447
|
+
}, isActivePage);
|
|
448
|
+
// The multi-selection transformer asks this when the selection changes, so a
|
|
449
|
+
// selection change never re-renders the canvas.
|
|
450
|
+
const canRotateSelection = useCallback(() => commands.capabilities().canRotate, [commands]);
|
|
451
|
+
useCanvasKeyboardHandlers({
|
|
452
|
+
store,
|
|
453
|
+
state,
|
|
454
|
+
actions,
|
|
455
|
+
setState: setStateWrapper,
|
|
456
|
+
setSelectedElement,
|
|
457
|
+
commands,
|
|
458
|
+
elements: config.elements,
|
|
459
|
+
saveToHistory,
|
|
460
|
+
enabled: shortcutsEnabled,
|
|
461
|
+
});
|
|
462
|
+
// Bridge ref for ToolbarStateBridge → useImperativeHandle communication
|
|
463
|
+
const bridgeRef = useRef(null);
|
|
464
|
+
/**
|
|
465
|
+
* Konva berechnet den Zeilenumbruch eines Text-Knotens EINMAL, beim Setzen
|
|
466
|
+
* seiner Eigenschaften, und legt ihn in `textArr` ab. Ist die Webschrift zu
|
|
467
|
+
* diesem Zeitpunkt noch nicht geladen, misst es gegen die Ersatzschrift und
|
|
468
|
+
* behaelt diesen Umbruch, auch wenn die echte Schrift eintrifft: Das Bild
|
|
469
|
+
* wird dann in der richtigen Schrift mit den falschen Bruechen gezeichnet.
|
|
470
|
+
* Im Realtest lief „aus Erneuerbaren." so auf drei Zeilen, mit dem Punkt
|
|
471
|
+
* allein auf der letzten — die Ersatzschrift Georgia ist breiter als
|
|
472
|
+
* Fraunces und drueckte ihn ueber das Satzmass.
|
|
473
|
+
*
|
|
474
|
+
* `layout` wird an `isFontAvailable` zwar neu berechnet, das rettet aber nur
|
|
475
|
+
* die Faelle, in denen sich dabei eine Eigenschaft aendert. Bleibt der
|
|
476
|
+
* Schriftgrad gleich, sieht React identische Props und Konva rechnet nichts
|
|
477
|
+
* neu. Der Text wird deshalb zweimal gesetzt: Konvas Setter steigt bei
|
|
478
|
+
* unveraendertem Wert frueh aus, ein einzelnes Setzen waere wirkungslos.
|
|
479
|
+
*
|
|
480
|
+
* Nur beim Umschlagen von `isFontAvailable`, nicht bei jeder Neuberechnung
|
|
481
|
+
* des Layouts: danach misst Konva ohnehin gegen die richtige Schrift, und
|
|
482
|
+
* ein Zuruecksetzen bei jeder Textaenderung wuerde der laufenden Bearbeitung
|
|
483
|
+
* in die Quere kommen.
|
|
484
|
+
*/
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
if (!isFontAvailable)
|
|
487
|
+
return;
|
|
488
|
+
const stage = stageRef.current?.getStage();
|
|
489
|
+
if (!stage)
|
|
490
|
+
return;
|
|
491
|
+
for (const node of stage.find('Text')) {
|
|
492
|
+
const textNode = node;
|
|
493
|
+
const value = textNode.text();
|
|
494
|
+
if (!value)
|
|
495
|
+
continue;
|
|
496
|
+
textNode.text('');
|
|
497
|
+
textNode.text(value);
|
|
498
|
+
}
|
|
499
|
+
stage.batchDraw();
|
|
500
|
+
}, [isFontAvailable]);
|
|
501
|
+
// Expose ref methods for parent access (multi-page export, shared sidebar, and toolbar handlers)
|
|
502
|
+
// Bridge handlers are read from bridgeRef.current at call time (set by ToolbarStateBridge)
|
|
503
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
504
|
+
toDataURL: (options) => {
|
|
505
|
+
return stageRef.current?.toDataURL(options);
|
|
506
|
+
},
|
|
507
|
+
// Transformer hiding replaces the old deselect + 50ms-rerender hack:
|
|
508
|
+
// the user's selection survives a capture.
|
|
509
|
+
captureCanvas: async (options) => {
|
|
510
|
+
await ensureFontsReady();
|
|
511
|
+
return captureStageImageAsync(stageRef.current, options);
|
|
512
|
+
},
|
|
513
|
+
capturePrintTile: async (tile, pixelRatio, quality) => {
|
|
514
|
+
await ensureFontsReady();
|
|
515
|
+
return stageRef.current?.toTileJpeg({ ...tile, pixelRatio, quality }) ?? null;
|
|
516
|
+
},
|
|
517
|
+
getPrintImages: () => stageRef.current?.getPrintImages() ?? [],
|
|
518
|
+
imagesSettled: () => pendingImages.size === 0,
|
|
519
|
+
captureCanvasForAi: async () => captureStageImage(stageRef.current, { format: 'jpeg', pixelRatio: 1, quality: 0.85 }),
|
|
520
|
+
getVisibleTexts: () => visibleStageTexts(stageRef.current?.getStage() ?? null),
|
|
521
|
+
rasterizeElement: async (elementId) => {
|
|
522
|
+
await ensureFontsReady();
|
|
523
|
+
return rasterizeStageElement(stageRef.current?.getStage() ?? null, elementId);
|
|
524
|
+
},
|
|
525
|
+
deselect: () => setSelectedElement(null),
|
|
526
|
+
selectLayers: (change) => applyLayerSelection(store, change),
|
|
527
|
+
beginMarquee,
|
|
528
|
+
dropMedia: (evt, media) => {
|
|
529
|
+
const stage = stageRef.current?.getStage();
|
|
530
|
+
if (!stage)
|
|
531
|
+
return false;
|
|
532
|
+
const drop = locateDrop(stage, evt, stageWidth / referenceWidth);
|
|
533
|
+
if (!drop)
|
|
534
|
+
return false;
|
|
535
|
+
if (drop.frameId && actions.setFrameImage) {
|
|
536
|
+
// The file argument is unused there; the durable URL is the image.
|
|
537
|
+
actions.setFrameImage(drop.frameId, new File([], media.name), media.url);
|
|
538
|
+
setSelectedElement(drop.frameId);
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
if (!actions.addUserImageFromUrl)
|
|
542
|
+
return false;
|
|
543
|
+
actions.addUserImageFromUrl(media.url, media.name, {
|
|
544
|
+
center: drop.point,
|
|
545
|
+
...(media.attribution && { attribution: media.attribution }),
|
|
546
|
+
});
|
|
547
|
+
return true;
|
|
548
|
+
},
|
|
549
|
+
insertBlock: async (make, at) => {
|
|
550
|
+
if (!actions.insertBlock)
|
|
551
|
+
return false;
|
|
552
|
+
// The drop point before the await: the pointer is only known now.
|
|
553
|
+
const stage = stageRef.current?.getStage();
|
|
554
|
+
const drop = at && stage ? locateDrop(stage, at, stageWidth / referenceWidth) : null;
|
|
555
|
+
const { backgroundMode, backgroundColor, brandScheme } = liveStateRef.current
|
|
556
|
+
.state;
|
|
557
|
+
const block = await make({ backgroundMode, backgroundColor, brandScheme });
|
|
558
|
+
if (!block)
|
|
559
|
+
return false;
|
|
560
|
+
const canvas = { width: referenceWidth, height: referenceHeight };
|
|
561
|
+
// Clicked in again and again, each lands a step down-right, not on the last.
|
|
562
|
+
const step = drop ? 0 : (clickedBlocksRef.current++ % 5) * BLOCK_CASCADE;
|
|
563
|
+
const placed = placeBlock(block, drop?.point ?? { x: canvas.width / 2 + step, y: canvas.height / 2 + step }, canvas);
|
|
564
|
+
const { insertBlock } = liveStateRef.current.actions;
|
|
565
|
+
if (!insertBlock)
|
|
566
|
+
return false;
|
|
567
|
+
insertBlock(placed);
|
|
568
|
+
store.getState().setSelectedLayers(blockElementIds(placed));
|
|
569
|
+
return true;
|
|
570
|
+
},
|
|
571
|
+
dropElement: (evt, payload) => {
|
|
572
|
+
const stage = stageRef.current?.getStage();
|
|
573
|
+
if (!stage)
|
|
574
|
+
return false;
|
|
575
|
+
const drop = locateDrop(stage, evt, stageWidth / referenceWidth);
|
|
576
|
+
if (!drop)
|
|
577
|
+
return false;
|
|
578
|
+
const placement = { center: drop.point };
|
|
579
|
+
switch (payload.kind) {
|
|
580
|
+
case 'asset':
|
|
581
|
+
if (!actions.addAsset)
|
|
582
|
+
return false;
|
|
583
|
+
actions.addAsset(payload.assetId, placement);
|
|
584
|
+
return true;
|
|
585
|
+
case 'sticker':
|
|
586
|
+
if (!actions.addStickerAsset)
|
|
587
|
+
return false;
|
|
588
|
+
actions.addStickerAsset(payload.ref, placement);
|
|
589
|
+
return true;
|
|
590
|
+
case 'shape':
|
|
591
|
+
if (!actions.addShape)
|
|
592
|
+
return false;
|
|
593
|
+
actions.addShape(payload.shapeType, payload.color, placement);
|
|
594
|
+
return true;
|
|
595
|
+
case 'illustration':
|
|
596
|
+
if (!actions.addIllustration)
|
|
597
|
+
return false;
|
|
598
|
+
actions.addIllustration(payload.id, placement);
|
|
599
|
+
return true;
|
|
600
|
+
case 'chart':
|
|
601
|
+
if (!actions.addChart)
|
|
602
|
+
return false;
|
|
603
|
+
actions.addChart(payload.chartType, placement);
|
|
604
|
+
return true;
|
|
605
|
+
case 'frame':
|
|
606
|
+
if (!actions.addFrame)
|
|
607
|
+
return false;
|
|
608
|
+
actions.addFrame(payload.clipType, placement);
|
|
609
|
+
return true;
|
|
610
|
+
case 'icon': {
|
|
611
|
+
if (!actions.toggleIcon)
|
|
612
|
+
return false;
|
|
613
|
+
// This page's icons; the sidebar's limit counts the active page's.
|
|
614
|
+
const { selectedIcons, iconStates } = liveStateRef.current.state;
|
|
615
|
+
const onPage = selectedCatalogIconIds(selectedIcons, iconStates);
|
|
616
|
+
if (onPage.includes(payload.iconId) || onPage.length >= MAX_ICON_SELECTIONS)
|
|
617
|
+
return false;
|
|
618
|
+
actions.toggleIcon(payload.iconId, true, placement);
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
// Composed asynchronously: the page wrapper hands it to `insertBlock`.
|
|
622
|
+
case 'block':
|
|
623
|
+
return false;
|
|
624
|
+
// A host kind's tile, added through its registered action.
|
|
625
|
+
default:
|
|
626
|
+
return addHostElement(payload, actions, placement);
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
undo,
|
|
630
|
+
redo,
|
|
631
|
+
historyStamps: () => {
|
|
632
|
+
flushPendingSaves();
|
|
633
|
+
const { history, historyIndex } = store.getState();
|
|
634
|
+
return {
|
|
635
|
+
undo: historyIndex > 0 ? (history[historyIndex]?.timestamp ?? null) : null,
|
|
636
|
+
redo: history[historyIndex + 1]?.timestamp ?? null,
|
|
637
|
+
};
|
|
638
|
+
},
|
|
639
|
+
handleMoveLayer: (dir) => commands.moveLayer(dir === 'up' ? 'forward' : 'backward'),
|
|
640
|
+
handleDuplicate: commands.duplicate,
|
|
641
|
+
handleDeleteElement: commands.remove,
|
|
642
|
+
runCommand: commands.run,
|
|
643
|
+
rotateElement: commands.rotateElement,
|
|
644
|
+
getGeometry: commands.geometry,
|
|
645
|
+
setPosition: commands.setPosition,
|
|
646
|
+
setSize: commands.setSize,
|
|
647
|
+
getMenuSnapshot: () => {
|
|
648
|
+
const { selectedLayerIds, selectedElement, croppingElement } = store.getState();
|
|
649
|
+
const committed = committedStateRef.current;
|
|
650
|
+
const layer = stageRef.current?.getStage()?.getLayers()[0];
|
|
651
|
+
return {
|
|
652
|
+
selection: selectedLayerIds,
|
|
653
|
+
module: floatingModuleFor(selectedElement, config, committed, commandInputsRef.current.layout),
|
|
654
|
+
caps: commands.capabilities(),
|
|
655
|
+
canSelectAll: layer ? selectableItemIds(layer).length > 0 : false,
|
|
656
|
+
isCropping: croppingElement !== null,
|
|
657
|
+
background: config.background?.(committed, actions) ?? null,
|
|
658
|
+
};
|
|
659
|
+
},
|
|
660
|
+
getSelectionBox: () => {
|
|
661
|
+
const ids = store.getState().selectedLayerIds;
|
|
662
|
+
const stage = stageRef.current?.getStage();
|
|
663
|
+
if (ids.length === 0 || !stage)
|
|
664
|
+
return null;
|
|
665
|
+
const rects = ids.map((id) => itemBodyRect(stage, id)).filter((r) => r !== null);
|
|
666
|
+
if (rects.length === 0)
|
|
667
|
+
return null;
|
|
668
|
+
// Der Drehgriff zählt mit: die Pille weicht ihm aus, statt ihn zu verdecken.
|
|
669
|
+
const rotaters = rotaterRects(stage);
|
|
670
|
+
rects.push(...rotaters);
|
|
671
|
+
const left = Math.min(...rects.map((r) => r.x));
|
|
672
|
+
const top = Math.min(...rects.map((r) => r.y));
|
|
673
|
+
const rect = {
|
|
674
|
+
x: left,
|
|
675
|
+
y: top,
|
|
676
|
+
width: Math.max(...rects.map((r) => r.x + r.width)) - left,
|
|
677
|
+
height: Math.max(...rects.map((r) => r.y + r.height)) - top,
|
|
678
|
+
};
|
|
679
|
+
const container = stage.container().getBoundingClientRect();
|
|
680
|
+
const cssScale = stageCssScale(stage, container);
|
|
681
|
+
return {
|
|
682
|
+
left: container.left + rect.x * cssScale,
|
|
683
|
+
top: container.top + rect.y * cssScale,
|
|
684
|
+
width: rect.width * cssScale,
|
|
685
|
+
height: rect.height * cssScale,
|
|
686
|
+
visible: visibleArea(stage.container()),
|
|
687
|
+
rotaters: rotaters.map((r) => ({
|
|
688
|
+
left: container.left + r.x * cssScale,
|
|
689
|
+
top: container.top + r.y * cssScale,
|
|
690
|
+
right: container.left + (r.x + r.width) * cssScale,
|
|
691
|
+
bottom: container.top + (r.y + r.height) * cssScale,
|
|
692
|
+
})),
|
|
693
|
+
};
|
|
694
|
+
},
|
|
695
|
+
subscribeManipulation: (listener) => {
|
|
696
|
+
const stage = stageRef.current?.getStage();
|
|
697
|
+
if (!stage)
|
|
698
|
+
return () => { };
|
|
699
|
+
const start = () => listener(true);
|
|
700
|
+
const end = () => listener(false);
|
|
701
|
+
// `transformstart`/`transformend` fire without bubbling (Konva's
|
|
702
|
+
// `_fire` on the Transformer and its node), so the stage never hears
|
|
703
|
+
// them. The press on an anchor does bubble: that is the start, and
|
|
704
|
+
// the end is taken from the Transformer that owns the anchor.
|
|
705
|
+
const onTransformerEnd = (e) => {
|
|
706
|
+
e.currentTarget.off('transformend', onTransformerEnd);
|
|
707
|
+
end();
|
|
708
|
+
};
|
|
709
|
+
const onPress = (e) => {
|
|
710
|
+
const transformer = e.target.getParent();
|
|
711
|
+
if (!(transformer instanceof Konva.Transformer))
|
|
712
|
+
return;
|
|
713
|
+
start();
|
|
714
|
+
transformer.on('transformend', onTransformerEnd);
|
|
715
|
+
};
|
|
716
|
+
stage.on('dragstart', start);
|
|
717
|
+
stage.on('dragend', end);
|
|
718
|
+
stage.on('mousedown touchstart', onPress);
|
|
719
|
+
return () => {
|
|
720
|
+
stage.off('dragstart', start);
|
|
721
|
+
stage.off('dragend', end);
|
|
722
|
+
stage.off('mousedown touchstart', onPress);
|
|
723
|
+
stage.find('Transformer').forEach((t) => t.off('transformend', onTransformerEnd));
|
|
724
|
+
};
|
|
725
|
+
},
|
|
726
|
+
handleColorSelect: (color) => bridgeRef.current?.handleColorSelect(color),
|
|
727
|
+
handleOpacityChange: (id, op, type) => bridgeRef.current?.handleOpacityChange(id, op, type),
|
|
728
|
+
handleFontSizeChange: elementHandlers.handleFontSizeChange,
|
|
729
|
+
handleFontRoleChange: elementHandlers.handleFontRoleChange,
|
|
730
|
+
handleTextFormatChange: elementHandlers.handleTextFormatChange,
|
|
731
|
+
handleShadowChange: (id, patch, type) => bridgeRef.current?.handleShadowChange(id, patch, type),
|
|
732
|
+
handleOutlineChange: (id, patch) => bridgeRef.current?.handleOutlineChange(id, patch),
|
|
733
|
+
handleBlurChange: (id, blur) => bridgeRef.current?.handleBlurChange(id, blur),
|
|
734
|
+
handleImageLookChange: (id, look) => bridgeRef.current?.handleImageLookChange(id, look),
|
|
735
|
+
handleCropImage: () => bridgeRef.current?.handleCropImage(),
|
|
736
|
+
handleCancelCrop: cropSession.cancel,
|
|
737
|
+
handleFinishCrop: cropSession.finish,
|
|
738
|
+
handleCropAspect: (id) => bridgeRef.current?.handleCropAspect(id),
|
|
739
|
+
handleCropRotation: (deg) => bridgeRef.current?.handleCropRotation(deg),
|
|
740
|
+
handleSmartCrop: () => bridgeRef.current?.handleSmartCrop(),
|
|
741
|
+
handleExpandImage: () => bridgeRef.current?.handleExpandImage(),
|
|
742
|
+
handleGradientSelect: (gradient) => bridgeRef.current?.handleGradientSelect(gradient),
|
|
743
|
+
handleTextAlignChange: (id, align) => bridgeRef.current?.handleTextAlignChange(id, align),
|
|
744
|
+
}), [
|
|
745
|
+
undo,
|
|
746
|
+
redo,
|
|
747
|
+
flushPendingSaves,
|
|
748
|
+
elementHandlers.handleFontSizeChange,
|
|
749
|
+
elementHandlers.handleFontRoleChange,
|
|
750
|
+
elementHandlers.handleTextFormatChange,
|
|
751
|
+
setSelectedElement,
|
|
752
|
+
beginMarquee,
|
|
753
|
+
pendingImages,
|
|
754
|
+
store,
|
|
755
|
+
actions,
|
|
756
|
+
stageWidth,
|
|
757
|
+
referenceWidth,
|
|
758
|
+
referenceHeight,
|
|
759
|
+
commands,
|
|
760
|
+
config,
|
|
761
|
+
cropSession,
|
|
762
|
+
]);
|
|
763
|
+
return (_jsx(PendingImagesContext.Provider, { value: pendingImages, children: _jsxs(PreviewRenderContext.Provider, { value: preview ? (previewCaptureRatio ?? 0) : null, children: [_jsxs(CanvasStage, { ref: stageRef, width: stageWidth, height: stageHeight, logicalWidth: referenceWidth, logicalHeight: referenceHeight, responsive: true, maxContainerWidth: maxWidth, onStageClick: handleStageClick, listening: interactive, ariaLabel: stageLabel, className: `${config.id}-stage`, overlay: interactive ? (_jsxs(_Fragment, { children: [_jsx(CropGhostOverlay, { getStage: getStage }), _jsx(SlotBudgetStatus, { state: state, canvasWidth: referenceWidth, canvasHeight: referenceHeight })] })) : null, children: [_jsx(CanvasRenderLayer, { sortedRenderList: sortedRenderList, canRotateSelection: canRotateSelection, config: config, state: drawnState, layout: layout, handlers: elementHandlers, getSnapTargets: getSnapTargets, registerGeometry: updateElementPosition, handleSnapChange: handleSnapChange, setSnapLines: setSnapLines, stageWidth: config.canvas.width, stageHeight: config.canvas.height, isFontAvailable: isFontAvailable, remoteSelections: remoteSelections, ...(pageNumber === undefined ? {} : { pageNumber }) }), _jsx(PrintGuides, { format: format }), _jsx(SnapGuidelines, {})] }), _jsx(ToolbarStateBridge, { bridgeRef: bridgeRef, config: config, state: state, layout: layout, actions: actions, sortedRenderList: sortedRenderList, setState: setStateWrapper, debouncedSaveToHistory: debouncedSaveToHistory, canUndo: canUndo, canRedo: canRedo, readOnly: !interactive, saveToHistory: saveToHistory, runHistoryBatch: runHistoryBatch, cropCancelCount: cropSession.cancelCount, getStage: getStage, onToolbarStateChange: onToolbarStateChange })] }) }));
|
|
764
|
+
}
|
|
765
|
+
GenericCanvasWithRef.displayName = 'GenericCanvasInner';
|
|
766
|
+
const MemoizedGenericCanvas = memo(GenericCanvasWithRef);
|
|
767
|
+
/**
|
|
768
|
+
* GenericCanvas — each instance gets its own scoped Zustand store via CanvasStoreProvider.
|
|
769
|
+
* The provider's context value (store reference) is stable, so wrapping adds zero re-render cost.
|
|
770
|
+
* Outer component is NOT memo'd — the inner MemoizedGenericCanvas handles prop comparison.
|
|
771
|
+
*/
|
|
772
|
+
function CanvasYjsBindingMount({ pageYMap, isSynced, }) {
|
|
773
|
+
useYjsCanvasBinding({ parent: pageYMap, isSynced });
|
|
774
|
+
return null;
|
|
775
|
+
}
|
|
776
|
+
function GenericCanvasWithProvider(props) {
|
|
777
|
+
// The page draws its defaults (the marker of a text without a marker style, the backdrop) in
|
|
778
|
+
// the brand of ITS document, wherever it is mounted: in the editor shell, embedded, or in an
|
|
779
|
+
// offscreen root for a preview or an export, where no shell provides one. A config that names
|
|
780
|
+
// none leaves the context as it is.
|
|
781
|
+
const outerBrand = useContext(DocumentBrandContext);
|
|
782
|
+
const brand = props.config.brand ?? outerBrand;
|
|
783
|
+
return (_jsx(DocumentBrandContext.Provider, { value: brand, children: _jsxs(CanvasStoreProvider, { initialFormatId: props.formatId, children: [props.pageBinding ? (_jsx(CanvasYjsBindingMount, { pageYMap: props.pageBinding.pageYMap, isSynced: props.pageBinding.isSynced })) : null, _jsx(MemoizedGenericCanvas, { ...props })] }) }));
|
|
784
|
+
}
|
|
785
|
+
GenericCanvasWithProvider.displayName = 'GenericCanvas';
|
|
786
|
+
export const GenericCanvas = GenericCanvasWithProvider;
|
|
787
|
+
export default GenericCanvas;
|