Performance regression fixes (#35664)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
.gitattributes
|
.gitattributes
|
||||||
.gitignore
|
.gitignore
|
||||||
.github
|
.github
|
||||||
|
.vscode
|
||||||
public/system
|
public/system
|
||||||
public/assets
|
public/assets
|
||||||
public/packs
|
public/packs
|
||||||
@@ -20,6 +21,7 @@ postgres14
|
|||||||
redis
|
redis
|
||||||
elasticsearch
|
elasticsearch
|
||||||
chart
|
chart
|
||||||
|
storybook-static
|
||||||
.yarn/
|
.yarn/
|
||||||
!.yarn/patches
|
!.yarn/patches
|
||||||
!.yarn/plugins
|
!.yarn/plugins
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import type { ComponentPropsWithoutRef, ElementType } from 'react';
|
import type { ComponentPropsWithoutRef, ElementType } from 'react';
|
||||||
|
|
||||||
|
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
||||||
|
|
||||||
import { useEmojify } from './hooks';
|
import { useEmojify } from './hooks';
|
||||||
import type { CustomEmojiMapArg } from './types';
|
import type { CustomEmojiMapArg } from './types';
|
||||||
|
|
||||||
@@ -12,7 +14,7 @@ type EmojiHTMLProps<Element extends ElementType = 'div'> = Omit<
|
|||||||
as?: Element;
|
as?: Element;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EmojiHTML = <Element extends ElementType>({
|
export const ModernEmojiHTML = <Element extends ElementType>({
|
||||||
extraEmojis,
|
extraEmojis,
|
||||||
htmlString,
|
htmlString,
|
||||||
as: asElement, // Rename for syntax highlighting
|
as: asElement, // Rename for syntax highlighting
|
||||||
@@ -29,3 +31,18 @@ export const EmojiHTML = <Element extends ElementType>({
|
|||||||
<Wrapper {...props} dangerouslySetInnerHTML={{ __html: emojifiedHtml }} />
|
<Wrapper {...props} dangerouslySetInnerHTML={{ __html: emojifiedHtml }} />
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const EmojiHTML = <Element extends ElementType>(
|
||||||
|
props: EmojiHTMLProps<Element>,
|
||||||
|
) => {
|
||||||
|
if (isModernEmojiEnabled()) {
|
||||||
|
return <ModernEmojiHTML {...props} />;
|
||||||
|
}
|
||||||
|
const Wrapper = props.as ?? 'div';
|
||||||
|
return (
|
||||||
|
<Wrapper
|
||||||
|
{...props}
|
||||||
|
dangerouslySetInnerHTML={{ __html: props.htmlString }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
|
|||||||
|
|
||||||
import { toSupportedLocale } from './locale';
|
import { toSupportedLocale } from './locale';
|
||||||
import { determineEmojiMode } from './mode';
|
import { determineEmojiMode } from './mode';
|
||||||
import { emojifyElement } from './render';
|
|
||||||
import type {
|
import type {
|
||||||
CustomEmojiMapArg,
|
CustomEmojiMapArg,
|
||||||
EmojiAppState,
|
EmojiAppState,
|
||||||
@@ -39,6 +38,7 @@ export function useEmojify(text: string, extraEmojis?: CustomEmojiMapArg) {
|
|||||||
async (input: string) => {
|
async (input: string) => {
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = input;
|
wrapper.innerHTML = input;
|
||||||
|
const { emojifyElement } = await import('./render');
|
||||||
const result = await emojifyElement(wrapper, appState, extra);
|
const result = await emojifyElement(wrapper, appState, extra);
|
||||||
if (result) {
|
if (result) {
|
||||||
setEmojifiedText(result.innerHTML);
|
setEmojifiedText(result.innerHTML);
|
||||||
|
|||||||
Reference in New Issue
Block a user