@ggraphic/editor 0.1.0-alpha.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 (52) hide show
  1. package/README.md +16 -3
  2. package/THIRD_PARTY_NOTICES +25 -1
  3. package/dist/components/CanvasContextMenu/CanvasActionSheet.js +2 -1
  4. package/dist/components/CanvasContextMenu/CanvasContextMenu.js +3 -2
  5. package/dist/components/CanvasEditor/CanvasEditorShell.js +4 -1
  6. package/dist/components/CanvasTextOverlay.js +10 -3
  7. package/dist/components/GenericCanvas.js +12 -3
  8. package/dist/components/RichTextField.js +1 -0
  9. package/dist/components/SelectionPill.js +2 -1
  10. package/dist/components/TextFormatButtons.js +7 -2
  11. package/dist/i18n/de.d.ts +12 -0
  12. package/dist/i18n/de.js +12 -0
  13. package/dist/i18n/en.js +11 -0
  14. package/dist/page/actions.d.ts +66 -0
  15. package/dist/page/actions.js +353 -0
  16. package/dist/page/config.d.ts +15 -0
  17. package/dist/page/config.js +91 -0
  18. package/dist/page/fitting.d.ts +6 -0
  19. package/dist/page/fitting.js +26 -0
  20. package/dist/page/hug.d.ts +10 -0
  21. package/dist/page/hug.js +18 -0
  22. package/dist/page/instantiate.d.ts +8 -0
  23. package/dist/page/instantiate.js +30 -0
  24. package/dist/page/logoSize.d.ts +8 -0
  25. package/dist/page/logoSize.js +29 -0
  26. package/dist/page/pageState.d.ts +41 -0
  27. package/dist/page/pageState.js +59 -0
  28. package/dist/page/seeds.d.ts +14 -0
  29. package/dist/page/seeds.js +40 -0
  30. package/dist/page/slotBudgets.d.ts +22 -0
  31. package/dist/page/slotBudgets.js +18 -0
  32. package/dist/page/templatePack.d.ts +31 -0
  33. package/dist/page/templatePack.js +55 -0
  34. package/dist/page/typography.d.ts +11 -0
  35. package/dist/page/typography.js +13 -0
  36. package/dist/sidebar/sections/CombinedTextSection.js +1 -1
  37. package/dist/sidebar/sections/GenericShareSection.js +3 -2
  38. package/dist/styles/compiled.css +2 -0
  39. package/dist/ui/alert-dialog.js +3 -2
  40. package/dist/ui/dialog.js +3 -2
  41. package/dist/ui/editorScope.d.ts +10 -0
  42. package/dist/ui/editorScope.js +9 -0
  43. package/dist/ui/popover.js +2 -1
  44. package/dist/ui/select.js +2 -1
  45. package/dist/utils/canvasLayerManager.d.ts +14 -0
  46. package/dist/utils/canvasLayerManager.js +24 -0
  47. package/dist/utils/fontMarkSupport.d.ts +10 -0
  48. package/dist/utils/fontMarkSupport.js +22 -6
  49. package/dist/utils/layerLabels.js +3 -6
  50. package/dist/utils/textUtils.js +2 -14
  51. package/package.json +13 -6
  52. package/skills/ggraphic-embed/SKILL.md +145 -0
@@ -0,0 +1,59 @@
1
+ import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
2
+ import { carryInstanceState } from '@ggraphic/editor/configs/factory/carryInstanceState';
3
+ const isRef = (v) => typeof v === 'object' &&
4
+ v !== null &&
5
+ typeof v.id === 'string' &&
6
+ Number.isInteger(v.version) &&
7
+ v.version >= 1;
8
+ const isGroup = (v) => {
9
+ if (typeof v !== 'object' || v === null)
10
+ return false;
11
+ const g = v;
12
+ return (typeof g['id'] === 'string' &&
13
+ Array.isArray(g['elementIds']) &&
14
+ g['elementIds'].every((id) => typeof id === 'string') &&
15
+ (g['blockRef'] === undefined || isRef(g['blockRef'])));
16
+ };
17
+ /** The brand binding and template keys a page keeps across a re-seed (read back, never invented). */
18
+ function brandKeysFrom(props) {
19
+ const out = {};
20
+ const bind = props['bind'];
21
+ if (typeof bind === 'object' && bind !== null && !Array.isArray(bind)) {
22
+ out.bind = bind;
23
+ }
24
+ if (typeof props['brandScheme'] === 'string')
25
+ out.brandScheme = props['brandScheme'];
26
+ if (typeof props['brandStamp'] === 'string')
27
+ out.brandStamp = props['brandStamp'];
28
+ if (isRef(props['templateRef'])) {
29
+ out.templateRef = { id: props['templateRef'].id, version: props['templateRef'].version };
30
+ }
31
+ if (Array.isArray(props['groups']))
32
+ out.groups = props['groups'].filter(isGroup);
33
+ return out;
34
+ }
35
+ /**
36
+ * The page state from what is stored (`props`). A page that has never been
37
+ * saved has no collections yet and gets the template's seed; a saved one keeps
38
+ * exactly what it holds, also when the user emptied it.
39
+ */
40
+ export function pageStateFrom(props, seed) {
41
+ const stored = Array.isArray(props['additionalTexts']) || Array.isArray(props['shapeInstances']);
42
+ const seeded = stored ? props : { ...props, ...seed, layerOrder: seedLayerOrder(seed) };
43
+ const background = seeded['backgroundColor'];
44
+ return {
45
+ isDesktop: typeof window !== 'undefined' && window.innerWidth >= 900,
46
+ ...carryInstanceState(seeded),
47
+ backgroundColor: typeof background === 'string'
48
+ ? background
49
+ : (seed.backgroundColor ?? activeBrand().defaultBackground),
50
+ ...brandKeysFrom(seeded),
51
+ };
52
+ }
53
+ function seedLayerOrder(seed) {
54
+ return [
55
+ ...(seed.shapeInstances ?? []),
56
+ ...(seed.userImageInstances ?? []),
57
+ ...(seed.additionalTexts ?? []),
58
+ ].map((e) => e.id);
59
+ }
@@ -0,0 +1,14 @@
1
+ /** What a fresh page starts with: a template placed on the sheet, and that seed as stored state. */
2
+ import { type TemplateFile, type TemplateFormat } from '@ggraphic/schema';
3
+ import { type PageSeed } from './pageState.js';
4
+ /** The declared aspect closest to the sheet's. */
5
+ export declare function aspectOfSize(width: number, height: number): TemplateFormat;
6
+ /** The fresh page of `template` on a `width` × `height` sheet; empty without a template. */
7
+ export declare function seedFromTemplate(template: TemplateFile | null, width: number, height: number): PageSeed;
8
+ /**
9
+ * The seed as stored page state. A page the editor opens with (`initialPages`)
10
+ * goes into the pages document as given, and the editor writes back only what
11
+ * changes later: a document must therefore start with the seed spelled out,
12
+ * or the AI draft and the autosave would see an empty page.
13
+ */
14
+ export declare function storedPageSeed(seed: PageSeed): Record<string, unknown>;
@@ -0,0 +1,40 @@
1
+ import { placeTemplate } from './instantiate.js';
2
+ const ASPECTS = [
3
+ { format: '1:1', ratio: 1 },
4
+ { format: '4:5', ratio: 4 / 5 },
5
+ { format: '16:9', ratio: 16 / 9 },
6
+ ];
7
+ /** The declared aspect closest to the sheet's. */
8
+ export function aspectOfSize(width, height) {
9
+ const ratio = width / height;
10
+ return ASPECTS.reduce((best, a) => Math.abs(a.ratio - ratio) < Math.abs(best.ratio - ratio) ? a : best).format;
11
+ }
12
+ /** The fresh page of `template` on a `width` × `height` sheet; empty without a template. */
13
+ export function seedFromTemplate(template, width, height) {
14
+ if (!template)
15
+ return {};
16
+ // The nearest aspect is picked from all three, not from the template's: say so here instead of
17
+ // leaving it to the placer, so a template never lands on a sheet it did not declare.
18
+ const aspect = aspectOfSize(width, height);
19
+ if (!template.formats.includes(aspect))
20
+ return {};
21
+ return (placeTemplate(template, { width, height }, aspect) ?? {});
22
+ }
23
+ /**
24
+ * The seed as stored page state. A page the editor opens with (`initialPages`)
25
+ * goes into the pages document as given, and the editor writes back only what
26
+ * changes later: a document must therefore start with the seed spelled out,
27
+ * or the AI draft and the autosave would see an empty page.
28
+ */
29
+ export function storedPageSeed(seed) {
30
+ const shapes = seed.shapeInstances ?? [];
31
+ const texts = seed.additionalTexts ?? [];
32
+ const images = seed.userImageInstances ?? [];
33
+ return {
34
+ ...seed,
35
+ shapeInstances: shapes,
36
+ ...(images.length ? { userImageInstances: images } : {}),
37
+ additionalTexts: texts,
38
+ layerOrder: [...shapes, ...images, ...texts].map((e) => e.id),
39
+ };
40
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The text budget of a template element, for the editor's status line
3
+ * (`CanvasEditorServices.slotBudgets`) and for fitting. A page made from a catalogue template
4
+ * carries `templateRef`; its elements keep the template's element ids, which
5
+ * are the keys of the template's `slots`.
6
+ */
7
+ import { type SlotBudget } from '@ggraphic/core';
8
+ import { type TemplateFile } from '@ggraphic/schema';
9
+ /** The host's catalogue: the template file of id `id`, or null when it has none of that id. */
10
+ export type TemplateLookup = (id: string) => TemplateFile | null;
11
+ /** A catalogue with no templates: pages that carry no `templateRef` need nothing more. */
12
+ export declare const noTemplates: TemplateLookup;
13
+ /**
14
+ * The budget and role of element `elementId` on a page in state `pageState`, or
15
+ * null for a page that is not from a template of `templateOf` and for an element that
16
+ * is not a slot. The template's current version applies, whatever version the
17
+ * page was made from.
18
+ */
19
+ export declare function slotBudgetFor(pageState: Readonly<Record<string, unknown>>, elementId: string, templateOf: TemplateLookup): {
20
+ budget: SlotBudget;
21
+ role: string;
22
+ } | null;
@@ -0,0 +1,18 @@
1
+ /** A catalogue with no templates: pages that carry no `templateRef` need nothing more. */
2
+ export const noTemplates = () => null;
3
+ /**
4
+ * The budget and role of element `elementId` on a page in state `pageState`, or
5
+ * null for a page that is not from a template of `templateOf` and for an element that
6
+ * is not a slot. The template's current version applies, whatever version the
7
+ * page was made from.
8
+ */
9
+ export function slotBudgetFor(pageState, elementId, templateOf) {
10
+ const ref = pageState['templateRef'];
11
+ if (typeof ref !== 'object' || ref === null)
12
+ return null;
13
+ const id = ref.id;
14
+ if (typeof id !== 'string')
15
+ return null;
16
+ const slot = templateOf(id)?.slots[elementId];
17
+ return slot ? { budget: slot.budget, role: slot.role } : null;
18
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Templates as data: template files (the `@ggraphic/schema` format) become editor templates.
3
+ * Every template is a free page (`createPageConfig`) seeded with its file, so a host registers its
4
+ * pack with `registerTemplates(...pack.definitions)` and writes no config of its own.
5
+ */
6
+ import { type TemplateFile } from '@ggraphic/schema';
7
+ import { type FullCanvasConfig } from '../configs/types.js';
8
+ import { type TemplateDefinition } from '../templates/registry.js';
9
+ import { type PageActions } from './actions.js';
10
+ import { type PageState } from './pageState.js';
11
+ import { type TemplateLookup } from './slotBudgets.js';
12
+ /** A file of the pack that was not loaded, and why. */
13
+ export interface TemplatePackProblem {
14
+ id: string | null;
15
+ reason: string;
16
+ }
17
+ export interface TemplatePack {
18
+ /** The pack's templates, in file order; blocks are not pages and are left out. */
19
+ templates: TemplateFile[];
20
+ /** One editor template per entry of `templates`, under the template's id. */
21
+ definitions: TemplateDefinition<string, FullCanvasConfig<PageState, PageActions>>[];
22
+ /** The pack as a lookup, for slot budgets (`CanvasEditorServices.slotBudgets`). */
23
+ templateOf: TemplateLookup;
24
+ /** Files that do not read, are newer than this editor, or repeat an id. */
25
+ problems: TemplatePackProblem[];
26
+ }
27
+ /**
28
+ * The template files in `json` (an array of files, or one file) as a pack. A file that does not
29
+ * read is reported and skipped, never half-loaded; the first of a duplicate id wins.
30
+ */
31
+ export declare function templatePackFromJson(json: unknown): TemplatePack;
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * Templates as data: template files (the `@ggraphic/schema` format) become editor templates.
4
+ * Every template is a free page (`createPageConfig`) seeded with its file, so a host registers its
5
+ * pack with `registerTemplates(...pack.definitions)` and writes no config of its own.
6
+ */
7
+ import { readTemplateFile } from '@ggraphic/schema';
8
+ import { defineTemplate } from '../templates/registry.js';
9
+ import { createPageConfig } from './config.js';
10
+ import { seedFromTemplate } from './seeds.js';
11
+ const idOf = (raw) => typeof raw === 'object' && raw !== null && typeof raw.id === 'string'
12
+ ? raw.id
13
+ : null;
14
+ /**
15
+ * The template files in `json` (an array of files, or one file) as a pack. A file that does not
16
+ * read is reported and skipped, never half-loaded; the first of a duplicate id wins.
17
+ */
18
+ export function templatePackFromJson(json) {
19
+ const files = Array.isArray(json) ? json : [json];
20
+ const templates = [];
21
+ const problems = [];
22
+ const byId = new Map();
23
+ const seen = new Set();
24
+ for (const raw of files) {
25
+ const read = readTemplateFile(raw);
26
+ if (read.status !== 'ok') {
27
+ const reason = read.status === 'invalid'
28
+ ? read.reason
29
+ : `written by a newer version (${read.scope} ${read.version})`;
30
+ problems.push({ id: idOf(raw), reason });
31
+ continue;
32
+ }
33
+ const template = read.template;
34
+ if (seen.has(template.id)) {
35
+ problems.push({ id: template.id, reason: 'duplicate id: the first one is kept' });
36
+ continue;
37
+ }
38
+ seen.add(template.id);
39
+ if (template.kind !== 'template')
40
+ continue;
41
+ byId.set(template.id, template);
42
+ templates.push(template);
43
+ }
44
+ const templateOf = (id) => byId.get(id) ?? null;
45
+ const definitions = templates.map((template) => defineTemplate({
46
+ id: template.id,
47
+ load: (formatId) => Promise.resolve(createPageConfig({
48
+ id: template.id,
49
+ formatId,
50
+ seedFor: (width, height) => seedFromTemplate(template, width, height),
51
+ templateOf,
52
+ })),
53
+ }));
54
+ return { templates, definitions, templateOf, problems };
55
+ }
@@ -0,0 +1,11 @@
1
+ import { type BrandFontRole } from '@ggraphic/core';
2
+ /** Font stacks of the active brand's headline, body and quote families. */
3
+ export declare const headlineFont: () => string;
4
+ export declare const bodyFont: () => string;
5
+ export declare const quoteFont: () => string;
6
+ /** The fallbacks behind a bound font role's family, the same as above. */
7
+ export declare const fontFallbackFor: (role: string) => "Georgia, serif" | "Arial, sans-serif";
8
+ /** The stack for a bound font role: the brand's family, then the same fallbacks as above. */
9
+ export declare const fontStackFor: (role: BrandFontRole, family: string) => string;
10
+ /** Type sizes are set for a 1080 px short side and follow the format from there. */
11
+ export declare const scaleFor: (width: number, height: number) => number;
@@ -0,0 +1,13 @@
1
+ import { activeBrand } from '@ggraphic/editor/brand/brandRegistry';
2
+ /** Font stacks of the active brand's headline, body and quote families. */
3
+ export const headlineFont = () => `${activeBrand().fonts.headline}, Arial, sans-serif`;
4
+ export const bodyFont = () => `${activeBrand().fonts.body}, Arial, sans-serif`;
5
+ export const quoteFont = () => `${activeBrand().fonts.quoteEmphasis}, Georgia, serif`;
6
+ /** The fallbacks behind a bound font role's family, the same as above. */
7
+ export const fontFallbackFor = (role) => role === 'quoteShort' || role === 'quoteEmphasis' || role === 'serif'
8
+ ? 'Georgia, serif'
9
+ : 'Arial, sans-serif';
10
+ /** The stack for a bound font role: the brand's family, then the same fallbacks as above. */
11
+ export const fontStackFor = (role, family) => `${family}, ${fontFallbackFor(role)}`;
12
+ /** Type sizes are set for a 1080 px short side and follow the format from there. */
13
+ export const scaleFor = (width, height) => Math.min(width, height) / 1080;
@@ -39,5 +39,5 @@ export function CombinedTextSection({ onAddHeader, onAddSubheader, onAddText, ad
39
39
  ? (size) => onFontSizeChange(fieldConfig.fontSizeStateKey, size)
40
40
  : undefined;
41
41
  return (_jsx(TextField, { config: fieldConfig, value: values[fieldConfig.key] || '', onChange: (val) => onFieldChange(fieldConfig.key, val), fontSize: fontSize, onFontSizeChange: handleFontSizeChange }, fieldConfig.key));
42
- }) })), hasCanvasTexts && onUpdateText && onRemoveText && (_jsxs("div", { className: "flex flex-col gap-xs max-canvas-mobile:gap-2.5", children: [_jsx("span", { className: "text-xs font-semibold text-foreground uppercase tracking-wide max-canvas-mobile:text-[13px] max-canvas-mobile:font-bold max-canvas-mobile:normal-case max-canvas-mobile:tracking-normal max-canvas-mobile:text-[var(--editor-text-muted)]", children: t.sidebar.text.onCanvas }), additionalTexts.map((text) => (_jsxs("div", { className: "flex items-center gap-sm p-sm bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg max-canvas-mobile:min-h-11 max-canvas-mobile:py-1 max-canvas-mobile:pl-3.5 max-canvas-mobile:pr-1.5 max-canvas-mobile:bg-[var(--editor-tile)] max-canvas-mobile:border-transparent max-canvas-mobile:rounded-xl", children: [_jsx("span", { className: "text-xs text-foreground-muted shrink-0 w-5", children: getTextTypeIcon(text.type) }), _jsx("input", { type: "text", value: text.text, onChange: (e) => onUpdateText(text.id, { text: e.target.value }), className: `flex-1 min-w-0 bg-transparent border-none outline-none text-sm text-foreground placeholder:text-foreground-muted max-canvas-mobile:text-[var(--editor-text)] ${MOBILE_INPUT_TEXT}`, placeholder: getTextTypePlaceholder(text.type) }), _jsx("button", { type: "button", onClick: () => onRemoveText(text.id), className: "touch-target shrink-0 size-7 flex items-center justify-center bg-transparent border-none rounded-md cursor-pointer text-foreground-muted transition-colors duration-150 hover:bg-red-50 hover:text-red-600", "aria-label": t.sidebar.text.removeText, children: _jsx(PiTrash, { size: 11 }) })] }, text.id)))] })), !hasFreeformText && !hasTemplateFields && !hasCanvasTexts && (_jsx(SidebarHint, { children: t.sidebar.text.hintEdit })), hasFreeformText && !hasCanvasTexts && _jsx(SidebarHint, { children: t.sidebar.text.hintAdd })] }));
42
+ }) })), hasCanvasTexts && onUpdateText && onRemoveText && (_jsxs("div", { className: "flex flex-col gap-xs max-canvas-mobile:gap-2.5", children: [_jsx("span", { className: "text-xs font-semibold text-foreground uppercase tracking-wide max-canvas-mobile:text-[13px] max-canvas-mobile:font-bold max-canvas-mobile:normal-case max-canvas-mobile:tracking-normal max-canvas-mobile:text-[var(--editor-text-muted)]", children: t.sidebar.text.onCanvas }), additionalTexts.map((text) => (_jsxs("div", { className: "flex items-center gap-sm p-sm bg-[var(--card-background)] border border-[var(--card-border)] rounded-lg max-canvas-mobile:min-h-11 max-canvas-mobile:py-1 max-canvas-mobile:pl-3.5 max-canvas-mobile:pr-1.5 max-canvas-mobile:bg-[var(--editor-tile)] max-canvas-mobile:border-transparent max-canvas-mobile:rounded-xl", children: [_jsx("span", { className: "text-xs text-foreground-muted shrink-0 w-5", children: getTextTypeIcon(text.type) }), _jsx("textarea", { value: text.text, rows: text.text.split('\n').length, onChange: (e) => onUpdateText(text.id, { text: e.target.value }), className: `flex-1 min-w-0 resize-none [field-sizing:content] bg-transparent border-none outline-none text-sm text-foreground placeholder:text-foreground-muted max-canvas-mobile:text-[var(--editor-text)] ${MOBILE_INPUT_TEXT}`, placeholder: getTextTypePlaceholder(text.type) }), _jsx("button", { type: "button", onClick: () => onRemoveText(text.id), className: "touch-target shrink-0 size-7 flex items-center justify-center bg-transparent border-none rounded-md cursor-pointer text-foreground-muted transition-colors duration-150 hover:bg-red-50 hover:text-red-600", "aria-label": t.sidebar.text.removeText, children: _jsx(PiTrash, { size: 11 }) })] }, text.id)))] })), !hasFreeformText && !hasTemplateFields && !hasCanvasTexts && (_jsx(SidebarHint, { children: t.sidebar.text.hintEdit })), hasFreeformText && !hasCanvasTexts && _jsx(SidebarHint, { children: t.sidebar.text.hintAdd })] }));
43
43
  }
@@ -13,6 +13,7 @@ import { IoCheckmarkOutline, IoShareOutline } from 'react-icons/io5';
13
13
  import { DownloadNotice } from '@ggraphic/editor/components/DownloadNotice';
14
14
  import { AltTextField, useCaptionAltText, useShareAltText, withAltText, } from '@ggraphic/editor/sidebar/components/AltTextField';
15
15
  import { SubsectionTabBar } from '../SubsectionTabBar.js';
16
+ import { EDITOR_SCOPE } from '../../ui/editorScope.js';
16
17
  const iconBtn = 'size-10 rounded-xl border-none bg-editor-tile cursor-pointer flex items-center justify-center text-foreground text-lg transition-[background-color,color,transform] duration-200 hover:bg-editor-active-bg hover:text-editor-active-fg active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed';
17
18
  const primaryBtn = 'w-full py-2.5 px-4 rounded-lg border-none bg-primary-600 text-white font-medium text-sm cursor-pointer flex items-center justify-center gap-2 transition-[background-color,transform] duration-200 hover:bg-primary-700 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed';
18
19
  const secondaryBtn = 'w-full py-2 px-4 rounded-lg border border-editor-border bg-transparent text-foreground font-medium text-sm cursor-pointer flex items-center justify-center gap-2 transition-[background-color,border-color] duration-200 hover:bg-editor-surface-hover';
@@ -206,10 +207,10 @@ function DownloadShareSubsection({ exportedImage, shareToken, onCaptureCanvas, c
206
207
  }, [isMultiPage, onShareAllPages, shareDropdown, handleNativeShare]);
207
208
  return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("h3", { className: "text-sm font-semibold text-foreground m-0", children: t.shell.downloadAndShare }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("div", { className: "relative", children: [_jsx("button", { ref: dlDropdown.triggerRef, className: iconBtn, onClick: handleDownloadClick, disabled: downloadState !== 'idle' && !isMultiPage, title: t.shell.download, "aria-label": t.shell.downloadImage, "aria-haspopup": isMultiPage ? 'menu' : undefined, "aria-expanded": isMultiPage ? dlDropdown.open : undefined, type: "button", children: downloadState === 'capturing' ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : downloadState === 'success' ? (_jsx(PiCheck, {})) : (_jsx(PiDownloadSimple, {})) }), dlDropdown.open &&
208
209
  isMultiPage &&
209
- createPortal(_jsxs("div", { ref: dlDropdown.menuRef, className: dropdownMenu, style: dlDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleSingleDownload, role: "menuitem", type: "button", children: [_jsx(PiFileImage, {}), _jsx("span", { children: t.shell.thisPagePng })] }), _jsx("button", { className: dropdownOption, onClick: handleDownloadAllZip, disabled: isMultiExporting, role: "menuitem", type: "button", children: isMultiExporting ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "size-4 rounded-full" }), _jsx("span", { children: t.shell.exporting })] })) : (_jsxs(_Fragment, { children: [_jsx(PiFileZip, {}), _jsx("span", { children: t.shell.allPagesZip(pageCount) })] })) })] }), document.body)] }), shareRoute !== null && (_jsxs("div", { className: "relative", children: [_jsx("button", { ref: shareDropdown.triggerRef, className: iconBtn, onClick: handleShareClick, disabled: isSharing, title: t.shell.share, "aria-label": t.shell.shareImage, "aria-haspopup": isMultiPage && onShareAllPages ? 'menu' : undefined, "aria-expanded": isMultiPage && onShareAllPages ? shareDropdown.open : undefined, type: "button", children: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})) }), shareDropdown.open &&
210
+ createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: dlDropdown.menuRef, className: dropdownMenu, style: dlDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleSingleDownload, role: "menuitem", type: "button", children: [_jsx(PiFileImage, {}), _jsx("span", { children: t.shell.thisPagePng })] }), _jsx("button", { className: dropdownOption, onClick: handleDownloadAllZip, disabled: isMultiExporting, role: "menuitem", type: "button", children: isMultiExporting ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "size-4 rounded-full" }), _jsx("span", { children: t.shell.exporting })] })) : (_jsxs(_Fragment, { children: [_jsx(PiFileZip, {}), _jsx("span", { children: t.shell.allPagesZip(pageCount) })] })) })] }), document.body)] }), shareRoute !== null && (_jsxs("div", { className: "relative", children: [_jsx("button", { ref: shareDropdown.triggerRef, className: iconBtn, onClick: handleShareClick, disabled: isSharing, title: t.shell.share, "aria-label": t.shell.shareImage, "aria-haspopup": isMultiPage && onShareAllPages ? 'menu' : undefined, "aria-expanded": isMultiPage && onShareAllPages ? shareDropdown.open : undefined, type: "button", children: isSharing ? (_jsx(Skeleton, { className: "size-4 rounded-full" })) : shareSuccess ? (_jsx(PiCheck, {})) : (_jsx(IoShareOutline, {})) }), shareDropdown.open &&
210
211
  isMultiPage &&
211
212
  onShareAllPages &&
212
- createPortal(_jsxs("div", { ref: shareDropdown.menuRef, className: dropdownMenu, style: shareDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleNativeShare, role: "menuitem", type: "button", children: [_jsx(IoShareOutline, {}), _jsx("span", { children: t.shell.shareThisPage })] }), _jsxs("button", { className: dropdownOption, onClick: handleShareAllPages, disabled: isSharing, role: "menuitem", type: "button", children: [_jsx(PiImages, {}), _jsx("span", { children: t.shell.shareAllPages })] })] }), document.body)] }))] }), _jsx(AltTextField, { value: altText, onChange: setAltText }), isMultiExporting && exportProgress && exportProgress.total > 0 && (_jsxs("div", { className: "relative w-full h-6 bg-editor-tile rounded-full overflow-hidden", children: [_jsx("div", { className: "absolute inset-y-0 left-0 bg-primary-600 rounded-full transition-[width] duration-300", style: { width: `${(exportProgress.current / exportProgress.total) * 100}%` } }), _jsx("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium text-foreground", children: t.shell.pagesProgress(exportProgress.current, exportProgress.total) })] })), downloadError && _jsx(DownloadNotice, { children: downloadError }), exportNotice && _jsx(DownloadNotice, { tone: "info", children: exportNotice }), exportError && !isMultiExporting && (_jsxs(DownloadNotice, { children: [_jsx("span", { children: exportError }), lastExportOpRef.current && (_jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => void lastExportOpRef.current?.(), type: "button", children: t.shell.retry }))] })), downloadState === 'success' && autoSaveStatus === 'saving' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground-muted", children: [_jsx(Skeleton, { className: "size-3 rounded-full" }), _jsx("span", { children: t.shell.syncing })] })), downloadState === 'success' && autoSaveStatus === 'saved' && shareToken && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm text-primary-600", children: [_jsx(IoCheckmarkOutline, {}), _jsx("span", { children: t.shell.savedToGallery })] }), _jsxs("button", { className: secondaryBtn, onClick: onNavigateToGallery, type: "button", children: [_jsx(PiImages, {}), t.shell.toGallery] })] })), autoSaveStatus === 'error' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600", children: [_jsx("span", { children: t.shell.saveError }), _jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => autoSaveStoreApi.getState().retryAutoSave?.(), type: "button", children: t.shell.retry })] }))] }));
213
+ createPortal(_jsxs("div", { ...EDITOR_SCOPE, ref: shareDropdown.menuRef, className: dropdownMenu, style: shareDropdown.style, role: "menu", children: [_jsxs("button", { className: dropdownOption, onClick: handleNativeShare, role: "menuitem", type: "button", children: [_jsx(IoShareOutline, {}), _jsx("span", { children: t.shell.shareThisPage })] }), _jsxs("button", { className: dropdownOption, onClick: handleShareAllPages, disabled: isSharing, role: "menuitem", type: "button", children: [_jsx(PiImages, {}), _jsx("span", { children: t.shell.shareAllPages })] })] }), document.body)] }))] }), _jsx(AltTextField, { value: altText, onChange: setAltText }), isMultiExporting && exportProgress && exportProgress.total > 0 && (_jsxs("div", { className: "relative w-full h-6 bg-editor-tile rounded-full overflow-hidden", children: [_jsx("div", { className: "absolute inset-y-0 left-0 bg-primary-600 rounded-full transition-[width] duration-300", style: { width: `${(exportProgress.current / exportProgress.total) * 100}%` } }), _jsx("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium text-foreground", children: t.shell.pagesProgress(exportProgress.current, exportProgress.total) })] })), downloadError && _jsx(DownloadNotice, { children: downloadError }), exportNotice && _jsx(DownloadNotice, { tone: "info", children: exportNotice }), exportError && !isMultiExporting && (_jsxs(DownloadNotice, { children: [_jsx("span", { children: exportError }), lastExportOpRef.current && (_jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => void lastExportOpRef.current?.(), type: "button", children: t.shell.retry }))] })), downloadState === 'success' && autoSaveStatus === 'saving' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-foreground-muted", children: [_jsx(Skeleton, { className: "size-3 rounded-full" }), _jsx("span", { children: t.shell.syncing })] })), downloadState === 'success' && autoSaveStatus === 'saved' && shareToken && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2 text-sm text-primary-600", children: [_jsx(IoCheckmarkOutline, {}), _jsx("span", { children: t.shell.savedToGallery })] }), _jsxs("button", { className: secondaryBtn, onClick: onNavigateToGallery, type: "button", children: [_jsx(PiImages, {}), t.shell.toGallery] })] })), autoSaveStatus === 'error' && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-red-600", children: [_jsx("span", { children: t.shell.saveError }), _jsx("button", { className: "bg-transparent border-none p-0 cursor-pointer text-sm font-medium text-primary-600 hover:underline", onClick: () => autoSaveStoreApi.getState().retryAutoSave?.(), type: "button", children: t.shell.retry })] }))] }));
213
214
  }
214
215
  /**
215
216
  * The template flow itself belongs to the host — it knows the document