Renamed folder, add @rocket.chat/message-parser, migrate some files to TypeScript
This commit is contained in:
parent
7a88d8df62
commit
20d2db9aa3
|
@ -1,19 +0,0 @@
|
||||||
/* eslint-disable react/no-array-index-key */
|
|
||||||
import React from 'react';
|
|
||||||
import { View } from 'react-native';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import Emoji from './Emoji';
|
|
||||||
|
|
||||||
|
|
||||||
const BigEmoji = ({ value }) => (
|
|
||||||
<View style={{ flexDirection: 'row' }}>
|
|
||||||
{value.map((block, index) => <Emoji key={index} emojiHandle={`:${ block.value.value }:`} isBigEmoji />)}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
|
|
||||||
BigEmoji.propTypes = {
|
|
||||||
value: PropTypes.object
|
|
||||||
};
|
|
||||||
|
|
||||||
export default BigEmoji;
|
|
|
@ -1,15 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Text } from 'react-native';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
const Plain = ({ value }) => (
|
|
||||||
<Text accessibilityLabel={value}>
|
|
||||||
{value}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
|
|
||||||
Plain.propTypes = {
|
|
||||||
value: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Plain;
|
|
|
@ -4,6 +4,7 @@ import { Node, Parser } from 'commonmark';
|
||||||
import Renderer from 'commonmark-react-renderer';
|
import Renderer from 'commonmark-react-renderer';
|
||||||
import removeMarkdown from 'remove-markdown';
|
import removeMarkdown from 'remove-markdown';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { MarkdownAST } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
import shortnameToUnicode from '../../utils/shortnameToUnicode';
|
import shortnameToUnicode from '../../utils/shortnameToUnicode';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
|
@ -22,10 +23,16 @@ import mergeTextNodes from './mergeTextNodes';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { isValidURL } from '../../utils/url';
|
import { isValidURL } from '../../utils/url';
|
||||||
import { getUserSelector } from '../../selectors/login';
|
import { getUserSelector } from '../../selectors/login';
|
||||||
import MessageBody from './MessageBody';
|
import NewMarkdown from './new';
|
||||||
|
|
||||||
interface IMarkdownProps {
|
interface IMarkdownProps {
|
||||||
msg: string;
|
msg: string;
|
||||||
|
md: [
|
||||||
|
{
|
||||||
|
tokens: MarkdownAST;
|
||||||
|
mentions: object[];
|
||||||
|
}
|
||||||
|
];
|
||||||
getCustomEmoji: Function;
|
getCustomEmoji: Function;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
username: string;
|
username: string;
|
||||||
|
@ -39,6 +46,9 @@ interface IMarkdownProps {
|
||||||
_id: number;
|
_id: number;
|
||||||
}[];
|
}[];
|
||||||
mentions: object[];
|
mentions: object[];
|
||||||
|
user: {
|
||||||
|
enableMessageParserEarlyAdoption: boolean;
|
||||||
|
};
|
||||||
navToRoomInfo: Function;
|
navToRoomInfo: Function;
|
||||||
preview: boolean;
|
preview: boolean;
|
||||||
theme: string;
|
theme: string;
|
||||||
|
@ -351,7 +361,7 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.enableMessageParserEarlyAdoption && md) {
|
if (user.enableMessageParserEarlyAdoption && md) {
|
||||||
return <MessageBody tokens={md} style={style} mentions={mentions} channels={channels} navToRoomInfo={navToRoomInfo} />;
|
return <NewMarkdown tokens={md} style={style} mentions={mentions} channels={channels} navToRoomInfo={navToRoomInfo} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
let m = formatText(msg);
|
let m = formatText(msg);
|
||||||
|
@ -385,7 +395,7 @@ class Markdown extends PureComponent<IMarkdownProps, any> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = (state: any) => ({
|
||||||
user: getUserSelector(state)
|
user: getUserSelector(state)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { StyleSheet, View } from 'react-native';
|
||||||
|
import { BigEmoji as BigEmojiProps } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
|
import Emoji from './Emoji';
|
||||||
|
|
||||||
|
interface IBigEmojiProps {
|
||||||
|
value: BigEmojiProps['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flexDirection: 'row'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const BigEmoji: FC<IBigEmojiProps> = ({ value }) => (
|
||||||
|
<View style={styles.container}>
|
||||||
|
{value.map(block => (
|
||||||
|
<Emoji emojiHandle={`:${block.value.value}:`} isBigEmoji />
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default BigEmoji;
|
|
@ -1,28 +1,32 @@
|
||||||
/* eslint-disable react/no-array-index-key */
|
/* eslint-disable react/no-array-index-key */
|
||||||
import React from 'react';
|
import React, { FC } from 'react';
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import { Bold as BoldProps } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
import Strike from './Strike';
|
import Strike from './Strike';
|
||||||
import Italic from './Italic';
|
import Italic from './Italic';
|
||||||
import Plain from './Plain';
|
import Plain from './Plain';
|
||||||
|
|
||||||
|
interface IBoldProps {
|
||||||
|
value: BoldProps['value'];
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
text: {
|
text: {
|
||||||
fontWeight: 'bold'
|
fontWeight: 'bold'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Bold = ({ value }) => (
|
const Bold: FC<IBoldProps> = ({ value }) => (
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
{value.map((block, index) => {
|
{value.map(block => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return <Plain value={block.value} />;
|
return <Plain value={block.value} />;
|
||||||
case 'STRIKE':
|
case 'STRIKE':
|
||||||
return <Strike key={index} value={block.value} />;
|
return <Strike value={block.value} />;
|
||||||
case 'ITALIC':
|
case 'ITALIC':
|
||||||
return <Italic key={index} value={block.value} />;
|
return <Italic value={block.value} />;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +34,4 @@ const Bold = ({ value }) => (
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
Bold.propTypes = {
|
|
||||||
value: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Bold;
|
export default Bold;
|
|
@ -3,15 +3,12 @@ import React from 'react';
|
||||||
import { Text } from 'react-native';
|
import { Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import CodeLine from './CodeLine';
|
|
||||||
import styles from '../styles';
|
import styles from '../styles';
|
||||||
|
|
||||||
import { themes } from '../../../constants/colors';
|
import { themes } from '../../../constants/colors';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
|
import CodeLine from './CodeLine';
|
||||||
|
|
||||||
const Code = ({
|
const Code = ({ value, style }) => {
|
||||||
value, style
|
|
||||||
}) => {
|
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -24,8 +21,7 @@ const Code = ({
|
||||||
borderColor: themes[theme].borderColor
|
borderColor: themes[theme].borderColor
|
||||||
},
|
},
|
||||||
...style
|
...style
|
||||||
]}
|
]}>
|
||||||
>
|
|
||||||
{value.map((block, index) => {
|
{value.map((block, index) => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'CODE_LINE':
|
case 'CODE_LINE':
|
|
@ -2,9 +2,7 @@ import React from 'react';
|
||||||
import { Text } from 'react-native';
|
import { Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
const CodeLine = ({ value }) => (
|
const CodeLine = ({ value }) => <Text>{value.type === 'PLAIN_TEXT' && value.value}</Text>;
|
||||||
<Text>{value.type === 'PLAIN_TEXT' && value.value}</Text>
|
|
||||||
);
|
|
||||||
|
|
||||||
CodeLine.propTypes = {
|
CodeLine.propTypes = {
|
||||||
value: PropTypes.object
|
value: PropTypes.object
|
|
@ -11,15 +11,7 @@ const Emoji = ({ emojiHandle, style, isBigEmoji }) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const emojiUnicode = shortnameToUnicode(emojiHandle);
|
const emojiUnicode = shortnameToUnicode(emojiHandle);
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text style={[{ color: themes[theme].bodyText }, isBigEmoji ? styles.textBig : styles.text, style]}>{emojiUnicode}</Text>
|
||||||
style={[
|
|
||||||
{ color: themes[theme].bodyText },
|
|
||||||
isBigEmoji ? styles.textBig : styles.text,
|
|
||||||
style
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{emojiUnicode}
|
|
||||||
</Text>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,18 +7,14 @@ import { useTheme } from '../../../theme';
|
||||||
|
|
||||||
const Heading = ({ value, level }) => {
|
const Heading = ({ value, level }) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const textStyle = styles[`heading${ level }`];
|
const textStyle = styles[`heading${level}`];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{value.map((block) => {
|
{value.map(block => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return (
|
return <Text style={[textStyle, { color: themes[theme].bodyText }]}>{block.value}</Text>;
|
||||||
<Text style={[textStyle, { color: themes[theme].bodyText }]}>
|
|
||||||
{block.value}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@ import React from 'react';
|
||||||
import { Text } from 'react-native';
|
import { Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import Hashtag from '../Hashtag';
|
||||||
|
|
||||||
import Link from './Link';
|
import Link from './Link';
|
||||||
import Plain from './Plain';
|
import Plain from './Plain';
|
||||||
import Bold from './Bold';
|
import Bold from './Bold';
|
||||||
|
@ -10,14 +12,10 @@ import Italic from './Italic';
|
||||||
import Emoji from './Emoji';
|
import Emoji from './Emoji';
|
||||||
import Mention from './Mention';
|
import Mention from './Mention';
|
||||||
import InlineCode from './InlineCode';
|
import InlineCode from './InlineCode';
|
||||||
import Hashtag from '../Hashtag';
|
|
||||||
|
|
||||||
|
const Inline = ({ value, mentions, channels, navToRoomInfo, style }) => (
|
||||||
const Inline = ({
|
|
||||||
value, mentions, channels, navToRoomInfo, style
|
|
||||||
}) => (
|
|
||||||
<Text>
|
<Text>
|
||||||
{value.map((block) => {
|
{value.map(block => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return <Plain value={block.value} />;
|
return <Plain value={block.value} />;
|
||||||
|
@ -33,7 +31,7 @@ const Inline = ({
|
||||||
case 'MENTION_USER':
|
case 'MENTION_USER':
|
||||||
return <Mention value={block.value} navToRoomInfo={navToRoomInfo} mentions={mentions} style={style} />;
|
return <Mention value={block.value} navToRoomInfo={navToRoomInfo} mentions={mentions} style={style} />;
|
||||||
case 'EMOJI':
|
case 'EMOJI':
|
||||||
return <Emoji emojiHandle={`:${ block.value.value }:`} />;
|
return <Emoji emojiHandle={`:${block.value.value}:`} />;
|
||||||
case 'MENTION_CHANNEL':
|
case 'MENTION_CHANNEL':
|
||||||
return <Hashtag hashtag={block.value.value} navToRoomInfo={navToRoomInfo} channels={channels} style={style} />;
|
return <Hashtag hashtag={block.value.value} navToRoomInfo={navToRoomInfo} channels={channels} style={style} />;
|
||||||
case 'INLINE_CODE':
|
case 'INLINE_CODE':
|
|
@ -10,7 +10,8 @@ const InlineCode = ({ value, style }) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text style={[
|
<Text
|
||||||
|
style={[
|
||||||
{
|
{
|
||||||
...styles.codeInline,
|
...styles.codeInline,
|
||||||
color: themes[theme].bodyText,
|
color: themes[theme].bodyText,
|
||||||
|
@ -18,9 +19,8 @@ const InlineCode = ({ value, style }) => {
|
||||||
borderColor: themes[theme].borderColor
|
borderColor: themes[theme].borderColor
|
||||||
},
|
},
|
||||||
...style
|
...style
|
||||||
]}
|
]}>
|
||||||
>
|
{(block => {
|
||||||
{((block) => {
|
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return block.value;
|
return block.value;
|
|
@ -1,19 +1,23 @@
|
||||||
/* eslint-disable react/no-array-index-key */
|
/* eslint-disable react/no-array-index-key */
|
||||||
import React from 'react';
|
import React, { FC } from 'react';
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import { Italic as ItalicProps } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
import Strike from './Strike';
|
import Strike from './Strike';
|
||||||
import Bold from './Bold';
|
import Bold from './Bold';
|
||||||
import Plain from './Plain';
|
import Plain from './Plain';
|
||||||
|
|
||||||
|
interface IItalicProps {
|
||||||
|
value: ItalicProps['value'];
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
text: {
|
text: {
|
||||||
fontStyle: 'italic'
|
fontStyle: 'italic'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Italic = ({ value }) => (
|
const Italic: FC<IItalicProps> = ({ value }) => (
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
{value.map((block, index) => {
|
{value.map((block, index) => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
|
@ -30,8 +34,4 @@ const Italic = ({ value }) => (
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
Italic.propTypes = {
|
|
||||||
value: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Italic;
|
export default Italic;
|
|
@ -2,9 +2,6 @@ import React from 'react';
|
||||||
import { Text, Clipboard } from 'react-native';
|
import { Text, Clipboard } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import Strike from './Strike';
|
|
||||||
import Italic from './Italic';
|
|
||||||
import Bold from './Bold';
|
|
||||||
import styles from '../styles';
|
import styles from '../styles';
|
||||||
import I18n from '../../../i18n';
|
import I18n from '../../../i18n';
|
||||||
import { LISTENER } from '../../Toast';
|
import { LISTENER } from '../../Toast';
|
||||||
|
@ -13,6 +10,10 @@ import openLink from '../../../utils/openLink';
|
||||||
import EventEmitter from '../../../utils/events';
|
import EventEmitter from '../../../utils/events';
|
||||||
import { themes } from '../../../constants/colors';
|
import { themes } from '../../../constants/colors';
|
||||||
|
|
||||||
|
import Strike from './Strike';
|
||||||
|
import Italic from './Italic';
|
||||||
|
import Bold from './Bold';
|
||||||
|
|
||||||
const Link = ({ value }) => {
|
const Link = ({ value }) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const { src, label } = value;
|
const { src, label } = value;
|
||||||
|
@ -29,12 +30,8 @@ const Link = ({ value }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text onPress={handlePress} onLongPress={onLongPress} style={{ ...styles.link, color: themes[theme].actionTintColor }}>
|
||||||
onPress={handlePress}
|
{(block => {
|
||||||
onLongPress={onLongPress}
|
|
||||||
style={{ ...styles.link, color: themes[theme].actionTintColor }}
|
|
||||||
>
|
|
||||||
{((block) => {
|
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return block.value;
|
return block.value;
|
|
@ -7,9 +7,7 @@ import { events, logEvent } from '../../../utils/log';
|
||||||
import { useTheme } from '../../../theme';
|
import { useTheme } from '../../../theme';
|
||||||
import { themes } from '../../../constants/colors';
|
import { themes } from '../../../constants/colors';
|
||||||
|
|
||||||
const Mention = ({
|
const Mention = ({ value: mention, mentions, navToRoomInfo, style }) => {
|
||||||
value: mention, mentions, navToRoomInfo, style
|
|
||||||
}) => {
|
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
let mentionStyle = [];
|
let mentionStyle = [];
|
||||||
const notMentionedStyle = [styles.text, { color: themes[theme].bodyText }, ...style];
|
const notMentionedStyle = [styles.text, { color: themes[theme].bodyText }, ...style];
|
||||||
|
@ -43,10 +41,14 @@ const Mention = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
style={[styles.mention, (mention || mentionedUser) && mentionStyle, !(mention || mentionedUser) && notMentionedStyle, ...style]}
|
style={[
|
||||||
onPress={handlePress}
|
styles.mention,
|
||||||
>
|
(mention || mentionedUser) && mentionStyle,
|
||||||
{mentionedUser ? mentionedUser.name || mention.value : `@{${ mention }}` }
|
!(mention || mentionedUser) && notMentionedStyle,
|
||||||
|
...style
|
||||||
|
]}
|
||||||
|
onPress={handlePress}>
|
||||||
|
{mentionedUser ? mentionedUser.name || mention.value : `@{${mention}}`}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import Inline from './Inline';
|
import Inline from './Inline';
|
||||||
|
|
||||||
const Paragraph = ({
|
const Paragraph = ({ value, mentions, channels, navToRoomInfo, style }) => (
|
||||||
value, mentions, channels, navToRoomInfo, style
|
<Inline value={value} mentions={mentions} channels={channels} navToRoomInfo={navToRoomInfo} style={style} />
|
||||||
}) => <Inline value={value} mentions={mentions} channels={channels} navToRoomInfo={navToRoomInfo} style={style} />;
|
);
|
||||||
|
|
||||||
Paragraph.propTypes = {
|
Paragraph.propTypes = {
|
||||||
value: PropTypes.string,
|
value: PropTypes.string,
|
|
@ -0,0 +1,11 @@
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { Text } from 'react-native';
|
||||||
|
import { Plain as PlainProps } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
|
interface IPlainProps {
|
||||||
|
value: PlainProps['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
const Plain: FC<IPlainProps> = ({ value }) => <Text accessibilityLabel={value}>{value}</Text>;
|
||||||
|
|
||||||
|
export default Plain;
|
|
@ -1,28 +1,32 @@
|
||||||
/* eslint-disable react/no-array-index-key */
|
/* eslint-disable react/no-array-index-key */
|
||||||
import React from 'react';
|
import React, { FC } from 'react';
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import { Strike as StrikeProps } from '@rocket.chat/message-parser';
|
||||||
|
|
||||||
import Bold from './Bold';
|
import Bold from './Bold';
|
||||||
import Italic from './Italic';
|
import Italic from './Italic';
|
||||||
import Plain from './Plain';
|
import Plain from './Plain';
|
||||||
|
|
||||||
|
interface IStrikeProps {
|
||||||
|
value: StrikeProps['value'];
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
text: {
|
text: {
|
||||||
textDecorationLine: 'line-through'
|
textDecorationLine: 'line-through'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Strike = ({ value }) => (
|
const Strike: FC<IStrikeProps> = ({ value }) => (
|
||||||
<Text style={styles.text}>
|
<Text style={styles.text}>
|
||||||
{value.map((block, index) => {
|
{value.map(block => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'PLAIN_TEXT':
|
case 'PLAIN_TEXT':
|
||||||
return <Plain key={index} value={block.value} />;
|
return <Plain value={block.value} />;
|
||||||
case 'BOLD':
|
case 'BOLD':
|
||||||
return <Bold key={index} value={block.value} />;
|
return <Bold value={block.value} />;
|
||||||
case 'ITALIC':
|
case 'ITALIC':
|
||||||
return <Italic key={index} value={block.value} />;
|
return <Italic value={block.value} />;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +34,4 @@ const Strike = ({ value }) => (
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|
||||||
Strike.propTypes = {
|
|
||||||
value: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Strike;
|
export default Strike;
|
|
@ -13,9 +13,7 @@ import UnorderedList from './UnorderedList';
|
||||||
|
|
||||||
const isBigEmoji = tokens => tokens.length === 1 && tokens[0].type === 'BIG_EMOJI';
|
const isBigEmoji = tokens => tokens.length === 1 && tokens[0].type === 'BIG_EMOJI';
|
||||||
|
|
||||||
const Body = ({
|
const Body = ({ tokens, mentions, channels, navToRoomInfo, style }) => {
|
||||||
tokens, mentions, channels, navToRoomInfo, style
|
|
||||||
}) => {
|
|
||||||
if (isBigEmoji(tokens)) {
|
if (isBigEmoji(tokens)) {
|
||||||
return <BigEmoji value={tokens[0].value} />;
|
return <BigEmoji value={tokens[0].value} />;
|
||||||
}
|
}
|
|
@ -47,6 +47,7 @@
|
||||||
"@react-navigation/drawer": "5.12.5",
|
"@react-navigation/drawer": "5.12.5",
|
||||||
"@react-navigation/native": "5.9.4",
|
"@react-navigation/native": "5.9.4",
|
||||||
"@react-navigation/stack": "5.14.5",
|
"@react-navigation/stack": "5.14.5",
|
||||||
|
"@rocket.chat/message-parser": "^0.29.0",
|
||||||
"@rocket.chat/react-native-fast-image": "^8.2.0",
|
"@rocket.chat/react-native-fast-image": "^8.2.0",
|
||||||
"@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile",
|
"@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile",
|
||||||
"@rocket.chat/ui-kit": "0.13.0",
|
"@rocket.chat/ui-kit": "0.13.0",
|
||||||
|
|
|
@ -3203,6 +3203,11 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
eslint-plugin-import "^2.17.2"
|
eslint-plugin-import "^2.17.2"
|
||||||
|
|
||||||
|
"@rocket.chat/message-parser@^0.29.0":
|
||||||
|
version "0.29.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@rocket.chat/message-parser/-/message-parser-0.29.0.tgz#9577f354756653e6271b9fe2290fadafcb5d4293"
|
||||||
|
integrity sha512-2qEPTNSHeWRCFfxCETqz9Asju6bf5dR98+AQUYwNus5911WW4tuehvrfvoqLYrlYqs4w5Qj6q9m2THCXqN27Gw==
|
||||||
|
|
||||||
"@rocket.chat/react-native-fast-image@^8.2.0":
|
"@rocket.chat/react-native-fast-image@^8.2.0":
|
||||||
version "8.2.0"
|
version "8.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.2.0.tgz#4f48858f95f40afcb10b39cee9b1239c150d6c51"
|
resolved "https://registry.yarnpkg.com/@rocket.chat/react-native-fast-image/-/react-native-fast-image-8.2.0.tgz#4f48858f95f40afcb10b39cee9b1239c150d6c51"
|
||||||
|
|
Loading…
Reference in New Issue