diff options
Diffstat (limited to 'src/components/emoji-input')
| -rw-r--r-- | src/components/emoji-input/emoji-input.js | 10 | ||||
| -rw-r--r-- | src/components/emoji-input/emoji-input.vue | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js index a5bb6eaf..8f7598ca 100644 --- a/src/components/emoji-input/emoji-input.js +++ b/src/components/emoji-input/emoji-input.js @@ -1,4 +1,6 @@ import Completion from '../../services/completion/completion.js' +import EmojiSelector from '../emoji-selector/emoji-selector.vue' + import { take, filter, map } from 'lodash' const EmojiInput = { @@ -14,6 +16,9 @@ const EmojiInput = { caret: 0 } }, + components: { + EmojiSelector + }, computed: { suggestions () { const firstchar = this.textAtCaret.charAt(0) @@ -100,6 +105,11 @@ const EmojiInput = { }, setCaret ({target: {selectionStart}}) { this.caret = selectionStart + }, + onEmoji (emoji) { + const newValue = this.value.substr(0, this.caret) + emoji + this.value.substr(this.caret) + this.$refs.input.focus() + this.$emit('input', newValue) } } } diff --git a/src/components/emoji-input/emoji-input.vue b/src/components/emoji-input/emoji-input.vue index 338b77cd..151861de 100644 --- a/src/components/emoji-input/emoji-input.vue +++ b/src/components/emoji-input/emoji-input.vue @@ -15,6 +15,7 @@ @keydown.shift.tab="cycleBackward" @keydown.tab="cycleForward" @keydown.enter="replaceEmoji" + ref="input" /> <textarea v-else @@ -30,7 +31,9 @@ @keydown.shift.tab="cycleBackward" @keydown.tab="cycleForward" @keydown.enter="replaceEmoji" + ref="input" ></textarea> + <EmojiSelector @emoji="onEmoji" /> <div class="autocomplete-panel" v-if="suggestions"> <div class="autocomplete-panel-body"> <div @@ -57,6 +60,8 @@ @import '../../_variables.scss'; .emoji-input { + position: relative; + .form-control { width: 100%; } |
