|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
import { useUserPreference } from '@rocket.chat/ui-contexts'; |
|
|
|
|
import { useEffect } from 'react'; |
|
|
|
|
import { useEffect, useLayoutEffect } from 'react'; |
|
|
|
|
|
|
|
|
|
import { queueMicrotask } from '../../../../client/lib/utils/queueMicrotask'; |
|
|
|
|
import { emoji } from '../../../emoji/client'; |
|
|
|
|
import { getEmojiConfig } from '../../lib/getEmojiConfig'; |
|
|
|
|
import { isSetNotNull } from '../../lib/isSetNotNull'; |
|
|
|
|
@ -11,32 +10,30 @@ const config = getEmojiConfig(); |
|
|
|
|
export const useEmojiOne = () => { |
|
|
|
|
const convertAsciiToEmoji = useUserPreference<boolean>('convertAsciiEmoji', true); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
queueMicrotask(() => { |
|
|
|
|
emoji.packages.emojione = config.emojione as any; |
|
|
|
|
if (emoji.packages.emojione) { |
|
|
|
|
emoji.packages.emojione.sprites = config.sprites; |
|
|
|
|
emoji.packages.emojione.emojisByCategory = config.emojisByCategory; |
|
|
|
|
emoji.packages.emojione.emojiCategories = config.emojiCategories as any; |
|
|
|
|
emoji.packages.emojione.toneList = config.toneList; |
|
|
|
|
|
|
|
|
|
emoji.packages.emojione.render = config.render; |
|
|
|
|
emoji.packages.emojione.renderPicker = config.renderPicker; |
|
|
|
|
|
|
|
|
|
// RocketChat.emoji.list is the collection of emojis from all emoji packages
|
|
|
|
|
for (const [key, currentEmoji] of Object.entries(config.emojione.emojioneList)) { |
|
|
|
|
currentEmoji.emojiPackage = 'emojione'; |
|
|
|
|
emoji.list[key] = currentEmoji; |
|
|
|
|
|
|
|
|
|
if (currentEmoji.shortnames) { |
|
|
|
|
currentEmoji.shortnames.forEach((shortname: string) => { |
|
|
|
|
emoji.list[shortname] = currentEmoji; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
useLayoutEffect(() => { |
|
|
|
|
emoji.packages.emojione = config.emojione as any; |
|
|
|
|
if (emoji.packages.emojione) { |
|
|
|
|
emoji.packages.emojione.sprites = config.sprites; |
|
|
|
|
emoji.packages.emojione.emojisByCategory = config.emojisByCategory; |
|
|
|
|
emoji.packages.emojione.emojiCategories = config.emojiCategories as any; |
|
|
|
|
emoji.packages.emojione.toneList = config.toneList; |
|
|
|
|
|
|
|
|
|
emoji.packages.emojione.render = config.render; |
|
|
|
|
emoji.packages.emojione.renderPicker = config.renderPicker; |
|
|
|
|
|
|
|
|
|
// RocketChat.emoji.list is the collection of emojis from all emoji packages
|
|
|
|
|
for (const [key, currentEmoji] of Object.entries(config.emojione.emojioneList)) { |
|
|
|
|
currentEmoji.emojiPackage = 'emojione'; |
|
|
|
|
emoji.list[key] = currentEmoji; |
|
|
|
|
|
|
|
|
|
if (currentEmoji.shortnames) { |
|
|
|
|
currentEmoji.shortnames.forEach((shortname: string) => { |
|
|
|
|
emoji.list[shortname] = currentEmoji; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
emoji.dispatchUpdate(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
emoji.dispatchUpdate(); |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|