Emoji: Bypass legacy emoji normalization (#36377)
This commit is contained in:
@@ -70,7 +70,7 @@ function loaded() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
document.querySelectorAll('.emojify').forEach((content) => {
|
document.querySelectorAll('.emojify').forEach((content) => {
|
||||||
content.innerHTML = emojify(content.innerHTML);
|
content.innerHTML = emojify(content.innerHTML, {}, true); // Force emojify as public doesn't load the new emoji system.
|
||||||
});
|
});
|
||||||
|
|
||||||
document
|
document
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export const AccountBio: React.FC<AccountBioProps> = ({
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return isModernEmojiEnabled() ? account.note : account.note_emojified;
|
return account.note_emojified;
|
||||||
});
|
});
|
||||||
const extraEmojis = useAppSelector((state) => {
|
const extraEmojis = useAppSelector((state) => {
|
||||||
const account = state.accounts.get(accountId);
|
const account = state.accounts.get(accountId);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import type { ComponentPropsWithoutRef, FC } from 'react';
|
|||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
|
||||||
|
|
||||||
import { AnimateEmojiProvider } from '../emoji/context';
|
import { AnimateEmojiProvider } from '../emoji/context';
|
||||||
import { EmojiHTML } from '../emoji/html';
|
import { EmojiHTML } from '../emoji/html';
|
||||||
import { Skeleton } from '../skeleton';
|
import { Skeleton } from '../skeleton';
|
||||||
@@ -24,11 +22,7 @@ export const DisplayNameWithoutDomain: FC<
|
|||||||
{account ? (
|
{account ? (
|
||||||
<EmojiHTML
|
<EmojiHTML
|
||||||
className='display-name__html'
|
className='display-name__html'
|
||||||
htmlString={
|
htmlString={account.get('display_name_html')}
|
||||||
isModernEmojiEnabled()
|
|
||||||
? account.get('display_name')
|
|
||||||
: account.get('display_name_html')
|
|
||||||
}
|
|
||||||
as='strong'
|
as='strong'
|
||||||
extraEmojis={account.get('emojis')}
|
extraEmojis={account.get('emojis')}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import type { ComponentPropsWithoutRef, FC } from 'react';
|
import type { ComponentPropsWithoutRef, FC } from 'react';
|
||||||
|
|
||||||
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
|
||||||
|
|
||||||
import { EmojiHTML } from '../emoji/html';
|
import { EmojiHTML } from '../emoji/html';
|
||||||
|
|
||||||
import type { DisplayNameProps } from './index';
|
import type { DisplayNameProps } from './index';
|
||||||
@@ -19,11 +17,7 @@ export const DisplayNameSimple: FC<
|
|||||||
<EmojiHTML
|
<EmojiHTML
|
||||||
{...props}
|
{...props}
|
||||||
as='span'
|
as='span'
|
||||||
htmlString={
|
htmlString={account.get('display_name_html')}
|
||||||
isModernEmojiEnabled()
|
|
||||||
? account.get('display_name')
|
|
||||||
: account.get('display_name_html')
|
|
||||||
}
|
|
||||||
extraEmojis={account.get('emojis')}
|
extraEmojis={account.get('emojis')}
|
||||||
/>
|
/>
|
||||||
</bdi>
|
</bdi>
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function getStatusContent(status) {
|
export function getStatusContent(status) {
|
||||||
if (isModernEmojiEnabled()) {
|
|
||||||
return status.getIn(['translation', 'content']) || status.get('content');
|
|
||||||
}
|
|
||||||
return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
|
return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Trie from 'substring-trie';
|
import Trie from 'substring-trie';
|
||||||
|
|
||||||
|
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
||||||
import { assetHost } from 'mastodon/utils/config';
|
import { assetHost } from 'mastodon/utils/config';
|
||||||
|
|
||||||
import { autoPlayGif } from '../../initial_state';
|
import { autoPlayGif } from '../../initial_state';
|
||||||
@@ -148,7 +149,17 @@ const emojifyNode = (node, customEmojis) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const emojify = (str, customEmojis = {}) => {
|
/**
|
||||||
|
* Legacy emoji processing function.
|
||||||
|
* @param {string} str
|
||||||
|
* @param {object} customEmojis
|
||||||
|
* @param {boolean} force If true, always emojify even if modern emoji is enabled
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
const emojify = (str, customEmojis = {}, force = false) => {
|
||||||
|
if (isModernEmojiEnabled() && !force) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = str;
|
wrapper.innerHTML = str;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user