RichText authored in the admin panel was rendered as plain text on the public site: headings/lists/quotes were flattened by Tailwind preflight (no @tailwindcss/typography installed), and Payload's default JSX converter ignored text colours. - src/lib/lexical: shared editor factory (ptfLexicalEditor) + shared colour palette (textState) + colour converter (richTextConverters) - RichTextView: canonical .lexical-content renderer (colour-aware), swapped into every frontend render site - All rich-text editors route through the factory, so every field inherits the coloured editor (incl. the previously-unedited ones) - .lexical-content CSS extended with checklist/table/heading rules, wrapped in @layer components so per-page utilities still override; dropped the now-dead per-page prose hacks - Remove the now-dead briefingConverters in favour of the shared converter; add tests/int/rich-text-view.int.spec.ts
94 lines
2.7 KiB
TypeScript
94 lines
2.7 KiB
TypeScript
import type { CollectionConfig } from "payload";
|
|
import { ptfLexicalEditor } from "@/lib/lexical/editor";
|
|
import hasRoles from "@/utils/access-control/hasRoles";
|
|
|
|
function isStoryAuthor(user: Parameters<typeof hasRoles>[1]): boolean {
|
|
return hasRoles(["admin", "developer"], user);
|
|
}
|
|
|
|
export const StoryBeats: CollectionConfig = {
|
|
slug: "story-beats",
|
|
labels: {
|
|
singular: "Chronicle Entry",
|
|
plural: "Chronicle Entries",
|
|
},
|
|
admin: {
|
|
group: "Chronicle",
|
|
useAsTitle: "title",
|
|
defaultColumns: ["title", "status", "occurredAt", "order", "mission"],
|
|
listSearchableFields: ["title", "body"],
|
|
description:
|
|
"Chronicle entries. Drafts are visible to staff only; published entries are readable by any logged-in user on /story.",
|
|
},
|
|
access: {
|
|
// Guests see nothing; admin/developer see everything; any other logged-in
|
|
// user sees only published beats.
|
|
read: ({ req }) => {
|
|
if (!req.user) return false;
|
|
if (isStoryAuthor(req.user)) return true;
|
|
return { status: { equals: "published" } };
|
|
},
|
|
create: ({ req }) => isStoryAuthor(req.user),
|
|
update: ({ req }) => isStoryAuthor(req.user),
|
|
delete: ({ req }) => isStoryAuthor(req.user),
|
|
},
|
|
fields: [
|
|
{
|
|
name: "title",
|
|
type: "text",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "occurredAt",
|
|
type: "date",
|
|
admin: {
|
|
description:
|
|
"In-story timestamp shown with the chapter on /story. Does not affect chapter order.",
|
|
},
|
|
},
|
|
{
|
|
name: "order",
|
|
type: "number",
|
|
admin: {
|
|
description:
|
|
"Manual chapter sequence: if any entry has an order, /story displays entries in that exact order (ascending, first at top). With no order values, the newest entry shows first and chapter numbers follow creation date.",
|
|
},
|
|
},
|
|
{
|
|
name: "status",
|
|
type: "select",
|
|
required: true,
|
|
defaultValue: "draft",
|
|
index: true,
|
|
options: [
|
|
{ label: "Draft", value: "draft" },
|
|
{ label: "Published", value: "published" },
|
|
],
|
|
},
|
|
{
|
|
name: "body",
|
|
type: "richText",
|
|
required: true,
|
|
editor: ptfLexicalEditor(),
|
|
admin: {
|
|
description: "Rich text body of the entry, rendered on /story with the Lexical renderer.",
|
|
},
|
|
},
|
|
{
|
|
name: "mission",
|
|
type: "relationship",
|
|
relationTo: "missions",
|
|
admin: {
|
|
description: "Optional mission this entry is tied to. Entries may stand alone.",
|
|
},
|
|
},
|
|
{
|
|
name: "voiceover",
|
|
type: "relationship",
|
|
relationTo: "story-voiceovers",
|
|
admin: {
|
|
description: "Optional audio narration for this entry. Rendered as a player on /story.",
|
|
},
|
|
},
|
|
],
|
|
};
|