2020-10-07 09:41:58 -07:00
|
|
|
import * as React from 'react';
|
|
|
|
import { forwardRef } from 'react';
|
|
|
|
import ReactMarkdown from 'react-markdown';
|
2020-07-05 17:20:10 -07:00
|
|
|
import {
|
|
|
|
List,
|
|
|
|
ListItem,
|
|
|
|
Heading,
|
|
|
|
Link,
|
|
|
|
CodeBlock,
|
|
|
|
TableData,
|
|
|
|
Paragraph,
|
|
|
|
InlineCode,
|
|
|
|
Divider,
|
2020-10-07 09:41:58 -07:00
|
|
|
Table,
|
|
|
|
} from './MDComponents';
|
2020-07-05 17:20:10 -07:00
|
|
|
|
|
|
|
const mdComponents = {
|
|
|
|
paragraph: Paragraph,
|
|
|
|
link: Link,
|
|
|
|
heading: Heading,
|
|
|
|
inlineCode: InlineCode,
|
|
|
|
list: List,
|
|
|
|
listItem: ListItem,
|
|
|
|
thematicBreak: Divider,
|
|
|
|
code: CodeBlock,
|
|
|
|
table: Table,
|
2020-10-07 09:41:58 -07:00
|
|
|
tableCell: TableData,
|
2020-07-05 17:20:10 -07:00
|
|
|
};
|
|
|
|
|
2020-09-28 11:54:00 -07:00
|
|
|
export const Markdown = forwardRef(({ content }, ref) => (
|
2020-07-05 17:20:10 -07:00
|
|
|
<ReactMarkdown ref={ref} renderers={mdComponents} source={content} />
|
|
|
|
));
|