Skip to content
Snippets Groups Projects

Add emoji selector

Closed Jared Redford requested to merge jaredr/pleroma-fe:101-emoji-selector into develop
6 unresolved threads
18 files
+ 350
41
Compare changes
  • Side-by-side
  • Inline
Files
18
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,29 @@ 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.$emit('input', newValue)
this.caret += emoji.length
setTimeout(() => {
this.updateCaretPos()
})
},
updateCaretPos () {
const elem = this.$refs.input
if (elem.createTextRange) {
const range = elem.createTextRange()
range.move('character', this.caret)
range.select()
} else {
if (elem.selectionStart) {
elem.focus()
elem.setSelectionRange(this.caret, this.caret)
} else {
elem.focus()
}
}
}
}
}
Loading