From 581e3e836ad6c8a9a211eb09d7eaa1fbaf830da2 Mon Sep 17 00:00:00 2001 From: eal Date: Mon, 20 Nov 2017 20:32:51 +0200 Subject: Add completion for normal emoji. --- src/components/post_status_form/post_status_form.js | 8 ++++++-- src/components/post_status_form/post_status_form.vue | 5 +++-- src/main.js | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6fc84407..2eb091f4 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -64,14 +64,15 @@ const PostStatusForm = { img: profile_image_url_original })) } else if (firstchar === ':') { - const matchedEmoji = filter(this.emoji, (emoji) => emoji.shortcode.match(this.textAtCaret.slice(1))) + const matchedEmoji = filter(this.emoji.concat(this.customEmoji), (emoji) => emoji.shortcode.match(this.textAtCaret.slice(1))) if (matchedEmoji.length <= 0) { return false } - return map(take(matchedEmoji, 5), ({shortcode, image_url}) => ({ + return map(take(matchedEmoji, 5), ({shortcode, image_url, utf}) => ({ // eslint-disable-next-line camelcase screen_name: `:${shortcode}:`, name: '', + utf: utf || '', img: image_url })) } else { @@ -90,6 +91,9 @@ const PostStatusForm = { }, emoji () { return this.$store.state.config.emoji || [] + }, + customEmoji () { + return this.$store.state.config.customEmoji || [] } }, methods: { diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index d0210286..8a2ec24d 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -6,8 +6,9 @@
-
- +
+ + {{candidate.utf}} {{candidate.screen_name}} {{candidate.name}} diff --git a/src/main.js b/src/main.js index b6544a5a..14cb27eb 100644 --- a/src/main.js +++ b/src/main.js @@ -125,5 +125,14 @@ window.fetch('/api/pleroma/emoji.json') const emoji = Object.keys(values).map((key) => { return { shortcode: key, image_url: values[key] } }) + store.dispatch('setOption', { name: 'customEmoji', value: emoji }) + }) + +window.fetch('/static/emoji.json') + .then((res) => res.json()) + .then((values) => { + const emoji = Object.keys(values).map((key) => { + return { shortcode: key, image_url: false, 'utf': values[key] } + }) store.dispatch('setOption', { name: 'emoji', value: emoji }) }) -- cgit v1.2.3-70-g09d2