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:
commit
db495e7162
1 changed files with 17 additions and 14 deletions
|
@ -533,21 +533,24 @@ 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);
|
||||||
|
|
||||||
const range = Range.create({
|
// only perform replacement if we found a match, otherwise we would be not letting user type
|
||||||
anchor: {
|
if (data) {
|
||||||
key: editorState.startText.key,
|
const range = Range.create({
|
||||||
offset: currentStartOffset - emoticonMatch[1].length - 1,
|
anchor: {
|
||||||
},
|
key: editorState.startText.key,
|
||||||
focus: {
|
offset: currentStartOffset - emoticonMatch[1].length - 1,
|
||||||
key: editorState.startText.key,
|
},
|
||||||
offset: currentStartOffset - 1,
|
focus: {
|
||||||
},
|
key: editorState.startText.key,
|
||||||
});
|
offset: currentStartOffset - 1,
|
||||||
change = change.insertTextAtRange(range, unicodeEmoji);
|
},
|
||||||
editorState = change.value;
|
});
|
||||||
|
change = change.insertTextAtRange(range, data.unicode);
|
||||||
|
editorState = change.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue