@elytracms/studio 0.0.68 → 0.0.70

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 (79) hide show
  1. package/dist/components/app-views/studio-config.d.ts +22 -0
  2. package/dist/components/app-views/studio-config.js.map +1 -1
  3. package/dist/components/assets/asset-detail.d.ts +4 -2
  4. package/dist/components/assets/asset-detail.js +4 -2
  5. package/dist/components/assets/asset-detail.js.map +1 -1
  6. package/dist/components/assets/assets-collection-view-source.d.ts +30 -19
  7. package/dist/components/assets/assets-collection-view-source.js +55 -23
  8. package/dist/components/assets/assets-collection-view-source.js.map +1 -1
  9. package/dist/components/builder/blocks-model.d.ts +91 -29
  10. package/dist/components/builder/blocks-model.js +83 -54
  11. package/dist/components/builder/blocks-model.js.map +1 -1
  12. package/dist/components/builder/blocks-panel.d.ts +40 -12
  13. package/dist/components/builder/blocks-panel.js +88 -34
  14. package/dist/components/builder/blocks-panel.js.map +1 -1
  15. package/dist/components/builder/canvas-chrome-css.js +6 -1
  16. package/dist/components/builder/canvas-chrome-css.js.map +1 -1
  17. package/dist/components/builder/fixture-thumbnail.d.ts +13 -23
  18. package/dist/components/builder/fixture-thumbnail.js +27 -99
  19. package/dist/components/builder/fixture-thumbnail.js.map +1 -1
  20. package/dist/components/builder/selection-overlay.d.ts +17 -4
  21. package/dist/components/builder/selection-overlay.js +17 -15
  22. package/dist/components/builder/selection-overlay.js.map +1 -1
  23. package/dist/components/builder/spacing-handles.d.ts +34 -6
  24. package/dist/components/builder/spacing-handles.js +70 -31
  25. package/dist/components/builder/spacing-handles.js.map +1 -1
  26. package/dist/components/cms/bulk-bar.d.ts +11 -1
  27. package/dist/components/cms/bulk-bar.js +10 -3
  28. package/dist/components/cms/bulk-bar.js.map +1 -1
  29. package/dist/components/cms/collection-table.js +19 -2
  30. package/dist/components/cms/collection-table.js.map +1 -1
  31. package/dist/components/cms/field-control.js +5 -1
  32. package/dist/components/cms/field-control.js.map +1 -1
  33. package/dist/components/cms/prop-fields.js +5 -1
  34. package/dist/components/cms/prop-fields.js.map +1 -1
  35. package/dist/components/cms/reference-confirm.js +5 -1
  36. package/dist/components/cms/reference-confirm.js.map +1 -1
  37. package/dist/components/cms/rich-text/editor.d.ts +24 -5
  38. package/dist/components/cms/rich-text/editor.js +23 -8
  39. package/dist/components/cms/rich-text/editor.js.map +1 -1
  40. package/dist/components/rail-view-source.d.ts +50 -1
  41. package/dist/components/rail-view-source.js +56 -2
  42. package/dist/components/rail-view-source.js.map +1 -1
  43. package/dist/components/redirects/redirects-collection-view-source.d.ts +3 -2
  44. package/dist/components/redirects/redirects-collection-view-source.js +4 -3
  45. package/dist/components/redirects/redirects-collection-view-source.js.map +1 -1
  46. package/dist/components/session-expired-overlay.d.ts +16 -0
  47. package/dist/components/session-expired-overlay.js +22 -6
  48. package/dist/components/session-expired-overlay.js.map +1 -1
  49. package/dist/components/sign-in-view.d.ts +10 -1
  50. package/dist/components/sign-in-view.js +14 -3
  51. package/dist/components/sign-in-view.js.map +1 -1
  52. package/dist/components/users/users-collection-view-source.js +1 -1
  53. package/dist/components/users/users-collection-view-source.js.map +1 -1
  54. package/dist/customization.d.ts +9 -1
  55. package/dist/customization.js.map +1 -1
  56. package/dist/lib/cms-views/view-model.d.ts +6 -6
  57. package/dist/lib/collection-view/collection-view-source.d.ts +12 -0
  58. package/dist/lib/collection-view/collection-view-source.js.map +1 -1
  59. package/dist/lib/dnd/gap-drag.d.ts +8 -1
  60. package/dist/lib/dnd/gap-drag.js +4 -0
  61. package/dist/lib/dnd/gap-drag.js.map +1 -1
  62. package/dist/lib/i18n/messages.de.js +8 -0
  63. package/dist/lib/i18n/messages.de.js.map +1 -1
  64. package/dist/lib/i18n/messages.en.d.ts +6 -0
  65. package/dist/lib/i18n/messages.en.js +9 -0
  66. package/dist/lib/i18n/messages.en.js.map +1 -1
  67. package/dist/lib/references/references-store.d.ts +8 -1
  68. package/dist/lib/references/references-store.js +12 -2
  69. package/dist/lib/references/references-store.js.map +1 -1
  70. package/dist/lib/workspace/index.d.ts +10 -0
  71. package/dist/lib/workspace/index.js +11 -0
  72. package/dist/lib/workspace/index.js.map +1 -1
  73. package/dist/ui/dialog.d.ts +9 -1
  74. package/dist/ui/dialog.js +8 -2
  75. package/dist/ui/dialog.js.map +1 -1
  76. package/dist/ui/surface-geometry.d.ts +8 -5
  77. package/dist/ui/surface-geometry.js +8 -5
  78. package/dist/ui/surface-geometry.js.map +1 -1
  79. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"prop-fields.js","sourceRoot":"","sources":["../../../src/components/cms/prop-fields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAoCtF,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAA;QACjB,KAAK,QAAQ;YACX,iFAAiF;YACjF,8EAA8E;YAC9E,+EAA+E;YAC/E,gF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AAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport { isStaticProp } from '@elytracms/core/project-graph'\nimport type { JsonValue, PropValue } from '@elytracms/core/project-graph'\nimport type { PropField } from '@elytracms/core/component-registry'\nimport { fieldValueValidator } from '@elytracms/core/cms-core'\nimport type { FieldDef, SelectFieldDef, SelectOption } from '@elytracms/core/cms-core'\nimport { Input, Row, Select, Stack, Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { FieldControl } from './field-control'\nimport { SegmentedOptions } from './field-control-lib'\nimport { FieldDensityProvider } from './field-density'\nimport { RichTextEditor } from './rich-text'\nimport { useOptionalCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-190 \"props-as-fields\" value control — the single renderer for a\n * manifest-declared prop field, shared by the canvas property inspector\n * (`builder/property-inspector.tsx`) and the rich-text component-embed prop editor\n * (`rich-text/embed-props.tsx`). Extracted here so both surfaces render prop fields\n * through *one* control set (asset → library picker, relation → document picker,\n * object → nested form, …) rather than two parallel form systems.\n *\n * It is deliberately store-agnostic: it reads a prop's current value and reports\n * edits through `onSet(rawValue)` / `onClear()`. The caller owns *where* the value\n * lands — the inspector dispatches a builder command; the embed editor rewrites a\n * ProseMirror node attr — and is responsible for wrapping the raw value in a\n * `staticProp` envelope.\n */\n\n/**\n * The inspector control to render for a prop field-def. The `control.kind`\n * vocabulary derives from the field `type` plus the optional `form.control`\n * presentation hint on `text` fields.\n */\nexport type ControlKind =\n | 'text'\n | 'textarea'\n | 'number'\n | 'boolean'\n | 'select'\n | 'options'\n | 'json'\n | 'color'\n | 'richtext'\n | 'asset'\n | 'object'\n | 'relation'\n\nexport function controlKind(spec: PropField): ControlKind {\n switch (spec.type) {\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'select':\n // EC-393: a single-select prop opting into `form.control: 'options'` renders the\n // SAME segmented button group the document form uses (EC-295), not the native\n // dropdown — parity with `field-control.tsx`. Segmented is single-select only,\n // so a `multiple` select stays on the native control (mirroring field-control).\n if (spec.form?.control === 'options' && !spec.multiple) return 'options'\n return 'select'\n case 'richText':\n return 'richtext'\n // EC-195: an `asset`-typed prop (e.g. the Image `src`) picks from the asset\n // library — never a raw asset id typed into a text box (the EC-192 persona).\n case 'asset':\n return 'asset'\n // EC-253: an `object`/repeater prop reuses the CMS repeater control below.\n case 'object':\n return 'object'\n // EC-262: a `relation`-typed prop (e.g. a ProductGrid's `category`) reuses the\n // CMS relation picker — never a text box that stringifies the ref to \"[object Object]\".\n case 'relation':\n return 'relation'\n case 'text': {\n const c = spec.form?.control\n if (c === 'textarea') return 'textarea'\n if (c === 'color') return 'color'\n if (c === 'json') return 'json'\n return 'text'\n }\n default:\n return 'text'\n }\n}\n\n/**\n * EC-387: route a rich-text editor emission to the prop value callbacks.\n *\n * The shared {@link RichTextEditor} emits either an emptied-editor `undefined`, the\n * exact stored envelope (an untouched/reverted edit), or a fresh `{ version, doc }`\n * value — never a plain string. An `undefined` clears the prop (reverting to the\n * manifest default, matching the asset/relation/object controls); anything else is a\n * structured `JsonValue` envelope set verbatim. Extracted pure so the wiring — the\n * exact bug the retired textarea stub had (it wrote a bare string over the envelope) —\n * is regression-pinned without driving TipTap.\n */\nexport function applyRichTextPropChange(\n next: unknown,\n handlers: { onSet: (value: JsonValue) => void; onClear: () => void },\n): void {\n if (next === undefined) handlers.onClear()\n else handlers.onSet(next as JsonValue)\n}\n\nexport interface PropValueControlProps {\n /** DOM id for the control's primary input (label `htmlFor` target). */\n id: string\n /** The prop's field name — needed to synthesize the `FieldDef` for reused controls. */\n name: string\n /** The manifest prop field-def driving the control kind + validation. */\n spec: PropField\n /** The prop's current value envelope (or `undefined` when unset). */\n value: PropValue | undefined\n /** Commit a new raw value (the caller wraps it in a `staticProp`). */\n onSet: (value: JsonValue) => void\n /** Remove the prop (revert to the manifest default). */\n onClear: () => void\n}\n\n/**\n * Render + edit a single manifest prop value. Store-agnostic: emits through\n * `onSet`/`onClear`. Shows a validation issue when the current value fails the\n * prop's field-def validator.\n */\nexport function PropValueControl({ id, name, spec, value, onSet, onClear }: PropValueControlProps) {\n const current = isStaticProp(value) ? value.value : (spec.default as JsonValue | undefined)\n // The `asset`/`relation`/`object` controls delegate to the CMS `FieldControl`,\n // which reads the ambient `CollectionViewSource` (asset library, relation\n // candidates, nested form). The component-registry preview surface has no\n // document/collection context, so outside a provider those controls must degrade\n // to a read-only value display instead of throwing \"useCollectionView must be\n // used within a <CollectionViewProvider>\" (the Konditorei Components-view crash).\n const hasWorkspaceContext = useOptionalCollectionView() != null\n\n // EC-190: validate with the prop's field-def value validator.\n const valid = current === undefined || fieldValueValidator({ ...spec, name } as FieldDef)(current)\n // EC-190: derive the editor control from the field `type` + optional `form.control`.\n const kind = controlKind(spec)\n // Select options live on the `select` field-def.\n const options: readonly SelectOption[] = spec.type === 'select' ? spec.options : []\n // EC-395: `form.readOnly` parity with the document form. `cms-store.tsx`'s\n // `isFieldReadOnly` reads the identical `field.form?.readOnly === true` check —\n // every control kind below (including the delegated `FieldControl`/\n // `SegmentedOptions` mounts, which previously hardcoded `readOnly={false}`)\n // degrades to the SAME disabled/inert interaction the document form's\n // `FieldControl` renders for a read-only field, not a parallel treatment.\n const readOnly = spec.form?.readOnly === true\n\n let control\n if (kind === 'boolean') {\n control = (\n <label className=\"flex h-8 items-center gap-2 text-sm\">\n <input\n id={id}\n type=\"checkbox\"\n checked={current === true}\n disabled={readOnly}\n onChange={(e) => onSet(e.target.checked)}\n className=\"size-4 accent-primary disabled:opacity-50\"\n />\n <Text size=\"sm\" tone=\"muted\">\n {current === true ? translate('common.true') : translate('common.false')}\n </Text>\n </label>\n )\n } else if (kind === 'select') {\n control = (\n <Select\n id={id}\n disabled={readOnly}\n value={String(current ?? '')}\n onChange={(e) => {\n // EC-190: select option values are strings (field-def `options`).\n const opt = options.find((o) => o.value === e.target.value)\n onSet(opt ? opt.value : e.target.value)\n }}\n >\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {localizedLabel(opt.label, opt.value)}\n </option>\n ))}\n </Select>\n )\n } else if (kind === 'options') {\n // EC-393: reuse the EC-295 segmented control the document form renders (via\n // `field-control.tsx`) — delegation over a parallel dropdown. It reads the\n // field-def's own `options` (label + per-option `description` tooltip); single-\n // select only (picks one, no unset — an unset select keeps the native dropdown).\n control = (\n <SegmentedOptions\n id={id}\n field={{ ...spec, name } as SelectFieldDef}\n value={current}\n onChange={(v) => onSet(v as JsonValue)}\n readOnly={readOnly}\n />\n )\n } else if (kind === 'number') {\n control = (\n <NumberControl id={id} current={current} onSet={onSet} onClear={onClear} readOnly={readOnly} />\n )\n } else if (kind === 'json') {\n control = <JsonControl id={id} current={current} onSet={onSet} readOnly={readOnly} />\n } else if (kind === 'color') {\n control = (\n <Row gap=\"2\">\n <input\n id={id}\n type=\"color\"\n disabled={readOnly}\n value={typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000'}\n onChange={(e) => onSet(e.target.value)}\n className=\"h-8 w-10 shrink-0 rounded-md border border-input bg-background disabled:opacity-50\"\n />\n <Input\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n />\n </Row>\n )\n } else if (kind === 'richtext') {\n // EC-387: a richText PROP now uses the SAME real editor as the collection-field\n // path (`field-control.tsx` `case 'richText'`) — one editing surface, one\n // `{ version, doc }` value contract, never a second implementation. The retired\n // textarea stub read `typeof current === 'string'`, so a stored envelope showed\n // EMPTY and any edit clobbered the structured document with a bare string\n // (silent data destruction). The editor reads the envelope (or a legacy string,\n // or empty), always emits an envelope, and routes an emptied editor's `undefined`\n // to a prop clear via {@link applyRichTextPropChange}.\n //\n // Like the asset/relation/object controls below, the editor needs the ambient\n // workspace — its asset-image picker reads the REQUIRED collection-view context.\n // The block property inspector (the EC-387 target) is inside the detail editor's\n // `CollectionViewProvider`, so it gets the full editor; the component-registry\n // preview surface (no provider, nothing to edit against) degrades to the same\n // read-only value display the sibling controls use, instead of crashing with\n // \"useCollectionView must be used within a <CollectionViewProvider>\".\n control = hasWorkspaceContext ? (\n <RichTextEditor\n id={id}\n value={current}\n onChange={(next) => applyRichTextPropChange(next, { onSet, onClear })}\n allow={spec.type === 'richText' ? spec.allow : undefined}\n readOnly={readOnly}\n />\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else if (kind === 'textarea') {\n control = (\n <textarea\n id={id}\n rows={2}\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n )\n } else if (kind === 'asset' || kind === 'object' || kind === 'relation') {\n // EC-195/EC-253/EC-262: reuse the CMS field control. `asset` = library picker +\n // preview; `object` = the nested/repeater form; `relation` = the document picker\n // (resolves the ref to its title, instead of stringifying it to \"[object Object]\").\n // All edit a structured static prop value through the same shared control documents use.\n // Without a workspace context (the Components preview), degrade to a read-only\n // value display so the pane renders instead of throwing.\n control = hasWorkspaceContext ? (\n <FieldDensityProvider density=\"compact\">\n <FieldControl\n id={id}\n field={{ ...spec, name } as FieldDef}\n value={current}\n onChange={(v) => (v === undefined || v === null ? onClear() : onSet(v as JsonValue))}\n readOnly={readOnly}\n />\n </FieldDensityProvider>\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else {\n control = (\n <Input\n id={id}\n disabled={readOnly}\n value={typeof current === 'string' ? current : String(current ?? '')}\n onChange={(e) => onSet(e.target.value)}\n />\n )\n }\n\n return (\n <Stack gap=\"1\">\n {control}\n {/* EC-395: a read-only prop's value can't be fixed here — suppress the\n invalid-value flag exactly like the document form suppresses its field\n error on a read-only row (`detail-editor.tsx`'s\n `error={fieldReadOnly ? undefined : ...}`). */}\n {!valid && !readOnly ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {translate('builder.inspector.invalidValue')}\n </Text>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Read-only stand-in for an `asset`/`relation`/`object` prop when there is no\n * ambient `CollectionViewSource` (the component-registry preview, which has no\n * document/collection context). Shows the current value and a hint that it is\n * editable inside a document — never the live picker, which needs a workspace.\n */\nfunction WorkspaceValueFallback({ value }: { value: JsonValue | undefined }) {\n const text =\n value === undefined || value === null\n ? '—'\n : typeof value === 'string'\n ? value\n : JSON.stringify(value)\n return (\n <Stack gap=\"1\">\n <div className=\"truncate rounded-md border border-input bg-muted/30 px-2.5 py-1.5 text-sm text-muted-foreground\">\n {text}\n </div>\n <Text size=\"xs\" tone=\"muted\">\n {translate('components.preview.propNeedsDocument')}\n </Text>\n </Stack>\n )\n}\n\n/** Number input with a local buffer: commits only finite values, never NaN; empty clears the prop. */\nfunction NumberControl({\n id,\n current,\n onSet,\n onClear,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: number) => void\n onClear: () => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(typeof current === 'number' ? String(current) : '')\n useEffect(() => {\n setRaw(typeof current === 'number' ? String(current) : '')\n }, [current])\n return (\n <Input\n id={id}\n type=\"number\"\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n if (v.trim() === '') {\n onClear()\n return\n }\n const n = Number(v)\n if (Number.isFinite(n)) onSet(n)\n }}\n />\n )\n}\n\n/** JSON textarea with a local buffer: commits only when the text parses; flags parse errors. */\nfunction JsonControl({\n id,\n current,\n onSet,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: JsonValue) => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(() => JSON.stringify(current ?? null))\n const [error, setError] = useState<string | null>(null)\n useEffect(() => {\n setRaw(JSON.stringify(current ?? null))\n setError(null)\n }, [current])\n return (\n <Stack gap=\"1\">\n <textarea\n id={id}\n rows={3}\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n try {\n onSet(JSON.parse(v) as JsonValue)\n setError(null)\n } catch {\n setError(translate('builder.inspector.invalidJson'))\n }\n }}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {error ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {error}\n </Text>\n ) : null}\n </Stack>\n )\n}\n"]}
1
+ {"version":3,"file":"prop-fields.js","sourceRoot":"","sources":["../../../src/components/cms/prop-fields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAoCtF,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAA;QACjB,KAAK,QAAQ;YACX,iFAAiF;YACjF,8EAA8E;YAC9E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A2P,GACrQ,EACD,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,kBAAkB,YACzC,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,IACF,CACT,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useState } from 'react'\nimport { isStaticProp } from '@elytracms/core/project-graph'\nimport type { JsonValue, PropValue } from '@elytracms/core/project-graph'\nimport type { PropField } from '@elytracms/core/component-registry'\nimport { fieldValueValidator } from '@elytracms/core/cms-core'\nimport type { FieldDef, SelectFieldDef, SelectOption } from '@elytracms/core/cms-core'\nimport { Input, Row, Select, Stack, Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { FieldControl } from './field-control'\nimport { SegmentedOptions } from './field-control-lib'\nimport { FieldDensityProvider } from './field-density'\nimport { RichTextEditor } from './rich-text'\nimport { useOptionalCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-190 \"props-as-fields\" value control — the single renderer for a\n * manifest-declared prop field, shared by the canvas property inspector\n * (`builder/property-inspector.tsx`) and the rich-text component-embed prop editor\n * (`rich-text/embed-props.tsx`). Extracted here so both surfaces render prop fields\n * through *one* control set (asset → library picker, relation → document picker,\n * object → nested form, …) rather than two parallel form systems.\n *\n * It is deliberately store-agnostic: it reads a prop's current value and reports\n * edits through `onSet(rawValue)` / `onClear()`. The caller owns *where* the value\n * lands — the inspector dispatches a builder command; the embed editor rewrites a\n * ProseMirror node attr — and is responsible for wrapping the raw value in a\n * `staticProp` envelope.\n */\n\n/**\n * The inspector control to render for a prop field-def. The `control.kind`\n * vocabulary derives from the field `type` plus the optional `form.control`\n * presentation hint on `text` fields.\n */\nexport type ControlKind =\n | 'text'\n | 'textarea'\n | 'number'\n | 'boolean'\n | 'select'\n | 'options'\n | 'json'\n | 'color'\n | 'richtext'\n | 'asset'\n | 'object'\n | 'relation'\n\nexport function controlKind(spec: PropField): ControlKind {\n switch (spec.type) {\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'select':\n // EC-393: a single-select prop opting into `form.control: 'options'` renders the\n // SAME segmented button group the document form uses (EC-295), not the native\n // dropdown — parity with `field-control.tsx`. Segmented is single-select only,\n // so a `multiple` select stays on the native control (mirroring field-control).\n if (spec.form?.control === 'options' && !spec.multiple) return 'options'\n return 'select'\n case 'richText':\n return 'richtext'\n // EC-195: an `asset`-typed prop (e.g. the Image `src`) picks from the asset\n // library — never a raw asset id typed into a text box (the EC-192 persona).\n case 'asset':\n return 'asset'\n // EC-253: an `object`/repeater prop reuses the CMS repeater control below.\n case 'object':\n return 'object'\n // EC-262: a `relation`-typed prop (e.g. a ProductGrid's `category`) reuses the\n // CMS relation picker — never a text box that stringifies the ref to \"[object Object]\".\n case 'relation':\n return 'relation'\n case 'text': {\n const c = spec.form?.control\n if (c === 'textarea') return 'textarea'\n if (c === 'color') return 'color'\n if (c === 'json') return 'json'\n return 'text'\n }\n default:\n return 'text'\n }\n}\n\n/**\n * EC-387: route a rich-text editor emission to the prop value callbacks.\n *\n * The shared {@link RichTextEditor} emits either an emptied-editor `undefined`, the\n * exact stored envelope (an untouched/reverted edit), or a fresh `{ version, doc }`\n * value — never a plain string. An `undefined` clears the prop (reverting to the\n * manifest default, matching the asset/relation/object controls); anything else is a\n * structured `JsonValue` envelope set verbatim. Extracted pure so the wiring — the\n * exact bug the retired textarea stub had (it wrote a bare string over the envelope) —\n * is regression-pinned without driving TipTap.\n */\nexport function applyRichTextPropChange(\n next: unknown,\n handlers: { onSet: (value: JsonValue) => void; onClear: () => void },\n): void {\n if (next === undefined) handlers.onClear()\n else handlers.onSet(next as JsonValue)\n}\n\nexport interface PropValueControlProps {\n /** DOM id for the control's primary input (label `htmlFor` target). */\n id: string\n /** The prop's field name — needed to synthesize the `FieldDef` for reused controls. */\n name: string\n /** The manifest prop field-def driving the control kind + validation. */\n spec: PropField\n /** The prop's current value envelope (or `undefined` when unset). */\n value: PropValue | undefined\n /** Commit a new raw value (the caller wraps it in a `staticProp`). */\n onSet: (value: JsonValue) => void\n /** Remove the prop (revert to the manifest default). */\n onClear: () => void\n}\n\n/**\n * Render + edit a single manifest prop value. Store-agnostic: emits through\n * `onSet`/`onClear`. Shows a validation issue when the current value fails the\n * prop's field-def validator.\n */\nexport function PropValueControl({ id, name, spec, value, onSet, onClear }: PropValueControlProps) {\n const current = isStaticProp(value) ? value.value : (spec.default as JsonValue | undefined)\n // The `asset`/`relation`/`object` controls delegate to the CMS `FieldControl`,\n // which reads the ambient `CollectionViewSource` (asset library, relation\n // candidates, nested form). The component-registry preview surface has no\n // document/collection context, so outside a provider those controls must degrade\n // to a read-only value display instead of throwing \"useCollectionView must be\n // used within a <CollectionViewProvider>\" (the Konditorei Components-view crash).\n const hasWorkspaceContext = useOptionalCollectionView() != null\n\n // EC-190: validate with the prop's field-def value validator.\n const valid = current === undefined || fieldValueValidator({ ...spec, name } as FieldDef)(current)\n // EC-190: derive the editor control from the field `type` + optional `form.control`.\n const kind = controlKind(spec)\n // Select options live on the `select` field-def.\n const options: readonly SelectOption[] = spec.type === 'select' ? spec.options : []\n // EC-395: `form.readOnly` parity with the document form. `cms-store.tsx`'s\n // `isFieldReadOnly` reads the identical `field.form?.readOnly === true` check —\n // every control kind below (including the delegated `FieldControl`/\n // `SegmentedOptions` mounts, which previously hardcoded `readOnly={false}`)\n // degrades to the SAME disabled/inert interaction the document form's\n // `FieldControl` renders for a read-only field, not a parallel treatment.\n const readOnly = spec.form?.readOnly === true\n\n let control\n if (kind === 'boolean') {\n control = (\n <label className=\"flex h-8 items-center gap-2 text-sm\">\n <input\n id={id}\n type=\"checkbox\"\n checked={current === true}\n disabled={readOnly}\n onChange={(e) => onSet(e.target.checked)}\n className=\"size-4 accent-primary disabled:opacity-50\"\n />\n <Text size=\"sm\" tone=\"muted\">\n {current === true ? translate('common.true') : translate('common.false')}\n </Text>\n </label>\n )\n } else if (kind === 'select') {\n control = (\n <Select\n id={id}\n disabled={readOnly}\n value={String(current ?? '')}\n onChange={(e) => {\n // EC-190: select option values are strings (field-def `options`).\n const opt = options.find((o) => o.value === e.target.value)\n onSet(opt ? opt.value : e.target.value)\n }}\n >\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {localizedLabel(opt.label, opt.value)}\n </option>\n ))}\n </Select>\n )\n } else if (kind === 'options') {\n // EC-393: reuse the EC-295 segmented control the document form renders (via\n // `field-control.tsx`) — delegation over a parallel dropdown. It reads the\n // field-def's own `options` (label + per-option `description` tooltip); single-\n // select only (picks one, no unset — an unset select keeps the native dropdown).\n control = (\n <SegmentedOptions\n id={id}\n field={{ ...spec, name } as SelectFieldDef}\n value={current}\n onChange={(v) => onSet(v as JsonValue)}\n readOnly={readOnly}\n />\n )\n } else if (kind === 'number') {\n control = (\n <NumberControl id={id} current={current} onSet={onSet} onClear={onClear} readOnly={readOnly} />\n )\n } else if (kind === 'json') {\n control = <JsonControl id={id} current={current} onSet={onSet} readOnly={readOnly} />\n } else if (kind === 'color') {\n control = (\n <Row gap=\"2\">\n <input\n id={id}\n type=\"color\"\n disabled={readOnly}\n value={typeof current === 'string' && /^#[0-9a-f]{6}$/i.test(current) ? current : '#000000'}\n onChange={(e) => onSet(e.target.value)}\n className=\"h-8 w-10 shrink-0 rounded-md border border-input bg-background disabled:opacity-50\"\n />\n <Input\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n />\n </Row>\n )\n } else if (kind === 'richtext') {\n // EC-387: a richText PROP now uses the SAME real editor as the collection-field\n // path (`field-control.tsx` `case 'richText'`) — one editing surface, one\n // `{ version, doc }` value contract, never a second implementation. The retired\n // textarea stub read `typeof current === 'string'`, so a stored envelope showed\n // EMPTY and any edit clobbered the structured document with a bare string\n // (silent data destruction). The editor reads the envelope (or a legacy string,\n // or empty), always emits an envelope, and routes an emptied editor's `undefined`\n // to a prop clear via {@link applyRichTextPropChange}.\n //\n // Like the asset/relation/object controls below, the editor needs the ambient\n // workspace — its asset-image picker reads the REQUIRED collection-view context.\n // The block property inspector (the EC-387 target) is inside the detail editor's\n // `CollectionViewProvider`, so it gets the full editor; the component-registry\n // preview surface (no provider, nothing to edit against) degrades to the same\n // read-only value display the sibling controls use, instead of crashing with\n // \"useCollectionView must be used within a <CollectionViewProvider>\".\n control = hasWorkspaceContext ? (\n <RichTextEditor\n id={id}\n value={current}\n onChange={(next) => applyRichTextPropChange(next, { onSet, onClear })}\n allow={spec.type === 'richText' ? spec.allow : undefined}\n readOnly={readOnly}\n // EC-436: the SAME resolved localized label the prop row renders (the\n // property inspector / embed form's `Field label`) — titles the expand\n // stage \"<label> — Rich text\".\n label={localizedLabel(spec.form?.label, name)}\n />\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else if (kind === 'textarea') {\n control = (\n <textarea\n id={id}\n rows={2}\n disabled={readOnly}\n value={typeof current === 'string' ? current : ''}\n onChange={(e) => onSet(e.target.value)}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 text-sm text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n )\n } else if (kind === 'asset' || kind === 'object' || kind === 'relation') {\n // EC-195/EC-253/EC-262: reuse the CMS field control. `asset` = library picker +\n // preview; `object` = the nested/repeater form; `relation` = the document picker\n // (resolves the ref to its title, instead of stringifying it to \"[object Object]\").\n // All edit a structured static prop value through the same shared control documents use.\n // Without a workspace context (the Components preview), degrade to a read-only\n // value display so the pane renders instead of throwing.\n control = hasWorkspaceContext ? (\n <FieldDensityProvider density=\"compact\">\n <FieldControl\n id={id}\n field={{ ...spec, name } as FieldDef}\n value={current}\n onChange={(v) => (v === undefined || v === null ? onClear() : onSet(v as JsonValue))}\n readOnly={readOnly}\n />\n </FieldDensityProvider>\n ) : (\n <WorkspaceValueFallback value={current} />\n )\n } else {\n control = (\n <Input\n id={id}\n disabled={readOnly}\n value={typeof current === 'string' ? current : String(current ?? '')}\n onChange={(e) => onSet(e.target.value)}\n />\n )\n }\n\n return (\n <Stack gap=\"1\">\n {control}\n {/* EC-395: a read-only prop's value can't be fixed here — suppress the\n invalid-value flag exactly like the document form suppresses its field\n error on a read-only row (`detail-editor.tsx`'s\n `error={fieldReadOnly ? undefined : ...}`). */}\n {!valid && !readOnly ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {translate('builder.inspector.invalidValue')}\n </Text>\n ) : null}\n </Stack>\n )\n}\n\n/**\n * Read-only stand-in for an `asset`/`relation`/`object` prop when there is no\n * ambient `CollectionViewSource` (the component-registry preview, which has no\n * document/collection context). Shows the current value and a hint that it is\n * editable inside a document — never the live picker, which needs a workspace.\n */\nfunction WorkspaceValueFallback({ value }: { value: JsonValue | undefined }) {\n const text =\n value === undefined || value === null\n ? '—'\n : typeof value === 'string'\n ? value\n : JSON.stringify(value)\n return (\n <Stack gap=\"1\">\n <div className=\"truncate rounded-md border border-input bg-muted/30 px-2.5 py-1.5 text-sm text-muted-foreground\">\n {text}\n </div>\n <Text size=\"xs\" tone=\"muted\">\n {translate('components.preview.propNeedsDocument')}\n </Text>\n </Stack>\n )\n}\n\n/** Number input with a local buffer: commits only finite values, never NaN; empty clears the prop. */\nfunction NumberControl({\n id,\n current,\n onSet,\n onClear,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: number) => void\n onClear: () => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(typeof current === 'number' ? String(current) : '')\n useEffect(() => {\n setRaw(typeof current === 'number' ? String(current) : '')\n }, [current])\n return (\n <Input\n id={id}\n type=\"number\"\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n if (v.trim() === '') {\n onClear()\n return\n }\n const n = Number(v)\n if (Number.isFinite(n)) onSet(n)\n }}\n />\n )\n}\n\n/** JSON textarea with a local buffer: commits only when the text parses; flags parse errors. */\nfunction JsonControl({\n id,\n current,\n onSet,\n readOnly,\n}: {\n id: string\n current: JsonValue | undefined\n onSet: (v: JsonValue) => void\n readOnly: boolean\n}) {\n const [raw, setRaw] = useState(() => JSON.stringify(current ?? null))\n const [error, setError] = useState<string | null>(null)\n useEffect(() => {\n setRaw(JSON.stringify(current ?? null))\n setError(null)\n }, [current])\n return (\n <Stack gap=\"1\">\n <textarea\n id={id}\n rows={3}\n disabled={readOnly}\n value={raw}\n onChange={(e) => {\n const v = e.target.value\n setRaw(v)\n try {\n onSet(JSON.parse(v) as JsonValue)\n setError(null)\n } catch {\n setError(translate('builder.inspector.invalidJson'))\n }\n }}\n className=\"flex w-full rounded-md border border-input bg-background px-2.5 py-1.5 font-mono text-xs text-foreground shadow-sm focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 outline-none disabled:cursor-not-allowed disabled:opacity-50\"\n />\n {error ? (\n <Text size=\"xs\" className=\"text-destructive\">\n {error}\n </Text>\n ) : null}\n </Stack>\n )\n}\n"]}
@@ -29,7 +29,11 @@ export function ReferenceConfirmDialog({ projectId, action, targets, open, busy
29
29
  // Queued session mutations (and the persisted baseline) must land
30
30
  // before the pre-flight query — the index is maintained on write.
31
31
  await source.flush?.();
32
- const views = await loadInboundReferenceViews(projectId, targets);
32
+ // The source knows how its records are addressed in the reference
33
+ // index (EC-433): documents by default, `{ type: 'asset' }` for the
34
+ // assets rail — so this pre-flight counts the SAME references the
35
+ // rail's detail surface does.
36
+ const views = await loadInboundReferenceViews(projectId, targets, source.referenceTarget);
33
37
  if (cancelled)
34
38
  return;
35
39
  setImpact(buildReferenceImpact(source.collections, action, views));
@@ -1 +1 @@
1
- {"version":3,"file":"reference-confirm.js","sourceRoot":"","sources":["../../../src/components/cms/reference-confirm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,SAA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T_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { AlertTriangle, ShieldAlert } from 'lucide-react'\nimport { useEffect, useMemo, useState } from 'react'\nimport { documentKey } from '@elytracms/core/cms-core'\nimport type { DocumentRef } from '@elytracms/core/cms-core'\nimport { buildReferenceImpact, loadInboundReferenceViews } from '@elytracms/studio/lib/references'\nimport type {\n DocumentReferenceImpact,\n ReferenceAction,\n ReferenceDeepLink,\n ReferenceEntryView,\n ReferenceImpact,\n} from '@elytracms/studio/lib/references'\nimport {\n Badge,\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { useCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-173 reference-aware confirmation dialog for unpublish/delete —\n * single documents (detail editor) and bulk selections (EC-169 bulk bar)\n * alike. It inverts the industry default, visibly:\n *\n * 1. *Before* the action it enumerates every inbound reference that will\n * break (published variant for unpublish, both variants for delete), with\n * the EC-172 labels and deep links to the exact field/node.\n * 2. Proceeding is allowed — weak references are the default. Zero references\n * render a plain confirm; breakage renders \"You can … — N places will show\n * a fallback\".\n * 3. Strict opt-in relation fields (`strict: true`) flip the same dialog into\n * a real block: the proceed button is disabled and every blocking referrer\n * is named and linked. The `@elytracms/core/operations` layer enforces the same\n * rule server-side (structured conflict error) — this dialog is the\n * friendly face, not the only guard.\n *\n * Pre-flight data goes through operations reference queries only (EC-155\n * index, flushed); impact semantics live in `lib/references/impact.ts`.\n */\n\ntype ImpactStatus = 'loading' | 'ready' | 'unavailable'\n\nconst ACTION_LABELS: Record<ReferenceAction, string> = {\n unpublish: translate('cms.editor.unpublish'),\n delete: translate('common.delete'),\n}\n\nexport function ReferenceConfirmDialog({\n projectId,\n action,\n targets,\n open,\n busy = false,\n onOpenChange,\n onConfirm,\n}: {\n projectId: string\n action: ReferenceAction\n /** The documents being acted on (a stable snapshot taken when opening). */\n targets: readonly DocumentRef[]\n open: boolean\n busy?: boolean\n onOpenChange: (open: boolean) => void\n onConfirm: () => void\n}) {\n const source = useCollectionView()\n const [status, setStatus] = useState<ImpactStatus>('loading')\n const [impact, setImpact] = useState<ReferenceImpact | null>(null)\n\n // A stable identity for the acted-on set, so the effect re-runs exactly\n // when the selection (not the array instance) changes.\n const targetsKey = targets.map((ref) => documentKey(ref)).join('\\n')\n\n useEffect(() => {\n if (!open || targets.length === 0) return\n let cancelled = false\n setStatus('loading')\n setImpact(null)\n void (async () => {\n try {\n // Queued session mutations (and the persisted baseline) must land\n // before the pre-flight query — the index is maintained on write.\n await source.flush?.()\n const views = await loadInboundReferenceViews(projectId, targets)\n if (cancelled) return\n setImpact(buildReferenceImpact(source.collections, action, views))\n setStatus('ready')\n } catch {\n // The index being unreachable must not trap the editor: degrade to a\n // plain confirm with an explicit \"could not check\" warning.\n if (!cancelled) setStatus('unavailable')\n }\n })()\n return () => {\n cancelled = true\n }\n // `targetsKey` stands in for `targets` (stable identity for the acted-on set).\n }, [open, action, targetsKey, projectId])\n\n const actionLabel = ACTION_LABELS[action]\n const subject = useMemo(() => {\n if (targets.length === 1) {\n const ref = targets[0]!\n return `“${source.titleOf(ref)}”`\n }\n return translate('cms.reference.documentCount', { count: targets.length })\n }, [targets, source])\n\n const blocked = status === 'ready' && (impact?.totalBlocking ?? 0) > 0\n const totalBroken = impact?.totalBroken ?? 0\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-testid=\"reference-confirm\" className=\"max-h-[80vh] overflow-y-auto\">\n <DialogHeader>\n <DialogTitle>\n {translate('cms.reference.confirmTitle', { action: actionLabel, subject })}\n </DialogTitle>\n <DialogDescription data-testid=\"reference-confirm-summary\">\n {status === 'loading' ? (\n translate('cms.reference.checking')\n ) : status === 'unavailable' ? (\n translate('cms.reference.checkUnavailable')\n ) : blocked ? (\n translate(\n impact!.totalBlocking === 1\n ? 'cms.reference.blocked.one'\n : 'cms.reference.blocked.other',\n { count: impact!.totalBlocking },\n )\n ) : totalBroken === 0 ? (\n <>\n {translate('cms.reference.notReferenced')}\n {action === 'delete'\n ? ` ${translate(\n targets.length === 1\n ? 'cms.reference.permanentDelete.one'\n : 'cms.reference.permanentDelete.other',\n { count: targets.length },\n )}`\n : ''}\n </>\n ) : (\n translate('cms.reference.canProceed', {\n action: translate(\n action === 'unpublish'\n ? 'cms.reference.verb.unpublish'\n : 'cms.reference.verb.delete',\n ),\n summary: impactSummary(targets.length, totalBroken),\n })\n )}\n </DialogDescription>\n </DialogHeader>\n\n {status === 'ready' && impact !== null && totalBroken > 0 ? (\n <ImpactList projectId={projectId} impact={impact} onNavigate={() => onOpenChange(false)} />\n ) : null}\n {status === 'unavailable' ? (\n <Row gap=\"2\" data-testid=\"reference-confirm-unavailable\">\n <AlertTriangle className=\"size-4 shrink-0 text-warning\" />\n <Text size=\"xs\" tone=\"muted\">\n {translate('cms.reference.proceedUnavailable')}\n </Text>\n </Row>\n ) : null}\n\n <DialogFooter>\n <Button\n variant=\"outline\"\n data-testid=\"reference-confirm-cancel\"\n onClick={() => onOpenChange(false)}\n >\n {translate('common.cancel')}\n </Button>\n <Button\n variant={action === 'delete' ? 'destructive' : 'default'}\n disabled={status === 'loading' || blocked || busy}\n data-testid=\"reference-confirm-proceed\"\n onClick={onConfirm}\n >\n {totalBroken > 0 && !blocked\n ? translate('cms.reference.proceedAnyway', { action: actionLabel })\n : actionLabel}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction impactSummary(targetCount: number, totalBroken: number): string {\n const places = translate(\n totalBroken === 1 ? 'cms.reference.placeCount.one' : 'cms.reference.placeCount.other',\n { count: totalBroken },\n )\n // The bulk aggregate: \"N documents, M inbound references will break.\"\n return targetCount > 1\n ? translate('cms.reference.bulkSummary', { count: targetCount, places })\n : places\n}\n\n/**\n * The enumerated impact: flat for a single target, grouped per target for\n * bulk selections (per-item detail, EC-169 honesty rules).\n */\nfunction ImpactList({\n projectId,\n impact,\n onNavigate,\n}: {\n projectId: string\n impact: ReferenceImpact\n onNavigate: () => void\n}) {\n const affected = impact.documents.filter((doc) => doc.broken.length > 0)\n return (\n <Stack gap=\"3\" data-testid=\"reference-confirm-impact\">\n {affected.map((doc) => (\n <ImpactGroup\n key={documentKey(doc.ref)}\n projectId={projectId}\n doc={doc}\n grouped={impact.documents.length > 1}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\nfunction ImpactGroup({\n projectId,\n doc,\n grouped,\n onNavigate,\n}: {\n projectId: string\n doc: DocumentReferenceImpact\n grouped: boolean\n onNavigate: () => void\n}) {\n const source = useCollectionView()\n const blockingKeys = new Set(doc.blocking.map((entry) => entry.key))\n return (\n <Stack gap=\"2\" data-testid={`reference-confirm-doc-${doc.ref.id}`}>\n {grouped ? (\n <Row gap=\"2\">\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\" className=\"uppercase tracking-wide\">\n {source.titleOf(doc.ref)}\n </Text>\n <Badge variant=\"outline\">{doc.broken.length}</Badge>\n </Row>\n ) : null}\n {doc.broken.map((entry) => (\n <ImpactEntryRow\n key={entry.key}\n projectId={projectId}\n entry={entry}\n blocking={blockingKeys.has(entry.key)}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\n/**\n * The shared EC-173 impact rows: one deep-linked row per broken inbound\n * reference, strict-blocking ones flagged. Rendered by the document\n * confirmation dialog (above) and the asset-delete dialog (EC-202) alike — both\n * reduce to \"these places reference the thing you're removing\", so both lean on\n * the same row + deep-link rendering (which already handles asset link kinds).\n */\nexport function ReferenceImpactRows({\n projectId,\n broken,\n blocking = [],\n onNavigate,\n}: {\n projectId: string\n broken: readonly ReferenceEntryView[]\n blocking?: readonly ReferenceEntryView[]\n onNavigate: () => void\n}) {\n const blockingKeys = new Set(blocking.map((entry) => entry.key))\n return (\n <Stack gap=\"2\" data-testid=\"reference-impact-rows\">\n {broken.map((entry) => (\n <ImpactEntryRow\n key={entry.key}\n projectId={projectId}\n entry={entry}\n blocking={blockingKeys.has(entry.key)}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\n/**\n * One affected place: the EC-172 labels with a working deep link to the exact\n * field/node, the entry kind, draft/published visibility — and a strict\n * marker when this entry is what blocks the action.\n */\nfunction ImpactEntryRow({\n projectId,\n entry,\n blocking,\n onNavigate,\n}: {\n projectId: string\n entry: ReferenceEntryView\n blocking: boolean\n onNavigate: () => void\n}) {\n return (\n <Row\n gap=\"2\"\n className={\n blocking\n ? 'rounded-md border border-destructive/50 bg-destructive/5 px-2.5 py-2'\n : 'rounded-md border border-border/70 bg-background/40 px-2.5 py-2'\n }\n data-testid=\"reference-confirm-entry\"\n >\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <ImpactDeepLink\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.sourceLabel}\n primary\n onNavigate={onNavigate}\n />\n <Row gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" tone=\"muted\" className=\"shrink-0\">\n {translate('cms.reference.atLocation')}\n </Text>\n <ImpactDeepLink\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.locationLabel}\n onNavigate={onNavigate}\n />\n </Row>\n </Stack>\n {blocking ? (\n <Badge variant=\"error\" data-testid=\"reference-confirm-strict\">\n <ShieldAlert className=\"size-3\" /> {translate('cms.reference.strictBadge')}\n </Badge>\n ) : null}\n <Badge variant=\"outline\" className=\"shrink-0\">\n {entry.kindLabel}\n </Badge>\n <Row gap=\"1\" className=\"shrink-0\">\n {entry.draft ? <Badge variant=\"warning\">{translate('cms.reference.draftBadge')}</Badge> : null}\n {entry.published ? (\n <Badge variant=\"success\">{translate('cms.reference.publishedBadge')}</Badge>\n ) : null}\n </Row>\n </Row>\n )\n}\n\n/** A deep link to the exact source location; closes the dialog on navigate. */\nfunction ImpactDeepLink({\n projectId,\n link,\n label,\n primary = false,\n onNavigate,\n}: {\n projectId: string\n link: ReferenceDeepLink | null\n label: string\n primary?: boolean\n onNavigate: () => void\n}) {\n const className = primary\n ? 'min-w-0 truncate text-sm font-medium text-foreground hover:text-primary hover:underline'\n : 'min-w-0 truncate text-xs text-muted-foreground hover:text-primary hover:underline'\n if (link === null) {\n return primary ? (\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n )\n }\n switch (link.kind) {\n case 'cms-field':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsDocument(link.collectionId, link.documentId) }}\n search={link.fieldPath !== undefined ? { field: link.fieldPath } : {}}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'builder-node':\n // The builder redirect (EC-187) only reads `?page=`; the page-graph-only\n // `node` has no home in the document editor and is dropped.\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.builder() }}\n search={link.pageId !== undefined ? { page: link.pageId } : {}}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'component':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.component(link.componentId) }}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'asset':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.assets() }}\n search={{ asset: link.assetId }}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n }\n}\n"]}
1
+ {"version":3,"file":"reference-confirm.js","sourceRoot":"","sources":["../../../src/components/cms/reference-confirm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAA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,OAAO,EAAE,EAC/B,SAAS,EAAE,SAAS,iBACR,wBAAwB,EACpC,OAAO,EAAE,UAAU,YAElB,KAAK,GACD,CACR,CAAA;IACL,CAAC;AACH,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { AlertTriangle, ShieldAlert } from 'lucide-react'\nimport { useEffect, useMemo, useState } from 'react'\nimport { documentKey } from '@elytracms/core/cms-core'\nimport type { DocumentRef } from '@elytracms/core/cms-core'\nimport { buildReferenceImpact, loadInboundReferenceViews } from '@elytracms/studio/lib/references'\nimport type {\n DocumentReferenceImpact,\n ReferenceAction,\n ReferenceDeepLink,\n ReferenceEntryView,\n ReferenceImpact,\n} from '@elytracms/studio/lib/references'\nimport {\n Badge,\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { useCollectionView } from '../collection-view/collection-view-context'\n\n/**\n * The EC-173 reference-aware confirmation dialog for unpublish/delete —\n * single documents (detail editor) and bulk selections (EC-169 bulk bar)\n * alike. It inverts the industry default, visibly:\n *\n * 1. *Before* the action it enumerates every inbound reference that will\n * break (published variant for unpublish, both variants for delete), with\n * the EC-172 labels and deep links to the exact field/node.\n * 2. Proceeding is allowed — weak references are the default. Zero references\n * render a plain confirm; breakage renders \"You can … — N places will show\n * a fallback\".\n * 3. Strict opt-in relation fields (`strict: true`) flip the same dialog into\n * a real block: the proceed button is disabled and every blocking referrer\n * is named and linked. The `@elytracms/core/operations` layer enforces the same\n * rule server-side (structured conflict error) — this dialog is the\n * friendly face, not the only guard.\n *\n * Pre-flight data goes through operations reference queries only (EC-155\n * index, flushed); impact semantics live in `lib/references/impact.ts`.\n */\n\ntype ImpactStatus = 'loading' | 'ready' | 'unavailable'\n\nconst ACTION_LABELS: Record<ReferenceAction, string> = {\n unpublish: translate('cms.editor.unpublish'),\n delete: translate('common.delete'),\n}\n\nexport function ReferenceConfirmDialog({\n projectId,\n action,\n targets,\n open,\n busy = false,\n onOpenChange,\n onConfirm,\n}: {\n projectId: string\n action: ReferenceAction\n /** The documents being acted on (a stable snapshot taken when opening). */\n targets: readonly DocumentRef[]\n open: boolean\n busy?: boolean\n onOpenChange: (open: boolean) => void\n onConfirm: () => void\n}) {\n const source = useCollectionView()\n const [status, setStatus] = useState<ImpactStatus>('loading')\n const [impact, setImpact] = useState<ReferenceImpact | null>(null)\n\n // A stable identity for the acted-on set, so the effect re-runs exactly\n // when the selection (not the array instance) changes.\n const targetsKey = targets.map((ref) => documentKey(ref)).join('\\n')\n\n useEffect(() => {\n if (!open || targets.length === 0) return\n let cancelled = false\n setStatus('loading')\n setImpact(null)\n void (async () => {\n try {\n // Queued session mutations (and the persisted baseline) must land\n // before the pre-flight query — the index is maintained on write.\n await source.flush?.()\n // The source knows how its records are addressed in the reference\n // index (EC-433): documents by default, `{ type: 'asset' }` for the\n // assets rail — so this pre-flight counts the SAME references the\n // rail's detail surface does.\n const views = await loadInboundReferenceViews(projectId, targets, source.referenceTarget)\n if (cancelled) return\n setImpact(buildReferenceImpact(source.collections, action, views))\n setStatus('ready')\n } catch {\n // The index being unreachable must not trap the editor: degrade to a\n // plain confirm with an explicit \"could not check\" warning.\n if (!cancelled) setStatus('unavailable')\n }\n })()\n return () => {\n cancelled = true\n }\n // `targetsKey` stands in for `targets` (stable identity for the acted-on set).\n }, [open, action, targetsKey, projectId])\n\n const actionLabel = ACTION_LABELS[action]\n const subject = useMemo(() => {\n if (targets.length === 1) {\n const ref = targets[0]!\n return `“${source.titleOf(ref)}”`\n }\n return translate('cms.reference.documentCount', { count: targets.length })\n }, [targets, source])\n\n const blocked = status === 'ready' && (impact?.totalBlocking ?? 0) > 0\n const totalBroken = impact?.totalBroken ?? 0\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-testid=\"reference-confirm\" className=\"max-h-[80vh] overflow-y-auto\">\n <DialogHeader>\n <DialogTitle>\n {translate('cms.reference.confirmTitle', { action: actionLabel, subject })}\n </DialogTitle>\n <DialogDescription data-testid=\"reference-confirm-summary\">\n {status === 'loading' ? (\n translate('cms.reference.checking')\n ) : status === 'unavailable' ? (\n translate('cms.reference.checkUnavailable')\n ) : blocked ? (\n translate(\n impact!.totalBlocking === 1\n ? 'cms.reference.blocked.one'\n : 'cms.reference.blocked.other',\n { count: impact!.totalBlocking },\n )\n ) : totalBroken === 0 ? (\n <>\n {translate('cms.reference.notReferenced')}\n {action === 'delete'\n ? ` ${translate(\n targets.length === 1\n ? 'cms.reference.permanentDelete.one'\n : 'cms.reference.permanentDelete.other',\n { count: targets.length },\n )}`\n : ''}\n </>\n ) : (\n translate('cms.reference.canProceed', {\n action: translate(\n action === 'unpublish'\n ? 'cms.reference.verb.unpublish'\n : 'cms.reference.verb.delete',\n ),\n summary: impactSummary(targets.length, totalBroken),\n })\n )}\n </DialogDescription>\n </DialogHeader>\n\n {status === 'ready' && impact !== null && totalBroken > 0 ? (\n <ImpactList projectId={projectId} impact={impact} onNavigate={() => onOpenChange(false)} />\n ) : null}\n {status === 'unavailable' ? (\n <Row gap=\"2\" data-testid=\"reference-confirm-unavailable\">\n <AlertTriangle className=\"size-4 shrink-0 text-warning\" />\n <Text size=\"xs\" tone=\"muted\">\n {translate('cms.reference.proceedUnavailable')}\n </Text>\n </Row>\n ) : null}\n\n <DialogFooter>\n <Button\n variant=\"outline\"\n data-testid=\"reference-confirm-cancel\"\n onClick={() => onOpenChange(false)}\n >\n {translate('common.cancel')}\n </Button>\n <Button\n variant={action === 'delete' ? 'destructive' : 'default'}\n disabled={status === 'loading' || blocked || busy}\n data-testid=\"reference-confirm-proceed\"\n onClick={onConfirm}\n >\n {totalBroken > 0 && !blocked\n ? translate('cms.reference.proceedAnyway', { action: actionLabel })\n : actionLabel}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction impactSummary(targetCount: number, totalBroken: number): string {\n const places = translate(\n totalBroken === 1 ? 'cms.reference.placeCount.one' : 'cms.reference.placeCount.other',\n { count: totalBroken },\n )\n // The bulk aggregate: \"N documents, M inbound references will break.\"\n return targetCount > 1\n ? translate('cms.reference.bulkSummary', { count: targetCount, places })\n : places\n}\n\n/**\n * The enumerated impact: flat for a single target, grouped per target for\n * bulk selections (per-item detail, EC-169 honesty rules).\n */\nfunction ImpactList({\n projectId,\n impact,\n onNavigate,\n}: {\n projectId: string\n impact: ReferenceImpact\n onNavigate: () => void\n}) {\n const affected = impact.documents.filter((doc) => doc.broken.length > 0)\n return (\n <Stack gap=\"3\" data-testid=\"reference-confirm-impact\">\n {affected.map((doc) => (\n <ImpactGroup\n key={documentKey(doc.ref)}\n projectId={projectId}\n doc={doc}\n grouped={impact.documents.length > 1}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\nfunction ImpactGroup({\n projectId,\n doc,\n grouped,\n onNavigate,\n}: {\n projectId: string\n doc: DocumentReferenceImpact\n grouped: boolean\n onNavigate: () => void\n}) {\n const source = useCollectionView()\n const blockingKeys = new Set(doc.blocking.map((entry) => entry.key))\n return (\n <Stack gap=\"2\" data-testid={`reference-confirm-doc-${doc.ref.id}`}>\n {grouped ? (\n <Row gap=\"2\">\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\" className=\"uppercase tracking-wide\">\n {source.titleOf(doc.ref)}\n </Text>\n <Badge variant=\"outline\">{doc.broken.length}</Badge>\n </Row>\n ) : null}\n {doc.broken.map((entry) => (\n <ImpactEntryRow\n key={entry.key}\n projectId={projectId}\n entry={entry}\n blocking={blockingKeys.has(entry.key)}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\n/**\n * The shared EC-173 impact rows: one deep-linked row per broken inbound\n * reference, strict-blocking ones flagged. Rendered by the document\n * confirmation dialog (above) and the asset-delete dialog (EC-202) alike — both\n * reduce to \"these places reference the thing you're removing\", so both lean on\n * the same row + deep-link rendering (which already handles asset link kinds).\n */\nexport function ReferenceImpactRows({\n projectId,\n broken,\n blocking = [],\n onNavigate,\n}: {\n projectId: string\n broken: readonly ReferenceEntryView[]\n blocking?: readonly ReferenceEntryView[]\n onNavigate: () => void\n}) {\n const blockingKeys = new Set(blocking.map((entry) => entry.key))\n return (\n <Stack gap=\"2\" data-testid=\"reference-impact-rows\">\n {broken.map((entry) => (\n <ImpactEntryRow\n key={entry.key}\n projectId={projectId}\n entry={entry}\n blocking={blockingKeys.has(entry.key)}\n onNavigate={onNavigate}\n />\n ))}\n </Stack>\n )\n}\n\n/**\n * One affected place: the EC-172 labels with a working deep link to the exact\n * field/node, the entry kind, draft/published visibility — and a strict\n * marker when this entry is what blocks the action.\n */\nfunction ImpactEntryRow({\n projectId,\n entry,\n blocking,\n onNavigate,\n}: {\n projectId: string\n entry: ReferenceEntryView\n blocking: boolean\n onNavigate: () => void\n}) {\n return (\n <Row\n gap=\"2\"\n className={\n blocking\n ? 'rounded-md border border-destructive/50 bg-destructive/5 px-2.5 py-2'\n : 'rounded-md border border-border/70 bg-background/40 px-2.5 py-2'\n }\n data-testid=\"reference-confirm-entry\"\n >\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <ImpactDeepLink\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.sourceLabel}\n primary\n onNavigate={onNavigate}\n />\n <Row gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" tone=\"muted\" className=\"shrink-0\">\n {translate('cms.reference.atLocation')}\n </Text>\n <ImpactDeepLink\n projectId={projectId}\n link={entry.sourceLink}\n label={entry.locationLabel}\n onNavigate={onNavigate}\n />\n </Row>\n </Stack>\n {blocking ? (\n <Badge variant=\"error\" data-testid=\"reference-confirm-strict\">\n <ShieldAlert className=\"size-3\" /> {translate('cms.reference.strictBadge')}\n </Badge>\n ) : null}\n <Badge variant=\"outline\" className=\"shrink-0\">\n {entry.kindLabel}\n </Badge>\n <Row gap=\"1\" className=\"shrink-0\">\n {entry.draft ? <Badge variant=\"warning\">{translate('cms.reference.draftBadge')}</Badge> : null}\n {entry.published ? (\n <Badge variant=\"success\">{translate('cms.reference.publishedBadge')}</Badge>\n ) : null}\n </Row>\n </Row>\n )\n}\n\n/** A deep link to the exact source location; closes the dialog on navigate. */\nfunction ImpactDeepLink({\n projectId,\n link,\n label,\n primary = false,\n onNavigate,\n}: {\n projectId: string\n link: ReferenceDeepLink | null\n label: string\n primary?: boolean\n onNavigate: () => void\n}) {\n const className = primary\n ? 'min-w-0 truncate text-sm font-medium text-foreground hover:text-primary hover:underline'\n : 'min-w-0 truncate text-xs text-muted-foreground hover:text-primary hover:underline'\n if (link === null) {\n return primary ? (\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n )\n }\n switch (link.kind) {\n case 'cms-field':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsDocument(link.collectionId, link.documentId) }}\n search={link.fieldPath !== undefined ? { field: link.fieldPath } : {}}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'builder-node':\n // The builder redirect (EC-187) only reads `?page=`; the page-graph-only\n // `node` has no home in the document editor and is dropped.\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.builder() }}\n search={link.pageId !== undefined ? { page: link.pageId } : {}}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'component':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.component(link.componentId) }}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n case 'asset':\n return (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.assets() }}\n search={{ asset: link.assetId }}\n className={className}\n data-testid=\"reference-confirm-link\"\n onClick={onNavigate}\n >\n {label}\n </Link>\n )\n }\n}\n"]}
@@ -6,6 +6,14 @@ interface RichTextEditorProps {
6
6
  id?: string;
7
7
  /** The field's embed `allow` list (component ids editors may embed). */
8
8
  allow?: string[];
9
+ /**
10
+ * EC-436 (AD-1) — the field's resolved localized display label, the SAME
11
+ * string the field/prop row renders next to this editor. Used only to title
12
+ * the expand stage ("<label> — Rich text" via the parameterized
13
+ * `richText.expand.titleWithField` message, {@link richTextStageTitle});
14
+ * absent → the generic `richText.expand.title` fallback.
15
+ */
16
+ label?: string;
9
17
  }
10
18
  /**
11
19
  * The CMS rich-text field editor (EC-314) — a real TipTap editor over the shared
@@ -23,17 +31,19 @@ interface RichTextEditorProps {
23
31
  * The image and component-embed pickers are owned here (not the toolbar) so both the
24
32
  * toolbar buttons and the `/` slash menu open the same modal — one insertion path.
25
33
  */
26
- export declare function RichTextEditor({ value, onChange, readOnly, id, allow }: RichTextEditorProps): import("react").JSX.Element | null;
34
+ export declare function RichTextEditor({ value, onChange, readOnly, id, allow, label }: RichTextEditorProps): import("react").JSX.Element | null;
27
35
  /**
28
36
  * EC-431 (AD-B) — the expanded editing surface's scroll body: the stage may be
29
37
  * wider than the text (that is the point — distraction-free writing, not more
30
- * pixels), so the PROSE COLUMN inside is constrained to the classic readable
31
- * measure (~70ch) and centered with `mx-auto`, which keeps the gutters
32
- * symmetric at every stage width. Applied to the `EditorContent` wrapper only
38
+ * pixels), so the PROSE COLUMN inside is constrained to a readable measure and
39
+ * centered with `mx-auto`, which keeps the gutters symmetric at every stage
40
+ * width. EC-436 widened the measure from the classic ~70ch to ~78ch in step
41
+ * with the wider `prose` stage panel (owner feedback: "the dialog + text looks
42
+ * a bit narrow on a big screen"). Applied to the `EditorContent` wrapper only
33
43
  * while expanded; it is also the scroll area, so the toolbar above it stays
34
44
  * put. Pinned by `expand.test.tsx` (the EC-391 class-contract pattern).
35
45
  */
36
- export declare const RICH_TEXT_STAGE_CONTENT_CLASS = "min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[70ch]";
46
+ export declare const RICH_TEXT_STAGE_CONTENT_CLASS = "min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[78ch]";
37
47
  /**
38
48
  * The inline strip shown in the field row while the editor is expanded onto its
39
49
  * stage (the real editing surface lives there then). Clicking it returns — so
@@ -42,4 +52,13 @@ export declare const RICH_TEXT_STAGE_CONTENT_CLASS = "min-h-0 flex-1 overflow-y-
42
52
  export declare function RichTextExpandPlaceholder({ onCollapse }: {
43
53
  onCollapse: () => void;
44
54
  }): import("react").JSX.Element;
55
+ /**
56
+ * EC-436 (AD-1) — the expand stage's title. With a field label in reach it
57
+ * composes "<label> — <localized type>" through the PARAMETERIZED
58
+ * `richText.expand.titleWithField` message — never string concatenation in
59
+ * code, because word order is a translation concern; without one (a custom
60
+ * mount that passes no label) it falls back to the generic
61
+ * `richText.expand.title`, unchanged. Exported for the `expand.test.tsx` pins.
62
+ */
63
+ export declare function richTextStageTitle(label?: string): string;
45
64
  export {};
@@ -30,7 +30,7 @@ import { RichTextToolbar } from './toolbar.js';
30
30
  * The image and component-embed pickers are owned here (not the toolbar) so both the
31
31
  * toolbar buttons and the `/` slash menu open the same modal — one insertion path.
32
32
  */
33
- export function RichTextEditor({ value, onChange, readOnly = false, id, allow }) {
33
+ export function RichTextEditor({ value, onChange, readOnly = false, id, allow, label }) {
34
34
  // Ambient context for reference-aware insertion (null outside a collection view /
35
35
  // asset backend — the editor then degrades to external links and no image insert).
36
36
  const source = useOptionalCollectionView();
@@ -133,7 +133,7 @@ export function RichTextEditor({ value, onChange, readOnly = false, id, allow })
133
133
  // While expanded, the toolbar stays put above the scrolling prose column
134
134
  // (the scroll area is the EditorContent wrapper).
135
135
  const surface = (_jsxs(_Fragment, { children: [!readOnly ? (_jsx(RichTextToolbar, { editor: editor, targets: linkTargets, onOpenImage: openImage, onOpenEmbed: openEmbed, expanded: expanded, onToggleExpand: () => setExpanded((v) => !v) })) : null, _jsx(EditorContent, { editor: editor, className: cn(expanded && RICH_TEXT_STAGE_CONTENT_CLASS) })] }));
136
- return (_jsxs("div", { className: cn('ec-rte overflow-hidden rounded-md border border-input bg-background shadow-sm', 'focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/40', readOnly && 'opacity-70'), children: [expanded ? (_jsxs(_Fragment, { children: [_jsx(RichTextExpandPlaceholder, { onCollapse: () => setExpanded(false) }), _jsx(RichTextExpandStage, { onCollapse: () => setExpanded(false), children: surface })] })) : (surface), canImage ? (_jsx(AssetPicker, { open: imageOpen, onOpenChange: setImageOpen, value: null, accept: "image/*", onChange: (assetId) => {
136
+ return (_jsxs("div", { className: cn('ec-rte overflow-hidden rounded-md border border-input bg-background shadow-sm', 'focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/40', readOnly && 'opacity-70'), children: [expanded ? (_jsxs(_Fragment, { children: [_jsx(RichTextExpandPlaceholder, { onCollapse: () => setExpanded(false) }), _jsx(RichTextExpandStage, { label: label, onCollapse: () => setExpanded(false), children: surface })] })) : (surface), canImage ? (_jsx(AssetPicker, { open: imageOpen, onOpenChange: setImageOpen, value: null, accept: "image/*", onChange: (assetId) => {
137
137
  setImageOpen(false);
138
138
  if (assetId)
139
139
  insertAssetImage(editor, assetId, assets);
@@ -142,13 +142,15 @@ export function RichTextEditor({ value, onChange, readOnly = false, id, allow })
142
142
  /**
143
143
  * EC-431 (AD-B) — the expanded editing surface's scroll body: the stage may be
144
144
  * wider than the text (that is the point — distraction-free writing, not more
145
- * pixels), so the PROSE COLUMN inside is constrained to the classic readable
146
- * measure (~70ch) and centered with `mx-auto`, which keeps the gutters
147
- * symmetric at every stage width. Applied to the `EditorContent` wrapper only
145
+ * pixels), so the PROSE COLUMN inside is constrained to a readable measure and
146
+ * centered with `mx-auto`, which keeps the gutters symmetric at every stage
147
+ * width. EC-436 widened the measure from the classic ~70ch to ~78ch in step
148
+ * with the wider `prose` stage panel (owner feedback: "the dialog + text looks
149
+ * a bit narrow on a big screen"). Applied to the `EditorContent` wrapper only
148
150
  * while expanded; it is also the scroll area, so the toolbar above it stays
149
151
  * put. Pinned by `expand.test.tsx` (the EC-391 class-contract pattern).
150
152
  */
151
- export const RICH_TEXT_STAGE_CONTENT_CLASS = 'min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[70ch]';
153
+ export const RICH_TEXT_STAGE_CONTENT_CLASS = 'min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[78ch]';
152
154
  /**
153
155
  * The inline strip shown in the field row while the editor is expanded onto its
154
156
  * stage (the real editing surface lives there then). Clicking it returns — so
@@ -157,6 +159,19 @@ export const RICH_TEXT_STAGE_CONTENT_CLASS = 'min-h-0 flex-1 overflow-y-auto px-
157
159
  export function RichTextExpandPlaceholder({ onCollapse }) {
158
160
  return (_jsxs("button", { type: "button", onClick: onCollapse, className: "flex min-h-[8rem] w-full items-center justify-center gap-2 px-3 py-6 text-sm text-muted-foreground transition-colors hover:bg-muted/40", children: [_jsx(Minimize2, { className: "size-4" }), _jsx(Text, { size: "sm", tone: "muted", children: translate('richText.expand.editingInSheet') })] }));
159
161
  }
162
+ /**
163
+ * EC-436 (AD-1) — the expand stage's title. With a field label in reach it
164
+ * composes "<label> — <localized type>" through the PARAMETERIZED
165
+ * `richText.expand.titleWithField` message — never string concatenation in
166
+ * code, because word order is a translation concern; without one (a custom
167
+ * mount that passes no label) it falls back to the generic
168
+ * `richText.expand.title`, unchanged. Exported for the `expand.test.tsx` pins.
169
+ */
170
+ export function richTextStageTitle(label) {
171
+ return label !== undefined && label.trim() !== ''
172
+ ? translate('richText.expand.titleWithField', { field: label })
173
+ : translate('richText.expand.title');
174
+ }
160
175
  /**
161
176
  * EC-388/EC-431 — the expanded editing surface: the SAME editor, grown onto the
162
177
  * centered STAGE (ratified AD-B — writing is a primary activity, so it takes
@@ -174,7 +189,7 @@ export function RichTextExpandPlaceholder({ onCollapse }) {
174
189
  * the stage's toolbar is a Radix dialog ABOVE the stage — it consumes Escape
175
190
  * first (the stage stays), per the EC-392 stacking rules.
176
191
  */
177
- function RichTextExpandStage({ children, onCollapse, }) {
178
- return (_jsx(ExpandableSurface, { title: translate('richText.expand.title'), closeLabel: translate('richText.expand.collapse'), variant: "stage", preset: "prose", onDismiss: onCollapse, children: _jsx("div", { className: "ec-rte flex min-h-0 flex-1 flex-col overflow-hidden bg-background", children: children }) }));
192
+ function RichTextExpandStage({ children, onCollapse, label, }) {
193
+ return (_jsx(ExpandableSurface, { title: richTextStageTitle(label), closeLabel: translate('richText.expand.collapse'), variant: "stage", preset: "prose", onDismiss: onCollapse, children: _jsx("div", { className: "ec-rte flex min-h-0 flex-1 flex-col overflow-hidden bg-background", children: children }) }));
179
194
  }
180
195
  //# sourceMappingURL=editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../../src/components/cms/rich-text/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AAC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AE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAChF,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,wHAAwH,CAAA;AAE1H;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,EAAE,UAAU,EAA8B;IAClF,OAAO,CACL,kBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EACnB,SAAS,EAAC,wIAAwI,aAElJ,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,EAChC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,SAAS,CAAC,gCAAgC,CAAC,GACvC,IACA,CACV,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,mBAAmB,CAAC,EAC3B,QAAQ,EACR,UAAU,GAIX;IACC,OAAO,CACL,KAAC,iBAAiB,IAChB,KAAK,EAAE,SAAS,CAAC,uBAAuB,CAAC,EACzC,UAAU,EAAE,SAAS,CAAC,0BAA0B,CAAC,EACjD,OAAO,EAAC,OAAO,EACf,MAAM,EAAC,OAAO,EACd,SAAS,EAAE,UAAU,YAErB,cAAK,SAAS,EAAC,mEAAmE,YAC/E,QAAQ,GACL,GACY,CACrB,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { EditorContent, useEditor } from '@tiptap/react'\nimport { Minimize2 } from 'lucide-react'\nimport type { RichTextDoc } from '@elytracms/core/rich-text'\nimport { ExpandableSurface, Text } from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { useOptionalCollectionView } from '../../collection-view/collection-view-context'\nimport { useOptionalAssets } from '../../assets/assets-store'\nimport { AssetPicker } from '../asset-picker'\nimport { buildRichTextExtensions } from './extensions'\nimport {\n isEffectivelyEmpty,\n isEquivalentToStored,\n normalizeEditorDoc,\n richTextValueFromDoc,\n toEditorDoc,\n} from './value'\nimport { insertAssetImage, insertComponentEmbed, listEmbeddable } from './insert'\nimport { EmbedPicker } from './embed-picker'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\nimport { RichTextToolbar } from './toolbar'\nimport type { LinkTarget } from './link-control'\n\ninterface RichTextEditorProps {\n /** The stored `richText` value (`{ version, doc }`, legacy string, or empty). */\n value: unknown\n onChange: (value: unknown) => void\n readOnly?: boolean\n id?: string\n /** The field's embed `allow` list (component ids editors may embed). */\n allow?: string[]\n}\n\n/**\n * The CMS rich-text field editor (EC-314) — a real TipTap editor over the shared\n * `@elytracms/core/rich-text` storage, replacing the plaintext textarea stub.\n *\n * It stays *controlled without churn*: the editor is created once from the initial\n * value; the stored value is only re-pushed into ProseMirror when it changes\n * externally (locale switch, reset, compare) and is not already equivalent to what\n * is on screen. On edit, output is pruned to the lean storage convention\n * ({@link normalizeEditorDoc}) and — crucially — when an edit lands the document back\n * on its stored meaning, the *exact stored value* is re-emitted so the field never\n * shows a spurious dirty state (the same \"commit-nothing-when-equivalent\" contract\n * the canvas inline editor uses).\n *\n * The image and component-embed pickers are owned here (not the toolbar) so both the\n * toolbar buttons and the `/` slash menu open the same modal — one insertion path.\n */\nexport function RichTextEditor({ value, onChange, readOnly = false, id, allow }: RichTextEditorProps) {\n // Ambient context for reference-aware insertion (null outside a collection view /\n // asset backend — the editor then degrades to external links and no image insert).\n const source = useOptionalCollectionView()\n const assets = useOptionalAssets()\n\n const [imageOpen, setImageOpen] = useState(false)\n const [embedOpen, setEmbedOpen] = useState(false)\n // EC-388/EC-431: whether the editor is promoted onto its centered expand stage.\n const [expanded, setExpanded] = useState(false)\n\n const canImage = assets != null\n // The `allow`-gated components this field may embed — drives both the toolbar\n // picker and the slash menu's direct per-component items (0.0.41).\n const embeddable = useMemo(\n () => listEmbeddable(allow, getStudioRegistry().registry.list()),\n [allow],\n )\n const canEmbed = embeddable.length > 0\n\n // Every linkable document across the workspace (excluding the asset rail — you link\n // to content, not to raw files). Recomputed only when the source changes.\n const linkTargets = useMemo<LinkTarget[]>(() => {\n if (!source) return []\n const out: LinkTarget[] = []\n for (const collection of source.collections) {\n if (collection.id === source.assetCollectionId) continue\n const collectionLabel = localizedLabel(collection.form?.labelSingular, collection.id)\n for (const doc of source.referenceCandidates(collection.id)) {\n const ref = { collection: collection.id, id: doc.id }\n out.push({ ref, label: source.titleOf(ref), collectionLabel })\n }\n }\n return out\n }, [source])\n\n // Latest value/onChange, read inside the stable onUpdate closure.\n const valueRef = useRef(value)\n valueRef.current = value\n const onChangeRef = useRef(onChange)\n onChangeRef.current = onChange\n // What we last emitted upward — lets the sync effect ignore our own echoes.\n const lastEmitted = useRef<unknown>(value)\n\n // Media openers for the toolbar + slash menu. setState fns are stable, so these\n // stay valid for the life of the editor even though it's built once.\n const openImage = canImage ? () => setImageOpen(true) : undefined\n const openEmbed = canEmbed ? () => setEmbedOpen(true) : undefined\n\n const editor = useEditor({\n extensions: buildRichTextExtensions({\n slash: {\n onImage: openImage,\n // Direct per-component slash items (0.0.41) — insert with manifest defaults\n // and select, so the embed inspector opens onto the new node's props.\n embed: canEmbed\n ? {\n components: embeddable,\n insert: (ed, range, manifest) => {\n ed.chain().focus().deleteRange(range).run()\n insertComponentEmbed(ed, manifest, { select: true })\n },\n }\n : undefined,\n },\n }),\n content: toEditorDoc(value),\n editable: !readOnly,\n editorProps: {\n attributes: { class: 'ec-rte-content', ...(id ? { id } : {}) },\n },\n onUpdate: ({ editor }) => {\n const current = normalizeEditorDoc(editor.getJSON() as unknown as RichTextDoc)\n const stored = valueRef.current\n // Three outcomes: unchanged → re-emit the stored value verbatim (no dirty);\n // emptied → clear the field (undefined); otherwise → the new stamped value.\n const next = isEquivalentToStored(current, stored)\n ? stored\n : isEffectivelyEmpty(current)\n ? undefined\n : richTextValueFromDoc(current)\n lastEmitted.current = next\n onChangeRef.current(next)\n },\n })\n\n // Reflect external value changes into the editor, never echoing our own emits.\n useEffect(() => {\n if (!editor) return\n if (value === lastEmitted.current) return\n const current = normalizeEditorDoc(editor.getJSON() as unknown as RichTextDoc)\n if (isEquivalentToStored(current, value)) return\n editor.commands.setContent(toEditorDoc(value), { emitUpdate: false })\n }, [editor, value])\n\n // Toggle editability without rebuilding the editor (preserves history/selection).\n useEffect(() => {\n editor?.setEditable(!readOnly)\n }, [editor, readOnly])\n\n if (!editor) return null\n\n // The editing surface — the toolbar (which carries the expand toggle) + the\n // editable content. Mounted inline OR inside the expand stage, never both. TipTap\n // preserves the editor instance across `EditorContent` remounts (its view DOM is\n // carried onto the new element), so relocating this surface keeps ONE editor\n // document and ONE value flow — the same instance, grown, not a second form.\n // While expanded, the toolbar stays put above the scrolling prose column\n // (the scroll area is the EditorContent wrapper).\n const surface = (\n <>\n {!readOnly ? (\n <RichTextToolbar\n editor={editor}\n targets={linkTargets}\n onOpenImage={openImage}\n onOpenEmbed={openEmbed}\n expanded={expanded}\n onToggleExpand={() => setExpanded((v) => !v)}\n />\n ) : null}\n <EditorContent editor={editor} className={cn(expanded && RICH_TEXT_STAGE_CONTENT_CLASS)} />\n </>\n )\n\n return (\n <div\n className={cn(\n 'ec-rte overflow-hidden rounded-md border border-input bg-background shadow-sm',\n 'focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/40',\n readOnly && 'opacity-70',\n )}\n >\n {expanded ? (\n <>\n <RichTextExpandPlaceholder onCollapse={() => setExpanded(false)} />\n <RichTextExpandStage onCollapse={() => setExpanded(false)}>{surface}</RichTextExpandStage>\n </>\n ) : (\n surface\n )}\n {canImage ? (\n <AssetPicker\n open={imageOpen}\n onOpenChange={setImageOpen}\n value={null}\n accept=\"image/*\"\n onChange={(assetId) => {\n setImageOpen(false)\n if (assetId) insertAssetImage(editor, assetId, assets)\n }}\n />\n ) : null}\n {canEmbed ? (\n <EmbedPicker\n open={embedOpen}\n onOpenChange={setEmbedOpen}\n allow={allow}\n onSelect={(manifest) => insertComponentEmbed(editor, manifest, { select: true })}\n />\n ) : null}\n </div>\n )\n}\n\n/**\n * EC-431 (AD-B) — the expanded editing surface's scroll body: the stage may be\n * wider than the text (that is the point — distraction-free writing, not more\n * pixels), so the PROSE COLUMN inside is constrained to the classic readable\n * measure (~70ch) and centered with `mx-auto`, which keeps the gutters\n * symmetric at every stage width. Applied to the `EditorContent` wrapper only\n * while expanded; it is also the scroll area, so the toolbar above it stays\n * put. Pinned by `expand.test.tsx` (the EC-391 class-contract pattern).\n */\nexport const RICH_TEXT_STAGE_CONTENT_CLASS =\n 'min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[70ch]'\n\n/**\n * The inline strip shown in the field row while the editor is expanded onto its\n * stage (the real editing surface lives there then). Clicking it returns — so\n * the collapsed field never appears as a broken empty box.\n */\nexport function RichTextExpandPlaceholder({ onCollapse }: { onCollapse: () => void }) {\n return (\n <button\n type=\"button\"\n onClick={onCollapse}\n className=\"flex min-h-[8rem] w-full items-center justify-center gap-2 px-3 py-6 text-sm text-muted-foreground transition-colors hover:bg-muted/40\"\n >\n <Minimize2 className=\"size-4\" />\n <Text size=\"sm\" tone=\"muted\">\n {translate('richText.expand.editingInSheet')}\n </Text>\n </button>\n )\n}\n\n/**\n * EC-388/EC-431 — the expanded editing surface: the SAME editor, grown onto the\n * centered STAGE (ratified AD-B — writing is a primary activity, so it takes\n * the `stage` prose preset, never the peripheral side sheet) where long prose\n * (a privacy statement, a Freeform block) is comfortable to edit. It renders\n * through the shared {@link ExpandableSurface} primitive (portal-to-body,\n * backdrop, header close, layer-stacked Escape); the prose column inside is\n * constrained to the distraction-free measure\n * ({@link RICH_TEXT_STAGE_CONTENT_CLASS}). It is the same edit surface, not a\n * second form: no save/cancel of its own — edits flow through the editor's\n * existing value contract, and it is lightly dismissible (Escape / backdrop /\n * the toolbar's collapse toggle / the header close), the forms-never-modal\n * spirit applied. The `children` are the live toolbar + `EditorContent`;\n * unmounting them here returns the editor inline. The asset picker opened from\n * the stage's toolbar is a Radix dialog ABOVE the stage — it consumes Escape\n * first (the stage stays), per the EC-392 stacking rules.\n */\nfunction RichTextExpandStage({\n children,\n onCollapse,\n}: {\n children: ReactNode\n onCollapse: () => void\n}) {\n return (\n <ExpandableSurface\n title={translate('richText.expand.title')}\n closeLabel={translate('richText.expand.collapse')}\n variant=\"stage\"\n preset=\"prose\"\n onDismiss={onCollapse}\n >\n <div className=\"ec-rte flex min-h-0 flex-1 flex-col overflow-hidden bg-background\">\n {children}\n </div>\n </ExpandableSurface>\n )\n}\n"]}
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../../src/components/cms/rich-text/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,GACZ,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAA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AI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EACnB,SAAS,EAAC,wIAAwI,aAElJ,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,EAChC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,SAAS,CAAC,gCAAgC,CAAC,GACvC,IACA,CACV,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAC/C,CAAC,CAAC,SAAS,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,mBAAmB,CAAC,EAC3B,QAAQ,EACR,UAAU,EACV,KAAK,GAMN;IACC,OAAO,CACL,KAAC,iBAAiB,IAChB,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAChC,UAAU,EAAE,SAAS,CAAC,0BAA0B,CAAC,EACjD,OAAO,EAAC,OAAO,EACf,MAAM,EAAC,OAAO,EACd,SAAS,EAAE,UAAU,YAErB,cAAK,SAAS,EAAC,mEAAmE,YAC/E,QAAQ,GACL,GACY,CACrB,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { EditorContent, useEditor } from '@tiptap/react'\nimport { Minimize2 } from 'lucide-react'\nimport type { RichTextDoc } from '@elytracms/core/rich-text'\nimport { ExpandableSurface, Text } from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { useOptionalCollectionView } from '../../collection-view/collection-view-context'\nimport { useOptionalAssets } from '../../assets/assets-store'\nimport { AssetPicker } from '../asset-picker'\nimport { buildRichTextExtensions } from './extensions'\nimport {\n isEffectivelyEmpty,\n isEquivalentToStored,\n normalizeEditorDoc,\n richTextValueFromDoc,\n toEditorDoc,\n} from './value'\nimport { insertAssetImage, insertComponentEmbed, listEmbeddable } from './insert'\nimport { EmbedPicker } from './embed-picker'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\nimport { RichTextToolbar } from './toolbar'\nimport type { LinkTarget } from './link-control'\n\ninterface RichTextEditorProps {\n /** The stored `richText` value (`{ version, doc }`, legacy string, or empty). */\n value: unknown\n onChange: (value: unknown) => void\n readOnly?: boolean\n id?: string\n /** The field's embed `allow` list (component ids editors may embed). */\n allow?: string[]\n /**\n * EC-436 (AD-1) — the field's resolved localized display label, the SAME\n * string the field/prop row renders next to this editor. Used only to title\n * the expand stage (\"<label> — Rich text\" via the parameterized\n * `richText.expand.titleWithField` message, {@link richTextStageTitle});\n * absent → the generic `richText.expand.title` fallback.\n */\n label?: string\n}\n\n/**\n * The CMS rich-text field editor (EC-314) — a real TipTap editor over the shared\n * `@elytracms/core/rich-text` storage, replacing the plaintext textarea stub.\n *\n * It stays *controlled without churn*: the editor is created once from the initial\n * value; the stored value is only re-pushed into ProseMirror when it changes\n * externally (locale switch, reset, compare) and is not already equivalent to what\n * is on screen. On edit, output is pruned to the lean storage convention\n * ({@link normalizeEditorDoc}) and — crucially — when an edit lands the document back\n * on its stored meaning, the *exact stored value* is re-emitted so the field never\n * shows a spurious dirty state (the same \"commit-nothing-when-equivalent\" contract\n * the canvas inline editor uses).\n *\n * The image and component-embed pickers are owned here (not the toolbar) so both the\n * toolbar buttons and the `/` slash menu open the same modal — one insertion path.\n */\nexport function RichTextEditor({ value, onChange, readOnly = false, id, allow, label }: RichTextEditorProps) {\n // Ambient context for reference-aware insertion (null outside a collection view /\n // asset backend — the editor then degrades to external links and no image insert).\n const source = useOptionalCollectionView()\n const assets = useOptionalAssets()\n\n const [imageOpen, setImageOpen] = useState(false)\n const [embedOpen, setEmbedOpen] = useState(false)\n // EC-388/EC-431: whether the editor is promoted onto its centered expand stage.\n const [expanded, setExpanded] = useState(false)\n\n const canImage = assets != null\n // The `allow`-gated components this field may embed — drives both the toolbar\n // picker and the slash menu's direct per-component items (0.0.41).\n const embeddable = useMemo(\n () => listEmbeddable(allow, getStudioRegistry().registry.list()),\n [allow],\n )\n const canEmbed = embeddable.length > 0\n\n // Every linkable document across the workspace (excluding the asset rail — you link\n // to content, not to raw files). Recomputed only when the source changes.\n const linkTargets = useMemo<LinkTarget[]>(() => {\n if (!source) return []\n const out: LinkTarget[] = []\n for (const collection of source.collections) {\n if (collection.id === source.assetCollectionId) continue\n const collectionLabel = localizedLabel(collection.form?.labelSingular, collection.id)\n for (const doc of source.referenceCandidates(collection.id)) {\n const ref = { collection: collection.id, id: doc.id }\n out.push({ ref, label: source.titleOf(ref), collectionLabel })\n }\n }\n return out\n }, [source])\n\n // Latest value/onChange, read inside the stable onUpdate closure.\n const valueRef = useRef(value)\n valueRef.current = value\n const onChangeRef = useRef(onChange)\n onChangeRef.current = onChange\n // What we last emitted upward — lets the sync effect ignore our own echoes.\n const lastEmitted = useRef<unknown>(value)\n\n // Media openers for the toolbar + slash menu. setState fns are stable, so these\n // stay valid for the life of the editor even though it's built once.\n const openImage = canImage ? () => setImageOpen(true) : undefined\n const openEmbed = canEmbed ? () => setEmbedOpen(true) : undefined\n\n const editor = useEditor({\n extensions: buildRichTextExtensions({\n slash: {\n onImage: openImage,\n // Direct per-component slash items (0.0.41) — insert with manifest defaults\n // and select, so the embed inspector opens onto the new node's props.\n embed: canEmbed\n ? {\n components: embeddable,\n insert: (ed, range, manifest) => {\n ed.chain().focus().deleteRange(range).run()\n insertComponentEmbed(ed, manifest, { select: true })\n },\n }\n : undefined,\n },\n }),\n content: toEditorDoc(value),\n editable: !readOnly,\n editorProps: {\n attributes: { class: 'ec-rte-content', ...(id ? { id } : {}) },\n },\n onUpdate: ({ editor }) => {\n const current = normalizeEditorDoc(editor.getJSON() as unknown as RichTextDoc)\n const stored = valueRef.current\n // Three outcomes: unchanged → re-emit the stored value verbatim (no dirty);\n // emptied → clear the field (undefined); otherwise → the new stamped value.\n const next = isEquivalentToStored(current, stored)\n ? stored\n : isEffectivelyEmpty(current)\n ? undefined\n : richTextValueFromDoc(current)\n lastEmitted.current = next\n onChangeRef.current(next)\n },\n })\n\n // Reflect external value changes into the editor, never echoing our own emits.\n useEffect(() => {\n if (!editor) return\n if (value === lastEmitted.current) return\n const current = normalizeEditorDoc(editor.getJSON() as unknown as RichTextDoc)\n if (isEquivalentToStored(current, value)) return\n editor.commands.setContent(toEditorDoc(value), { emitUpdate: false })\n }, [editor, value])\n\n // Toggle editability without rebuilding the editor (preserves history/selection).\n useEffect(() => {\n editor?.setEditable(!readOnly)\n }, [editor, readOnly])\n\n if (!editor) return null\n\n // The editing surface — the toolbar (which carries the expand toggle) + the\n // editable content. Mounted inline OR inside the expand stage, never both. TipTap\n // preserves the editor instance across `EditorContent` remounts (its view DOM is\n // carried onto the new element), so relocating this surface keeps ONE editor\n // document and ONE value flow — the same instance, grown, not a second form.\n // While expanded, the toolbar stays put above the scrolling prose column\n // (the scroll area is the EditorContent wrapper).\n const surface = (\n <>\n {!readOnly ? (\n <RichTextToolbar\n editor={editor}\n targets={linkTargets}\n onOpenImage={openImage}\n onOpenEmbed={openEmbed}\n expanded={expanded}\n onToggleExpand={() => setExpanded((v) => !v)}\n />\n ) : null}\n <EditorContent editor={editor} className={cn(expanded && RICH_TEXT_STAGE_CONTENT_CLASS)} />\n </>\n )\n\n return (\n <div\n className={cn(\n 'ec-rte overflow-hidden rounded-md border border-input bg-background shadow-sm',\n 'focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/40',\n readOnly && 'opacity-70',\n )}\n >\n {expanded ? (\n <>\n <RichTextExpandPlaceholder onCollapse={() => setExpanded(false)} />\n <RichTextExpandStage label={label} onCollapse={() => setExpanded(false)}>\n {surface}\n </RichTextExpandStage>\n </>\n ) : (\n surface\n )}\n {canImage ? (\n <AssetPicker\n open={imageOpen}\n onOpenChange={setImageOpen}\n value={null}\n accept=\"image/*\"\n onChange={(assetId) => {\n setImageOpen(false)\n if (assetId) insertAssetImage(editor, assetId, assets)\n }}\n />\n ) : null}\n {canEmbed ? (\n <EmbedPicker\n open={embedOpen}\n onOpenChange={setEmbedOpen}\n allow={allow}\n onSelect={(manifest) => insertComponentEmbed(editor, manifest, { select: true })}\n />\n ) : null}\n </div>\n )\n}\n\n/**\n * EC-431 (AD-B) — the expanded editing surface's scroll body: the stage may be\n * wider than the text (that is the point — distraction-free writing, not more\n * pixels), so the PROSE COLUMN inside is constrained to a readable measure and\n * centered with `mx-auto`, which keeps the gutters symmetric at every stage\n * width. EC-436 widened the measure from the classic ~70ch to ~78ch in step\n * with the wider `prose` stage panel (owner feedback: \"the dialog + text looks\n * a bit narrow on a big screen\"). Applied to the `EditorContent` wrapper only\n * while expanded; it is also the scroll area, so the toolbar above it stays\n * put. Pinned by `expand.test.tsx` (the EC-391 class-contract pattern).\n */\nexport const RICH_TEXT_STAGE_CONTENT_CLASS =\n 'min-h-0 flex-1 overflow-y-auto px-6 py-6 sm:px-10 sm:py-8 [&>.ec-rte-content]:mx-auto [&>.ec-rte-content]:max-w-[78ch]'\n\n/**\n * The inline strip shown in the field row while the editor is expanded onto its\n * stage (the real editing surface lives there then). Clicking it returns — so\n * the collapsed field never appears as a broken empty box.\n */\nexport function RichTextExpandPlaceholder({ onCollapse }: { onCollapse: () => void }) {\n return (\n <button\n type=\"button\"\n onClick={onCollapse}\n className=\"flex min-h-[8rem] w-full items-center justify-center gap-2 px-3 py-6 text-sm text-muted-foreground transition-colors hover:bg-muted/40\"\n >\n <Minimize2 className=\"size-4\" />\n <Text size=\"sm\" tone=\"muted\">\n {translate('richText.expand.editingInSheet')}\n </Text>\n </button>\n )\n}\n\n/**\n * EC-436 (AD-1) — the expand stage's title. With a field label in reach it\n * composes \"<label> — <localized type>\" through the PARAMETERIZED\n * `richText.expand.titleWithField` message — never string concatenation in\n * code, because word order is a translation concern; without one (a custom\n * mount that passes no label) it falls back to the generic\n * `richText.expand.title`, unchanged. Exported for the `expand.test.tsx` pins.\n */\nexport function richTextStageTitle(label?: string): string {\n return label !== undefined && label.trim() !== ''\n ? translate('richText.expand.titleWithField', { field: label })\n : translate('richText.expand.title')\n}\n\n/**\n * EC-388/EC-431 — the expanded editing surface: the SAME editor, grown onto the\n * centered STAGE (ratified AD-B — writing is a primary activity, so it takes\n * the `stage` prose preset, never the peripheral side sheet) where long prose\n * (a privacy statement, a Freeform block) is comfortable to edit. It renders\n * through the shared {@link ExpandableSurface} primitive (portal-to-body,\n * backdrop, header close, layer-stacked Escape); the prose column inside is\n * constrained to the distraction-free measure\n * ({@link RICH_TEXT_STAGE_CONTENT_CLASS}). It is the same edit surface, not a\n * second form: no save/cancel of its own — edits flow through the editor's\n * existing value contract, and it is lightly dismissible (Escape / backdrop /\n * the toolbar's collapse toggle / the header close), the forms-never-modal\n * spirit applied. The `children` are the live toolbar + `EditorContent`;\n * unmounting them here returns the editor inline. The asset picker opened from\n * the stage's toolbar is a Radix dialog ABOVE the stage — it consumes Escape\n * first (the stage stays), per the EC-392 stacking rules.\n */\nfunction RichTextExpandStage({\n children,\n onCollapse,\n label,\n}: {\n children: ReactNode\n onCollapse: () => void\n /** The field's resolved display label — see {@link richTextStageTitle}. */\n label?: string\n}) {\n return (\n <ExpandableSurface\n title={richTextStageTitle(label)}\n closeLabel={translate('richText.expand.collapse')}\n variant=\"stage\"\n preset=\"prose\"\n onDismiss={onCollapse}\n >\n <div className=\"ec-rte flex min-h-0 flex-1 flex-col overflow-hidden bg-background\">\n {children}\n </div>\n </ExpandableSurface>\n )\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import type { CmsDocument, CmsValidationIssue, CollectionDef, DocumentRef, FieldDef, LocaleConfig } from '@elytracms/core/cms-core';
2
- import type { OperationError } from '@elytracms/core/operations';
2
+ import type { OperationError, OperationResult } from '@elytracms/core/operations';
3
+ import type { ReferenceTarget } from '@elytracms/core/persistence';
3
4
  import type { TableViewState } from '@elytracms/studio/lib/cms-views';
4
5
  import type { CollectionViewCapabilities, CollectionViewSource, FieldAccess } from '@elytracms/studio/lib/collection-view/collection-view-source';
6
+ import type { BulkAction, BulkReport, BulkSetField } from './cms/bulk-actions.js';
5
7
  /**
6
8
  * The shared scaffold behind the primitive-rail `CollectionViewSource` hooks
7
9
  * (EC-327) — assets, users, redirects. All three hand-rolled identical
@@ -47,6 +49,32 @@ export declare function metaBagProjection(values: Record<string, unknown>, canon
47
49
  * `setError` — the factory's error-mapping plumbing, pulled out as a plain
48
50
  * function (no hook) so it is unit-testable without a `renderHook` harness. */
49
51
  export declare function createErrorMappedWriter<TArg, TResult>(write: (arg: TArg) => Promise<TResult>, normalize: (result: TResult) => OperationError | null, setError: (error: OperationError) => void): (arg: TArg) => void;
52
+ /** The store-facing input of {@link runRailBulkAction} — plain data/functions,
53
+ * so the rail bulk path is unit-testable without a hook harness. */
54
+ export interface RailBulkInput {
55
+ collectionId: string;
56
+ /** Current rail rows (lens documents) — the runner's lookup + validation input. */
57
+ documents: readonly CmsDocument[];
58
+ titleOf(ref: DocumentRef): string;
59
+ validate(doc: CmsDocument): CmsValidationIssue[];
60
+ /**
61
+ * Dispatch ONE already-confirmed delete (the EC-173 reference dialog ran
62
+ * before anything reaches this) and reconcile the rail store's result shape
63
+ * into an operation-shaped outcome — a failure here is a visible per-item
64
+ * failure in the report, never a swallowed one.
65
+ */
66
+ removeConfirmed(ref: DocumentRef): Promise<OperationResult<unknown>>;
67
+ }
68
+ /**
69
+ * The primitive rails' bulk runner (EC-433): the SAME `runBulkAction` machinery
70
+ * the CMS rail uses ([[client-data-flow-one-cache]] — no parallel data flow),
71
+ * wired to the rail's own store delete. Only `delete` is dispatchable — the
72
+ * rails have no publish lifecycle and no bulk set-field — and an unsupported
73
+ * action fails each item HONESTLY in the report rather than silently no-oping
74
+ * (the exact bug this replaces: the assets rail's bulk delete confirmed into a
75
+ * missing `source.bulk` and dropped the whole action on the floor).
76
+ */
77
+ export declare function runRailBulkAction(input: RailBulkInput, ids: readonly string[], action: BulkAction, setField?: BulkSetField): Promise<BulkReport>;
50
78
  /** The fields shared by {@link RailAdapter} and the pure assembly input —
51
79
  * everything the factory copies straight onto the assembled source, or
52
80
  * defaults when a rail omits it. */
@@ -68,6 +96,12 @@ interface RailViewSourceCore {
68
96
  isFieldReadOnly?(field: FieldDef): boolean;
69
97
  /** Principal-based tri-state — only the users rail supplies one. */
70
98
  fieldAccess?(field: FieldDef, record?: CmsDocument): FieldAccess;
99
+ /**
100
+ * How this rail's records are addressed in the reference index (EC-433) —
101
+ * only the assets rail supplies one (`{ type: 'asset' }`); absent ⇒ the
102
+ * confirm dialog's default document-shaped lookup.
103
+ */
104
+ referenceTarget?(ref: DocumentRef): ReferenceTarget;
71
105
  validate(doc: CmsDocument): CmsValidationIssue[];
72
106
  create(): DocumentRef;
73
107
  }
@@ -78,6 +112,14 @@ interface RailViewSourceCore {
78
112
  export interface RailAdapter<TSaveResult, TRemoveResult> extends RailViewSourceCore {
79
113
  save(doc: CmsDocument): Promise<TSaveResult>;
80
114
  remove(ref: DocumentRef): Promise<TRemoveResult>;
115
+ /**
116
+ * The delete the BULK path dispatches (EC-433) — always post-confirmation
117
+ * (the EC-173 reference dialog ran first). Defaults to {@link remove}; the
118
+ * assets rail overrides it to pass `confirmInUse: true` so a confirmed bulk
119
+ * delete of a referenced asset actually deletes (mirroring the detail
120
+ * surface's confirmed delete) instead of re-blocking on the usage gate.
121
+ */
122
+ bulkRemove?(ref: DocumentRef): Promise<TRemoveResult>;
81
123
  normalizeSaveResult(result: TSaveResult): OperationError | null;
82
124
  normalizeRemoveResult(result: TRemoveResult): OperationError | null;
83
125
  }
@@ -90,6 +132,13 @@ interface RailViewSourceAssemblyInput extends RailViewSourceCore {
90
132
  setViewState: CollectionViewSource['setViewState'];
91
133
  save(doc: CmsDocument): void;
92
134
  remove(ref: DocumentRef): void;
135
+ /**
136
+ * The rail bulk runner (EC-433). Assembled onto the source ONLY when
137
+ * `capabilities.bulk` is set — the `CollectionViewSource` contract is
138
+ * "method present iff the flag is" — so a bulk-less rail's list never
139
+ * half-offers the affordance.
140
+ */
141
+ bulk?: CollectionViewSource['bulk'];
93
142
  }
94
143
  /**
95
144
  * Pure assembly of a {@link CollectionViewSource} from a rail's resolved