@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.
Files changed (136) hide show
  1. package/README.md +16 -3
  2. package/THIRD_PARTY_NOTICES +25 -1
  3. package/dist/brand/brandRegistry.d.ts +11 -3
  4. package/dist/brand/brandRegistry.js +18 -3
  5. package/dist/brand/documentBrand.d.ts +16 -0
  6. package/dist/brand/documentBrand.js +6 -0
  7. package/dist/components/CanvasContextMenu/CanvasActionSheet.js +2 -1
  8. package/dist/components/CanvasContextMenu/CanvasContextMenu.js +3 -2
  9. package/dist/components/CanvasEditor/CanvasEditorShell.js +43 -34
  10. package/dist/components/CanvasTextOverlay.js +14 -5
  11. package/dist/components/CustomColorSwatch.js +3 -2
  12. package/dist/components/GenericCanvas.js +21 -5
  13. package/dist/components/RichTextField.js +6 -1
  14. package/dist/components/SelectionPill.js +2 -1
  15. package/dist/components/TextFormatButtons.js +12 -23
  16. package/dist/components/TopBar/ContextControls.js +4 -2
  17. package/dist/components/TopBar/modules/FloatingColorPicker.js +3 -1
  18. package/dist/components/TopBar/modules/FloatingFontRoleControl.js +2 -2
  19. package/dist/components/kindRenderers.d.ts +1 -1
  20. package/dist/components/markerMark.d.ts +6 -1
  21. package/dist/components/markerMark.js +7 -11
  22. package/dist/configs/factory/actionFactories.d.ts +38 -9
  23. package/dist/configs/factory/actionFactories.js +53 -36
  24. package/dist/configs/types.d.ts +13 -2
  25. package/dist/export/pptx/buildPptxModel.d.ts +3 -0
  26. package/dist/export/pptx/buildPptxModel.js +5 -5
  27. package/dist/export/pptx/exportPptxDeck.d.ts +4 -1
  28. package/dist/export/pptx/exportPptxDeck.js +5 -2
  29. package/dist/export/pptx/textModel.d.ts +6 -2
  30. package/dist/export/pptx/textModel.js +14 -11
  31. package/dist/hooks/useFloatingModuleHandlers.js +2 -2
  32. package/dist/hooks/useMultiPageExport.js +1 -1
  33. package/dist/i18n/de.d.ts +14 -0
  34. package/dist/i18n/de.js +14 -0
  35. package/dist/i18n/en.js +12 -0
  36. package/dist/page/actions.d.ts +66 -0
  37. package/dist/page/actions.js +353 -0
  38. package/dist/page/config.d.ts +15 -0
  39. package/dist/page/config.js +91 -0
  40. package/dist/page/fitting.d.ts +6 -0
  41. package/dist/page/fitting.js +26 -0
  42. package/dist/page/hug.d.ts +10 -0
  43. package/dist/page/hug.js +18 -0
  44. package/dist/page/instantiate.d.ts +8 -0
  45. package/dist/page/instantiate.js +30 -0
  46. package/dist/page/logoSize.d.ts +8 -0
  47. package/dist/page/logoSize.js +29 -0
  48. package/dist/page/pageState.d.ts +41 -0
  49. package/dist/page/pageState.js +59 -0
  50. package/dist/page/seeds.d.ts +14 -0
  51. package/dist/page/seeds.js +40 -0
  52. package/dist/page/slotBudgets.d.ts +22 -0
  53. package/dist/page/slotBudgets.js +18 -0
  54. package/dist/page/templatePack.d.ts +31 -0
  55. package/dist/page/templatePack.js +55 -0
  56. package/dist/page/typography.d.ts +11 -0
  57. package/dist/page/typography.js +13 -0
  58. package/dist/primitives/CanvasRichText.js +7 -4
  59. package/dist/primitives/CanvasStage.js +3 -2
  60. package/dist/primitives/UserImagePrimitive.js +3 -1
  61. package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
  62. package/dist/sidebar/sections/ChartSettingsSection.js +5 -2
  63. package/dist/sidebar/sections/CombinedTextSection.js +4 -3
  64. package/dist/sidebar/sections/DiagrammeSection.js +10 -11
  65. package/dist/sidebar/sections/FormenSection.d.ts +3 -1
  66. package/dist/sidebar/sections/FormenSection.js +25 -13
  67. package/dist/sidebar/sections/GenericShareSection.js +3 -2
  68. package/dist/sidebar/sections/IllustrationSettings.js +4 -3
  69. package/dist/sidebar/sections/ImageAdjustSection.js +6 -5
  70. package/dist/sidebar/sections/assets/ElementThumb.js +3 -1
  71. package/dist/sidebar/sections/assets/useElementCatalog.d.ts +2 -1
  72. package/dist/sidebar/sections/assets/useElementCatalog.js +30 -15
  73. package/dist/sidebar/sections/effects/GradientSettings.js +4 -2
  74. package/dist/sidebar/sections/effects/OutlineSettings.js +4 -3
  75. package/dist/sidebar/sections/effects/ShadowSettings.js +4 -3
  76. package/dist/sidebar/sections/tools/BlobCreatorTool.js +11 -6
  77. package/dist/sidebar/sections/tools/GradientTextTool.js +14 -12
  78. package/dist/sidebar/sections/tools/TextPathCreatorTool.js +15 -13
  79. package/dist/sidebar/sections/tools/ToolsSection.js +5 -3
  80. package/dist/styles/compiled.css +2 -0
  81. package/dist/testing/documentBrandConfig.d.ts +14 -0
  82. package/dist/testing/documentBrandConfig.js +60 -0
  83. package/dist/testing/documentBrandPacks.d.ts +10 -0
  84. package/dist/testing/documentBrandPacks.js +45 -0
  85. package/dist/ui/alert-dialog.js +3 -2
  86. package/dist/ui/button.d.ts +2 -2
  87. package/dist/ui/dialog.js +3 -2
  88. package/dist/ui/editorScope.d.ts +10 -0
  89. package/dist/ui/editorScope.js +9 -0
  90. package/dist/ui/popover.js +2 -1
  91. package/dist/ui/select.js +2 -1
  92. package/dist/utils/canvasAssets.d.ts +7 -1
  93. package/dist/utils/canvasLayerManager.d.ts +14 -0
  94. package/dist/utils/canvasLayerManager.js +24 -0
  95. package/dist/utils/circleBadgeUtils.d.ts +3 -1
  96. package/dist/utils/circleBadgeUtils.js +5 -5
  97. package/dist/utils/colorNames.d.ts +7 -2
  98. package/dist/utils/colorNames.js +14 -5
  99. package/dist/utils/fontMarkSupport.d.ts +11 -0
  100. package/dist/utils/fontMarkSupport.js +27 -5
  101. package/dist/utils/frameUtils.d.ts +3 -2
  102. package/dist/utils/frameUtils.js +3 -2
  103. package/dist/utils/illustrations/registry.d.ts +4 -1
  104. package/dist/utils/illustrations/registry.js +5 -3
  105. package/dist/utils/illustrations/svgCache.js +13 -6
  106. package/dist/utils/illustrations/types.d.ts +1 -1
  107. package/dist/utils/imageFilters.d.ts +4 -2
  108. package/dist/utils/imageFilters.js +3 -2
  109. package/dist/utils/imageLook.d.ts +4 -2
  110. package/dist/utils/imageLook.js +4 -2
  111. package/dist/utils/layerLabels.js +3 -6
  112. package/dist/utils/markerBoxes.d.ts +16 -1
  113. package/dist/utils/markerBoxes.js +2 -15
  114. package/dist/utils/markerColors.d.ts +12 -5
  115. package/dist/utils/markerColors.js +8 -15
  116. package/dist/utils/photoPlaceholder.d.ts +4 -1
  117. package/dist/utils/photoPlaceholder.js +5 -3
  118. package/dist/utils/pillBadgeUtils.d.ts +3 -2
  119. package/dist/utils/pillBadgeUtils.js +5 -5
  120. package/dist/utils/shapes.d.ts +4 -2
  121. package/dist/utils/shapes.js +4 -2
  122. package/dist/utils/textUtils.js +2 -10
  123. package/dist/utils/zipPageImages.d.ts +2 -1
  124. package/dist/utils/zipPageImages.js +3 -2
  125. package/package.json +14 -7
  126. package/skills/ggraphic-embed/SKILL.md +145 -0
  127. package/dist/components/MobileSelectionPill.d.ts +0 -40
  128. package/dist/components/MobileSelectionPill.js +0 -85
  129. package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +0 -9
  130. package/dist/components/TopBar/modules/FloatingGradientControl.js +0 -35
  131. package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +0 -11
  132. package/dist/components/TopBar/modules/FloatingOutlineControl.js +0 -31
  133. package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +0 -12
  134. package/dist/components/TopBar/modules/FloatingShadowControl.js +0 -40
  135. package/dist/utils/balkenUtils.d.ts +0 -22
  136. package/dist/utils/balkenUtils.js +0 -8
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // SPDX-License-Identifier: MPL-2.0
2
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
3
3
  import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
4
4
  import { useMessages } from '@ggraphic/editor/i18n/messages';
5
5
  import { brandColors } from '@ggraphic/editor/utils/colorOptions';
@@ -14,8 +14,11 @@ const BASE_RADIUS = STAGE_SIZE * 0.38;
14
14
  const EXPORT_PIXEL_RATIO = 4; // 220 * 4 = 880px PNG
15
15
  const MAX_POINTS = 12;
16
16
  const TENSION = 0.6;
17
- /** The brand's fourth colour, read when the tool opens. */
18
- const defaultColor = () => brandColors()[3]?.value ?? brandColors()[0]?.value ?? '#000000';
17
+ /** The document brand's fourth colour, read when the tool opens. */
18
+ const defaultColor = (brand) => () => {
19
+ const palette = brandColors(brand);
20
+ return palette[3]?.value ?? palette[0]?.value ?? '#000000';
21
+ };
19
22
  function randomSeed() {
20
23
  return Array.from({ length: MAX_POINTS }, () => Math.random());
21
24
  }
@@ -36,23 +39,25 @@ function computeBlobPoints(seed, numPoints, irregularity) {
36
39
  }
37
40
  function ColorRow({ selected, onSelect, disabled, }) {
38
41
  const t = useMessages();
39
- return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
42
+ const brand = useDocumentBrand();
43
+ return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
40
44
  backgroundColor: c.value,
41
45
  outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
42
46
  outlineOffset: '2px',
43
- } }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
47
+ } }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors(brand).map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
44
48
  }
45
49
  function LabeledRange({ label, value, min, max, step, onChange, disabled, }) {
46
50
  return (_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: label }), _jsx("input", { type: "range", min: min, max: max, step: step, value: value, onChange: (e) => onChange(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] }));
47
51
  }
48
52
  export function BlobCreatorTool({ onJumpToUploads, onPlaceImageUrl }) {
49
53
  const t = useMessages();
54
+ const brand = useDocumentBrand();
50
55
  const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
51
56
  const stageRef = useRef(null);
52
57
  const [seed, setSeed] = useState(randomSeed);
53
58
  const [numPoints, setNumPoints] = useState(7);
54
59
  const [irregularity, setIrregularity] = useState(0.35);
55
- const [color, setColor] = useState(defaultColor);
60
+ const [color, setColor] = useState(defaultColor(brand));
56
61
  const [isBusy, setIsBusy] = useState(false);
57
62
  const [error, setError] = useState(null);
58
63
  const [success, setSuccess] = useState(null);
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // SPDX-License-Identifier: MPL-2.0
3
2
  import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
4
3
  import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
4
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
5
5
  import { useMessages } from '@ggraphic/editor/i18n/messages';
6
6
  import { brandColors } from '@ggraphic/editor/utils/colorOptions';
7
7
  import { useCallback, useState } from 'react';
@@ -12,21 +12,22 @@ import { useToolImagePlacement } from '@ggraphic/editor/sidebar/sections/tools/u
12
12
  // High-res render so the placed image stays crisp when scaled on the canvas.
13
13
  const RENDER_FONT_PX = 240;
14
14
  const RENDER_PADDING = 24;
15
- /** The brand's nth colour, read when the tool opens. */
16
- const paletteColor = (index) => () => brandColors()[index]?.value ?? '#000000';
15
+ /** The document brand's nth colour, read when the tool opens. */
16
+ const paletteColor = (brand, index) => () => brandColors(brand)[index]?.value ?? '#000000';
17
17
  function ColorRow({ label, selected, onSelect, disabled, }) {
18
- return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: label }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
18
+ const brand = useDocumentBrand();
19
+ return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: label }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
19
20
  backgroundColor: c.value,
20
21
  outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
21
22
  outlineOffset: '2px',
22
- } }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
23
+ } }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors(brand).map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
23
24
  }
24
- async function renderGradientTextPng(text, color1, color2, angle) {
25
+ async function renderGradientTextPng(text, color1, color2, angle, fontStack) {
25
26
  const canvas = document.createElement('canvas');
26
27
  const ctx = canvas.getContext('2d');
27
28
  if (!ctx)
28
29
  return null;
29
- const font = `700 ${RENDER_FONT_PX}px ${headlineFontStack()}`;
30
+ const font = `700 ${RENDER_FONT_PX}px ${fontStack}`;
30
31
  // Best-effort: make sure the brand font is ready before measuring/drawing.
31
32
  try {
32
33
  await document.fonts.load(font, text);
@@ -59,10 +60,11 @@ async function renderGradientTextPng(text, color1, color2, angle) {
59
60
  }
60
61
  export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
61
62
  const t = useMessages();
63
+ const brand = useDocumentBrand();
62
64
  const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
63
65
  const [value, setValue] = useState('');
64
- const [color1, setColor1] = useState(paletteColor(0));
65
- const [color2, setColor2] = useState(paletteColor(1));
66
+ const [color1, setColor1] = useState(paletteColor(brand, 0));
67
+ const [color2, setColor2] = useState(paletteColor(brand, 1));
66
68
  const [angle, setAngle] = useState(90);
67
69
  const [isBusy, setIsBusy] = useState(false);
68
70
  const [error, setError] = useState(null);
@@ -75,7 +77,7 @@ export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
75
77
  setSuccess(null);
76
78
  setIsBusy(true);
77
79
  try {
78
- const blob = await renderGradientTextPng(trimmed, color1, color2, angle);
80
+ const blob = await renderGradientTextPng(trimmed, color1, color2, angle, headlineFontStack(brand));
79
81
  if (!blob)
80
82
  throw new Error(t.sidebar.tools.pngFailed);
81
83
  const file = new File([blob], `verlaufstext_${Date.now()}.png`, { type: 'image/png' });
@@ -89,11 +91,11 @@ export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
89
91
  finally {
90
92
  setIsBusy(false);
91
93
  }
92
- }, [t, trimmed, color1, color2, angle, finish]);
94
+ }, [t, trimmed, color1, color2, angle, finish, brand]);
93
95
  const disabled = isBusy || isUploading;
94
96
  const previewText = trimmed || t.sidebar.tools.gradientPreview;
95
97
  return (_jsx(ToolPanel, { body: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: "Text" }), _jsx("input", { type: "text", value: value, onChange: (e) => setValue(e.target.value), placeholder: t.sidebar.tools.yourText, disabled: disabled, className: `rounded-md border border-editor-border-strong bg-background px-sm py-xs text-sm ${MOBILE_INPUT_TEXT} text-foreground outline-none focus:border-primary-500 disabled:opacity-50` })] }), _jsx("div", { className: "flex items-center justify-center rounded-lg bg-editor-inset p-4 overflow-hidden", children: _jsx("span", { className: "text-3xl font-bold leading-tight text-center break-words", style: {
96
- fontFamily: headlineFontStack(),
98
+ fontFamily: headlineFontStack(brand),
97
99
  backgroundImage: `linear-gradient(${angle}deg, ${color1}, ${color2})`,
98
100
  WebkitBackgroundClip: 'text',
99
101
  backgroundClip: 'text',
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // SPDX-License-Identifier: MPL-2.0
3
2
  import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
4
3
  import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
4
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
5
5
  import { useMessages } from '@ggraphic/editor/i18n/messages';
6
6
  import { brandColors } from '@ggraphic/editor/utils/colorOptions';
7
7
  import Konva from 'konva';
@@ -10,8 +10,8 @@ import { PiPath } from 'react-icons/pi';
10
10
  import { MOBILE_INPUT_TEXT } from '@ggraphic/editor/sidebar/sidebarStyles';
11
11
  import { ToolPanel, } from '@ggraphic/editor/sidebar/sections/tools/ToolPanel';
12
12
  import { useToolImagePlacement } from '@ggraphic/editor/sidebar/sections/tools/useToolImagePlacement';
13
- /** The brand's first colour, read when the tool opens. */
14
- const defaultColor = () => brandColors()[0]?.value ?? '#000000';
13
+ /** The document brand's first colour, read when the tool opens. */
14
+ const defaultColor = (brand) => () => brandColors(brand)[0]?.value ?? '#000000';
15
15
  // Path presets in a ~360-wide coordinate space. The exact coords don't affect
16
16
  // framing — the export measures getClientRect() and crops to the drawn glyphs.
17
17
  const VARIANTS = [
@@ -28,12 +28,12 @@ const VARIANTS = [
28
28
  * Renders text along an SVG path (Konva.TextPath) into a tightly-cropped PNG.
29
29
  * See https://konvajs.org/docs/shapes/TextPath.html
30
30
  */
31
- async function renderTextPath(text, data, fontSize, color, pixelRatio) {
31
+ async function renderTextPath(text, data, fontSize, color, pixelRatio, fontStack) {
32
32
  const container = document.createElement('div');
33
33
  const stage = new Konva.Stage({ container, width: 10, height: 10 });
34
34
  const layer = new Konva.Layer();
35
35
  stage.add(layer);
36
- const font = `bold ${fontSize}px ${headlineFontStack()}`;
36
+ const font = `bold ${fontSize}px ${fontStack}`;
37
37
  try {
38
38
  await document.fonts.load(font, text);
39
39
  }
@@ -44,7 +44,7 @@ async function renderTextPath(text, data, fontSize, color, pixelRatio) {
44
44
  text,
45
45
  data,
46
46
  fontSize,
47
- fontFamily: headlineFontStack(),
47
+ fontFamily: fontStack,
48
48
  fontStyle: 'bold',
49
49
  fill: color,
50
50
  });
@@ -67,11 +67,13 @@ async function renderTextPath(text, data, fontSize, color, pixelRatio) {
67
67
  }
68
68
  export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
69
69
  const t = useMessages();
70
+ const brand = useDocumentBrand();
71
+ const fontStack = headlineFontStack(brand);
70
72
  const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
71
73
  const [value, setValue] = useState('');
72
74
  const [variant, setVariant] = useState(VARIANTS[0]);
73
75
  const [fontSize, setFontSize] = useState(48);
74
- const [color, setColor] = useState(defaultColor);
76
+ const [color, setColor] = useState(defaultColor(brand));
75
77
  const [previewUrl, setPreviewUrl] = useState(null);
76
78
  const [isBusy, setIsBusy] = useState(false);
77
79
  const [error, setError] = useState(null);
@@ -81,14 +83,14 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
81
83
  // Preview mirrors the exact export pipeline (lower resolution).
82
84
  useEffect(() => {
83
85
  let cancelled = false;
84
- void renderTextPath(previewText, variant.data, fontSize, color, 1).then((url) => {
86
+ void renderTextPath(previewText, variant.data, fontSize, color, 1, fontStack).then((url) => {
85
87
  if (!cancelled)
86
88
  setPreviewUrl(url);
87
89
  });
88
90
  return () => {
89
91
  cancelled = true;
90
92
  };
91
- }, [previewText, variant.data, fontSize, color]);
93
+ }, [previewText, variant.data, fontSize, color, fontStack]);
92
94
  const disabled = isBusy || isUploading;
93
95
  const handleAction = useCallback(async () => {
94
96
  if (!trimmed)
@@ -97,7 +99,7 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
97
99
  setSuccess(null);
98
100
  setIsBusy(true);
99
101
  try {
100
- const dataUrl = await renderTextPath(trimmed, variant.data, fontSize, color, 3);
102
+ const dataUrl = await renderTextPath(trimmed, variant.data, fontSize, color, 3, fontStack);
101
103
  if (!dataUrl)
102
104
  throw new Error(t.sidebar.tools.previewFailed);
103
105
  const blob = await (await fetch(dataUrl)).blob();
@@ -112,12 +114,12 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
112
114
  finally {
113
115
  setIsBusy(false);
114
116
  }
115
- }, [t, trimmed, variant.data, fontSize, color, finish]);
117
+ }, [t, trimmed, variant.data, fontSize, color, finish, fontStack]);
116
118
  return (_jsx(ToolPanel, { body: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: "Text" }), _jsx("input", { type: "text", value: value, onChange: (e) => setValue(e.target.value), placeholder: t.sidebar.tools.yourText, disabled: disabled, className: `rounded-md border border-editor-border-strong bg-background px-sm py-xs text-sm ${MOBILE_INPUT_TEXT} text-foreground outline-none focus:border-primary-500 disabled:opacity-50` })] }), _jsx("div", { className: "flex items-center justify-center rounded-lg bg-editor-inset p-3 min-h-[120px] overflow-hidden", children: previewUrl ? (_jsx("img", { src: previewUrl, alt: t.ui.preview, className: "max-h-[140px] max-w-full" })) : (_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.tools.preview })) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.topBar.shape }), _jsx("div", { className: "grid grid-cols-3 gap-1.5", children: VARIANTS.map((v) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setVariant(v), className: `rounded-md border px-2 py-1.5 text-xs transition-colors disabled:opacity-50 ${variant.id === v.id
117
119
  ? 'border-primary-500 bg-primary-500/10 text-foreground'
118
- : 'border-editor-border-strong text-foreground-muted hover:border-primary-500'}`, children: t.sidebar.tools.pathNames[v.id] }, v.id))) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setColor(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
120
+ : 'border-editor-border-strong text-foreground-muted hover:border-primary-500'}`, children: t.sidebar.tools.pathNames[v.id] }, v.id))) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setColor(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
119
121
  backgroundColor: c.value,
120
122
  outline: color === c.value ? '2px solid var(--editor-accent)' : 'none',
121
123
  outlineOffset: '2px',
122
- } }, c.id))), _jsx(CustomColorSwatch, { value: color, presets: brandColors().map((c) => c.value), onPick: setColor, className: "size-6", disabled: disabled })] })] }), _jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsxs("span", { className: "text-foreground-muted", children: [t.sidebar.fontSize, ": ", fontSize, "px"] }), _jsx("input", { type: "range", min: 24, max: 80, step: 2, value: fontSize, onChange: (e) => setFontSize(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] })] }), actionLabel: onPlaceImageUrl ? t.sidebar.tools.pathTextPlace : t.sidebar.tools.pathTextAdd, actionIcon: PiPath, canSubmit: !!trimmed, isBusy: disabled, progressMessage: isBusy ? t.sidebar.tools.pathTextSaving : null, error: error, success: success, onAction: () => void handleAction() }));
124
+ } }, c.id))), _jsx(CustomColorSwatch, { value: color, presets: brandColors(brand).map((c) => c.value), onPick: setColor, className: "size-6", disabled: disabled })] })] }), _jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsxs("span", { className: "text-foreground-muted", children: [t.sidebar.fontSize, ": ", fontSize, "px"] }), _jsx("input", { type: "range", min: 24, max: 80, step: 2, value: fontSize, onChange: (e) => setFontSize(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] })] }), actionLabel: onPlaceImageUrl ? t.sidebar.tools.pathTextPlace : t.sidebar.tools.pathTextAdd, actionIcon: PiPath, canSubmit: !!trimmed, isBusy: disabled, progressMessage: isBusy ? t.sidebar.tools.pathTextSaving : null, error: error, success: success, onAction: () => void handleAction() }));
123
125
  }
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: MPL-2.0
3
3
  import { useCanvasEditorServices } from '@ggraphic/editor/CanvasEditorProvider';
4
- import { activeBrand, headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
4
+ import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
5
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
5
6
  import { useMessages } from '@ggraphic/editor/i18n/messages';
6
7
  import { cn } from '@ggraphic/editor/utils/cn';
7
8
  import { Suspense, useEffect, useId, useState } from 'react';
@@ -32,8 +33,9 @@ const warmPanel = (id) => void PANELS[id].preload().catch(() => { });
32
33
  // The letters carry the gradient themselves, so the tile shows what the tool makes.
33
34
  export function GradientTextIcon({ size = 24, className }) {
34
35
  const gradientId = useId();
35
- const { secondary, accent } = activeBrand().colors;
36
- return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", className: className, "aria-hidden": "true", children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "1", y2: "0", children: [_jsx("stop", { offset: "0", stopColor: secondary }), _jsx("stop", { offset: "1", stopColor: accent })] }) }), _jsx("text", { x: "12", y: "18", textAnchor: "middle", fontSize: "17", fontWeight: "900", fontFamily: headlineFontStack(), fill: `url(#${gradientId})`, children: "Aa" })] }));
36
+ const brand = useDocumentBrand();
37
+ const { secondary, accent } = brand.colors;
38
+ return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", className: className, "aria-hidden": "true", children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "1", y2: "0", children: [_jsx("stop", { offset: "0", stopColor: secondary }), _jsx("stop", { offset: "1", stopColor: accent })] }) }), _jsx("text", { x: "12", y: "18", textAnchor: "middle", fontSize: "17", fontWeight: "900", fontFamily: headlineFontStack(brand), fill: `url(#${gradientId})`, children: "Aa" })] }));
37
39
  }
38
40
  function ToolCardButton({ card, onClick, }) {
39
41
  return (_jsxs("button", { type: "button", onClick: onClick, onPointerEnter: () => warmPanel(card.id), onFocus: () => warmPanel(card.id), className: cn('tool-tile-trigger flex w-full flex-col items-center gap-2.5 p-2 cursor-pointer bg-transparent border-none rounded-[14px]', 'transition-colors duration-150 hover:bg-[var(--editor-active-soft)]', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600'), children: [_jsx(ToolTile, { id: card.id }), _jsx("span", { className: "text-sm leading-tight text-foreground text-center", children: card.label })] }));