Normalize emoticons when building data
parent
9e57de33ce
commit
49ec3b9efe
File diff suppressed because one or more lines are too long
|
@ -39,6 +39,14 @@ emojiData.forEach((datum) => {
|
|||
throw new Error('“' + datum.short_name + '” doesn’t have a name')
|
||||
}
|
||||
|
||||
datum.emoticons = datum.texts || []
|
||||
if (datum.text && !datum.emoticons.length) {
|
||||
datum.emoticons = [datum.text]
|
||||
}
|
||||
|
||||
delete datum.text
|
||||
delete datum.texts
|
||||
|
||||
if (datum.category == 'Skin Tones') {
|
||||
data.skins[datum.short_name] = datum
|
||||
} else {
|
||||
|
|
|
@ -70,15 +70,10 @@ export default class Emoji extends React.Component {
|
|||
|
||||
handleClick(emojiData) {
|
||||
var { onClick } = this.props,
|
||||
{ name, short_names, skin_tone, text, texts, unified } = emojiData,
|
||||
{ name, short_names, skin_tone, emoticons, unified } = emojiData,
|
||||
id = short_names[0],
|
||||
colons = `:${id}:`
|
||||
|
||||
texts || (texts = [])
|
||||
if (text && !texts.length) {
|
||||
texts = [text]
|
||||
}
|
||||
|
||||
if (skin_tone) {
|
||||
colons += `:skin-tone-${skin_tone}:`
|
||||
}
|
||||
|
@ -87,8 +82,8 @@ export default class Emoji extends React.Component {
|
|||
id,
|
||||
name,
|
||||
colons,
|
||||
emoticons,
|
||||
skin: skin_tone || 1,
|
||||
emoticons: texts,
|
||||
native: this.getNative(emojiData),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,19 +12,14 @@ export default class Preview extends React.Component {
|
|||
{ emojiProps, skinsProps } = this.props
|
||||
|
||||
if (emoji) {
|
||||
var { text, texts } = emoji,
|
||||
var { emoticons } = emoji,
|
||||
knownEmoticons = [],
|
||||
emoticons = []
|
||||
listedEmoticons = []
|
||||
|
||||
texts || (texts = [])
|
||||
if (text && !texts.length) {
|
||||
texts = [text]
|
||||
}
|
||||
|
||||
for (let text of texts) {
|
||||
if (knownEmoticons.indexOf(text.toLowerCase()) == -1) {
|
||||
knownEmoticons.push(text.toLowerCase())
|
||||
emoticons.push(text)
|
||||
for (let emoticon of emoticons) {
|
||||
if (knownEmoticons.indexOf(emoticon.toLowerCase()) == -1) {
|
||||
knownEmoticons.push(emoticon.toLowerCase())
|
||||
listedEmoticons.push(emoticon)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +38,7 @@ export default class Preview extends React.Component {
|
|||
{emoji.short_names.map((short_name) =>
|
||||
<span key={short_name} className='emoji-picker-preview-shortname'>:{short_name}:</span>
|
||||
)}<br />
|
||||
{emoticons.map((emoticon) =>
|
||||
{listedEmoticons.map((emoticon) =>
|
||||
<span key={emoticon} className='emoji-picker-preview-emoticon'>{emoticon}</span>
|
||||
)}
|
||||
</span>
|
||||
|
|
|
@ -22,16 +22,11 @@ export default class Search extends React.Component {
|
|||
|
||||
for (let emoji in data.emojis) {
|
||||
let emojiData = data.emojis[emoji],
|
||||
{ short_name, name, text, texts } = emojiData
|
||||
|
||||
texts || (texts = [])
|
||||
if (text && !texts.length) {
|
||||
texts = [text]
|
||||
}
|
||||
{ short_name, name, emoticons } = emojiData
|
||||
|
||||
this.index.add({
|
||||
id: short_name,
|
||||
emoticons: texts,
|
||||
emoticons: emoticons,
|
||||
short_name: this.tokenize(short_name),
|
||||
name: this.tokenize(name),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue