2022-12-13 15:37:20 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ReactMarkdown from 'react-markdown';
|
2023-03-16 11:45:44 +01:00
|
|
|
import {
|
|
|
|
TypographyVariant,
|
|
|
|
OVERFLOW_WRAP,
|
|
|
|
} from '../../../../helpers/constants/design-system';
|
2022-12-13 15:37:20 +01:00
|
|
|
import Typography from '../../../ui/typography/typography';
|
|
|
|
|
2022-12-20 11:44:49 +01:00
|
|
|
const Paragraph = (props) => (
|
|
|
|
<Typography
|
|
|
|
{...props}
|
2023-02-02 21:15:26 +01:00
|
|
|
variant={TypographyVariant.H6}
|
2022-12-20 11:44:49 +01:00
|
|
|
className="snap-ui-markdown__text"
|
2023-03-16 11:45:44 +01:00
|
|
|
overflowWrap={OVERFLOW_WRAP.BREAK_WORD}
|
2022-12-20 11:44:49 +01:00
|
|
|
/>
|
|
|
|
);
|
2022-12-13 15:37:20 +01:00
|
|
|
|
|
|
|
export const SnapUIMarkdown = ({ children }) => {
|
|
|
|
return (
|
|
|
|
<ReactMarkdown
|
|
|
|
allowedElements={['p', 'strong', 'em']}
|
|
|
|
components={{ p: Paragraph }}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</ReactMarkdown>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
SnapUIMarkdown.propTypes = {
|
|
|
|
children: PropTypes.string,
|
|
|
|
};
|