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