diff --git a/client/js/lounge.js b/client/js/lounge.js index b67bc4eb..e7128eeb 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -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: "", + post: "" + } + ); + callback(results.map((el) => [el.string, el.original])); }, - template(value) { - return `${emojiMap[value]} ${value}`; + template([string, original]) { + return `${emojiMap[original]} ${string}`; }, - replace(value) { - return emojiMap[value]; + replace([, original]) { + return emojiMap[original]; }, index: 1 };