import React, { useEffect, useRef } from 'react'; import ReactMarkdown from 'react-markdown'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { atomDark } from 'react-syntax-highlighter/dist/esm/styles/prism'; import remarkGfm from 'remark-gfm'; import rehypeRaw from 'rehype-raw'; import './Streaming.css'; // Streaming component for rendering markdown content const Streaming = ({ content, isStreaming, onContentRef }) => { const contentRef = useRef(null); useEffect(() => { if (contentRef.current && onContentRef) { onContentRef(contentRef.current); } }, [content, onContentRef]); const displayContent = isStreaming ? `${content}▌` : (content || ''); return (
{match ? match[1] : 'code'}
{String(children).replace(/\n$/, '')}
) : ( {children} ); }, table({node, ...props}) { return (
); }, a({node, children, href, ...props}) { return ( {children} ); }, blockquote({node, ...props}) { return (
); } }} > {displayContent} ); }; export default Streaming;