feat: added markdown styles in messaages

feat: added option to show / hide agent name
This commit is contained in:
canove
2020-11-29 13:37:55 -03:00
parent 36098bf12d
commit ce1a0f48e2
10 changed files with 106 additions and 32 deletions

View File

@@ -0,0 +1,46 @@
import React from "react";
import Markdown from "markdown-to-jsx";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles(theme => ({
markdownP: {
marginBlockStart: 0,
marginBlockEnd: 0,
},
}));
const CustomLink = ({ children, ...props }) => (
<a {...props} target="_blank" rel="noopener noreferrer">
{children}
</a>
);
const MarkdownWrapper = ({ children }) => {
const classes = useStyles();
const boldRegex = /\*(.*?)\*/g;
if (children && boldRegex.test(children)) {
children = children.replace(boldRegex, "**$1**");
}
return (
<Markdown
options={{
disableParsingRawHTML: true,
overrides: {
a: { component: CustomLink },
p: {
props: {
className: classes.markdownP,
},
},
},
}}
>
{children}
</Markdown>
);
};
export default MarkdownWrapper;