@ggraphic/editor 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +16 -3
- package/THIRD_PARTY_NOTICES +34 -1
- package/dist/CanvasEditorProvider.d.ts +8 -8
- package/dist/ai/applyOperation.d.ts +6 -6
- package/dist/ai/applyOperation.js +4 -4
- package/dist/ai/describeCanvasElements.d.ts +2 -2
- package/dist/ai/describeCanvasElements.js +4 -4
- package/dist/ai/illustrationCapability.d.ts +1 -1
- package/dist/ai/illustrationCapability.js +1 -1
- package/dist/blocks/liftedBlock.d.ts +5 -5
- package/dist/blocks/liftedBlock.js +2 -2
- package/dist/collab/useSelectionAwareness.js +3 -3
- package/dist/collab/useYjsPageStateSync.js +1 -1
- package/dist/collab/useYjsPages.d.ts +2 -2
- package/dist/collab/useYjsPages.js +4 -4
- package/dist/collab/yjsBinding.js +1 -1
- package/dist/common/Lightbox.js +2 -2
- package/dist/components/AddPageButton.js +2 -2
- package/dist/components/CanvasContextMenu/CanvasActionSheet.d.ts +1 -1
- package/dist/components/CanvasContextMenu/CanvasActionSheet.js +6 -5
- package/dist/components/CanvasContextMenu/CanvasContextMenu.d.ts +2 -2
- package/dist/components/CanvasContextMenu/CanvasContextMenu.js +3 -2
- package/dist/components/CanvasContextMenu/canvasMenuModel.d.ts +1 -1
- package/dist/components/CanvasContextMenu/canvasMenuModel.js +2 -2
- package/dist/components/CanvasEditor/CanvasEditorShell.d.ts +2 -2
- package/dist/components/CanvasEditor/CanvasEditorShell.js +102 -76
- package/dist/components/CanvasEditor/PageWrapper.d.ts +1 -1
- package/dist/components/CanvasEditor/PageWrapper.js +16 -16
- package/dist/components/CanvasEditor/blockInsertContext.d.ts +2 -2
- package/dist/components/CanvasEditor/editorShell.d.ts +5 -5
- package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.d.ts +1 -1
- package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.js +3 -3
- package/dist/components/CanvasEditor/hooks/useLoadedConfigs.d.ts +1 -1
- package/dist/components/CanvasEditor/hooks/usePageRefs.d.ts +1 -1
- package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.d.ts +1 -1
- package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.js +2 -2
- package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.d.ts +1 -1
- package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.js +5 -5
- package/dist/components/CanvasEditor/hooks/useToolbarHandlers.d.ts +9 -9
- package/dist/components/CanvasEditor/hooks/useToolbarHandlers.js +1 -1
- package/dist/components/CanvasEditor/hooks/useWorkAreaDeselect.js +1 -1
- package/dist/components/CanvasEditor/layersTab.js +1 -1
- package/dist/components/CanvasEditor/mobileSelectionArea.d.ts +1 -1
- package/dist/components/CanvasEditor/types.d.ts +15 -6
- package/dist/components/CanvasEditorSkeleton.js +3 -3
- package/dist/components/CanvasMetaBar.js +1 -1
- package/dist/components/CanvasRenderLayer.d.ts +3 -3
- package/dist/components/CanvasRenderLayer.js +5 -5
- package/dist/components/CanvasTextOverlay.js +15 -8
- package/dist/components/ConfigCanvas.js +1 -1
- package/dist/components/CropGhostOverlay.js +1 -1
- package/dist/components/CustomColorSwatch.js +3 -3
- package/dist/components/GenericCanvas.d.ts +10 -10
- package/dist/components/GenericCanvas.js +53 -33
- package/dist/components/GenericCanvasElement.d.ts +2 -2
- package/dist/components/GenericCanvasElement.js +7 -7
- package/dist/components/MultiSelectionTransformer.js +4 -4
- package/dist/components/PagePreview.js +2 -2
- package/dist/components/PageThumbnailStrip.d.ts +1 -1
- package/dist/components/PageThumbnailStrip.js +2 -2
- package/dist/components/PageToolbar.js +1 -1
- package/dist/components/RichTextField.js +5 -4
- package/dist/components/SelectionPill.d.ts +1 -1
- package/dist/components/SelectionPill.js +7 -6
- package/dist/components/SlideNotesPanel.js +1 -1
- package/dist/components/StandaloneCanvas.d.ts +3 -3
- package/dist/components/StandaloneCanvas.js +3 -3
- package/dist/components/TextFormatButtons.js +11 -6
- package/dist/components/TextFormatControls.js +1 -1
- package/dist/components/Toolbar.js +5 -5
- package/dist/components/ToolbarStateBridge.d.ts +4 -4
- package/dist/components/ToolbarStateBridge.js +4 -4
- package/dist/components/TopBar/AutoSaveIndicator.js +3 -3
- package/dist/components/TopBar/ContextControls.d.ts +8 -8
- package/dist/components/TopBar/ContextControls.js +18 -18
- package/dist/components/TopBar/ContextToolbar.d.ts +1 -1
- package/dist/components/TopBar/ContextToolbar.js +2 -2
- package/dist/components/TopBar/CropModeControls.d.ts +1 -1
- package/dist/components/TopBar/CropModeControls.js +4 -4
- package/dist/components/TopBar/DownloadSection.d.ts +3 -3
- package/dist/components/TopBar/DownloadSection.js +19 -19
- package/dist/components/TopBar/MobileSelectionBar.d.ts +1 -1
- package/dist/components/TopBar/MobileSelectionBar.js +7 -7
- package/dist/components/TopBar/MobileSelectionControls.d.ts +1 -1
- package/dist/components/TopBar/MobileSelectionControls.js +6 -6
- package/dist/components/TopBar/MultiSelectionToolbar.d.ts +1 -1
- package/dist/components/TopBar/MultiSelectionToolbar.js +4 -4
- package/dist/components/TopBar/ShareDropdown.js +11 -11
- package/dist/components/TopBar/barTiles.js +1 -1
- package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.d.ts +1 -1
- package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.js +4 -4
- package/dist/components/TopBar/modules/FloatingBackgroundControls.d.ts +2 -2
- package/dist/components/TopBar/modules/FloatingBackgroundControls.js +9 -9
- package/dist/components/TopBar/modules/FloatingColorPicker.d.ts +1 -1
- package/dist/components/TopBar/modules/FloatingColorPicker.js +6 -6
- package/dist/components/TopBar/modules/FloatingFontRoleControl.js +5 -5
- package/dist/components/TopBar/modules/FloatingFontSizeControl.js +2 -2
- package/dist/components/TopBar/modules/FloatingHistoryControls.js +1 -1
- package/dist/components/TopBar/modules/FloatingImageLookControl.d.ts +1 -1
- package/dist/components/TopBar/modules/FloatingImageLookControl.js +2 -2
- package/dist/components/TopBar/modules/FloatingLayerControls.js +1 -1
- package/dist/components/TopBar/modules/FloatingOpacityControl.js +3 -3
- package/dist/components/TopBar/modules/FloatingPositionControl.d.ts +1 -1
- package/dist/components/TopBar/modules/FloatingPositionControl.js +5 -5
- package/dist/components/TopBar/modules/FloatingTextAlignControl.d.ts +1 -1
- package/dist/components/TopBar/modules/FloatingTextAlignControl.js +3 -3
- package/dist/components/kindRenderers.d.ts +6 -6
- package/dist/components/kindRenderers.js +9 -9
- package/dist/components/markerMark.js +1 -1
- package/dist/composer/cardFollowsText.d.ts +2 -2
- package/dist/composer/cardFollowsText.js +1 -1
- package/dist/composer/steckbriefLayout.d.ts +1 -1
- package/dist/composer/steckbriefLayout.js +1 -1
- package/dist/configs/buildCanvasText.d.ts +5 -0
- package/dist/configs/buildCanvasText.js +58 -0
- package/dist/configs/buildSharepicText.d.ts +2 -5
- package/dist/configs/buildSharepicText.js +2 -57
- package/dist/configs/configLoader.d.ts +1 -1
- package/dist/configs/configLoader.js +2 -2
- package/dist/configs/factory/actionFactories.d.ts +11 -11
- package/dist/configs/factory/actionFactories.js +13 -13
- package/dist/configs/factory/baseTypes.d.ts +10 -10
- package/dist/configs/factory/carryInstanceState.d.ts +8 -8
- package/dist/configs/factory/carryInstanceState.js +2 -2
- package/dist/configs/factory/createTextElement.d.ts +1 -1
- package/dist/configs/factory/createTextElement.js +1 -1
- package/dist/configs/factory/defineSection.d.ts +1 -1
- package/dist/configs/factory/layoutAccessors.d.ts +1 -1
- package/dist/configs/featureInjector.d.ts +2 -2
- package/dist/configs/featureInjector.js +2 -2
- package/dist/configs/placeholders.js +1 -1
- package/dist/configs/shareSection.d.ts +3 -3
- package/dist/configs/shareSection.js +12 -8
- package/dist/configs/types.d.ts +5 -5
- package/dist/embed/EmbeddedEditor.d.ts +4 -0
- package/dist/embed/EmbeddedEditor.js +68 -0
- package/dist/embed/GgraphicEditor.d.ts +2 -0
- package/dist/embed/GgraphicEditor.js +16 -0
- package/dist/embed/index.d.ts +6 -0
- package/dist/embed/index.js +5 -0
- package/dist/embed/loadTemplatePack.d.ts +8 -0
- package/dist/embed/loadTemplatePack.js +9 -0
- package/dist/embed/types.d.ts +44 -0
- package/dist/embed/types.js +1 -0
- package/dist/entries/ai.d.ts +5 -0
- package/dist/entries/ai.js +5 -0
- package/dist/entries/brand.d.ts +4 -0
- package/dist/entries/brand.js +5 -0
- package/dist/entries/canvas.d.ts +5 -0
- package/dist/entries/canvas.js +6 -0
- package/dist/entries/collab.d.ts +6 -0
- package/dist/entries/collab.js +7 -0
- package/dist/entries/config.d.ts +12 -0
- package/dist/entries/config.js +9 -0
- package/dist/entries/elements.d.ts +21 -0
- package/dist/entries/elements.js +17 -0
- package/dist/entries/embed.d.ts +2 -0
- package/dist/entries/embed.js +7 -0
- package/dist/entries/export.d.ts +8 -0
- package/dist/entries/export.js +7 -0
- package/dist/entries/host.d.ts +30 -0
- package/dist/entries/host.js +10 -0
- package/dist/entries/hostReact.d.ts +9 -0
- package/dist/entries/hostReact.js +11 -0
- package/dist/entries/i18n.d.ts +2 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/illustrations/gophers.d.ts +2 -0
- package/dist/entries/illustrations/gophers.js +3 -0
- package/dist/entries/illustrations/humaaans.d.ts +2 -0
- package/dist/entries/illustrations/humaaans.js +3 -0
- package/dist/entries/illustrations/illlustrations.d.ts +2 -0
- package/dist/entries/illustrations/illlustrations.js +3 -0
- package/dist/entries/illustrations/kawaii.d.ts +2 -0
- package/dist/entries/illustrations/kawaii.js +3 -0
- package/dist/entries/illustrations/opendoodles.d.ts +2 -0
- package/dist/entries/illustrations/opendoodles.js +3 -0
- package/dist/entries/illustrations/openpeeps.d.ts +2 -0
- package/dist/entries/illustrations/openpeeps.js +3 -0
- package/dist/entries/illustrations/transhumans.d.ts +2 -0
- package/dist/entries/illustrations/transhumans.js +3 -0
- package/dist/entries/kinds.d.ts +101 -0
- package/dist/entries/kinds.js +100 -0
- package/dist/entries/page.d.ts +13 -0
- package/dist/entries/page.js +13 -0
- package/dist/entries/services.d.ts +6 -0
- package/dist/entries/services.js +4 -0
- package/dist/entries/shell.d.ts +13 -0
- package/dist/entries/shell.js +13 -0
- package/dist/entries/sidebar.d.ts +15 -0
- package/dist/entries/sidebar.js +13 -0
- package/dist/entries/store.d.ts +3 -0
- package/dist/entries/store.js +4 -0
- package/dist/entries/templates.d.ts +4 -0
- package/dist/entries/templates.js +5 -0
- package/dist/entries/text.d.ts +6 -0
- package/dist/entries/text.js +7 -0
- package/dist/export/pptx/buildPptxModel.d.ts +1 -1
- package/dist/export/pptx/buildPptxModel.js +9 -9
- package/dist/export/pptx/exportPptxDeck.d.ts +2 -2
- package/dist/export/pptx/exportPptxDeck.js +2 -2
- package/dist/export/pptx/textModel.d.ts +1 -1
- package/dist/export/pptx/textModel.js +1 -1
- package/dist/export/pptx/writePptx.d.ts +5 -2
- package/dist/export/pptx/writePptx.js +6 -3
- package/dist/export/pptx/writeText.d.ts +60 -6
- package/dist/export/pptx/writeText.js +2 -2
- package/dist/export/printExport.d.ts +1 -1
- package/dist/export/printExport.js +2 -2
- package/dist/export/slidesPdf.js +1 -1
- package/dist/formats/index.d.ts +37 -15
- package/dist/formats/index.js +51 -95
- package/dist/formats/legacyCatalog.d.ts +21 -0
- package/dist/formats/legacyCatalog.js +76 -0
- package/dist/hooks/editorBox.d.ts +20 -0
- package/dist/hooks/editorBox.js +65 -0
- package/dist/hooks/index.d.ts +13 -13
- package/dist/hooks/index.js +9 -9
- package/dist/hooks/stageFit.d.ts +24 -0
- package/dist/hooks/stageFit.js +76 -0
- package/dist/hooks/useAiImageGeneration.js +2 -2
- package/dist/hooks/useCanvasAutoSave.js +1 -1
- package/dist/hooks/useCanvasElementHandlers.d.ts +6 -6
- package/dist/hooks/useCanvasInteractions.d.ts +1 -1
- package/dist/hooks/useCanvasInteractions.js +1 -1
- package/dist/hooks/useCanvasKeyboardHandlers.d.ts +1 -1
- package/dist/hooks/useCanvasKeyboardHandlers.js +4 -4
- package/dist/hooks/useCanvasUndoRedo.js +3 -3
- package/dist/hooks/useContextPress.js +3 -3
- package/dist/hooks/useCropSession.js +1 -1
- package/dist/hooks/useDeckAutoSave.js +3 -3
- package/dist/hooks/useDeepSelect.js +2 -2
- package/dist/hooks/useFloatingModuleHandlers.d.ts +3 -3
- package/dist/hooks/useFloatingModuleHandlers.js +2 -2
- package/dist/hooks/useFloatingModuleState.d.ts +3 -3
- package/dist/hooks/useFloatingModuleState.js +1 -1
- package/dist/hooks/useFontGeneration.d.ts +1 -9
- package/dist/hooks/useFontGeneration.js +3 -48
- package/dist/hooks/useFontLoader.d.ts +1 -9
- package/dist/hooks/useFontLoader.js +2 -16
- package/dist/hooks/useIconSetsFor.js +1 -1
- package/dist/hooks/useIsCanvasMobile.d.ts +5 -1
- package/dist/hooks/useIsCanvasMobile.js +10 -2
- package/dist/hooks/useMarqueeSelection.js +2 -2
- package/dist/hooks/useMultiPageExport.d.ts +1 -1
- package/dist/hooks/useMultiPageExport.js +3 -3
- package/dist/hooks/usePageManager.d.ts +1 -1
- package/dist/hooks/usePageManager.js +4 -4
- package/dist/hooks/useSelectionAnnouncement.js +2 -2
- package/dist/hooks/useTrackUnsplashDownload.d.ts +1 -1
- package/dist/hooks/useTrackUnsplashDownload.js +1 -1
- package/dist/hostServices.d.ts +53 -31
- package/dist/hostServices.js +6 -4
- package/dist/i18n/catalogue.d.ts +21 -0
- package/dist/i18n/catalogue.js +58 -0
- package/dist/i18n/de.d.ts +26 -15
- package/dist/i18n/de.js +28 -32
- package/dist/i18n/en.js +27 -32
- package/dist/i18n/messages.d.ts +1 -13
- package/dist/i18n/messages.js +2 -52
- package/dist/layouts/CanvasEditorLayout.d.ts +1 -1
- package/dist/layouts/CanvasEditorLayout.js +11 -7
- package/dist/page/actions.d.ts +66 -0
- package/dist/page/actions.js +353 -0
- package/dist/page/config.d.ts +15 -0
- package/dist/page/config.js +128 -0
- package/dist/page/fitting.d.ts +6 -0
- package/dist/page/fitting.js +26 -0
- package/dist/page/hug.d.ts +10 -0
- package/dist/page/hug.js +18 -0
- package/dist/page/instantiate.d.ts +8 -0
- package/dist/page/instantiate.js +30 -0
- package/dist/page/logoSize.d.ts +8 -0
- package/dist/page/logoSize.js +29 -0
- package/dist/page/pageState.d.ts +41 -0
- package/dist/page/pageState.js +59 -0
- package/dist/page/seeds.d.ts +14 -0
- package/dist/page/seeds.js +40 -0
- package/dist/page/slotBudgets.d.ts +22 -0
- package/dist/page/slotBudgets.js +18 -0
- package/dist/page/templatePack.d.ts +31 -0
- package/dist/page/templatePack.js +55 -0
- package/dist/page/typography.d.ts +11 -0
- package/dist/page/typography.js +13 -0
- package/dist/primitives/AssetPrimitive.d.ts +2 -2
- package/dist/primitives/AssetPrimitive.js +9 -9
- package/dist/primitives/CanvasIcons.js +1 -1
- package/dist/primitives/CanvasImage.d.ts +4 -4
- package/dist/primitives/CanvasImage.js +9 -9
- package/dist/primitives/CanvasRichText.js +13 -13
- package/dist/primitives/CanvasStage.d.ts +7 -1
- package/dist/primitives/CanvasStage.js +29 -16
- package/dist/primitives/CanvasText.d.ts +6 -6
- package/dist/primitives/CanvasText.js +11 -11
- package/dist/primitives/ChartPrimitive.d.ts +2 -2
- package/dist/primitives/ChartPrimitive.js +6 -6
- package/dist/primitives/CircleBadge.d.ts +1 -1
- package/dist/primitives/CircleBadge.js +9 -9
- package/dist/primitives/FramePrimitive.d.ts +2 -2
- package/dist/primitives/FramePrimitive.js +5 -5
- package/dist/primitives/IllustrationPrimitive.d.ts +2 -2
- package/dist/primitives/IllustrationPrimitive.js +6 -6
- package/dist/primitives/PillBadge.d.ts +1 -1
- package/dist/primitives/PillBadge.js +9 -9
- package/dist/primitives/ShapePrimitive.d.ts +2 -2
- package/dist/primitives/ShapePrimitive.js +9 -9
- package/dist/primitives/UserImagePrimitive.d.ts +2 -2
- package/dist/primitives/UserImagePrimitive.js +14 -14
- package/dist/primitives/index.d.ts +12 -12
- package/dist/primitives/index.js +7 -7
- package/dist/sidebar/SidebarPanel.d.ts +1 -1
- package/dist/sidebar/SidebarPanel.js +7 -7
- package/dist/sidebar/SidebarTabBar.d.ts +1 -1
- package/dist/sidebar/SidebarTabBar.js +5 -5
- package/dist/sidebar/SubsectionTabBar.js +5 -5
- package/dist/sidebar/UserUploadsProvider.js +2 -2
- package/dist/sidebar/components/AltTextField.js +3 -3
- package/dist/sidebar/components/SidebarHint.js +2 -2
- package/dist/sidebar/components/TextFieldPrimitives.d.ts +1 -1
- package/dist/sidebar/components/TextFieldPrimitives.js +1 -1
- package/dist/sidebar/coreSidebar.d.ts +23 -0
- package/dist/sidebar/coreSidebar.js +12 -0
- package/dist/sidebar/coreSidebarParts.d.ts +3 -0
- package/dist/sidebar/coreSidebarParts.js +20 -0
- package/dist/sidebar/sections/AssetGallery.d.ts +33 -0
- package/dist/sidebar/sections/AssetGallery.js +58 -0
- package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
- package/dist/sidebar/sections/ChartSettingsSection.js +6 -6
- package/dist/sidebar/sections/ChartsSection.d.ts +9 -0
- package/dist/sidebar/sections/ChartsSection.js +40 -0
- package/dist/sidebar/sections/CombinedTextSection.d.ts +2 -2
- package/dist/sidebar/sections/CombinedTextSection.js +8 -8
- package/dist/sidebar/sections/DiagrammeSection.d.ts +6 -9
- package/dist/sidebar/sections/DiagrammeSection.js +4 -39
- package/dist/sidebar/sections/EffectsSection.d.ts +3 -3
- package/dist/sidebar/sections/EffectsSection.js +5 -5
- package/dist/sidebar/sections/FormenSection.d.ts +6 -28
- package/dist/sidebar/sections/FormenSection.js +4 -439
- package/dist/sidebar/sections/FrameSettingsSection.d.ts +1 -1
- package/dist/sidebar/sections/FrameSettingsSection.js +3 -3
- package/dist/sidebar/sections/FramesSection.d.ts +7 -0
- package/dist/sidebar/sections/FramesSection.js +18 -0
- package/dist/sidebar/sections/GenericShareSection.js +11 -10
- package/dist/sidebar/sections/IconsSection.js +6 -4
- package/dist/sidebar/sections/IllustrationSettings.d.ts +1 -1
- package/dist/sidebar/sections/IllustrationSettings.js +5 -5
- package/dist/sidebar/sections/IllustrationThumb.d.ts +1 -1
- package/dist/sidebar/sections/IllustrationThumb.js +2 -2
- package/dist/sidebar/sections/ImageAdjustSection.d.ts +1 -1
- package/dist/sidebar/sections/ImageAdjustSection.js +8 -8
- package/dist/sidebar/sections/LayersSection.d.ts +2 -2
- package/dist/sidebar/sections/LayersSection.js +3 -3
- package/dist/sidebar/sections/RahmenSection.d.ts +2 -7
- package/dist/sidebar/sections/RahmenSection.js +2 -17
- package/dist/sidebar/sections/ShapesSection.d.ts +28 -0
- package/dist/sidebar/sections/ShapesSection.js +440 -0
- package/dist/sidebar/sections/StudioGallery.d.ts +4 -33
- package/dist/sidebar/sections/StudioGallery.js +4 -57
- package/dist/sidebar/sections/UploadsSection.js +11 -11
- package/dist/sidebar/sections/assets/AssetsSection.d.ts +8 -8
- package/dist/sidebar/sections/assets/AssetsSection.js +2 -2
- package/dist/sidebar/sections/assets/BackgroundCatalog.d.ts +1 -1
- package/dist/sidebar/sections/assets/BackgroundCatalog.js +7 -7
- package/dist/sidebar/sections/assets/CategoryCard.js +1 -1
- package/dist/sidebar/sections/assets/ElementThumb.js +10 -8
- package/dist/sidebar/sections/assets/ElementTile.js +4 -4
- package/dist/sidebar/sections/assets/ElementsPanel.js +12 -12
- package/dist/sidebar/sections/assets/EmojiTonePicker.js +2 -2
- package/dist/sidebar/sections/assets/FotosCatalog.js +5 -5
- package/dist/sidebar/sections/assets/IconifyCatalog.d.ts +1 -1
- package/dist/sidebar/sections/assets/IconifyCatalog.js +4 -4
- package/dist/sidebar/sections/assets/RecentCarousel.js +4 -4
- package/dist/sidebar/sections/assets/StickerCatalog.js +5 -5
- package/dist/sidebar/sections/assets/constants.d.ts +1 -1
- package/dist/sidebar/sections/assets/elementPanelHost.d.ts +2 -2
- package/dist/sidebar/sections/assets/elementSearch.js +1 -1
- package/dist/sidebar/sections/assets/elementTypes.d.ts +6 -6
- package/dist/sidebar/sections/assets/elementTypes.js +1 -1
- package/dist/sidebar/sections/assets/useElementCatalog.d.ts +4 -4
- package/dist/sidebar/sections/assets/useElementCatalog.js +14 -14
- package/dist/sidebar/sections/assets/useRecentElements.js +2 -2
- package/dist/sidebar/sections/assets/useStockPhotos.d.ts +2 -2
- package/dist/sidebar/sections/assets/useStockPhotos.js +3 -3
- package/dist/sidebar/sections/effects/EffectCard.js +2 -2
- package/dist/sidebar/sections/effects/GradientSettings.d.ts +1 -1
- package/dist/sidebar/sections/effects/GradientSettings.js +6 -6
- package/dist/sidebar/sections/effects/OutlineSettings.js +5 -5
- package/dist/sidebar/sections/effects/ShadowSettings.d.ts +1 -1
- package/dist/sidebar/sections/effects/ShadowSettings.js +5 -5
- package/dist/sidebar/sections/effects/effectsFor.d.ts +1 -1
- package/dist/sidebar/sections/effects/effectsFor.js +1 -1
- package/dist/sidebar/sections/index.d.ts +6 -2
- package/dist/sidebar/sections/index.js +5 -3
- package/dist/sidebar/sections/registerBundledIconSets.d.ts +6 -0
- package/dist/sidebar/sections/registerBundledIconSets.js +11 -0
- package/dist/sidebar/sections/tools/AiCreateTool.js +3 -3
- package/dist/sidebar/sections/tools/AiEditTool.js +5 -5
- package/dist/sidebar/sections/tools/AltTextTool.d.ts +1 -1
- package/dist/sidebar/sections/tools/AltTextTool.js +5 -5
- package/dist/sidebar/sections/tools/BlobCreatorTool.js +6 -6
- package/dist/sidebar/sections/tools/GradientTextTool.js +8 -8
- package/dist/sidebar/sections/tools/ImageInputPicker.js +6 -6
- package/dist/sidebar/sections/tools/QRCodeTool.js +5 -5
- package/dist/sidebar/sections/tools/RemoveBackgroundTool.js +4 -4
- package/dist/sidebar/sections/tools/TextPathCreatorTool.js +8 -8
- package/dist/sidebar/sections/tools/ToolPanel.js +2 -2
- package/dist/sidebar/sections/tools/ToolTiles.js +1 -1
- package/dist/sidebar/sections/tools/ToolsSection.d.ts +2 -2
- package/dist/sidebar/sections/tools/ToolsSection.js +17 -17
- package/dist/sidebar/sections/tools/UnsplashLimitNotice.js +2 -2
- package/dist/sidebar/sections/tools/UnsplashTool.d.ts +1 -1
- package/dist/sidebar/sections/tools/UnsplashTool.js +8 -8
- package/dist/sidebar/sections/usePreloadSections.d.ts +16 -0
- package/dist/sidebar/sections/usePreloadSections.js +29 -0
- package/dist/sidebar/tabTypes.d.ts +1 -1
- package/dist/sidebar/types.d.ts +4 -4
- package/dist/sidebar/useImagePlacement.d.ts +1 -1
- package/dist/sidebar/useImagePlacement.js +4 -4
- package/dist/stores/createCanvasEditorStore.d.ts +4 -4
- package/dist/stores/createCanvasEditorStore.js +2 -2
- package/dist/styles/compiled.css +2 -0
- package/dist/styles/editor.css +33 -41
- package/dist/styles/tailwind.css +20 -3
- package/dist/styles/tokens.css +3 -2
- package/dist/templates/templateGeometry.js +26 -1
- package/dist/templates/testKinds.d.ts +1 -1
- package/dist/templates/testKinds.js +1 -1
- package/dist/testing/fixtureTemplates.d.ts +1 -1
- package/dist/testing/fixtureTemplates.js +1 -1
- package/dist/ui/alert-dialog.js +3 -2
- package/dist/ui/dialog.js +4 -3
- package/dist/ui/editorScope.d.ts +10 -0
- package/dist/ui/editorScope.js +9 -0
- package/dist/ui/popover.js +2 -1
- package/dist/ui/select.js +2 -1
- package/dist/utils/canvasAssets.d.ts +3 -3
- package/dist/utils/canvasCommandRegistry.js +1 -1
- package/dist/utils/canvasCommands.d.ts +3 -3
- package/dist/utils/canvasCommands.js +7 -7
- package/dist/utils/canvasIcons.d.ts +7 -0
- package/dist/utils/canvasIcons.js +16 -4
- package/dist/utils/canvasItem.d.ts +7 -7
- package/dist/utils/canvasLayerManager.d.ts +21 -7
- package/dist/utils/canvasLayerManager.js +24 -0
- package/dist/utils/captureStage.d.ts +1 -1
- package/dist/utils/captureStage.js +1 -1
- package/dist/utils/chartUtils.d.ts +2 -2
- package/dist/utils/chartUtils.js +3 -3
- package/dist/utils/circleBadgeUtils.js +2 -2
- package/dist/utils/collectAltTextPages.d.ts +2 -2
- package/dist/utils/collectAltTextPages.js +1 -1
- package/dist/utils/colorNames.js +3 -3
- package/dist/utils/colorOptions.js +1 -1
- package/dist/utils/cropAspect.js +1 -1
- package/dist/utils/cropGhost.d.ts +1 -1
- package/dist/utils/cropSession.d.ts +1 -1
- package/dist/utils/cropSession.js +1 -1
- package/dist/utils/cropTarget.d.ts +1 -1
- package/dist/utils/downloadError.js +1 -1
- package/dist/utils/duplicateElement.d.ts +7 -7
- package/dist/utils/emoji/emojiCatalog.d.ts +1 -1
- package/dist/utils/emoji/emojiCatalog.js +2 -2
- package/dist/utils/expandImage.js +1 -1
- package/dist/utils/externalIcons.js +1 -1
- package/dist/utils/fontGeneration.d.ts +16 -0
- package/dist/utils/fontGeneration.js +56 -0
- package/dist/utils/fontMarkSupport.d.ts +10 -0
- package/dist/utils/fontMarkSupport.js +23 -7
- package/dist/utils/fontSpecs.d.ts +9 -0
- package/dist/utils/fontSpecs.js +17 -0
- package/dist/utils/framePresets.d.ts +19 -0
- package/dist/utils/framePresets.js +260 -0
- package/dist/utils/frameUtils.d.ts +3 -18
- package/dist/utils/frameUtils.js +2 -261
- package/dist/utils/iconInstances.d.ts +1 -1
- package/dist/utils/illustrations/gophers.d.ts +1 -1
- package/dist/utils/illustrations/humaaans.d.ts +1 -1
- package/dist/utils/illustrations/illlustrations.d.ts +1 -1
- package/dist/utils/illustrations/kawaii.d.ts +1 -1
- package/dist/utils/illustrations/opendoodles.d.ts +1 -1
- package/dist/utils/illustrations/openpeeps.d.ts +1 -1
- package/dist/utils/illustrations/registry.d.ts +3 -3
- package/dist/utils/illustrations/registry.js +2 -2
- package/dist/utils/illustrations/svgCache.d.ts +1 -1
- package/dist/utils/illustrations/transhumans.d.ts +1 -1
- package/dist/utils/illustrations/types.js +1 -1
- package/dist/utils/imageElementComparison.js +3 -3
- package/dist/utils/imageFilters.d.ts +1 -3
- package/dist/utils/imageFilters.js +7 -11
- package/dist/utils/keyboardCrop.d.ts +1 -1
- package/dist/utils/keyboardCrop.js +3 -3
- package/dist/utils/layerLabels.js +5 -8
- package/dist/utils/markerColors.js +2 -2
- package/dist/utils/mediaDrop.d.ts +13 -7
- package/dist/utils/mediaDrop.js +12 -6
- package/dist/utils/mediaPlacement.js +2 -2
- package/dist/utils/photoCredit.js +1 -1
- package/dist/utils/photoCredits.d.ts +1 -1
- package/dist/utils/photoCredits.js +2 -2
- package/dist/utils/photoPlaceholder.js +1 -1
- package/dist/utils/pillBadgeUtils.js +2 -2
- package/dist/utils/renderedBoxes.d.ts +5 -5
- package/dist/utils/renderedBoxes.js +2 -2
- package/dist/utils/resolveElementValue.js +1 -1
- package/dist/utils/shapes.d.ts +2 -2
- package/dist/utils/shapes.js +2 -2
- package/dist/utils/smartCrop.d.ts +2 -2
- package/dist/utils/smartCrop.js +4 -4
- package/dist/utils/surfaceGlow.js +1 -1
- package/dist/utils/templateElementInstance.js +1 -1
- package/dist/utils/templateRotation.js +1 -1
- package/dist/utils/textUtils.js +3 -15
- package/dist/utils/unsplashLinks.js +1 -1
- package/dist/utils/userImageCrop.d.ts +1 -1
- package/dist/utils/userImageCrop.js +2 -2
- package/dist/utils/userImageUtils.d.ts +2 -0
- package/dist/utils/userImageUtils.js +6 -1
- package/dist/utils/viewport.d.ts +12 -8
- package/dist/utils/viewport.js +17 -13
- package/dist/utils/zipPageImages.js +1 -1
- package/dist/vendor/pptxgen.LICENSES.txt +1023 -0
- package/dist/vendor/pptxgen.d.ts +2679 -0
- package/dist/vendor/pptxgen.js +8831 -0
- package/package.json +189 -27
- package/skills/ggraphic-embed/SKILL.md +266 -0
package/dist/formats/index.js
CHANGED
|
@@ -1,49 +1,32 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
import { messages } from '../i18n/
|
|
2
|
+
import { messages } from '../i18n/catalogue.js';
|
|
3
3
|
const BUILT_IN_GROUPS = [
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'praesentation',
|
|
4
|
+
'post',
|
|
5
|
+
'square',
|
|
6
|
+
'slides',
|
|
8
7
|
'print',
|
|
9
8
|
];
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
id,
|
|
27
|
-
label: `${name} · ${trimMm.w} × ${trimMm.h} mm`,
|
|
28
|
-
description: `${trimMm.w} × ${trimMm.h} mm · ${PRINT_BLEED_MM} mm Beschnitt · ${seiten === 1 ? 'einseitig' : seiten === 2 ? 'Vorder- und Rückseite' : `${seiten} Seiten`}`,
|
|
29
|
-
group: 'print',
|
|
30
|
-
category: 'print',
|
|
31
|
-
width: Math.round((trimMm.w + 2 * PRINT_BLEED_MM) * pxPerMm),
|
|
32
|
-
height: Math.round((trimMm.h + 2 * PRINT_BLEED_MM) * pxPerMm),
|
|
33
|
-
dpi: exportDpi,
|
|
34
|
-
iconKey: trimMm.w > trimMm.h ? 'landscape' : 'portrait',
|
|
35
|
-
defaultExport: 'pdf',
|
|
36
|
-
exportable: ['pdf', 'png'],
|
|
37
|
-
print: { trimMm, bleedMm: PRINT_BLEED_MM, safeMm, exportDpi, seiten, impressum },
|
|
38
|
-
};
|
|
39
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* Where the built-in picker groups sit, with gaps so a host group can go between them
|
|
11
|
+
* (`CanvasFormatGroupDef.order`, e.g. `CANVAS_FORMAT_GROUP_ORDER.post + 50` for right after posts).
|
|
12
|
+
* Print stays out: a host lists its print formats where it creates print canvases.
|
|
13
|
+
*/
|
|
14
|
+
export const CANVAS_FORMAT_GROUP_ORDER = {
|
|
15
|
+
post: 100,
|
|
16
|
+
square: 200,
|
|
17
|
+
slides: 300,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The built-in formats: a 4:5 post, a square and a 16:9 slide. Everything else
|
|
21
|
+
* (stories, print, …) is the host's, added with `registerCanvasFormats`. The
|
|
22
|
+
* formats built in up to 0.1.0-alpha.1 are in `./legacyCatalog`.
|
|
23
|
+
*/
|
|
40
24
|
export const CANVAS_FORMATS = [
|
|
41
|
-
// ── Sharepics ────────────────────────────────────────────────────────────
|
|
42
25
|
{
|
|
43
26
|
id: 'post-portrait',
|
|
44
|
-
label: '
|
|
27
|
+
label: 'Beitrag 4:5',
|
|
45
28
|
description: '1080 × 1350 · 4:5 · Instagram, Facebook',
|
|
46
|
-
group: '
|
|
29
|
+
group: 'post',
|
|
47
30
|
category: 'digital',
|
|
48
31
|
width: 1080,
|
|
49
32
|
height: 1350,
|
|
@@ -53,26 +36,11 @@ export const CANVAS_FORMATS = [
|
|
|
53
36
|
exportable: ['png', 'jpeg'],
|
|
54
37
|
print: null,
|
|
55
38
|
},
|
|
56
|
-
{
|
|
57
|
-
id: 'post-portrait-tall',
|
|
58
|
-
label: 'Sharepic 3:4',
|
|
59
|
-
description: '1080 × 1440 · 3:4 · Instagram',
|
|
60
|
-
group: 'sharepic-tall',
|
|
61
|
-
category: 'digital',
|
|
62
|
-
width: 1080,
|
|
63
|
-
height: 1440,
|
|
64
|
-
dpi: 72,
|
|
65
|
-
iconKey: 'portrait',
|
|
66
|
-
defaultExport: 'png',
|
|
67
|
-
exportable: ['png', 'jpeg'],
|
|
68
|
-
print: null,
|
|
69
|
-
},
|
|
70
|
-
// ── Profilbild ───────────────────────────────────────────────────────────
|
|
71
39
|
{
|
|
72
40
|
id: 'profile-square',
|
|
73
|
-
label: '
|
|
41
|
+
label: 'Quadrat 1:1',
|
|
74
42
|
description: '1080 × 1080 · 1:1',
|
|
75
|
-
group: '
|
|
43
|
+
group: 'square',
|
|
76
44
|
category: 'digital',
|
|
77
45
|
width: 1080,
|
|
78
46
|
height: 1080,
|
|
@@ -82,12 +50,11 @@ export const CANVAS_FORMATS = [
|
|
|
82
50
|
exportable: ['png', 'jpeg'],
|
|
83
51
|
print: null,
|
|
84
52
|
},
|
|
85
|
-
// ── Präsentation ─────────────────────────────────────────────────────────
|
|
86
53
|
{
|
|
87
54
|
id: 'slide-16-9',
|
|
88
55
|
label: 'Präsentation',
|
|
89
56
|
description: '1920 × 1080 · 16:9 · Folien',
|
|
90
|
-
group: '
|
|
57
|
+
group: 'slides',
|
|
91
58
|
category: 'digital',
|
|
92
59
|
width: 1920,
|
|
93
60
|
height: 1080,
|
|
@@ -97,24 +64,6 @@ export const CANVAS_FORMATS = [
|
|
|
97
64
|
exportable: ['pptx', 'pdf', 'png'],
|
|
98
65
|
print: null,
|
|
99
66
|
},
|
|
100
|
-
// ── Print ────────────────────────────────────────────────────────────────
|
|
101
|
-
printFormat('print-visitenkarte-quer', 'Visitenkarte quer', { w: 85, h: 55 }, 3, 2),
|
|
102
|
-
printFormat('print-visitenkarte-hoch', 'Visitenkarte hoch', { w: 55, h: 85 }, 3, 2),
|
|
103
|
-
printFormat('print-a3-hoch', 'Plakat A3 hoch', { w: 297, h: 420 }, 4, 1),
|
|
104
|
-
printFormat('print-a4-hoch', 'Plakat A4 hoch', { w: 210, h: 297 }, 4, 1),
|
|
105
|
-
printFormat('print-a3-quer', 'Plakat A3 quer', { w: 420, h: 297 }, 4, 1),
|
|
106
|
-
printFormat('print-a1-hoch', 'Plakat A1 hoch', { w: 594, h: 841 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
107
|
-
printFormat('print-a1-quer', 'Plakat A1 quer', { w: 841, h: 594 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
108
|
-
// 18/1 billboard: the artwork is supplied at A2 and enlarged (print spec).
|
|
109
|
-
printFormat('print-grossflaeche', 'Großfläche 18/1 (Vorlage A2)', { w: 594, h: 420 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
110
|
-
// Visible area 230 × 342 mm (print spec): the safe zone ends inside it.
|
|
111
|
-
printFormat('print-citylight', 'Citylight', { w: 237, h: 350 }, 8, 1, PRINT_LARGE_EXPORT_DPI),
|
|
112
|
-
// Roll fold to DIN lang: panels 100 / 100 / 97 mm, outside and inside (print spec).
|
|
113
|
-
printFormat('print-flyer-dinlang', 'Flyer DIN lang (A4 quer, Wickelfalz)', { w: 297, h: 210 }, 4, 2, PRINT_EXPORT_DPI, 'erste-seite'),
|
|
114
|
-
printFormat('print-a6-hoch', 'Flyer A6 hoch', { w: 105, h: 148 }, 3, 2, PRINT_EXPORT_DPI, 'letzte-seite'),
|
|
115
|
-
printFormat('print-a6-quer', 'Flyer A6 quer', { w: 148, h: 105 }, 3, 2, PRINT_EXPORT_DPI, 'letzte-seite'),
|
|
116
|
-
printFormat('print-briefbogen-a4', 'Briefbogen A4', { w: 210, h: 297 }, 5, 2),
|
|
117
|
-
printFormat('print-zeitung-a4', 'Zeitung A4', { w: 210, h: 297 }, 5, 4, PRINT_EXPORT_DPI, 'letzte-seite'),
|
|
118
67
|
];
|
|
119
68
|
export const DEFAULT_FORMAT_ID = 'post-portrait';
|
|
120
69
|
/**
|
|
@@ -153,6 +102,9 @@ export function registerCanvasFormatGroups(groups) {
|
|
|
153
102
|
for (const g of groups) {
|
|
154
103
|
if (seen.has(g.id))
|
|
155
104
|
throw new Error(`Canvas format group id '${g.id}' is already taken`);
|
|
105
|
+
if (g.order !== undefined && !Number.isFinite(g.order)) {
|
|
106
|
+
throw new Error(`Canvas format group '${g.id}' has no finite order`);
|
|
107
|
+
}
|
|
156
108
|
seen.add(g.id);
|
|
157
109
|
}
|
|
158
110
|
for (const f of hostFormats) {
|
|
@@ -162,9 +114,14 @@ export function registerCanvasFormatGroups(groups) {
|
|
|
162
114
|
}
|
|
163
115
|
hostGroups = [...groups];
|
|
164
116
|
}
|
|
165
|
-
/** The
|
|
117
|
+
/** The picker groups by position: the built-ins, host groups where their `order` puts them, unpositioned ones last. Read lazily. */
|
|
166
118
|
export function canvasFormatGroupOrder() {
|
|
167
|
-
|
|
119
|
+
const builtIn = Object.entries(CANVAS_FORMAT_GROUP_ORDER).map(([id, order]) => ({ id, order }));
|
|
120
|
+
const host = hostGroups.map((g) => ({ id: g.id, order: g.order ?? Number.POSITIVE_INFINITY }));
|
|
121
|
+
// Array#sort is stable: equal positions keep built-ins first, then registration order.
|
|
122
|
+
return [...builtIn, ...host]
|
|
123
|
+
.sort((a, b) => (a.order === b.order ? 0 : a.order - b.order))
|
|
124
|
+
.map((g) => g.id);
|
|
168
125
|
}
|
|
169
126
|
/** Display label of a group: the active catalogue for built-ins, the host's label otherwise. */
|
|
170
127
|
export function canvasFormatGroupLabel(id) {
|
|
@@ -178,19 +135,8 @@ export function canvasFormatGroupLabel(id) {
|
|
|
178
135
|
export function canvasFormats() {
|
|
179
136
|
return hostFormats.length === 0 ? CANVAS_FORMATS : [...CANVAS_FORMATS, ...hostFormats];
|
|
180
137
|
}
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
* carry exactly this format: the stage takes the document's format and scales
|
|
184
|
-
* the sheet to it per axis, so the square profile picture on a 4:5 document
|
|
185
|
-
* came out stretched by 1.25 (#4087).
|
|
186
|
-
*/
|
|
187
|
-
const PINNED_TEMPLATE_FORMATS = {
|
|
188
|
-
profilbild: 'profile-square',
|
|
189
|
-
sticker: 'profile-square',
|
|
190
|
-
};
|
|
191
|
-
export function pinnedFormatId(templateId) {
|
|
192
|
-
return PINNED_TEMPLATE_FORMATS[templateId] ?? null;
|
|
193
|
-
}
|
|
138
|
+
/** @deprecated Moved to `./legacyCatalog`: the template ids are the host's. Removed in the next alpha. */
|
|
139
|
+
export { pinnedFormatId } from './legacyCatalog.js';
|
|
194
140
|
/**
|
|
195
141
|
* The digital format of exactly this size, for a template that comes without
|
|
196
142
|
* one: the stage scales the template's space onto its format per axis, so the
|
|
@@ -203,9 +149,9 @@ export function formatIdForSize(width, height) {
|
|
|
203
149
|
export function getCanvasFormat(id) {
|
|
204
150
|
return canvasFormats().find((f) => f.id === id) ?? null;
|
|
205
151
|
}
|
|
206
|
-
/**
|
|
152
|
+
/** The one place that answers: is this a slide deck? A host's slide format joins the `slides` group. */
|
|
207
153
|
export function isSlideFormat(format) {
|
|
208
|
-
return format.group === '
|
|
154
|
+
return format.group === 'slides';
|
|
209
155
|
}
|
|
210
156
|
/**
|
|
211
157
|
* Startgröße neu eingefügter Elemente (Text, Formen, Icons, Grafiken,
|
|
@@ -233,7 +179,13 @@ export class UnsupportedCanvasFormatError extends Error {
|
|
|
233
179
|
this.name = 'UnsupportedCanvasFormatError';
|
|
234
180
|
}
|
|
235
181
|
}
|
|
236
|
-
/** Unknown
|
|
182
|
+
/** Unknown ids already warned about: a document resolves its format on every render. */
|
|
183
|
+
const warnedUnknownIds = new Set();
|
|
184
|
+
/**
|
|
185
|
+
* Unknown digital ids fall back to the default, with a warning once per id:
|
|
186
|
+
* a host that forgot to register its formats would otherwise ship them as
|
|
187
|
+
* 4:5 without a trace. Unknown print ids throw.
|
|
188
|
+
*/
|
|
237
189
|
export function getCanvasFormatOrDefault(id) {
|
|
238
190
|
if (id) {
|
|
239
191
|
const found = getCanvasFormat(id);
|
|
@@ -241,6 +193,10 @@ export function getCanvasFormatOrDefault(id) {
|
|
|
241
193
|
return found;
|
|
242
194
|
if (isUnsupportedFormatId(id))
|
|
243
195
|
throw new UnsupportedCanvasFormatError(id);
|
|
196
|
+
if (!warnedUnknownIds.has(id)) {
|
|
197
|
+
warnedUnknownIds.add(id);
|
|
198
|
+
console.warn(`unknown canvas format '${id}', falling back to '${DEFAULT_FORMAT_ID}'; register it with registerCanvasFormats`);
|
|
199
|
+
}
|
|
244
200
|
}
|
|
245
201
|
const fallback = getCanvasFormat(DEFAULT_FORMAT_ID);
|
|
246
202
|
if (!fallback) {
|
|
@@ -278,8 +234,8 @@ export function formatLabel(format) {
|
|
|
278
234
|
export function formatDescription(format) {
|
|
279
235
|
const m = messages().formats;
|
|
280
236
|
if (format.print) {
|
|
281
|
-
const { trimMm, bleedMm,
|
|
282
|
-
return m.printDescription(`${trimMm.w} × ${trimMm.h} mm`, bleedMm,
|
|
237
|
+
const { trimMm, bleedMm, pageCount } = format.print;
|
|
238
|
+
return m.printDescription(`${trimMm.w} × ${trimMm.h} mm`, bleedMm, pageCount);
|
|
283
239
|
}
|
|
284
240
|
if (format.id === 'slide-16-9')
|
|
285
241
|
return m.slidesDescription('1920 × 1080 · 16:9');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The formats, the group and the template pinning the editor shipped built in
|
|
3
|
+
* up to 0.1.0-alpha.1, kept unchanged so a host that relied on them can
|
|
4
|
+
* register them itself:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* registerCanvasFormatGroups(LEGACY_CANVAS_FORMAT_GROUPS);
|
|
8
|
+
* registerCanvasFormats(LEGACY_CANVAS_FORMATS);
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The ids are the ones stored in documents, so stored documents keep opening.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Copy what you need into the host; this module is removed in the next alpha.
|
|
14
|
+
*/
|
|
15
|
+
import type { CanvasFormat, CanvasFormatGroupDef } from './index.js';
|
|
16
|
+
/** @deprecated See the module comment. */
|
|
17
|
+
export declare const LEGACY_CANVAS_FORMAT_GROUPS: ReadonlyArray<CanvasFormatGroupDef>;
|
|
18
|
+
/** @deprecated See the module comment. */
|
|
19
|
+
export declare const LEGACY_CANVAS_FORMATS: ReadonlyArray<CanvasFormat>;
|
|
20
|
+
/** @deprecated The template ids are the host's; keep this map in the host. */
|
|
21
|
+
export declare function pinnedFormatId(templateId: string): string | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const PRINT_BLEED_MM = 3;
|
|
2
|
+
const PRINT_EXPORT_DPI = 300;
|
|
3
|
+
/** Large formats print from a distance: 150 dpi, the usual large-format rate. */
|
|
4
|
+
const PRINT_LARGE_EXPORT_DPI = 150;
|
|
5
|
+
/** Working resolution: the long side including bleed is 2000 px. */
|
|
6
|
+
const PRINT_LONG_SIDE_PX = 2000;
|
|
7
|
+
function printFormat(id, name, trimMm, safeMm, pageCount, exportDpi = PRINT_EXPORT_DPI, imprint = pageCount === 1 ? 'every-page' : null) {
|
|
8
|
+
const pxPerMm = PRINT_LONG_SIDE_PX / (Math.max(trimMm.w, trimMm.h) + 2 * PRINT_BLEED_MM);
|
|
9
|
+
return {
|
|
10
|
+
id,
|
|
11
|
+
label: `${name} · ${trimMm.w} × ${trimMm.h} mm`,
|
|
12
|
+
description: `${trimMm.w} × ${trimMm.h} mm · ${PRINT_BLEED_MM} mm Beschnitt · ${pageCount === 1 ? 'einseitig' : pageCount === 2 ? 'Vorder- und Rückseite' : `${pageCount} Seiten`}`,
|
|
13
|
+
group: 'print',
|
|
14
|
+
category: 'print',
|
|
15
|
+
width: Math.round((trimMm.w + 2 * PRINT_BLEED_MM) * pxPerMm),
|
|
16
|
+
height: Math.round((trimMm.h + 2 * PRINT_BLEED_MM) * pxPerMm),
|
|
17
|
+
dpi: exportDpi,
|
|
18
|
+
iconKey: trimMm.w > trimMm.h ? 'landscape' : 'portrait',
|
|
19
|
+
defaultExport: 'pdf',
|
|
20
|
+
exportable: ['pdf', 'png'],
|
|
21
|
+
print: { trimMm, bleedMm: PRINT_BLEED_MM, safeMm, exportDpi, pageCount, imprint },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** @deprecated See the module comment. */
|
|
25
|
+
export const LEGACY_CANVAS_FORMAT_GROUPS = [
|
|
26
|
+
// 3:4 is its own group because only freeform lays out on it.
|
|
27
|
+
{ id: 'sharepic-tall', label: 'Sharepics 3:4' },
|
|
28
|
+
];
|
|
29
|
+
/** @deprecated See the module comment. */
|
|
30
|
+
export const LEGACY_CANVAS_FORMATS = [
|
|
31
|
+
{
|
|
32
|
+
id: 'post-portrait-tall',
|
|
33
|
+
label: 'Sharepic 3:4',
|
|
34
|
+
description: '1080 × 1440 · 3:4 · Instagram',
|
|
35
|
+
group: 'sharepic-tall',
|
|
36
|
+
category: 'digital',
|
|
37
|
+
width: 1080,
|
|
38
|
+
height: 1440,
|
|
39
|
+
dpi: 72,
|
|
40
|
+
iconKey: 'portrait',
|
|
41
|
+
defaultExport: 'png',
|
|
42
|
+
exportable: ['png', 'jpeg'],
|
|
43
|
+
print: null,
|
|
44
|
+
},
|
|
45
|
+
printFormat('print-visitenkarte-quer', 'Visitenkarte quer', { w: 85, h: 55 }, 3, 2),
|
|
46
|
+
printFormat('print-visitenkarte-hoch', 'Visitenkarte hoch', { w: 55, h: 85 }, 3, 2),
|
|
47
|
+
printFormat('print-a3-hoch', 'Plakat A3 hoch', { w: 297, h: 420 }, 4, 1),
|
|
48
|
+
printFormat('print-a4-hoch', 'Plakat A4 hoch', { w: 210, h: 297 }, 4, 1),
|
|
49
|
+
printFormat('print-a3-quer', 'Plakat A3 quer', { w: 420, h: 297 }, 4, 1),
|
|
50
|
+
printFormat('print-a1-hoch', 'Plakat A1 hoch', { w: 594, h: 841 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
51
|
+
printFormat('print-a1-quer', 'Plakat A1 quer', { w: 841, h: 594 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
52
|
+
// 18/1 billboard: the artwork is supplied at A2 and enlarged (print spec).
|
|
53
|
+
printFormat('print-grossflaeche', 'Großfläche 18/1 (Vorlage A2)', { w: 594, h: 420 }, 10, 1, PRINT_LARGE_EXPORT_DPI),
|
|
54
|
+
// Visible area 230 × 342 mm (print spec): the safe zone ends inside it.
|
|
55
|
+
printFormat('print-citylight', 'Citylight', { w: 237, h: 350 }, 8, 1, PRINT_LARGE_EXPORT_DPI),
|
|
56
|
+
// Roll fold to DIN lang: panels 100 / 100 / 97 mm, outside and inside (print spec).
|
|
57
|
+
printFormat('print-flyer-dinlang', 'Flyer DIN lang (A4 quer, Wickelfalz)', { w: 297, h: 210 }, 4, 2, PRINT_EXPORT_DPI, 'first-page'),
|
|
58
|
+
printFormat('print-a6-hoch', 'Flyer A6 hoch', { w: 105, h: 148 }, 3, 2, PRINT_EXPORT_DPI, 'last-page'),
|
|
59
|
+
printFormat('print-a6-quer', 'Flyer A6 quer', { w: 148, h: 105 }, 3, 2, PRINT_EXPORT_DPI, 'last-page'),
|
|
60
|
+
printFormat('print-briefbogen-a4', 'Briefbogen A4', { w: 210, h: 297 }, 5, 2),
|
|
61
|
+
printFormat('print-zeitung-a4', 'Zeitung A4', { w: 210, h: 297 }, 5, 4, PRINT_EXPORT_DPI, 'last-page'),
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Templates whose fixed sheet is not 4:5. A document of such a template must
|
|
65
|
+
* carry exactly this format: the stage takes the document's format and scales
|
|
66
|
+
* the sheet to it per axis, so the square profile picture on a 4:5 document
|
|
67
|
+
* came out stretched by 1.25 (#4087).
|
|
68
|
+
*/
|
|
69
|
+
const PINNED_TEMPLATE_FORMATS = {
|
|
70
|
+
profilbild: 'profile-square',
|
|
71
|
+
sticker: 'profile-square',
|
|
72
|
+
};
|
|
73
|
+
/** @deprecated The template ids are the host's; keep this map in the host. */
|
|
74
|
+
export function pinnedFormatId(templateId) {
|
|
75
|
+
return PINNED_TEMPLATE_FORMATS[templateId] ?? null;
|
|
76
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** The part of the window the editor occupies: its root's size, clipped to the window. */
|
|
3
|
+
export interface EditorBox {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Measures the editor root (`useEditorBoxRef`) so layout and canvas fit follow the box the host
|
|
9
|
+
* gives the editor, not the window. Clipped to the window, a full-screen host measures exactly
|
|
10
|
+
* the window, also where `min-h-[500px]` makes the root taller than a landscape phone.
|
|
11
|
+
*/
|
|
12
|
+
export declare function EditorBoxProvider({ children }: {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** Ref for the editor root; without an `EditorBoxProvider` it measures nothing. */
|
|
16
|
+
export declare function useEditorBoxRef(): ((root: HTMLElement | null) => (() => void) | undefined) | undefined;
|
|
17
|
+
/** The measured box, or `null` outside an editor or before its root mounted. */
|
|
18
|
+
export declare function useMeasuredEditorBox(): EditorBox | null;
|
|
19
|
+
/** The editor's box; the window where nothing was measured (a canvas outside the editor). */
|
|
20
|
+
export declare function useEditorBox(): EditorBox;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
import { createContext, useCallback, useContext, useMemo, useState, useSyncExternalStore, } from 'react';
|
|
4
|
+
const EditorBoxContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* Measures the editor root (`useEditorBoxRef`) so layout and canvas fit follow the box the host
|
|
7
|
+
* gives the editor, not the window. Clipped to the window, a full-screen host measures exactly
|
|
8
|
+
* the window, also where `min-h-[500px]` makes the root taller than a landscape phone.
|
|
9
|
+
*/
|
|
10
|
+
export function EditorBoxProvider({ children }) {
|
|
11
|
+
const [box, setBox] = useState(null);
|
|
12
|
+
const measure = useCallback((root) => {
|
|
13
|
+
if (!root)
|
|
14
|
+
return undefined;
|
|
15
|
+
const update = () => {
|
|
16
|
+
const rect = root.getBoundingClientRect();
|
|
17
|
+
// A root without a box (hidden by the host, or no layout at all) says nothing about the
|
|
18
|
+
// space the editor will get; until it has one, the window decides.
|
|
19
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
20
|
+
setBox(null);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const width = Math.min(rect.width, window.innerWidth);
|
|
24
|
+
const height = Math.min(rect.height, window.innerHeight);
|
|
25
|
+
setBox((prev) => prev?.width === width && prev.height === height ? prev : { width, height });
|
|
26
|
+
};
|
|
27
|
+
// Measured while React commits, so the first paint already uses the box.
|
|
28
|
+
update();
|
|
29
|
+
const observer = new ResizeObserver(update);
|
|
30
|
+
observer.observe(root);
|
|
31
|
+
window.addEventListener('resize', update);
|
|
32
|
+
return () => {
|
|
33
|
+
observer.disconnect();
|
|
34
|
+
window.removeEventListener('resize', update);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const value = useMemo(() => ({ box, measure }), [box, measure]);
|
|
38
|
+
return _jsx(EditorBoxContext.Provider, { value: value, children: children });
|
|
39
|
+
}
|
|
40
|
+
/** Ref for the editor root; without an `EditorBoxProvider` it measures nothing. */
|
|
41
|
+
export function useEditorBoxRef() {
|
|
42
|
+
return useContext(EditorBoxContext)?.measure;
|
|
43
|
+
}
|
|
44
|
+
/** The measured box, or `null` outside an editor or before its root mounted. */
|
|
45
|
+
export function useMeasuredEditorBox() {
|
|
46
|
+
return useContext(EditorBoxContext)?.box ?? null;
|
|
47
|
+
}
|
|
48
|
+
const SERVER_WINDOW = { width: Infinity, height: Infinity };
|
|
49
|
+
let windowBox = SERVER_WINDOW;
|
|
50
|
+
function readWindow() {
|
|
51
|
+
const { innerWidth: width, innerHeight: height } = window;
|
|
52
|
+
if (windowBox.width !== width || windowBox.height !== height)
|
|
53
|
+
windowBox = { width, height };
|
|
54
|
+
return windowBox;
|
|
55
|
+
}
|
|
56
|
+
function subscribeWindow(onChange) {
|
|
57
|
+
window.addEventListener('resize', onChange);
|
|
58
|
+
return () => window.removeEventListener('resize', onChange);
|
|
59
|
+
}
|
|
60
|
+
/** The editor's box; the window where nothing was measured (a canvas outside the editor). */
|
|
61
|
+
export function useEditorBox() {
|
|
62
|
+
const measured = useMeasuredEditorBox();
|
|
63
|
+
const viewport = useSyncExternalStore(subscribeWindow, readWindow, () => SERVER_WINDOW);
|
|
64
|
+
return measured ?? viewport;
|
|
65
|
+
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { useElementSnapping } from '
|
|
2
|
-
export type { UseElementSnappingResult } from '
|
|
3
|
-
export { useCanvasUndoRedo } from '
|
|
1
|
+
export { useElementSnapping } from './useElementSnapping.js';
|
|
2
|
+
export type { UseElementSnappingResult } from './useElementSnapping.js';
|
|
3
|
+
export { useCanvasUndoRedo } from './useCanvasUndoRedo.js';
|
|
4
4
|
export { useCanvasInteractions } from './useCanvasInteractions.js';
|
|
5
5
|
export type { UseCanvasInteractionsOptions, UseCanvasInteractionsResult, } from './useCanvasInteractions.js';
|
|
6
|
-
export { useCanvasStoreReset } from '
|
|
7
|
-
export { useCanvasHistorySetup } from '
|
|
8
|
-
export type { UseCanvasHistorySetupResult } from '
|
|
9
|
-
export { useImageCoverFit } from '
|
|
10
|
-
export type { CoverFitDimensions } from '
|
|
6
|
+
export { useCanvasStoreReset } from './useCanvasStoreReset.js';
|
|
7
|
+
export { useCanvasHistorySetup } from './useCanvasHistorySetup.js';
|
|
8
|
+
export type { UseCanvasHistorySetupResult } from './useCanvasHistorySetup.js';
|
|
9
|
+
export { useImageCoverFit } from './useImageCoverFit.js';
|
|
10
|
+
export type { CoverFitDimensions } from './useImageCoverFit.js';
|
|
11
11
|
export { useFloatingModuleState } from './useFloatingModuleState.js';
|
|
12
12
|
export type { FloatingModuleState, UseFloatingModuleStateOptions, } from './useFloatingModuleState.js';
|
|
13
13
|
export { useFloatingModuleHandlers } from './useFloatingModuleHandlers.js';
|
|
@@ -16,14 +16,14 @@ export { useCanvasElementHandlers } from './useCanvasElementHandlers.js';
|
|
|
16
16
|
export type { UseCanvasElementHandlersOptions, UseCanvasElementHandlersResult, } from './useCanvasElementHandlers.js';
|
|
17
17
|
export { useCanvasKeyboardHandlers } from './useCanvasKeyboardHandlers.js';
|
|
18
18
|
export type { UseCanvasKeyboardHandlersOptions } from './useCanvasKeyboardHandlers.js';
|
|
19
|
-
export { useFontGeneration } from '
|
|
20
|
-
export { useFontLoader } from '
|
|
21
|
-
export type { UseFontLoaderOptions, UseFontLoaderResult
|
|
22
|
-
export { usePaginatedIcons } from '
|
|
19
|
+
export { useFontGeneration } from './useFontGeneration.js';
|
|
20
|
+
export { useFontLoader } from './useFontLoader.js';
|
|
21
|
+
export type { UseFontLoaderOptions, UseFontLoaderResult } from './useFontLoader.js';
|
|
22
|
+
export { usePaginatedIcons } from './usePaginatedIcons.js';
|
|
23
23
|
export { useMultiPageExport } from './useMultiPageExport.js';
|
|
24
24
|
export type { UseMultiPageExportProps, UseMultiPageExportReturn, ExportProgress, } from './useMultiPageExport.js';
|
|
25
25
|
export { usePageManager, parseInitialPages, readInitialDocument } from './usePageManager.js';
|
|
26
26
|
export { useDeckAutoSave, SHARE_ORIGINAL_IMAGE_SRC } from './useDeckAutoSave.js';
|
|
27
27
|
export type { InitialPageDef, UsePageManagerOptions, UsePageManagerReturn, } from './usePageManager.js';
|
|
28
28
|
export { usePageThumbnails } from './usePageThumbnails.js';
|
|
29
|
-
export { useMobileSheet } from '
|
|
29
|
+
export { useMobileSheet } from './useMobileSheet.js';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
export { useElementSnapping } from '
|
|
3
|
-
export { useCanvasUndoRedo } from '
|
|
2
|
+
export { useElementSnapping } from './useElementSnapping.js';
|
|
3
|
+
export { useCanvasUndoRedo } from './useCanvasUndoRedo.js';
|
|
4
4
|
export { useCanvasInteractions } from './useCanvasInteractions.js';
|
|
5
|
-
export { useCanvasStoreReset } from '
|
|
6
|
-
export { useCanvasHistorySetup } from '
|
|
7
|
-
export { useImageCoverFit } from '
|
|
5
|
+
export { useCanvasStoreReset } from './useCanvasStoreReset.js';
|
|
6
|
+
export { useCanvasHistorySetup } from './useCanvasHistorySetup.js';
|
|
7
|
+
export { useImageCoverFit } from './useImageCoverFit.js';
|
|
8
8
|
export { useFloatingModuleState } from './useFloatingModuleState.js';
|
|
9
9
|
export { useFloatingModuleHandlers } from './useFloatingModuleHandlers.js';
|
|
10
10
|
export { useCanvasElementHandlers } from './useCanvasElementHandlers.js';
|
|
11
11
|
export { useCanvasKeyboardHandlers } from './useCanvasKeyboardHandlers.js';
|
|
12
|
-
export { useFontGeneration } from '
|
|
13
|
-
export { useFontLoader } from '
|
|
14
|
-
export { usePaginatedIcons } from '
|
|
12
|
+
export { useFontGeneration } from './useFontGeneration.js';
|
|
13
|
+
export { useFontLoader } from './useFontLoader.js';
|
|
14
|
+
export { usePaginatedIcons } from './usePaginatedIcons.js';
|
|
15
15
|
export { useMultiPageExport } from './useMultiPageExport.js';
|
|
16
16
|
export { usePageManager, parseInitialPages, readInitialDocument } from './usePageManager.js';
|
|
17
17
|
export { useDeckAutoSave, SHARE_ORIGINAL_IMAGE_SRC } from './useDeckAutoSave.js';
|
|
18
18
|
export { usePageThumbnails } from './usePageThumbnails.js';
|
|
19
|
-
export { useMobileSheet } from '
|
|
19
|
+
export { useMobileSheet } from './useMobileSheet.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The largest size a page's stage may take, in CSS px at zoom 100 %. */
|
|
2
|
+
export interface StageFit {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
/** Set by the editor shell; the pages inside fit their stage to it. */
|
|
7
|
+
export declare const StageFitProvider: import("react").Provider<StageFit | null>;
|
|
8
|
+
/** The measured fit, or `null` (previews, a canvas outside the editor). */
|
|
9
|
+
export declare function useStageFit(): StageFit | null;
|
|
10
|
+
/**
|
|
11
|
+
* The part of the canvas area a page can use without anything covering it: the scrolling main
|
|
12
|
+
* column, minus what sits above the first stage (context bar slot, padding, page toolbar), the
|
|
13
|
+
* bottom bar and a gap above it as wide as the gap above the page (canvas and container padding). Every value is laid out by the
|
|
14
|
+
* editor, never by the stage itself, so a stage that grows or shrinks to the result measures the
|
|
15
|
+
* same result again. Layout sizes (`offset*`, `client*`), not rects: the zoom scales the pages
|
|
16
|
+
* container, and the fit is the size at 100 %.
|
|
17
|
+
*/
|
|
18
|
+
export declare function measureStageFit(container: HTMLElement): StageFit | null;
|
|
19
|
+
/**
|
|
20
|
+
* Measures `measureStageFit` for the pages container while `enabled`, and again on every resize.
|
|
21
|
+
* While `hold`, the last fit stays and nothing is measured: an open mobile sheet takes space from
|
|
22
|
+
* the main column and shifts the pages, and `useMobileSheetFit` already scales them into what is left.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useMeasuredStageFit(container: HTMLElement | null, enabled: boolean, hold?: boolean): StageFit | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
3
|
+
const StageFitContext = createContext(null);
|
|
4
|
+
/** Set by the editor shell; the pages inside fit their stage to it. */
|
|
5
|
+
export const StageFitProvider = StageFitContext.Provider;
|
|
6
|
+
/** The measured fit, or `null` (previews, a canvas outside the editor). */
|
|
7
|
+
export function useStageFit() {
|
|
8
|
+
return useContext(StageFitContext);
|
|
9
|
+
}
|
|
10
|
+
/** The pixel value of a computed length (`12px` → 12). */
|
|
11
|
+
const px = (value) => Number.parseFloat(value) || 0;
|
|
12
|
+
/**
|
|
13
|
+
* The part of the canvas area a page can use without anything covering it: the scrolling main
|
|
14
|
+
* column, minus what sits above the first stage (context bar slot, padding, page toolbar), the
|
|
15
|
+
* bottom bar and a gap above it as wide as the gap above the page (canvas and container padding). Every value is laid out by the
|
|
16
|
+
* editor, never by the stage itself, so a stage that grows or shrinks to the result measures the
|
|
17
|
+
* same result again. Layout sizes (`offset*`, `client*`), not rects: the zoom scales the pages
|
|
18
|
+
* container, and the fit is the size at 100 %.
|
|
19
|
+
*/
|
|
20
|
+
export function measureStageFit(container) {
|
|
21
|
+
const main = container.closest('.canvas-editor-layout__main');
|
|
22
|
+
const page = container.querySelector('.heterogeneous-multipage__page-wrapper');
|
|
23
|
+
const stage = page?.querySelector('.canvas-stage-container');
|
|
24
|
+
if (!main || !page || !stage)
|
|
25
|
+
return null;
|
|
26
|
+
const bar = container
|
|
27
|
+
.closest('.canvas-editor-layout')
|
|
28
|
+
?.querySelector('.canvas-editor-layout__bottom-bar');
|
|
29
|
+
const style = getComputedStyle(container);
|
|
30
|
+
const canvas = container.closest('.canvas-editor-layout__canvas');
|
|
31
|
+
const gap = px(style.paddingTop) + (canvas ? px(getComputedStyle(canvas).paddingTop) : 0);
|
|
32
|
+
// The container's top edge stays put under the zoom (`transform-origin: top center`).
|
|
33
|
+
const above = container.getBoundingClientRect().top - main.getBoundingClientRect().top + main.scrollTop;
|
|
34
|
+
const pageChrome = page.offsetHeight - stage.offsetHeight;
|
|
35
|
+
const width = container.clientWidth - px(style.paddingLeft) - px(style.paddingRight);
|
|
36
|
+
// `above` already holds the gap over the page; the same gap again over the bottom bar.
|
|
37
|
+
const height = main.clientHeight - above - px(style.paddingTop) - pageChrome - (bar?.offsetHeight ?? 0) - gap;
|
|
38
|
+
if (width <= 0 || height <= 0)
|
|
39
|
+
return null;
|
|
40
|
+
return { width: Math.floor(width), height: Math.floor(height) };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Measures `measureStageFit` for the pages container while `enabled`, and again on every resize.
|
|
44
|
+
* While `hold`, the last fit stays and nothing is measured: an open mobile sheet takes space from
|
|
45
|
+
* the main column and shifts the pages, and `useMobileSheetFit` already scales them into what is left.
|
|
46
|
+
*/
|
|
47
|
+
export function useMeasuredStageFit(container, enabled, hold = false) {
|
|
48
|
+
const [fit, setFit] = useState(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!enabled || !container) {
|
|
51
|
+
setFit(null);
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (hold)
|
|
55
|
+
return undefined;
|
|
56
|
+
const update = () => {
|
|
57
|
+
const next = measureStageFit(container);
|
|
58
|
+
setFit((prev) => prev?.width === next?.width && prev?.height === next?.height ? prev : next);
|
|
59
|
+
};
|
|
60
|
+
update();
|
|
61
|
+
const observer = new ResizeObserver(update);
|
|
62
|
+
// The container resizes with its pages (a page appearing, a toolbar showing); the main column
|
|
63
|
+
// and the bottom bar with the window and the side panel.
|
|
64
|
+
observer.observe(container);
|
|
65
|
+
const main = container.closest('.canvas-editor-layout__main');
|
|
66
|
+
if (main)
|
|
67
|
+
observer.observe(main);
|
|
68
|
+
const bar = container
|
|
69
|
+
.closest('.canvas-editor-layout')
|
|
70
|
+
?.querySelector('.canvas-editor-layout__bottom-bar');
|
|
71
|
+
if (bar)
|
|
72
|
+
observer.observe(bar);
|
|
73
|
+
return () => observer.disconnect();
|
|
74
|
+
}, [container, enabled, hold]);
|
|
75
|
+
return fit;
|
|
76
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
import { messages } from '
|
|
3
|
-
import { useCanvasEditorServices } from '
|
|
2
|
+
import { messages } from '../i18n/catalogue.js';
|
|
3
|
+
import { useCanvasEditorServices } from '../CanvasEditorProvider.js';
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
5
|
export function useAiImageGeneration() {
|
|
6
6
|
const { generateAiImage } = useCanvasEditorServices();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useCallback } from 'react';
|
|
3
|
-
import { useAutoSaveStore, useAutoSaveStoreApi } from '
|
|
3
|
+
import { useAutoSaveStore, useAutoSaveStoreApi } from '../stores/useAutoSaveStore.js';
|
|
4
4
|
import { useCanvasEditorServices } from '../CanvasEditorProvider.js';
|
|
5
5
|
import { plainImageUrls } from '../hostServices.js';
|
|
6
6
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type LiftedBlock } from '../blocks/liftedBlock.js';
|
|
2
2
|
import type { FullCanvasConfig, LayoutResult, AdditionalText } from '../configs/types.js';
|
|
3
3
|
import type { FontRole } from '@ggraphic/core';
|
|
4
|
-
import type { CircleBadgeInstance } from '
|
|
5
|
-
import type { ChartInstance, ChartType } from '
|
|
6
|
-
import type { FrameClipType, FrameInstance } from '
|
|
7
|
-
import type { PillBadgeInstance } from '
|
|
8
|
-
import type { ShapeInstance, ShapeType } from '
|
|
9
|
-
import type { ElementPlacement, UserImageInstance, UserImagePlacement } from '
|
|
4
|
+
import type { CircleBadgeInstance } from '../primitives/CircleBadge.js';
|
|
5
|
+
import type { ChartInstance, ChartType } from '../utils/chartTypes.js';
|
|
6
|
+
import type { FrameClipType, FrameInstance } from '../utils/frameUtils.js';
|
|
7
|
+
import type { PillBadgeInstance } from '../utils/pillBadgeUtils.js';
|
|
8
|
+
import type { ShapeInstance, ShapeType } from '../utils/shapes.js';
|
|
9
|
+
import type { ElementPlacement, UserImageInstance, UserImagePlacement } from '../utils/userImageUtils.js';
|
|
10
10
|
import type { StickerRef } from '@ggraphic/schema';
|
|
11
11
|
/**
|
|
12
12
|
* Canvas Element Handlers - Handlers for all element interactions
|