Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: script rendering in message (#10807)

zxhlyhde6d3e493c43
diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx
index 58e54123ddf..b19c2b5b652 100644
--- a/web/app/components/base/markdown.tsx
+++ b/web/app/components/base/markdown.tsx
@@ -211,6 +211,12 @@ const AudioBlock: CodeComponent = memo(({ node }) => {
})
AudioBlock.displayName = 'AudioBlock'
+const ScriptBlock = memo(({ node }: any) => {
+ const scriptContent = node.children[0]?.value || ''
+ return `<script>${scriptContent}</script>`
+})
+ScriptBlock.displayName = 'ScriptBlock'
+
const Paragraph = (paragraph: any) => {
const { node }: any = paragraph
const children_node = node.children
@@ -265,7 +271,7 @@ export function Markdown(props: { content: string; className?: string }) {
}
},
]}
- disallowedElements={['script', 'iframe', 'head', 'html', 'meta', 'link', 'style', 'body']}
+ disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body']}
components={{
code: CodeBlock,
img: Img,
@@ -275,6 +281,7 @@ export function Markdown(props: { content: string; className?: string }) {
p: Paragraph,
button: MarkdownButton,
form: MarkdownForm,
+ script: ScriptBlock,
}}
linkTarget='_blank'
>