Add NewMarkdown component
This commit is contained in:
parent
56ee8d45cd
commit
332a4ebf71
|
@ -0,0 +1,42 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Text, PropTypes } from 'react-native';
|
||||||
|
import MarkdownLink from '../Link';
|
||||||
|
import MarkdownList from '../List';
|
||||||
|
import MarkdownListItem from '../ListItem';
|
||||||
|
import MarkdownAtMention from '../AtMention';
|
||||||
|
import MarkdownHashtag from '../Hashtag';
|
||||||
|
import MarkdownBlockQuote from '../BlockQuote';
|
||||||
|
import MarkdownEmoji from '../Emoji';
|
||||||
|
import MarkdownTable from '../Table';
|
||||||
|
import MarkdownTableRow from '../TableRow';
|
||||||
|
import MarkdownTableCell from '../TableCell';
|
||||||
|
import styles from '../styles';
|
||||||
|
import { withTheme } from '../../../theme';
|
||||||
|
import { themes } from '../../../constants/colors';
|
||||||
|
|
||||||
|
|
||||||
|
const NewMarkdown = ({ md, theme }) => (
|
||||||
|
<>
|
||||||
|
{md.map((block, index) => {
|
||||||
|
switch (block.type) {
|
||||||
|
case 'PARAGRAPH':
|
||||||
|
return (
|
||||||
|
<Text style={[styles.text, style, { color: themes[theme].bodyText }]} numberOfLines={numberOfLines} index={index}>
|
||||||
|
{block.value?.value}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
case 'LINK':
|
||||||
|
return <MarkdownLink />;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
NewMarkdown.propTypes = {
|
||||||
|
md: PropTypes.array,
|
||||||
|
theme: PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withTheme(NewMarkdown);
|
|
@ -98,6 +98,9 @@ const Content = React.memo((props) => {
|
||||||
if (prevProps.msg !== nextProps.msg) {
|
if (prevProps.msg !== nextProps.msg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (prevProps.md !== nextProps.md) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (prevProps.type !== nextProps.type) {
|
if (prevProps.type !== nextProps.type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ const LastMessage = React.memo(({
|
||||||
msg={formatMsg({
|
msg={formatMsg({
|
||||||
lastMessage, type, showLastMessage, username, useRealName
|
lastMessage, type, showLastMessage, username, useRealName
|
||||||
})}
|
})}
|
||||||
|
md={lastMessage?.md}
|
||||||
style={[styles.markdownText, { color: alert ? themes[theme].bodyText : themes[theme].auxiliaryText }]}
|
style={[styles.markdownText, { color: alert ? themes[theme].bodyText : themes[theme].auxiliaryText }]}
|
||||||
customEmojis={false}
|
customEmojis={false}
|
||||||
useRealName={useRealName}
|
useRealName={useRealName}
|
||||||
|
|
Loading…
Reference in New Issue