Skip to content

Commit a7e7fbe

Browse files
authored
fix: pass urlTransform prop through to ReactMarkdown (CopilotKit#3845)
Closes CopilotKit#1921 The Markdown component accepted `components` but not `urlTransform`, preventing users from customizing URL sanitization. Added `urlTransform` as an optional prop with passthrough to `MemoizedReactMarkdown`. Split from CopilotKit#3838.
2 parents 0bc0405 + bcea467 commit a7e7fbe

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.changeset/little-pears-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@copilotkit/react-ui": patch
3+
---
4+
5+
fix: pass urlTransform prop through to ReactMarkdown

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,21 @@ 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.urlTransform === nextProps.urlTransform,
130131
);
131132

132133
type MarkdownProps = {
133134
content: string;
134135
components?: Components;
136+
urlTransform?: Options["urlTransform"];
135137
};
136138

137-
export const Markdown = ({ content, components }: MarkdownProps) => {
139+
export const Markdown = ({
140+
content,
141+
components,
142+
urlTransform,
143+
}: MarkdownProps) => {
138144
const mergedComponents = useMemo(
139145
() => ({ ...defaultComponents, ...components }),
140146
[components],
@@ -148,6 +154,7 @@ export const Markdown = ({ content, components }: MarkdownProps) => {
148154
[remarkMath, { singleDollarTextMath: false }],
149155
]}
150156
rehypePlugins={[rehypeRaw]}
157+
{...(urlTransform !== undefined ? { urlTransform } : {})}
151158
>
152159
{content}
153160
</MemoizedReactMarkdown>

0 commit comments

Comments
 (0)