diff options
Diffstat (limited to 'src/components/emoji_input')
| -rw-r--r-- | src/components/emoji_input/emoji_input.js | 33 | ||||
| -rw-r--r-- | src/components/emoji_input/emoji_input.vue | 16 |
2 files changed, 36 insertions, 13 deletions
diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index 5a9d1406..5ff27b20 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -58,6 +58,16 @@ const EmojiInput = { required: false, type: Boolean, default: false + }, + emojiPickerExternalTrigger: { + required: false, + type: Boolean, + default: false + }, + stickerPicker: { + required: false, + type: Boolean, + default: false } }, data () { @@ -95,9 +105,6 @@ const EmojiInput = { textAtCaret () { return (this.wordAtCaret || {}).word || '' }, - pickerIconBottom () { - return this.input && this.input.tag === 'textarea' - }, wordAtCaret () { if (this.value && this.caret) { const word = Completion.wordAtPosition(this.value, this.caret - 1) || {} @@ -133,6 +140,9 @@ const EmojiInput = { } }, methods: { + triggerShowPicker () { + this.showPicker = true + }, togglePicker () { this.showPicker = !this.showPicker }, @@ -148,6 +158,15 @@ const EmojiInput = { this.value.substring(this.caret) ].join('') this.$emit('input', newValue) + const position = this.caret + insertion.length + + this.$nextTick(function () { + // Re-focus inputbox after clicking suggestion + this.input.elm.focus() + // Set selection right after the replacement instead of the very end + this.input.elm.setSelectionRange(position, position) + this.caret = position + }) }, replaceText (e, suggestion) { const len = this.suggestions.length || 0 @@ -264,6 +283,14 @@ const EmojiInput = { onClickOutside () { this.showPicker = false }, + onStickerUploaded (e) { + this.showPicker = false + this.$emit('sticker-uploaded', e) + }, + onStickerUploadFailed (e) { + this.showPicker = false + this.$emit('sticker-upload-Failed', e) + }, setCaret ({ target: { selectionStart } }) { this.caret = selectionStart }, diff --git a/src/components/emoji_input/emoji_input.vue b/src/components/emoji_input/emoji_input.vue index 3ca12af1..b077e6e9 100644 --- a/src/components/emoji_input/emoji_input.vue +++ b/src/components/emoji_input/emoji_input.vue @@ -6,8 +6,8 @@ <slot /> <template v-if="emojiPicker"> <div + v-if="!emojiPickerExternalTrigger" class="emoji-picker-icon" - :class="pickerIconBottom ? 'picker-icon-bottom': 'picker-icon-right'" @click.prevent="togglePicker" > <i class="icon-smile" /> @@ -16,8 +16,11 @@ v-if="emojiPicker" ref="picker" :class="{ hide: !showPicker }" + :sticker-picker="stickerPicker" class="emoji-picker-panel" @emoji="insert" + @sticker-uploaded="onStickerUploaded" + @sticker-upload-failed="onStickerUploadFailed" /> </template> <div @@ -62,6 +65,8 @@ .emoji-picker-icon { position: absolute; + top: 0; + right: 0; margin: 0 .25em; font-size: 16px; cursor: pointer; @@ -70,15 +75,6 @@ color: $fallback--text; color: var(--text, $fallback--text); } - - &.picker-icon-bottom { - bottom: 0; - left: 0; - } - &.picker-icon-right { - top: 0; - right: 0; - } } .emoji-picker-panel { position: absolute; |
