Skip to content

Commit 6c9d6a4

Browse files
authored
fix: add custom disallowed elements to Markdown component and restore the default disallowed elements (langgenius#15057)
1 parent 9962118 commit 6c9d6a4

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

web/app/components/base/markdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const Link = ({ node, ...props }: any) => {
239239
}
240240
}
241241

242-
export function Markdown(props: { content: string; className?: string }) {
242+
export function Markdown(props: { content: string; className?: string; customDisallowedElements?: string[] }) {
243243
const latexContent = flow([
244244
preprocessThinkTag,
245245
preprocessLaTeX,
@@ -274,7 +274,7 @@ export function Markdown(props: { content: string; className?: string }) {
274274
}
275275
},
276276
]}
277-
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body', 'input']}
277+
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body', ...(props.customDisallowedElements || [])]}
278278
components={{
279279
code: CodeBlock,
280280
img: Img,

web/app/components/datasets/documents/detail/completed/common/chunk-content.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ const ChunkContent: FC<IChunkContentProps> = ({
181181
<Markdown
182182
className='h-full w-full !text-text-secondary'
183183
content={question}
184+
customDisallowedElements={['input']}
184185
/>
185186
)
186187
}

web/app/components/datasets/documents/detail/completed/segment-card/chunk-content.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const ChunkContent: FC<ChunkContentProps> = ({
5050
className,
5151
)}
5252
content={sign_content || content || ''}
53+
customDisallowedElements={['input']}
5354
/>
5455
}
5556

web/app/components/datasets/hit-testing/components/chunk-detail-modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const ChunkDetailModal: FC<Props> = ({
6060
<Markdown
6161
className={cn('!mt-2 !text-text-secondary', heighClassName)}
6262
content={sign_content || content}
63+
customDisallowedElements={['input']}
6364
/>
6465
{!isParentChildRetrieval && keywords && keywords.length > 0 && (
6566
<div className='mt-6'>

web/app/components/datasets/hit-testing/components/result-item.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ const ResultItem: FC<Props> = ({
4747

4848
{/* Main */}
4949
<div className='mt-1 px-3'>
50-
<Markdown className='line-clamp-2' content={sign_content || content} />
50+
<Markdown
51+
className='line-clamp-2'
52+
content={sign_content || content}
53+
customDisallowedElements={['input']}
54+
/>
5155
{isParentChildRetrieval && (
5256
<div className='mt-1'>
5357
<div

0 commit comments

Comments
 (0)