split emoji support methods from the async module
This commit is contained in:
parent
88114c41fb
commit
27a1348f20
7 changed files with 16 additions and 12 deletions
|
@ -1,10 +1,9 @@
|
|||
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);
|
||||
|
||||
const generatedUnicodeSupportMap = getUnicodeSupportMap();
|
||||
|
||||
function emojiImageTag(name, src) {
|
||||
return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`;
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ function installGlEmojiElement() {
|
|||
if (
|
||||
emojiUnicode &&
|
||||
isEmojiUnicode &&
|
||||
!isEmojiUnicodeSupported(generatedUnicodeSupportMap, emojiUnicode, unicodeVersion)
|
||||
!isEmojiUnicodeSupported(emojiUnicode, unicodeVersion)
|
||||
) {
|
||||
// CSS sprite fallback takes precedence over image fallback
|
||||
if (hasCssSpriteFalback) {
|
||||
|
@ -106,5 +105,4 @@ function installGlEmojiElement() {
|
|||
export {
|
||||
installGlEmojiElement,
|
||||
glEmojiTag,
|
||||
emojiImageTag,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import emojiMap from 'emojis/digests.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)];
|
||||
|
||||
|
@ -52,8 +50,6 @@ export {
|
|||
filterEmojiNames,
|
||||
filterEmojiNamesByAlias,
|
||||
getEmojiByCategory,
|
||||
getUnicodeSupportMap,
|
||||
isEmojiNameValid,
|
||||
isEmojiUnicodeSupported,
|
||||
validEmojiNames,
|
||||
};
|
||||
|
|
10
app/assets/javascripts/emoji/support/index.js
Normal file
10
app/assets/javascripts/emoji/support/index.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
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);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import AccessorUtilities from '../lib/utils/accessor';
|
||||
import AccessorUtilities from '../../lib/utils/accessor';
|
||||
|
||||
const unicodeSupportTestMap = {
|
||||
// man, student (emojione does not have any of these yet), http://emojipedia.org/emoji-zwj-sequences/
|
|
@ -1,4 +1,4 @@
|
|||
import getUnicodeSupportMap from '~/emoji/unicode_support_map';
|
||||
import getUnicodeSupportMap from '~/emoji/support/unicode_support_map';
|
||||
import AccessorUtilities from '~/lib/utils/accessor';
|
||||
|
||||
describe('Unicode Support Map', () => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import isEmojiUnicodeSupported, {
|
|||
isSkinToneComboEmoji,
|
||||
isHorceRacingSkinToneComboEmoji,
|
||||
isPersonZwjEmoji,
|
||||
} from '~/emoji/is_emoji_unicode_supported';
|
||||
} from '~/emoji/support/is_emoji_unicode_supported';
|
||||
|
||||
const emptySupportMap = {
|
||||
personZwj: false,
|
||||
|
|
Loading…
Reference in a new issue