Files: b65df85068d01bbc7fd6b0ba8686cccbae6928ee / modules / suggest-emoji.js
683 bytesRaw
1 | exports.needs = { |
2 | emoji_url: 'first', |
3 | emoji_names: 'first' |
4 | } |
5 | |
6 | exports.gives = 'suggest_mentions' |
7 | |
8 | exports.create = function (api) { |
9 | |
10 | return function (word) { |
11 | return function (cb) { |
12 | if (word[0] !== ':' || word.length < 2) return cb() |
13 | word = word.substr(1) |
14 | if (word[word.length-1] === ':') word = word.substr(0, word.length-1) |
15 | cb(null, api.emoji_names().filter(function (name) { |
16 | return name.substr(0, word.length) === word |
17 | }).slice(0, 50).map(function (emoji) { |
18 | return { |
19 | image: api.emoji_url(emoji), |
20 | title: emoji, |
21 | subtitle: emoji, |
22 | value: ':' + emoji + ':' |
23 | } |
24 | })) |
25 | } |
26 | } |
27 | |
28 | } |
29 |
Built with git-ssb-web