You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-20 16:22:28 +03:00
Merge pull request #3070 from matrix-org/t3chguy/fuzzier-emojis
Be somewhat fuzzier when matching emojis to complete on space
This commit is contained in:
@@ -533,9 +533,11 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
// The first matched group includes just the matched plaintext emoji
|
// The first matched group includes just the matched plaintext emoji
|
||||||
const emoticonMatch = REGEX_EMOTICON_WHITESPACE.exec(text.slice(0, currentStartOffset));
|
const emoticonMatch = REGEX_EMOTICON_WHITESPACE.exec(text.slice(0, currentStartOffset));
|
||||||
if (emoticonMatch) {
|
if (emoticonMatch) {
|
||||||
const data = EMOJIBASE.find(e => e.emoticon === emoticonMatch[1]);
|
const query = emoticonMatch[1].toLowerCase().replace("-", "");
|
||||||
const unicodeEmoji = data ? data.unicode : '';
|
const data = EMOJIBASE.find(e => e.emoticon ? e.emoticon.toLowerCase() === query : false);
|
||||||
|
|
||||||
|
// only perform replacement if we found a match, otherwise we would be not letting user type
|
||||||
|
if (data) {
|
||||||
const range = Range.create({
|
const range = Range.create({
|
||||||
anchor: {
|
anchor: {
|
||||||
key: editorState.startText.key,
|
key: editorState.startText.key,
|
||||||
@@ -546,11 +548,12 @@ export default class MessageComposerInput extends React.Component {
|
|||||||
offset: currentStartOffset - 1,
|
offset: currentStartOffset - 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
change = change.insertTextAtRange(range, unicodeEmoji);
|
change = change.insertTextAtRange(range, data.unicode);
|
||||||
editorState = change.value;
|
editorState = change.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.props.onInputStateChanged && editorState.blocks.size > 0) {
|
if (this.props.onInputStateChanged && editorState.blocks.size > 0) {
|
||||||
let blockType = editorState.blocks.first().type;
|
let blockType = editorState.blocks.first().type;
|
||||||
|
|||||||
Reference in New Issue
Block a user