diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-03-07 02:34:48 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-03-07 02:34:48 +0000 |
commit | 0ec62b6c5d686496aa120edd66082af94007ca75 (patch) | |
tree | fd50989710ca09928c902c933890349a7dc23987 /app/assets/javascripts/gfm_auto_complete.js | |
parent | 55cc28d1ca167b502ef7a2f79b11e75fa559d174 (diff) | |
parent | 5ea6f4b017ae5cecf431d26bbf69fea524fe9428 (diff) | |
download | gitlab-ce-0ec62b6c5d686496aa120edd66082af94007ca75.tar.gz |
Merge branch '26371-native-emojis-v3' into 'master'
Add emoji images - Base Native Unicode Emojis
Closes #26371
See merge request !9569
Diffstat (limited to 'app/assets/javascripts/gfm_auto_complete.js')
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js index 60d6658dc16..1bc04a5ad96 100644 --- a/app/assets/javascripts/gfm_auto_complete.js +++ b/app/assets/javascripts/gfm_auto_complete.js @@ -1,5 +1,11 @@ /* eslint-disable func-names, space-before-function-paren, no-template-curly-in-string, comma-dangle, object-shorthand, quotes, dot-notation, no-else-return, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-param-reassign, no-useless-escape, prefer-template, consistent-return, wrap-iife, prefer-arrow-callback, camelcase, no-unused-vars, no-useless-return, vars-on-top, max-len */ +const emojiMap = require('emoji-map'); +const emojiAliases = require('emoji-aliases'); +const glEmoji = require('./behaviors/gl_emoji'); + +const glEmojiTag = glEmoji.glEmojiTag; + // Creates the variables for setting up GFM auto-completion (function() { if (window.gl == null) { @@ -26,7 +32,12 @@ }, // Emoji Emoji: { - template: '<li>${name} <img alt="${name}" height="20" src="${path}" width="20" /></li>' + templateFunction: function(name) { + return `<li> + ${name} ${glEmojiTag(name)} + </li> + `; + } }, // Team Members Members: { @@ -113,7 +124,7 @@ $input.atwho({ at: ':', displayTpl: function(value) { - return value.path != null ? this.Emoji.template : this.Loading.template; + return value && value.name ? this.Emoji.templateFunction(value.name) : this.Loading.template; }.bind(this), insertTpl: ':${name}:', skipSpecialCharacterTest: true, @@ -355,6 +366,8 @@ this.isLoadingData[at] = true; if (this.cachedData[at]) { this.loadData($input, at, this.cachedData[at]); + } else if (this.atTypeMap[at] === 'emojis') { + this.loadData($input, at, Object.keys(emojiMap).concat(Object.keys(emojiAliases))); } else { $.getJSON(this.dataSources[this.atTypeMap[at]], (data) => { this.loadData($input, at, data); |