mirror of
https://github.com/thelounge/thelounge
synced 2024-11-29 23:40:28 +00:00
Merge pull request #1334 from MaxLeiter/MaxLeiter/emoji
Emoji fuzzysearching
This commit is contained in:
commit
4e7eed7958
1 changed files with 14 additions and 5 deletions
|
@ -45,17 +45,26 @@ $(function() {
|
|||
|
||||
// Autocompletion Strategies
|
||||
|
||||
const emojiSearchTerms = Object.keys(emojiMap);
|
||||
const emojiStrategy = {
|
||||
id: "emoji",
|
||||
match: /\B:([-+\w]*):?$/,
|
||||
search(term, callback) {
|
||||
callback(Object.keys(emojiMap).filter((name) => name.indexOf(term) === 0));
|
||||
const results = fuzzy.filter(
|
||||
term,
|
||||
emojiSearchTerms,
|
||||
{
|
||||
pre: "<b>",
|
||||
post: "</b>"
|
||||
}
|
||||
);
|
||||
callback(results.map((el) => [el.string, el.original]));
|
||||
},
|
||||
template(value) {
|
||||
return `<span class="emoji">${emojiMap[value]}</span> ${value}`;
|
||||
template([string, original]) {
|
||||
return `<span class="emoji">${emojiMap[original]}</span> ${string}`;
|
||||
},
|
||||
replace(value) {
|
||||
return emojiMap[value];
|
||||
replace([, original]) {
|
||||
return emojiMap[original];
|
||||
},
|
||||
index: 1
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue