fix(Markdown): Conditionally apply MarkdownShadowDOMRenderer for style components based on message content
This commit is contained in:
parent
7284679907
commit
e02c967f5b
@ -67,8 +67,7 @@ const Markdown: FC<Props> = ({ message, citationsData }) => {
|
|||||||
},
|
},
|
||||||
code: CodeBlock,
|
code: CodeBlock,
|
||||||
img: ImagePreview,
|
img: ImagePreview,
|
||||||
pre: (props: any) => <pre style={{ overflow: 'visible' }} {...props} />,
|
pre: (props: any) => <pre style={{ overflow: 'visible' }} {...props} />
|
||||||
style: MarkdownShadowDOMRenderer as any
|
|
||||||
} as Partial<Components>
|
} as Partial<Components>
|
||||||
return baseComponents
|
return baseComponents
|
||||||
}, [citationsData])
|
}, [citationsData])
|
||||||
@ -77,6 +76,10 @@ const Markdown: FC<Props> = ({ message, citationsData }) => {
|
|||||||
return <p style={{ marginBottom: 5, whiteSpace: 'pre-wrap' }}>{messageContent}</p>
|
return <p style={{ marginBottom: 5, whiteSpace: 'pre-wrap' }}>{messageContent}</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (messageContent.includes('<style>')) {
|
||||||
|
components.style = MarkdownShadowDOMRenderer as any
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
rehypePlugins={rehypePlugins}
|
rehypePlugins={rehypePlugins}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user