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.

feat: custom components in markdown comp (#22776)

Wu Tianweice15ca8929c6
diff --git a/web/app/components/base/markdown/index.tsx b/web/app/components/base/markdown/index.tsx
index 1e50e6745bd..bab5ac8eba2 100644
--- a/web/app/components/base/markdown/index.tsx
+++ b/web/app/components/base/markdown/index.tsx
@@ -28,8 +28,15 @@ import {
* Further refactoring candidates (custom block components not fitting general categories)
* are noted in their respective files if applicable.
*/
+export type MarkdownProps = {
+ content: string
+ className?: string
+ customDisallowedElements?: string[]
+ customComponents?: Record<string, React.ComponentType<any>>
+}
-export function Markdown(props: { content: string; className?: string; customDisallowedElements?: string[] }) {
+export const Markdown = (props: MarkdownProps) => {
+ const { customComponents = {} } = props
const latexContent = flow([
preprocessThinkTag,
preprocessLaTeX,
@@ -78,6 +85,7 @@ export function Markdown(props: { content: string; className?: string; customDis
form: MarkdownForm,
script: ScriptBlock as any,
details: ThinkBlock,
+ ...customComponents,
}}
>
{/* Markdown detect has problem. */}