fix bigemoji
parent
24b03374ac
commit
9f70bf3aec
|
@ -32,7 +32,7 @@ import MatrixClientPeg from './MatrixClientPeg';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
|
|
||||||
import EMOJIBASE from 'emojibase-data/en/compact.json';
|
import EMOJIBASE from 'emojibase-data/en/compact.json';
|
||||||
import EMOJI_REGEX from 'emojibase-regex';
|
import EMOJIBASE_REGEX from 'emojibase-regex';
|
||||||
|
|
||||||
linkifyMatrix(linkify);
|
linkifyMatrix(linkify);
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ const ZWJ_REGEX = new RegExp("\u200D|\u2003", "g");
|
||||||
// Regex pattern for whitespace characters
|
// Regex pattern for whitespace characters
|
||||||
const WHITESPACE_REGEX = new RegExp("\\s", "g");
|
const WHITESPACE_REGEX = new RegExp("\\s", "g");
|
||||||
|
|
||||||
|
const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX})+$`, "i");
|
||||||
|
|
||||||
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
|
const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/;
|
||||||
|
|
||||||
const PERMITTED_URL_SCHEMES = ['http', 'https', 'ftp', 'mailto', 'magnet'];
|
const PERMITTED_URL_SCHEMES = ['http', 'https', 'ftp', 'mailto', 'magnet'];
|
||||||
|
@ -442,7 +444,6 @@ export function bodyToHtml(content, highlights, opts={}) {
|
||||||
|
|
||||||
let emojiBody = false;
|
let emojiBody = false;
|
||||||
if (!opts.disableBigEmoji && bodyHasEmoji) {
|
if (!opts.disableBigEmoji && bodyHasEmoji) {
|
||||||
EMOJI_REGEX.lastIndex = 0;
|
|
||||||
let contentBodyTrimmed = strippedBody !== undefined ? strippedBody.trim() : '';
|
let contentBodyTrimmed = strippedBody !== undefined ? strippedBody.trim() : '';
|
||||||
|
|
||||||
// Ignore spaces in body text. Emojis with spaces in between should
|
// Ignore spaces in body text. Emojis with spaces in between should
|
||||||
|
@ -454,7 +455,7 @@ export function bodyToHtml(content, highlights, opts={}) {
|
||||||
// presented as large.
|
// presented as large.
|
||||||
contentBodyTrimmed = contentBodyTrimmed.replace(ZWJ_REGEX, '');
|
contentBodyTrimmed = contentBodyTrimmed.replace(ZWJ_REGEX, '');
|
||||||
|
|
||||||
const match = EMOJI_REGEX.exec(contentBodyTrimmed);
|
const match = BIGEMOJI_REGEX.exec(contentBodyTrimmed);
|
||||||
emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length &&
|
emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length &&
|
||||||
// Prevent user pills expanding for users with only emoji in
|
// Prevent user pills expanding for users with only emoji in
|
||||||
// their username
|
// their username
|
||||||
|
|
Loading…
Reference in New Issue