Add markdown and emoji support

This commit is contained in:
Rodrigo Nascimento 2017-08-10 11:27:28 -03:00
parent 4c5adc5dc9
commit 038e28c40b
3 changed files with 9 additions and 7 deletions

View File

@ -2,6 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { View, Text, StyleSheet } from 'react-native'; import { View, Text, StyleSheet } from 'react-native';
import { CachedImage } from 'react-native-img-cache'; import { CachedImage } from 'react-native-img-cache';
import Markdown from 'react-native-easy-markdown';
import { emojify } from 'react-emojione';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
message: { message: {
@ -46,6 +48,8 @@ export default class Message extends React.PureComponent {
extraStyle.opacity = 0.3; extraStyle.opacity = 0.3;
} }
const msg = emojify(this.props.item.msg || 'asd', { output: 'unicode' });
return ( return (
<View style={[styles.message, extraStyle]}> <View style={[styles.message, extraStyle]}>
<View style={styles.avatarContainer}> <View style={styles.avatarContainer}>
@ -55,12 +59,9 @@ export default class Message extends React.PureComponent {
<Text onPress={this._onPress} style={styles.username}> <Text onPress={this._onPress} style={styles.username}>
{this.props.item.u.username} {this.props.item.u.username}
</Text> </Text>
<Text style={styles.msg}> <Markdown>
{this.props.item.msg} {msg}
</Text> </Markdown>
{/* <Markdown whitelist={['link', 'url']}>
{this.props.item.msg}
</Markdown> */}
</View> </View>
</View> </View>
); );

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text, View, FlatList, StyleSheet } from 'react-native'; import { Text, View, FlatList, StyleSheet } from 'react-native';
// import Markdown from 'react-native-simple-markdown';
import realm from '../lib/realm'; import realm from '../lib/realm';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';

View File

@ -13,7 +13,9 @@
"dependencies": { "dependencies": {
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"react": "16.0.0-alpha.12", "react": "16.0.0-alpha.12",
"react-emojione": "^3.1.10",
"react-native": "0.46.1", "react-native": "0.46.1",
"react-native-easy-markdown": "git+https://github.com/lappalj4/react-native-easy-markdown.git",
"react-native-fetch-blob": "^0.10.8", "react-native-fetch-blob": "^0.10.8",
"react-native-img-cache": "^1.4.0", "react-native-img-cache": "^1.4.0",
"react-native-meteor": "^1.1.0", "react-native-meteor": "^1.1.0",