mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-18 02:45:58 +08:00
feat: deal with broken images
This commit is contained in:
parent
6ffe46e39b
commit
a4ccdfce22
@ -39,6 +39,10 @@ export function Markdown({
|
||||
}
|
||||
return [rehypeKatex];
|
||||
}, [animate]);
|
||||
const handleImgError = (e: React.SyntheticEvent<HTMLImageElement>) => {
|
||||
e.currentTarget.style.display = "none";
|
||||
console.warn(`Markdown: Image "${e.currentTarget.src}" failed to load`);
|
||||
};
|
||||
return (
|
||||
<div
|
||||
className={cn(className, "markdown flex flex-col gap-4")}
|
||||
@ -53,6 +57,9 @@ export function Markdown({
|
||||
{children}
|
||||
</a>
|
||||
),
|
||||
img: ({ src, alt }) => (
|
||||
<img src={src} alt={alt} onError={handleImgError} />
|
||||
),
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user