diff --git a/client/src/components/chat.vue b/client/src/components/chat.vue
index 694832b..85a8ae8 100644
--- a/client/src/components/chat.vue
+++ b/client/src/components/chat.vue
@@ -35,8 +35,16 @@
@@ -336,9 +344,11 @@
},
})
export default class extends Vue {
+ @Ref('input') readonly _input!: HTMLTextAreaElement
@Ref('history') readonly _history!: HTMLElement
@Ref('context') readonly _context!: any
+ emoji = false
content = ''
get id() {
@@ -360,6 +370,11 @@
})
}
+ @Watch('emoji')
+ onEmojiChange() {
+ this._input.focus()
+ }
+
@Watch('muted')
onMutedChange(muted: boolean) {
if (muted) {
@@ -382,6 +397,22 @@
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`
}
+ onEmojiPicked(emoji: string) {
+ const text = `:${emoji}:`
+ if (this._input.selectionStart || this._input.selectionStart === 0) {
+ var startPos = this._input.selectionStart
+ var endPos = this._input.selectionEnd
+ this.content = this.content.substring(0, startPos) + text + this.content.substring(endPos, this.content.length)
+ this.$nextTick(() => {
+ this._input.selectionStart = startPos + text.length
+ this._input.selectionEnd = startPos + text.length
+ })
+ } else {
+ this.content += text
+ }
+ this.emoji = false
+ }
+
onContext(event: MouseEvent, data: any) {
this._context.open(event, data)
}
diff --git a/client/src/components/emoji.vue b/client/src/components/emoji.vue
index 0c55e7e..28701e6 100644
--- a/client/src/components/emoji.vue
+++ b/client/src/components/emoji.vue
@@ -1,7 +1,9 @@
@@ -47,7 +49,7 @@
:class="[group.id, active === group.id && search === '' ? 'active' : '']"
@click.stop.prevent="scrollTo($event, index)"
>
-
+
@@ -55,12 +57,13 @@