@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
package/README.md CHANGED
@@ -2,8 +2,21 @@
2
2
 
3
3
  > **Alpha, untested.** Early work in progress: the API and the document format can change without notice. See the [repository README](../../README.md#ggraphic).
4
4
 
5
- The brand-neutral canvas editor of ggraphic, built on react-konva. Licensed under the [Mozilla Public License 2.0](./LICENSE). Code moves in from the host app's editor package only once it passes the boundary check (`scripts/check-ggraphic-core-boundary.mjs`), file by file and bottom-up: a file moves when it carries no brand content and every file it imports has moved already.
5
+ The brand-neutral canvas editor of ggraphic, built on react-konva: the editor shell with its sidebar, stage, text editing, elements (shapes, icons, illustrations, charts, badges, images), multi-page documents, undo, export (PNG, PDF, PPTX) and the Yjs page document for collaboration. Licensed under the [Mozilla Public License 2.0](./LICENSE).
6
6
 
7
- Each file is its own entry point (a host imports `@ggraphic/editor/utils/snapping`, not a barrel), so a module keeps its identity and a test can mock it by that path. The export map in `package.json` lists every file.
7
+ ## Install
8
8
 
9
- So far it holds the editor's leaf modules: geometry and snapping, selection and keyboard helpers, the icon catalogue, the autosave store, the Yjs page document, and the stage primitives that need nothing else (`CanvasBackground`, `IconPrimitive`, `TransformHud`).
9
+ ```bash
10
+ npm install --save-exact @ggraphic/editor@0.1.0-alpha.0 @ggraphic/core@0.1.0-alpha.0 @ggraphic/schema@0.1.0-alpha.0
11
+ npm install react react-dom konva react-konva @tanstack/react-query
12
+ ```
13
+
14
+ Releases are published under the npm dist-tag `alpha`. The package is ESM-only.
15
+
16
+ ## Embedding
17
+
18
+ The editor needs a host: a brand pack, at least one template (page config), host services and styles. The step-by-step guide, with the traps hosts have hit, is the agent skill shipped in this package: [`skills/ggraphic-embed/SKILL.md`](./skills/ggraphic-embed/SKILL.md). It is plain Markdown, so it reads as documentation too.
19
+
20
+ ## Entry points
21
+
22
+ Each source file is its own entry point (a host imports `@ggraphic/editor/utils/snapping`, not a barrel), so a module keeps its identity and a test can mock it by that path. The CSS entries are `@ggraphic/editor/styles` (token defaults and editor rules) and `@ggraphic/editor/styles/tailwind` (for Tailwind v4 hosts).
@@ -1,4 +1,28 @@
1
- This package bundles no third-party components.
1
+ This package bundles one third-party component: dist/styles/compiled.css
2
+ (`@ggraphic/editor/styles/compiled`) contains CSS generated by Tailwind CSS, including its
3
+ preflight reset, under the following license:
4
+
5
+ MIT License
6
+
7
+ Copyright (c) Tailwind Labs, Inc.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
2
26
 
3
27
  Its npm dependencies keep their own licenses. The icon data comes at runtime from the
4
28
  @iconify-json sets: Tabler, Flowbite, Heroicons, Iconoir and Bootstrap Icons (MIT),
@@ -6,13 +6,21 @@
6
6
  * `CanvasEditorServices`, because the defaults are read in commands, factories
7
7
  * and offscreen roots that have no React context. Without a host the editor
8
8
  * renders `brandDefault`.
9
+ *
10
+ * The first pack is only the fallback. A document of another pack names it on
11
+ * its config (`FullCanvasConfig.brand`); the action factories take it as a
12
+ * parameter and the editor's panels read it with `useDocumentBrand`
13
+ * (`brand/documentBrand.ts`). The order of this list never changes with the
14
+ * document that is open: other editors in the same host read it too.
9
15
  */
10
- import { type BrandPack } from '@ggraphic/core';
16
+ import { type BrandPack, type FontCuts } from '@ggraphic/core';
11
17
  export declare function registerBrandPacks(packs: readonly [BrandPack, ...BrandPack[]]): void;
12
18
  /** The pack new elements take their defaults from. */
13
19
  export declare function activeBrand(): BrandPack;
14
20
  export declare function registeredBrands(): readonly BrandPack[];
15
21
  /** Every family a registered pack names or ships a file for: the host provides these. */
16
22
  export declare function declaredFontFamilies(): ReadonlySet<string>;
17
- /** The active brand's headline family as a CSS stack, for canvas and SVG text a tool draws itself. */
18
- export declare function headlineFontStack(): string;
23
+ /** A brand's headline family as a CSS stack, for canvas and SVG text a tool draws itself. */
24
+ export declare function headlineFontStack(brand?: BrandPack): string;
25
+ /** The real cuts a registered pack declares for `family`, or null. */
26
+ export declare function brandCuts(family: string): FontCuts | null;
@@ -7,6 +7,12 @@
7
7
  * `CanvasEditorServices`, because the defaults are read in commands, factories
8
8
  * and offscreen roots that have no React context. Without a host the editor
9
9
  * renders `brandDefault`.
10
+ *
11
+ * The first pack is only the fallback. A document of another pack names it on
12
+ * its config (`FullCanvasConfig.brand`); the action factories take it as a
13
+ * parameter and the editor's panels read it with `useDocumentBrand`
14
+ * (`brand/documentBrand.ts`). The order of this list never changes with the
15
+ * document that is open: other editors in the same host read it too.
10
16
  */
11
17
  import { brandDefault } from '@ggraphic/core';
12
18
  let registered = [brandDefault];
@@ -35,7 +41,16 @@ function packFamilies(pack) {
35
41
  ...pack.fontFaces.map((face) => face.family),
36
42
  ];
37
43
  }
38
- /** The active brand's headline family as a CSS stack, for canvas and SVG text a tool draws itself. */
39
- export function headlineFontStack() {
40
- return `"${activeBrand().fonts.headline}", sans-serif`;
44
+ /** A brand's headline family as a CSS stack, for canvas and SVG text a tool draws itself. */
45
+ export function headlineFontStack(brand = activeBrand()) {
46
+ return `"${brand.fonts.headline}", sans-serif`;
47
+ }
48
+ /** The real cuts a registered pack declares for `family`, or null. */
49
+ export function brandCuts(family) {
50
+ for (const brand of registered) {
51
+ const cuts = brand.fonts.cuts?.[family];
52
+ if (cuts)
53
+ return cuts;
54
+ }
55
+ return null;
41
56
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The brand of the document that is open, for the panels that offer defaults
3
+ * (swatches, effect presets, text tiles) and for the canvas that draws one (the
4
+ * marker of a text without a marker style). The registry is one list for every
5
+ * editor in the host, so an open document of another pack has to say its own:
6
+ * the shell provides the active page's `FullCanvasConfig.brand`, and
7
+ * `GenericCanvas` provides its own page's to its tree, so an embedded or
8
+ * offscreen canvas has it too. Where nothing is provided, or the page names no
9
+ * pack, a reader falls back to the active brand (`activeBrand()`).
10
+ *
11
+ * Code without React context takes the brand as a parameter instead: the
12
+ * action factories get it from the config.
13
+ */
14
+ import { type BrandPack } from '@ggraphic/core';
15
+ export declare const DocumentBrandContext: import("react").Context<BrandPack | null>;
16
+ export declare function useDocumentBrand(): BrandPack;
@@ -0,0 +1,6 @@
1
+ import { createContext, useContext } from 'react';
2
+ import { activeBrand } from './brandRegistry.js';
3
+ export const DocumentBrandContext = createContext(null);
4
+ export function useDocumentBrand() {
5
+ return useContext(DocumentBrandContext) ?? activeBrand();
6
+ }
@@ -7,6 +7,7 @@ import { AFTER_CLOSE, } from '@ggraphic/editor/components/CanvasContextMenu/Canv
7
7
  import { compact, } from '@ggraphic/editor/components/CanvasContextMenu/canvasMenuModel';
8
8
  import { useMessages } from '@ggraphic/editor/i18n/messages';
9
9
  import { cn } from '@ggraphic/editor/utils/cn';
10
+ import { EDITOR_SCOPE } from '../../ui/editorScope.js';
10
11
  /** Die Zwischenablage steht oben als Kacheln, wie bei Canva: das, was man am häufigsten tippt. */
11
12
  const QUICK = new Set([
12
13
  'copy',
@@ -133,7 +134,7 @@ export function CanvasActionSheet({ handleRef, }) {
133
134
  }
134
135
  }
135
136
  };
136
- return (_jsx(Dialog.Root, { open: open, onOpenChange: setOpen, children: _jsxs(Dialog.Portal, { children: [_jsx(Dialog.Overlay, { className: "fixed inset-0 z-[1010] bg-black/30" }), _jsxs(Dialog.Content, { "aria-describedby": undefined, className: "fixed inset-x-0 bottom-0 z-[1010] flex max-h-[75dvh] flex-col rounded-t-2xl bg-[var(--editor-surface)] pb-[env(safe-area-inset-bottom)] text-[var(--editor-text)] shadow-[0_-8px_24px_rgba(0,0,0,0.16)] outline-none", onCloseAutoFocus: (e) => {
137
+ return (_jsx(Dialog.Root, { open: open, onOpenChange: setOpen, children: _jsxs(Dialog.Portal, { children: [_jsx(Dialog.Overlay, { ...EDITOR_SCOPE, className: "fixed inset-0 z-[1010] bg-black/30" }), _jsxs(Dialog.Content, { ...EDITOR_SCOPE, "aria-describedby": undefined, className: "fixed inset-x-0 bottom-0 z-[1010] flex max-h-[75dvh] flex-col rounded-t-2xl bg-[var(--editor-surface)] pb-[env(safe-area-inset-bottom)] text-[var(--editor-text)] shadow-[0_-8px_24px_rgba(0,0,0,0.16)] outline-none", onCloseAutoFocus: (e) => {
137
138
  if (!keepFocusRef.current)
138
139
  return;
139
140
  keepFocusRef.current = false;
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { ContextMenu } from 'radix-ui';
4
4
  import { useEffect, useImperativeHandle, useRef, useState } from 'react';
5
5
  import { PiCaretRight, PiCheck } from 'react-icons/pi';
6
+ import { EDITOR_SCOPE } from '../../ui/editorScope.js';
6
7
  /** Befehle, die selbst den Fokus nehmen (Text-Editor, Bildauswahl): erst nach dem Schließen. */
7
8
  export const AFTER_CLOSE = new Set(['editText', 'replaceBackground']);
8
9
  const CONTENT = 'z-[10001] min-w-[14rem] max-h-(--radix-context-menu-content-available-height) overflow-y-auto rounded-lg border border-[var(--editor-border)] bg-[var(--editor-surface)] p-1 text-[var(--editor-text)] shadow-[0_8px_24px_rgba(0,0,0,0.16)]';
@@ -93,12 +94,12 @@ export function CanvasContextMenu({ handleRef, closeKey, }) {
93
94
  case 'check':
94
95
  return (_jsxs(ContextMenu.CheckboxItem, { className: `${ITEM} pl-7`, checked: entry.checked, onSelect: () => select(entry.id), children: [_jsx(ContextMenu.ItemIndicator, { className: "absolute left-2 inline-flex", children: _jsx(PiCheck, { size: 14, "aria-hidden": true }) }), entry.label] }, entry.id));
95
96
  case 'sub':
96
- return (_jsxs(ContextMenu.Sub, { children: [_jsxs(ContextMenu.SubTrigger, { className: ITEM, children: [entry.label, _jsx(PiCaretRight, { size: 14, className: "ml-auto", "aria-hidden": true })] }), _jsx(ContextMenu.Portal, { children: _jsx(ContextMenu.SubContent, { className: CONTENT, sideOffset: 4, children: entry.entries.map(renderEntry) }) })] }, `sub-${entry.label}`));
97
+ return (_jsxs(ContextMenu.Sub, { children: [_jsxs(ContextMenu.SubTrigger, { className: ITEM, children: [entry.label, _jsx(PiCaretRight, { size: 14, className: "ml-auto", "aria-hidden": true })] }), _jsx(ContextMenu.Portal, { children: _jsx(ContextMenu.SubContent, { ...EDITOR_SCOPE, className: CONTENT, sideOffset: 4, children: entry.entries.map(renderEntry) }) })] }, `sub-${entry.label}`));
97
98
  case 'item':
98
99
  return (_jsxs(ContextMenu.Item, { className: ITEM, disabled: entry.disabled, onSelect: () => select(entry.id), ...(entry.destructive ? { 'data-destructive': '' } : {}), ...(entry.ariaShortcut ? { 'aria-keyshortcuts': entry.ariaShortcut } : {}), children: [entry.label, entry.shortcut && (_jsx("span", { className: "ml-auto pl-6 text-[12px] text-[var(--editor-text-muted)]", children: entry.shortcut }))] }, entry.id));
99
100
  }
100
101
  };
101
- return (_jsxs(ContextMenu.Root, { open: open, onOpenChange: changeOpen, modal: false, children: [_jsx(ContextMenu.Trigger, { asChild: true, children: _jsx("span", { ref: anchorRef, "aria-hidden": true, className: "fixed left-0 top-0 size-0" }) }), _jsx(ContextMenu.Portal, { children: request && (_jsx(ContextMenu.Content, { ref: contentRef, className: CONTENT, "aria-label": request.menu.label, onContextMenu: (e) => e.preventDefault(), onCloseAutoFocus: (e) => {
102
+ return (_jsxs(ContextMenu.Root, { open: open, onOpenChange: changeOpen, modal: false, children: [_jsx(ContextMenu.Trigger, { asChild: true, children: _jsx("span", { ref: anchorRef, "aria-hidden": true, className: "fixed left-0 top-0 size-0" }) }), _jsx(ContextMenu.Portal, { children: request && (_jsx(ContextMenu.Content, { ...EDITOR_SCOPE, ref: contentRef, className: CONTENT, "aria-label": request.menu.label, onContextMenu: (e) => e.preventDefault(), onCloseAutoFocus: (e) => {
102
103
  if (!keepFocusRef.current)
103
104
  return;
104
105
  keepFocusRef.current = false;
@@ -27,6 +27,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
27
27
  * - usePageUndoRedoShortcuts — Cmd/Ctrl+Z page-array history
28
28
  * - useToolbarHandlers — bundled toolbar actions for the active page
29
29
  */
30
+ import { DocumentBrandContext } from '@ggraphic/editor/brand/documentBrand';
30
31
  import { useCanvasEditorServices } from '@ggraphic/editor/CanvasEditorProvider';
31
32
  import { messages, useMessages } from '@ggraphic/editor/i18n/messages';
32
33
  import { pagePersistedStateKeys } from '@ggraphic/editor/collab/pageElementStateKeys';
@@ -108,8 +109,10 @@ const NO_CALLBACK_KEYS = () => [];
108
109
  const DEFAULT_DECK_LOCALE = () => 'de-DE';
109
110
  /** Folien-PDF: 2× der 1920 × 1080-Folie, scharf auch im Vollbild. */
110
111
  const SLIDES_PDF_PIXEL_RATIO = 2;
112
+ /** A box-less root that scopes `@ggraphic/editor/styles/compiled` to the editor (`EDITOR_SCOPE`). */
113
+ const SCOPE_ROOT_STYLE = { display: 'contents' };
111
114
  export function CanvasEditorShell(props) {
112
- return (_jsx(AutoSaveStoreProvider, { initialShareToken: props.initialShareToken ?? null, children: _jsx(CanvasEditorInner, { ...props }) }));
115
+ return (_jsx("div", { ...EDITOR_SCOPE, style: SCOPE_ROOT_STYLE, children: _jsx(AutoSaveStoreProvider, { initialShareToken: props.initialShareToken ?? null, children: _jsx(CanvasEditorInner, { ...props }) }) }));
113
116
  }
114
117
  function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialProps, onExport, onCancel, onDownload, callbacks = {}, maxPages = 10, initialPages, collaborative, chromeLeft, chromeCenter, chromeRight, onInvitePeople, onSaveAsTemplate, onCollabSnapshot, onAutoSaveShareToken, initialTab = null, onActiveTabChange, galleryAutoSave = true, showShare = true, exportApiRef, hostChrome, readOnly = false, }) {
115
118
  const t = useMessages();
@@ -403,14 +406,17 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
403
406
  if (deck.some((_, i) => !refs[i]?.current)) {
404
407
  throw new Error(messages().errors.exportSlidesPartial);
405
408
  }
409
+ // One brand per deck: its pages share a country.
410
+ const brand = deck[0] ? loadedConfigs.get(deck[0].configId)?.brand : undefined;
406
411
  return exportPptxDeck({
407
412
  pages: deck.map((page) => page.state),
408
413
  format: getCanvasFormatOrDefault(formatId),
409
414
  rasterizeElement: async (slideIndex, elementId) => (await refs[slideIndex]?.current?.rasterizeElement(elementId)) ?? null,
410
415
  ...(documentTitle ? { title: documentTitle } : {}),
416
+ ...(brand ? { brand } : {}),
411
417
  ...(onProgress ? { onProgress } : {}),
412
418
  });
413
- }, [pagesDoc, canvasRefsRef, formatId, documentTitle]);
419
+ }, [pagesDoc, canvasRefsRef, formatId, documentTitle, loadedConfigs]);
414
420
  useImperativeHandle(exportApiRef, () => ({
415
421
  captureActivePage: async ({ pixelRatio = 1, transparent = false } = {}) => {
416
422
  await ensureFontsReady();
@@ -619,7 +625,7 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
619
625
  });
620
626
  if (dataUrl) {
621
627
  const ext = format === 'jpeg' ? 'jpg' : format;
622
- await fileDelivery.downloadDataUrl(dataUrl, `${filenamePrefix}-page-${currentPageIndex + 1}.${ext}`);
628
+ await fileDelivery.downloadDataUrl(dataUrl, `${filenamePrefix}-${messages().export.pageFile}-${currentPageIndex + 1}.${ext}`);
623
629
  onDownload?.(dataUrl);
624
630
  }
625
631
  }, [currentPageIndex, canvasRefsRef, onDownload, fileDelivery, filenamePrefix]);
@@ -773,14 +779,16 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
773
779
  if (dataUrls.length === 0)
774
780
  return;
775
781
  if (route === 'native-host') {
776
- dataUrls.forEach((dataUrl, i) => fileDelivery.shareDataUrlViaNativeHost(dataUrl, `${filenamePrefix}-page-${i + 1}.png`, {
782
+ dataUrls.forEach((dataUrl, i) => fileDelivery.shareDataUrlViaNativeHost(dataUrl, `${filenamePrefix}-${messages().export.pageFile}-${i + 1}.png`, {
777
783
  title: shareTitle,
778
784
  }));
779
785
  return;
780
786
  }
781
787
  const files = await Promise.all(dataUrls.map(async (dataUrl, i) => {
782
788
  const blob = await (await fetch(dataUrl)).blob();
783
- return new File([blob], `${filenamePrefix}-page-${i + 1}.png`, { type: 'image/png' });
789
+ return new File([blob], `${filenamePrefix}-${messages().export.pageFile}-${i + 1}.png`, {
790
+ type: 'image/png',
791
+ });
784
792
  }));
785
793
  if (navigator.canShare?.({ files })) {
786
794
  await navigator.share({ files, title: shareTitle });
@@ -805,7 +813,7 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
805
813
  await ensureFontsReady();
806
814
  const dataUrl = ref.current.toDataURL({ pixelRatio: 1 });
807
815
  if (dataUrl) {
808
- await fileDelivery.downloadDataUrl(dataUrl, `${filenamePrefix}-slider-page-${currentPageIndex + 1}.png`);
816
+ await fileDelivery.downloadDataUrl(dataUrl, `${filenamePrefix}-slider-${messages().export.pageFile}-${currentPageIndex + 1}.png`);
809
817
  }
810
818
  }
811
819
  },
@@ -878,7 +886,7 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
878
886
  ...shareProps,
879
887
  ...(specEdit && { specEdit }),
880
888
  background: source.config.background?.(source.state, source.actions) ?? null,
881
- chartColors: source.config.chartColors,
889
+ chartColors: source.config.chartColors ?? source.config.brand?.chart,
882
890
  });
883
891
  return (_jsx(Suspense, { fallback: sidebarLoadingFallback, children: _jsx(SectionComponent, { ...sectionProps }) }));
884
892
  }, [
@@ -1104,35 +1112,36 @@ function CanvasEditorInner({ initialConfigId, formatId, documentTitle, initialPr
1104
1112
  const bottomBarGroup = 'flex items-center rounded-xl border border-[var(--editor-border)] bg-[var(--editor-surface)]/80 shadow-sm backdrop-blur-sm pointer-events-auto';
1105
1113
  const pageStrip = showPageStrip ? (_jsx(PageThumbnailStrip, { pages: pages, currentPageIndex: currentPageIndex, thumbnails: pageThumbnails, loadedConfigs: loadedConfigs, currentTemplateId: currentTemplateId, canAddMore: canAddPages, onSelect: handleThumbnailSelect, onAddPage: handleAddPage, quickAddOpensPicker: pagePicker?.quickAddOpensPicker?.(pages) ?? false, renderPicker: renderAddPicker })) : null;
1106
1114
  const bottomBar = (_jsxs("div", { className: "canvas-bottom-bar pointer-events-none flex items-center gap-2 px-2 pb-2", children: [pageStrip ? (_jsx("div", { className: "min-w-0 flex-1", children: _jsx("div", { className: cn('w-fit max-w-full', bottomBarGroup), children: pageStrip }) })) : (_jsx("div", { className: "min-w-0 flex-1", children: canAddPages && (_jsx("div", { className: cn('w-fit px-1.5 py-1', bottomBarGroup), children: _jsx(AddPageButton, { onAddPage: handleAddPageLikeCurrent, renderPicker: renderAddPicker, disabled: !renderAddPicker && !currentTemplateId, compact: true }) })) })), _jsx("div", { className: cn('shrink-0', bottomBarGroup), children: _jsx(CanvasMetaBar, { pageCount: pageCount, currentPageIndex: currentPageIndex, zoom: zoom, onZoomChange: setZoom }) })] }));
1107
- return (_jsxs(AnnouncerContext.Provider, { value: announcer, children: [_jsx(CanvasAnnouncer, { message: liveMessage }), _jsx(ShellProvider, { pages: pages, currentPageIndex: currentPageIndex, formatId: formatId, canvasRefsRef: canvasRefsRef, configTabIds: configTabIds, children: _jsx(UserUploadsProvider, { children: _jsxs(CanvasTextEditorProvider, { children: [!isPreview && !readOnly && !hasPendingSuggestion && (_jsx("button", { type: "button", onClick: handleSkipToLayers, className: "sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[400] focus:flex focus:min-h-8 focus:items-center focus:rounded-md focus:border focus:border-[var(--editor-border-strong)] focus:bg-[var(--editor-surface)] focus:px-3 focus:text-[length:var(--font-size-small)] focus:font-semibold focus:text-[var(--editor-text)] focus:shadow-md outline-none kbd:focus-visible:outline-2 kbd:focus-visible:outline-solid kbd:focus-visible:outline-offset-2 kbd:focus-visible:outline-[var(--editor-accent)]", children: t.shell.skipToLayers })), _jsxs(CanvasEditorLayout
1108
- // Vorschau vor dem Sync: zeigen, aber nichts anbieten, was schreibt —
1109
- // die Seiten hängen noch an keinem Y.Map, jede Änderung ginge verloren.
1110
- // Ein Viewer ebenso: der Server verwirft seine Schreibzugriffe.
1111
- , {
1115
+ return (_jsx(DocumentBrandContext.Provider, { value: activeConfig?.brand ?? null, children: _jsxs(AnnouncerContext.Provider, { value: announcer, children: [_jsx(CanvasAnnouncer, { message: liveMessage }), _jsx(ShellProvider, { pages: pages, currentPageIndex: currentPageIndex, formatId: formatId, canvasRefsRef: canvasRefsRef, configTabIds: configTabIds, children: _jsx(UserUploadsProvider, { children: _jsxs(CanvasTextEditorProvider, { children: [!isPreview && !readOnly && !hasPendingSuggestion && (_jsx("button", { type: "button", onClick: handleSkipToLayers, className: "sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[400] focus:flex focus:min-h-8 focus:items-center focus:rounded-md focus:border focus:border-[var(--editor-border-strong)] focus:bg-[var(--editor-surface)] focus:px-3 focus:text-[length:var(--font-size-small)] focus:font-semibold focus:text-[var(--editor-text)] focus:shadow-md outline-none kbd:focus-visible:outline-2 kbd:focus-visible:outline-solid kbd:focus-visible:outline-offset-2 kbd:focus-visible:outline-[var(--editor-accent)]", children: t.shell.skipToLayers })), _jsxs(CanvasEditorLayout
1112
1116
  // Vorschau vor dem Sync: zeigen, aber nichts anbieten, was schreibt —
1113
1117
  // die Seiten hängen noch an keinem Y.Map, jede Änderung ginge verloren.
1114
1118
  // Ein Viewer ebenso: der Server verwirft seine Schreibzugriffe.
1115
- sidebar: isPreview || readOnly ? null : hasPendingSuggestion ? (_jsx("div", { inert: true, className: "contents", children: panel })) : (panel), tabBar: isPreview || readOnly ? null : tabBar, actions: null, toolbar: toolbarElement, contextBar: isPreview || readOnly ? null : contextBarElement,
1116
- // Die Desktop-Leiste ist auf dem Handy per CSS ausgeblendet; gar
1117
- // nicht erst mitgeben, sonst hinge der Streifen zweimal im Baum.
1118
- bottomBar: isMobileWeb || isPreview ? null : bottomBar,
1119
- // Auf dem Handy scrollt ein Finger auf dem Sharepic nicht (wie in
1120
- // Canva) — die Seiten wechselt dort dieser Streifen.
1121
- mobilePageStrip: isMobileWeb && !isMobileSheetOpen && !isPreview ? pageStrip : null, mobileZoomControl: isMobileWeb && !isMobileSheetOpen && !isPreview ? (_jsx(CanvasZoomIndicator, { zoom: zoom, onZoomChange: setZoom })) : null, mobileSheetOpen: isMobileSheetOpen, onCanvasBackdropPointerDown: isMobileSheetOpen ? handlePanelClose : undefined, children: [schemaRefusal && (_jsx("p", { role: "alert", className: "mx-auto mt-sm max-w-prose rounded-md border border-[var(--editor-border-strong)] bg-[var(--editor-surface)] px-3 py-2 text-[length:var(--font-size-small)] text-[var(--editor-text)]", children: t.shell.schemaRefusal[schemaRefusal.status] })), _jsxs("div", { inert: isPreview || hasPendingSuggestion, "aria-busy": isPreview && !schemaRefusal, ref: pagesContainerCallbackRef, onPointerDown: handleWorkAreaPointerDown, className: cn('heterogeneous-multipage__pages-container has-bottom-bar flex flex-col items-center gap-md p-sm pb-lg w-full max-canvas-mobile:gap-sm max-canvas-mobile:p-xs', hasPendingSuggestion && 'opacity-60 transition-opacity duration-200'), children: [pages.map((page, index) => {
1122
- const config = loadedConfigs.get(page.configId);
1123
- if (!config)
1124
- return null;
1125
- const isActive = index === currentPageIndex;
1126
- const canDelete = pageCount > 1;
1127
- return (_jsx(PageWrapper
1128
- // A replaced state (convert, undo) mounts the page afresh on the new state.
1129
- , { page: page, index: index, pageCount: pageCount, config: config, formatId: formatId, isActive: isActive, canDelete: canDelete, canvasRef: canvasRefsRef.current[index], pageRef: pageDomRefsRef.current[index], onSelect: handlePageSelect, onDelete: removePage, onMovePage: movePage, onDuplicatePage: duplicatePage, onChangeTemplate: PagePicker ? handleOpenTemplateChange : undefined, onDropVorlage: takesPageDrops && !readOnly ? handleDropVorlage : undefined, onExport: handleExport, onCancel: onCancel, callbacks: getCallbacksForPage(page.id, page.configId), multiPageExport: index === 0 ? multiPageExportProps : undefined, onStateChange: handlePageStateChange, onObservedState: printService && needsImpressum(printFormat)
1130
- ? handleObservedState
1131
- : undefined, onToolbarStateChange: isActive && !isPreview ? handleToolbarStateChange : undefined, onAutoSaveShareToken: onAutoSaveShareToken, autoSave: false, pageBinding: pageBindingAt(index, page.id, isActive), readOnly: readOnly }, `${page.id}:${page.stateEpoch ?? 0}`));
1132
- }), noPageRenderable && _jsx(CanvasPageSkeleton, { aspectRatio: pageAspectRatio }), templateChangePage && PagePicker && (_jsx(PagePicker, { isOpen: true, mode: "replace", anchorRef: pageDomRefsRef.current[templateChangePage.index], onSelectTemplate: handleSelectTemplateChange, onClose: handleCloseTemplateChange, currentTemplateId: templateChangePage.configId, currentState: templateChangePage.state, activeTemplateId: currentTemplateId, pages: pages, formatId: formatId })), isSlideFormat(format) && !isPreview && pages[currentPageIndex] && (_jsx(SlideNotesPanel, { value: typeof pages[currentPageIndex].state.notes === 'string'
1133
- ? pages[currentPageIndex].state.notes
1134
- : '', onChange: (notes) => updatePageState(pages[currentPageIndex].id, { notes }), readOnly: readOnly })), canAddPages && !showPageStrip && (_jsx("div", { className: "w-full max-w-[28rem] pt-sm max-canvas-mobile:pt-xs max-canvas-mobile:px-xs max-canvas-mobile:origin-top max-canvas-mobile:[scale:calc(1/var(--canvas-total-scale,1))] canvas-mobile:hidden", children: _jsx(AddPageButton, { onAddPage: handleAddPageLikeCurrent, renderPicker: renderAddPicker, disabled: !canAddMore || (!renderAddPicker && !currentTemplateId) }) }))] })] }), selectionPill, !isPreview &&
1135
- !readOnly &&
1136
- (isMobileWeb ? (_jsx(CanvasActionSheet, { handleRef: contextMenuRef })) : (_jsx(CanvasContextMenu, { handleRef: contextMenuRef, closeKey: zoom })))] }) }) })] }));
1119
+ , {
1120
+ // Vorschau vor dem Sync: zeigen, aber nichts anbieten, was schreibt —
1121
+ // die Seiten hängen noch an keinem Y.Map, jede Änderung ginge verloren.
1122
+ // Ein Viewer ebenso: der Server verwirft seine Schreibzugriffe.
1123
+ sidebar: isPreview || readOnly ? null : hasPendingSuggestion ? (_jsx("div", { inert: true, className: "contents", children: panel })) : (panel), tabBar: isPreview || readOnly ? null : tabBar, actions: null, toolbar: toolbarElement, contextBar: isPreview || readOnly ? null : contextBarElement,
1124
+ // Die Desktop-Leiste ist auf dem Handy per CSS ausgeblendet; gar
1125
+ // nicht erst mitgeben, sonst hinge der Streifen zweimal im Baum.
1126
+ bottomBar: isMobileWeb || isPreview ? null : bottomBar,
1127
+ // Auf dem Handy scrollt ein Finger auf dem Sharepic nicht (wie in
1128
+ // Canva) — die Seiten wechselt dort dieser Streifen.
1129
+ mobilePageStrip: isMobileWeb && !isMobileSheetOpen && !isPreview ? pageStrip : null, mobileZoomControl: isMobileWeb && !isMobileSheetOpen && !isPreview ? (_jsx(CanvasZoomIndicator, { zoom: zoom, onZoomChange: setZoom })) : null, mobileSheetOpen: isMobileSheetOpen, onCanvasBackdropPointerDown: isMobileSheetOpen ? handlePanelClose : undefined, children: [schemaRefusal && (_jsx("p", { role: "alert", className: "mx-auto mt-sm max-w-prose rounded-md border border-[var(--editor-border-strong)] bg-[var(--editor-surface)] px-3 py-2 text-[length:var(--font-size-small)] text-[var(--editor-text)]", children: t.shell.schemaRefusal[schemaRefusal.status] })), _jsxs("div", { inert: isPreview || hasPendingSuggestion, "aria-busy": isPreview && !schemaRefusal, ref: pagesContainerCallbackRef, onPointerDown: handleWorkAreaPointerDown, className: cn('heterogeneous-multipage__pages-container has-bottom-bar flex flex-col items-center gap-md p-sm pb-lg w-full max-canvas-mobile:gap-sm max-canvas-mobile:p-xs', hasPendingSuggestion && 'opacity-60 transition-opacity duration-200'), children: [pages.map((page, index) => {
1130
+ const config = loadedConfigs.get(page.configId);
1131
+ if (!config)
1132
+ return null;
1133
+ const isActive = index === currentPageIndex;
1134
+ const canDelete = pageCount > 1;
1135
+ return (_jsx(PageWrapper
1136
+ // A replaced state (convert, undo) mounts the page afresh on the new state.
1137
+ , { page: page, index: index, pageCount: pageCount, config: config, formatId: formatId, isActive: isActive, canDelete: canDelete, canvasRef: canvasRefsRef.current[index], pageRef: pageDomRefsRef.current[index], onSelect: handlePageSelect, onDelete: removePage, onMovePage: movePage, onDuplicatePage: duplicatePage, onChangeTemplate: PagePicker ? handleOpenTemplateChange : undefined, onDropVorlage: takesPageDrops && !readOnly ? handleDropVorlage : undefined, onExport: handleExport, onCancel: onCancel, callbacks: getCallbacksForPage(page.id, page.configId), multiPageExport: index === 0 ? multiPageExportProps : undefined, onStateChange: handlePageStateChange, onObservedState: printService && needsImpressum(printFormat)
1138
+ ? handleObservedState
1139
+ : undefined, onToolbarStateChange: isActive && !isPreview ? handleToolbarStateChange : undefined, onAutoSaveShareToken: onAutoSaveShareToken, autoSave: false, pageBinding: pageBindingAt(index, page.id, isActive), readOnly: readOnly }, `${page.id}:${page.stateEpoch ?? 0}`));
1140
+ }), noPageRenderable && _jsx(CanvasPageSkeleton, { aspectRatio: pageAspectRatio }), templateChangePage && PagePicker && (_jsx(PagePicker, { isOpen: true, mode: "replace", anchorRef: pageDomRefsRef.current[templateChangePage.index], onSelectTemplate: handleSelectTemplateChange, onClose: handleCloseTemplateChange, currentTemplateId: templateChangePage.configId, currentState: templateChangePage.state, activeTemplateId: currentTemplateId, pages: pages, formatId: formatId })), isSlideFormat(format) && !isPreview && pages[currentPageIndex] && (_jsx(SlideNotesPanel, { value: typeof pages[currentPageIndex].state.notes === 'string'
1141
+ ? pages[currentPageIndex].state.notes
1142
+ : '', onChange: (notes) => updatePageState(pages[currentPageIndex].id, { notes }), readOnly: readOnly })), canAddPages && !showPageStrip && (_jsx("div", { className: "w-full max-w-[28rem] pt-sm max-canvas-mobile:pt-xs max-canvas-mobile:px-xs max-canvas-mobile:origin-top max-canvas-mobile:[scale:calc(1/var(--canvas-total-scale,1))] canvas-mobile:hidden", children: _jsx(AddPageButton, { onAddPage: handleAddPageLikeCurrent, renderPicker: renderAddPicker, disabled: !canAddMore || (!renderAddPicker && !currentTemplateId) }) }))] })] }), selectionPill, !isPreview &&
1143
+ !readOnly &&
1144
+ (isMobileWeb ? (_jsx(CanvasActionSheet, { handleRef: contextMenuRef })) : (_jsx(CanvasContextMenu, { handleRef: contextMenuRef, closeKey: zoom })))] }) }) })] }) }));
1137
1145
  }
1146
+ import { EDITOR_SCOPE } from '../../ui/editorScope.js';
1138
1147
  export default CanvasEditorShell;
@@ -67,6 +67,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
67
67
  import { PLAIN_STYLE, splitListItems, stripInlineMarks } from '@ggraphic/schema';
68
68
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
69
69
  import { createPortal, flushSync } from 'react-dom';
70
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
70
71
  import { messages } from '@ggraphic/editor/i18n/messages';
71
72
  import { captureFocusOrigin, returnFocus, } from '@ggraphic/editor/utils/editorFocus';
72
73
  import { normalizeRotation } from '@ggraphic/editor/utils/orientation';
@@ -75,8 +76,15 @@ import { resolveFontFamily } from '../utils/fontAliases.js';
75
76
  import { fontMarkSupport } from '../utils/fontMarkSupport.js';
76
77
  import { defaultTextMarker } from '../utils/markerColors.js';
77
78
  import { fontStyleForRun, measureTextWidthWithFont, } from '../utils/textUtils.js';
79
+ import { EDITOR_SCOPE } from '../ui/editorScope.js';
78
80
  /** Ohne offene Sitzung trägt niemand einen Schnitt. */
79
- const NO_MARKS = { bold: false, italic: false, accent: false, marker: false };
81
+ const NO_MARKS = {
82
+ bold: false,
83
+ italic: false,
84
+ boldItalic: false,
85
+ accent: false,
86
+ marker: false,
87
+ };
80
88
  /**
81
89
  * Untergrenze für die gespiegelte Deckkraft. Der Regler der Kopfleiste geht
82
90
  * bis 0; ein Feld, das dort steht, wäre als Editor nicht mehr zu sehen.
@@ -342,6 +350,7 @@ export function CanvasTextEditorProvider({ children }) {
342
350
  return _jsx(TextEditorRoot, { children: children });
343
351
  }
344
352
  function TextEditorRoot({ children }) {
353
+ const brand = useDocumentBrand();
345
354
  const [session, setSession] = useState(null);
346
355
  const [editor, setEditor] = useState(null);
347
356
  const [draft, setDraft] = useState('');
@@ -489,8 +498,8 @@ function TextEditorRoot({ children }) {
489
498
  // Wert aber unverändert durch.
490
499
  ...{
491
500
  '--canvas-rte-list-indent': `${listIndent}px`,
492
- '--canvas-rte-marker-fill': (session.marker ?? defaultTextMarker()).fill,
493
- '--canvas-rte-marker-color': (session.marker ?? defaultTextMarker()).color,
501
+ '--canvas-rte-marker-fill': (session.marker ?? defaultTextMarker(brand)).fill,
502
+ '--canvas-rte-marker-color': (session.marker ?? defaultTextMarker(brand)).color,
494
503
  ...(session.accent && {
495
504
  '--canvas-rte-accent-color': session.accent.fill,
496
505
  '--canvas-rte-accent-font': resolveFontFamily(session.accent.fontFamily ?? session.fontFamily),
@@ -512,7 +521,7 @@ function TextEditorRoot({ children }) {
512
521
  // kein `overflow: hidden` der Leinwandfläche die Werkzeugleiste
513
522
  // abschneidet — die sitzt über dem Text und ragt bei einem Feld am
514
523
  // oberen Rand aus dem Sujet heraus.
515
- createPortal(_jsx("div", { style: {
524
+ createPortal(_jsx("div", { ...EDITOR_SCOPE, style: {
516
525
  position: 'absolute',
517
526
  top: box.top,
518
527
  left: box.left,
@@ -521,5 +530,5 @@ function TextEditorRoot({ children }) {
521
530
  zIndex: 10000,
522
531
  pointerEvents: shrink < 1 ? 'none' : undefined,
523
532
  }, children: modules ? (_jsx(modules.RichTextField, { value: draft, onChange: onDraftChange, marks: marks, showToolbar: hosts === 0, onEditorReady: setEditor, autoFocus: true, contentStyle: contentStyle, onBlur: commit, onEscape: commit, onSubmit: commit })) : (_jsx("div", { className: "canvas-rte", children: _jsx("div", { style: contentStyle, children: _jsx("div", { className: "canvas-rte__content", children: stripInlineMarks(draft) }) }) })) }), document.body), loadFailed &&
524
- createPortal(_jsx("div", { role: "alert", className: "fixed bottom-4 left-1/2 z-[10000] max-w-[min(420px,calc(100vw-32px))] -translate-x-1/2 rounded-md bg-[var(--editor-surface)] px-4 py-3 text-sm text-[var(--editor-text)] shadow-lg", children: messages().errors.textEditorLoad }), document.body)] }));
533
+ createPortal(_jsx("div", { ...EDITOR_SCOPE, role: "alert", className: "fixed bottom-4 left-1/2 z-[10000] max-w-[min(420px,calc(100vw-32px))] -translate-x-1/2 rounded-md bg-[var(--editor-surface)] px-4 py-3 text-sm text-[var(--editor-text)] shadow-lg", children: messages().errors.textEditorLoad }), document.body)] }));
525
534
  }
@@ -18,7 +18,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
18
  * samt Listener verloren. Beim Abbauen wird eine offene Wahl noch übernommen.
19
19
  */
20
20
  import { useEffect, useRef } from 'react';
21
- import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
21
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
22
22
  import { useMessages } from '@ggraphic/editor/i18n/messages';
23
23
  import { cn } from '@ggraphic/editor/utils/cn';
24
24
  const HEX6 = /^#[0-9a-f]{6}$/i;
@@ -26,6 +26,7 @@ const DRAG_COMMIT_MS = 250;
26
26
  const COLOR_WHEEL = 'conic-gradient(from 180deg, #ff4d4d, #ffd84d, #4dd98a, #4db8ff, #8a4dff, #ff4dc4, #ff4d4d)';
27
27
  export function CustomColorSwatch({ value, presets, onPick, onPreview, className, outlineOffset = 2, disabled = false, inputProps, }) {
28
28
  const ownColor = useMessages().common.ownColor;
29
+ const brand = useDocumentBrand();
29
30
  const inputRef = useRef(null);
30
31
  const hex = value && HEX6.test(value) ? value.toUpperCase() : null;
31
32
  const pickRef = useRef(onPick);
@@ -76,5 +77,5 @@ export function CustomColorSwatch({ value, presets, onPick, onPreview, className
76
77
  outline: isCustom ? '2px solid var(--editor-accent)' : 'none',
77
78
  outlineOffset: `${outlineOffset}px`,
78
79
  };
79
- return (_jsx("label", { title: ownColor, style: style, className: cn('relative inline-block shrink-0 cursor-pointer rounded-full border border-black/10 transition-transform hover:scale-110', disabled && 'pointer-events-none opacity-50', className), children: _jsx("input", { ref: inputRef, type: "color", "aria-label": ownColor, disabled: disabled, defaultValue: (hex ?? activeBrand().colors.primary).toLowerCase(), onChange: (e) => onPreview?.(e.target.value.toUpperCase()), className: "absolute inset-0 size-full cursor-pointer opacity-0", ...inputProps }) }));
80
+ return (_jsx("label", { title: ownColor, style: style, className: cn('relative inline-block shrink-0 cursor-pointer rounded-full border border-black/10 transition-transform hover:scale-110', disabled && 'pointer-events-none opacity-50', className), children: _jsx("input", { ref: inputRef, type: "color", "aria-label": ownColor, disabled: disabled, defaultValue: (hex ?? brand.colors.primary).toLowerCase(), onChange: (e) => onPreview?.(e.target.value.toUpperCase()), className: "absolute inset-0 size-full cursor-pointer opacity-0", ...inputProps }) }));
80
81
  }
@@ -9,7 +9,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
9
9
  * Refactored to use extracted hooks, utilities, and components for better maintainability.
10
10
  */
11
11
  import Konva from 'konva';
12
- import { useRef, useState, useEffect, useCallback, useMemo, memo, useImperativeHandle, useLayoutEffect, } from 'react';
12
+ import { useRef, useState, useEffect, useCallback, useMemo, memo, useContext, useImperativeHandle, useLayoutEffect, } from 'react';
13
+ import { DocumentBrandContext } from '@ggraphic/editor/brand/documentBrand';
13
14
  import { useEmitHostStateChanges } from '@ggraphic/editor/collab/useEmitHostStateChanges';
14
15
  import { useYjsCanvasBinding } from '@ggraphic/editor/collab/useYjsCanvasBinding';
15
16
  import { stateKeyOfCallback } from '@ggraphic/editor/collab/wrapCallbacksWithPageSync';
@@ -48,7 +49,7 @@ import { floatingModuleFor } from '../hooks/useFloatingModuleState.js';
48
49
  import { CanvasStage, SnapGuidelines } from '../primitives/index.js';
49
50
  import { createCanvasCommands, } from '../utils/canvasCommands.js';
50
51
  import { canvasFontFamilies } from '../utils/canvasFontFamilies.js';
51
- import { buildCanvasItems, buildSortedRenderList } from '../utils/canvasLayerManager.js';
52
+ import { buildCanvasItems, buildSortedRenderList, withInsertsOnTop, } from '../utils/canvasLayerManager.js';
52
53
  import { addHostElement, fromHostKinds } from '../utils/elementKinds.js';
53
54
  import { captureStageImage, captureStageImageAsync, rasterizeStageElement, visibleStageTexts, } from '../utils/captureStage.js';
54
55
  import { MAX_ICON_SELECTIONS, selectedCatalogIconIds } from '../utils/iconInstances.js';
@@ -117,6 +118,15 @@ function GenericCanvasWithRef(props) {
117
118
  return { ...prev, ...partial };
118
119
  });
119
120
  }, []);
121
+ // The setter the element actions get: whatever an action inserts is drawn on top of the page,
122
+ // regardless of its kind. The canvas commands (paste, duplicate, reorder) place their own
123
+ // elements and keep the plain setter.
124
+ const setActionState = useCallback((partial) => {
125
+ setStateRaw((prev) => {
126
+ const next = typeof partial === 'function' ? partial(prev) : { ...prev, ...partial };
127
+ return withInsertsOnTop(config, prev, next);
128
+ });
129
+ }, [config]);
120
130
  // External edits to this page's `state` Y.Map (chat sharepic editing via
121
131
  // the Hocuspocus internal API) merge into the live component state.
122
132
  // Rebuilding through createInitialState recomputes the derived fields.
@@ -200,12 +210,12 @@ function GenericCanvasWithRef(props) {
200
210
  // `runHistoryBatch` rides on the actions so the AI bridge (built from the
201
211
  // page's live actions) coalesces one op batch into one undo step.
202
212
  const actions = useMemo(() => ({
203
- ...config.createActions(getState, setStateWrapper, saveToHistory, debouncedSaveToHistory, callbacks),
213
+ ...config.createActions(getState, setActionState, saveToHistory, debouncedSaveToHistory, callbacks),
204
214
  runHistoryBatch,
205
215
  }), [
206
216
  config,
207
217
  getState,
208
- setStateWrapper,
218
+ setActionState,
209
219
  saveToHistory,
210
220
  debouncedSaveToHistory,
211
221
  runHistoryBatch,
@@ -773,7 +783,13 @@ function CanvasYjsBindingMount({ pageYMap, isSynced, }) {
773
783
  return null;
774
784
  }
775
785
  function GenericCanvasWithProvider(props) {
776
- return (_jsxs(CanvasStoreProvider, { initialFormatId: props.formatId, children: [props.pageBinding ? (_jsx(CanvasYjsBindingMount, { pageYMap: props.pageBinding.pageYMap, isSynced: props.pageBinding.isSynced })) : null, _jsx(MemoizedGenericCanvas, { ...props })] }));
786
+ // The page draws its defaults (the marker of a text without a marker style, the backdrop) in
787
+ // the brand of ITS document, wherever it is mounted: in the editor shell, embedded, or in an
788
+ // offscreen root for a preview or an export, where no shell provides one. A config that names
789
+ // none leaves the context as it is.
790
+ const outerBrand = useContext(DocumentBrandContext);
791
+ const brand = props.config.brand ?? outerBrand;
792
+ return (_jsx(DocumentBrandContext.Provider, { value: brand, children: _jsxs(CanvasStoreProvider, { initialFormatId: props.formatId, children: [props.pageBinding ? (_jsx(CanvasYjsBindingMount, { pageYMap: props.pageBinding.pageYMap, isSynced: props.pageBinding.isSynced })) : null, _jsx(MemoizedGenericCanvas, { ...props })] }) }));
777
793
  }
778
794
  GenericCanvasWithProvider.displayName = 'GenericCanvas';
779
795
  export const GenericCanvas = GenericCanvasWithProvider;
@@ -37,6 +37,7 @@ import { Underline } from '@tiptap/extension-underline';
37
37
  import { Placeholder, UndoRedo } from '@tiptap/extensions';
38
38
  import { EditorContent, useEditor } from '@tiptap/react';
39
39
  import { useEffect, useRef } from 'react';
40
+ import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
40
41
  import { Accent } from '@ggraphic/editor/components/accentMark';
41
42
  import { messages } from '@ggraphic/editor/i18n/messages';
42
43
  import { keepsEditing } from '@ggraphic/editor/utils/keyboardOwnership';
@@ -58,7 +59,8 @@ const BASE_EXTENSIONS = [
58
59
  * Schriftschnitt und ist deshalb auf jedem Feld aktiv. Der Akzent steht
59
60
  * immer im Schema; angeboten wird er nur, wo der Text einen Akzentstil trägt.
60
61
  */
61
- const ALWAYS_MARK_EXTENSIONS = [Underline, Accent, Marker];
62
+ const ALWAYS_MARK_EXTENSIONS = [Underline, Accent];
63
+ // Der Marker steht ebenso immer im Schema; er kommt mit dem Paket des Dokuments dazu.
62
64
  /**
63
65
  * Fett und Kursiv müssen IM SCHEMA stehen, auch wo die Schrift sie nicht
64
66
  * tragen kann. Ein Dokument mit einem Mark, den das Schema nicht kennt, lässt
@@ -90,6 +92,7 @@ function focusFormatToolbar(editor) {
90
92
  const ALL_MARKS_SUPPORTED = {
91
93
  bold: true,
92
94
  italic: true,
95
+ boldItalic: true,
93
96
  accent: false,
94
97
  marker: false,
95
98
  };
@@ -101,10 +104,12 @@ export function RichTextField({ value, onChange, placeholder, marks = ALL_MARKS_
101
104
  callbacks.current = { onChange, onBlur, onEscape, onSubmit };
102
105
  // `handleKeyDown` steht in der Konfiguration, bevor es den Editor gibt.
103
106
  const editorRef = useRef(null);
107
+ const brand = useDocumentBrand();
104
108
  const editor = useEditor({
105
109
  extensions: [
106
110
  ...BASE_EXTENSIONS,
107
111
  ...ALWAYS_MARK_EXTENSIONS,
112
+ Marker.configure({ brand }),
108
113
  markExtension(Bold, marks.bold),
109
114
  markExtension(Italic, marks.italic),
110
115
  Placeholder.configure({ placeholder: placeholder ?? '' }),
@@ -8,6 +8,7 @@ import { useRovingToolbar } from '@ggraphic/editor/hooks/useRovingToolbar';
8
8
  import { useMessages } from '@ggraphic/editor/i18n/messages';
9
9
  import { CANVAS_COMMANDS, formatShortcut, isMacPlatform, shortcutOf, } from '@ggraphic/editor/utils/canvasCommandRegistry';
10
10
  import { cn } from '@ggraphic/editor/utils/cn';
11
+ import { EDITOR_SCOPE } from '../ui/editorScope.js';
11
12
  const GAP = 12;
12
13
  const EDGE = 8;
13
14
  const GEOMETRY = {
@@ -119,5 +120,5 @@ export function SelectionPill({ variant = 'touch', measureKey, zoom, getBox, sub
119
120
  ? t.topBar.nothingDeletable
120
121
  : t.topBar.templateNoDelete;
121
122
  const deleteButton = (_jsx("button", { type: "button", className: cn(btn, pointer && DANGER_BTN), onClick: onDelete, disabled: !canDelete, title: pointer ? deleteTitle : undefined, "aria-label": t.commands.delete, children: _jsx(PiTrash, { size: iconSize, "aria-hidden": true }) }));
122
- return createPortal(_jsxs("div", { ref: pillRef, onKeyDown: onKeyDown, onFocus: onFocus, role: "toolbar", "aria-label": t.common.element, style: { top, left }, className: cn('fixed z-[110] flex items-center gap-0.5 rounded-full border border-[var(--editor-border-soft)] bg-[var(--editor-surface)] shadow-[0_2px_8px_rgba(0,0,0,0.12)]', pointer ? 'p-0.5' : 'px-1'), children: [pointer && onToggleLock && (_jsx("button", { type: "button", className: btn, onClick: onToggleLock, "aria-pressed": isLocked, title: isLocked ? t.topBar.unlockHint : t.topBar.lockHint, "aria-label": lockLabel, children: isLocked ? (_jsx(PiLockSimple, { size: iconSize, "aria-hidden": true })) : (_jsx(PiLockSimpleOpen, { size: iconSize, "aria-hidden": true })) })), _jsx("button", { type: "button", className: btn, onClick: onDuplicate, disabled: !canDuplicate, title: pointer ? (canDuplicate ? t.topBar.duplicate : t.topBar.templateNoDuplicate) : undefined, "aria-label": t.commands.duplicate, children: _jsx(PiCopy, { size: iconSize, "aria-hidden": true }) }), pointer ? (deleteButton) : isLocked && onToggleLock ? (_jsx("button", { type: "button", className: btn, onClick: onToggleLock, "aria-label": t.contextMenu.unlock, children: _jsx(PiLockSimpleOpen, { size: iconSize, "aria-hidden": true }) })) : (deleteButton), onFlip && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: btn, onClick: () => onFlip('x'), "aria-label": CANVAS_COMMANDS.flipHorizontal.label, children: _jsx(PiFlipHorizontal, { size: iconSize, "aria-hidden": true }) }), _jsx("button", { type: "button", className: btn, onClick: () => onFlip('y'), "aria-label": CANVAS_COMMANDS.flipVertical.label, children: _jsx(PiFlipVertical, { size: iconSize, "aria-hidden": true }) })] })), onMore && (_jsx("button", { type: "button", className: btn, onClick: (e) => onMore(e.currentTarget), "aria-haspopup": pointer ? 'menu' : 'dialog', title: pointer ? t.shell.moreOptions : undefined, "aria-label": t.shell.moreOptions, children: _jsx(PiDotsThreeBold, { size: iconSize, "aria-hidden": true }) }))] }), document.body);
123
+ return createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: pillRef, onKeyDown: onKeyDown, onFocus: onFocus, role: "toolbar", "aria-label": t.common.element, style: { top, left }, className: cn('fixed z-[110] flex items-center gap-0.5 rounded-full border border-[var(--editor-border-soft)] bg-[var(--editor-surface)] shadow-[0_2px_8px_rgba(0,0,0,0.12)]', pointer ? 'p-0.5' : 'px-1'), children: [pointer && onToggleLock && (_jsx("button", { type: "button", className: btn, onClick: onToggleLock, "aria-pressed": isLocked, title: isLocked ? t.topBar.unlockHint : t.topBar.lockHint, "aria-label": lockLabel, children: isLocked ? (_jsx(PiLockSimple, { size: iconSize, "aria-hidden": true })) : (_jsx(PiLockSimpleOpen, { size: iconSize, "aria-hidden": true })) })), _jsx("button", { type: "button", className: btn, onClick: onDuplicate, disabled: !canDuplicate, title: pointer ? (canDuplicate ? t.topBar.duplicate : t.topBar.templateNoDuplicate) : undefined, "aria-label": t.commands.duplicate, children: _jsx(PiCopy, { size: iconSize, "aria-hidden": true }) }), pointer ? (deleteButton) : isLocked && onToggleLock ? (_jsx("button", { type: "button", className: btn, onClick: onToggleLock, "aria-label": t.contextMenu.unlock, children: _jsx(PiLockSimpleOpen, { size: iconSize, "aria-hidden": true }) })) : (deleteButton), onFlip && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: btn, onClick: () => onFlip('x'), "aria-label": CANVAS_COMMANDS.flipHorizontal.label, children: _jsx(PiFlipHorizontal, { size: iconSize, "aria-hidden": true }) }), _jsx("button", { type: "button", className: btn, onClick: () => onFlip('y'), "aria-label": CANVAS_COMMANDS.flipVertical.label, children: _jsx(PiFlipVertical, { size: iconSize, "aria-hidden": true }) })] })), onMore && (_jsx("button", { type: "button", className: btn, onClick: (e) => onMore(e.currentTarget), "aria-haspopup": pointer ? 'menu' : 'dialog', title: pointer ? t.shell.moreOptions : undefined, "aria-label": t.shell.moreOptions, children: _jsx(PiDotsThreeBold, { size: iconSize, "aria-hidden": true }) }))] }), document.body);
123
124
  }