1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-07 10:46:24 +03:00

make EmojiProvider and stripped-emoji.json work

This commit is contained in:
Matthew Hodgson
2019-05-19 20:48:18 +01:00
parent 497be91c4d
commit dbc6815abf
7 changed files with 39 additions and 63 deletions

View File

@@ -74,22 +74,23 @@ export function containsEmoji(str) {
* @return {String} The shortcode (such as :thumbup:)
*/
export function unicodeToShortcode(char) {
const data = EMOJIBASE.find((e)=>{ e.unicode === char });
return (data && data.shortcodes ? data.shortcodes[0] : '');
const data = EMOJIBASE.find(e => e.unicode === char);
return (data && data.shortcodes ? `:${data.shortcodes[0]}:` : '');
}
/**
* Returns the unicode character for an emoji shortcode
*
* @param {String} shortcode The shortcode (such as :thumbup:)
* @return {String} The emoji character
* @return {String} The emoji character; null if none exists
*/
export function shortcodeToUnicode(shortcode) {
const data = EMOJIBASE.find((e)=>{ e.shortcodes && e.shortcodes.contains(shortcode) });
return data.unicode;
shortcode = shortcode.slice(1, shortcode.length - 1);
const data = EMOJIBASE.find(e => e.shortcodes && e.shortcodes.includes(shortcode));
return data ? data.unicode : null;
}
export function processHtmlForSending(html: string): string {
export function processHtmlForSending (html: string): string {
const contentDiv = document.createElement('div');
contentDiv.innerHTML = html;