import { ReactNode, useState } from "react"; import { theme } from "../theme"; import { Clipboard, ClipboardCheck } from "lucide-react"; export function CodeBlock({ children, enableCopy, }: { children: ReactNode; enableCopy?: boolean; }) { const [copySuccess, setCopySuccess] = useState(false); const handleCopy = (text: string) => { return () => { navigator.clipboard.writeText(text).then(() => { setCopySuccess(true); setTimeout(() => { setCopySuccess(false); }, 3000); }); }; }; const copyText = children instanceof Array ? children.join("") : children; return (

{children}

{enableCopy && navigator.clipboard && (copySuccess ? ( ) : ( ))}
); }