Skip to content

Commit

Permalink
chore: Use @rocket.chat/message-parser instead of Commonmark (#6080)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Mello <[email protected]>
  • Loading branch information
OtavioStasiak and diegolmello authored Jan 22, 2025
1 parent 7fa6ddc commit acc0301
Show file tree
Hide file tree
Showing 70 changed files with 264 additions and 1,931 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ We use [Jest](https://jestjs.io/) and [Storybook](https://storybook.js.org/) on

Storybook is a tool for developing UI Components and has some plugins to make Jest generate snapshots of them.

[On the root of the project](https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/index.js#L24), comment everything leaving only the last import to Storybook left and refresh your project.
To open the Storybook, run yarn `storybook:start`, and then use `yarn android` or `yarn ios` to launch it on your desired platform.

You'll see some tests like this:

<img src="https://user-images.githubusercontent.com/804994/89677725-56393200-d8c4-11ea-84b0-213be1d24e98.png" width="350" />
Expand Down
12 changes: 10 additions & 2 deletions app/containers/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import FastImage from 'react-native-fast-image';
import Touchable from 'react-native-platform-touchable';
import { settings as RocketChatSettings } from '@rocket.chat/sdk';

import Emoji from '../markdown/components/emoji/Emoji';
import { getAvatarURL } from '../../lib/methods/helpers/getAvatarUrl';
import { SubscriptionType } from '../../definitions';
import Emoji from '../markdown/Emoji';
import { IAvatar } from './interfaces';
import MarkdownContext from '../markdown/contexts/MarkdownContext';
import I18n from '../../i18n';

const Avatar = React.memo(
Expand Down Expand Up @@ -48,7 +49,14 @@ const Avatar = React.memo(

let image;
if (emoji) {
image = <Emoji getCustomEmoji={getCustomEmoji} isMessageContainsOnlyEmoji literal={emoji} style={avatarStyle} />;
image = (
<MarkdownContext.Provider
value={{
getCustomEmoji
}}>
<Emoji block={{ type: 'EMOJI', value: { type: 'PLAIN_TEXT', value: emoji }, shortCode: emoji }} style={avatarStyle} />
</MarkdownContext.Provider>
);
} else {
let uri = avatar;
if (!isStatic) {
Expand Down
8 changes: 3 additions & 5 deletions app/containers/CollapsibleText/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { TextStyle, Text, StyleSheet } from 'react-native';

import sharedStyles from '../../views/Styles';
import { useTheme } from '../../theme';
import { previewFormatText } from '../markdown/previewFormatText';
import I18n from '../../i18n';
import { previewFormatText } from '../../lib/helpers/previewFormatText';

interface ICollapsibleText {
msg?: string;
Expand Down Expand Up @@ -67,15 +67,13 @@ const CollapsibleText = ({ msg, style = [], linesToTruncate = 1 }: ICollapsibleT
} else {
setShowTruncated(false);
}
}}
>
}}>
{m}
{truncatedText ? (
<Text
testID='collapsible-text-show-less'
onPress={() => setShowTruncated(true)}
style={[styles.textInfo, { color: colors.fontHint }]}
>
style={[styles.textInfo, { color: colors.fontHint }]}>
{` ${I18n.t('Show_less')}`}
</Text>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion app/containers/UIKit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MessageParser extends UiKitParserMessage<React.ReactElement> {
<MarkdownPreview msg={element.text} style={[isContext && { color: themes[theme].fontSecondaryInfo }]} numberOfLines={0} />
);
}
return <Markdown msg={element.text} theme={theme} style={[isContext && { color: themes[theme].fontSecondaryInfo }]} />;
return <Markdown msg={element.text} style={[isContext && { color: themes[theme].fontSecondaryInfo }]} />;
}

button(element: IButton, context: BlockContext) {
Expand Down
20 changes: 0 additions & 20 deletions app/containers/markdown/BlockQuote.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions app/containers/markdown/Emoji.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions app/containers/markdown/Link.tsx

This file was deleted.

37 changes: 0 additions & 37 deletions app/containers/markdown/List.tsx

This file was deleted.

54 changes: 0 additions & 54 deletions app/containers/markdown/ListItem.tsx

This file was deleted.

Loading

0 comments on commit acc0301

Please sign in to comment.