From 45fbba2742b8b7bf278b68573b39bfb6682e5481 Mon Sep 17 00:00:00 2001 From: fuyu <54523771+mfmfuyu@users.noreply.github.com> Date: Thu, 11 Jun 2020 04:56:14 +0900 Subject: [PATCH] [Glitch] Fixed emoji detection problem to append border Port b1484cf3ceebe1f1f083e4c06872493dc0a68511 to glitch-soc Co-authored-by: ThibG Signed-off-by: Thibaut Girka --- .../flavours/glitch/util/emoji/index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/util/emoji/index.js b/app/javascript/flavours/glitch/util/emoji/index.js index 22b657b05..61f211c92 100644 --- a/app/javascript/flavours/glitch/util/emoji/index.js +++ b/app/javascript/flavours/glitch/util/emoji/index.js @@ -6,13 +6,18 @@ const trie = new Trie(Object.keys(unicodeMapping)); const assetHost = process.env.CDN_HOST || ''; -// Emoji requiring extra borders depending on theme -const darkEmoji = '🎱🐜âšĢ🖤âŦ›â—ŧī¸â—žâ—ŧī¸âœ’ī¸â–Ēī¸đŸ’ŖđŸŽŗ📷📸â™Ŗī¸đŸ•ļī¸âœ´ī¸đŸ”ŒđŸ’‚‍♀ī¸đŸ“Ŋī¸đŸŗđŸĻđŸ’‚đŸ”ĒđŸ•ŗī¸đŸ•šī¸đŸ•‹đŸ–Šī¸đŸ–‹ī¸đŸ’‚‍♂ī¸đŸŽ¤đŸŽ“đŸŽĨđŸŽŧ♠ī¸đŸŽŠđŸĻƒđŸ“ŧ📹🎮🐃🏴'; -const lightEmoji = 'đŸ‘Ŋ⚾🐔☁ī¸đŸ’¨đŸ•Šī¸đŸ‘€đŸĨđŸ‘ģ🐐❕❔⛸ī¸đŸŒŠī¸đŸ”ŠđŸ”‡đŸ“ƒđŸŒ§ī¸đŸđŸšđŸ™đŸ“đŸ‘đŸ’€â˜ ī¸đŸŒ¨ī¸đŸ”‰đŸ”ˆđŸ’Ŧ💭🏐đŸŗī¸âšĒâŦœâ—Ŋâ—ģī¸â–Ģī¸'; +// Convert to file names from emojis. (For different variation selector emojis) +const emojiFilenames = (emojis) => { + return emojis.map(v => unicodeMapping[v].filename); +}; -const emojiFilename = (filename, match) => { +// Emoji requiring extra borders depending on theme +const darkEmoji = emojiFilenames(['🎱', '🐜', 'âšĢ', '🖤', 'âŦ›', 'â—ŧī¸', '◾', 'â—ŧī¸', '✒ī¸', 'â–Ēī¸', 'đŸ’Ŗ', 'đŸŽŗ', '📷', '📸', 'â™Ŗī¸', 'đŸ•ļī¸', '✴ī¸', '🔌', '💂‍♀ī¸', 'đŸ“Ŋī¸', 'đŸŗ', 'đŸĻ', '💂', 'đŸ”Ē', 'đŸ•ŗī¸', '🕹ī¸', '🕋', '🖊ī¸', '🖋ī¸', '💂‍♂ī¸', '🎤', '🎓', 'đŸŽĨ', 'đŸŽŧ', '♠ī¸', '🎩', 'đŸĻƒ', 'đŸ“ŧ', '📹', '🎮', '🐃', '🏴']); +const lightEmoji = emojiFilenames(['đŸ‘Ŋ', '⚾', '🐔', '☁ī¸', '💨', '🕊ī¸', '👀', 'đŸĨ', 'đŸ‘ģ', '🐐', '❕', '❔', '⛸ī¸', '🌩ī¸', '🔊', '🔇', '📃', '🌧ī¸', '🐏', '🍚', '🍙', '🐓', '🐑', '💀', '☠ī¸', '🌨ī¸', '🔉', '🔈', 'đŸ’Ŧ', '💭', '🏐', 'đŸŗī¸', 'âšĒ', 'âŦœ', 'â—Ŋ', 'â—ģī¸', 'â–Ģī¸']); + +const emojiFilename = (filename) => { const borderedEmoji = (document.body && document.body.classList.contains('skin-mastodon-light')) ? lightEmoji : darkEmoji; - return borderedEmoji.includes(match) ? (filename + '_border') : filename; + return borderedEmoji.includes(filename) ? (filename + '_border') : filename; }; const emojify = (str, customEmojis = {}) => { @@ -69,7 +74,7 @@ const emojify = (str, customEmojis = {}) => { } else if (!useSystemEmojiFont) { // matched to unicode emoji const { filename, shortCode } = unicodeMapping[match]; const title = shortCode ? `:${shortCode}:` : ''; - replacement = `${match}`; + replacement = `${match}`; rend = i + match.length; // If the matched character was followed by VS15 (for selecting text presentation), skip it. if (str.codePointAt(rend) === 65038) {