Use emojione/emoji.json because we don't want two sets of emoji meta

This commit is contained in:
Luke Barnard 2017-06-28 11:19:16 +01:00
parent f4db765239
commit 8ca3b382ed
2 changed files with 16 additions and 26 deletions

View file

@ -54,7 +54,6 @@
"draft-js": "^0.9.1",
"draft-js-export-html": "^0.5.0",
"draft-js-export-markdown": "^0.2.0",
"emoji-datasource": "^3.0.0",
"emojione": "2.2.3",
"file-saver": "^1.3.3",
"filesize": "3.5.6",

View file

@ -24,43 +24,34 @@ import sdk from '../index';
import {PillCompletion} from './Components';
import type {SelectionRange, Completion} from './Autocompleter';
import EmojiData from 'emoji-datasource/emoji';
const emojiDataToEmojiOne = (name) => ':' + name + ':';
// Only include emojis that are in both data sets
const emojiOneShortNames = Object.keys(emojioneList);
const emojiDataWithEmojiOneSupport = EmojiData.filter((a) => {
return emojiOneShortNames.indexOf(
emojiDataToEmojiOne(a.short_name),
) !== -1;
});
import EmojiData from 'emojione/emoji.json';
const LIMIT = 20;
const CATEGORY_ORDER = [
'People',
'Foods',
'Objects',
'Activity',
'Skin Tones',
'Nature',
'Places',
'Flags',
'Symbols',
'people',
'food',
'objects',
'activity',
'nature',
'travel',
'flags',
'symbols',
'unicode9',
'modifier',
];
const EMOJI_REGEX = /:\w*:?/g;
const EMOJI_SHORTNAMES = emojiDataWithEmojiOneSupport.sort(
const EMOJI_SHORTNAMES = Object.keys(EmojiData).map((key) => EmojiData[key]).sort(
(a, b) => {
if (a.category === b.category) {
return a.sort_order - b.sort_order;
return a.emoji_order - b.emoji_order;
}
return CATEGORY_ORDER.indexOf(a.category) - CATEGORY_ORDER.indexOf(b.category);
},
).map((a) => {
return {
shortname: emojiDataToEmojiOne(a.short_name),
shortnames: a.short_names.join(','),
name: a.name,
shortname: a.shortname,
};
});
@ -70,7 +61,7 @@ export default class EmojiProvider extends AutocompleteProvider {
constructor() {
super(EMOJI_REGEX);
this.matcher = new FuzzyMatcher(EMOJI_SHORTNAMES, {
keys: ['shortname', 'shortnames'],
keys: ['shortname', 'name'],
});
}