import { type FC, useMemo } from 'react' import SyntaxHighlighter from 'react-syntax-highlighter'; import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'; import CopyBtn from './CopyBtn'; import ReactEcharts from 'echarts-for-react'; import Svg from './Svg' import MermaidChart from './MermaidChart' type ICodeProps = { children: string; className: string; } const Code: FC = (props) => { const { children, className } = props; const language = className?.split('-')[1] console.log('Code', props) const charData = useMemo(() => { if (language !== 'echarts') return null; try { return JSON.parse(String(children).replace(/\n$/, '')) } catch (error) { console.error('Error parsing JSON for ECharts:', error) return {"title":{"text":"ECharts error - Wrong JSON format."}} } }, [language, children]) if (language === 'echarts') { return ( ) } if (language === 'svg') { return ( ) } if (language === 'mermaid') { return ( ) } if (className) { return (
{children}
) } return {children} } export default Code