improved emoji suggestions

This commit is contained in:
unknown 2021-08-10 14:12:00 +05:30
parent 90e67b22b4
commit 5e76d6d865
2 changed files with 26 additions and 1 deletions

View file

@ -276,7 +276,22 @@ function getCmdSuggestions({ prefix, slug }, fireCmd, viewEvent) {
} }
function getEmojiSuggestion(emPrefix, shortcutSlug) { function getEmojiSuggestion(emPrefix, shortcutSlug) {
const result = searchEmoji(shortcutSlug); let searchTerm = shortcutSlug;
if (searchTerm.length <= 3) {
if (searchTerm.match(/^[-]?(\))/)) searchTerm = 'smile';
else if (searchTerm.match(/^[-]?(s|S)/)) searchTerm = 'confused';
else if (searchTerm.match(/^[-]?(o|O|0)/)) searchTerm = 'astonished';
else if (searchTerm.match(/^[-]?(\|)/)) searchTerm = 'neutral_face';
else if (searchTerm.match(/^[-]?(d|D)/)) searchTerm = 'grin';
else if (searchTerm.match(/^[-]?(\/)/)) searchTerm = 'frown';
else if (searchTerm.match(/^[-]?(p|P)/)) searchTerm = 'stick_out_tongue';
else if (searchTerm.match(/^'[-]?(\()/)) searchTerm = 'cry';
else if (searchTerm.match(/^[-]?(x|X)/)) searchTerm = 'dizzy_face';
else if (searchTerm.match(/^[-]?(\()/)) searchTerm = 'pleading_face';
else if (searchTerm.match(/^[-]?(\$)/)) searchTerm = 'money';
else if (searchTerm.match(/^(<3)/)) searchTerm = 'heart';
}
const result = searchEmoji(searchTerm);
if (result.length === 0) viewEvent.emit('cmd_error'); if (result.length === 0) viewEvent.emit('cmd_error');
perfectMatchCmd = { perfectMatchCmd = {
prefix: emPrefix, prefix: emPrefix,

View file

@ -213,6 +213,16 @@ function ChannelViewInput({
const cmdPrefix = cmdParts[1]; const cmdPrefix = cmdParts[1];
const cmdSlug = cmdParts[2]; const cmdSlug = cmdParts[2];
if (cmdPrefix === ':') {
// skip emoji autofill command if link is suspected.
const checkForLink = targetInput.slice(0, cmdParts.index);
if (checkForLink.match(/(http|https|mailto|matrix|ircs|irc)$/)) {
deactivateCmd();
viewEvent.emit('cmd_deactivate');
return;
}
}
cmdCursorPos = cursor; cmdCursorPos = cursor;
if (cmdSlug === '') { if (cmdSlug === '') {
activateCmd(cmdPrefix); activateCmd(cmdPrefix);