Browse Source

feat: custom components in markdown comp (#22776)

tags/1.7.0
Wu Tianwei 3 months ago
parent
commit
ce15ca8929
No account linked to committer's email address
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      web/app/components/base/markdown/index.tsx

+ 9
- 1
web/app/components/base/markdown/index.tsx View File

* Further refactoring candidates (custom block components not fitting general categories) * Further refactoring candidates (custom block components not fitting general categories)
* are noted in their respective files if applicable. * 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([ const latexContent = flow([
preprocessThinkTag, preprocessThinkTag,
preprocessLaTeX, preprocessLaTeX,
form: MarkdownForm, form: MarkdownForm,
script: ScriptBlock as any, script: ScriptBlock as any,
details: ThinkBlock, details: ThinkBlock,
...customComponents,
}} }}
> >
{/* Markdown detect has problem. */} {/* Markdown detect has problem. */}

Loading…
Cancel
Save