diff --git a/web/app/components/base/mermaid/index.tsx b/web/app/components/base/mermaid/index.tsx
index af5c010ac2..8e8296697e 100644
--- a/web/app/components/base/mermaid/index.tsx
+++ b/web/app/components/base/mermaid/index.tsx
@@ -3,6 +3,7 @@ import mermaid from 'mermaid'
import { usePrevious } from 'ahooks'
import { useTranslation } from 'react-i18next'
import { ExclamationTriangleIcon } from '@heroicons/react/24/outline'
+import { cleanUpSvgCode } from './utils'
import LoadingAnim from '@/app/components/base/chat/chat/loading-anim'
import cn from '@/utils/classnames'
import ImagePreview from '@/app/components/base/image-uploader/image-preview'
@@ -44,7 +45,7 @@ const Flowchart = React.forwardRef((props: {
try {
if (typeof window !== 'undefined' && mermaidAPI) {
const svgGraph = await mermaidAPI.render('flowchart', PrimitiveCode)
- const base64Svg: any = await svgToBase64(svgGraph.svg)
+ const base64Svg: any = await svgToBase64(cleanUpSvgCode(svgGraph.svg))
setSvgCode(base64Svg)
setIsLoading(false)
}
diff --git a/web/app/components/base/mermaid/utils.spec.ts b/web/app/components/base/mermaid/utils.spec.ts
new file mode 100644
index 0000000000..6ea7f17bfa
--- /dev/null
+++ b/web/app/components/base/mermaid/utils.spec.ts
@@ -0,0 +1,8 @@
+import { cleanUpSvgCode } from './utils'
+
+describe('cleanUpSvgCode', () => {
+ it('replaces old-style
tags with the new style', () => {
+ const result = cleanUpSvgCode('
test
')
+ expect(result).toEqual('
test
')
+ })
+})
diff --git a/web/app/components/base/mermaid/utils.ts b/web/app/components/base/mermaid/utils.ts
new file mode 100644
index 0000000000..1f07690cea
--- /dev/null
+++ b/web/app/components/base/mermaid/utils.ts
@@ -0,0 +1,3 @@
+export function cleanUpSvgCode(svgCode: string): string {
+ return svgCode.replaceAll('
', '
')
+}