remove twemoji

This commit is contained in:
array-in-a-matrix 2023-04-08 01:36:28 -04:00
parent 7a0fe843dc
commit 23580c9de7
8 changed files with 15 additions and 33 deletions

View file

@ -210,19 +210,13 @@ const MessageBody = React.memo(({
let content = null;
if (isCustomHTML) {
try {
content = twemojify(
sanitizeCustomHtml(initMatrix.matrixClient, body),
undefined,
true,
false,
true,
);
content = twemojify(sanitizeCustomHtml(initMatrix.matrixClient, body), undefined, true, false);
} catch {
console.error('Malformed custom html: ', body);
content = twemojify(body, undefined);
content = twemojify(body);
}
} else {
content = twemojify(body, undefined, true);
content = twemojify(body);
}
// Determine if this message should render with large emojis

View file

@ -161,7 +161,7 @@ function RoomProfile({ roomId }) {
)}
</div>
<Text variant="b3">{room.getCanonicalAlias() || room.roomId}</Text>
{roomTopic && <Text variant="b2">{twemojify(roomTopic, undefined, true)}</Text>}
{roomTopic && <Text variant="b2">{twemojify(roomTopic)}</Text>}
</div>
);

View file

@ -33,7 +33,7 @@ function RoomTile({
</Text>
{
desc !== null && (typeof desc === 'string')
? <Text className="room-tile__content__desc" variant="b2">{twemojify(desc, undefined, true)}</Text>
? <Text className="room-tile__content__desc" variant="b2">{twemojify(desc)}</Text>
: desc
}
</div>

View file

@ -338,7 +338,7 @@ function EmojiBoard({ onSelect, searchRef }) {
</ScrollView>
</div>
<div ref={emojiInfo} className="emoji-board__content__info">
<div>{parse(twemoji.parse('🙂', { base: TWEMOJI_BASE_URL }))}</div>
<div>{parse('🙂')}</div>
<Text>:slight_smile:</Text>
</div>
</div>

View file

@ -5,7 +5,7 @@ import './RoomViewCmdBar.scss';
import parse from 'html-react-parser';
import twemoji from 'twemoji';
import { twemojify, TWEMOJI_BASE_URL } from '../../../util/twemojify';
import { twemojify } from '../../../util/twemojify';
import initMatrix from '../../../client/initMatrix';
import { getEmojiForCompletion } from '../emoji-board/custom-emoji';
@ -53,15 +53,7 @@ function renderSuggestions({ prefix, option, suggestions }, fireCmd) {
// Renders a small Twemoji
function renderTwemoji(emoji) {
return parse(
twemoji.parse(emoji.unicode, {
attributes: () => ({
unicode: emoji.unicode,
shortcodes: emoji.shortcodes?.toString(),
}),
base: TWEMOJI_BASE_URL,
})
);
return parse(emoji.unicode);
}
// Render a custom emoji

View file

@ -62,7 +62,7 @@ function RoomIntroContainer({ event, timeline }) {
avatarSrc = isDM ? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 80, 80, 'crop') : avatarSrc;
const heading = isDM ? room.name : `Welcome to ${room.name}`;
const topic = twemojify(roomTopic || '', undefined, true);
const topic = twemojify(roomTopic || '');
const nameJsx = twemojify(room.name);
const desc = isDM
? (

View file

@ -151,7 +151,7 @@ function SpaceManageItem({
: <Button variant="primary" onClick={handleJoin} disabled={isJoining}>{isJoining ? 'Joining...' : 'Join'}</Button>
}
</div>
{isExpand && roomInfo.topic && <Text variant="b2">{twemojify(roomInfo.topic, undefined, true)}</Text>}
{isExpand && roomInfo.topic && <Text variant="b2">{twemojify(roomInfo.topic)}</Text>}
</div>
);
}

View file

@ -30,20 +30,16 @@ const mathOptions = {
};
/**
* @param {string} text - text to twemojify
* @param {object|undefined} opts - options for tweomoji.parse
* @param {boolean} [linkify=false] - convert links to html tags (default: false)
* @param {string} text - text
* @param {undefined} opts
* @param {boolean} [linkify=true] - convert links to html tags (default: true)
* @param {boolean} [sanitize=true] - sanitize html text (default: true)
* @param {boolean} [maths=false] - render maths (default: false)
* @param {boolean} [maths=true] - render maths (default: true)
* @returns React component
*/
export function twemojify(text, opts, linkify = false, sanitize = true, maths = true) {
export function twemojify(text, opts, linkify = true, sanitize = true, maths = true) {
if (typeof text !== 'string') return text;
let content = text;
const options = opts ?? { base: TWEMOJI_BASE_URL };
if (!options.base) {
options.base = TWEMOJI_BASE_URL;
}
if (sanitize) {
content = sanitizeText(content);