Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/containers/markdown/AtMention.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Text } from 'react-native';
import styles from './styles';

const AtMention = React.memo(({
mention, mentions, username, navToRoomInfo, style = []
mention, mentions, username, navToRoomInfo, preview, style = []
}) => {
let mentionStyle = styles.mention;
if (mention === 'all' || mention === 'here') {
Expand Down Expand Up @@ -33,8 +33,8 @@ const AtMention = React.memo(({

return (
<Text
style={[mentionStyle, ...style]}
onPress={handlePress}
style={[preview ? styles.text : mentionStyle, ...style]}
onPress={preview ? undefined : handlePress}
>
{`@${ mention }`}
</Text>
Expand All @@ -46,6 +46,7 @@ AtMention.propTypes = {
username: PropTypes.string,
navToRoomInfo: PropTypes.func,
style: PropTypes.array,
preview: PropTypes.bool,
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
};

Expand Down
7 changes: 4 additions & 3 deletions app/containers/markdown/Hashtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Text } from 'react-native';
import styles from './styles';

const Hashtag = React.memo(({
hashtag, channels, navToRoomInfo, style = []
hashtag, channels, navToRoomInfo, preview, style = []
}) => {
const handlePress = () => {
const index = channels.findIndex(channel => channel.name === hashtag);
Expand All @@ -19,8 +19,8 @@ const Hashtag = React.memo(({
if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) {
return (
<Text
style={[styles.mention, ...style]}
onPress={handlePress}
style={[preview ? styles.text : styles.mention, ...style]}
onPress={preview ? undefined : handlePress}
>
{`#${ hashtag }`}
</Text>
Expand All @@ -33,6 +33,7 @@ Hashtag.propTypes = {
hashtag: PropTypes.string,
navToRoomInfo: PropTypes.func,
style: PropTypes.array,
preview: PropTypes.bool,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
};

Expand Down
7 changes: 4 additions & 3 deletions app/containers/markdown/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './styles';
import openLink from '../../utils/openLink';

const Link = React.memo(({
children, link
children, link, preview
}) => {
const handlePress = () => {
if (!link) {
Expand All @@ -20,7 +20,7 @@ const Link = React.memo(({
// if you have a [](https://rocket.chat) render https://rocket.chat
return (
<Text
onPress={handlePress}
onPress={preview ? undefined : handlePress}
style={styles.link}
>
{ childLength !== 0 ? children : link }
Expand All @@ -30,7 +30,8 @@ const Link = React.memo(({

Link.propTypes = {
children: PropTypes.node,
link: PropTypes.string
link: PropTypes.string,
preview: PropTypes.bool
};

export default Link;
37 changes: 25 additions & 12 deletions app/containers/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,41 @@ export default class Markdown extends PureComponent {
);
};

renderLink = ({ children, href }) => (
<MarkdownLink link={href}>
{children}
</MarkdownLink>
);
renderLink = ({ children, href }) => {
const { preview } = this.props;
return (
<MarkdownLink link={href} preview={preview}>
{children}
</MarkdownLink>
);
}

renderHashtag = ({ hashtag }) => {
const { channels, navToRoomInfo, style } = this.props;
const {
channels, navToRoomInfo, style, preview
} = this.props;
return (
<MarkdownHashtag
hashtag={hashtag}
channels={channels}
navToRoomInfo={navToRoomInfo}
preview={preview}
style={style}
/>
);
}

renderAtMention = ({ mentionName }) => {
const {
username, mentions, navToRoomInfo, style
username, mentions, navToRoomInfo, preview, style
} = this.props;
return (
<MarkdownAtMention
mentions={mentions}
mention={mentionName}
username={username}
navToRoomInfo={navToRoomInfo}
preview={preview}
style={style}
/>
);
Expand Down Expand Up @@ -275,11 +282,17 @@ export default class Markdown extends PureComponent {
);
};

renderBlockQuote = ({ children }) => (
<MarkdownBlockQuote>
{children}
</MarkdownBlockQuote>
);
renderBlockQuote = ({ children }) => {
const { preview } = this.props;
if (preview) {
return children;
}
return (
<MarkdownBlockQuote>
{children}
</MarkdownBlockQuote>
);
}

renderTable = ({ children, numColumns }) => (
<MarkdownTable numColumns={numColumns}>
Expand Down