diff options
| author | Henry Jameson <me@hjkos.com> | 2019-08-12 20:01:38 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2019-08-12 20:03:48 +0300 |
| commit | 5851f97eb058b3e2df91f9122ba899bc7e4affaf (patch) | |
| tree | 3e635d2a5f6d9755b24d5331a7a97043755d9ecb /src/components/emoji_input/emoji_input.js | |
| parent | 579b5c9e77154db5fe1bc712969b6fa39830442f (diff) | |
fixed a lot of bugs with emoji picker, improved relevant components
Diffstat (limited to 'src/components/emoji_input/emoji_input.js')
| -rw-r--r-- | src/components/emoji_input/emoji_input.js | 33 |
1 files changed, 30 insertions, 3 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 }, |
