(undefined);
const [copied, setCopied] = useState(false);
const handleCopy = useCallback(() => {
if (!navigator.clipboard) return;
const text = preRef.current?.textContent ?? "";
navigator.clipboard
.writeText(text)
.then(() => {
setCopied(true);
window.clearTimeout(resetTimerRef.current);
resetTimerRef.current = window.setTimeout(() => setCopied(false), 1500);
})
.catch(() => {});
}, []);
return (
);
}
const components: Components = {
a({ node: _node, ...props }) {
return ;
},
img({ node: _node, ...props }) {
return
;
},
pre({ node: _node, ...props }) {
return ;
},
};
export const ChatMarkdown = memo(function ChatMarkdown({
children,
streaming = false,
}: ChatMarkdownProps) {
const source = streaming ? closeUnterminatedFence(children) : children;
return (
sanitizeMarkdownUrl(url, true) ?? ""}
>
{source}
{streaming ? : null}
);
});
export type { ChatMarkdownProps } from "./markdown";