mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-19 23:19:06 +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];
|
return [rehypeKatex];
|
||||||
}, [animate]);
|
}, [animate]);
|
||||||
|
const handleImgError = (e: React.SyntheticEvent<HTMLImageElement>) => {
|
||||||
|
e.currentTarget.style.display = "none";
|
||||||
|
console.warn(`Markdown: Image "${e.currentTarget.src}" failed to load`);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(className, "markdown flex flex-col gap-4")}
|
className={cn(className, "markdown flex flex-col gap-4")}
|
||||||
@ -53,6 +57,9 @@ export function Markdown({
|
|||||||
{children}
|
{children}
|
||||||
</a>
|
</a>
|
||||||
),
|
),
|
||||||
|
img: ({ src, alt }) => (
|
||||||
|
<img src={src} alt={alt} onError={handleImgError} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user