Use emojione/emoji.json because we don't want two sets of emoji meta
This commit is contained in:
parent
f4db765239
commit
8ca3b382ed
2 changed files with 16 additions and 26 deletions
|
@ -54,7 +54,6 @@
|
||||||
"draft-js": "^0.9.1",
|
"draft-js": "^0.9.1",
|
||||||
"draft-js-export-html": "^0.5.0",
|
"draft-js-export-html": "^0.5.0",
|
||||||
"draft-js-export-markdown": "^0.2.0",
|
"draft-js-export-markdown": "^0.2.0",
|
||||||
"emoji-datasource": "^3.0.0",
|
|
||||||
"emojione": "2.2.3",
|
"emojione": "2.2.3",
|
||||||
"file-saver": "^1.3.3",
|
"file-saver": "^1.3.3",
|
||||||
"filesize": "3.5.6",
|
"filesize": "3.5.6",
|
||||||
|
|
|
@ -24,43 +24,34 @@ import sdk from '../index';
|
||||||
import {PillCompletion} from './Components';
|
import {PillCompletion} from './Components';
|
||||||
import type {SelectionRange, Completion} from './Autocompleter';
|
import type {SelectionRange, Completion} from './Autocompleter';
|
||||||
|
|
||||||
import EmojiData from 'emoji-datasource/emoji';
|
import EmojiData from 'emojione/emoji.json';
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
const LIMIT = 20;
|
const LIMIT = 20;
|
||||||
const CATEGORY_ORDER = [
|
const CATEGORY_ORDER = [
|
||||||
'People',
|
'people',
|
||||||
'Foods',
|
'food',
|
||||||
'Objects',
|
'objects',
|
||||||
'Activity',
|
'activity',
|
||||||
'Skin Tones',
|
'nature',
|
||||||
'Nature',
|
'travel',
|
||||||
'Places',
|
'flags',
|
||||||
'Flags',
|
'symbols',
|
||||||
'Symbols',
|
'unicode9',
|
||||||
|
'modifier',
|
||||||
];
|
];
|
||||||
|
|
||||||
const EMOJI_REGEX = /:\w*:?/g;
|
const EMOJI_REGEX = /:\w*:?/g;
|
||||||
const EMOJI_SHORTNAMES = emojiDataWithEmojiOneSupport.sort(
|
const EMOJI_SHORTNAMES = Object.keys(EmojiData).map((key) => EmojiData[key]).sort(
|
||||||
(a, b) => {
|
(a, b) => {
|
||||||
if (a.category === b.category) {
|
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);
|
return CATEGORY_ORDER.indexOf(a.category) - CATEGORY_ORDER.indexOf(b.category);
|
||||||
},
|
},
|
||||||
).map((a) => {
|
).map((a) => {
|
||||||
return {
|
return {
|
||||||
shortname: emojiDataToEmojiOne(a.short_name),
|
name: a.name,
|
||||||
shortnames: a.short_names.join(','),
|
shortname: a.shortname,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -70,7 +61,7 @@ export default class EmojiProvider extends AutocompleteProvider {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(EMOJI_REGEX);
|
super(EMOJI_REGEX);
|
||||||
this.matcher = new FuzzyMatcher(EMOJI_SHORTNAMES, {
|
this.matcher = new FuzzyMatcher(EMOJI_SHORTNAMES, {
|
||||||
keys: ['shortname', 'shortnames'],
|
keys: ['shortname', 'name'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue