瀏覽代碼

feat: custom components in markdown comp (#22776)

tags/1.7.0
Wu Tianwei 3 月之前
父節點
當前提交
ce15ca8929
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 9 行新增1 行删除
  1. 9
    1
      web/app/components/base/markdown/index.tsx

+ 9
- 1
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. */}

Loading…
取消
儲存