File tree Expand file tree Collapse file tree
packages/react-ui/src/components/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,15 +126,24 @@ const MemoizedReactMarkdown: FC<Options> = memo(
126126 ReactMarkdown ,
127127 ( prevProps , nextProps ) =>
128128 prevProps . children === nextProps . children &&
129- prevProps . components === nextProps . components ,
129+ prevProps . components === nextProps . components &&
130+ prevProps . remarkPlugins === nextProps . remarkPlugins &&
131+ prevProps . rehypePlugins === nextProps . rehypePlugins ,
130132) ;
131133
132134type MarkdownProps = {
133135 content : string ;
134136 components ?: Components ;
137+ remarkPlugins ?: Options [ "remarkPlugins" ] ;
138+ rehypePlugins ?: Options [ "rehypePlugins" ] ;
135139} ;
136140
137- export const Markdown = ( { content, components } : MarkdownProps ) => {
141+ export const Markdown = ( {
142+ content,
143+ components,
144+ remarkPlugins,
145+ rehypePlugins,
146+ } : MarkdownProps ) => {
138147 const mergedComponents = useMemo (
139148 ( ) => ( { ...defaultComponents , ...components } ) ,
140149 [ components ] ,
@@ -146,8 +155,9 @@ export const Markdown = ({ content, components }: MarkdownProps) => {
146155 remarkPlugins = { [
147156 remarkGfm ,
148157 [ remarkMath , { singleDollarTextMath : false } ] ,
158+ ...( remarkPlugins || [ ] ) ,
149159 ] }
150- rehypePlugins = { [ rehypeRaw ] }
160+ rehypePlugins = { [ rehypeRaw , ... ( rehypePlugins || [ ] ) ] }
151161 >
152162 { content }
153163 </ MemoizedReactMarkdown >
You can’t perform that action at this time.
0 commit comments