import type { ComponentPropsWithoutRef, ElementType } from 'react'; import { isModernEmojiEnabled } from '@/mastodon/utils/environment'; import { useEmojify } from './hooks'; import type { CustomEmojiMapArg } from './types'; type EmojiHTMLProps = Omit< ComponentPropsWithoutRef, 'dangerouslySetInnerHTML' > & { htmlString: string; extraEmojis?: CustomEmojiMapArg; as?: Element; }; export const ModernEmojiHTML = ({ extraEmojis, htmlString, as: asElement, // Rename for syntax highlighting ...props }: EmojiHTMLProps) => { const Wrapper = asElement ?? 'div'; const emojifiedHtml = useEmojify(htmlString, extraEmojis); if (emojifiedHtml === null) { return null; } return ( ); }; export const EmojiHTML = ( props: EmojiHTMLProps, ) => { if (isModernEmojiEnabled()) { return ; } const Wrapper = props.as ?? 'div'; return ( ); };