From ce15ca8929c6dcc65aae93f56942a5aae36ed081 Mon Sep 17 00:00:00 2001 From: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Date: Tue, 22 Jul 2025 15:30:22 +0800 Subject: [PATCH] feat: custom components in markdown comp (#22776) --- web/app/components/base/markdown/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/markdown/index.tsx b/web/app/components/base/markdown/index.tsx index 1e50e6745..bab5ac8eb 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> +} -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. */}