From 32a681036ea437da9704cba6545ea00ad0e23dbd Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 16 Sep 2019 17:50:51 -0300 Subject: [PATCH] [CHORE] Use JoyPixels (#1164) * react-emojione -> emoji-toolkit * Change to toUnicode() * Fix ascii emoji on joypixels * Revert unnecessary modify * Fix some emojis * Fix custom emojis (Android) * Update Snapshot --- .../__snapshots__/Storyshots.test.js.snap | 6728 ++++++++--------- app/containers/EmojiPicker/EmojiCategory.js | 4 +- app/containers/EmojiPicker/index.js | 6 +- app/containers/MessageBox/index.js | 4 +- app/containers/markdown/Emoji.js | 4 +- app/containers/markdown/index.js | 12 +- app/containers/message/Emoji.js | 4 +- app/containers/message/RepliedThread.js | 4 +- app/presentation/RoomItem/LastMessage.js | 4 +- app/views/RoomView/Header/Header.js | 4 +- index.js | 3 + package.json | 2 +- patches/emoji-toolkit+5.0.4.patch | 35 + yarn.lock | 10 +- 14 files changed, 3265 insertions(+), 3559 deletions(-) create mode 100644 patches/emoji-toolkit+5.0.4.patch diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index 332732a14..831f2b7e8 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -211,31 +211,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -441,31 +437,27 @@ exports[`Storyshots Message list 1`] = ` > - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -671,31 +663,27 @@ exports[`Storyshots Message list 1`] = ` > - - ... - + ... @@ -883,31 +871,27 @@ exports[`Storyshots Message list 1`] = ` > - - Different user - + Different user @@ -977,31 +961,27 @@ exports[`Storyshots Message list 1`] = ` > - - This is the third message - + This is the third message @@ -1071,31 +1051,27 @@ exports[`Storyshots Message list 1`] = ` > - - This is the second message - + This is the second message @@ -1283,31 +1259,27 @@ exports[`Storyshots Message list 1`] = ` > - - This is the first message - + This is the first message @@ -1395,31 +1367,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -1639,31 +1607,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -1865,31 +1829,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -2095,31 +2055,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -2350,32 +2306,28 @@ exports[`Storyshots Message list 1`] = ` > - - Testing block quote - + Testing block quote @@ -2590,32 +2542,28 @@ exports[`Storyshots Message list 1`] = ` > - - Testing block quote - + Testing block quote @@ -2631,31 +2579,27 @@ exports[`Storyshots Message list 1`] = ` > - - Testing block quote - + Testing block quote @@ -2893,33 +2837,29 @@ exports[`Storyshots Message list 1`] = ` > - - Dogs - + Dogs - - cats - + cats @@ -3041,35 +2977,31 @@ exports[`Storyshots Message list 1`] = ` > - - cats - + cats @@ -3311,33 +3243,29 @@ exports[`Storyshots Message list 1`] = ` > - - Dogs - + Dogs @@ -3385,33 +3313,29 @@ exports[`Storyshots Message list 1`] = ` > - - Cats - + Cats @@ -3651,33 +3575,29 @@ exports[`Storyshots Message list 1`] = ` > - - Dogs - + Dogs @@ -3781,33 +3701,29 @@ exports[`Storyshots Message list 1`] = ` > - - Cats - + Cats @@ -4015,31 +3931,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -4245,31 +4157,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -4474,179 +4382,175 @@ exports[`Storyshots Message list 1`] = ` } > - + - @rocket.cat - - - - - + + + + @diego.mello + + - @diego.mello - - - - - + + + + @all + + - @all - - - - - + + + + @here + + - @here - - - - - + + + - #general - + } + > + #general @@ -4852,31 +4756,27 @@ exports[`Storyshots Message list 1`] = ` > - - 👊🤙👏 - + 👊🤙👏 @@ -5082,31 +4982,27 @@ exports[`Storyshots Message list 1`] = ` > - - 👏 - + 👏 @@ -5310,97 +5206,93 @@ exports[`Storyshots Message list 1`] = ` } } > + - - - - - - - - - + + + + + + @@ -5603,23 +5495,19 @@ exports[`Storyshots Message list 1`] = ` } } > - - - + } + /> @@ -5824,45 +5712,41 @@ exports[`Storyshots Message list 1`] = ` > - - 🤙 - - + 🤙 + @@ -6067,68 +5951,64 @@ exports[`Storyshots Message list 1`] = ` > - + - 🤙 - - + - - 🤙🤙 - + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + 🤙🤙 @@ -6334,31 +6214,27 @@ exports[`Storyshots Message list 1`] = ` > - - Testing - + Testing @@ -6564,31 +6440,27 @@ exports[`Storyshots Message list 1`] = ` > - - Reactions - + Reactions @@ -7094,31 +6966,27 @@ exports[`Storyshots Message list 1`] = ` > - - Multiple Reactions - + Multiple Reactions @@ -7997,31 +7865,27 @@ exports[`Storyshots Message list 1`] = ` > - - Fourth message - + Fourth message @@ -8209,31 +8073,27 @@ exports[`Storyshots Message list 1`] = ` > - - Third message - + Third message @@ -8421,31 +8281,27 @@ exports[`Storyshots Message list 1`] = ` > - - Second message - + Second message @@ -8633,31 +8489,27 @@ exports[`Storyshots Message list 1`] = ` > - - First message - + First message @@ -8863,31 +8715,27 @@ exports[`Storyshots Message list 1`] = ` > - - Fourth message - + Fourth message @@ -9140,31 +8988,27 @@ exports[`Storyshots Message list 1`] = ` > - - Third message - + Third message @@ -9281,31 +9125,27 @@ exports[`Storyshots Message list 1`] = ` > - - Second message - + Second message @@ -9493,31 +9333,27 @@ exports[`Storyshots Message list 1`] = ` > - - Second message - + Second message @@ -9744,31 +9580,27 @@ exports[`Storyshots Message list 1`] = ` > - - First message - + First message @@ -10027,30 +9859,28 @@ exports[`Storyshots Message list 1`] = ` } } > - - - This is a description - + + This is a description @@ -10292,44 +10122,42 @@ exports[`Storyshots Message list 1`] = ` } } > - - - This is a description - - + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + This is a description + @@ -10580,44 +10408,42 @@ exports[`Storyshots Message list 1`] = ` } } > - - - This is a description - - + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + This is a description + @@ -11235,44 +11061,42 @@ exports[`Storyshots Message list 1`] = ` } } > - - - This is a description - - + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + This is a description + @@ -11340,31 +11164,27 @@ exports[`Storyshots Message list 1`] = ` > - - First message - + First message @@ -11628,30 +11448,28 @@ exports[`Storyshots Message list 1`] = ` } } > - - - This is a description - + + This is a description @@ -12358,79 +12176,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -12517,30 +12331,28 @@ exports[`Storyshots Message list 1`] = ` } } > - - - How are you? - + + How are you? @@ -12729,79 +12541,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -12888,44 +12696,42 @@ exports[`Storyshots Message list 1`] = ` } } > - - - How are you? - - + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + How are you? + @@ -13131,79 +12937,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -13273,79 +13075,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -13533,79 +13331,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -13697,79 +13491,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -13997,31 +13787,27 @@ exports[`Storyshots Message list 1`] = ` > - - How are you? - + How are you? @@ -14290,31 +14076,27 @@ exports[`Storyshots Message list 1`] = ` > - - How are you? - + How are you? @@ -14613,79 +14395,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -14734,7 +14512,7 @@ exports[`Storyshots Message list 1`] = ` "marginTop": 6, } } - testID="message-thread-replied-on-Thread with emoji 🙂 😂" + testID="message-thread-replied-on-Thread with emoji :) 😂" > - Thread with emoji 🙂 😂 + Thread with emoji :) 😂 - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -15193,79 +14967,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -15483,79 +15253,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -15773,31 +15539,27 @@ exports[`Storyshots Message list 1`] = ` > - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -16015,31 +15777,27 @@ exports[`Storyshots Message list 1`] = ` > - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -16462,31 +16220,27 @@ exports[`Storyshots Message list 1`] = ` > - - How are you? - + How are you? @@ -16710,79 +16464,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -16925,31 +16675,27 @@ exports[`Storyshots Message list 1`] = ` > - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -17327,79 +17073,75 @@ exports[`Storyshots Message list 1`] = ` > - - I - - - 'm fine - - - ! - + I + + + 'm fine + + + ! @@ -17542,55 +17284,51 @@ exports[`Storyshots Message list 1`] = ` > - - Cool - - - ! - + Cool + + + ! @@ -17733,31 +17471,27 @@ exports[`Storyshots Message list 1`] = ` > - - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. @@ -19633,45 +19367,41 @@ exports[`Storyshots Message list 1`] = ` > - - Message - - + Message + - - Message - + Message @@ -20172,30 +19898,28 @@ exports[`Storyshots Message list 1`] = ` } } > - - - Custom fields - + + Custom fields - - Message - + Message @@ -20723,30 +20443,28 @@ exports[`Storyshots Message list 1`] = ` } } > - - - Custom fields - + + Custom fields - - - Custom fields 2 - + + Custom fields 2 - - Broadcasted message - + Broadcasted message @@ -21553,31 +21265,27 @@ exports[`Storyshots Message list 1`] = ` > - - This message is inside an archived room - + This message is inside an archived room @@ -21814,31 +21522,27 @@ exports[`Storyshots Message list 1`] = ` > - - This message has error - + This message has error @@ -21988,31 +21692,27 @@ exports[`Storyshots Message list 1`] = ` > - - This message has error too - + This message has error too @@ -22223,31 +21923,27 @@ exports[`Storyshots Message list 1`] = ` > - - Temp message - + Temp message @@ -22453,31 +22149,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message being edited - + Message being edited @@ -25073,31 +24765,27 @@ exports[`Storyshots Message list 1`] = ` > - - Message - + Message @@ -25303,316 +24991,312 @@ exports[`Storyshots Message list 1`] = ` > - - Italic with single - - - underscore - - - or double - - - underscores - - - . Bold with single - - - asterisk - - - or double - - - asterisks - - - . Strikethrough with single - - - Strikethrough - - - or double - - - Strikethrough - + Italic with single + + + underscore + + + or double + + + underscores + + + . Bold with single + + + asterisk + + + or double + + + asterisks + + + . Strikethrough with single + + + Strikethrough + + + or double + + + Strikethrough @@ -26154,6 +25838,39 @@ exports[`Storyshots Message list 1`] = ` > + Support + + - Support + Google - + + + + + - - Google - + I - - - - - I - - - \` - - - m an inline-style link - + \` - + m an inline-style link - + + + + + - - https://google.com - + https://google.com @@ -26624,24 +26304,20 @@ exports[`Storyshots Message list 1`] = ` } } > - - - + } + /> @@ -26846,105 +26522,101 @@ exports[`Storyshots Message list 1`] = ` > - + - Inline - - + code + + - code - - - has - - + has + + + back-ticks around + + - back-ticks around - - - it. - + }, + Object { + "alignItems": "flex-start", + "flexDirection": "row", + "flexWrap": "wrap", + "justifyContent": "flex-start", + "marginBottom": 0, + "marginTop": 0, + }, + ] + } + > + it. - - Quote - + Quote diff --git a/app/containers/EmojiPicker/EmojiCategory.js b/app/containers/EmojiPicker/EmojiCategory.js index ed6a145b0..e5b572d97 100644 --- a/app/containers/EmojiPicker/EmojiCategory.js +++ b/app/containers/EmojiPicker/EmojiCategory.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Text, TouchableOpacity } from 'react-native'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import { responsive } from 'react-native-responsive-ui'; import { OptimizedFlatList } from 'react-native-optimized-flatlist'; @@ -18,7 +18,7 @@ const renderEmoji = (emoji, size, baseUrl) => { } return ( - {emojify(`:${ emoji }:`, { output: 'unicode' })} + {shortnameToUnicode(`:${ emoji }:`)} ); }; diff --git a/app/containers/EmojiPicker/index.js b/app/containers/EmojiPicker/index.js index 251e6b212..1b0a7c172 100644 --- a/app/containers/EmojiPicker/index.js +++ b/app/containers/EmojiPicker/index.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { ScrollView } from 'react-native'; import ScrollableTabView from 'react-native-scrollable-tab-view'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import equal from 'deep-equal'; import { connect } from 'react-redux'; import orderBy from 'lodash/orderBy'; @@ -80,7 +80,7 @@ class EmojiPicker extends Component { const content = emoji; this._addFrequentlyUsed({ content, isCustom: false }); const shortname = `:${ emoji }:`; - onEmojiSelected(emojify(shortname, { output: 'unicode' }), shortname); + onEmojiSelected(shortnameToUnicode(shortname), shortname); } } catch (e) { log(e); @@ -119,7 +119,7 @@ class EmojiPicker extends Component { if (item.isCustom) { return { content: item.content, extension: item.extension, isCustom: item.isCustom }; } - return emojify(`${ item.content }`, { output: 'unicode' }); + return shortnameToUnicode(`${ item.content }`); }); this.setState({ frequentlyUsed }); } diff --git a/app/containers/MessageBox/index.js b/app/containers/MessageBox/index.js index 2b61d0f35..89dfdfd22 100644 --- a/app/containers/MessageBox/index.js +++ b/app/containers/MessageBox/index.js @@ -4,7 +4,7 @@ import { View, TextInput, FlatList, Text, TouchableOpacity, Alert, ScrollView } from 'react-native'; import { connect } from 'react-redux'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import { KeyboardAccessoryView } from 'react-native-keyboard-input'; import ImagePicker from 'react-native-image-crop-picker'; import equal from 'deep-equal'; @@ -709,7 +709,7 @@ class MessageBox extends Component { key='mention-item-avatar' style={styles.mentionItemEmoji} > - {emojify(`:${ item }:`, { output: 'unicode' })} + {shortnameToUnicode(`:${ item }:`)} ); } diff --git a/app/containers/markdown/Emoji.js b/app/containers/markdown/Emoji.js index f60c2cb9a..49aed9cf4 100644 --- a/app/containers/markdown/Emoji.js +++ b/app/containers/markdown/Emoji.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Text } from 'react-native'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; @@ -10,7 +10,7 @@ import styles from './styles'; const Emoji = React.memo(({ emojiName, literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl }) => { - const emojiUnicode = emojify(literal, { output: 'unicode' }); + const emojiUnicode = shortnameToUnicode(literal); const emoji = getCustomEmoji && getCustomEmoji(emojiName); if (emoji) { return ( diff --git a/app/containers/markdown/index.js b/app/containers/markdown/index.js index 43e35c86c..7a1d3973c 100644 --- a/app/containers/markdown/index.js +++ b/app/containers/markdown/index.js @@ -3,6 +3,7 @@ import { View, Text, Image } from 'react-native'; import { Parser, Node } from 'commonmark'; import Renderer from 'commonmark-react-renderer'; import PropTypes from 'prop-types'; +import { toShort, shortnameToUnicode } from 'emoji-toolkit'; import I18n from '../../i18n'; @@ -52,6 +53,8 @@ const emojiCount = (str) => { return counter; }; +const encodeEmojis = str => toShort(shortnameToUnicode(str)); + export default class Markdown extends PureComponent { static propTypes = { msg: PropTypes.string, @@ -154,16 +157,12 @@ export default class Markdown extends PureComponent { } renderParagraph = ({ children }) => { - const { numberOfLines } = this.props; - if (!children || children.length === 0) { return null; } return ( - - {children} - + {children} ); }; @@ -286,7 +285,8 @@ export default class Markdown extends PureComponent { } const ast = this.parser.parse(m); - this.isMessageContainsOnlyEmoji = isOnlyEmoji(m) && emojiCount(m) <= 3; + const encodedEmojis = encodeEmojis(m); + this.isMessageContainsOnlyEmoji = isOnlyEmoji(encodedEmojis) && emojiCount(encodedEmojis) <= 3; this.editedMessage(ast); diff --git a/app/containers/message/Emoji.js b/app/containers/message/Emoji.js index f716ba27a..b776d90dc 100644 --- a/app/containers/message/Emoji.js +++ b/app/containers/message/Emoji.js @@ -1,7 +1,7 @@ import React from 'react'; import { Text } from 'react-native'; import PropTypes from 'prop-types'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; @@ -13,7 +13,7 @@ const Emoji = React.memo(({ if (emoji) { return ; } - return { emojify(content, { output: 'unicode' }) }; + return { shortnameToUnicode(content) }; }, () => true); Emoji.propTypes = { diff --git a/app/containers/message/RepliedThread.js b/app/containers/message/RepliedThread.js index 80dcd1cda..7a6f17b7f 100644 --- a/app/containers/message/RepliedThread.js +++ b/app/containers/message/RepliedThread.js @@ -1,7 +1,7 @@ import React from 'react'; import { View, Text } from 'react-native'; import removeMarkdown from 'remove-markdown'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import PropTypes from 'prop-types'; import { CustomIcon } from '../../lib/Icons'; @@ -20,7 +20,7 @@ const RepliedThread = React.memo(({ return null; } - let msg = emojify(tmsg, { output: 'unicode' }); + let msg = shortnameToUnicode(tmsg); msg = removeMarkdown(msg); return ( diff --git a/app/presentation/RoomItem/LastMessage.js b/app/presentation/RoomItem/LastMessage.js index 7bd2e41f8..9ab34a6a0 100644 --- a/app/presentation/RoomItem/LastMessage.js +++ b/app/presentation/RoomItem/LastMessage.js @@ -1,6 +1,6 @@ import React from 'react'; import { Text } from 'react-native'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import PropTypes from 'prop-types'; import _ from 'lodash'; @@ -33,7 +33,7 @@ const formatMsg = ({ let msg = `${ prefix }${ lastMessage.msg.replace(/[\n\t\r]/igm, '') }`; if (msg) { - msg = emojify(msg, { output: 'unicode' }); + msg = shortnameToUnicode(msg); } return msg; }; diff --git a/app/views/RoomView/Header/Header.js b/app/views/RoomView/Header/Header.js index 0b7b14163..802a2a391 100644 --- a/app/views/RoomView/Header/Header.js +++ b/app/views/RoomView/Header/Header.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { View, Text, StyleSheet, ScrollView } from 'react-native'; -import { emojify } from 'react-emojione'; +import { shortnameToUnicode } from 'emoji-toolkit'; import removeMarkdown from 'remove-markdown'; import I18n from '../../../i18n'; @@ -101,7 +101,7 @@ const Header = React.memo(({ } } if (title) { - title = emojify(title, { output: 'unicode' }); + title = shortnameToUnicode(title); if (tmid) { title = removeMarkdown(title); } diff --git a/index.js b/index.js index 06af35ed3..c1f08edf1 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,10 @@ import 'react-native-console-time-polyfill'; import { AppRegistry } from 'react-native'; +import joypixels from 'emoji-toolkit'; import { name as appName, share as shareName } from './app.json'; +joypixels.ascii = true; + if (__DEV__) { require('./app/ReactotronConfig'); } diff --git a/package.json b/package.json index 2195cdb8b..c9c4a1e50 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "commonmark-react-renderer": "git+https://github.com/RocketChat/commonmark-react-renderer.git", "deep-equal": "^1.0.1", "ejson": "2.2.0", + "emoji-toolkit": "^5.0.4", "expo-av": "^6.0.0", "expo-file-system": "^6.0.2", "expo-haptics": "6.0.0", @@ -42,7 +43,6 @@ "moment": "^2.24.0", "prop-types": "15.7.2", "react": "16.8.6", - "react-emojione": "^5.0.1", "react-native": "0.60.4", "react-native-action-sheet": "^2.2.0", "react-native-audio": "^4.3.0", diff --git a/patches/emoji-toolkit+5.0.4.patch b/patches/emoji-toolkit+5.0.4.patch new file mode 100644 index 000000000..f3642d514 --- /dev/null +++ b/patches/emoji-toolkit+5.0.4.patch @@ -0,0 +1,35 @@ +diff --git a/node_modules/emoji-toolkit/lib/js/joypixels.js b/node_modules/emoji-toolkit/lib/js/joypixels.js +index 8e696e6..f2998b9 100644 +--- a/node_modules/emoji-toolkit/lib/js/joypixels.js ++++ b/node_modules/emoji-toolkit/lib/js/joypixels.js +@@ -111,6 +111,7 @@ + ':L':'1f615', + '=L':'1f615', + ':P':'1f61b', ++ ':p':'1f61b', + '=P':'1f61b', + ':b':'1f61b', + ':O':'1f62e', +@@ -245,12 +246,19 @@ + // replace regular shortnames first + var unicode,fname; + str = str.replace(ns.regShortNames, function(shortname) { +- if( (typeof shortname === 'undefined') || (shortname === '') || (!(shortname in ns.emojiList)) ) { +- // if the shortname doesnt exist just return the entire matchhju ++ if( (typeof shortname === 'undefined') || (shortname === '') || (ns.shortnames.indexOf(shortname) === -1) ) { ++ // if the shortname doesnt exist just return the entire match + return shortname; + } ++ if (!ns.emojiList[shortname]) { ++ for ( var emoji in ns.emojiList ) { ++ if (!ns.emojiList.hasOwnProperty(emoji) || (emoji === '')) continue; ++ if (ns.emojiList[emoji].shortnames.indexOf(shortname) === -1) continue; ++ shortname = emoji; ++ break; ++ } ++ } + unicode = ns.emojiList[shortname].uc_full.toUpperCase(); +- fname = ns.emojiList[shortname].uc_base; + return ns.convert(unicode); + }); + diff --git a/yarn.lock b/yarn.lock index 4fa216417..761f6ea41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3837,6 +3837,11 @@ emoji-regex@^7.0.1, emoji-regex@^7.0.2: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== +emoji-toolkit@^5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/emoji-toolkit/-/emoji-toolkit-5.0.4.tgz#73e6902b73894aa1899c7f148d3801eb157455a6" + integrity sha512-ZZfVQkWQ+1v3q3EdeYSVOQHVg/idvOhARoG4G+hPesN1i00vSeSgI+PUrsRRQSdrET7/Fe9Jr0n7iFbLlY5dKA== + emotion-theming@^10.0.9: version "10.0.14" resolved "https://registry.yarnpkg.com/emotion-theming/-/emotion-theming-10.0.14.tgz#e548d388493d07bedbb0d9d3bbe221766174b1f4" @@ -9299,11 +9304,6 @@ react-dom@16.8.6, react-dom@^16.8.3: prop-types "^15.6.2" scheduler "^0.13.6" -react-emojione@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/react-emojione/-/react-emojione-5.0.1.tgz#faa4ccdad4bf24e2f5a1a96d9b44c2e902d2bc79" - integrity sha512-sjI6k8uQ14rWENYoAb+2BFQGLBt/cpLDJJNhnZvdFJytAJijhv+JmbmyyrfQPdyID0Cs4N8XFqnek0xq6POwGA== - react-fast-compare@2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"