forked from AkkomaGang/akkoma-fe
Reorder Unicode emojis
Reorder Unicode emojis according to Unicode CLDR emoji collation rules.
This commit is contained in:
parent
b4b13d777f
commit
d5b078e084
|
@ -159,13 +159,13 @@ const instance = {
|
|||
const res = await window.fetch('/static/emoji.json')
|
||||
if (res.ok) {
|
||||
const values = await res.json()
|
||||
const emoji = Object.keys(values).map((key) => {
|
||||
const emoji = values.map((key) => {
|
||||
return {
|
||||
displayText: key,
|
||||
displayText: key.keyword,
|
||||
imageUrl: false,
|
||||
replacement: values[key]
|
||||
replacement: key.value
|
||||
}
|
||||
}).sort((a, b) => a.name > b.name ? 1 : -1)
|
||||
})
|
||||
commit('setInstanceOption', { name: 'emoji', value: emoji })
|
||||
} else {
|
||||
throw (res)
|
||||
|
|
7109
static/emoji.json
7109
static/emoji.json
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,27 @@
|
|||
const fs = require('fs')
|
||||
|
||||
const emojiFilename = '../static/emoji.json'
|
||||
|
||||
const data = fs.readFileSync(emojiFilename, 'utf8')
|
||||
const currentEmojis = JSON.parse(data)
|
||||
|
||||
const currentEmojisArray = Object.entries(currentEmojis).map(([name, codepoint]) => {
|
||||
return {
|
||||
keyword: name,
|
||||
value: codepoint
|
||||
}
|
||||
}).filter(e => {
|
||||
const hasSingleCodepoint = Array.from(e.value).length === 1;
|
||||
const isSkinToneIndicator = e.value.codePointAt(0) >= 0x1F3FB && e.value.codePointAt(0) <= 0x1F3FF;
|
||||
return !(hasSingleCodepoint && isSkinToneIndicator)
|
||||
})
|
||||
|
||||
const collator = new Intl.Collator('en-u-co-emoji')
|
||||
|
||||
currentEmojisArray.sort((a, b) => {
|
||||
return collator.compare(a.value, b.value)
|
||||
})
|
||||
|
||||
fs.writeFile(emojiFilename, JSON.stringify(currentEmojisArray, null, 2), 'utf8', (err) => {
|
||||
if (err) console.log('Error writing file', err)
|
||||
})
|
Loading…
Reference in New Issue