Skip to content

Commit a462185

Browse files
committed
fix: add remarkPlugins/rehypePlugins passthrough support (CopilotKit#2296)
1 parent 10edf63 commit a462185

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

packages/react-ui/src/components/chat/Markdown.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff 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

132134
type 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>

0 commit comments

Comments
 (0)