Commit 27a1348f authored by Mike Greiling's avatar Mike Greiling

split emoji support methods from the async module

parent 88114c41
import installCustomElements from 'document-register-element'; import installCustomElements from 'document-register-element';
import { emojiMap, normalizeEmojiName, isEmojiUnicodeSupported, getUnicodeSupportMap } from '../emoji'; import { emojiMap, normalizeEmojiName } from '../emoji';
import isEmojiUnicodeSupported from '../emoji/support';
installCustomElements(window); installCustomElements(window);
const generatedUnicodeSupportMap = getUnicodeSupportMap();
function emojiImageTag(name, src) { function emojiImageTag(name, src) {
return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`; return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`;
} }
...@@ -82,7 +81,7 @@ function installGlEmojiElement() { ...@@ -82,7 +81,7 @@ function installGlEmojiElement() {
if ( if (
emojiUnicode && emojiUnicode &&
isEmojiUnicode && isEmojiUnicode &&
!isEmojiUnicodeSupported(generatedUnicodeSupportMap, emojiUnicode, unicodeVersion) !isEmojiUnicodeSupported(emojiUnicode, unicodeVersion)
) { ) {
// CSS sprite fallback takes precedence over image fallback // CSS sprite fallback takes precedence over image fallback
if (hasCssSpriteFalback) { if (hasCssSpriteFalback) {
...@@ -106,5 +105,4 @@ function installGlEmojiElement() { ...@@ -106,5 +105,4 @@ function installGlEmojiElement() {
export { export {
installGlEmojiElement, installGlEmojiElement,
glEmojiTag, glEmojiTag,
emojiImageTag,
}; };
import emojiMap from 'emojis/digests.json'; import emojiMap from 'emojis/digests.json';
import emojiAliases from 'emojis/aliases.json'; import emojiAliases from 'emojis/aliases.json';
import getUnicodeSupportMap from './unicode_support_map';
import isEmojiUnicodeSupported from './is_emoji_unicode_supported';
const validEmojiNames = [...Object.keys(emojiMap), ...Object.keys(emojiAliases)]; const validEmojiNames = [...Object.keys(emojiMap), ...Object.keys(emojiAliases)];
...@@ -52,8 +50,6 @@ export { ...@@ -52,8 +50,6 @@ export {
filterEmojiNames, filterEmojiNames,
filterEmojiNamesByAlias, filterEmojiNamesByAlias,
getEmojiByCategory, getEmojiByCategory,
getUnicodeSupportMap,
isEmojiNameValid, isEmojiNameValid,
isEmojiUnicodeSupported,
validEmojiNames, validEmojiNames,
}; };
import isEmojiUnicodeSupported from './is_emoji_unicode_supported';
import getUnicodeSupportMap from './unicode_support_map';
// cache browser support map between calls
let browserUnicodeSupportMap;
export default function isEmojiUnicodeSupportedByBrowser(emojiUnicode, unicodeVersion) {
browserUnicodeSupportMap = browserUnicodeSupportMap || getUnicodeSupportMap();
return isEmojiUnicodeSupported(browserUnicodeSupportMap, emojiUnicode, unicodeVersion);
}
import AccessorUtilities from '../lib/utils/accessor'; import AccessorUtilities from '../../lib/utils/accessor';
const unicodeSupportTestMap = { const unicodeSupportTestMap = {
// man, student (emojione does not have any of these yet), http://emojipedia.org/emoji-zwj-sequences/ // man, student (emojione does not have any of these yet), http://emojipedia.org/emoji-zwj-sequences/
......
import getUnicodeSupportMap from '~/emoji/unicode_support_map'; import getUnicodeSupportMap from '~/emoji/support/unicode_support_map';
import AccessorUtilities from '~/lib/utils/accessor'; import AccessorUtilities from '~/lib/utils/accessor';
describe('Unicode Support Map', () => { describe('Unicode Support Map', () => {
......
...@@ -5,7 +5,7 @@ import isEmojiUnicodeSupported, { ...@@ -5,7 +5,7 @@ import isEmojiUnicodeSupported, {
isSkinToneComboEmoji, isSkinToneComboEmoji,
isHorceRacingSkinToneComboEmoji, isHorceRacingSkinToneComboEmoji,
isPersonZwjEmoji, isPersonZwjEmoji,
} from '~/emoji/is_emoji_unicode_supported'; } from '~/emoji/support/is_emoji_unicode_supported';
const emptySupportMap = { const emptySupportMap = {
personZwj: false, personZwj: false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment