@elytracms/studio 0.0.20 → 0.0.21
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.
- package/dist/components/builder/canvas.d.ts +7 -1
- package/dist/components/builder/canvas.js +63 -6
- package/dist/components/builder/canvas.js.map +1 -1
- package/dist/components/builder/composition-field-editor.js +1 -1
- package/dist/components/builder/composition-field-editor.js.map +1 -1
- package/dist/components/builder/reuse-context.js +21 -8
- package/dist/components/builder/reuse-context.js.map +1 -1
- package/dist/components/builder/reuse.d.ts +14 -1
- package/dist/components/builder/reuse.js +33 -1
- package/dist/components/builder/reuse.js.map +1 -1
- package/dist/components/cms/detail-editor.js +78 -7
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/lib/data/collection-content.d.ts +12 -3
- package/dist/lib/data/collection-content.js +20 -17
- package/dist/lib/data/collection-content.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail-editor.js","sourceRoot":"","sources":["../../../src/components/cms/detail-editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC9F,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,GAAG,EACH,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,IAAI,EACJ,cAAc,EACd,GAAG,EACH,MAAM,GACP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL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,IAAI,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;KACzF,CAAC,CAAC,CAAA;AACL,CAAC;AAED,SAAS,YAAY,CACnB,GAAgB,EAChB,UAAyB,EACzB,MAAc,EACd,MAAoB;IAEpB,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,UAAU,IAAI,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACjG,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport {\n CircleAlert,\n CircleCheck,\n ExternalLink,\n Eye,\n EyeOff,\n History,\n Languages,\n Loader2,\n Lock,\n MoreHorizontal,\n Tag,\n Trash2,\n} from 'lucide-react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n SIDEBAR_FIELD_GROUP,\n clearHiddenValues,\n documentKey,\n hasAliases,\n isBlocksField,\n isFieldHidden,\n isFieldLocalized,\n isSingleton,\n resolveField,\n sidebarFields,\n staticFieldHidden,\n urlForDocument,\n} from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef, FieldDef, Locale, LocaleConfig } from '@elytracms/core/cms-core'\nimport {\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Field,\n Heading,\n Panel,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n toast,\n} from '@elytracms/studio/ui'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport {\n LocaleSwitcher,\n displayedFieldFallback,\n hasLocaleVariant,\n localeChipLabel,\n setStudioLocale,\n} from '@elytracms/studio/lib/locale'\nimport { parseDocumentFieldPath } from '@elytracms/studio/lib/references'\nimport type { ReferenceAction } from '@elytracms/studio/lib/references'\nimport { FallbackChip, fallbackTitle } from './cell'\nimport { FieldControl } from './field-control'\nimport { CompositionFieldEditor } from '../builder/composition-field-editor'\nimport { fieldLabel, useCms } from './cms-store'\nimport { DocStateBadge } from './doc-state'\nimport { ReferenceConfirmDialog } from './reference-confirm'\nimport { ReferencesPanel } from '../references/references-panel'\nimport { InspectorSidebar } from '../inspector/inspector-sidebar'\nimport type { InspectorPane } from '../inspector/inspector-sidebar'\nimport { DocumentEditorProvider } from './document-editor-context'\nimport { VersionsPane } from './versions-pane'\nimport { IssuesPane } from './issues-pane'\nimport { DetailsPane } from './details-pane'\nimport { useSetBreadcrumb } from '../breadcrumb-context'\nimport type { BreadcrumbItem } from '../breadcrumb-context'\nimport { resolveDeploymentFrontendUrl, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace'\nimport { usePublishedDocuments } from '@elytracms/studio/lib/cms/published-documents'\n\nexport function DetailEditor({\n projectId,\n collectionId,\n documentId,\n focusPath,\n}: {\n projectId: string\n collectionId: string\n documentId: string\n /** Reference-index field path (`?field=`, EC-172): highlight + scroll to the exact field. */\n focusPath?: string\n}) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const doc = cms.getDocument({ collection: collectionId, id: documentId })\n\n // EC-274: singleton opening is owned by `SingletonGate` (it resolves the lone\n // document and materializes it). The detail editor just renders the document it\n // is given by id — singletons need no special case here.\n if (!collection || !doc) {\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Stack gap=\"3\" align=\"center\" className=\"text-center\">\n <Heading level={2} size=\"h2\">\n Document not found\n </Heading>\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsCollection(collectionId) }}\n className=\"text-sm text-primary hover:underline\"\n >\n Back to {collectionId}\n </Link>\n </Stack>\n </div>\n )\n }\n\n return (\n <EditorBody\n key={`${collectionId}/${documentId}`}\n projectId={projectId}\n collection={collection}\n doc={doc}\n focusPath={focusPath}\n />\n )\n}\n\n/** The loaded state of a document's pinned published snapshot (EC-226). */\ntype PublishedSnapshot =\n | { status: 'loading' }\n | { status: 'ready'; doc: CmsDocument }\n | { status: 'missing' }\n\nfunction EditorBody({\n projectId,\n collection,\n doc,\n focusPath,\n}: {\n projectId: string\n collection: CollectionDef\n doc: CmsDocument\n focusPath?: string\n}) {\n const cms = useCms()\n const navigate = useNavigate()\n // EC-217: a singleton collection has no list — there is nowhere to go \"back\"\n // to, and its one document is fixed (never deleted). The header drops the\n // back-crumb/id line and the Delete action accordingly.\n const singleton = isSingleton(collection)\n const [draft, setDraft] = useState<CmsDocument>(() => structuredClone(doc))\n // The studio's ambient active locale (EC-176): the form displays and edits\n // exactly this locale — switched via the shared LocaleSwitcher, never per field.\n const locale = cms.activeLocale\n // Bumped when a version restore replaces the draft out-of-band, to remount the\n // (uncontrolled) canvas editor from the restored value (EC-224).\n const [restoreNonce, setRestoreNonce] = useState(0)\n // EC-173: unpublish/delete go through the reference-aware confirmation.\n const [confirmAction, setConfirmAction] = useState<ReferenceAction | null>(null)\n // Stable so the document-editor context value (EC-224) doesn't churn each render.\n const ref = useMemo(() => ({ collection: collection.id, id: doc.id }), [collection.id, doc.id])\n const confirmTargets = useMemo(\n () => [{ collection: collection.id, id: doc.id }],\n [collection.id, doc.id],\n )\n\n // EC-226: the draft/published VIEW perspective. Draft = the editable working\n // draft; Published = the pinned published snapshot, rendered read-only. Only\n // meaningful when the document is published.\n const published = cms.isPublished(ref)\n const [perspective, setPerspective] = useState<'draft' | 'published'>('draft')\n const [publishedSnapshot, setPublishedSnapshot] = useState<PublishedSnapshot>({ status: 'loading' })\n // Snap back to Draft if the document is unpublished while viewing Published.\n useEffect(() => {\n if (!published) setPerspective('draft')\n }, [published])\n // Load the pinned published snapshot when viewing Published (fresh each switch,\n // so it reflects the current pin after a re-publish). `loadDocumentVersions` is\n // a stable callback, so this only re-runs on a perspective/ref change.\n const loadVersions = cms.loadDocumentVersions\n useEffect(() => {\n if (perspective !== 'published') return\n let cancelled = false\n setPublishedSnapshot({ status: 'loading' })\n void (async () => {\n const view = await loadVersions(ref)\n if (cancelled) return\n const pinned =\n view.publishedVersion !== undefined\n ? view.versions.find((v) => v.version === view.publishedVersion)?.snapshot\n : undefined\n setPublishedSnapshot(pinned ? { status: 'ready', doc: pinned } : { status: 'missing' })\n })()\n return () => {\n cancelled = true\n }\n }, [perspective, ref, loadVersions])\n\n // The whole fieldset is read-only when viewing Published. The form/canvas\n // render the pinned snapshot ONLY once it has loaded — never the draft, which\n // must not be presented as published; until then the body shows a placeholder.\n const viewReadOnly = perspective === 'published'\n const viewDoc =\n viewReadOnly && publishedSnapshot.status === 'ready' ? publishedSnapshot.doc : draft\n const publishedPending = viewReadOnly && publishedSnapshot.status !== 'ready'\n\n const dirty = JSON.stringify(draft) !== JSON.stringify(doc)\n const issues = useMemo(() => cms.validate(draft), [cms, draft])\n const errorCount = issues.filter((i) => i.severity === 'error').length\n const hasErrors = errorCount > 0\n\n // --- Autosave (EC-225) -----------------------------------------------------\n // The draft persists automatically 1s after the last edit; there is no manual\n // Save button. Refs let the unmount flush read the latest values without\n // re-subscribing the effects.\n const draftRef = useRef(draft)\n draftRef.current = draft\n const dirtyRef = useRef(dirty)\n dirtyRef.current = dirty\n const cmsRef = useRef(cms)\n cmsRef.current = cms\n\n useEffect(() => {\n if (!dirty) return\n const timer = window.setTimeout(() => cmsRef.current.saveDocument(draftRef.current), 1000)\n return () => window.clearTimeout(timer)\n }, [dirty, draft])\n\n // Flush a still-pending edit on unmount (navigating away inside the debounce\n // window) so nothing is lost. Unmount-only — refs carry the latest state.\n useEffect(\n () => () => {\n if (dirtyRef.current) cmsRef.current.saveDocument(draftRef.current)\n },\n [],\n )\n const errorsByField = useMemo(() => {\n const map = new Map<string, string>()\n for (const issue of issues) {\n // validateDocument populates meta.field for field-level issues (works for\n // both `values` and `localized/<locale>` paths, unlike positional indexing).\n const field = issue.meta?.field\n if (typeof field === 'string' && !map.has(field)) map.set(field, issue.message)\n }\n return map\n }, [issues])\n\n const tabs = collection.form?.tabs ?? ['main']\n // EC-269: References gets its own dedicated, visibility-gated tab — it mounts\n // (and loads) only when selected, and unmounts on leave, so normal editing\n // never triggers reference fetching. Appended after the collection's content tabs.\n const REFERENCES_TAB = 'references'\n const editorTabs = [...tabs, REFERENCES_TAB]\n const [activeTab, setActiveTab] = useState(tabs[0]!)\n // EC-285: the reserved `sidebar` group is document-level metadata (slug, author…)\n // — it renders in the Details inspector pane, not as a content tab, so it is\n // excluded from the tab fields here and collected once below.\n const sidebarFieldDefs = useMemo(() => sidebarFields(collection), [collection])\n // EC-273: only STATICALLY hidden fields (`hidden: true`) are structurally\n // excluded here; a conditionally (predicate) hidden field stays in the tab and\n // is evaluated per-render against the current values (it may show or hide as the\n // editor types).\n const tabFields = collection.fields.filter(\n (f) =>\n (f.form?.tab ?? tabs[0]) === activeTab &&\n !staticFieldHidden(f) &&\n f.form?.group !== SIDEBAR_FIELD_GROUP,\n )\n const groups = groupFields(tabFields, collection)\n // EC-188 (AD-12): a composition (`blocks`) field is a special content feature,\n // not a field-row — it takes over its tab with the full page-builder canvas.\n // Convention: such a field lives on its own dedicated fieldset tab.\n const canvasField = tabFields.find(isBlocksField)\n\n const [highlightedField, setHighlightedField] = useState<string | null>(null)\n // EC-285: the form-path inspector's active pane, controlled so a jump to a\n // `sidebar`-group field can open the Details pane (where it renders). Undefined\n // = uncontrolled (the sidebar defaults to its first pane).\n const [inspectorPaneId, setInspectorPaneId] = useState<string>()\n // Focus a field by name: switch to its tab (and locale, when given), scroll the\n // control into view, and ring-highlight it. Shared by the reference deep-link\n // (`focusPath`, EC-172) and the Issues pane's jump-to-field (EC-283).\n const focusTimersRef = useRef<number[]>([])\n const focusField = useCallback(\n (fieldName: string, localeHint?: string) => {\n const field = collection.fields.find((f) => f.name === fieldName)\n if (!field) return\n // EC-285: a `sidebar`-group field renders in the Details inspector pane, not\n // a content tab — open that pane instead of switching tabs.\n if (field.form?.group === SIDEBAR_FIELD_GROUP) {\n setInspectorPaneId('details')\n } else {\n const fieldTabs = collection.form?.tabs ?? ['main']\n setActiveTab(field.form?.tab ?? fieldTabs[0]!)\n }\n if (localeHint !== undefined && cms.localeConfig.locales.includes(localeHint)) {\n setStudioLocale(localeHint)\n }\n setHighlightedField(field.name)\n // Clear any timers from a prior jump so back-to-back jumps don't fight.\n focusTimersRef.current.forEach((t) => window.clearTimeout(t))\n const scrollTimer = window.setTimeout(() => {\n // Some controls (relation/asset pickers) don't render the input id —\n // the field label (`htmlFor`) is always present.\n const control =\n document.getElementById(`f-${field.name}`) ??\n document.querySelector(`label[for=\"${CSS.escape(`f-${field.name}`)}\"]`)\n control?.scrollIntoView({ block: 'center', behavior: 'smooth' })\n }, 60)\n const clearTimer = window.setTimeout(() => setHighlightedField(null), 3200)\n focusTimersRef.current = [scrollTimer, clearTimer]\n },\n [collection, cms.localeConfig],\n )\n useEffect(() => () => focusTimersRef.current.forEach((t) => window.clearTimeout(t)), [])\n\n // Reference deep links (EC-172): `?field=<index path>` pinpoints the exact field.\n useEffect(() => {\n if (!focusPath) return\n const parsed = parseDocumentFieldPath(focusPath)\n if (!parsed) return\n focusField(parsed.field, parsed.locale)\n }, [focusPath, focusField])\n\n function getValue(field: FieldDef): unknown {\n // EC-226: read from the active VIEW (the draft, or the pinned published\n // snapshot when viewing Published) — never directly from `draft`.\n if (isFieldLocalized(collection, field.name)) {\n // Display the explicit variant when it exists, else the EC-018 fallback\n // value — labeled as such by the field's fallback marker (EC-176), so a\n // German view shows the English text visibly, never an unexplained blank.\n const explicit = viewDoc.localized?.[locale]?.[field.name]\n if (explicit !== undefined) return explicit\n return resolveField(collection, viewDoc, field.name, locale, cms.localeConfig).value\n }\n return viewDoc.values[field.name]\n }\n\n function setValue(field: FieldDef, value: unknown) {\n setDraft((d) => {\n if (isFieldLocalized(collection, field.name)) {\n const perLocale = { ...(d.localized?.[locale] ?? {}) }\n if (value === undefined) delete perLocale[field.name]\n else perLocale[field.name] = value\n return { ...d, localized: { ...d.localized, [locale]: perLocale } }\n }\n const values = { ...d.values }\n if (value === undefined) delete values[field.name]\n else values[field.name] = value\n return { ...d, values }\n })\n }\n\n // EC-273: conditional-visibility context — the draft's values for the active\n // locale, against which a field's `hidden(values)` predicate is evaluated. A\n // hidden field's row is omitted (and it is not validated). Recomputed as the\n // draft changes, so a field shows/hides live as the editor types.\n const conditionValues = { ...draft.values, ...(draft.localized?.[locale] ?? {}) }\n const isHidden = (field: FieldDef) => isFieldHidden(field, { values: conditionValues })\n const visibleSidebarFields = sidebarFieldDefs.filter((f) => !isHidden(f))\n\n // One document field row (label + fallback/translation/read-only badges + the\n // control), shared by the content groups and the EC-285 Details pane so a\n // sidebar field renders identically — same control, validation, localization,\n // and EC-283 highlight/jump target — wherever it surfaces. Returns null when the\n // field is conditionally hidden (EC-273).\n function renderFieldRow(field: FieldDef) {\n if (isHidden(field)) return null\n // Field-level read-only (the Lock badge) vs the view-level read-only\n // (Published perspective) — the control honors both.\n const fieldLevelReadOnly = cms.isFieldReadOnly(field)\n const fieldReadOnly = viewReadOnly || fieldLevelReadOnly\n const localized = isFieldLocalized(collection, field.name)\n // Fallback visibility (EC-176): the control DISPLAYS the fallback value, and\n // this marker says so on the exact field.\n const fallback = localized\n ? displayedFieldFallback(collection, viewDoc, field.name, locale, cms.localeConfig)\n : null\n // The variant was created in this editing session (the saved document doesn't\n // have it yet): editing a fallback-shown value is an explicit translation act.\n // Moot (and hidden) while viewing the read-only published snapshot.\n const newlyTranslated =\n !viewReadOnly &&\n localized &&\n hasLocaleVariant(draft, field.name, locale) &&\n !hasLocaleVariant(doc, field.name, locale)\n return (\n <Field\n key={field.name}\n className={cn(\n 'rounded-md transition-shadow',\n highlightedField === field.name && 'bg-primary/5 p-2 ring-2 ring-primary/70',\n )}\n label={\n <Row gap=\"2\">\n <span>{fieldLabel(field)}</span>\n {field.validation?.required ? <span className=\"text-destructive\">*</span> : null}\n {localized ? <Badge variant=\"outline\">{locale}</Badge> : null}\n {fallback ? (\n <Badge\n variant=\"warning\"\n title={fallbackTitle(fallback)}\n data-testid={`field-fallback-${field.name}`}\n >\n showing {localeChipLabel(fallback.sourceLocale)}\n </Badge>\n ) : null}\n {newlyTranslated ? (\n <Badge variant=\"success\" data-testid={`field-translated-${field.name}`}>\n <Languages className=\"size-3\" /> translated to {localeChipLabel(locale)}\n </Badge>\n ) : null}\n {fieldLevelReadOnly ? (\n <Badge variant=\"outline\">\n <Lock className=\"size-3\" /> read-only\n </Badge>\n ) : null}\n <Spacer />\n </Row>\n }\n htmlFor={`f-${field.name}`}\n hint={\n fallback ? (\n <>\n Showing the {localeChipLabel(fallback.sourceLocale)} (fallback) value — edit to\n translate to {localeChipLabel(locale)}. Clearing the {localeChipLabel(locale)} text\n falls back again.\n </>\n ) : (\n field.form?.description\n )\n }\n error={fieldReadOnly ? undefined : errorsByField.get(field.name)}\n >\n <FieldControl\n id={`f-${field.name}`}\n field={field}\n value={getValue(field)}\n onChange={(v) => setValue(field, v)}\n readOnly={fieldReadOnly}\n />\n </Field>\n )\n }\n\n function save() {\n cms.saveDocument(draft)\n }\n\n // EC-224: a version restore swaps the working draft for an older snapshot; the\n // open editor adopts it so the form/canvas re-render from the restored content\n // (the operation already persisted it, so it lands clean/non-dirty).\n function replaceDraft(next: CmsDocument) {\n setDraft(next)\n // The canvas editor is uncontrolled after mount (it builds its graph once and\n // lifts edits OUT). A restore replaces the draft from outside, so bump the\n // nonce to REMOUNT the canvas from the restored value — otherwise it keeps the\n // pre-restore tree and the next edit would clobber the restore.\n setRestoreNonce((n) => n + 1)\n }\n\n // The frame-owned `Versions` pane (EC-224) — appended after any view-supplied\n // pane (the canvas's `Properties`). One instance feeds both the form view's\n // sidebar and the canvas view's sidebar.\n const versionsPane = useMemo<InspectorPane>(\n () => ({\n id: 'versions',\n label: 'Versions',\n icon: <History className=\"size-3.5\" />,\n render: () => <VersionsPane />,\n }),\n [],\n )\n // The frame-owned `Issues` pane (EC-283) — the document-scoped validation\n // surface that replaces the always-on footer band. The tab carries a count\n // badge (error- vs warning-toned) so a non-zero count is discoverable from\n // any tab; document-level issues (e.g. EC-260 nesting-depth) live only here.\n const issuesPane = useMemo<InspectorPane>(\n () => ({\n id: 'issues',\n label: 'Issues',\n icon: <CircleAlert className=\"size-3.5\" />,\n badge:\n issues.length === 0 ? undefined : (\n <Badge\n variant={errorCount > 0 ? 'error' : 'warning'}\n className=\"px-1.5 py-0 leading-none\"\n >\n {issues.length}\n </Badge>\n ),\n render: () => (\n <IssuesPane issues={issues} collection={collection} onJumpToField={focusField} />\n ),\n }),\n [issues, errorCount, collection, focusField],\n )\n // EC-284 + EC-285: the document-metadata pane — slot assignment (EC-284) and/or\n // the document-level `sidebar`-group fields (EC-285). Present only when the\n // collection has either, so it never adds an empty tab elsewhere. First in the\n // order, so a slotted / sidebar-bearing document opens straight to it. Not\n // memoized: its render closes over per-render edit state (draft, highlight,\n // field errors) via `renderFieldRow`, and the inspector re-renders with the rest\n // of the editor anyway, so a stable pane identity would buy nothing here.\n const detailsPane: InspectorPane | null =\n hasAliases(collection) || visibleSidebarFields.length > 0\n ? {\n id: 'details',\n label: 'Details',\n icon: <Tag className=\"size-3.5\" />,\n render: () => (\n <DetailsPane\n collection={collection}\n doc={draft}\n siblings={cms.documentsOf(collection.id)}\n readOnly={viewReadOnly}\n fields={visibleSidebarFields}\n renderField={renderFieldRow}\n onAliasChange={(alias) =>\n setDraft((d) => {\n const next = { ...d }\n if (alias === undefined) delete next.alias\n else next.alias = alias\n return next\n })\n }\n />\n ),\n }\n : null\n const trailingPanes = detailsPane\n ? [detailsPane, versionsPane, issuesPane]\n : [versionsPane, issuesPane]\n\n // EC-268: the Publish button is its own indicator — pending while the publish\n // round-trips, a brief success, and an error toast if it rejects at transport.\n const [publishState, setPublishState] = useState<'idle' | 'pending' | 'success'>('idle')\n\n async function handlePublish() {\n // EC-273: clean conditionally-hidden values from the draft AT PUBLISH TIME.\n // While editing, the draft keeps them so an accidental hide (e.g. flipping a\n // link's type) is recoverable; publishing is the intentional moment we commit\n // the cleanup — into the draft AND the snapshot, so both go clean together (the\n // reference index updates off the saved draft, so a now-unlinked page becomes\n // deletable once the change is published). Also captures the latest edit in case\n // Publish is clicked inside the autosave debounce window; the serial persister\n // runs the upsert before the publish so the snapshot is exactly this draft (EC-225).\n const cleaned = clearHiddenValues(collection, draft)\n if (cleaned !== draft) setDraft(cleaned)\n if (cleaned !== draft || dirty) cms.saveDocument(cleaned)\n // Publish snapshots the draft as a version and pins it (EC-224). The live\n // row stays a continuous draft — published-ness is the version pointer\n // (`cms.isPublished`). Pre-gated by `disabled={hasErrors}`; the optimistic\n // flip reconciles against the backend (EC-225), so a logical rejection the\n // gate doesn't cover (schema divergence) self-corrects the badge. A hard\n // failure (transport) rejects the flush — surface it loudly (EC-268).\n setPublishState('pending')\n try {\n await cms.publishDocument(ref)\n setPublishState('success')\n setTimeout(() => setPublishState('idle'), 1800)\n } catch (error) {\n setPublishState('idle')\n toast.error(error instanceof Error ? `Publish failed: ${error.message}` : 'Publish failed.')\n }\n }\n\n function handleConfirmedAction() {\n if (confirmAction === 'unpublish') {\n setConfirmAction(null)\n void cms.unpublishDocument(ref)\n return\n }\n if (confirmAction === 'delete') {\n setConfirmAction(null)\n cms.deleteDocument(ref)\n void navigate({\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.cmsCollection(collection.id) },\n })\n }\n }\n\n // While the published snapshot is pending, don't derive the title from the\n // draft (it must not read as the published title) — fall back to the id.\n const title = publishedPending ? '' : primaryTitle(viewDoc, collection, locale, cms.localeConfig)\n const titleFallback = publishedPending\n ? null\n : displayedFieldFallback(\n collection,\n viewDoc,\n collection.titleField ?? 'title',\n locale,\n cms.localeConfig,\n )\n\n // EC-214: the document is the active record — contribute the collection (a\n // link back to its list) and the document title to the global header\n // breadcrumb, replacing the editor's own back-link + collection/id line. A\n // singleton has no list, so it contributes a single, non-linked crumb. The\n // title tracks the live draft so a rename updates the crumb immediately.\n const breadcrumbItems = useMemo<BreadcrumbItem[]>(() => {\n const collectionLabel = collection.form?.label ?? collection.id\n if (singleton) return [{ label: collectionLabel }]\n const docTitle = primaryTitle(draft, collection, locale, cms.localeConfig) || doc.id\n return [\n {\n label: collectionLabel,\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.cmsCollection(collection.id) },\n },\n { label: docTitle },\n ]\n }, [singleton, collection, draft, locale, cms.localeConfig, doc.id, projectId])\n useSetBreadcrumb(breadcrumbItems)\n\n // EC-205/EC-216: the LIVE URL derives strictly from PUBLISHED data — the\n // document's pinned published snapshot and its published ancestors — never the\n // draft (an unpublished slug/parent edit must not leak into the live URL). The\n // pool is exactly what the live site serves, so a published doc resolves to the\n // URL visitors actually get; `undefined` until the doc is published (and the\n // pool has loaded). The collection being routable gates the disabled hint below.\n const publishedDocs = usePublishedDocuments(cms.projectId, collection.id)\n const routableCollection = useMemo(\n () => resolveDeploymentRoutes().some((route) => route.document?.collection === collection.id),\n [collection.id],\n )\n const liveUrl = useMemo(() => {\n const published = publishedDocs.byId.get(doc.id)\n if (!published) return undefined\n return urlForDocument(\n {\n routes: resolveDeploymentRoutes(),\n frontendUrl: resolveDeploymentFrontendUrl(),\n localeConfig: cms.localeConfig,\n },\n collection,\n published,\n { siblings: [...publishedDocs.byId.values()], locale },\n )\n }, [publishedDocs, collection, doc.id, locale, cms.localeConfig])\n\n return (\n <DocumentEditorProvider\n value={{\n projectId,\n collection,\n docRef: ref,\n draft,\n dirty,\n hasErrors,\n viewReadOnly,\n save,\n replaceDraft,\n }}\n >\n <div className={cn('flex h-full min-h-0 flex-col', viewReadOnly && 'bg-info/[0.04]')}>\n {/* Header — the back-link + collection/id line moved into the global\n breadcrumb (EC-214); this keeps only the record title + actions. */}\n <div className=\"shrink-0 border-b border-border px-4 py-3 sm:px-6\">\n <Row gap=\"3\">\n <Row gap=\"2\" align=\"center\" className=\"min-w-0\">\n <Heading level={1} size=\"h2\" className=\"truncate\">\n {singleton ? collection.form?.label ?? collection.id : title || doc.id}\n </Heading>\n {singleton ? null : <FallbackChip fallback={titleFallback} testId=\"doc-title-fallback\" />}\n </Row>\n <Spacer />\n {/* Autosave status (EC-225) — replaces the manual Save button. */}\n <Text size=\"xs\" tone=\"muted\" className=\"whitespace-nowrap\" data-testid=\"autosave-status\">\n {cms.persistError ? 'Save failed' : dirty ? 'Saving…' : 'Saved'}\n </Text>\n <DocStateBadge published={cms.isPublished(ref)} />\n {/* EC-216: open the document's live URL. Enabled once published with a\n configured frontendUrl; otherwise a disabled hint explains why. */}\n {/* EC-216 + EC-205: open the document's LIVE (published) URL. Enabled\n only once the published snapshot exists and a frontendUrl is set;\n otherwise a disabled hint explains why. Hidden for non-routable\n collections (e.g. singletons). */}\n {routableCollection ? (\n liveUrl?.href ? (\n <Button asChild variant=\"outline\" size=\"sm\" title={`Open ${liveUrl.path}`}>\n <a href={liveUrl.href} target=\"_blank\" rel=\"noreferrer\" data-testid=\"view-live\">\n <ExternalLink /> View live\n </a>\n </Button>\n ) : (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled\n data-testid=\"view-live-disabled\"\n title={\n publishedDocs.status === 'loading'\n ? 'Loading the live URL…'\n : !cms.isPublished(ref)\n ? 'Publish to view the live page'\n : 'Set frontendUrl in elytra.config.ts to enable'\n }\n >\n <ExternalLink /> View live\n </Button>\n )\n ) : null}\n <Button\n size=\"sm\"\n onClick={() => void handlePublish()}\n disabled={hasErrors || viewReadOnly || publishState === 'pending'}\n title={\n viewReadOnly\n ? 'Switch to Draft to publish'\n : hasErrors\n ? `Fix ${errorCount} ${errorCount === 1 ? 'issue' : 'issues'} to publish`\n : undefined\n }\n >\n {publishState === 'pending' ? (\n <>\n <Loader2 className=\"animate-spin\" /> Publishing…\n </>\n ) : publishState === 'success' ? (\n <>\n <CircleCheck /> Published\n </>\n ) : (\n <>\n <Eye /> Publish\n </>\n )}\n </Button>\n {/* EC-217: a singleton is never deleted; with nothing else to show\n (an unpublished singleton) the actions menu is omitted entirely. */}\n {cms.isPublished(ref) || !singleton ? (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" size=\"icon-sm\" aria-label=\"More actions\">\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {cms.isPublished(ref) ? (\n <DropdownMenuItem onClick={() => setConfirmAction('unpublish')}>\n <EyeOff /> Unpublish\n </DropdownMenuItem>\n ) : null}\n {singleton ? null : (\n <DropdownMenuItem\n data-testid=\"doc-delete\"\n className=\"text-destructive\"\n onClick={() => setConfirmAction('delete')}\n >\n <Trash2 /> Delete\n </DropdownMenuItem>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n ) : null}\n </Row>\n\n {/* Ambient locale switcher (EC-176, supersedes the per-document EC-076 one) + tabs (EC-073)\n + the Draft/Published view perspective (EC-226). */}\n <Row gap=\"3\" className=\"mt-3\" wrap>\n <LocaleSwitcher />\n <Row gap=\"1\">\n {editorTabs.map((tab) => (\n <button\n key={tab}\n type=\"button\"\n aria-pressed={tab === activeTab}\n onClick={() => setActiveTab(tab)}\n className={cn(\n 'rounded-md px-2.5 py-1 text-xs font-medium capitalize transition-colors',\n tab === activeTab ? 'bg-accent text-accent-foreground' : 'text-muted-foreground hover:bg-muted',\n )}\n >\n {tab}\n </button>\n ))}\n </Row>\n <Spacer />\n <Row gap=\"px\" className=\"rounded-md bg-muted/60 p-0.5\">\n <PerspectiveButton\n label=\"Draft\"\n active={perspective === 'draft'}\n onClick={() => setPerspective('draft')}\n />\n <PerspectiveButton\n label=\"Published\"\n active={perspective === 'published'}\n accent=\"info\"\n disabled={!published}\n title={published ? undefined : 'Publish this document to view its published version'}\n onClick={() => setPerspective('published')}\n />\n </Row>\n </Row>\n </div>\n\n {/* EC-214: an unmistakable banner whenever the read-only Published snapshot\n is in view — disabled controls + a footer notice alone read as too\n subtle. Paired with the tinted surface and the accented toggle. */}\n {viewReadOnly ? (\n <Row\n gap=\"2\"\n className=\"shrink-0 border-b border-info/30 bg-info/10 px-4 py-1.5 text-info sm:px-6\"\n data-testid=\"published-view-banner\"\n >\n <Lock className=\"size-3.5 shrink-0\" aria-hidden />\n <Text size=\"xs\" className=\"text-info\">\n Viewing the published version — read-only.\n </Text>\n <Spacer />\n <button\n type=\"button\"\n onClick={() => setPerspective('draft')}\n className=\"text-xs font-medium underline-offset-2 hover:underline\"\n >\n Switch to Draft\n </button>\n </Row>\n ) : null}\n\n {/* Body — a blocks field takes over the body with the page-builder canvas\n (which carries its own inspector sidebar, EC-188/EC-224); otherwise the\n field form sits beside the shared inspector sidebar (Versions). In\n Published view the snapshot must load before rendering — the draft is\n never shown as published (EC-226). */}\n {publishedPending ? (\n <div className=\"grid min-h-0 flex-1 place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n {publishedSnapshot.status === 'loading'\n ? 'Loading the published version…'\n : 'No published version found for this document.'}\n </Text>\n </div>\n ) : canvasField ? (\n <div className=\"min-h-0 flex-1 overflow-hidden\">\n <CompositionFieldEditor\n key={`${canvasField.name}:${restoreNonce}:${perspective}`}\n field={canvasField}\n value={getValue(canvasField)}\n onChange={(v) => setValue(canvasField, v)}\n readOnly={viewReadOnly || cms.isFieldReadOnly(canvasField)}\n trailingPanes={trailingPanes}\n />\n </div>\n ) : activeTab === REFERENCES_TAB ? (\n // EC-269: mounted only while this tab is active → reference data loads on\n // demand and is torn down on leave (no fetching during normal editing).\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-h-0 flex-1 overflow-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-2xl\">\n <ReferencesPanel\n projectId={projectId}\n source={{ type: 'document', id: documentKey(ref) }}\n target={{ type: 'document', id: documentKey(ref) }}\n />\n </div>\n </div>\n </div>\n ) : (\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-h-0 flex-1 overflow-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-2xl\">\n <Stack gap=\"6\">\n {groups.map((group) => {\n // EC-273: drop a fieldset whose every field is conditionally hidden,\n // so the form never shows an empty panel header.\n const visible = group.fields.filter((f) => !isHidden(f))\n if (visible.length === 0) return null\n return (\n <Panel key={group.name}>\n <PanelHeader>\n <Text size=\"sm\" weight=\"semibold\" className=\"capitalize\">\n {group.name}\n </Text>\n </PanelHeader>\n <Stack gap=\"4\" className=\"p-4\">\n {visible.map(renderFieldRow)}\n </Stack>\n </Panel>\n )\n })}\n </Stack>\n </div>\n </div>\n <InspectorSidebar\n panes={trailingPanes}\n activeId={inspectorPaneId}\n onActiveChange={setInspectorPaneId}\n className=\"w-[320px] shrink-0 border-l border-border\"\n />\n </div>\n )}\n\n {/* EC-283: the always-on validation footer is retired. Validation now lives\n in the document-scoped `Issues` inspector pane (full list + jump-to-field,\n count badge on its tab), field issues stay inline, and the Publish button\n gates on errors. Read-only is announced by the top banner (EC-214). */}\n\n {/* Reference-aware unpublish/delete confirmation (EC-173). */}\n {confirmAction !== null ? (\n <ReferenceConfirmDialog\n projectId={projectId}\n action={confirmAction}\n targets={confirmTargets}\n open\n onOpenChange={(open) => {\n if (!open) setConfirmAction(null)\n }}\n onConfirm={handleConfirmedAction}\n />\n ) : null}\n </div>\n </DocumentEditorProvider>\n )\n}\n\n/**\n * A segmented-control button for the Draft/Published view toggle (EC-226). The\n * `accent` variant (EC-214) gives the active Published segment a distinct info\n * treatment, so the read-only mode is obvious at the control itself.\n */\nfunction PerspectiveButton({\n label,\n active,\n accent,\n disabled,\n title,\n onClick,\n}: {\n label: string\n active: boolean\n accent?: 'info'\n disabled?: boolean\n title?: string\n onClick: () => void\n}) {\n return (\n <button\n type=\"button\"\n aria-pressed={active}\n disabled={disabled}\n title={title}\n onClick={onClick}\n className={cn(\n 'rounded px-2.5 py-1 text-xs font-medium transition-colors disabled:opacity-40',\n active\n ? accent === 'info'\n ? 'bg-info text-info-foreground shadow-sm'\n : 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground',\n )}\n >\n {label}\n </button>\n )\n}\n\ninterface FieldGroup {\n name: string\n fields: FieldDef[]\n}\n\nfunction groupFields(fields: FieldDef[], collection: CollectionDef): FieldGroup[] {\n const order = collection.form?.groups ?? []\n const byGroup = new Map<string, FieldDef[]>()\n for (const field of fields) {\n const group = field.form?.group ?? 'fields'\n if (!byGroup.has(group)) byGroup.set(group, [])\n byGroup.get(group)!.push(field)\n }\n const names = [...byGroup.keys()].sort((a, b) => {\n const ia = order.indexOf(a)\n const ib = order.indexOf(b)\n return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib)\n })\n return names.map((name) => ({\n name,\n fields: byGroup.get(name)!.sort((a, b) => (a.form?.order ?? 99) - (b.form?.order ?? 99)),\n }))\n}\n\nfunction primaryTitle(\n doc: CmsDocument,\n collection: CollectionDef,\n locale: Locale,\n config: LocaleConfig,\n): string {\n const { value } = resolveField(collection, doc, collection.titleField ?? 'title', locale, config)\n return typeof value === 'string' ? value : ''\n}\n"]}
|
|
1
|
+
{"version":3,"file":"detail-editor.js","sourceRoot":"","sources":["../../../src/components/cms/detail-editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC9F,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,GAAG,EACH,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,IAAI,EACJ,cAAc,EACd,GAAG,EACH,MAAM,GACP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAA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AAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1B,IAAI;QACJ,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;KACzF,CAAC,CAAC,CAAA;AACL,CAAC;AAED,SAAS,YAAY,CACnB,GAAgB,EAChB,UAAyB,EACzB,MAAc,EACd,MAAoB;IAEpB,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,UAAU,IAAI,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACjG,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/C,CAAC","sourcesContent":["import { Link, STUDIO_PROJECT_ROUTE, studioPath, useNavigate } from '@elytracms/studio/router'\nimport {\n CircleAlert,\n CircleCheck,\n ExternalLink,\n Eye,\n EyeOff,\n History,\n Languages,\n Loader2,\n Lock,\n MoreHorizontal,\n Tag,\n Trash2,\n} from 'lucide-react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n SIDEBAR_FIELD_GROUP,\n clearHiddenValues,\n documentKey,\n hasAliases,\n isBlocksField,\n isFieldHidden,\n isFieldLocalized,\n isSingleton,\n resolveField,\n sidebarFields,\n staticFieldHidden,\n urlForDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CmsValidationIssue,\n CollectionDef,\n DocumentRef,\n FieldDef,\n Locale,\n LocaleConfig,\n} from '@elytracms/core/cms-core'\nimport { blockRootsOf } from '@elytracms/core/project-graph'\nimport {\n Badge,\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Field,\n Heading,\n Panel,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n toast,\n} from '@elytracms/studio/ui'\nimport { getStudioRegistry } from '@elytracms/studio/lib/registry'\nimport { collectEmbedRefs, resolveReuseCapability } from '../builder/reuse'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport {\n LocaleSwitcher,\n displayedFieldFallback,\n hasLocaleVariant,\n localeChipLabel,\n setStudioLocale,\n} from '@elytracms/studio/lib/locale'\nimport { parseDocumentFieldPath } from '@elytracms/studio/lib/references'\nimport type { ReferenceAction } from '@elytracms/studio/lib/references'\nimport { FallbackChip, fallbackTitle } from './cell'\nimport { FieldControl } from './field-control'\nimport { CompositionFieldEditor } from '../builder/composition-field-editor'\nimport { fieldLabel, useCms } from './cms-store'\nimport type { CmsStore } from './cms-store'\nimport { DocStateBadge } from './doc-state'\nimport { ReferenceConfirmDialog } from './reference-confirm'\nimport { ReferencesPanel } from '../references/references-panel'\nimport { InspectorSidebar } from '../inspector/inspector-sidebar'\nimport type { InspectorPane } from '../inspector/inspector-sidebar'\nimport { DocumentEditorProvider } from './document-editor-context'\nimport { VersionsPane } from './versions-pane'\nimport { IssuesPane } from './issues-pane'\nimport { DetailsPane } from './details-pane'\nimport { useSetBreadcrumb } from '../breadcrumb-context'\nimport type { BreadcrumbItem } from '../breadcrumb-context'\nimport { resolveDeploymentFrontendUrl, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace'\nimport { usePublishedDocuments } from '@elytracms/studio/lib/cms/published-documents'\n\nexport function DetailEditor({\n projectId,\n collectionId,\n documentId,\n focusPath,\n}: {\n projectId: string\n collectionId: string\n documentId: string\n /** Reference-index field path (`?field=`, EC-172): highlight + scroll to the exact field. */\n focusPath?: string\n}) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const doc = cms.getDocument({ collection: collectionId, id: documentId })\n\n // EC-274: singleton opening is owned by `SingletonGate` (it resolves the lone\n // document and materializes it). The detail editor just renders the document it\n // is given by id — singletons need no special case here.\n if (!collection || !doc) {\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Stack gap=\"3\" align=\"center\" className=\"text-center\">\n <Heading level={2} size=\"h2\">\n Document not found\n </Heading>\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: studioPath.cmsCollection(collectionId) }}\n className=\"text-sm text-primary hover:underline\"\n >\n Back to {collectionId}\n </Link>\n </Stack>\n </div>\n )\n }\n\n return (\n <EditorBody\n key={`${collectionId}/${documentId}`}\n projectId={projectId}\n collection={collection}\n doc={doc}\n focusPath={focusPath}\n />\n )\n}\n\n/** The loaded state of a document's pinned published snapshot (EC-226). */\ntype PublishedSnapshot =\n | { status: 'loading' }\n | { status: 'ready'; doc: CmsDocument }\n | { status: 'missing' }\n\nfunction EditorBody({\n projectId,\n collection,\n doc,\n focusPath,\n}: {\n projectId: string\n collection: CollectionDef\n doc: CmsDocument\n focusPath?: string\n}) {\n const cms = useCms()\n const navigate = useNavigate()\n // EC-217: a singleton collection has no list — there is nowhere to go \"back\"\n // to, and its one document is fixed (never deleted). The header drops the\n // back-crumb/id line and the Delete action accordingly.\n const singleton = isSingleton(collection)\n const [draft, setDraft] = useState<CmsDocument>(() => structuredClone(doc))\n // The studio's ambient active locale (EC-176): the form displays and edits\n // exactly this locale — switched via the shared LocaleSwitcher, never per field.\n const locale = cms.activeLocale\n // Bumped when a version restore replaces the draft out-of-band, to remount the\n // (uncontrolled) canvas editor from the restored value (EC-224).\n const [restoreNonce, setRestoreNonce] = useState(0)\n // EC-173: unpublish/delete go through the reference-aware confirmation.\n const [confirmAction, setConfirmAction] = useState<ReferenceAction | null>(null)\n // Stable so the document-editor context value (EC-224) doesn't churn each render.\n const ref = useMemo(() => ({ collection: collection.id, id: doc.id }), [collection.id, doc.id])\n const confirmTargets = useMemo(\n () => [{ collection: collection.id, id: doc.id }],\n [collection.id, doc.id],\n )\n\n // EC-226: the draft/published VIEW perspective. Draft = the editable working\n // draft; Published = the pinned published snapshot, rendered read-only. Only\n // meaningful when the document is published.\n const published = cms.isPublished(ref)\n const [perspective, setPerspective] = useState<'draft' | 'published'>('draft')\n const [publishedSnapshot, setPublishedSnapshot] = useState<PublishedSnapshot>({ status: 'loading' })\n // Snap back to Draft if the document is unpublished while viewing Published.\n useEffect(() => {\n if (!published) setPerspective('draft')\n }, [published])\n // Load the pinned published snapshot when viewing Published (fresh each switch,\n // so it reflects the current pin after a re-publish). `loadDocumentVersions` is\n // a stable callback, so this only re-runs on a perspective/ref change.\n const loadVersions = cms.loadDocumentVersions\n useEffect(() => {\n if (perspective !== 'published') return\n let cancelled = false\n setPublishedSnapshot({ status: 'loading' })\n void (async () => {\n const view = await loadVersions(ref)\n if (cancelled) return\n const pinned =\n view.publishedVersion !== undefined\n ? view.versions.find((v) => v.version === view.publishedVersion)?.snapshot\n : undefined\n setPublishedSnapshot(pinned ? { status: 'ready', doc: pinned } : { status: 'missing' })\n })()\n return () => {\n cancelled = true\n }\n }, [perspective, ref, loadVersions])\n\n // The whole fieldset is read-only when viewing Published. The form/canvas\n // render the pinned snapshot ONLY once it has loaded — never the draft, which\n // must not be presented as published; until then the body shows a placeholder.\n const viewReadOnly = perspective === 'published'\n const viewDoc =\n viewReadOnly && publishedSnapshot.status === 'ready' ? publishedSnapshot.doc : draft\n const publishedPending = viewReadOnly && publishedSnapshot.status !== 'ready'\n\n const dirty = JSON.stringify(draft) !== JSON.stringify(doc)\n const schemaIssues = useMemo(() => cms.validate(draft), [cms, draft])\n // EC-300/AD-16: composition embeds (hard references) whose target isn't published\n // would render empty on the live site. Surface them as errors in the Issues panel,\n // but they DON'T gate the Publish button (schema errors do) — publishing is\n // confirm-through, so the editor can publish the page and the reusable together\n // knowingly. The publish guard below catches them.\n const referenceIssues = useMemo(\n () => unpublishedEmbedIssues(collection, draft, cms),\n [collection, draft, cms],\n )\n const issues = useMemo(\n () => [...schemaIssues, ...referenceIssues],\n [schemaIssues, referenceIssues],\n )\n const errorCount = schemaIssues.filter((i) => i.severity === 'error').length\n const hasErrors = errorCount > 0\n const hasUnpublishedRefs = referenceIssues.length > 0\n\n // --- Autosave (EC-225) -----------------------------------------------------\n // The draft persists automatically 1s after the last edit; there is no manual\n // Save button. Refs let the unmount flush read the latest values without\n // re-subscribing the effects.\n const draftRef = useRef(draft)\n draftRef.current = draft\n const dirtyRef = useRef(dirty)\n dirtyRef.current = dirty\n const cmsRef = useRef(cms)\n cmsRef.current = cms\n\n useEffect(() => {\n if (!dirty) return\n const timer = window.setTimeout(() => cmsRef.current.saveDocument(draftRef.current), 1000)\n return () => window.clearTimeout(timer)\n }, [dirty, draft])\n\n // Flush a still-pending edit on unmount (navigating away inside the debounce\n // window) so nothing is lost. Unmount-only — refs carry the latest state.\n useEffect(\n () => () => {\n if (dirtyRef.current) cmsRef.current.saveDocument(draftRef.current)\n },\n [],\n )\n const errorsByField = useMemo(() => {\n const map = new Map<string, string>()\n for (const issue of issues) {\n // validateDocument populates meta.field for field-level issues (works for\n // both `values` and `localized/<locale>` paths, unlike positional indexing).\n const field = issue.meta?.field\n if (typeof field === 'string' && !map.has(field)) map.set(field, issue.message)\n }\n return map\n }, [issues])\n\n const tabs = collection.form?.tabs ?? ['main']\n // EC-269: References gets its own dedicated, visibility-gated tab — it mounts\n // (and loads) only when selected, and unmounts on leave, so normal editing\n // never triggers reference fetching. Appended after the collection's content tabs.\n const REFERENCES_TAB = 'references'\n const editorTabs = [...tabs, REFERENCES_TAB]\n const [activeTab, setActiveTab] = useState(tabs[0]!)\n // EC-285: the reserved `sidebar` group is document-level metadata (slug, author…)\n // — it renders in the Details inspector pane, not as a content tab, so it is\n // excluded from the tab fields here and collected once below.\n const sidebarFieldDefs = useMemo(() => sidebarFields(collection), [collection])\n // EC-273: only STATICALLY hidden fields (`hidden: true`) are structurally\n // excluded here; a conditionally (predicate) hidden field stays in the tab and\n // is evaluated per-render against the current values (it may show or hide as the\n // editor types).\n const tabFields = collection.fields.filter(\n (f) =>\n (f.form?.tab ?? tabs[0]) === activeTab &&\n !staticFieldHidden(f) &&\n f.form?.group !== SIDEBAR_FIELD_GROUP,\n )\n const groups = groupFields(tabFields, collection)\n // EC-188 (AD-12): a composition (`blocks`) field is a special content feature,\n // not a field-row — it takes over its tab with the full page-builder canvas.\n // Convention: such a field lives on its own dedicated fieldset tab.\n const canvasField = tabFields.find(isBlocksField)\n\n const [highlightedField, setHighlightedField] = useState<string | null>(null)\n // EC-285: the form-path inspector's active pane, controlled so a jump to a\n // `sidebar`-group field can open the Details pane (where it renders). Undefined\n // = uncontrolled (the sidebar defaults to its first pane).\n const [inspectorPaneId, setInspectorPaneId] = useState<string>()\n // Focus a field by name: switch to its tab (and locale, when given), scroll the\n // control into view, and ring-highlight it. Shared by the reference deep-link\n // (`focusPath`, EC-172) and the Issues pane's jump-to-field (EC-283).\n const focusTimersRef = useRef<number[]>([])\n const focusField = useCallback(\n (fieldName: string, localeHint?: string) => {\n const field = collection.fields.find((f) => f.name === fieldName)\n if (!field) return\n // EC-285: a `sidebar`-group field renders in the Details inspector pane, not\n // a content tab — open that pane instead of switching tabs.\n if (field.form?.group === SIDEBAR_FIELD_GROUP) {\n setInspectorPaneId('details')\n } else {\n const fieldTabs = collection.form?.tabs ?? ['main']\n setActiveTab(field.form?.tab ?? fieldTabs[0]!)\n }\n if (localeHint !== undefined && cms.localeConfig.locales.includes(localeHint)) {\n setStudioLocale(localeHint)\n }\n setHighlightedField(field.name)\n // Clear any timers from a prior jump so back-to-back jumps don't fight.\n focusTimersRef.current.forEach((t) => window.clearTimeout(t))\n const scrollTimer = window.setTimeout(() => {\n // Some controls (relation/asset pickers) don't render the input id —\n // the field label (`htmlFor`) is always present.\n const control =\n document.getElementById(`f-${field.name}`) ??\n document.querySelector(`label[for=\"${CSS.escape(`f-${field.name}`)}\"]`)\n control?.scrollIntoView({ block: 'center', behavior: 'smooth' })\n }, 60)\n const clearTimer = window.setTimeout(() => setHighlightedField(null), 3200)\n focusTimersRef.current = [scrollTimer, clearTimer]\n },\n [collection, cms.localeConfig],\n )\n useEffect(() => () => focusTimersRef.current.forEach((t) => window.clearTimeout(t)), [])\n\n // Reference deep links (EC-172): `?field=<index path>` pinpoints the exact field.\n useEffect(() => {\n if (!focusPath) return\n const parsed = parseDocumentFieldPath(focusPath)\n if (!parsed) return\n focusField(parsed.field, parsed.locale)\n }, [focusPath, focusField])\n\n function getValue(field: FieldDef): unknown {\n // EC-226: read from the active VIEW (the draft, or the pinned published\n // snapshot when viewing Published) — never directly from `draft`.\n if (isFieldLocalized(collection, field.name)) {\n // Display the explicit variant when it exists, else the EC-018 fallback\n // value — labeled as such by the field's fallback marker (EC-176), so a\n // German view shows the English text visibly, never an unexplained blank.\n const explicit = viewDoc.localized?.[locale]?.[field.name]\n if (explicit !== undefined) return explicit\n return resolveField(collection, viewDoc, field.name, locale, cms.localeConfig).value\n }\n return viewDoc.values[field.name]\n }\n\n function setValue(field: FieldDef, value: unknown) {\n setDraft((d) => {\n if (isFieldLocalized(collection, field.name)) {\n const perLocale = { ...(d.localized?.[locale] ?? {}) }\n if (value === undefined) delete perLocale[field.name]\n else perLocale[field.name] = value\n return { ...d, localized: { ...d.localized, [locale]: perLocale } }\n }\n const values = { ...d.values }\n if (value === undefined) delete values[field.name]\n else values[field.name] = value\n return { ...d, values }\n })\n }\n\n // EC-273: conditional-visibility context — the draft's values for the active\n // locale, against which a field's `hidden(values)` predicate is evaluated. A\n // hidden field's row is omitted (and it is not validated). Recomputed as the\n // draft changes, so a field shows/hides live as the editor types.\n const conditionValues = { ...draft.values, ...(draft.localized?.[locale] ?? {}) }\n const isHidden = (field: FieldDef) => isFieldHidden(field, { values: conditionValues })\n const visibleSidebarFields = sidebarFieldDefs.filter((f) => !isHidden(f))\n\n // One document field row (label + fallback/translation/read-only badges + the\n // control), shared by the content groups and the EC-285 Details pane so a\n // sidebar field renders identically — same control, validation, localization,\n // and EC-283 highlight/jump target — wherever it surfaces. Returns null when the\n // field is conditionally hidden (EC-273).\n function renderFieldRow(field: FieldDef) {\n if (isHidden(field)) return null\n // Field-level read-only (the Lock badge) vs the view-level read-only\n // (Published perspective) — the control honors both.\n const fieldLevelReadOnly = cms.isFieldReadOnly(field)\n const fieldReadOnly = viewReadOnly || fieldLevelReadOnly\n const localized = isFieldLocalized(collection, field.name)\n // Fallback visibility (EC-176): the control DISPLAYS the fallback value, and\n // this marker says so on the exact field.\n const fallback = localized\n ? displayedFieldFallback(collection, viewDoc, field.name, locale, cms.localeConfig)\n : null\n // The variant was created in this editing session (the saved document doesn't\n // have it yet): editing a fallback-shown value is an explicit translation act.\n // Moot (and hidden) while viewing the read-only published snapshot.\n const newlyTranslated =\n !viewReadOnly &&\n localized &&\n hasLocaleVariant(draft, field.name, locale) &&\n !hasLocaleVariant(doc, field.name, locale)\n return (\n <Field\n key={field.name}\n className={cn(\n 'rounded-md transition-shadow',\n highlightedField === field.name && 'bg-primary/5 p-2 ring-2 ring-primary/70',\n )}\n label={\n <Row gap=\"2\">\n <span>{fieldLabel(field)}</span>\n {field.validation?.required ? <span className=\"text-destructive\">*</span> : null}\n {localized ? <Badge variant=\"outline\">{locale}</Badge> : null}\n {fallback ? (\n <Badge\n variant=\"warning\"\n title={fallbackTitle(fallback)}\n data-testid={`field-fallback-${field.name}`}\n >\n showing {localeChipLabel(fallback.sourceLocale)}\n </Badge>\n ) : null}\n {newlyTranslated ? (\n <Badge variant=\"success\" data-testid={`field-translated-${field.name}`}>\n <Languages className=\"size-3\" /> translated to {localeChipLabel(locale)}\n </Badge>\n ) : null}\n {fieldLevelReadOnly ? (\n <Badge variant=\"outline\">\n <Lock className=\"size-3\" /> read-only\n </Badge>\n ) : null}\n <Spacer />\n </Row>\n }\n htmlFor={`f-${field.name}`}\n hint={\n fallback ? (\n <>\n Showing the {localeChipLabel(fallback.sourceLocale)} (fallback) value — edit to\n translate to {localeChipLabel(locale)}. Clearing the {localeChipLabel(locale)} text\n falls back again.\n </>\n ) : (\n field.form?.description\n )\n }\n error={fieldReadOnly ? undefined : errorsByField.get(field.name)}\n >\n <FieldControl\n id={`f-${field.name}`}\n field={field}\n value={getValue(field)}\n onChange={(v) => setValue(field, v)}\n readOnly={fieldReadOnly}\n />\n </Field>\n )\n }\n\n function save() {\n cms.saveDocument(draft)\n }\n\n // EC-224: a version restore swaps the working draft for an older snapshot; the\n // open editor adopts it so the form/canvas re-render from the restored content\n // (the operation already persisted it, so it lands clean/non-dirty).\n function replaceDraft(next: CmsDocument) {\n setDraft(next)\n // The canvas editor is uncontrolled after mount (it builds its graph once and\n // lifts edits OUT). A restore replaces the draft from outside, so bump the\n // nonce to REMOUNT the canvas from the restored value — otherwise it keeps the\n // pre-restore tree and the next edit would clobber the restore.\n setRestoreNonce((n) => n + 1)\n }\n\n // The frame-owned `Versions` pane (EC-224) — appended after any view-supplied\n // pane (the canvas's `Properties`). One instance feeds both the form view's\n // sidebar and the canvas view's sidebar.\n const versionsPane = useMemo<InspectorPane>(\n () => ({\n id: 'versions',\n label: 'Versions',\n icon: <History className=\"size-3.5\" />,\n render: () => <VersionsPane />,\n }),\n [],\n )\n // The frame-owned `Issues` pane (EC-283) — the document-scoped validation\n // surface that replaces the always-on footer band. The tab carries a count\n // badge (error- vs warning-toned) so a non-zero count is discoverable from\n // any tab; document-level issues (e.g. EC-260 nesting-depth) live only here.\n const issuesPane = useMemo<InspectorPane>(\n () => ({\n id: 'issues',\n label: 'Issues',\n icon: <CircleAlert className=\"size-3.5\" />,\n badge:\n issues.length === 0 ? undefined : (\n <Badge\n variant={issues.some((i) => i.severity === 'error') ? 'error' : 'warning'}\n className=\"px-1.5 py-0 leading-none\"\n >\n {issues.length}\n </Badge>\n ),\n render: () => (\n <IssuesPane issues={issues} collection={collection} onJumpToField={focusField} />\n ),\n }),\n [issues, errorCount, collection, focusField],\n )\n // EC-284 + EC-285: the document-metadata pane — slot assignment (EC-284) and/or\n // the document-level `sidebar`-group fields (EC-285). Present only when the\n // collection has either, so it never adds an empty tab elsewhere. First in the\n // order, so a slotted / sidebar-bearing document opens straight to it. Not\n // memoized: its render closes over per-render edit state (draft, highlight,\n // field errors) via `renderFieldRow`, and the inspector re-renders with the rest\n // of the editor anyway, so a stable pane identity would buy nothing here.\n const detailsPane: InspectorPane | null =\n hasAliases(collection) || visibleSidebarFields.length > 0\n ? {\n id: 'details',\n label: 'Details',\n icon: <Tag className=\"size-3.5\" />,\n render: () => (\n <DetailsPane\n collection={collection}\n doc={draft}\n siblings={cms.documentsOf(collection.id)}\n readOnly={viewReadOnly}\n fields={visibleSidebarFields}\n renderField={renderFieldRow}\n onAliasChange={(alias) =>\n setDraft((d) => {\n const next = { ...d }\n if (alias === undefined) delete next.alias\n else next.alias = alias\n return next\n })\n }\n />\n ),\n }\n : null\n const trailingPanes = detailsPane\n ? [detailsPane, versionsPane, issuesPane]\n : [versionsPane, issuesPane]\n\n // EC-268: the Publish button is its own indicator — pending while the publish\n // round-trips, a brief success, and an error toast if it rejects at transport.\n const [publishState, setPublishState] = useState<'idle' | 'pending' | 'success'>('idle')\n // EC-300/AD-16: confirm-through guard when the page embeds unpublished reusables.\n const [publishConfirm, setPublishConfirm] = useState(false)\n\n // Gate publish on the confirm-through dialog when there are unpublished hard\n // references (they'd render empty on the live site); schema errors already\n // disable the button, so they never reach here.\n function handlePublish() {\n if (hasUnpublishedRefs) {\n setPublishConfirm(true)\n return\n }\n void doPublish()\n }\n\n async function doPublish() {\n // EC-273: clean conditionally-hidden values from the draft AT PUBLISH TIME.\n // While editing, the draft keeps them so an accidental hide (e.g. flipping a\n // link's type) is recoverable; publishing is the intentional moment we commit\n // the cleanup — into the draft AND the snapshot, so both go clean together (the\n // reference index updates off the saved draft, so a now-unlinked page becomes\n // deletable once the change is published). Also captures the latest edit in case\n // Publish is clicked inside the autosave debounce window; the serial persister\n // runs the upsert before the publish so the snapshot is exactly this draft (EC-225).\n const cleaned = clearHiddenValues(collection, draft)\n if (cleaned !== draft) setDraft(cleaned)\n if (cleaned !== draft || dirty) cms.saveDocument(cleaned)\n // Publish snapshots the draft as a version and pins it (EC-224). The live\n // row stays a continuous draft — published-ness is the version pointer\n // (`cms.isPublished`). Pre-gated by `disabled={hasErrors}`; the optimistic\n // flip reconciles against the backend (EC-225), so a logical rejection the\n // gate doesn't cover (schema divergence) self-corrects the badge. A hard\n // failure (transport) rejects the flush — surface it loudly (EC-268).\n setPublishState('pending')\n try {\n await cms.publishDocument(ref)\n setPublishState('success')\n setTimeout(() => setPublishState('idle'), 1800)\n } catch (error) {\n setPublishState('idle')\n toast.error(error instanceof Error ? `Publish failed: ${error.message}` : 'Publish failed.')\n }\n }\n\n function handleConfirmedAction() {\n if (confirmAction === 'unpublish') {\n setConfirmAction(null)\n void cms.unpublishDocument(ref)\n return\n }\n if (confirmAction === 'delete') {\n setConfirmAction(null)\n cms.deleteDocument(ref)\n void navigate({\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.cmsCollection(collection.id) },\n })\n }\n }\n\n // While the published snapshot is pending, don't derive the title from the\n // draft (it must not read as the published title) — fall back to the id.\n const title = publishedPending ? '' : primaryTitle(viewDoc, collection, locale, cms.localeConfig)\n const titleFallback = publishedPending\n ? null\n : displayedFieldFallback(\n collection,\n viewDoc,\n collection.titleField ?? 'title',\n locale,\n cms.localeConfig,\n )\n\n // EC-214: the document is the active record — contribute the collection (a\n // link back to its list) and the document title to the global header\n // breadcrumb, replacing the editor's own back-link + collection/id line. A\n // singleton has no list, so it contributes a single, non-linked crumb. The\n // title tracks the live draft so a rename updates the crumb immediately.\n const breadcrumbItems = useMemo<BreadcrumbItem[]>(() => {\n const collectionLabel = collection.form?.label ?? collection.id\n if (singleton) return [{ label: collectionLabel }]\n const docTitle = primaryTitle(draft, collection, locale, cms.localeConfig) || doc.id\n return [\n {\n label: collectionLabel,\n to: STUDIO_PROJECT_ROUTE,\n params: { projectId, _splat: studioPath.cmsCollection(collection.id) },\n },\n { label: docTitle },\n ]\n }, [singleton, collection, draft, locale, cms.localeConfig, doc.id, projectId])\n useSetBreadcrumb(breadcrumbItems)\n\n // EC-205/EC-216: the LIVE URL derives strictly from PUBLISHED data — the\n // document's pinned published snapshot and its published ancestors — never the\n // draft (an unpublished slug/parent edit must not leak into the live URL). The\n // pool is exactly what the live site serves, so a published doc resolves to the\n // URL visitors actually get; `undefined` until the doc is published (and the\n // pool has loaded). The collection being routable gates the disabled hint below.\n const publishedDocs = usePublishedDocuments(cms.projectId, collection.id)\n const routableCollection = useMemo(\n () => resolveDeploymentRoutes().some((route) => route.document?.collection === collection.id),\n [collection.id],\n )\n const liveUrl = useMemo(() => {\n const published = publishedDocs.byId.get(doc.id)\n if (!published) return undefined\n return urlForDocument(\n {\n routes: resolveDeploymentRoutes(),\n frontendUrl: resolveDeploymentFrontendUrl(),\n localeConfig: cms.localeConfig,\n },\n collection,\n published,\n { siblings: [...publishedDocs.byId.values()], locale },\n )\n }, [publishedDocs, collection, doc.id, locale, cms.localeConfig])\n\n return (\n <DocumentEditorProvider\n value={{\n projectId,\n collection,\n docRef: ref,\n draft,\n dirty,\n hasErrors,\n viewReadOnly,\n save,\n replaceDraft,\n }}\n >\n <div className={cn('flex h-full min-h-0 flex-col', viewReadOnly && 'bg-info/[0.04]')}>\n {/* Header — the back-link + collection/id line moved into the global\n breadcrumb (EC-214); this keeps only the record title + actions. */}\n <div className=\"shrink-0 border-b border-border px-4 py-3 sm:px-6\">\n <Row gap=\"3\">\n <Row gap=\"2\" align=\"center\" className=\"min-w-0\">\n <Heading level={1} size=\"h2\" className=\"truncate\">\n {singleton ? collection.form?.label ?? collection.id : title || doc.id}\n </Heading>\n {singleton ? null : <FallbackChip fallback={titleFallback} testId=\"doc-title-fallback\" />}\n </Row>\n <Spacer />\n {/* Autosave status (EC-225) — replaces the manual Save button. */}\n <Text size=\"xs\" tone=\"muted\" className=\"whitespace-nowrap\" data-testid=\"autosave-status\">\n {cms.persistError ? 'Save failed' : dirty ? 'Saving…' : 'Saved'}\n </Text>\n <DocStateBadge published={cms.isPublished(ref)} />\n {/* EC-216: open the document's live URL. Enabled once published with a\n configured frontendUrl; otherwise a disabled hint explains why. */}\n {/* EC-216 + EC-205: open the document's LIVE (published) URL. Enabled\n only once the published snapshot exists and a frontendUrl is set;\n otherwise a disabled hint explains why. Hidden for non-routable\n collections (e.g. singletons). */}\n {routableCollection ? (\n liveUrl?.href ? (\n <Button asChild variant=\"outline\" size=\"sm\" title={`Open ${liveUrl.path}`}>\n <a href={liveUrl.href} target=\"_blank\" rel=\"noreferrer\" data-testid=\"view-live\">\n <ExternalLink /> View live\n </a>\n </Button>\n ) : (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled\n data-testid=\"view-live-disabled\"\n title={\n publishedDocs.status === 'loading'\n ? 'Loading the live URL…'\n : !cms.isPublished(ref)\n ? 'Publish to view the live page'\n : 'Set frontendUrl in elytra.config.ts to enable'\n }\n >\n <ExternalLink /> View live\n </Button>\n )\n ) : null}\n <Button\n size=\"sm\"\n onClick={handlePublish}\n disabled={hasErrors || viewReadOnly || publishState === 'pending'}\n title={\n viewReadOnly\n ? 'Switch to Draft to publish'\n : hasErrors\n ? `Fix ${errorCount} ${errorCount === 1 ? 'issue' : 'issues'} to publish`\n : undefined\n }\n >\n {publishState === 'pending' ? (\n <>\n <Loader2 className=\"animate-spin\" /> Publishing…\n </>\n ) : publishState === 'success' ? (\n <>\n <CircleCheck /> Published\n </>\n ) : (\n <>\n <Eye /> Publish\n </>\n )}\n </Button>\n {/* EC-217: a singleton is never deleted; with nothing else to show\n (an unpublished singleton) the actions menu is omitted entirely. */}\n {cms.isPublished(ref) || !singleton ? (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" size=\"icon-sm\" aria-label=\"More actions\">\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {cms.isPublished(ref) ? (\n <DropdownMenuItem onClick={() => setConfirmAction('unpublish')}>\n <EyeOff /> Unpublish\n </DropdownMenuItem>\n ) : null}\n {singleton ? null : (\n <DropdownMenuItem\n data-testid=\"doc-delete\"\n className=\"text-destructive\"\n onClick={() => setConfirmAction('delete')}\n >\n <Trash2 /> Delete\n </DropdownMenuItem>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n ) : null}\n </Row>\n\n {/* Ambient locale switcher (EC-176, supersedes the per-document EC-076 one) + tabs (EC-073)\n + the Draft/Published view perspective (EC-226). */}\n <Row gap=\"3\" className=\"mt-3\" wrap>\n <LocaleSwitcher />\n <Row gap=\"1\">\n {editorTabs.map((tab) => (\n <button\n key={tab}\n type=\"button\"\n aria-pressed={tab === activeTab}\n onClick={() => setActiveTab(tab)}\n className={cn(\n 'rounded-md px-2.5 py-1 text-xs font-medium capitalize transition-colors',\n tab === activeTab ? 'bg-accent text-accent-foreground' : 'text-muted-foreground hover:bg-muted',\n )}\n >\n {tab}\n </button>\n ))}\n </Row>\n <Spacer />\n <Row gap=\"px\" className=\"rounded-md bg-muted/60 p-0.5\">\n <PerspectiveButton\n label=\"Draft\"\n active={perspective === 'draft'}\n onClick={() => setPerspective('draft')}\n />\n <PerspectiveButton\n label=\"Published\"\n active={perspective === 'published'}\n accent=\"info\"\n disabled={!published}\n title={published ? undefined : 'Publish this document to view its published version'}\n onClick={() => setPerspective('published')}\n />\n </Row>\n </Row>\n </div>\n\n {/* EC-214: an unmistakable banner whenever the read-only Published snapshot\n is in view — disabled controls + a footer notice alone read as too\n subtle. Paired with the tinted surface and the accented toggle. */}\n {viewReadOnly ? (\n <Row\n gap=\"2\"\n className=\"shrink-0 border-b border-info/30 bg-info/10 px-4 py-1.5 text-info sm:px-6\"\n data-testid=\"published-view-banner\"\n >\n <Lock className=\"size-3.5 shrink-0\" aria-hidden />\n <Text size=\"xs\" className=\"text-info\">\n Viewing the published version — read-only.\n </Text>\n <Spacer />\n <button\n type=\"button\"\n onClick={() => setPerspective('draft')}\n className=\"text-xs font-medium underline-offset-2 hover:underline\"\n >\n Switch to Draft\n </button>\n </Row>\n ) : null}\n\n {/* Body — a blocks field takes over the body with the page-builder canvas\n (which carries its own inspector sidebar, EC-188/EC-224); otherwise the\n field form sits beside the shared inspector sidebar (Versions). In\n Published view the snapshot must load before rendering — the draft is\n never shown as published (EC-226). */}\n {publishedPending ? (\n <div className=\"grid min-h-0 flex-1 place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n {publishedSnapshot.status === 'loading'\n ? 'Loading the published version…'\n : 'No published version found for this document.'}\n </Text>\n </div>\n ) : canvasField ? (\n <div className=\"min-h-0 flex-1 overflow-hidden\">\n <CompositionFieldEditor\n key={`${canvasField.name}:${restoreNonce}:${perspective}`}\n field={canvasField}\n value={getValue(canvasField)}\n onChange={(v) => setValue(canvasField, v)}\n readOnly={viewReadOnly || cms.isFieldReadOnly(canvasField)}\n trailingPanes={trailingPanes}\n />\n </div>\n ) : activeTab === REFERENCES_TAB ? (\n // EC-269: mounted only while this tab is active → reference data loads on\n // demand and is torn down on leave (no fetching during normal editing).\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-h-0 flex-1 overflow-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-2xl\">\n <ReferencesPanel\n projectId={projectId}\n source={{ type: 'document', id: documentKey(ref) }}\n target={{ type: 'document', id: documentKey(ref) }}\n />\n </div>\n </div>\n </div>\n ) : (\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-h-0 flex-1 overflow-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-2xl\">\n <Stack gap=\"6\">\n {groups.map((group) => {\n // EC-273: drop a fieldset whose every field is conditionally hidden,\n // so the form never shows an empty panel header.\n const visible = group.fields.filter((f) => !isHidden(f))\n if (visible.length === 0) return null\n return (\n <Panel key={group.name}>\n <PanelHeader>\n <Text size=\"sm\" weight=\"semibold\" className=\"capitalize\">\n {group.name}\n </Text>\n </PanelHeader>\n <Stack gap=\"4\" className=\"p-4\">\n {visible.map(renderFieldRow)}\n </Stack>\n </Panel>\n )\n })}\n </Stack>\n </div>\n </div>\n <InspectorSidebar\n panes={trailingPanes}\n activeId={inspectorPaneId}\n onActiveChange={setInspectorPaneId}\n className=\"w-[320px] shrink-0 border-l border-border\"\n />\n </div>\n )}\n\n {/* EC-283: the always-on validation footer is retired. Validation now lives\n in the document-scoped `Issues` inspector pane (full list + jump-to-field,\n count badge on its tab), field issues stay inline, and the Publish button\n gates on errors. Read-only is announced by the top banner (EC-214). */}\n\n {/* Reference-aware unpublish/delete confirmation (EC-173). */}\n {confirmAction !== null ? (\n <ReferenceConfirmDialog\n projectId={projectId}\n action={confirmAction}\n targets={confirmTargets}\n open\n onOpenChange={(open) => {\n if (!open) setConfirmAction(null)\n }}\n onConfirm={handleConfirmedAction}\n />\n ) : null}\n\n {/* EC-300/AD-16: confirm-through guard for unpublished hard references. The\n schema is valid (those errors block the button); these would just render\n empty on the live site, so the editor confirms rather than being blocked. */}\n <Dialog open={publishConfirm} onOpenChange={(open) => { if (!open) setPublishConfirm(false) }}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Publish with unpublished references?</DialogTitle>\n <DialogDescription>\n This page embeds reusable elements that aren’t published yet. They will be empty on the\n live site until you publish them too.\n </DialogDescription>\n </DialogHeader>\n <Stack gap=\"1\">\n {referenceIssues.map((issue, i) => (\n <Text key={`${issue.meta?.id ?? i}`} size=\"xs\" tone=\"muted\">\n • {issue.message}\n </Text>\n ))}\n </Stack>\n <DialogFooter className=\"mt-4\">\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setPublishConfirm(false)}>\n Cancel\n </Button>\n <Button\n size=\"sm\"\n data-testid=\"publish-anyway\"\n onClick={() => {\n setPublishConfirm(false)\n void doPublish()\n }}\n >\n Publish anyway\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n </DocumentEditorProvider>\n )\n}\n\n/**\n * EC-300/AD-16 — errors for composition embeds (hard references) whose target isn't\n * published: they render empty on the live site. Walks every `blocks` field of the\n * document for reuse embeds; a missing target is an `unknown-relation-target` error,\n * an unpublished one an `unpublished-relation-target` error. Publishing is\n * confirm-through (not blocked), so these feed the Issues panel + the publish\n * confirmation, never the button's disabled gate. No reuse capability → none.\n */\nfunction unpublishedEmbedIssues(\n collection: CollectionDef,\n draft: CmsDocument,\n cms: CmsStore,\n): CmsValidationIssue[] {\n const capability = resolveReuseCapability(getStudioRegistry().registry.list(), cms.collections)\n if (!capability) return []\n const issues: CmsValidationIssue[] = []\n const seen = new Set<string>()\n for (const field of collection.fields) {\n if (!isBlocksField(field)) continue\n for (const ref of collectEmbedRefs(blockRootsOf(draft.values?.[field.name]), capability)) {\n const key = `${ref.collection}:${ref.id}`\n if (seen.has(key)) continue\n seen.add(key)\n const exists = cms.getDocument(ref) !== undefined\n if (exists && cms.isPublished(ref)) continue\n issues.push(unpublishedEmbedIssue(collection, draft, field.name, ref, exists, cms))\n }\n }\n return issues\n}\n\n/** One unpublished/missing reuse-embed issue (EC-300). */\nfunction unpublishedEmbedIssue(\n collection: CollectionDef,\n draft: CmsDocument,\n field: string,\n ref: DocumentRef,\n exists: boolean,\n cms: CmsStore,\n): CmsValidationIssue {\n return {\n code: exists ? 'unpublished-relation-target' : 'unknown-relation-target',\n severity: 'error',\n message: exists\n ? `Embeds the reusable “${cms.titleOf(ref)}”, which isn’t published — it will be empty on the live site until you publish it.`\n : `Embeds a reusable that no longer exists (“${ref.id}”) — fix or remove the embed.`,\n path: [field],\n collectionId: collection.id,\n documentId: draft.id,\n meta: { field, target: ref.collection, id: ref.id },\n }\n}\n\n/**\n * A segmented-control button for the Draft/Published view toggle (EC-226). The\n * `accent` variant (EC-214) gives the active Published segment a distinct info\n * treatment, so the read-only mode is obvious at the control itself.\n */\nfunction PerspectiveButton({\n label,\n active,\n accent,\n disabled,\n title,\n onClick,\n}: {\n label: string\n active: boolean\n accent?: 'info'\n disabled?: boolean\n title?: string\n onClick: () => void\n}) {\n return (\n <button\n type=\"button\"\n aria-pressed={active}\n disabled={disabled}\n title={title}\n onClick={onClick}\n className={cn(\n 'rounded px-2.5 py-1 text-xs font-medium transition-colors disabled:opacity-40',\n active\n ? accent === 'info'\n ? 'bg-info text-info-foreground shadow-sm'\n : 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground',\n )}\n >\n {label}\n </button>\n )\n}\n\ninterface FieldGroup {\n name: string\n fields: FieldDef[]\n}\n\nfunction groupFields(fields: FieldDef[], collection: CollectionDef): FieldGroup[] {\n const order = collection.form?.groups ?? []\n const byGroup = new Map<string, FieldDef[]>()\n for (const field of fields) {\n const group = field.form?.group ?? 'fields'\n if (!byGroup.has(group)) byGroup.set(group, [])\n byGroup.get(group)!.push(field)\n }\n const names = [...byGroup.keys()].sort((a, b) => {\n const ia = order.indexOf(a)\n const ib = order.indexOf(b)\n return (ia < 0 ? 99 : ia) - (ib < 0 ? 99 : ib)\n })\n return names.map((name) => ({\n name,\n fields: byGroup.get(name)!.sort((a, b) => (a.form?.order ?? 99) - (b.form?.order ?? 99)),\n }))\n}\n\nfunction primaryTitle(\n doc: CmsDocument,\n collection: CollectionDef,\n locale: Locale,\n config: LocaleConfig,\n): string {\n const { value } = resolveField(collection, doc, collection.titleField ?? 'title', locale, config)\n return typeof value === 'string' ? value : ''\n}\n"]}
|
|
@@ -58,6 +58,15 @@ export interface ContentSessionState {
|
|
|
58
58
|
* collections + documents arrive via {@link configureContentSession} (Convex mode).
|
|
59
59
|
*/
|
|
60
60
|
export declare const playgroundCollections: readonly CollectionDef[];
|
|
61
|
+
/**
|
|
62
|
+
* The perspective a canvas preview resolves references against (EC-300/AD-16). The
|
|
63
|
+
* canvas is draft-coherent: the editable Draft view resolves references to their
|
|
64
|
+
* `'draft'` targets (so a just-made reusable shows immediately), the read-only
|
|
65
|
+
* Published view resolves `'published'` (an honest preview of what delivery serves;
|
|
66
|
+
* an unpublished hard ref shows the in-canvas placeholder). Delivery stays
|
|
67
|
+
* published-only — this does not weaken `live-is-published-only`.
|
|
68
|
+
*/
|
|
69
|
+
export type CanvasPerspective = 'draft' | 'published';
|
|
61
70
|
/**
|
|
62
71
|
* Point the preview engine at a project's hydrated content (Convex mode), or
|
|
63
72
|
* back at the deterministic playground fixtures (`null` — the default, and
|
|
@@ -93,7 +102,7 @@ export declare function getCollectionDocument(collectionId: string, idOrSlug: st
|
|
|
93
102
|
* Reusable's element) exactly as delivery renders them. `null` when the target is
|
|
94
103
|
* missing or not visible → the block degrades to its own empty state.
|
|
95
104
|
*/
|
|
96
|
-
export declare function resolveCanvasRelation(ref: DocumentRef, locale?: Locale): ResolvedDocument | null;
|
|
105
|
+
export declare function resolveCanvasRelation(ref: DocumentRef, locale?: Locale, perspective?: CanvasPerspective): ResolvedDocument | null;
|
|
97
106
|
/**
|
|
98
107
|
* Resolve a listing block's query to its documents for the canvas (EC-255) — the
|
|
99
108
|
* studio analog of the host's baked listings map. Runs the query (collection +
|
|
@@ -103,7 +112,7 @@ export declare function resolveCanvasRelation(ref: DocumentRef, locale?: Locale)
|
|
|
103
112
|
* (structured, never thrown) or a non-list lookup yields `[]` → the block's empty
|
|
104
113
|
* state. Reuses the same `listDocuments` path as `runCollectionListQuery`.
|
|
105
114
|
*/
|
|
106
|
-
export declare function resolveCanvasListing(query: ListingQuery, locale?: Locale): ResolvedDocument[];
|
|
115
|
+
export declare function resolveCanvasListing(query: ListingQuery, locale?: Locale, perspective?: CanvasPerspective): ResolvedDocument[];
|
|
107
116
|
/**
|
|
108
117
|
* Resolve a rich-text internal link's target document to its URL path for the canvas
|
|
109
118
|
* (EC-291) — the studio analog of the host's baked links map. Derives the URL through
|
|
@@ -113,7 +122,7 @@ export declare function resolveCanvasListing(query: ListingQuery, locale?: Local
|
|
|
113
122
|
* no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses
|
|
114
123
|
* the same `resolveLink` path as the host bake, so both agree on the derived URL.
|
|
115
124
|
*/
|
|
116
|
-
export declare function resolveCanvasLink(ref: DocumentRef, locale?: Locale): string | null;
|
|
125
|
+
export declare function resolveCanvasLink(ref: DocumentRef, locale?: Locale, perspective?: CanvasPerspective): string | null;
|
|
117
126
|
/** A pickable entry of a collection (the template-page preview switcher). */
|
|
118
127
|
export interface CollectionEntrySummary {
|
|
119
128
|
id: string;
|
|
@@ -10,6 +10,7 @@ import { getStudioLocale } from '../locale/locale-store';
|
|
|
10
10
|
export const playgroundCollections = [];
|
|
11
11
|
let contentSession = null;
|
|
12
12
|
let lookup = createLookup(playgroundCollections, [], []);
|
|
13
|
+
// Keyed by `${locale}:${perspective}` (EC-300) — one deterministic client per pair.
|
|
13
14
|
const clients = new Map();
|
|
14
15
|
/**
|
|
15
16
|
* Point the preview engine at a project's hydrated content (Convex mode), or
|
|
@@ -121,28 +122,30 @@ function createLookup(collectionDefs, documents, publishedKeys, assetRecords) {
|
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
/**
|
|
124
|
-
* One deterministic client per locale
|
|
125
|
-
*
|
|
126
|
-
* the
|
|
127
|
-
*
|
|
125
|
+
* One deterministic client per (locale, perspective): EC-018 locale fallback,
|
|
126
|
+
* draft-or-published perspective (EC-300/AD-16, default `'published'`). The studio's
|
|
127
|
+
* ambient active locale (EC-176, `lib/locale`) picks the locale at query time, so the
|
|
128
|
+
* canvas previews follow the locale switcher exactly like delivery would; the canvas's
|
|
129
|
+
* Draft/Published view picks the perspective. The cache resets whenever the content
|
|
130
|
+
* session changes.
|
|
128
131
|
*/
|
|
129
|
-
function clientFor(locale) {
|
|
130
|
-
const
|
|
132
|
+
function clientFor(locale, perspective = 'published') {
|
|
133
|
+
const key = `${locale}:${perspective}`;
|
|
134
|
+
const existing = clients.get(key);
|
|
131
135
|
if (existing)
|
|
132
136
|
return existing;
|
|
133
137
|
const client = createContentClient({
|
|
134
138
|
lookup,
|
|
135
139
|
context: createContentContext({
|
|
136
140
|
locale,
|
|
137
|
-
perspective
|
|
141
|
+
perspective,
|
|
138
142
|
locales: activeLocaleConfig(),
|
|
139
143
|
}),
|
|
140
|
-
// EC-291: the routes a rich-text link resolves against (config-sourced)
|
|
141
|
-
//
|
|
142
|
-
// the host's baked link map.
|
|
144
|
+
// EC-291: the routes a rich-text link resolves against (config-sourced) — the
|
|
145
|
+
// studio-live half of the host link bake.
|
|
143
146
|
routes: contentSession?.routes ?? [],
|
|
144
147
|
});
|
|
145
|
-
clients.set(
|
|
148
|
+
clients.set(key, client);
|
|
146
149
|
return client;
|
|
147
150
|
}
|
|
148
151
|
/**
|
|
@@ -166,8 +169,8 @@ export function getCollectionDocument(collectionId, idOrSlug, locale = getStudio
|
|
|
166
169
|
* Reusable's element) exactly as delivery renders them. `null` when the target is
|
|
167
170
|
* missing or not visible → the block degrades to its own empty state.
|
|
168
171
|
*/
|
|
169
|
-
export function resolveCanvasRelation(ref, locale = getStudioLocale()) {
|
|
170
|
-
return clientFor(locale).resolveRelation(ref);
|
|
172
|
+
export function resolveCanvasRelation(ref, locale = getStudioLocale(), perspective = 'published') {
|
|
173
|
+
return clientFor(locale, perspective).resolveRelation(ref);
|
|
171
174
|
}
|
|
172
175
|
/**
|
|
173
176
|
* Resolve a listing block's query to its documents for the canvas (EC-255) — the
|
|
@@ -178,8 +181,8 @@ export function resolveCanvasRelation(ref, locale = getStudioLocale()) {
|
|
|
178
181
|
* (structured, never thrown) or a non-list lookup yields `[]` → the block's empty
|
|
179
182
|
* state. Reuses the same `listDocuments` path as `runCollectionListQuery`.
|
|
180
183
|
*/
|
|
181
|
-
export function resolveCanvasListing(query, locale = getStudioLocale()) {
|
|
182
|
-
const result = clientFor(locale).listDocuments(query.collection, {
|
|
184
|
+
export function resolveCanvasListing(query, locale = getStudioLocale(), perspective = 'published') {
|
|
185
|
+
const result = clientFor(locale, perspective).listDocuments(query.collection, {
|
|
183
186
|
where: query.where,
|
|
184
187
|
...(query.sort ? { sort: query.sort } : {}),
|
|
185
188
|
...(query.limit !== undefined ? { limit: query.limit } : {}),
|
|
@@ -195,8 +198,8 @@ export function resolveCanvasListing(query, locale = getStudioLocale()) {
|
|
|
195
198
|
* no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses
|
|
196
199
|
* the same `resolveLink` path as the host bake, so both agree on the derived URL.
|
|
197
200
|
*/
|
|
198
|
-
export function resolveCanvasLink(ref, locale = getStudioLocale()) {
|
|
199
|
-
return clientFor(locale).resolveLink(ref);
|
|
201
|
+
export function resolveCanvasLink(ref, locale = getStudioLocale(), perspective = 'published') {
|
|
202
|
+
return clientFor(locale, perspective).resolveLink(ref);
|
|
200
203
|
}
|
|
201
204
|
/** Published entries of a collection, labeled by the schema's title field. */
|
|
202
205
|
export function listCollectionEntries(collectionId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBAAyB,CAAA;AAUhC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAW1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAqDxD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA6B,EAAE,CAAA;AAEjE,IAAI,cAAc,GAA+B,IAAI,CAAA;AACrD,IAAI,MAAM,GAAkB,YAAY,CAAC,qBAAqB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACvE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEhD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAgC;IACtE,cAAc,GAAG,IAAI,CAAA;IACrB,MAAM,GAAG,IAAI;QACX,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC;QACjF,CAAC,CAAC,YAAY,CAAC,qBAAqB,EAAE,EAAE,EA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iBAAiB,CAC/B,GAAgB,EAChB,SAAiB,eAAe,EAAE;IAElC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;AAC3C,CAAC;AAQD,8EAA8E;AAC9E,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,MAAM,UAAU,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;IACnD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,CAAA;IACzB,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAC7E,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n createContentClient,\n createContentContext,\n} from '@elytracms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport { documentKey, sampleLocaleConfig } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport { getStudioLocale } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Playground mode (and tests): the deterministic EC-145 sample fixtures —\n * byte-identical to the pre-hydration behavior, no backend.\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n *\n * Nothing here invents query semantics; both shapes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /** Locale config of the session content; defaults to the sample config. */\n localeConfig?: LocaleConfig\n /**\n * The project's config-sourced routes (EC-207). Wired into the content client so\n * the canvas preview's `resolveLink` (EC-291) derives a rich-text link's URL from\n * the SAME routes delivery serves — the studio-live half of the host link bake.\n * Absent (playground/tests) → no routes, so `resolveLink` returns null and a\n * reference link degrades to the visible `unresolved-ref` issue.\n */\n routes?: readonly RouteRecord[]\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} (Convex mode).\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\nconst clients = new Map<Locale, ContentClient>()\n\n/**\n * Point the preview engine at a project's hydrated content (Convex mode), or\n * back at the deterministic playground fixtures (`null` — the default, and\n * the only state playground mode ever sees).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\nfunction activeLocaleConfig(): LocaleConfig {\n return contentSession?.localeConfig ?? sampleLocaleConfig\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/** Synthesize the persistence-shaped asset record the asset resolver reads. */\nfunction assetRecordOf(doc: CmsDocument): AssetRecord {\n const values = doc.values\n const alt = doc.localized?.en?.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') assets.set(doc.id, assetRecordOf(doc))\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per locale: published perspective, EC-018 locale\n * fallback. The studio's ambient active locale (EC-176, `lib/locale`) picks\n * the client at query time, so the canvas previews follow the locale switcher\n * exactly like delivery would. The cache resets whenever the content session changes.\n */\nfunction clientFor(locale: Locale): ContentClient {\n const existing = clients.get(locale)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective: 'published',\n locales: activeLocaleConfig(),\n }),\n // EC-291: the routes a rich-text link resolves against (config-sourced). The\n // canvas previews PUBLISHED content, so a link derives the live URL — matching\n // the host's baked link map.\n routes: contentSession?.routes ?? [],\n })\n clients.set(locale, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = getStudioLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = getStudioLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument | null {\n return clientFor(locale).resolveRelation(ref)\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only filter, optional sort/limit) through the active session's client\n * (published perspective, active locale), so the canvas previews a dynamic grid (a\n * ProductGrid keyed to a category) exactly as delivery renders it. An invalid query\n * (structured, never thrown) or a non-list lookup yields `[]` → the block's empty\n * state. Reuses the same `listDocuments` path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument[] {\n const result = clientFor(locale).listDocuments(query.collection, {\n where: query.where,\n ...(query.sort ? { sort: query.sort } : {}),\n ...(query.limit !== undefined ? { limit: query.limit } : {}),\n })\n return result.ok ? result.documents : []\n}\n\n/**\n * Resolve a rich-text internal link's target document to its URL path for the canvas\n * (EC-291) — the studio analog of the host's baked links map. Derives the URL through\n * the active session's client (published perspective, active locale, config-sourced\n * routes), so the canvas previews a `{type:'reference'}` link's `href` exactly as\n * delivery serves it. `null` when the target is unpublished, missing, or addressed by\n * no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses\n * the same `resolveLink` path as the host bake, so both agree on the derived URL.\n */\nexport function resolveCanvasLink(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n): string | null {\n return clientFor(locale).resolveLink(ref)\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n return result.documents.map((doc) => {\n const title = collection?.titleField ? doc[collection.titleField] : undefined\n return { id: doc.id, label: typeof title === 'string' && title.length > 0 ? title : doc.id }\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBAAyB,CAAA;AAUhC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAW1E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAqDxD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA6B,EAAE,CAAA;AAYjE,IAAI,cAAc,GAA+B,IAAI,CAAA;AACrD,IAAI,MAAM,GAAkB,YAAY,CAAC,qBAAqB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACvE,oFAAoF;AACpF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;AAEhD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAgC;IACtE,cAAc,GAAG,IAAI,CAAA;IACrB,MAAM,GAAG,IAAI;QACX,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC;QACjF,CAAC,CAAC,YAAY,CAAC,qBAAqB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAC/C,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,KAAK,IAAI,CAAA;AAChC,CAAC;AAED,iFAAiF;AACjF,SAAS,iBAAiB;IACxB,OAAO,cAAc,EAAE,WAAW,IAAI,qBAAqB,CAAA;AAC7D,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,cAAc,EAAE,YAAY,IAAI,kBAAkB,CAAA;AAC3D,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,o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C,YAAY,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAA;IACnD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,EAAE,CAAA;IACzB,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAC7E,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n createContentClient,\n createContentContext,\n} from '@elytracms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport { documentKey, sampleLocaleConfig } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport { getStudioLocale } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Playground mode (and tests): the deterministic EC-145 sample fixtures —\n * byte-identical to the pre-hydration behavior, no backend.\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n *\n * Nothing here invents query semantics; both shapes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /** Locale config of the session content; defaults to the sample config. */\n localeConfig?: LocaleConfig\n /**\n * The project's config-sourced routes (EC-207). Wired into the content client so\n * the canvas preview's `resolveLink` (EC-291) derives a rich-text link's URL from\n * the SAME routes delivery serves — the studio-live half of the host link bake.\n * Absent (playground/tests) → no routes, so `resolveLink` returns null and a\n * reference link degrades to the visible `unresolved-ref` issue.\n */\n routes?: readonly RouteRecord[]\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} (Convex mode).\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\n/**\n * The perspective a canvas preview resolves references against (EC-300/AD-16). The\n * canvas is draft-coherent: the editable Draft view resolves references to their\n * `'draft'` targets (so a just-made reusable shows immediately), the read-only\n * Published view resolves `'published'` (an honest preview of what delivery serves;\n * an unpublished hard ref shows the in-canvas placeholder). Delivery stays\n * published-only — this does not weaken `live-is-published-only`.\n */\nexport type CanvasPerspective = 'draft' | 'published'\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\n// Keyed by `${locale}:${perspective}` (EC-300) — one deterministic client per pair.\nconst clients = new Map<string, ContentClient>()\n\n/**\n * Point the preview engine at a project's hydrated content (Convex mode), or\n * back at the deterministic playground fixtures (`null` — the default, and\n * the only state playground mode ever sees).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\nfunction activeLocaleConfig(): LocaleConfig {\n return contentSession?.localeConfig ?? sampleLocaleConfig\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/** Synthesize the persistence-shaped asset record the asset resolver reads. */\nfunction assetRecordOf(doc: CmsDocument): AssetRecord {\n const values = doc.values\n const alt = doc.localized?.en?.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') assets.set(doc.id, assetRecordOf(doc))\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per (locale, perspective): EC-018 locale fallback,\n * draft-or-published perspective (EC-300/AD-16, default `'published'`). The studio's\n * ambient active locale (EC-176, `lib/locale`) picks the locale at query time, so the\n * canvas previews follow the locale switcher exactly like delivery would; the canvas's\n * Draft/Published view picks the perspective. The cache resets whenever the content\n * session changes.\n */\nfunction clientFor(locale: Locale, perspective: CanvasPerspective = 'published'): ContentClient {\n const key = `${locale}:${perspective}`\n const existing = clients.get(key)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective,\n locales: activeLocaleConfig(),\n }),\n // EC-291: the routes a rich-text link resolves against (config-sourced) — the\n // studio-live half of the host link bake.\n routes: contentSession?.routes ?? [],\n })\n clients.set(key, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = getStudioLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = getStudioLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n perspective: CanvasPerspective = 'published',\n): ResolvedDocument | null {\n return clientFor(locale, perspective).resolveRelation(ref)\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only filter, optional sort/limit) through the active session's client\n * (published perspective, active locale), so the canvas previews a dynamic grid (a\n * ProductGrid keyed to a category) exactly as delivery renders it. An invalid query\n * (structured, never thrown) or a non-list lookup yields `[]` → the block's empty\n * state. Reuses the same `listDocuments` path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = getStudioLocale(),\n perspective: CanvasPerspective = 'published',\n): ResolvedDocument[] {\n const result = clientFor(locale, perspective).listDocuments(query.collection, {\n where: query.where,\n ...(query.sort ? { sort: query.sort } : {}),\n ...(query.limit !== undefined ? { limit: query.limit } : {}),\n })\n return result.ok ? result.documents : []\n}\n\n/**\n * Resolve a rich-text internal link's target document to its URL path for the canvas\n * (EC-291) — the studio analog of the host's baked links map. Derives the URL through\n * the active session's client (published perspective, active locale, config-sourced\n * routes), so the canvas previews a `{type:'reference'}` link's `href` exactly as\n * delivery serves it. `null` when the target is unpublished, missing, or addressed by\n * no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses\n * the same `resolveLink` path as the host bake, so both agree on the derived URL.\n */\nexport function resolveCanvasLink(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n perspective: CanvasPerspective = 'published',\n): string | null {\n return clientFor(locale, perspective).resolveLink(ref)\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n return result.documents.map((doc) => {\n const title = collection?.titleField ? doc[collection.titleField] : undefined\n return { id: doc.id, label: typeof title === 'string' && title.length > 0 ? title : doc.id }\n })\n}\n"]}
|