import { Components } from "react-markdown" import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism" import { Button } from "../../../ui/button" import { CornerUpLeft } from "lucide-react" import { stringifyContent } from "./chatUtils" // Create markdown components for chat message component export const createMarkdownComponents = ( renderCopyButton: (text: any) => JSX.Element, renderMarkdownElement: (props: any) => JSX.Element, askAboutCode: (code: any) => void ): Components => ({ code: ({ node, className, children, ...props }: { node?: import('hast').Element, className?: string, children?: React.ReactNode, [key: string]: any, }) => { const match = /language-(\w+)/.exec(className || "") return match ? (
{children}
)
},
// Render markdown elements
p: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h1: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h2: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h3: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h4: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h5: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
h6: ({ node, children, ...props }) => renderMarkdownElement({ node, children, ...props }),
ul: (props) => (