@ggraphic/editor 0.0.0 → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/brand/brandRegistry.d.ts +11 -3
  2. package/dist/brand/brandRegistry.js +18 -3
  3. package/dist/brand/documentBrand.d.ts +16 -0
  4. package/dist/brand/documentBrand.js +6 -0
  5. package/dist/components/CanvasEditor/CanvasEditorShell.js +39 -33
  6. package/dist/components/CanvasTextOverlay.js +4 -2
  7. package/dist/components/CustomColorSwatch.js +3 -2
  8. package/dist/components/GenericCanvas.js +9 -2
  9. package/dist/components/RichTextField.js +5 -1
  10. package/dist/components/TextFormatButtons.js +6 -22
  11. package/dist/components/TopBar/ContextControls.js +4 -2
  12. package/dist/components/TopBar/modules/FloatingColorPicker.js +3 -1
  13. package/dist/components/TopBar/modules/FloatingFontRoleControl.js +2 -2
  14. package/dist/components/kindRenderers.d.ts +1 -1
  15. package/dist/components/markerMark.d.ts +6 -1
  16. package/dist/components/markerMark.js +7 -11
  17. package/dist/configs/factory/actionFactories.d.ts +38 -9
  18. package/dist/configs/factory/actionFactories.js +53 -36
  19. package/dist/configs/types.d.ts +13 -2
  20. package/dist/export/pptx/buildPptxModel.d.ts +3 -0
  21. package/dist/export/pptx/buildPptxModel.js +5 -5
  22. package/dist/export/pptx/exportPptxDeck.d.ts +4 -1
  23. package/dist/export/pptx/exportPptxDeck.js +5 -2
  24. package/dist/export/pptx/textModel.d.ts +6 -2
  25. package/dist/export/pptx/textModel.js +14 -11
  26. package/dist/hooks/useFloatingModuleHandlers.js +2 -2
  27. package/dist/hooks/useMultiPageExport.js +1 -1
  28. package/dist/i18n/de.d.ts +2 -0
  29. package/dist/i18n/de.js +2 -0
  30. package/dist/i18n/en.js +1 -0
  31. package/dist/primitives/CanvasRichText.js +7 -4
  32. package/dist/primitives/CanvasStage.js +3 -2
  33. package/dist/primitives/UserImagePrimitive.js +3 -1
  34. package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
  35. package/dist/sidebar/sections/ChartSettingsSection.js +5 -2
  36. package/dist/sidebar/sections/CombinedTextSection.js +3 -2
  37. package/dist/sidebar/sections/DiagrammeSection.js +10 -11
  38. package/dist/sidebar/sections/FormenSection.d.ts +3 -1
  39. package/dist/sidebar/sections/FormenSection.js +25 -13
  40. package/dist/sidebar/sections/IllustrationSettings.js +4 -3
  41. package/dist/sidebar/sections/ImageAdjustSection.js +6 -5
  42. package/dist/sidebar/sections/assets/ElementThumb.js +3 -1
  43. package/dist/sidebar/sections/assets/useElementCatalog.d.ts +2 -1
  44. package/dist/sidebar/sections/assets/useElementCatalog.js +30 -15
  45. package/dist/sidebar/sections/effects/GradientSettings.js +4 -2
  46. package/dist/sidebar/sections/effects/OutlineSettings.js +4 -3
  47. package/dist/sidebar/sections/effects/ShadowSettings.js +4 -3
  48. package/dist/sidebar/sections/tools/BlobCreatorTool.js +11 -6
  49. package/dist/sidebar/sections/tools/GradientTextTool.js +14 -12
  50. package/dist/sidebar/sections/tools/TextPathCreatorTool.js +15 -13
  51. package/dist/sidebar/sections/tools/ToolsSection.js +5 -3
  52. package/dist/testing/documentBrandConfig.d.ts +14 -0
  53. package/dist/testing/documentBrandConfig.js +60 -0
  54. package/dist/testing/documentBrandPacks.d.ts +10 -0
  55. package/dist/testing/documentBrandPacks.js +45 -0
  56. package/dist/ui/button.d.ts +2 -2
  57. package/dist/utils/canvasAssets.d.ts +7 -1
  58. package/dist/utils/circleBadgeUtils.d.ts +3 -1
  59. package/dist/utils/circleBadgeUtils.js +5 -5
  60. package/dist/utils/colorNames.d.ts +7 -2
  61. package/dist/utils/colorNames.js +14 -5
  62. package/dist/utils/fontMarkSupport.d.ts +1 -0
  63. package/dist/utils/fontMarkSupport.js +7 -1
  64. package/dist/utils/frameUtils.d.ts +3 -2
  65. package/dist/utils/frameUtils.js +3 -2
  66. package/dist/utils/illustrations/registry.d.ts +4 -1
  67. package/dist/utils/illustrations/registry.js +5 -3
  68. package/dist/utils/illustrations/svgCache.js +13 -6
  69. package/dist/utils/illustrations/types.d.ts +1 -1
  70. package/dist/utils/imageFilters.d.ts +4 -2
  71. package/dist/utils/imageFilters.js +3 -2
  72. package/dist/utils/imageLook.d.ts +4 -2
  73. package/dist/utils/imageLook.js +4 -2
  74. package/dist/utils/markerBoxes.d.ts +16 -1
  75. package/dist/utils/markerBoxes.js +2 -15
  76. package/dist/utils/markerColors.d.ts +12 -5
  77. package/dist/utils/markerColors.js +8 -15
  78. package/dist/utils/photoPlaceholder.d.ts +4 -1
  79. package/dist/utils/photoPlaceholder.js +5 -3
  80. package/dist/utils/pillBadgeUtils.d.ts +3 -2
  81. package/dist/utils/pillBadgeUtils.js +5 -5
  82. package/dist/utils/shapes.d.ts +4 -2
  83. package/dist/utils/shapes.js +4 -2
  84. package/dist/utils/textUtils.js +6 -2
  85. package/dist/utils/zipPageImages.d.ts +2 -1
  86. package/dist/utils/zipPageImages.js +3 -2
  87. package/package.json +3 -3
  88. package/dist/components/MobileSelectionPill.d.ts +0 -40
  89. package/dist/components/MobileSelectionPill.js +0 -85
  90. package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +0 -9
  91. package/dist/components/TopBar/modules/FloatingGradientControl.js +0 -35
  92. package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +0 -11
  93. package/dist/components/TopBar/modules/FloatingOutlineControl.js +0 -31
  94. package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +0 -12
  95. package/dist/components/TopBar/modules/FloatingShadowControl.js +0 -40
  96. package/dist/utils/balkenUtils.d.ts +0 -22
  97. package/dist/utils/balkenUtils.js +0 -8
@@ -10,7 +10,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
10
10
  import Konva from 'konva';
11
11
  import { useRef, useState, useEffect, forwardRef, useImperativeHandle, useCallback, } from 'react';
12
12
  import { Stage, Layer, Group, Rect } from 'react-konva';
13
- import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
13
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
14
14
  import { CanvasTextEditorProvider } from '@ggraphic/editor/components/CanvasTextOverlay';
15
15
  import { TransformHud } from '@ggraphic/editor/components/TransformHud';
16
16
  import { useHoverOutline } from '@ggraphic/editor/hooks/useHoverOutline';
@@ -91,6 +91,7 @@ function cancelTransforms(before) {
91
91
  }
92
92
  const exportMimeType = (options) => `image/${options.format || 'png'}`;
93
93
  export const CanvasStage = forwardRef(({ width, height, logicalWidth, logicalHeight, responsive = true, maxContainerWidth = 600, maxContainerHeight, onStageClick, listening = true, ariaLabel, children, overlay, className, style, }, ref) => {
94
+ const surface = useDocumentBrand().colors.surface;
94
95
  const displayStageRef = useRef(null);
95
96
  const containerDivRef = useRef(null);
96
97
  const [containerSize, setContainerSize] = useState({ width: 400, height: 400 });
@@ -286,6 +287,6 @@ export const CanvasStage = forwardRef(({ width, height, logicalWidth, logicalHei
286
287
  ...style,
287
288
  }, children: [_jsx(Stage, { ref: displayStageRef, width: containerSize.width, height: containerSize.height, scale: { x: displayScale, y: displayScale }, listening: listening, onMouseDown: onStageClick, onTouchStart: onStageClick, children: _jsx(Layer, { listening: listening, children: logicalWidth &&
288
289
  logicalHeight &&
289
- (logicalWidth !== width || logicalHeight !== height) ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: activeBrand().colors.surface }), _jsx(Group, { scaleX: width / logicalWidth, scaleY: height / logicalHeight, children: children })] })) : (children) }) }), overlay, _jsx(TransformHud, { stageRef: displayStageRef, enabled: listening })] }) }));
290
+ (logicalWidth !== width || logicalHeight !== height) ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: surface }), _jsx(Group, { scaleX: width / logicalWidth, scaleY: height / logicalHeight, children: children })] })) : (children) }) }), overlay, _jsx(TransformHud, { stageRef: displayStageRef, enabled: listening })] }) }));
290
291
  });
291
292
  CanvasStage.displayName = 'CanvasStage';
@@ -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, chartColors, chartLegendPosition, chartSeries, isRoundChartType, removeChartRow, removeChartSeries, renameChartSeries, setChartValue, } from '@ggraphic/editor/utils/chartUtils';
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 = chartColors(), }) {
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 { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
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: `${activeBrand().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: `${activeBrand().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
+ 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;
@@ -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 { chartColors, CHART_GROUP_LABELS, CHART_GROUP_ORDER, CHART_TYPE_DEFS, } from '@ggraphic/editor/utils/chartUtils';
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
- return (_jsx("svg", { width: size, height: size * 0.75, viewBox: "0 0 64 48", fill: "none", "aria-hidden": true, children: CHART_PREVIEWS[type]() }));
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
- export declare function getShapeVariant(type: ShapeType): ShapeVariant;
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 brand fills it. Lazy for the
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
- let shapeVariantByType = null;
356
- export function getShapeVariant(type) {
357
- if (!shapeVariantByType) {
358
- const { colors } = activeBrand();
359
- const variants = SHAPE_VARIANT_ROLES.map((role) => ({
360
- color: colors[role],
361
- darkPreviewClass: role === 'primary' ? PRIMARY_PREVIEW_CLASS : '',
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
- shapeVariantByType = new Map(ALL_PALETTE_SHAPES.map((shape, index) => [shape.id, variants[index % variants.length]]));
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 (shapeVariantByType.get(type) ?? {
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) {
@@ -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 { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
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: [activeBrand().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
+ '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: activeBrand().palette.map((color) => color.color), onPick: (color) => onUpdateIllustration(selectedIllustration.id, {
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 { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
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 { tints, shadows } = activeBrand().effects;
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 const SHAPE_ITEMS: ElementItem[];
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
- // SPDX-License-Identifier: MPL-2.0
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
- export const SHAPE_ITEMS = ALL_PALETTE_SHAPES.map((shape) => {
32
- const def = getShapeDef(shape.id);
33
- return {
34
- key: `shape:${shape.id}`,
35
- get label() {
36
- return def.name;
37
- },
38
- keywords: def.tags,
39
- action: { kind: 'shape', shapeType: shape.id, color: getShapeVariant(shape.id).color },
40
- thumb: { t: 'shape', shapeType: shape.id },
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: SHAPE_ITEMS.length,
291
- items: SHAPE_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
- return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { className: "size-6 rounded-full border border-black/10 hover:scale-110 transition-transform", style: {
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 { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
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 { outlines } = activeBrand().effects;
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 { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
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 { shadows } = activeBrand().effects;
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
  }