markdown and textarea input

This commit is contained in:
josc146
2023-05-19 15:40:17 +08:00
parent 1105fbf6ec
commit db61d3f7f9
8 changed files with 1201 additions and 44 deletions

View File

@@ -0,0 +1,31 @@
import ReactMarkdown from 'react-markdown';
import rehypeRaw from 'rehype-raw';
import rehypeHighlight from 'rehype-highlight';
import remarkGfm from 'remark-gfm';
import remarkBreaks from 'remark-breaks';
import {FC} from 'react';
import {ReactMarkdownOptions} from 'react-markdown/lib/react-markdown';
export const MarkdownRender: FC<ReactMarkdownOptions> = (props) => {
return (
<div dir="auto" className="markdown-body">
<ReactMarkdown
remarkPlugins={[remarkGfm, remarkBreaks]}
rehypePlugins={[
rehypeRaw,
[
rehypeHighlight,
{
detect: true,
ignoreMissing: true
}
]
]}
>
{props.children}
</ReactMarkdown>
</div>
);
};
export default MarkdownRender;