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
111 lines
4.1 KiB
TypeScript
111 lines
4.1 KiB
TypeScript
import { RichTextView } from "@/components/frontend/RichTextView";
|
|
import { RadioIcon } from "lucide-react";
|
|
import { Item, ItemContent, ItemHeader, ItemTitle } from "@/components/ui/item";
|
|
|
|
interface FrequencyEntry {
|
|
frequency: number;
|
|
channel?: number | null;
|
|
netName: string;
|
|
freqUsage: string;
|
|
}
|
|
|
|
interface MissionCommsProps {
|
|
commsAndDocs: {
|
|
radioPlan?: {
|
|
root: {
|
|
type: string;
|
|
children: {
|
|
type: any;
|
|
version: number;
|
|
[k: string]: unknown;
|
|
}[];
|
|
direction: ("ltr" | "rtl") | null;
|
|
format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
|
|
indent: number;
|
|
version: number;
|
|
};
|
|
[k: string]: unknown;
|
|
} | null;
|
|
frequencies?: FrequencyEntry[] | null;
|
|
} | null;
|
|
}
|
|
|
|
export function MissionComms({ commsAndDocs }: MissionCommsProps) {
|
|
if (!commsAndDocs) {
|
|
return (
|
|
<Item variant="outline">
|
|
<ItemHeader>
|
|
<div className="flex items-center gap-2">
|
|
<RadioIcon className="size-4 text-muted-foreground" />
|
|
<ItemTitle>Communications</ItemTitle>
|
|
</div>
|
|
</ItemHeader>
|
|
<ItemContent>
|
|
<p className="text-sm text-muted-foreground italic">No communications plan available.</p>
|
|
</ItemContent>
|
|
</Item>
|
|
);
|
|
}
|
|
|
|
const { radioPlan, frequencies } = commsAndDocs;
|
|
const hasFrequencies = frequencies && frequencies.length > 0;
|
|
|
|
return (
|
|
<div className="flex min-w-0 flex-col gap-3 px-4 py-4">
|
|
<Item variant="outline">
|
|
<ItemContent className="flex flex-col gap-4">
|
|
{radioPlan && (
|
|
<div className="flex flex-col gap-1.5">
|
|
<span className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
|
Radio Plan
|
|
</span>
|
|
<RichTextView data={radioPlan} className="text-muted-foreground" />
|
|
</div>
|
|
)}
|
|
{hasFrequencies && (
|
|
<div className="flex flex-col gap-1.5">
|
|
<span className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
|
Frequencies
|
|
</span>
|
|
<div className="border border-border rounded-lg overflow-hidden">
|
|
<table className="w-full text-sm">
|
|
<thead>
|
|
<tr className="bg-muted/50 border-b border-border">
|
|
<th className="text-left px-4 py-2.5 font-semibold uppercase text-xs tracking-wider text-muted-foreground">
|
|
Frequency
|
|
</th>
|
|
<th className="text-left px-4 py-2.5 font-semibold uppercase text-xs tracking-wider text-muted-foreground">
|
|
Channel
|
|
</th>
|
|
<th className="text-left px-4 py-2.5 font-semibold uppercase text-xs tracking-wider text-muted-foreground">
|
|
Net Name
|
|
</th>
|
|
<th className="text-left px-4 py-2.5 font-semibold uppercase text-xs tracking-wider text-muted-foreground">
|
|
Usage
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{frequencies!.map((freq, index) => (
|
|
<tr key={index} className="border-b border-border/50">
|
|
<td className="px-4 py-2 font-mono font-medium">{freq.frequency}</td>
|
|
<td className="px-4 py-2 text-muted-foreground">{freq.channel ?? "-"}</td>
|
|
<td className="px-4 py-2 font-medium">{freq.netName}</td>
|
|
<td className="px-4 py-2 text-muted-foreground">{freq.freqUsage}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
)}
|
|
{!radioPlan && !hasFrequencies && (
|
|
<p className="text-sm text-muted-foreground italic">
|
|
No communications details provided.
|
|
</p>
|
|
)}
|
|
</ItemContent>
|
|
</Item>
|
|
</div>
|
|
);
|
|
}
|