Skip to content

Commit de6d3e4

Browse files
zxhlyhcrazywoola
andauthored
fix: script rendering in message (#10807)
Co-authored-by: crazywoola <[email protected]>
1 parent 7f1fdb7 commit de6d3e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

web/app/components/base/markdown.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ const AudioBlock: CodeComponent = memo(({ node }) => {
211211
})
212212
AudioBlock.displayName = 'AudioBlock'
213213

214+
const ScriptBlock = memo(({ node }: any) => {
215+
const scriptContent = node.children[0]?.value || ''
216+
return `<script>${scriptContent}</script>`
217+
})
218+
ScriptBlock.displayName = 'ScriptBlock'
219+
214220
const Paragraph = (paragraph: any) => {
215221
const { node }: any = paragraph
216222
const children_node = node.children
@@ -265,7 +271,7 @@ export function Markdown(props: { content: string; className?: string }) {
265271
}
266272
},
267273
]}
268-
disallowedElements={['script', 'iframe', 'head', 'html', 'meta', 'link', 'style', 'body']}
274+
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body']}
269275
components={{
270276
code: CodeBlock,
271277
img: Img,
@@ -275,6 +281,7 @@ export function Markdown(props: { content: string; className?: string }) {
275281
p: Paragraph,
276282
button: MarkdownButton,
277283
form: MarkdownForm,
284+
script: ScriptBlock,
278285
}}
279286
linkTarget='_blank'
280287
>

0 commit comments

Comments
 (0)