import React, { useContext } from 'react'; import { Text } from 'react-native'; import { Paragraph as ParagraphProps } from '@rocket.chat/message-parser'; import Hashtag from '../Hashtag'; import AtMention from '../AtMention'; import styles from '../styles'; import Link from './Link'; import Plain from './Plain'; import Bold from './Bold'; import Strike from './Strike'; import Italic from './Italic'; import Emoji from './Emoji'; import InlineCode from './InlineCode'; import Image from './Image'; import MarkdownContext from './MarkdownContext'; // import { InlineKaTeX, KaTeX } from './Katex'; interface IParagraphProps { value: ParagraphProps['value']; forceTrim?: boolean; } const Inline = ({ value, forceTrim }: IParagraphProps): React.ReactElement | null => { const { useRealName, username, navToRoomInfo, mentions, channels } = useContext(MarkdownContext); return ( {value.map((block, index) => { // We are forcing trim when is a `[ ](https://https://open.rocket.chat/) plain_text` // to clean the empty spaces if (forceTrim) { if (index === 0 && block.type === 'LINK') { if (!Array.isArray(block.value.label)) { block.value.label.value = block.value?.label?.value?.toString().trimLeft(); } else { // @ts-ignore - we are forcing the value to be a string block.value.label.value = block?.value?.label?.[0]?.value?.toString().trimLeft(); } } if (index === 1 && block.type !== 'LINK') { block.value = block.value?.toString().trimLeft(); } } switch (block.type) { case 'IMAGE': return ; case 'PLAIN_TEXT': return ; case 'BOLD': return ; case 'STRIKE': return ; case 'ITALIC': return ; case 'LINK': return ; case 'MENTION_USER': return ( ); case 'EMOJI': return ; case 'MENTION_CHANNEL': return ; case 'INLINE_CODE': return ; case 'INLINE_KATEX': // return ; return {block.value}; default: return null; } })} ); }; export default Inline;