Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added changes to fix the markdown for mention user #5367

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
15 changes: 14 additions & 1 deletion app/containers/markdown/new/Bold.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import { StyleSheet, Text } from 'react-native';
import { Bold as BoldProps } from '@rocket.chat/message-parser';

Expand All @@ -7,6 +7,8 @@ import Strike from './Strike';
import Italic from './Italic';
import Plain from './Plain';
import Link from './Link';
import AtMention from '../AtMention';
import MarkdownContext from './MarkdownContext';

interface IBoldProps {
value: BoldProps['value'];
Expand All @@ -21,6 +23,7 @@ const styles = StyleSheet.create({
const Bold = ({ value }: IBoldProps) => (
<Text style={styles.text}>
{value.map(block => {
const { useRealName, username, navToRoomInfo, mentions} = useContext(MarkdownContext);
switch (block.type) {
case 'LINK':
return <Link value={block.value} />;
Expand All @@ -32,6 +35,16 @@ const Bold = ({ value }: IBoldProps) => (
return <Italic value={block.value} />;
case 'MENTION_CHANNEL':
return <Plain value={`#${block.value.value}`} />;
case 'MENTION_USER':
return (
<AtMention
mention={block.value.value}
useRealName={useRealName}
username={username}
navToRoomInfo={navToRoomInfo}
mentions={mentions}
/>
);
default:
return null;
}
Expand Down
15 changes: 14 additions & 1 deletion app/containers/markdown/new/Italic.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, { useContext } from 'react';
import { StyleSheet, Text } from 'react-native';
import { Italic as ItalicProps } from '@rocket.chat/message-parser';

import Strike from './Strike';
import Bold from './Bold';
import Plain from './Plain';
import Link from './Link';
import MarkdownContext from './MarkdownContext';
import AtMention from '../AtMention';

interface IItalicProps {
value: ItalicProps['value'];
Expand All @@ -20,6 +22,7 @@ const styles = StyleSheet.create({
const Italic = ({ value }: IItalicProps) => (
<Text style={styles.text}>
{value.map(block => {
const { useRealName, username, navToRoomInfo, mentions} = useContext(MarkdownContext);
switch (block.type) {
case 'LINK':
return <Link value={block.value} />;
Expand All @@ -31,6 +34,16 @@ const Italic = ({ value }: IItalicProps) => (
return <Bold value={block.value} />;
case 'MENTION_CHANNEL':
return <Plain value={`#${block.value.value}`} />;
case 'MENTION_USER':
return (
<AtMention
mention={block.value.value}
useRealName={useRealName}
username={username}
navToRoomInfo={navToRoomInfo}
mentions={mentions}
/>
);
default:
return null;
}
Expand Down
15 changes: 14 additions & 1 deletion app/containers/markdown/new/Strike.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, { useContext } from 'react';
import { StyleSheet, Text } from 'react-native';
import { Strike as StrikeProps } from '@rocket.chat/message-parser';

import Bold from './Bold';
import Italic from './Italic';
import Plain from './Plain';
import Link from './Link';
import AtMention from '../AtMention';
import MarkdownContext from './MarkdownContext';

interface IStrikeProps {
value: StrikeProps['value'];
Expand All @@ -20,6 +22,7 @@ const styles = StyleSheet.create({
const Strike = ({ value }: IStrikeProps) => (
<Text style={styles.text}>
{value.map(block => {
const { useRealName, username, navToRoomInfo, mentions} = useContext(MarkdownContext);
switch (block.type) {
case 'LINK':
return <Link value={block.value} />;
Expand All @@ -31,6 +34,16 @@ const Strike = ({ value }: IStrikeProps) => (
return <Italic value={block.value} />;
case 'MENTION_CHANNEL':
return <Plain value={`#${block.value.value}`} />;
case 'MENTION_USER':
return (
<AtMention
mention={block.value.value}
useRealName={useRealName}
username={username}
navToRoomInfo={navToRoomInfo}
mentions={mentions}
/>
);
default:
return null;
}
Expand Down