@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
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: MPL-2.0
3
3
  import { Popover as PopoverPrimitive } from 'radix-ui';
4
4
  import { cn } from '../utils/cn.js';
5
+ import { EDITOR_SCOPE } from './editorScope.js';
5
6
  function Popover({ ...props }) {
6
7
  return _jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
7
8
  }
@@ -9,7 +10,7 @@ function PopoverTrigger({ ...props }) {
9
10
  return _jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
10
11
  }
11
12
  function PopoverContent({ className, align = 'center', sideOffset = 4, ...props }) {
12
- return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('z-[1020] w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-background-pure p-4 text-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:zoom-in-100! motion-reduce:zoom-out-100! motion-reduce:slide-in-from-top-0! motion-reduce:slide-in-from-left-0!', className), ...props }) }));
13
+ return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ...EDITOR_SCOPE, "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('z-[1020] w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-background-pure p-4 text-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:zoom-in-100! motion-reduce:zoom-out-100! motion-reduce:slide-in-from-top-0! motion-reduce:slide-in-from-left-0!', className), ...props }) }));
13
14
  }
14
15
  function PopoverAnchor({ ...props }) {
15
16
  return _jsx(PopoverPrimitive.Anchor, { "data-slot": "popover-anchor", ...props });
package/dist/ui/select.js CHANGED
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
4
4
  import { Select as SelectPrimitive } from 'radix-ui';
5
5
  import { cn } from '../utils/cn.js';
6
+ import { EDITOR_SCOPE } from './editorScope.js';
6
7
  function Select({ ...props }) {
7
8
  return _jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
8
9
  }
@@ -16,7 +17,7 @@ function SelectTrigger({ className, size = 'default', children, ...props }) {
16
17
  return (_jsxs(SelectPrimitive.Trigger, { "data-slot": "select-trigger", "data-size": size, className: cn("flex w-fit items-center justify-between gap-2 rounded-md border border-editor-control-border bg-editor-control-bg px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 hover:bg-editor-control-bg-hover touch-target [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })] }));
17
18
  }
18
19
  function SelectContent({ className, children, position = 'item-aligned', align = 'center', ...props }) {
19
- return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { "data-slot": "select-content", className: cn('relative z-[1020] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-editor-control-border bg-background-pure text-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', position === 'popper' &&
20
+ return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ...EDITOR_SCOPE, "data-slot": "select-content", className: cn('relative z-[1020] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-editor-control-border bg-background-pure text-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', position === 'popper' &&
20
21
  'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), position: position, align: align, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn('p-1', position === 'popper' &&
21
22
  'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1'), children: children }), _jsx(SelectScrollDownButton, {})] }) }));
22
23
  }
@@ -6,7 +6,7 @@
6
6
  import { type AssetInstance } from '@ggraphic/core';
7
7
  import type { CanvasAiNamedOption } from '@ggraphic/editor/ai/types';
8
8
  import type { ElementPanelHost } from '@ggraphic/editor/sidebar/sections/assets/elementPanelHost';
9
- import type { KawaiiDef, SvgDef } from '@ggraphic/editor/utils/illustrations/types';
9
+ import type { KawaiiDef, SvgDef, SvgSource } from '@ggraphic/editor/utils/illustrations/types';
10
10
  import type { StickerRef } from '@ggraphic/schema';
11
11
  export { ASSET_TARGET_SIZE, type AssetInstance } from '@ggraphic/core';
12
12
  export type AssetAudience = 'de-DE' | 'de-AT' | 'all';
@@ -103,6 +103,12 @@ export interface IllustrationSources {
103
103
  featured?: readonly SvgDef[];
104
104
  /** Colour the Kawaii characters are drawn in on their tiles. */
105
105
  kawaiiColor?: string;
106
+ /**
107
+ * Per SVG set, the colour its files draw their main shapes in; a tinted
108
+ * illustration swaps it for the chosen colour. A set without an entry keeps
109
+ * its colours. Open Doodles' `#ff5678` is known without a host entry.
110
+ */
111
+ recolor?: Readonly<Partial<Record<SvgSource, string>>>;
106
112
  }
107
113
  /** The host's catalogue, installed once at startup; replaces the one before. */
108
114
  export declare function registerAssetCatalog(catalog: CanvasAssetCatalog): void;
@@ -49,3 +49,17 @@ export declare function backgroundFloor(items: readonly CanvasItem[]): number;
49
49
  /** Die Zeichenfolge nach dem Schritt; unverändert, wenn er nichts bewegt. */
50
50
  export declare function moveLayerTo(items: readonly CanvasItem[], id: string, step: LayerStep): string[];
51
51
  export declare function canMoveLayer(items: readonly CanvasItem[], id: string, step: LayerStep): boolean;
52
+ /**
53
+ * An action that inserts an element writes only its own list, never `layerOrder`, so the new item
54
+ * stays untracked and `buildSortedRenderList` draws it among the other untracked ones in per-kind
55
+ * order: a new icon (first kind) landed under an older chart (last kind). Wrapped around an
56
+ * action's state update, this puts every item that update introduces on top of the page: the new
57
+ * `layerOrder` is the render order of `prev` (materialized when it was empty, as `moveLayerTo`
58
+ * does) followed by the new ids.
59
+ *
60
+ * Template elements are not inserts and stay where the config puts them. An update that already
61
+ * wrote a different `layerOrder` (a duplicate placed above its original) is left alone.
62
+ */
63
+ export declare function withInsertsOnTop<TState extends StateWithFeatures & {
64
+ layerOrder?: string[];
65
+ }, TActions = Record<string, unknown>>(config: FullCanvasConfig<TState, TActions>, prev: TState, next: TState): TState;
@@ -105,3 +105,27 @@ export function canMoveLayer(items, id, step) {
105
105
  const target = layerTarget(items.map((item) => item.id), id, step, backgroundFloor(items));
106
106
  return target !== null && target.from !== target.to;
107
107
  }
108
+ /**
109
+ * An action that inserts an element writes only its own list, never `layerOrder`, so the new item
110
+ * stays untracked and `buildSortedRenderList` draws it among the other untracked ones in per-kind
111
+ * order: a new icon (first kind) landed under an older chart (last kind). Wrapped around an
112
+ * action's state update, this puts every item that update introduces on top of the page: the new
113
+ * `layerOrder` is the render order of `prev` (materialized when it was empty, as `moveLayerTo`
114
+ * does) followed by the new ids.
115
+ *
116
+ * Template elements are not inserts and stay where the config puts them. An update that already
117
+ * wrote a different `layerOrder` (a duplicate placed above its original) is left alone.
118
+ */
119
+ export function withInsertsOnTop(config, prev, next) {
120
+ if (next === prev || next.layerOrder !== prev.layerOrder)
121
+ return next;
122
+ const before = buildCanvasItems(config, prev);
123
+ const known = new Set(before.map((item) => item.id));
124
+ const added = buildCanvasItems(config, next)
125
+ .filter((item) => item.type !== 'element' && !known.has(item.id))
126
+ .map((item) => item.id);
127
+ if (added.length === 0)
128
+ return next;
129
+ const order = buildSortedRenderList(before, prev.layerOrder ?? []).map((item) => item.id);
130
+ return { ...next, layerOrder: [...order, ...added] };
131
+ }
@@ -5,6 +5,7 @@
5
5
  * A circle badge is a colored circle with multiple centered text lines,
6
6
  * commonly used for date displays in event templates.
7
7
  */
8
+ import { type BrandPack } from '@ggraphic/core';
8
9
  import type { CircleBadgeInstance, CircleBadgeTextLine } from '../primitives/CircleBadge.js';
9
10
  export type { CircleBadgeInstance, CircleBadgeTextLine };
10
11
  export interface CircleBadgePreset {
@@ -24,5 +25,6 @@ export declare function generateCircleBadgeId(): string;
24
25
  *
25
26
  * @param presetId - The preset to use (e.g., 'default', 'default-inverted')
26
27
  * @param overrides - Optional overrides for specific properties
28
+ * @param brand - The pack the preset takes its colours and font from; the active brand by default
27
29
  */
28
- export declare function createCircleBadgeInstance(presetId?: string, overrides?: Partial<CircleBadgeInstance>): CircleBadgeInstance;
30
+ export declare function createCircleBadgeInstance(presetId?: string, overrides?: Partial<CircleBadgeInstance>, brand?: BrandPack): CircleBadgeInstance;
@@ -11,9 +11,8 @@ import { messages } from '@ggraphic/editor/i18n/messages';
11
11
  // ============================================================================
12
12
  // PRESETS
13
13
  // ============================================================================
14
- /** The presets in the active brand's colours and headline font. */
15
- function circleBadgePresets() {
16
- const { colors, fonts } = activeBrand();
14
+ /** The presets in a brand's colours and headline font. */
15
+ function circleBadgePresets({ colors, fonts }) {
17
16
  return {
18
17
  default: {
19
18
  radius: 80,
@@ -65,9 +64,10 @@ export function generateCircleBadgeId() {
65
64
  *
66
65
  * @param presetId - The preset to use (e.g., 'default', 'default-inverted')
67
66
  * @param overrides - Optional overrides for specific properties
67
+ * @param brand - The pack the preset takes its colours and font from; the active brand by default
68
68
  */
69
- export function createCircleBadgeInstance(presetId = 'default', overrides = {}) {
70
- const presets = circleBadgePresets();
69
+ export function createCircleBadgeInstance(presetId = 'default', overrides = {}, brand = activeBrand()) {
70
+ const presets = circleBadgePresets(brand);
71
71
  const preset = presets[presetId] ?? presets.default;
72
72
  return {
73
73
  id: generateCircleBadgeId(),
@@ -1,2 +1,7 @@
1
- /** Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s. */
2
- export declare function colorName(hex: string): string;
1
+ import { type BrandPack } from '@ggraphic/core';
2
+ /**
3
+ * Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s.
4
+ * The document's pack names it first; a colour it lacks (the effect swatches
5
+ * are shared) keeps the name another registered pack gives it.
6
+ */
7
+ export declare function colorName(hex: string, brand: BrandPack): string;
@@ -1,8 +1,17 @@
1
- // SPDX-License-Identifier: MPL-2.0
1
+ import { registeredBrands } from '@ggraphic/editor/brand/brandRegistry';
2
2
  import { messages } from '@ggraphic/editor/i18n/messages';
3
3
  import { brandColors } from '@ggraphic/editor/utils/colorOptions';
4
- /** Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s. */
5
- export function colorName(hex) {
6
- const brand = brandColors().find((c) => c.value.toLowerCase() === hex.toLowerCase());
7
- return brand ? brand.name : messages().common.colorHex(hex.toUpperCase());
4
+ /**
5
+ * Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s.
6
+ * The document's pack names it first; a colour it lacks (the effect swatches
7
+ * are shared) keeps the name another registered pack gives it.
8
+ */
9
+ export function colorName(hex, brand) {
10
+ const value = hex.toLowerCase();
11
+ for (const pack of [brand, ...registeredBrands()]) {
12
+ const match = brandColors(pack).find((c) => c.value.toLowerCase() === value);
13
+ if (match)
14
+ return match.name;
15
+ }
16
+ return messages().common.colorHex(hex.toUpperCase());
8
17
  }
@@ -19,7 +19,18 @@
19
19
  export interface FontMarkSupport {
20
20
  bold: boolean;
21
21
  italic: boolean;
22
+ /**
23
+ * Fett UND kursiv zugleich ist ein echter Schnitt. Fehlt er, gewinnt Kursiv
24
+ * (`runFont`) — Fett wäre sonst nur angekreuzt, aber nicht zu sehen.
25
+ */
26
+ boldItalic: boolean;
22
27
  }
28
+ /**
29
+ * Built in, or declared by a registered brand (`BrandFonts.cuts`). Takes an
30
+ * already aliased family; the one answer `runFont` and the toolbar share.
31
+ */
32
+ export declare function hasRealBoldItalic(family: string): boolean;
23
33
  /** Erste Familie aus einem CSS-Stapel, ohne Anführungszeichen. */
24
34
  export declare function primaryFontFamily(fontFamily: string): string;
35
+ /** A registered brand's `cuts` win over the built-in table: the host loads that family. */
25
36
  export declare function fontMarkSupport(fontFamily: string): FontMarkSupport;
@@ -1,4 +1,5 @@
1
1
  // SPDX-License-Identifier: MPL-2.0
2
+ import { brandCuts } from '@ggraphic/editor/brand/brandRegistry';
2
3
  import { aliasFontFamily } from './fontAliases.js';
3
4
  /**
4
5
  * Familien mit echten Schnitten. Alles, was hier fehlt, bekommt weder Fett
@@ -12,15 +13,36 @@ import { aliasFontFamily } from './fontAliases.js';
12
13
  * Ersetzte Familien laufen vorher durch `aliasFontFamily`.
13
14
  */
14
15
  const FACES = {
15
- 'Instrument Sans': { bold: true, italic: true },
16
- Fraunces: { bold: true, italic: true },
17
- 'Bricolage Grotesque': { bold: true, italic: false },
16
+ 'Instrument Sans': { bold: true, italic: true, boldItalic: false },
17
+ Fraunces: { bold: true, italic: true, boldItalic: true },
18
+ 'Bricolage Grotesque': { bold: true, italic: false, boldItalic: false },
18
19
  };
19
- const NONE = { bold: false, italic: false };
20
+ const NONE = { bold: false, italic: false, boldItalic: false };
21
+ /**
22
+ * Familien, deren `bold italic` in `typography.css` ein echter Schnitt ist:
23
+ * Fraunces trägt dort Bold Italic als `italic` und Black Italic als
24
+ * `bold italic`. Nur hier gilt „kursiv schlägt fett" nicht — der Browser
25
+ * fettet nichts synthetisch, er lädt den Black-Schnitt. Den braucht die
26
+ * Betonung einiger Markenpakete.
27
+ */
28
+ const REAL_BOLD_ITALIC = new Set(['Fraunces']);
29
+ /**
30
+ * Built in, or declared by a registered brand (`BrandFonts.cuts`). Takes an
31
+ * already aliased family; the one answer `runFont` and the toolbar share.
32
+ */
33
+ export function hasRealBoldItalic(family) {
34
+ return REAL_BOLD_ITALIC.has(family) || brandCuts(family)?.boldItalic === true;
35
+ }
20
36
  /** Erste Familie aus einem CSS-Stapel, ohne Anführungszeichen. */
21
37
  export function primaryFontFamily(fontFamily) {
22
38
  return aliasFontFamily((fontFamily.split(',')[0] ?? '').trim().replace(/^['"]|['"]$/g, ''));
23
39
  }
40
+ /** A registered brand's `cuts` win over the built-in table: the host loads that family. */
24
41
  export function fontMarkSupport(fontFamily) {
25
- return FACES[primaryFontFamily(fontFamily)] ?? NONE;
42
+ const family = primaryFontFamily(fontFamily);
43
+ const cuts = brandCuts(family);
44
+ const boldItalic = hasRealBoldItalic(family);
45
+ if (cuts)
46
+ return { bold: cuts.bold === true, italic: cuts.italic === true, boldItalic };
47
+ return { ...(FACES[family] ?? NONE), boldItalic };
26
48
  }
@@ -1,4 +1,4 @@
1
- import { type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
1
+ import { type BrandPack, type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
2
2
  import type { IconType } from 'react-icons';
3
3
  export { type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
4
4
  export interface FramePreset<T extends FrameClipType = FrameClipType> {
@@ -16,4 +16,5 @@ export declare const FRAME_CATEGORY_ORDER: readonly FrameCategory[];
16
16
  export declare const FRAME_ICON_MAP: Record<FrameClipType, IconType>;
17
17
  export declare const FRAME_PRESET_PATHS: Record<FrameClipType, string>;
18
18
  export declare const DEFAULT_FRAME_SIZE = 300;
19
- export declare function createFrameInstance(clipType: FrameClipType, x: number, y: number): FrameInstance;
19
+ /** A new frame; its border takes the colour of `brand`, the active brand by default. */
20
+ export declare function createFrameInstance(clipType: FrameClipType, x: number, y: number, brand?: BrandPack): FrameInstance;
@@ -254,7 +254,8 @@ const DEFAULT_FRAME_DIMENSIONS = {
254
254
  oval: { width: 300, height: 220 },
255
255
  };
256
256
  let instanceCounter = 0;
257
- export function createFrameInstance(clipType, x, y) {
257
+ /** A new frame; its border takes the colour of `brand`, the active brand by default. */
258
+ export function createFrameInstance(clipType, x, y, brand = activeBrand()) {
258
259
  instanceCounter += 1;
259
260
  const dims = DEFAULT_FRAME_DIMENSIONS[clipType] ?? {
260
261
  width: DEFAULT_FRAME_SIZE,
@@ -275,7 +276,7 @@ export function createFrameInstance(clipType, x, y) {
275
276
  imageOffsetX: 0,
276
277
  imageOffsetY: 0,
277
278
  imageScale: 1,
278
- borderColor: activeBrand().colors.primary,
279
+ borderColor: brand.colors.primary,
279
280
  borderWidth: 3,
280
281
  cornerRadius: clipType === 'rounded-rect' ? 24 : 0,
281
282
  };
@@ -7,6 +7,7 @@
7
7
  * the metadata lands in the editor-core chunk (this module is reached eagerly
8
8
  * through the render layer and action factories).
9
9
  */
10
+ import { type BrandPack } from '@ggraphic/core';
10
11
  import type { KawaiiDef, SvgDef, IllustrationDef, IllustrationInstance } from '@ggraphic/editor/utils/illustrations/types';
11
12
  export type { KawaiiDef, SvgDef, IllustrationDef, IllustrationInstance, KawaiiInstance, SvgInstance, KawaiiMood, KawaiiIllustrationType, } from '@ggraphic/editor/utils/illustrations/types';
12
13
  export { KAWAII_MOODS } from '@ggraphic/editor/utils/illustrations/types';
@@ -15,7 +16,9 @@ export declare function getAllIllustrations(): Promise<IllustrationDef[]>;
15
16
  export declare function getAllSvgIllustrations(): Promise<SvgDef[]>;
16
17
  export declare function getIllustrationPath(illustration: SvgDef, baseUrl?: string): string;
17
18
  export declare function getIllustrationThumbPath(illustration: SvgDef, baseUrl?: string): string;
18
- export declare function createIllustration(illustrationId: string, canvasWidth: number, canvasHeight: number): Promise<IllustrationInstance>;
19
+ export declare function createIllustration(illustrationId: string, canvasWidth: number, canvasHeight: number,
20
+ /** The pack a new illustration takes its colour from; the active brand by default. */
21
+ brand?: BrandPack): Promise<IllustrationInstance>;
19
22
  export declare function findIllustrationById(id: string): Promise<IllustrationDef | undefined>;
20
23
  export declare function searchIllustrations(query: string): Promise<IllustrationDef[]>;
21
24
  export declare function getIllustrationsByCategory(category: string): Promise<SvgDef[]>;
@@ -37,7 +37,9 @@ export function getIllustrationThumbPath(illustration, baseUrl = '') {
37
37
  const pngFilename = illustration.filename.replace(/\.svg$/, '.png');
38
38
  return `${illustrationBase(baseUrl)}/thumbs/${illustration.source}/${pngFilename}`;
39
39
  }
40
- export async function createIllustration(illustrationId, canvasWidth, canvasHeight) {
40
+ export async function createIllustration(illustrationId, canvasWidth, canvasHeight,
41
+ /** The pack a new illustration takes its colour from; the active brand by default. */
42
+ brand = activeBrand()) {
41
43
  const kawaiiIllustrations = await loadKawaiiIllustrations();
42
44
  const kawaiiDef = kawaiiIllustrations.find((k) => k.id === illustrationId);
43
45
  if (kawaiiDef) {
@@ -49,7 +51,7 @@ export async function createIllustration(illustrationId, canvasWidth, canvasHeig
49
51
  y: canvasHeight / 2 - 50,
50
52
  scale: 1,
51
53
  rotation: 0,
52
- color: activeBrand().colors.secondary,
54
+ color: brand.colors.secondary,
53
55
  opacity: 1,
54
56
  mood: 'happy',
55
57
  };
@@ -67,7 +69,7 @@ export async function createIllustration(illustrationId, canvasWidth, canvasHeig
67
69
  scale: 1.0,
68
70
  rotation: 0,
69
71
  opacity: 1,
70
- color: activeBrand().colors.primary,
72
+ color: brand.colors.primary,
71
73
  };
72
74
  }
73
75
  throw new Error(`Unknown illustration ID: ${illustrationId}`);
@@ -9,6 +9,7 @@
9
9
  * 4. RequestIdleCallback for non-blocking background loads
10
10
  */
11
11
  import { recordCacheHit, recordCacheMiss, recordNetworkRequest } from './prefetchAnalytics.js';
12
+ import { registeredAssetCatalog } from '../canvasAssets.js';
12
13
  import { getIllustrationPath } from './registry.js';
13
14
  // =============================================================================
14
15
  // CACHE STATE
@@ -46,11 +47,16 @@ function ensureXmlns(svgText) {
46
47
  /**
47
48
  * Replace SVG colors with target color
48
49
  */
49
- function replaceColors(svgText, color) {
50
- let result = svgText;
51
- // Replace Open Doodles primary color
52
- result = result.replace(/#ff5678/gi, color);
53
- return result;
50
+ const BUILT_IN_RECOLOR = {
51
+ opendoodles: '#ff5678',
52
+ };
53
+ function escapeRegExp(text) {
54
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
55
+ }
56
+ /** Swaps the set's main colour (host `recolor`, else the built-in one) for `color`. */
57
+ function replaceColors(svgText, color, source) {
58
+ const key = registeredAssetCatalog().illustrations?.recolor?.[source] ?? BUILT_IN_RECOLOR[source];
59
+ return key ? svgText.replace(new RegExp(escapeRegExp(key), 'gi'), color) : svgText;
54
60
  }
55
61
  /**
56
62
  * Convert SVG text to base64 data URL
@@ -74,7 +80,7 @@ function getOrComputeColorVariant(cached, color) {
74
80
  const existing = cached.colorVariants.get(color);
75
81
  if (existing)
76
82
  return existing;
77
- const coloredSvg = replaceColors(cached.rawSvg, color);
83
+ const coloredSvg = replaceColors(cached.rawSvg, color, cached.source);
78
84
  const dataUrl = svgToDataUrl(coloredSvg);
79
85
  cached.colorVariants.set(color, dataUrl);
80
86
  // Update size estimate
@@ -146,6 +152,7 @@ async function fetchAndCacheSVG(id, def, color, baseUrl = '') {
146
152
  const size = finalSvg.length * 2 + dataUrl.length * 2;
147
153
  const cached = {
148
154
  rawSvg: finalSvg,
155
+ source: def.source,
149
156
  colorVariants,
150
157
  dataUrl,
151
158
  timestamp: Date.now(),
@@ -2,7 +2,7 @@
2
2
  * Shared types and constants for illustration registry
3
3
  */
4
4
  import { type KawaiiIllustrationType, type KawaiiMood, type SvgSource } from '@ggraphic/core';
5
- export { type IllustrationInstance, type KawaiiIllustrationType, type KawaiiInstance, type KawaiiMood, type SvgInstance, type SvgSource, } from '@ggraphic/core';
5
+ export { type IllustrationInstance, type KawaiiIllustrationType, type KawaiiInstance, type KawaiiMood, type SvgInstance, type SvgSource, type SvgSources, } from '@ggraphic/core';
6
6
  export interface KawaiiDef {
7
7
  id: KawaiiIllustrationType;
8
8
  name: string;
@@ -3,7 +3,7 @@
3
3
  * (Konva.Filters "Multiple Filters" pattern: cache() the node, then apply an
4
4
  * array of filters that read node attrs). See https://konvajs.org/api/Konva.Filters.html
5
5
  */
6
- import { type Bindings } from '@ggraphic/core';
6
+ import { type Bindings, type BrandPack } from '@ggraphic/core';
7
7
  import Konva from 'konva';
8
8
  import type { ImageAdjustments } from './userImageUtils.js';
9
9
  type KonvaFilter = typeof Konva.Filters.Grayscale;
@@ -78,7 +78,9 @@ type Bound = {
78
78
  * `duo-low` / `duo-high` of that world, bound to it, with the other colour looks
79
79
  * cleared. Null when the brand has no such world.
80
80
  */
81
- export declare function duotoneLook(img: Bound | undefined, brandScheme: string | null | undefined): (ImageAdjustments & {
81
+ export declare function duotoneLook(img: Bound | undefined, brandScheme: string | null | undefined,
82
+ /** The pack of the document the image sits in; the active brand by default. */
83
+ brand?: BrandPack): (ImageAdjustments & {
82
84
  bind: Bindings;
83
85
  }) | null;
84
86
  /** Clears the duotone and its two bindings; `bind` is undefined once none is left. */
@@ -268,8 +268,9 @@ export const IMAGE_PRESETS = [
268
268
  * `duo-low` / `duo-high` of that world, bound to it, with the other colour looks
269
269
  * cleared. Null when the brand has no such world.
270
270
  */
271
- export function duotoneLook(img, brandScheme) {
272
- const brand = activeBrand();
271
+ export function duotoneLook(img, brandScheme,
272
+ /** The pack of the document the image sits in; the active brand by default. */
273
+ brand = activeBrand()) {
273
274
  const id = SCHEME_IDS.includes(brandScheme ?? '')
274
275
  ? brandScheme
275
276
  : 'primary';
@@ -1,4 +1,4 @@
1
- import type { Bindings } from '@ggraphic/core';
1
+ import type { Bindings, BrandPack } from '@ggraphic/core';
2
2
  /** The four looks of the top-bar control; each is derived from stored fields, none is stored. */
3
3
  export declare const IMAGE_LOOK_IDS: readonly ["none", "bw", "duotone", "darken"];
4
4
  export type ImageLookId = (typeof IMAGE_LOOK_IDS)[number];
@@ -13,4 +13,6 @@ export interface LookFields {
13
13
  /** Duotone if both colours are set, else B/W if grayscale, else Darken at exactly -0.3, else None. */
14
14
  export declare function currentImageLook(img: LookFields): ImageLookId;
15
15
  /** The fields one choice writes. Duotone takes its colours from the page's world. */
16
- export declare function imageLookPatch(look: ImageLookId, img: LookFields, brandScheme: string | null | undefined): Record<string, unknown>;
16
+ export declare function imageLookPatch(look: ImageLookId, img: LookFields, brandScheme: string | null | undefined,
17
+ /** The pack of the document the image sits in; the active brand by default. */
18
+ brand?: BrandPack): Record<string, unknown>;
@@ -14,7 +14,9 @@ export function currentImageLook(img) {
14
14
  return 'none';
15
15
  }
16
16
  /** The fields one choice writes. Duotone takes its colours from the page's world. */
17
- export function imageLookPatch(look, img, brandScheme) {
17
+ export function imageLookPatch(look, img, brandScheme,
18
+ /** The pack of the document the image sits in; the active brand by default. */
19
+ brand) {
18
20
  switch (look) {
19
21
  case 'none':
20
22
  return {
@@ -26,7 +28,7 @@ export function imageLookPatch(look, img, brandScheme) {
26
28
  case 'bw':
27
29
  return { ...BW_LOOK, ...withoutDuotone(img) };
28
30
  case 'duotone':
29
- return duotoneLook(img, brandScheme) ?? {};
31
+ return duotoneLook(img, brandScheme, brand) ?? {};
30
32
  case 'darken':
31
33
  // Exclusive: a look ends B/W (and its contrast) and the duotone.
32
34
  return {
@@ -5,7 +5,7 @@
5
5
  * „Hintergrund“), gesperrte mit „, gesperrt“. Rein — kein React, kein Store —,
6
6
  * damit Bühnen-Beschriftung, Alt-Text und Ansagen dieselben Namen lesen.
7
7
  */
8
- import { stripMarks } from '@ggraphic/editor/composer/marks';
8
+ import { stripInlineMarks } from '@ggraphic/schema';
9
9
  import { messages } from '@ggraphic/editor/i18n/messages';
10
10
  import { getShapeDef } from '@ggraphic/editor/utils/shapes';
11
11
  import { getAssetById, isStickerLikeInstance } from './canvasAssets.js';
@@ -33,12 +33,9 @@ function templateImageName(id) {
33
33
  return undefined;
34
34
  }
35
35
  }
36
- /** Fließtext für den Namen: Inline-Marken (`**`, `==`, `++` …) und <u> weg, Leerraum zusammengezogen, gekürzt. */
36
+ /** Fließtext für den Namen: Inline-Marken (`**`, `_`, `==`, `++`, <u> …) weg, Leerraum zusammengezogen, gekürzt. */
37
37
  function shorten(text) {
38
- const flat = stripMarks(text)
39
- .replace(/<\/?u>/g, '')
40
- .replace(/\s+/g, ' ')
41
- .trim();
38
+ const flat = stripInlineMarks(text).replace(/\s+/g, ' ').trim();
42
39
  return flat.length > LAYER_TEXT_MAX ? `${flat.slice(0, LAYER_TEXT_MAX - 1).trimEnd()}…` : flat;
43
40
  }
44
41
  function named(kind, content) {
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Die Kästen eines `++Marker++`-Textes — rein geometrisch, ohne Konva, damit
3
+ * der Umbruch pro Zeilenstück testbar ist (`markerBoxes.vitest.ts`).
4
+ *
5
+ * Ein Kasten je Zeile und je zusammenhängender Strecke markierter Läufe: bricht
6
+ * eine Passage um, bekommt jede Zeile ihr eigenes Stück, wie beim Textmarker.
7
+ * Das Leerzeichen hinter dem letzten markierten Wort gehört nicht in den
8
+ * Kasten (der Lauf trägt es, weil ein Wort den Stil seines Leerzeichens erbt).
9
+ * Steht daneben ein unmarkiertes Wort in derselben Zeile, ragt der Kasten nur
10
+ * knapp ins Leerzeichen: sonst stößt er an das Nachbarwort, dessen kursive
11
+ * Glyphen ohnehin schon hineinlehnen.
12
+ */
13
+ import { type BrandPack } from '@ggraphic/core';
1
14
  import type { TextMarker } from './textUtils.js';
2
15
  import type { MeasureRun, RichLayoutedLine } from '@ggraphic/schema';
3
16
  export interface MarkerBox {
@@ -19,5 +32,7 @@ export interface MarkerBoxOptions {
19
32
  top: number;
20
33
  /** Linke Kante jeder Zeile (Rand, Ausrichtungsversatz) — ohne Einzug. */
21
34
  originX: number[];
35
+ /** Das Paket, dessen dunkle Schrift auf frei gewählten Kästen steht; Vorgabe: das aktive. */
36
+ brand?: BrandPack;
22
37
  }
23
- export declare function markerBoxes(lines: RichLayoutedLine[], measure: MeasureRun, marker: TextMarker, { fontSize, lineHeightPx, top, originX }: MarkerBoxOptions): MarkerBox[];
38
+ export declare function markerBoxes(lines: RichLayoutedLine[], measure: MeasureRun, marker: TextMarker, { fontSize, lineHeightPx, top, originX, brand }: MarkerBoxOptions): MarkerBox[];
@@ -1,16 +1,3 @@
1
- // SPDX-License-Identifier: MPL-2.0
2
- /**
3
- * Die Kästen eines `++Marker++`-Textes — rein geometrisch, ohne Konva, damit
4
- * der Umbruch pro Zeilenstück testbar ist (`markerBoxes.vitest.ts`).
5
- *
6
- * Ein Kasten je Zeile und je zusammenhängender Strecke markierter Läufe: bricht
7
- * eine Passage um, bekommt jede Zeile ihr eigenes Stück, wie beim Textmarker.
8
- * Das Leerzeichen hinter dem letzten markierten Wort gehört nicht in den
9
- * Kasten (der Lauf trägt es, weil ein Wort den Stil seines Leerzeichens erbt).
10
- * Steht daneben ein unmarkiertes Wort in derselben Zeile, ragt der Kasten nur
11
- * knapp ins Leerzeichen: sonst stößt er an das Nachbarwort, dessen kursive
12
- * Glyphen ohnehin schon hineinlehnen.
13
- */
14
1
  import { markerInkOn } from './markerColors.js';
15
2
  const DEFAULT_PAD_X = 0.18;
16
3
  const DEFAULT_PAD_Y = 0.02;
@@ -18,7 +5,7 @@ const DEFAULT_PAD_Y = 0.02;
18
5
  const GLYPH_BODY = 1.0;
19
6
  /** So viel des Leerzeichens zu einem Nachbarwort darf der Kasten höchstens belegen. */
20
7
  const NEIGHBOUR_SPACE_SHARE = 0.3;
21
- export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, top, originX }) {
8
+ export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, top, originX, brand }) {
22
9
  const padX = (marker.padX ?? DEFAULT_PAD_X) * fontSize;
23
10
  const padY = (marker.padY ?? DEFAULT_PAD_Y) * fontSize;
24
11
  const height = Math.min(fontSize * GLYPH_BODY + 2 * padY, lineHeightPx);
@@ -43,7 +30,7 @@ export function markerBoxes(lines, measure, marker, { fontSize, lineHeightPx, to
43
30
  width: end - start + padLeft + padRight,
44
31
  height,
45
32
  fill: color ?? marker.fill,
46
- ink: color ? markerInkOn(color) : marker.color,
33
+ ink: color ? markerInkOn(color, brand) : marker.color,
47
34
  });
48
35
  start = null;
49
36
  };
@@ -1,9 +1,16 @@
1
+ /**
2
+ * Farben des Textmarkers — für die Box hinter `++Passagen++`, die Textmarker-
3
+ * Formen im Formen-Katalog und den Farbwähler im Text. Sie kommen aus dem
4
+ * aktiven Markenpaket (`markers`): der erste Kasten ist der Standard, `ink`
5
+ * die dunkle Schrift darauf.
6
+ */
7
+ import { type BrandPack } from '@ggraphic/core';
1
8
  import { type ColorOption } from './colorOptions.js';
2
9
  import { type TextMarker } from './textUtils.js';
3
- /** Die Kastenfarben des aktiven Markenpakets, für den Farbwähler. */
4
- export declare const markerSwatches: () => ColorOption[];
10
+ /** Die Kastenfarben eines Markenpakets (Vorgabe: des aktiven), für den Farbwähler. */
11
+ export declare const markerSwatches: (brand?: BrandPack) => ColorOption[];
5
12
  /** Der erste Kasten des Markenpakets: die Farbe neuer Textmarker-Formen. */
6
- export declare const defaultMarkerFill: () => string;
7
- export declare function defaultTextMarker(): TextMarker;
13
+ export declare const defaultMarkerFill: (brand?: BrandPack) => string;
14
+ export declare function defaultTextMarker(brand?: BrandPack): TextMarker;
8
15
  /** Die lesbarere der beiden Schriftfarben auf einem frei gewählten Kasten. */
9
- export declare function markerInkOn(fill: string): string;
16
+ export declare function markerInkOn(fill: string, brand?: BrandPack): string;
@@ -1,35 +1,28 @@
1
- // SPDX-License-Identifier: MPL-2.0
2
- /**
3
- * Farben des Textmarkers — für die Box hinter `++Passagen++`, die Textmarker-
4
- * Formen im Formen-Katalog und den Farbwähler im Text. Sie kommen aus dem
5
- * aktiven Markenpaket (`markers`): der erste Kasten ist der Standard, `ink`
6
- * die dunkle Schrift darauf.
7
- */
8
1
  import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
9
2
  import { contrastRatio, luminance } from '@ggraphic/editor/utils/colorLuminance';
10
3
  import { asColorOptions } from './colorOptions.js';
11
4
  const MARKER_INK_LIGHT = '#FFFFFF';
12
- /** Die Kastenfarben des aktiven Markenpakets, für den Farbwähler. */
13
- export const markerSwatches = () => asColorOptions(activeBrand().markers.swatches);
5
+ /** Die Kastenfarben eines Markenpakets (Vorgabe: des aktiven), für den Farbwähler. */
6
+ export const markerSwatches = (brand = activeBrand()) => asColorOptions(brand.markers.swatches);
14
7
  /** Der erste Kasten des Markenpakets: die Farbe neuer Textmarker-Formen. */
15
- export const defaultMarkerFill = () => activeBrand().markers.swatches[0]?.color ?? '#FFFFFF';
8
+ export const defaultMarkerFill = (brand = activeBrand()) => brand.markers.swatches[0]?.color ?? '#FFFFFF';
16
9
  /**
17
10
  * Der Kasten eines Textes, dessen Vorlage keinen Markerstil kennt: der erste
18
11
  * Kasten des Markenpakets mit dessen dunkler Schrift.
19
12
  */
20
13
  const textMarkers = new WeakMap();
21
- export function defaultTextMarker() {
22
- const { markers } = activeBrand();
14
+ export function defaultTextMarker(brand = activeBrand()) {
15
+ const { markers } = brand;
23
16
  let marker = textMarkers.get(markers);
24
17
  if (!marker) {
25
- marker = { fill: defaultMarkerFill(), color: markers.ink };
18
+ marker = { fill: defaultMarkerFill(brand), color: markers.ink };
26
19
  textMarkers.set(markers, marker);
27
20
  }
28
21
  return marker;
29
22
  }
30
23
  /** Die lesbarere der beiden Schriftfarben auf einem frei gewählten Kasten. */
31
- export function markerInkOn(fill) {
32
- const inkDark = activeBrand().markers.ink;
24
+ export function markerInkOn(fill, brand = activeBrand()) {
25
+ const inkDark = brand.markers.ink;
33
26
  const ground = luminance(fill);
34
27
  if (ground === null)
35
28
  return inkDark;