Skip to content
Snippets Groups Projects
Commit 28f7bfb1 authored by Jono Wenger's avatar Jono Wenger
Browse files

Copy EmojiMartData interface emoji-mart directly to emojiMartSet

parent 0b1cb906
No related branches found
No related tags found
2 merge requests!67fix for latest client release,!61Add emoji sanitizater
......@@ -19,36 +19,47 @@ type emojiID string
type codepoint string
// emojiMartSet is a representation of the JSON file format containing the emoji
// list in emoji-mart.
// list in emoji-mart. It matches the object EmojiMartData:
// https://github.com/missive/emoji-mart/blob/main/packages/emoji-mart-data/index.d.ts
//
// Doc: https://github.com/missive/emoji-mart/
// JSON example: https://github.com/missive/emoji-mart/blob/main/packages/emoji-mart-data/sets/14/native.json
type emojiMartSet struct {
Categories []category `json:"categories"`
Emojis map[emojiID]emoji `json:"emojis"`
Aliases map[string]emojiID `json:"aliases"`
Sheet map[string]interface{} `json:"sheet"`
Categories []category `json:"categories"`
Emojis map[emojiID]emoji `json:"emojis"`
Aliases map[string]emojiID `json:"aliases"`
Sheet sheet `json:"sheet"`
}
// category adheres to the category field of the emoji-mart JSON file.
// category adheres to the categories field within the EmojiMartData Javascript
// interface.
type category struct {
Emojis []emojiID `json:"emojis"`
ID string `json:"id"`
Emojis []emojiID `json:"emojis"`
}
// emoji adheres to the emoji field of the emoji-mart JSON file.
// emoji adheres to the emojis field within the EmojiMartData Javascript
// interface.
type emoji struct {
Emoticons []string `json:"emoticons,omitempty"`
ID emojiID `json:"id"`
Name string `json:"name"`
Keywords []string `json:"keywords"`
Skins []skin `json:"skins"`
Version float32 `json:"version"`
Version float64 `json:"version"`
Emoticons []string `json:"emoticons,omitempty"`
}
// skin adheres to the skin field within the emoji field of the emoji-mart JSON
// file.
// skin adheres to the skins field within the EmojiMartData Javascript interface.
type skin struct {
Unified codepoint `json:"unified"`
Native string `json:"native"`
X float64 `json:"x,omitempty"`
Y float64 `json:"y,omitempty"`
}
// sheet adheres to the sheet field within the EmojiMartData Javascript
// interface.
type sheet struct {
Cols float64 `json:"cols"`
Rows float64 `json:"rows"`
}
......@@ -39,8 +39,9 @@ func Test_emojiMartData_JSON_Marshal_Unmarshal(t *testing.T) {
Aliases: map[string]emojiID{
"lady_beetle": "ladybug",
},
Sheet: map[string]interface{}{
"test": "data",
Sheet: sheet{
Cols: 5,
Rows: 12,
},
}
......
......@@ -82,7 +82,7 @@ func (s *Set) findIncompatibleEmojis(set *emojiMartSet) (emojisToRemove []emojiI
// Determine if the emoji's codepoint should be replaced or removed
replacement, replace := s.replace(Skin.Unified)
if replace {
jww.TRACE.Printf("Replaced codepoint %q with %q for emoji %q",
jww.TRACE.Printf("Replaced codepoint %q with %v for emoji %q",
Skin.Unified, replacement, id)
newSkins = append(newSkins, replacement)
} else if !s.remove(Skin.Unified) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment