dify/web/app/components/base/markdown/index.tsx
2026-03-02 11:17:07 +08:00

35 lines
1.3 KiB
TypeScript

import type { ReactMarkdownWrapperProps, SimplePluginInfo } from './react-markdown-wrapper'
import dynamic from 'next/dynamic'
import { cn } from '@/utils/classnames'
const ReactMarkdown = dynamic(() => import('./react-markdown-wrapper').then(mod => mod.ReactMarkdownWrapper), { ssr: false })
/**
* @fileoverview Main Markdown rendering component.
* This file was refactored to extract individual block renderers and utility functions
* into separate modules for better organization and maintainability as of [Date of refactor].
* 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
pluginInfo?: SimplePluginInfo
} & Pick<ReactMarkdownWrapperProps, 'customComponents' | 'customDisallowedElements' | 'rehypePlugins'>
export const Markdown = (props: MarkdownProps) => {
const { customComponents = {}, pluginInfo } = props
return (
<div className={cn('markdown-body', '!text-text-primary', props.className)}>
<ReactMarkdown
pluginInfo={pluginInfo}
content={props.content}
customComponents={customComponents}
customDisallowedElements={props.customDisallowedElements}
rehypePlugins={props.rehypePlugins}
/>
</div>
)
}