@ggraphic/editor 0.0.0 → 0.1.0-alpha.1
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 +25 -1
- package/dist/brand/brandRegistry.d.ts +11 -3
- package/dist/brand/brandRegistry.js +18 -3
- package/dist/brand/documentBrand.d.ts +16 -0
- package/dist/brand/documentBrand.js +6 -0
- package/dist/components/CanvasContextMenu/CanvasActionSheet.js +2 -1
- package/dist/components/CanvasContextMenu/CanvasContextMenu.js +3 -2
- package/dist/components/CanvasEditor/CanvasEditorShell.js +43 -34
- package/dist/components/CanvasTextOverlay.js +14 -5
- package/dist/components/CustomColorSwatch.js +3 -2
- package/dist/components/GenericCanvas.js +21 -5
- package/dist/components/RichTextField.js +6 -1
- package/dist/components/SelectionPill.js +2 -1
- package/dist/components/TextFormatButtons.js +12 -23
- package/dist/components/TopBar/ContextControls.js +4 -2
- package/dist/components/TopBar/modules/FloatingColorPicker.js +3 -1
- package/dist/components/TopBar/modules/FloatingFontRoleControl.js +2 -2
- package/dist/components/kindRenderers.d.ts +1 -1
- package/dist/components/markerMark.d.ts +6 -1
- package/dist/components/markerMark.js +7 -11
- package/dist/configs/factory/actionFactories.d.ts +38 -9
- package/dist/configs/factory/actionFactories.js +53 -36
- package/dist/configs/types.d.ts +13 -2
- package/dist/export/pptx/buildPptxModel.d.ts +3 -0
- package/dist/export/pptx/buildPptxModel.js +5 -5
- package/dist/export/pptx/exportPptxDeck.d.ts +4 -1
- package/dist/export/pptx/exportPptxDeck.js +5 -2
- package/dist/export/pptx/textModel.d.ts +6 -2
- package/dist/export/pptx/textModel.js +14 -11
- package/dist/hooks/useFloatingModuleHandlers.js +2 -2
- package/dist/hooks/useMultiPageExport.js +1 -1
- package/dist/i18n/de.d.ts +14 -0
- package/dist/i18n/de.js +14 -0
- package/dist/i18n/en.js +12 -0
- 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 +91 -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/CanvasRichText.js +7 -4
- package/dist/primitives/CanvasStage.js +3 -2
- package/dist/primitives/UserImagePrimitive.js +3 -1
- package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
- package/dist/sidebar/sections/ChartSettingsSection.js +5 -2
- package/dist/sidebar/sections/CombinedTextSection.js +4 -3
- package/dist/sidebar/sections/DiagrammeSection.js +10 -11
- package/dist/sidebar/sections/FormenSection.d.ts +3 -1
- package/dist/sidebar/sections/FormenSection.js +25 -13
- package/dist/sidebar/sections/GenericShareSection.js +3 -2
- package/dist/sidebar/sections/IllustrationSettings.js +4 -3
- package/dist/sidebar/sections/ImageAdjustSection.js +6 -5
- package/dist/sidebar/sections/assets/ElementThumb.js +3 -1
- package/dist/sidebar/sections/assets/useElementCatalog.d.ts +2 -1
- package/dist/sidebar/sections/assets/useElementCatalog.js +30 -15
- package/dist/sidebar/sections/effects/GradientSettings.js +4 -2
- package/dist/sidebar/sections/effects/OutlineSettings.js +4 -3
- package/dist/sidebar/sections/effects/ShadowSettings.js +4 -3
- package/dist/sidebar/sections/tools/BlobCreatorTool.js +11 -6
- package/dist/sidebar/sections/tools/GradientTextTool.js +14 -12
- package/dist/sidebar/sections/tools/TextPathCreatorTool.js +15 -13
- package/dist/sidebar/sections/tools/ToolsSection.js +5 -3
- package/dist/styles/compiled.css +2 -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/ui/alert-dialog.js +3 -2
- package/dist/ui/button.d.ts +2 -2
- package/dist/ui/dialog.js +3 -2
- 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 +7 -1
- package/dist/utils/canvasLayerManager.d.ts +14 -0
- package/dist/utils/canvasLayerManager.js +24 -0
- package/dist/utils/circleBadgeUtils.d.ts +3 -1
- package/dist/utils/circleBadgeUtils.js +5 -5
- package/dist/utils/colorNames.d.ts +7 -2
- package/dist/utils/colorNames.js +14 -5
- package/dist/utils/fontMarkSupport.d.ts +11 -0
- package/dist/utils/fontMarkSupport.js +27 -5
- package/dist/utils/frameUtils.d.ts +3 -2
- package/dist/utils/frameUtils.js +3 -2
- package/dist/utils/illustrations/registry.d.ts +4 -1
- package/dist/utils/illustrations/registry.js +5 -3
- package/dist/utils/illustrations/svgCache.js +13 -6
- package/dist/utils/illustrations/types.d.ts +1 -1
- package/dist/utils/imageFilters.d.ts +4 -2
- package/dist/utils/imageFilters.js +3 -2
- package/dist/utils/imageLook.d.ts +4 -2
- package/dist/utils/imageLook.js +4 -2
- package/dist/utils/layerLabels.js +3 -6
- package/dist/utils/markerBoxes.d.ts +16 -1
- package/dist/utils/markerBoxes.js +2 -15
- package/dist/utils/markerColors.d.ts +12 -5
- package/dist/utils/markerColors.js +8 -15
- package/dist/utils/photoPlaceholder.d.ts +4 -1
- package/dist/utils/photoPlaceholder.js +5 -3
- package/dist/utils/pillBadgeUtils.d.ts +3 -2
- package/dist/utils/pillBadgeUtils.js +5 -5
- package/dist/utils/shapes.d.ts +4 -2
- package/dist/utils/shapes.js +4 -2
- package/dist/utils/textUtils.js +2 -10
- package/dist/utils/zipPageImages.d.ts +2 -1
- package/dist/utils/zipPageImages.js +3 -2
- package/package.json +14 -7
- package/skills/ggraphic-embed/SKILL.md +145 -0
- package/dist/components/MobileSelectionPill.d.ts +0 -40
- package/dist/components/MobileSelectionPill.js +0 -85
- package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +0 -9
- package/dist/components/TopBar/modules/FloatingGradientControl.js +0 -35
- package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +0 -11
- package/dist/components/TopBar/modules/FloatingOutlineControl.js +0 -31
- package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +0 -12
- package/dist/components/TopBar/modules/FloatingShadowControl.js +0 -40
- package/dist/utils/balkenUtils.d.ts +0 -22
- package/dist/utils/balkenUtils.js +0 -8
|
@@ -10,6 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
10
10
|
import { useState, useEffect, useRef, useMemo, memo } from 'react';
|
|
11
11
|
import { Image, Group, Rect, Transformer, Circle, Line } from 'react-konva';
|
|
12
12
|
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
13
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
13
14
|
import { LOCKED_TRANSFORMER, useIsItemLocked } from '@ggraphic/editor/components/canvasItemLock';
|
|
14
15
|
import { useAnnounce } from '@ggraphic/editor/hooks/useAnnounce';
|
|
15
16
|
import { useBoxSnap } from '@ggraphic/editor/hooks/useBoxSnap';
|
|
@@ -43,6 +44,7 @@ const ALL_ANCHORS = [
|
|
|
43
44
|
];
|
|
44
45
|
function UserImagePrimitiveInner({ userImage, isSelected, onSelect, onDragEnd, onTransformEnd, onCropEnd, isCropping: cropping = false, onCroppingChange, cropAspect = 'free', draggable = true, brandScheme = null, ...snapProps }) {
|
|
45
46
|
const locked = useIsItemLocked();
|
|
47
|
+
const documentBrand = useDocumentBrand();
|
|
46
48
|
const snap = useBoxSnap({ id: userImage.id, ...snapProps }, userImageBox(userImage));
|
|
47
49
|
const announce = useAnnounce();
|
|
48
50
|
const panStartRef = useRef(null);
|
|
@@ -226,7 +228,7 @@ function UserImagePrimitiveInner({ userImage, isSelected, onSelect, onDragEnd, o
|
|
|
226
228
|
return null;
|
|
227
229
|
if (!image || noPhoto) {
|
|
228
230
|
// The slot keeps its frame: same position, scale, rotation and mask as a photo would get.
|
|
229
|
-
const look = photoPlaceholderLook(brandScheme, userImage.width, userImage.height);
|
|
231
|
+
const look = photoPlaceholderLook(brandScheme, userImage.width, userImage.height, documentBrand);
|
|
230
232
|
return (_jsxs(_Fragment, { children: [_jsxs(Group, { ref: groupRef, ...groupProps, draggable: draggable && !locked, children: [_jsxs(Group, { name: EXPORT_HIDDEN_NAME, children: [notchClipped(_jsx(Rect, { width: userImage.width, height: userImage.height, fill: look.fill, cornerRadius: userImage.mask === 'kreis' && !notchSize
|
|
231
233
|
? look.circleRadius
|
|
232
234
|
: (userImage.cornerRadius ?? 0) })), _jsxs(Group, { name: "placeholder-icon", x: look.icon.x, y: look.icon.y, opacity: look.icon.opacity, listening: false, children: [_jsx(Line, { points: look.icon.mountain, stroke: look.icon.color, strokeWidth: look.icon.stroke, lineCap: "round", lineJoin: "round" }), _jsx(Circle, { x: look.icon.sun.x, y: look.icon.sun.y, radius: look.icon.sun.r, stroke: look.icon.color, strokeWidth: look.icon.stroke })] })] }), isSelected && (_jsx(Rect, { name: "selection-chrome", width: userImage.width, height: userImage.height, stroke: activeBrand().colors.primary, strokeWidth: 2 / userImage.scale, dash: [5, 5], listening: false }))] }), isSelected && (_jsx(Transformer, { ref: transformerRef, keepRatio: true, enabledAnchors: ['top-left', 'top-right', 'bottom-left', 'bottom-right'], rotateEnabled: true, ...ELEMENT_TRANSFORMER, ...(locked ? LOCKED_TRANSFORMER : {}) }))] }));
|
|
@@ -6,4 +6,4 @@ export interface ChartSettingsSectionProps {
|
|
|
6
6
|
/** The swatches: the page's country palette. */
|
|
7
7
|
palette?: readonly string[];
|
|
8
8
|
}
|
|
9
|
-
export declare function ChartSettingsSection({ selectedChart, onUpdateChart, onRemoveChart, palette, }: ChartSettingsSectionProps): import("react").JSX.Element | null;
|
|
9
|
+
export declare function ChartSettingsSection({ selectedChart, onUpdateChart, onRemoveChart, palette: ownPalette, }: ChartSettingsSectionProps): import("react").JSX.Element | null;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
4
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
4
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
5
6
|
import { Switch } from '@ggraphic/editor/ui/switch';
|
|
6
|
-
import { addChartRow, addChartSeries,
|
|
7
|
+
import { addChartRow, addChartSeries, chartLegendPosition, chartSeries, isRoundChartType, removeChartRow, removeChartSeries, renameChartSeries, setChartValue, } from '@ggraphic/editor/utils/chartUtils';
|
|
7
8
|
import { PiChartBar, PiChartBarHorizontal, PiChartDonut, PiChartLine, PiChartLineUp, PiChartPie, PiTrash, PiPlus, } from 'react-icons/pi';
|
|
8
9
|
import { MOBILE_INPUT_TEXT } from '@ggraphic/editor/sidebar/sidebarStyles';
|
|
9
10
|
const typeOptions = (t) => [
|
|
@@ -21,8 +22,10 @@ const legendOptions = (t) => [
|
|
|
21
22
|
/** More series than colours in a palette would repeat a colour. */
|
|
22
23
|
const MAX_SERIES = 5;
|
|
23
24
|
const CELL = `rounded-md border border-editor-border-strong bg-background px-2 py-1 text-sm ${MOBILE_INPUT_TEXT} text-foreground outline-none focus:border-primary-500`;
|
|
24
|
-
export function ChartSettingsSection({ selectedChart, onUpdateChart, onRemoveChart, palette
|
|
25
|
+
export function ChartSettingsSection({ selectedChart, onUpdateChart, onRemoveChart, palette: ownPalette, }) {
|
|
25
26
|
const t = useMessages();
|
|
27
|
+
const documentChart = useDocumentBrand().chart;
|
|
28
|
+
const palette = ownPalette ?? documentChart;
|
|
26
29
|
const chart = selectedChart;
|
|
27
30
|
if (!chart)
|
|
28
31
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
import {
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
4
4
|
import { messages, useMessages } from '@ggraphic/editor/i18n/messages';
|
|
5
5
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
6
6
|
import { PiPlusBold, PiTextAa, PiTextHBold, PiTrash } from 'react-icons/pi';
|
|
@@ -26,11 +26,12 @@ function getTextTypePlaceholder(type) {
|
|
|
26
26
|
}
|
|
27
27
|
export function CombinedTextSection({ onAddHeader, onAddSubheader, onAddText, additionalTexts, onUpdateText, onRemoveText, textFields, values, onFieldChange, fontSizes, onFontSizeChange, }) {
|
|
28
28
|
const t = useMessages();
|
|
29
|
+
const brand = useDocumentBrand();
|
|
29
30
|
const isMobile = useIsCanvasMobile();
|
|
30
31
|
const hasFreeformText = onAddHeader !== undefined || onAddText !== undefined;
|
|
31
32
|
const hasTemplateFields = textFields !== undefined && textFields.length > 0;
|
|
32
33
|
const hasCanvasTexts = additionalTexts !== undefined && additionalTexts.length > 0;
|
|
33
|
-
return (_jsxs("div", { className: cn(SIDEBAR_SECTION, 'gap-md p-md max-canvas-mobile:gap-4 max-canvas-mobile:p-0'), children: [hasFreeformText && isMobile && (_jsxs("div", { className: "flex flex-col gap-2.5", children: [onAddHeader && (_jsx("button", { type: "button", onClick: onAddHeader, className: cn(MOBILE_ADD_TILE, 'h-12 text-[20px] font-black'), children: t.sidebar.text.addHeader })), onAddSubheader && (_jsx("button", { type: "button", onClick: onAddSubheader, className: cn(MOBILE_ADD_TILE, 'h-11 text-[17px] font-bold'), children: t.sidebar.text.addSubheader })), onAddText && (_jsx("button", { type: "button", onClick: onAddText, className: cn(MOBILE_ADD_TILE, 'h-11 text-[15px] font-normal'), children: t.sidebar.text.addBody }))] })), hasFreeformText && !isMobile && (_jsxs(_Fragment, { children: [onAddText && (_jsxs("button", { type: "button", onClick: onAddText, className: "flex items-center justify-center gap-xs w-full py-2.5 bg-primary-600 text-white border-none rounded-lg cursor-pointer text-sm font-semibold transition-colors duration-150 hover:bg-primary-700", children: [_jsx(PiPlusBold, { size: 14 }), t.sidebar.text.addTextField] })), _jsxs("div", { className: "flex flex-col gap-1.5", children: [onAddHeader && (_jsx("button", { type: "button", onClick: onAddHeader, className: "w-full text-left py-3 px-4 bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg cursor-pointer transition-all duration-150 hover:bg-hover-alt hover:border-editor-border-strong", children: _jsx("span", { className: "text-xl font-bold text-foreground", style: { fontFamily: `${
|
|
34
|
+
return (_jsxs("div", { className: cn(SIDEBAR_SECTION, 'gap-md p-md max-canvas-mobile:gap-4 max-canvas-mobile:p-0'), children: [hasFreeformText && isMobile && (_jsxs("div", { className: "flex flex-col gap-2.5", children: [onAddHeader && (_jsx("button", { type: "button", onClick: onAddHeader, className: cn(MOBILE_ADD_TILE, 'h-12 text-[20px] font-black'), children: t.sidebar.text.addHeader })), onAddSubheader && (_jsx("button", { type: "button", onClick: onAddSubheader, className: cn(MOBILE_ADD_TILE, 'h-11 text-[17px] font-bold'), children: t.sidebar.text.addSubheader })), onAddText && (_jsx("button", { type: "button", onClick: onAddText, className: cn(MOBILE_ADD_TILE, 'h-11 text-[15px] font-normal'), children: t.sidebar.text.addBody }))] })), hasFreeformText && !isMobile && (_jsxs(_Fragment, { children: [onAddText && (_jsxs("button", { type: "button", onClick: onAddText, className: "flex items-center justify-center gap-xs w-full py-2.5 bg-primary-600 text-white border-none rounded-lg cursor-pointer text-sm font-semibold transition-colors duration-150 hover:bg-primary-700", children: [_jsx(PiPlusBold, { size: 14 }), t.sidebar.text.addTextField] })), _jsxs("div", { className: "flex flex-col gap-1.5", children: [onAddHeader && (_jsx("button", { type: "button", onClick: onAddHeader, className: "w-full text-left py-3 px-4 bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg cursor-pointer transition-all duration-150 hover:bg-hover-alt hover:border-editor-border-strong", children: _jsx("span", { className: "text-xl font-bold text-foreground", style: { fontFamily: `${brand.fonts.headline}, Arial, sans-serif` }, children: t.sidebar.text.labelTitle }) })), onAddSubheader && (_jsx("button", { type: "button", onClick: onAddSubheader, className: "w-full text-left py-2.5 px-4 bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg cursor-pointer transition-all duration-150 hover:bg-hover-alt hover:border-editor-border-strong", children: _jsx("span", { className: "text-base font-bold text-foreground", style: { fontFamily: `${brand.fonts.headline}, Arial, sans-serif` }, children: t.sidebar.text.labelSubtitle }) })), onAddText && (_jsx("button", { type: "button", onClick: onAddText, className: "w-full text-left py-2 px-4 bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg cursor-pointer transition-all duration-150 hover:bg-hover-alt hover:border-editor-border-strong", children: _jsx("span", { className: "font-[PT_Sans,Arial,sans-serif] text-sm text-foreground", children: t.sidebar.text.labelText }) }))] })] })), hasTemplateFields && values && onFieldChange && (_jsx("div", { className: cn('flex flex-col gap-[var(--spacing-large)]', MOBILE_FIELD_TILES), children: textFields.map((fieldConfig) => {
|
|
34
35
|
const fontSize = fieldConfig.fontSizeStateKey
|
|
35
36
|
? fontSizes?.[fieldConfig.fontSizeStateKey]
|
|
36
37
|
: undefined;
|
|
@@ -38,5 +39,5 @@ export function CombinedTextSection({ onAddHeader, onAddSubheader, onAddText, ad
|
|
|
38
39
|
? (size) => onFontSizeChange(fieldConfig.fontSizeStateKey, size)
|
|
39
40
|
: undefined;
|
|
40
41
|
return (_jsx(TextField, { config: fieldConfig, value: values[fieldConfig.key] || '', onChange: (val) => onFieldChange(fieldConfig.key, val), fontSize: fontSize, onFontSizeChange: handleFontSizeChange }, fieldConfig.key));
|
|
41
|
-
}) })), hasCanvasTexts && onUpdateText && onRemoveText && (_jsxs("div", { className: "flex flex-col gap-xs max-canvas-mobile:gap-2.5", children: [_jsx("span", { className: "text-xs font-semibold text-foreground uppercase tracking-wide max-canvas-mobile:text-[13px] max-canvas-mobile:font-bold max-canvas-mobile:normal-case max-canvas-mobile:tracking-normal max-canvas-mobile:text-[var(--editor-text-muted)]", children: t.sidebar.text.onCanvas }), additionalTexts.map((text) => (_jsxs("div", { className: "flex items-center gap-sm p-sm bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg max-canvas-mobile:min-h-11 max-canvas-mobile:py-1 max-canvas-mobile:pl-3.5 max-canvas-mobile:pr-1.5 max-canvas-mobile:bg-[var(--editor-tile)] max-canvas-mobile:border-transparent max-canvas-mobile:rounded-xl", children: [_jsx("span", { className: "text-xs text-foreground-muted shrink-0 w-5", children: getTextTypeIcon(text.type) }), _jsx("
|
|
42
|
+
}) })), hasCanvasTexts && onUpdateText && onRemoveText && (_jsxs("div", { className: "flex flex-col gap-xs max-canvas-mobile:gap-2.5", children: [_jsx("span", { className: "text-xs font-semibold text-foreground uppercase tracking-wide max-canvas-mobile:text-[13px] max-canvas-mobile:font-bold max-canvas-mobile:normal-case max-canvas-mobile:tracking-normal max-canvas-mobile:text-[var(--editor-text-muted)]", children: t.sidebar.text.onCanvas }), additionalTexts.map((text) => (_jsxs("div", { className: "flex items-center gap-sm p-sm bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg max-canvas-mobile:min-h-11 max-canvas-mobile:py-1 max-canvas-mobile:pl-3.5 max-canvas-mobile:pr-1.5 max-canvas-mobile:bg-[var(--editor-tile)] max-canvas-mobile:border-transparent max-canvas-mobile:rounded-xl", children: [_jsx("span", { className: "text-xs text-foreground-muted shrink-0 w-5", children: getTextTypeIcon(text.type) }), _jsx("textarea", { value: text.text, rows: text.text.split('\n').length, onChange: (e) => onUpdateText(text.id, { text: e.target.value }), className: `flex-1 min-w-0 resize-none [field-sizing:content] bg-transparent border-none outline-none text-sm text-foreground placeholder:text-foreground-muted max-canvas-mobile:text-[var(--editor-text)] ${MOBILE_INPUT_TEXT}`, placeholder: getTextTypePlaceholder(text.type) }), _jsx("button", { type: "button", onClick: () => onRemoveText(text.id), className: "touch-target shrink-0 size-7 flex items-center justify-center bg-transparent border-none rounded-md cursor-pointer text-foreground-muted transition-colors duration-150 hover:bg-red-50 hover:text-red-600", "aria-label": t.sidebar.text.removeText, children: _jsx(PiTrash, { size: 11 }) })] }, text.id)))] })), !hasFreeformText && !hasTemplateFields && !hasCanvasTexts && (_jsx(SidebarHint, { children: t.sidebar.text.hintEdit })), hasFreeformText && !hasCanvasTexts && _jsx(SidebarHint, { children: t.sidebar.text.hintAdd })] }));
|
|
42
43
|
}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
4
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
4
|
-
import {
|
|
5
|
+
import { CHART_GROUP_LABELS, CHART_GROUP_ORDER, CHART_TYPE_DEFS, } from '@ggraphic/editor/utils/chartUtils';
|
|
5
6
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
6
|
-
// Read at render time, not module init: the chart series live in another chunk and
|
|
7
|
-
// indexing it here risks the documented prod chunk-order crash (see FormenSection).
|
|
8
|
-
const c = (index) => chartColors()[index];
|
|
9
7
|
/**
|
|
10
8
|
* Static mini-chart glyphs (literal brand colors, no live Recharts) — one per
|
|
11
9
|
* ChartType, exhaustively keyed so adding a type without a preview is a
|
|
12
10
|
* compile error.
|
|
13
11
|
*/
|
|
14
12
|
const CHART_PREVIEWS = {
|
|
15
|
-
bar: () => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "8", y: "20", width: "9", height: "22", rx: "1.5", fill: c(0) }), _jsx("rect", { x: "21", y: "10", width: "9", height: "32", rx: "1.5", fill: c(1) }), _jsx("rect", { x: "34", y: "26", width: "9", height: "16", rx: "1.5", fill: c(2) }), _jsx("rect", { x: "47", y: "16", width: "9", height: "26", rx: "1.5", fill: c(0) })] })),
|
|
16
|
-
'bar-horizontal': () => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "8", y: "8", width: "40", height: "7", rx: "1.5", fill: c(0) }), _jsx("rect", { x: "8", y: "18", width: "48", height: "7", rx: "1.5", fill: c(1) }), _jsx("rect", { x: "8", y: "28", width: "26", height: "7", rx: "1.5", fill: c(2) }), _jsx("rect", { x: "8", y: "38", width: "34", height: "7", rx: "1.5", fill: c(0) })] })),
|
|
17
|
-
line: () => (_jsxs(_Fragment, { children: [_jsx("polyline", { points: "8,38 22,26 36,30 56,10", fill: "none", stroke: c(0), strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }), [
|
|
13
|
+
bar: (c) => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "8", y: "20", width: "9", height: "22", rx: "1.5", fill: c(0) }), _jsx("rect", { x: "21", y: "10", width: "9", height: "32", rx: "1.5", fill: c(1) }), _jsx("rect", { x: "34", y: "26", width: "9", height: "16", rx: "1.5", fill: c(2) }), _jsx("rect", { x: "47", y: "16", width: "9", height: "26", rx: "1.5", fill: c(0) })] })),
|
|
14
|
+
'bar-horizontal': (c) => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "8", y: "8", width: "40", height: "7", rx: "1.5", fill: c(0) }), _jsx("rect", { x: "8", y: "18", width: "48", height: "7", rx: "1.5", fill: c(1) }), _jsx("rect", { x: "8", y: "28", width: "26", height: "7", rx: "1.5", fill: c(2) }), _jsx("rect", { x: "8", y: "38", width: "34", height: "7", rx: "1.5", fill: c(0) })] })),
|
|
15
|
+
line: (c) => (_jsxs(_Fragment, { children: [_jsx("polyline", { points: "8,38 22,26 36,30 56,10", fill: "none", stroke: c(0), strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }), [
|
|
18
16
|
[8, 38],
|
|
19
17
|
[22, 26],
|
|
20
18
|
[36, 30],
|
|
21
19
|
[56, 10],
|
|
22
20
|
].map(([cx, cy]) => (_jsx("circle", { cx: cx, cy: cy, r: "3", fill: c(0) }, `${cx}-${cy}`)))] })),
|
|
23
|
-
area: () => (_jsxs(_Fragment, { children: [_jsx("path", { d: "M8 38 L22 26 L36 30 L56 10 L56 44 L8 44 Z", fill: c(0), fillOpacity: "0.3" }), _jsx("polyline", { points: "8,38 22,26 36,30 56,10", fill: "none", stroke: c(0), strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] })),
|
|
24
|
-
pie: () => (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "32", cy: "24", r: "18", fill: c(0) }), _jsx("path", { d: "M32 24 L32 6 A18 18 0 0 1 47.6 33 Z", fill: c(1) }), _jsx("path", { d: "M32 24 L47.6 33 A18 18 0 0 1 25.8 40.9 Z", fill: c(2) })] })),
|
|
25
|
-
donut: () => (_jsxs("g", { transform: "rotate(-90 32 24)", children: [_jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(0), strokeWidth: "8" }), _jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(1), strokeWidth: "8", strokeDasharray: "35 53" }), _jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(2), strokeWidth: "8", strokeDasharray: "20 68", strokeDashoffset: "-35" })] })),
|
|
21
|
+
area: (c) => (_jsxs(_Fragment, { children: [_jsx("path", { d: "M8 38 L22 26 L36 30 L56 10 L56 44 L8 44 Z", fill: c(0), fillOpacity: "0.3" }), _jsx("polyline", { points: "8,38 22,26 36,30 56,10", fill: "none", stroke: c(0), strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] })),
|
|
22
|
+
pie: (c) => (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "32", cy: "24", r: "18", fill: c(0) }), _jsx("path", { d: "M32 24 L32 6 A18 18 0 0 1 47.6 33 Z", fill: c(1) }), _jsx("path", { d: "M32 24 L47.6 33 A18 18 0 0 1 25.8 40.9 Z", fill: c(2) })] })),
|
|
23
|
+
donut: (c) => (_jsxs("g", { transform: "rotate(-90 32 24)", children: [_jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(0), strokeWidth: "8" }), _jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(1), strokeWidth: "8", strokeDasharray: "35 53" }), _jsx("circle", { cx: "32", cy: "24", r: "14", fill: "none", stroke: c(2), strokeWidth: "8", strokeDasharray: "20 68", strokeDashoffset: "-35" })] })),
|
|
26
24
|
};
|
|
27
25
|
export function ChartTypePreview({ type, size = 48 }) {
|
|
28
|
-
|
|
26
|
+
const { chart } = useDocumentBrand();
|
|
27
|
+
return (_jsx("svg", { width: size, height: size * 0.75, viewBox: "0 0 64 48", fill: "none", "aria-hidden": true, children: CHART_PREVIEWS[type]((index) => chart[index]) }));
|
|
29
28
|
}
|
|
30
29
|
function ChartCard({ type, name, onClick, }) {
|
|
31
30
|
const t = useMessages();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
2
|
import { type HandShapeType } from '@ggraphic/editor/utils/handDrawn';
|
|
2
3
|
import { type ShapeType } from '@ggraphic/editor/utils/shapes';
|
|
3
4
|
export interface FormenSectionProps {
|
|
@@ -22,5 +23,6 @@ export interface ShapeVariant {
|
|
|
22
23
|
important modifier) while the inserted fill stays the true brand color. */
|
|
23
24
|
darkPreviewClass: string;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
/** The colour variant of a shape tile in `brand` (the document's pack); the active brand by default. */
|
|
27
|
+
export declare function getShapeVariant(type: ShapeType, brand?: BrandPack): ShapeVariant;
|
|
26
28
|
export declare function FormenSection({ onAddShape, isExpanded, searchQuery, }: FormenSectionProps): import("react").JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
4
4
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
5
5
|
import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
|
|
6
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
6
7
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
7
8
|
import { handDrawnPath } from '@ggraphic/editor/utils/handDrawn';
|
|
8
9
|
import { defaultMarkerFill } from '@ggraphic/editor/utils/markerColors';
|
|
@@ -348,24 +349,34 @@ const MARKER_SHAPES = new Set(['hand-marker', 'hand-marker-box']);
|
|
|
348
349
|
* Brand color variants cycled across shape tiles (Canva-style); clicking inserts the
|
|
349
350
|
* shown color. Keyed by the shape's global palette index so the same shape shows the
|
|
350
351
|
* same color in the strip, the drill-down groups, and search results.
|
|
351
|
-
* The cycle is the brand's colour roles, so any
|
|
352
|
+
* The cycle is the pack's `shapeCycle`, else the brand's colour roles, so any
|
|
353
|
+
* brand fills it. Lazy for the
|
|
352
354
|
* same chunk-init reason as getShapesByCategory below, and because the host
|
|
353
355
|
* registers its brand at startup.
|
|
354
356
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
357
|
+
const shapeVariantsByPack = new WeakMap();
|
|
358
|
+
function shapeVariants(brand) {
|
|
359
|
+
let byType = shapeVariantsByPack.get(brand);
|
|
360
|
+
if (!byType) {
|
|
361
|
+
const { colors } = brand;
|
|
362
|
+
const palette = brandColors(brand);
|
|
363
|
+
const named = (brand.shapeCycle ?? []).flatMap((id) => palette.filter((c) => c.id === id).map((c) => c.value));
|
|
364
|
+
const cycle = named.length > 0 ? named : SHAPE_VARIANT_ROLES.map((role) => colors[role]);
|
|
365
|
+
const variants = cycle.map((color) => ({
|
|
366
|
+
color,
|
|
367
|
+
darkPreviewClass: color === colors.primary ? PRIMARY_PREVIEW_CLASS : '',
|
|
362
368
|
}));
|
|
363
|
-
|
|
369
|
+
byType = new Map(ALL_PALETTE_SHAPES.map((shape, index) => [shape.id, variants[index % variants.length]]));
|
|
370
|
+
shapeVariantsByPack.set(brand, byType);
|
|
364
371
|
}
|
|
372
|
+
return byType;
|
|
373
|
+
}
|
|
374
|
+
/** The colour variant of a shape tile in `brand` (the document's pack); the active brand by default. */
|
|
375
|
+
export function getShapeVariant(type, brand = activeBrand()) {
|
|
365
376
|
if (MARKER_SHAPES.has(type))
|
|
366
|
-
return { color: defaultMarkerFill(), darkPreviewClass: '' };
|
|
367
|
-
return (
|
|
368
|
-
color: brandColors()[0]?.value ?? EUCALYPTUS,
|
|
377
|
+
return { color: defaultMarkerFill(brand), darkPreviewClass: '' };
|
|
378
|
+
return (shapeVariants(brand).get(type) ?? {
|
|
379
|
+
color: brandColors(brand)[0]?.value ?? EUCALYPTUS,
|
|
369
380
|
darkPreviewClass: '',
|
|
370
381
|
});
|
|
371
382
|
}
|
|
@@ -399,6 +410,7 @@ function shapeMatchesQuery(shape, q) {
|
|
|
399
410
|
}
|
|
400
411
|
export function FormenSection({ onAddShape, isExpanded = false, searchQuery = '', }) {
|
|
401
412
|
const t = useMessages();
|
|
413
|
+
const brand = useDocumentBrand();
|
|
402
414
|
const q = searchQuery.trim().toLowerCase();
|
|
403
415
|
// Collapsed (mobile) view: flat first-N grid, no subheaders.
|
|
404
416
|
const collapsedShapes = useMemo(() => {
|
|
@@ -418,7 +430,7 @@ export function FormenSection({ onAddShape, isExpanded = false, searchQuery = ''
|
|
|
418
430
|
return groups;
|
|
419
431
|
}, [q]);
|
|
420
432
|
const renderShapeButton = (shape) => {
|
|
421
|
-
const variant = getShapeVariant(shape.id);
|
|
433
|
+
const variant = getShapeVariant(shape.id, brand);
|
|
422
434
|
return (_jsx("button", { className: SELECTABLE_CARD, onClick: () => onAddShape(shape.id, variant.color), title: t.common.addShape(t.shapes[shape.id]), children: _jsx("div", { className: cn(CARD_PREVIEW, variant.darkPreviewClass), style: { color: variant.color }, children: shape.renderPreview() }) }, shape.id));
|
|
423
435
|
};
|
|
424
436
|
if (!isExpanded) {
|
|
@@ -13,6 +13,7 @@ import { IoCheckmarkOutline, IoShareOutline } from 'react-icons/io5';
|
|
|
13
13
|
import { DownloadNotice } from '@ggraphic/editor/components/DownloadNotice';
|
|
14
14
|
import { AltTextField, useCaptionAltText, useShareAltText, withAltText, } from '@ggraphic/editor/sidebar/components/AltTextField';
|
|
15
15
|
import { SubsectionTabBar } from '../SubsectionTabBar.js';
|
|
16
|
+
import { EDITOR_SCOPE } from '../../ui/editorScope.js';
|
|
16
17
|
const iconBtn = 'size-10 rounded-xl border-none bg-editor-tile cursor-pointer flex items-center justify-center text-foreground text-lg transition-[background-color,color,transform] duration-200 hover:bg-editor-active-bg hover:text-editor-active-fg active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed';
|
|
17
18
|
const primaryBtn = 'w-full py-2.5 px-4 rounded-lg border-none bg-primary-600 text-white font-medium text-sm cursor-pointer flex items-center justify-center gap-2 transition-[background-color,transform] duration-200 hover:bg-primary-700 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed';
|
|
18
19
|
const secondaryBtn = 'w-full py-2 px-4 rounded-lg border border-editor-border bg-transparent text-foreground font-medium text-sm cursor-pointer flex items-center justify-center gap-2 transition-[background-color,border-color] duration-200 hover:bg-editor-surface-hover';
|
|
@@ -206,10 +207,10 @@ function DownloadShareSubsection({ exportedImage, shareToken, onCaptureCanvas, c
|
|
|
206
207
|
}, [isMultiPage, onShareAllPages, shareDropdown, handleNativeShare]);
|
|
207
208
|
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("h3", { className: "text-sm font-semibold text-foreground m-0", children: t.shell.downloadAndShare }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("div", { className: "relative", children: [_jsx("button", { ref: dlDropdown.triggerRef, className: iconBtn, onClick: handleDownloadClick, disabled: downloadState !== 'idle' && !isMultiPage, title: t.shell.download, "aria-label": t.shell.downloadImage, "aria-haspopup": isMultiPage ? 'menu' : undefined, "aria-expanded": isMultiPage ? dlDropdown.open : undefined, type: "button", children: downloadState === 'capturing' ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : downloadState === 'success' ? (_jsx(PiCheck, {})) : (_jsx(PiDownloadSimple, {})) }), dlDropdown.open &&
|
|
208
209
|
isMultiPage &&
|
|
209
|
-
createPortal(_jsxs("div", { ref: dlDropdown.menuRef, className: dropdownMenu, style: dlDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleSingleDownload, role: "menuitem", type: "button", children: [_jsx(PiFileImage, {}), _jsx("span", { children: t.shell.thisPagePng })] }), _jsx("button", { className: dropdownOption, onClick: handleDownloadAllZip, disabled: isMultiExporting, role: "menuitem", type: "button", children: isMultiExporting ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "size-4 rounded-full" }), _jsx("span", { children: t.shell.exporting })] })) : (_jsxs(_Fragment, { children: [_jsx(PiFileZip, {}), _jsx("span", { children: t.shell.allPagesZip(pageCount) })] })) })] }), document.body)] }), shareRoute !== null && (_jsxs("div", { className: "relative", children: [_jsx("button", { ref: shareDropdown.triggerRef, className: iconBtn, onClick: handleShareClick, disabled: isSharing, title: t.shell.share, "aria-label": t.shell.shareImage, "aria-haspopup": isMultiPage && onShareAllPages ? 'menu' : undefined, "aria-expanded": isMultiPage && onShareAllPages ? shareDropdown.open : undefined, type: "button", children: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})) }), shareDropdown.open &&
|
|
210
|
+
createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: dlDropdown.menuRef, className: dropdownMenu, style: dlDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleSingleDownload, role: "menuitem", type: "button", children: [_jsx(PiFileImage, {}), _jsx("span", { children: t.shell.thisPagePng })] }), _jsx("button", { className: dropdownOption, onClick: handleDownloadAllZip, disabled: isMultiExporting, role: "menuitem", type: "button", children: isMultiExporting ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "size-4 rounded-full" }), _jsx("span", { children: t.shell.exporting })] })) : (_jsxs(_Fragment, { children: [_jsx(PiFileZip, {}), _jsx("span", { children: t.shell.allPagesZip(pageCount) })] })) })] }), document.body)] }), shareRoute !== null && (_jsxs("div", { className: "relative", children: [_jsx("button", { ref: shareDropdown.triggerRef, className: iconBtn, onClick: handleShareClick, disabled: isSharing, title: t.shell.share, "aria-label": t.shell.shareImage, "aria-haspopup": isMultiPage && onShareAllPages ? 'menu' : undefined, "aria-expanded": isMultiPage && onShareAllPages ? shareDropdown.open : undefined, type: "button", children: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})) }), shareDropdown.open &&
|
|
210
211
|
isMultiPage &&
|
|
211
212
|
onShareAllPages &&
|
|
212
|
-
createPortal(_jsxs("div", { ref: shareDropdown.menuRef, className: dropdownMenu, style: shareDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleNativeShare, role: "menuitem", type: "button", children: [_jsx(IoShareOutline, {}), _jsx("span", { children: t.shell.shareThisPage })] }), _jsxs("button", { className: dropdownOption, onClick: handleShareAllPages, disabled: isSharing, role: "menuitem", type: "button", children: [_jsx(PiImages, {}), _jsx("span", { children: t.shell.shareAllPages })] })] }), document.body)] }))] }), _jsx(AltTextField, { value: altText, onChange: setAltText }), isMultiExporting && exportProgress && exportProgress.total > 0 && (_jsxs("div", { className: "relative w-full h-6 bg-editor-tile rounded-full overflow-hidden", children: [_jsx("div", { className: "absolute inset-y-0 left-0 bg-primary-600 rounded-full transition-[width] duration-300", style: { width: `${(exportProgress.current / exportProgress.total) * 100}%` } }), _jsx("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium text-foreground", children: t.shell.pagesProgress(exportProgress.current, exportProgress.total) })] })), downloadError && _jsx(DownloadNotice, { children: downloadError }), exportNotice && _jsx(DownloadNotice, { tone: "info", children: exportNotice }), exportError && !isMultiExporting && (_jsxs(DownloadNotice, { children: [_jsx("span", { children: exportError }), lastExportOpRef.current && (_jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => void lastExportOpRef.current?.(), type: "button", children: t.shell.retry }))] })), downloadState === 'success' && autoSaveStatus === 'saving' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground-muted", children: [_jsx(Skeleton, { className: "size-3 rounded-full" }), _jsx("span", { children: t.shell.syncing })] })), downloadState === 'success' && autoSaveStatus === 'saved' && shareToken && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm text-primary-600", children: [_jsx(IoCheckmarkOutline, {}), _jsx("span", { children: t.shell.savedToGallery })] }), _jsxs("button", { className: secondaryBtn, onClick: onNavigateToGallery, type: "button", children: [_jsx(PiImages, {}), t.shell.toGallery] })] })), autoSaveStatus === 'error' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600", children: [_jsx("span", { children: t.shell.saveError }), _jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => autoSaveStoreApi.getState().retryAutoSave?.(), type: "button", children: t.shell.retry })] }))] }));
|
|
213
|
+
createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: shareDropdown.menuRef, className: dropdownMenu, style: shareDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleNativeShare, role: "menuitem", type: "button", children: [_jsx(IoShareOutline, {}), _jsx("span", { children: t.shell.shareThisPage })] }), _jsxs("button", { className: dropdownOption, onClick: handleShareAllPages, disabled: isSharing, role: "menuitem", type: "button", children: [_jsx(PiImages, {}), _jsx("span", { children: t.shell.shareAllPages })] })] }), document.body)] }))] }), _jsx(AltTextField, { value: altText, onChange: setAltText }), isMultiExporting && exportProgress && exportProgress.total > 0 && (_jsxs("div", { className: "relative w-full h-6 bg-editor-tile rounded-full overflow-hidden", children: [_jsx("div", { className: "absolute inset-y-0 left-0 bg-primary-600 rounded-full transition-[width] duration-300", style: { width: `${(exportProgress.current / exportProgress.total) * 100}%` } }), _jsx("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium text-foreground", children: t.shell.pagesProgress(exportProgress.current, exportProgress.total) })] })), downloadError && _jsx(DownloadNotice, { children: downloadError }), exportNotice && _jsx(DownloadNotice, { tone: "info", children: exportNotice }), exportError && !isMultiExporting && (_jsxs(DownloadNotice, { children: [_jsx("span", { children: exportError }), lastExportOpRef.current && (_jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => void lastExportOpRef.current?.(), type: "button", children: t.shell.retry }))] })), downloadState === 'success' && autoSaveStatus === 'saving' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground-muted", children: [_jsx(Skeleton, { className: "size-3 rounded-full" }), _jsx("span", { children: t.shell.syncing })] })), downloadState === 'success' && autoSaveStatus === 'saved' && shareToken && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm text-primary-600", children: [_jsx(IoCheckmarkOutline, {}), _jsx("span", { children: t.shell.savedToGallery })] }), _jsxs("button", { className: secondaryBtn, onClick: onNavigateToGallery, type: "button", children: [_jsx(PiImages, {}), t.shell.toGallery] })] })), autoSaveStatus === 'error' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600", children: [_jsx("span", { children: t.shell.saveError }), _jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => autoSaveStoreApi.getState().retryAutoSave?.(), type: "button", children: t.shell.retry })] }))] }));
|
|
213
214
|
}
|
|
214
215
|
/**
|
|
215
216
|
* The template flow itself belongs to the host — it knows the document
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { bindPatch } from '../../brand/bindPick.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
6
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
7
7
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
@@ -18,14 +18,15 @@ const MOOD_OPTIONS = [
|
|
|
18
18
|
/** Mood, colour and opacity of the illustration selected on the canvas. */
|
|
19
19
|
export function IllustrationSettings({ selectedIllustration, onUpdateIllustration, onRemoveIllustration, onDuplicateIllustration, }) {
|
|
20
20
|
const t = useMessages();
|
|
21
|
+
const brand = useDocumentBrand();
|
|
21
22
|
const isKawaiiSelected = selectedIllustration.source === 'kawaii';
|
|
22
23
|
const kawaiiInstance = isKawaiiSelected ? selectedIllustration : null;
|
|
23
24
|
return (_jsxs("div", { className: "flex flex-col gap-[var(--spacing-small)] p-[var(--spacing-small)] bg-background-alt rounded-[var(--border-radius-md)] mt-auto", children: [_jsxs("div", { className: SECTION_HEADER, children: [_jsx("span", { className: SECTION_TITLE, children: isKawaiiSelected ? t.sidebar.illustration.editCharacter : t.sidebar.illustration.edit }), onDuplicateIllustration && (_jsx("button", { className: ACTION_BTN, onClick: () => onDuplicateIllustration(selectedIllustration.id), title: t.commands.duplicate, children: _jsx(PiCopy, { size: 12 }) })), _jsx("button", { className: ACTION_BTN_DANGER, onClick: () => onRemoveIllustration(selectedIllustration.id), title: t.sidebar.imageAdjust.remove, children: _jsx(PiTrash, { size: 12 }) })] }), kawaiiInstance && (_jsxs("div", { className: "flex flex-col gap-xs", children: [_jsx("span", { className: "text-[length:var(--font-size-sm)] text-foreground-muted mb-xs", children: t.sidebar.illustration.mood }), _jsx("div", { className: "flex gap-xs flex-wrap", children: MOOD_OPTIONS.map((mood) => (_jsx("button", { className: cn('w-8 h-8 rounded-[var(--border-radius-md)] border border-[var(--border-default,rgba(0,0,0,0.1))] bg-background cursor-pointer text-lg flex items-center justify-center transition-all duration-150 p-0 hover:border-primary-600', kawaiiInstance.mood === mood.id &&
|
|
24
|
-
'border-primary-600 bg-[var(--primary-50,#e8f5e9)]'), onClick: () => onUpdateIllustration(kawaiiInstance.id, { mood: mood.id }), title: mood.id, children: mood.label }, mood.id))) })] })), selectedIllustration && (_jsxs("div", { className: "flex flex-col gap-xs", children: [_jsx("span", { className: "text-[length:var(--font-size-sm)] text-foreground-muted mb-xs", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex gap-[var(--spacing-small)] flex-wrap", children: [
|
|
25
|
+
'border-primary-600 bg-[var(--primary-50,#e8f5e9)]'), onClick: () => onUpdateIllustration(kawaiiInstance.id, { mood: mood.id }), title: mood.id, children: mood.label }, mood.id))) })] })), selectedIllustration && (_jsxs("div", { className: "flex flex-col gap-xs", children: [_jsx("span", { className: "text-[length:var(--font-size-sm)] text-foreground-muted mb-xs", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex gap-[var(--spacing-small)] flex-wrap", children: [brand.palette.map((color) => (_jsx("button", { className: cn('w-7 h-7 rounded-full border border-black/10 cursor-pointer transition-transform duration-150 relative p-0 hover:border-[var(--border-default,rgba(0,0,0,0.2))]', selectedIllustration.color === color.color &&
|
|
25
26
|
'after:content-[""] after:absolute after:-top-1 after:-left-1 after:-right-1 after:-bottom-1 after:border-2 after:border-primary-600 after:rounded-full'), style: { backgroundColor: color.color }, onClick: () => onUpdateIllustration(selectedIllustration.id, {
|
|
26
27
|
color: color.color,
|
|
27
28
|
...bindPatch(selectedIllustration.bind, 'color', color.color, color.ref),
|
|
28
|
-
}), title: color.label }, color.id))), _jsx(CustomColorSwatch, { value: selectedIllustration.color, presets:
|
|
29
|
+
}), title: color.label }, color.id))), _jsx(CustomColorSwatch, { value: selectedIllustration.color, presets: brand.palette.map((color) => color.color), onPick: (color) => onUpdateIllustration(selectedIllustration.id, {
|
|
29
30
|
color,
|
|
30
31
|
...bindPatch(selectedIllustration.bind, 'color', color),
|
|
31
32
|
}), className: "size-7", outlineOffset: 3 })] })] })), _jsx("div", { className: "flex flex-col gap-xs", children: _jsx(SidebarSlider, { value: selectedIllustration.opacity, onValueChange: (opacity) => onUpdateIllustration(selectedIllustration.id, { opacity }), min: 0.1, max: 1, step: 0.05, label: t.sidebar.illustration.transparency, unit: "%" }) })] }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
-
import {
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
4
4
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
5
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
6
|
import { Switch } from '@ggraphic/editor/ui/switch';
|
|
@@ -19,7 +19,8 @@ function naturalSize(src) {
|
|
|
19
19
|
}
|
|
20
20
|
const GROUP_LABEL = 'text-[11px] font-semibold uppercase tracking-wide text-foreground-muted';
|
|
21
21
|
export function ImageAdjustSection({ selectedImage, onUpdateImage, backgroundPhoto = null, brandScheme = null, }) {
|
|
22
|
-
const
|
|
22
|
+
const brand = useDocumentBrand();
|
|
23
|
+
const { tints, shadows } = brand.effects;
|
|
23
24
|
const t = useMessages();
|
|
24
25
|
const img = selectedImage;
|
|
25
26
|
const adj = img ?? backgroundPhoto?.adjustments ?? null;
|
|
@@ -29,7 +30,7 @@ export function ImageAdjustSection({ selectedImage, onUpdateImage, backgroundPho
|
|
|
29
30
|
// A look other than Duotone ends the duotone and the bindings of its two colours.
|
|
30
31
|
const applyPreset = (preset) => {
|
|
31
32
|
if (preset.id === 'duotone') {
|
|
32
|
-
const look = duotoneLook(img ?? undefined, brandScheme);
|
|
33
|
+
const look = duotoneLook(img ?? undefined, brandScheme, brand);
|
|
33
34
|
// The page background photo has no bindings to carry: it takes the colours only.
|
|
34
35
|
if (!look)
|
|
35
36
|
return;
|
|
@@ -66,13 +67,13 @@ export function ImageAdjustSection({ selectedImage, onUpdateImage, backgroundPho
|
|
|
66
67
|
return (_jsxs("div", { className: "flex flex-col gap-4 p-md w-full min-w-0", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-sm font-semibold text-foreground", children: t.sidebar.imageAdjust.title }), _jsx("button", { type: "button", onClick: () => set({ ...EMPTY_ADJUSTMENTS, ...(img ? withoutDuotone(img) : {}) }), className: "rounded-md px-2 py-1 text-xs text-foreground-muted hover:text-foreground", children: t.sidebar.imageAdjust.reset })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: GROUP_LABEL, children: "Presets" }), _jsx("div", { className: "grid grid-cols-3 gap-1.5", children: IMAGE_PRESETS.map((preset) => (_jsx("button", { type: "button", onClick: () => applyPreset(preset), className: "rounded-md border border-editor-border-strong px-2 py-1.5 text-xs text-foreground-muted transition-colors hover:border-primary-500 hover:text-foreground", children: preset.label }, preset.id))) })] }), img && (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: GROUP_LABEL, children: t.topBar.crop }), _jsx("div", { className: "grid grid-cols-4 gap-1.5", children: CROP_PRESETS.map((preset) => (_jsx("button", { type: "button", onClick: () => applyCrop(preset), className: "rounded-md border border-editor-border-strong px-2 py-1.5 text-xs text-foreground-muted transition-colors hover:border-primary-500 hover:text-foreground", children: preset.label }, preset.id))) })] })), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.flip }), _jsx("div", { className: "grid grid-cols-2 gap-1.5", children: [
|
|
67
68
|
['flipX', t.sidebar.imageAdjust.horizontal],
|
|
68
69
|
['flipY', t.sidebar.imageAdjust.vertical],
|
|
69
|
-
].map(([key, label]) => (_jsx("button", { type: "button", "aria-pressed": !!adj[key], onClick: () => set({ [key]: !adj[key] }), className: "rounded-md border border-editor-border-strong px-2 py-1.5 text-xs text-foreground-muted transition-colors hover:border-primary-500 hover:text-foreground aria-pressed:border-primary-500 aria-pressed:text-foreground", children: label }, key))) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.tint }), _jsxs("div", { className: "flex items-center gap-1.5", children: [tints.map((c) => (_jsx("button", { type: "button", onClick: () => setTint({ tint: c, tintStrength: adj.tintStrength || 1 }), title: colorName(c), "aria-label": t.sidebar.imageAdjust.tintIn(colorName(c)), "aria-pressed": (adj.tint ?? defaultTint()) === c && !!adj.tintStrength, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110", style: {
|
|
70
|
+
].map(([key, label]) => (_jsx("button", { type: "button", "aria-pressed": !!adj[key], onClick: () => set({ [key]: !adj[key] }), className: "rounded-md border border-editor-border-strong px-2 py-1.5 text-xs text-foreground-muted transition-colors hover:border-primary-500 hover:text-foreground aria-pressed:border-primary-500 aria-pressed:text-foreground", children: label }, key))) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.tint }), _jsxs("div", { className: "flex items-center gap-1.5", children: [tints.map((c) => (_jsx("button", { type: "button", onClick: () => setTint({ tint: c, tintStrength: adj.tintStrength || 1 }), title: colorName(c, brand), "aria-label": t.sidebar.imageAdjust.tintIn(colorName(c, brand)), "aria-pressed": (adj.tint ?? defaultTint()) === c && !!adj.tintStrength, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110", style: {
|
|
70
71
|
backgroundColor: c,
|
|
71
72
|
outline: (adj.tint ?? defaultTint()) === c && adj.tintStrength
|
|
72
73
|
? '2px solid var(--editor-accent)'
|
|
73
74
|
: 'none',
|
|
74
75
|
outlineOffset: '2px',
|
|
75
|
-
} }, c))), _jsx(CustomColorSwatch, { value: adj.tintStrength ? adj.tint : null, presets: tints, onPick: (color) => setTint({ tint: color, tintStrength: adj.tintStrength || 1 }), className: "size-6" })] }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.intensity, value: adj.tintStrength ?? 0, onValueChange: (v) => set({ tintStrength: v }), min: 0, max: 1, step: 0.05, unit: "%" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.whiteBalance }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.colorTemperature, value: adj.temperature ?? 0, onValueChange: (v) => set({ temperature: v }), min: -100, max: 100, step: 1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.hue, value: adj.hue ?? 0, onValueChange: (v) => set({ hue: v }), min: 0, max: 360, step: 1 })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.light }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.brightness, value: adj.brightness ?? 0, onValueChange: (v) => set({ brightness: v }), min: -1, max: 1, step: 0.05 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.contrast, value: adj.contrast ?? 0, onValueChange: (v) => set({ contrast: v }), min: -100, max: 100, step: 1 })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.colorAndSharpness }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.saturation, value: adj.saturation ?? 0, onValueChange: (v) => set({ saturation: v }), min: -2, max: 10, step: 0.1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.blur, value: adj.blur ?? 0, onValueChange: (v) => set({ blur: v }), min: 0, max: 40, step: 1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.vignette, value: adj.vignette ?? 0, onValueChange: (v) => set({ vignette: v }), min: 0, max: 1, step: 0.05, unit: "%" })] }), img && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: GROUP_LABEL, children: t.topBar.shadow }), _jsx("button", { type: "button", onClick: toggleShadow, className: "text-[11px] font-medium text-primary-600 hover:underline", children: shadowOn ? t.sidebar.imageAdjust.remove : t.sidebar.imageAdjust.enable })] }), shadowOn && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-1.5", children: [shadows.map((c) => (_jsx("button", { type: "button", onClick: () => setShadow({ shadowColor: c }), title: colorName(c), "aria-label": colorName(c), "aria-pressed": img.shadowColor === c, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110", style: {
|
|
76
|
+
} }, c))), _jsx(CustomColorSwatch, { value: adj.tintStrength ? adj.tint : null, presets: tints, onPick: (color) => setTint({ tint: color, tintStrength: adj.tintStrength || 1 }), className: "size-6" })] }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.intensity, value: adj.tintStrength ?? 0, onValueChange: (v) => set({ tintStrength: v }), min: 0, max: 1, step: 0.05, unit: "%" })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.whiteBalance }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.colorTemperature, value: adj.temperature ?? 0, onValueChange: (v) => set({ temperature: v }), min: -100, max: 100, step: 1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.hue, value: adj.hue ?? 0, onValueChange: (v) => set({ hue: v }), min: 0, max: 360, step: 1 })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.light }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.brightness, value: adj.brightness ?? 0, onValueChange: (v) => set({ brightness: v }), min: -1, max: 1, step: 0.05 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.contrast, value: adj.contrast ?? 0, onValueChange: (v) => set({ contrast: v }), min: -100, max: 100, step: 1 })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("span", { className: GROUP_LABEL, children: t.sidebar.imageAdjust.colorAndSharpness }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.saturation, value: adj.saturation ?? 0, onValueChange: (v) => set({ saturation: v }), min: -2, max: 10, step: 0.1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.blur, value: adj.blur ?? 0, onValueChange: (v) => set({ blur: v }), min: 0, max: 40, step: 1 }), _jsx(SidebarSlider, { label: t.sidebar.imageAdjust.vignette, value: adj.vignette ?? 0, onValueChange: (v) => set({ vignette: v }), min: 0, max: 1, step: 0.05, unit: "%" })] }), img && (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: GROUP_LABEL, children: t.topBar.shadow }), _jsx("button", { type: "button", onClick: toggleShadow, className: "text-[11px] font-medium text-primary-600 hover:underline", children: shadowOn ? t.sidebar.imageAdjust.remove : t.sidebar.imageAdjust.enable })] }), shadowOn && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-1.5", children: [shadows.map((c) => (_jsx("button", { type: "button", onClick: () => setShadow({ shadowColor: c }), title: colorName(c, brand), "aria-label": colorName(c, brand), "aria-pressed": img.shadowColor === c, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110", style: {
|
|
76
77
|
backgroundColor: c,
|
|
77
78
|
outline: img.shadowColor === c ? '2px solid var(--editor-accent)' : 'none',
|
|
78
79
|
outlineOffset: '2px',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
4
|
import { plainAssetImageUrls, registeredAssetCatalog } from '@ggraphic/editor/utils/canvasAssets';
|
|
4
5
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
5
6
|
import { Icon } from '@iconify/react';
|
|
@@ -20,10 +21,11 @@ export function thumbNeedsDarkTile(thumb) {
|
|
|
20
21
|
return thumb.t === 'img' && thumb.inverse === true;
|
|
21
22
|
}
|
|
22
23
|
function ShapeThumb({ shapeType }) {
|
|
24
|
+
const brand = useDocumentBrand();
|
|
23
25
|
const shape = PALETTE_BY_TYPE.get(shapeType);
|
|
24
26
|
if (!shape)
|
|
25
27
|
return null;
|
|
26
|
-
const variant = getShapeVariant(shapeType);
|
|
28
|
+
const variant = getShapeVariant(shapeType, brand);
|
|
27
29
|
return (_jsx("span", { className: cn('inline-flex items-center justify-center scale-[1.45]', variant.darkPreviewClass), style: { color: variant.color }, children: shape.renderPreview() }));
|
|
28
30
|
}
|
|
29
31
|
export function ElementThumb({ thumb, eager = false, }) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
1
2
|
import { type UniversalAsset } from '@ggraphic/editor/utils/canvasAssets';
|
|
2
3
|
import { type ReactNode } from 'react';
|
|
3
4
|
import type { ElementBlocks } from './elementPanelHost.js';
|
|
@@ -20,7 +21,7 @@ export interface CatalogCategory {
|
|
|
20
21
|
searchable: boolean;
|
|
21
22
|
}
|
|
22
23
|
export declare function assetItem(asset: UniversalAsset): ElementItem;
|
|
23
|
-
export declare
|
|
24
|
+
export declare function shapeItems(brand: BrandPack): ElementItem[];
|
|
24
25
|
export declare const CHART_ITEMS: ElementItem[];
|
|
25
26
|
export declare const FRAME_ITEMS: ElementItem[];
|
|
26
27
|
export declare function illustrationItem(def: IllustrationDef): ElementItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
3
|
import { useCanvasEditorServices } from '@ggraphic/editor/CanvasEditorProvider';
|
|
4
4
|
import { useAllIconsCatalog, useIconCatalog } from '@ggraphic/editor/hooks/useIconCatalog';
|
|
5
5
|
import { useNoStudioAssets } from '@ggraphic/editor/hostServices';
|
|
@@ -28,18 +28,31 @@ export function assetItem(asset) {
|
|
|
28
28
|
thumb: { t: 'img', src: asset.src, ...(hasDarkPreview(asset) ? { inverse: true } : {}) },
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
31
|
+
/** The shape tiles in a pack's colours, built once per pack. */
|
|
32
|
+
const shapeItemsByPack = new WeakMap();
|
|
33
|
+
export function shapeItems(brand) {
|
|
34
|
+
let items = shapeItemsByPack.get(brand);
|
|
35
|
+
if (!items) {
|
|
36
|
+
items = ALL_PALETTE_SHAPES.map((shape) => {
|
|
37
|
+
const def = getShapeDef(shape.id);
|
|
38
|
+
return {
|
|
39
|
+
key: `shape:${shape.id}`,
|
|
40
|
+
get label() {
|
|
41
|
+
return def.name;
|
|
42
|
+
},
|
|
43
|
+
keywords: def.tags,
|
|
44
|
+
action: {
|
|
45
|
+
kind: 'shape',
|
|
46
|
+
shapeType: shape.id,
|
|
47
|
+
color: getShapeVariant(shape.id, brand).color,
|
|
48
|
+
},
|
|
49
|
+
thumb: { t: 'shape', shapeType: shape.id },
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
shapeItemsByPack.set(brand, items);
|
|
53
|
+
}
|
|
54
|
+
return items;
|
|
55
|
+
}
|
|
43
56
|
export const CHART_ITEMS = CHART_TYPE_DEFS.map((def) => ({
|
|
44
57
|
key: `chart:${def.id}`,
|
|
45
58
|
get label() {
|
|
@@ -166,6 +179,7 @@ export function useElementCatalog(props, needFull,
|
|
|
166
179
|
/** Skin tone of the emoji tiles: 0 default, 1–5 light → dark. */
|
|
167
180
|
emojiTone = 0) {
|
|
168
181
|
const t = useMessages();
|
|
182
|
+
const shapes = shapeItems(useDocumentBrand());
|
|
169
183
|
const { userLocale = 'de-DE', fetchStockImages } = useCanvasEditorServices();
|
|
170
184
|
const panelHost = registeredAssetCatalog().elementPanel;
|
|
171
185
|
const locale = userLocale;
|
|
@@ -287,8 +301,8 @@ emojiTone = 0) {
|
|
|
287
301
|
push({
|
|
288
302
|
id: 'formen',
|
|
289
303
|
label: t.sidebar.elements.categories.shapes,
|
|
290
|
-
count:
|
|
291
|
-
items:
|
|
304
|
+
count: shapes.length,
|
|
305
|
+
items: shapes,
|
|
292
306
|
isLoading: false,
|
|
293
307
|
searchable: true,
|
|
294
308
|
});
|
|
@@ -354,6 +368,7 @@ emojiTone = 0) {
|
|
|
354
368
|
photos.isLoading,
|
|
355
369
|
props.onSetBackgroundImage,
|
|
356
370
|
props.onAddShape,
|
|
371
|
+
shapes,
|
|
357
372
|
props.onAddChart,
|
|
358
373
|
props.onAddFrame,
|
|
359
374
|
hasIllustrations,
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { Slider } from 'radix-ui';
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
4
5
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
5
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
7
|
import { EffectCard } from '@ggraphic/editor/sidebar/sections/effects/EffectCard';
|
|
7
8
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
8
9
|
import { createDefaultGradient } from '@ggraphic/editor/utils/gradientFill';
|
|
9
10
|
function StopSwatches({ selected, onSelect, }) {
|
|
10
|
-
|
|
11
|
+
const brand = useDocumentBrand();
|
|
12
|
+
return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { className: "size-6 rounded-full border border-black/10 hover:scale-110 transition-transform", style: {
|
|
11
13
|
backgroundColor: c.value,
|
|
12
14
|
outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
|
|
13
15
|
outlineOffset: '1px',
|
|
14
|
-
}, onClick: () => onSelect(c.value), title: c.name, "aria-label": c.name, "aria-pressed": selected === c.value, type: "button" }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-5", outlineOffset: 1 })] }));
|
|
16
|
+
}, onClick: () => onSelect(c.value), title: c.name, "aria-label": c.name, "aria-pressed": selected === c.value, type: "button" }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors(brand).map((c) => c.value), onPick: onSelect, className: "size-5", outlineOffset: 1 })] }));
|
|
15
17
|
}
|
|
16
18
|
/** Farbverlauf einer Form oder eines freien Textes, im Bereich „Effekte“. */
|
|
17
19
|
export function GradientSettings({ currentColor, gradient, onChange }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { Slider } from 'radix-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
6
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
7
7
|
import { EffectCard } from '@ggraphic/editor/sidebar/sections/effects/EffectCard';
|
|
@@ -9,7 +9,8 @@ import { colorName } from '@ggraphic/editor/utils/colorNames';
|
|
|
9
9
|
const DEFAULT_WIDTH = 2;
|
|
10
10
|
/** Kontur eines freien Textes, im Bereich „Effekte“. */
|
|
11
11
|
export function OutlineSettings({ stroke, strokeWidth, onChange }) {
|
|
12
|
-
const
|
|
12
|
+
const brand = useDocumentBrand();
|
|
13
|
+
const { outlines } = brand.effects;
|
|
13
14
|
const t = useMessages();
|
|
14
15
|
const enabled = !!stroke && (strokeWidth ?? 0) > 0;
|
|
15
16
|
const toggle = () => {
|
|
@@ -24,5 +25,5 @@ export function OutlineSettings({ stroke, strokeWidth, onChange }) {
|
|
|
24
25
|
backgroundColor: c,
|
|
25
26
|
outline: stroke === c ? '2px solid var(--editor-accent)' : 'none',
|
|
26
27
|
outlineOffset: '2px',
|
|
27
|
-
}, onClick: () => onChange({ stroke: c }), title: colorName(c), "aria-label": colorName(c), "aria-pressed": stroke === c, type: "button" }, c))), _jsx(CustomColorSwatch, { value: stroke, presets: outlines, onPick: (color) => onChange({ stroke: color }), className: "size-6" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-[11px] w-12 text-[var(--editor-text-muted)]", children: t.topBar.strength }), _jsxs(Slider.Root, { className: "relative flex items-center select-none touch-none grow h-4 max-canvas-mobile:h-11", value: [strokeWidth ?? DEFAULT_WIDTH], onValueChange: (v) => onChange({ strokeWidth: v[0] }), min: 0.5, max: 12, step: 0.5, children: [_jsx(Slider.Track, { className: "relative grow rounded-full h-1 bg-[var(--editor-border-soft)]", children: _jsx(Slider.Range, { className: "absolute rounded-full h-full bg-[var(--editor-accent)]" }) }), _jsx(Slider.Thumb, { className: "block size-3 max-canvas-mobile:size-5 bg-white rounded-full border-2 border-[var(--editor-accent)] shadow-[0_1px_3px_rgba(0,0,0,0.2)] cursor-grab focus:outline-none", "aria-label": t.topBar.outlineWidth })] }), _jsx("span", { className: "text-[11px] w-8 text-right tabular-nums text-[var(--editor-text-muted)]", children: strokeWidth ?? DEFAULT_WIDTH })] })] }));
|
|
28
|
+
}, onClick: () => onChange({ stroke: c }), title: colorName(c, brand), "aria-label": colorName(c, brand), "aria-pressed": stroke === c, type: "button" }, c))), _jsx(CustomColorSwatch, { value: stroke, presets: outlines, onPick: (color) => onChange({ stroke: color }), className: "size-6" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-[11px] w-12 text-[var(--editor-text-muted)]", children: t.topBar.strength }), _jsxs(Slider.Root, { className: "relative flex items-center select-none touch-none grow h-4 max-canvas-mobile:h-11", value: [strokeWidth ?? DEFAULT_WIDTH], onValueChange: (v) => onChange({ strokeWidth: v[0] }), min: 0.5, max: 12, step: 0.5, children: [_jsx(Slider.Track, { className: "relative grow rounded-full h-1 bg-[var(--editor-border-soft)]", children: _jsx(Slider.Range, { className: "absolute rounded-full h-full bg-[var(--editor-accent)]" }) }), _jsx(Slider.Thumb, { className: "block size-3 max-canvas-mobile:size-5 bg-white rounded-full border-2 border-[var(--editor-accent)] shadow-[0_1px_3px_rgba(0,0,0,0.2)] cursor-grab focus:outline-none", "aria-label": t.topBar.outlineWidth })] }), _jsx("span", { className: "text-[11px] w-8 text-right tabular-nums text-[var(--editor-text-muted)]", children: strokeWidth ?? DEFAULT_WIDTH })] })] }));
|
|
28
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { Slider } from 'radix-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
6
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
7
7
|
import { EffectCard } from '@ggraphic/editor/sidebar/sections/effects/EffectCard';
|
|
@@ -18,7 +18,8 @@ function LabeledSlider({ label, value, min, max, step, suffix, onValueChange, })
|
|
|
18
18
|
}
|
|
19
19
|
/** Schatten einer Form oder eines freien Textes, im Bereich „Effekte“. */
|
|
20
20
|
export function ShadowSettings({ shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY, shadowOpacity, onChange, }) {
|
|
21
|
-
const
|
|
21
|
+
const brand = useDocumentBrand();
|
|
22
|
+
const { shadows } = brand.effects;
|
|
22
23
|
const t = useMessages();
|
|
23
24
|
const enabled = !!shadowColor;
|
|
24
25
|
const toggle = () => {
|
|
@@ -33,5 +34,5 @@ export function ShadowSettings({ shadowColor, shadowBlur, shadowOffsetX, shadowO
|
|
|
33
34
|
backgroundColor: c,
|
|
34
35
|
outline: shadowColor === c ? '2px solid var(--editor-accent)' : 'none',
|
|
35
36
|
outlineOffset: '2px',
|
|
36
|
-
}, onClick: () => onChange({ shadowColor: c }), title: colorName(c), "aria-label": colorName(c), "aria-pressed": shadowColor === c, type: "button" }, c))), _jsx(CustomColorSwatch, { value: shadowColor, presets: shadows, onPick: (color) => onChange({ shadowColor: color }), className: "size-6" })] }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.softness, value: shadowBlur ?? 0, min: 0, max: 40, step: 1, onValueChange: (v) => onChange({ shadowBlur: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.offsetX, value: shadowOffsetX ?? 0, min: -40, max: 40, step: 1, onValueChange: (v) => onChange({ shadowOffsetX: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.offsetY, value: shadowOffsetY ?? 0, min: -40, max: 40, step: 1, onValueChange: (v) => onChange({ shadowOffsetY: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.opacity, value: (shadowOpacity ?? 0) * 100, min: 0, max: 100, step: 1, suffix: "%", onValueChange: (v) => onChange({ shadowOpacity: v / 100 }) })] }));
|
|
37
|
+
}, onClick: () => onChange({ shadowColor: c }), title: colorName(c, brand), "aria-label": colorName(c, brand), "aria-pressed": shadowColor === c, type: "button" }, c))), _jsx(CustomColorSwatch, { value: shadowColor, presets: shadows, onPick: (color) => onChange({ shadowColor: color }), className: "size-6" })] }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.softness, value: shadowBlur ?? 0, min: 0, max: 40, step: 1, onValueChange: (v) => onChange({ shadowBlur: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.offsetX, value: shadowOffsetX ?? 0, min: -40, max: 40, step: 1, onValueChange: (v) => onChange({ shadowOffsetX: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.offsetY, value: shadowOffsetY ?? 0, min: -40, max: 40, step: 1, onValueChange: (v) => onChange({ shadowOffsetY: v }) }), _jsx(LabeledSlider, { label: t.sidebar.imageAdjust.opacity, value: (shadowOpacity ?? 0) * 100, min: 0, max: 100, step: 1, suffix: "%", onValueChange: (v) => onChange({ shadowOpacity: v / 100 }) })] }));
|
|
37
38
|
}
|