"use client" import React from "react" interface TiptapNode { type: string content?: TiptapNode[] text?: string marks?: { type: string; attrs?: Record }[] attrs?: Record } export function TiptapRenderer({ content }: { content: string }) { let parsed: TiptapNode try { parsed = JSON.parse(content) } catch { // If it's just plain text, wrap it in a paragraph return

{content}

} return
{renderNode(parsed)}
} function renderNode(node: TiptapNode, key?: number): React.ReactNode { switch (node.type) { case "doc": return node.content?.map((child, i) => renderNode(child, i)) case "paragraph": return

{node.content ? node.content.map((child, i) => renderNode(child, i)) :
}

case "text": { let el: React.ReactNode = node.text ?? "" node.marks?.forEach((mark) => { if (mark.type === "bold") el = {el} if (mark.type === "italic") el = {el} }) return {el} } case "bulletList": return case "orderedList": return
    {node.content?.map((child, i) => renderNode(child, i))}
case "listItem": return
  • {node.content?.map((child, i) => renderNode(child, i))}
  • case "link": return {node.content?.map((child, i) => renderNode(child, i))} case "hardBreak": return
    default: return node.content?.map((child, i) => renderNode(child, i)) } }