Remove emojification on message send
This commit is contained in:
parent
4811b5fd4d
commit
7a55c68c6c
2 changed files with 5 additions and 25 deletions
|
@ -20,12 +20,7 @@ import classNames from 'classnames';
|
||||||
import emojiRegex from 'emoji-regex';
|
import emojiRegex from 'emoji-regex';
|
||||||
import { Emoji } from './emoji/Emoji';
|
import { Emoji } from './emoji/Emoji';
|
||||||
import { EmojiPickDataType } from './emoji/EmojiPicker';
|
import { EmojiPickDataType } from './emoji/EmojiPicker';
|
||||||
import {
|
import { convertShortName, EmojiData, search } from './emoji/lib';
|
||||||
convertShortName,
|
|
||||||
EmojiData,
|
|
||||||
replaceColons,
|
|
||||||
search,
|
|
||||||
} from './emoji/lib';
|
|
||||||
import { LocalizerType } from '../types/Util';
|
import { LocalizerType } from '../types/Util';
|
||||||
import { createRefMerger } from './_util';
|
import { createRefMerger } from './_util';
|
||||||
|
|
||||||
|
@ -395,9 +390,10 @@ export const CompositionInput = ({
|
||||||
|
|
||||||
const submit = React.useCallback(() => {
|
const submit = React.useCallback(() => {
|
||||||
const { current: state } = editorStateRef;
|
const { current: state } = editorStateRef;
|
||||||
const text = state.getCurrentContent().getPlainText();
|
const trimmedText = state
|
||||||
const emojidText = replaceColons(text);
|
.getCurrentContent()
|
||||||
const trimmedText = emojidText.trim();
|
.getPlainText()
|
||||||
|
.trim();
|
||||||
onSubmit(trimmedText);
|
onSubmit(trimmedText);
|
||||||
}, [editorStateRef, onSubmit]);
|
}, [editorStateRef, onSubmit]);
|
||||||
|
|
||||||
|
|
|
@ -274,22 +274,6 @@ export function emojiToImage(emoji: string): string | undefined {
|
||||||
return imageByEmoji[emoji];
|
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) {
|
function getCountOfAllMatches(str: string, regex: RegExp) {
|
||||||
let match = regex.exec(str);
|
let match = regex.exec(str);
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue