@@ -17,6 +17,8 @@ import { CodeBlock } from "./CodeBlock";
1717import { isTagNode , isTaskListItemNode } from "./ConditionalComponent" ;
1818import { COMPACT_MODE_CONFIG , SANITIZE_SCHEMA } from "./constants" ;
1919import { useCompactLabel , useCompactMode } from "./hooks" ;
20+ import { Blockquote , Heading , HorizontalRule , Image , InlineCode , Link , List , ListItem , Paragraph } from "./markdown" ;
21+ import { Table , TableBody , TableCell , TableHead , TableHeaderCell , TableRow } from "./Table" ;
2022import { Tag } from "./Tag" ;
2123import { TaskListItem } from "./TaskListItem" ;
2224import type { MemoContentProps } from "./types" ;
@@ -37,7 +39,7 @@ const MemoContent = (props: MemoContentProps) => {
3739 < div
3840 ref = { memoContentContainerRef }
3941 className = { cn (
40- "markdown-content relative w-full max-w-full wrap-break-word text-base leading-6" ,
42+ "relative w-full max-w-full wrap-break-word text-base leading-6" ,
4143 showCompactMode === "ALL" && `max-h-[${ COMPACT_MODE_CONFIG . maxHeightVh } vh] overflow-hidden` ,
4244 contentClassName ,
4345 ) }
@@ -62,12 +64,38 @@ const MemoContent = (props: MemoContentProps) => {
6264 }
6365 return < span { ...rest } /> ;
6466 } ) as React . ComponentType < React . ComponentProps < "span" > > ,
65- pre : CodeBlock ,
66- a : ( { href, children, ...aProps } ) => (
67- < a href = { href } target = "_blank" rel = "noopener noreferrer" { ...aProps } >
67+ // Headings
68+ h1 : ( { children } ) => < Heading level = { 1 } > { children } </ Heading > ,
69+ h2 : ( { children } ) => < Heading level = { 2 } > { children } </ Heading > ,
70+ h3 : ( { children } ) => < Heading level = { 3 } > { children } </ Heading > ,
71+ h4 : ( { children } ) => < Heading level = { 4 } > { children } </ Heading > ,
72+ h5 : ( { children } ) => < Heading level = { 5 } > { children } </ Heading > ,
73+ h6 : ( { children } ) => < Heading level = { 6 } > { children } </ Heading > ,
74+ // Block elements
75+ p : ( { children } ) => < Paragraph > { children } </ Paragraph > ,
76+ blockquote : ( { children } ) => < Blockquote > { children } </ Blockquote > ,
77+ hr : ( ) => < HorizontalRule /> ,
78+ // Lists
79+ ul : ( { children, ...props } ) => < List { ...props } > { children } </ List > ,
80+ ol : ( { children, ...props } ) => (
81+ < List ordered { ...props } >
6882 { children }
69- </ a >
83+ </ List >
7084 ) ,
85+ li : ( { children, ...props } ) => < ListItem { ...props } > { children } </ ListItem > ,
86+ // Inline elements
87+ a : ( { children, ...props } ) => < Link { ...props } > { children } </ Link > ,
88+ code : ( { children } ) => < InlineCode > { children } </ InlineCode > ,
89+ img : ( { ...props } ) => < Image { ...props } /> ,
90+ // Code blocks
91+ pre : CodeBlock ,
92+ // Tables
93+ table : ( { children } ) => < Table > { children } </ Table > ,
94+ thead : ( { children } ) => < TableHead > { children } </ TableHead > ,
95+ tbody : ( { children } ) => < TableBody > { children } </ TableBody > ,
96+ tr : ( { children } ) => < TableRow > { children } </ TableRow > ,
97+ th : ( { children, ...props } ) => < TableHeaderCell { ...props } > { children } </ TableHeaderCell > ,
98+ td : ( { children, ...props } ) => < TableCell { ...props } > { children } </ TableCell > ,
7199 } }
72100 >
73101 { content }
0 commit comments