Files
portfolio/app/components/RichTextClient.tsx
2026-01-12 14:36:10 +00:00

25 lines
498 B
TypeScript

"use client";
import React, { useMemo } from "react";
import type { JSONContent } from "@tiptap/react";
import { richTextToSafeHtml } from "@/lib/richtext";
export default function RichTextClient({
doc,
className,
}: {
doc: JSONContent;
className?: string;
}) {
const html = useMemo(() => richTextToSafeHtml(doc), [doc]);
return (
<div
className={className}
// HTML is sanitized in `richTextToSafeHtml`
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}