mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 06:08:58 +08:00
fix: add custom disallowed elements to Markdown component and restore the default disallowed elements (#15057)
This commit is contained in:
parent
9962118dbd
commit
6c9d6a4d57
@ -239,7 +239,7 @@ const Link = ({ node, ...props }: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
export function Markdown(props: { content: string; className?: string }) {
|
||||
export function Markdown(props: { content: string; className?: string; customDisallowedElements?: string[] }) {
|
||||
const latexContent = flow([
|
||||
preprocessThinkTag,
|
||||
preprocessLaTeX,
|
||||
@ -274,7 +274,7 @@ export function Markdown(props: { content: string; className?: string }) {
|
||||
}
|
||||
},
|
||||
]}
|
||||
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body', 'input']}
|
||||
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body', ...(props.customDisallowedElements || [])]}
|
||||
components={{
|
||||
code: CodeBlock,
|
||||
img: Img,
|
||||
|
@ -181,6 +181,7 @@ const ChunkContent: FC<IChunkContentProps> = ({
|
||||
<Markdown
|
||||
className='h-full w-full !text-text-secondary'
|
||||
content={question}
|
||||
customDisallowedElements={['input']}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ const ChunkContent: FC<ChunkContentProps> = ({
|
||||
className,
|
||||
)}
|
||||
content={sign_content || content || ''}
|
||||
customDisallowedElements={['input']}
|
||||
/>
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ const ChunkDetailModal: FC<Props> = ({
|
||||
<Markdown
|
||||
className={cn('!mt-2 !text-text-secondary', heighClassName)}
|
||||
content={sign_content || content}
|
||||
customDisallowedElements={['input']}
|
||||
/>
|
||||
{!isParentChildRetrieval && keywords && keywords.length > 0 && (
|
||||
<div className='mt-6'>
|
||||
|
@ -47,7 +47,11 @@ const ResultItem: FC<Props> = ({
|
||||
|
||||
{/* Main */}
|
||||
<div className='mt-1 px-3'>
|
||||
<Markdown className='line-clamp-2' content={sign_content || content} />
|
||||
<Markdown
|
||||
className='line-clamp-2'
|
||||
content={sign_content || content}
|
||||
customDisallowedElements={['input']}
|
||||
/>
|
||||
{isParentChildRetrieval && (
|
||||
<div className='mt-1'>
|
||||
<div
|
||||
|
Loading…
x
Reference in New Issue
Block a user