diff --git a/web/src/components/highlight-markdown/index.tsx b/web/src/components/highlight-markdown/index.tsx index 71c3a26885..0dd38f4f83 100644 --- a/web/src/components/highlight-markdown/index.tsx +++ b/web/src/components/highlight-markdown/index.tsx @@ -32,6 +32,7 @@ import { citationMarkerReg } from '@/utils/citation-utils'; import { getDirAttribute } from '@/utils/text-direction'; import { omit } from 'lodash'; import { useIsDarkTheme } from '../theme-provider'; +import { SafeImg } from '@/components/safe-img'; import styles from './index.module.less'; const HighLightMarkdown = ({ @@ -60,6 +61,7 @@ const HighLightMarkdown = ({ p: ({ children, ...props }: any) => (
{children}
), + img: SafeImg, code(props: any) { const { children, className, ...rest } = props; const match = /language-(\w+)/.exec(className || ''); diff --git a/web/src/components/markdown-content/index.tsx b/web/src/components/markdown-content/index.tsx index 744f05120e..b86c04b80d 100644 --- a/web/src/components/markdown-content/index.tsx +++ b/web/src/components/markdown-content/index.tsx @@ -57,6 +57,8 @@ import { HoverCardTrigger, } from '../ui/hover-card'; import styles from './index.module.less'; +import { sanitizeHtmlWithImagesAsText } from '@/utils/dom-util'; +import { SafeImg } from '@/components/safe-img'; const getChunkIndex = (match: string) => parseCitationIndex(match); @@ -211,7 +213,7 @@ const MarkdownContent = ({{children}
, 'custom-typography': ({ children }: { children: string }) => renderReference(children), + img: SafeImg, code(props: any) { const { children, className, ...rest } = props; const restProps = omit(rest, 'node'); diff --git a/web/src/components/next-markdown-content/index.tsx b/web/src/components/next-markdown-content/index.tsx index 834c81b230..b2cea608c2 100644 --- a/web/src/components/next-markdown-content/index.tsx +++ b/web/src/components/next-markdown-content/index.tsx @@ -16,6 +16,7 @@ import Image, { AuthenticatedImg } from '@/components/image'; import SvgIcon from '@/components/svg-icon'; +import { SafeImg } from '@/components/safe-img'; import { MarkdownRemarkPlugins } from '@/constants/markdown-remark-plugins'; import { IReferenceChunk, IReferenceObject } from '@/interfaces/database/chat'; import { getExtension } from '@/utils/document-util'; @@ -419,7 +420,7 @@ function MarkdownContent({ ); }, - img({ src, alt, ...props }: any) { + img({ src, alt, title }: any) { if (isArtifactUrl(src)) { return (