fix(Markdown): Conditionally apply MarkdownShadowDOMRenderer for style components based on message content

This commit is contained in:
kangfenmao 2025-04-06 09:11:23 +08:00
parent 7284679907
commit e02c967f5b

View File

@ -67,8 +67,7 @@ const Markdown: FC<Props> = ({ message, citationsData }) => {
},
code: CodeBlock,
img: ImagePreview,
pre: (props: any) => <pre style={{ overflow: 'visible' }} {...props} />,
style: MarkdownShadowDOMRenderer as any
pre: (props: any) => <pre style={{ overflow: 'visible' }} {...props} />
} as Partial<Components>
return baseComponents
}, [citationsData])
@ -77,6 +76,10 @@ const Markdown: FC<Props> = ({ message, citationsData }) => {
return <p style={{ marginBottom: 5, whiteSpace: 'pre-wrap' }}>{messageContent}</p>
}
if (messageContent.includes('<style>')) {
components.style = MarkdownShadowDOMRenderer as any
}
return (
<ReactMarkdown
rehypePlugins={rehypePlugins}