import { Checkbox, Code, Divider, Heading, Link, List, ListItem, Text, } from "@chakra-ui/react"; import Emoji from "components/common/Emoji"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "components/common/Table"; import { useMyTheme } from "lib/useMyTheme"; import ReactMarkdown from "react-markdown"; import reactStringReplace from "react-string-replace"; interface MarkdownProps { value: string; } const Markdown: React.FC = ({ value }) => { const { themeColorHex: themeColor } = useMyTheme(); //https://github.com/mustaphaturhan/chakra-ui-markdown-renderer/blob/master/src/index.js const ChakraUIRenderer = () => { function getCoreProps(props: any) { return props["data-sourcepos"] ? { "data-sourcepos": props["data-sourcepos"] } : {}; } return { paragraph: (props: any) => { const { children } = props; return {children}; }, emphasis: (props: any) => { const { children } = props; return {children}; }, blockquote: (props: any) => { const { children } = props; return {children}; }, code: (props: any) => { const { language, value } = props; const className = language && `language-${language}`; return (
            
              {value}
            
          
); }, delete: (props: any) => { const { children } = props; return {children}; }, thematicBreak: Divider, link: (props: any) => { const { children } = props; return ( {children} ); }, linkReference: (props: any) => { const { children } = props; return ( {children} ); }, text: (props: any) => { const { children } = props; // TODO: "react-dom.development.js?61bb:67 Warning: validateDOMNesting(...):
cannot appear as a descendant of

." return ( {reactStringReplace(children, /(:\S+:)/g, (match, i) => ( ))} ); }, list: (props: any) => { const { start, ordered, children, depth } = props; const attrs = getCoreProps(props); if (start !== null && start !== 1 && start !== undefined) { // @ts-ignore attrs.start = start.toString(); } let styleType = "disc"; if (ordered) styleType = "decimal"; if (depth === 1) styleType = "circle"; return ( {children} ); }, listItem: (props: any) => { const { children, checked } = props; let checkbox = null; if (checked !== null && checked !== undefined) { checkbox = ( {children} ); } return ( {checkbox || children} ); }, definition: () => null, heading: (props: any) => { const { children } = props; return ( {children} ); }, inlineCode: (props: any) => { const { children } = props; return {children}; }, table: (props: any) => { const { children } = props; return {children}
; }, tableHead: (props: any) => { const { children } = props; return {children}; }, tableBody: (props: any) => { const { children } = props; return {children}; }, tableRow: (props: any) => { const { children } = props; return {children}; }, tableCell: (props: any) => { const { children, isHeader } = props; if (isHeader) { return {children}; } return {children}; }, }; }; return ( ); }; export default Markdown;