mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-17 21:15:47 +02:00
Add exact emoji name match detection to emoji keyboard
This commit is contained in:
parent
ab14b72526
commit
ec2aaa8789
Resources/Plugins/emoji-keyboard
@ -9,7 +9,7 @@ Emoji keyboard
|
|||||||
chylex
|
chylex
|
||||||
|
|
||||||
[version]
|
[version]
|
||||||
1.4
|
1.4.1
|
||||||
|
|
||||||
[website]
|
[website]
|
||||||
https://tweetduck.chylex.com
|
https://tweetduck.chylex.com
|
||||||
|
@ -303,23 +303,26 @@ enabled(){
|
|||||||
let firstColon = val.lastIndexOf(':', ele[0].selectionStart);
|
let firstColon = val.lastIndexOf(':', ele[0].selectionStart);
|
||||||
return if firstColon === -1;
|
return if firstColon === -1;
|
||||||
|
|
||||||
let search = val.substring(firstColon+1, ele[0].selectionStart);
|
let search = val.substring(firstColon+1, ele[0].selectionStart).toLowerCase();
|
||||||
return if !/^[a-z_]+$/i.test(search);
|
return if !/^[a-z_]+$/.test(search);
|
||||||
|
|
||||||
let keywords = search.split("_").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
|
let keywords = search.split("_").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
|
||||||
return if keywords.length === 0;
|
return if keywords.length === 0;
|
||||||
|
|
||||||
let foundName = me.emojiNames.filter(name => keywords.every(kw => name.includes(kw)));
|
let foundNames = me.emojiNames.filter(name => keywords.every(kw => name.includes(kw)));
|
||||||
|
|
||||||
if (foundName.length === 0){
|
if (foundNames.length === 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (foundNames.length > 1 && foundNames.includes(search)){
|
||||||
|
foundNames = [ search ];
|
||||||
|
}
|
||||||
|
|
||||||
lastEmojiKeyword = `:${search}:`;
|
lastEmojiKeyword = `:${search}:`;
|
||||||
lastEmojiPosition = lastEmojiLength = 0;
|
lastEmojiPosition = lastEmojiLength = 0;
|
||||||
|
|
||||||
if (foundName.length === 1){
|
if (foundNames.length === 1){
|
||||||
let foundIndex = me.emojiNames.indexOf(foundName[0]);
|
let foundIndex = me.emojiNames.indexOf(foundNames[0]);
|
||||||
let foundEmoji;
|
let foundEmoji;
|
||||||
|
|
||||||
for(let array of [ me.emojiData1, me.emojiData2[me.selectedSkinTone], me.emojiData3 ]){
|
for(let array of [ me.emojiData1, me.emojiData2[me.selectedSkinTone], me.emojiData3 ]){
|
||||||
@ -346,7 +349,7 @@ enabled(){
|
|||||||
lastEmojiLength = foundEmoji.length;
|
lastEmojiLength = foundEmoji.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (foundName.length > 1){
|
else if (foundNames.length > 1){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ele.val(val.substring(0, firstColon)+val.substring(ele[0].selectionStart));
|
ele.val(val.substring(0, firstColon)+val.substring(ele[0].selectionStart));
|
||||||
ele[0].selectionEnd = ele[0].selectionStart = firstColon;
|
ele[0].selectionEnd = ele[0].selectionStart = firstColon;
|
||||||
|
Loading…
Reference in New Issue
Block a user