'use client'; import React from 'react'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import customCodeRenderer from './CodeRenderer'; // Assuming CodeRenderer is in the same directory or adjust path interface DefaultCodeProps { node: any; className?: string; children: React.ReactNode & React.ReactNode[]; style?: React.CSSProperties; // For animationStyle codeStyle?: any; animateText: (text: any) => React.ReactNode; animation?: string; animationDuration?: string; animationTimingFunction?: string; } const DefaultCode: React.FC = ({ node, className, children, style, codeStyle, animateText, animation, animationDuration, animationTimingFunction, ...props }) => { const [copied, setCopied] = React.useState(false); const handleCopy = () => { // Ensure children is a string for navigator.clipboard.writeText const textToCopy = Array.isArray(children) ? children.join('') : String(children); navigator.clipboard.writeText(textToCopy); setCopied(true); setTimeout(() => setCopied(false), 2000); }; if (!className || !className.startsWith("language-")) { return {animateText(children)} ; } return
{String(children) /* Ensure children is string for SyntaxHighlighter */}
; }; export default DefaultCode;