Remove emojification on message send

This commit is contained in:
Ken Powers 2020-05-07 15:58:28 -04:00 committed by GitHub
parent 4811b5fd4d
commit 7a55c68c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 25 deletions
ts/components

View file

@ -20,12 +20,7 @@ import classNames from 'classnames';
import emojiRegex from 'emoji-regex';
import { Emoji } from './emoji/Emoji';
import { EmojiPickDataType } from './emoji/EmojiPicker';
import {
convertShortName,
EmojiData,
replaceColons,
search,
} from './emoji/lib';
import { convertShortName, EmojiData, search } from './emoji/lib';
import { LocalizerType } from '../types/Util';
import { createRefMerger } from './_util';
@ -395,9 +390,10 @@ export const CompositionInput = ({
const submit = React.useCallback(() => {
const { current: state } = editorStateRef;
const text = state.getCurrentContent().getPlainText();
const emojidText = replaceColons(text);
const trimmedText = emojidText.trim();
const trimmedText = state
.getCurrentContent()
.getPlainText()
.trim();
onSubmit(trimmedText);
}, [editorStateRef, onSubmit]);

View file

@ -274,22 +274,6 @@ export function emojiToImage(emoji: string): string | undefined {
return imageByEmoji[emoji];
}
export function replaceColons(str: string) {
return str.replace(/:[a-z0-9-_+]+:(?::skin-tone-[1-5]:)?/gi, m => {
const [shortName = '', skinTone = '0'] = m
.replace('skin-tone-', '')
.toLowerCase()
.split(':')
.filter(Boolean);
if (shortName && isShortName(shortName)) {
return convertShortName(shortName, parseInt(skinTone, 10));
}
return m;
});
}
function getCountOfAllMatches(str: string, regex: RegExp) {
let match = regex.exec(str);
let count = 0;