Skip to content

Commit

Permalink
fix(emoji): 馃悰 added support for colorful emoji variations
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jan 16, 2020
1 parent c0ff022 commit dff0ede
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/devmoji/__tests__/devmoji.ts
Expand Up @@ -15,6 +15,20 @@ test("emojify", () => {
}
})

test("strip", () => {
const devmoji = new Devmoji(new Config())

const tests: [string, string][] = [
["build: 馃摝 added", "build: added"],
[":missing:", ""],
["testing 123 :feat:", "testing 123 "],
]

for (const t of tests) {
expect(devmoji.strip(t[0])).toBe(t[1])
}
})

test("demojify", () => {
const devmoji = new Devmoji(new Config())

Expand Down
357 changes: 357 additions & 0 deletions packages/devmoji/src/data/variations.emoji.ts
@@ -0,0 +1,357 @@
export default {
"variations": [
35,
42,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
169,
174,
8252,
8265,
8482,
8505,
8596,
8597,
8598,
8599,
8600,
8601,
8617,
8618,
8986,
8987,
9000,
9167,
9193,
9194,
9197,
9198,
9199,
9201,
9202,
9203,
9208,
9209,
9210,
9410,
9642,
9643,
9654,
9664,
9723,
9724,
9725,
9726,
9728,
9729,
9730,
9731,
9732,
9742,
9745,
9748,
9749,
9752,
9757,
9760,
9762,
9763,
9766,
9770,
9774,
9775,
9784,
9785,
9786,
9792,
9794,
9800,
9801,
9802,
9803,
9804,
9805,
9806,
9807,
9808,
9809,
9810,
9811,
9823,
9824,
9827,
9829,
9830,
9832,
9851,
9854,
9855,
9874,
9875,
9876,
9877,
9878,
9879,
9881,
9883,
9884,
9888,
9889,
9898,
9899,
9904,
9905,
9917,
9918,
9924,
9925,
9928,
9935,
9937,
9939,
9940,
9961,
9962,
9968,
9969,
9970,
9971,
9972,
9973,
9975,
9976,
9977,
9978,
9981,
9986,
9992,
9993,
9996,
9997,
9999,
10002,
10004,
10006,
10013,
10017,
10035,
10036,
10052,
10055,
10067,
10071,
10083,
10084,
10145,
10548,
10549,
11013,
11014,
11015,
11035,
11036,
11088,
11093,
12336,
12349,
12951,
12953,
126980,
127344,
127345,
127358,
127359,
127490,
127514,
127535,
127543,
127757,
127758,
127759,
127765,
127772,
127777,
127780,
127781,
127782,
127783,
127784,
127785,
127786,
127787,
127788,
127798,
127864,
127869,
127891,
127894,
127895,
127897,
127898,
127899,
127902,
127903,
127911,
127916,
127917,
127918,
127938,
127940,
127942,
127946,
127947,
127948,
127949,
127950,
127956,
127957,
127958,
127959,
127960,
127961,
127962,
127963,
127964,
127965,
127966,
127967,
127968,
127981,
127987,
127989,
127991,
128008,
128021,
128031,
128038,
128063,
128065,
128066,
128070,
128071,
128072,
128073,
128077,
128078,
128083,
128106,
128125,
128163,
128176,
128179,
128187,
128191,
128203,
128218,
128223,
128228,
128229,
128230,
128234,
128235,
128236,
128237,
128247,
128249,
128250,
128251,
128253,
128264,
128269,
128274,
128275,
128329,
128330,
128336,
128337,
128338,
128339,
128340,
128341,
128342,
128343,
128344,
128345,
128346,
128347,
128348,
128349,
128350,
128351,
128352,
128353,
128354,
128355,
128356,
128357,
128358,
128359,
128367,
128368,
128371,
128372,
128373,
128374,
128375,
128376,
128377,
128391,
128394,
128395,
128396,
128397,
128400,
128421,
128424,
128433,
128434,
128444,
128450,
128451,
128452,
128465,
128466,
128467,
128476,
128477,
128478,
128481,
128483,
128488,
128495,
128499,
128506,
128528,
128647,
128653,
128657,
128660,
128664,
128685,
128690,
128697,
128698,
128700,
128715,
128717,
128718,
128719,
128736,
128737,
128738,
128739,
128740,
128741,
128745,
128752,
128755
]
}
5 changes: 4 additions & 1 deletion packages/devmoji/src/emoji-pack.ts
Expand Up @@ -6,6 +6,7 @@ export type TEmoji = { code: string; emoji: string; description?: string }
export class EmojiPack {
codes = new Map<string, TEmoji>()
emojis = new Map<string, TEmoji[]>()
emojiVariation = String.fromCodePoint(0xfe0f)

add(def: TEmoji) {
def.code = this.unwrap(def.code)
Expand All @@ -22,7 +23,9 @@ export class EmojiPack {
}

getCodes(emoji: string) {
return this.emojis.get(emoji)
let ret = this.emojis.get(emoji)
if (!ret) ret = this.emojis.get(emoji + this.emojiVariation)
return ret
}

getCode(emoji: string) {
Expand Down

0 comments on commit dff0ede

Please sign in to comment.