mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe.git
synced 2024-11-08 17:39:09 +00:00
#101 - insert emoji from emoji selector
This commit is contained in:
parent
f9071dac25
commit
3172b4e7c1
4 changed files with 30 additions and 3 deletions
|
@ -105,6 +105,11 @@ const EmojiInput = {
|
||||||
},
|
},
|
||||||
setCaret ({target: {selectionStart}}) {
|
setCaret ({target: {selectionStart}}) {
|
||||||
this.caret = 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="emoji-input">
|
<div class="emoji-input">
|
||||||
<EmojiSelector />
|
|
||||||
<input
|
<input
|
||||||
v-if="type !== 'textarea'"
|
v-if="type !== 'textarea'"
|
||||||
:class="classname"
|
:class="classname"
|
||||||
|
@ -16,6 +15,7 @@
|
||||||
@keydown.shift.tab="cycleBackward"
|
@keydown.shift.tab="cycleBackward"
|
||||||
@keydown.tab="cycleForward"
|
@keydown.tab="cycleForward"
|
||||||
@keydown.enter="replaceEmoji"
|
@keydown.enter="replaceEmoji"
|
||||||
|
ref="input"
|
||||||
/>
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
v-else
|
v-else
|
||||||
|
@ -31,7 +31,9 @@
|
||||||
@keydown.shift.tab="cycleBackward"
|
@keydown.shift.tab="cycleBackward"
|
||||||
@keydown.tab="cycleForward"
|
@keydown.tab="cycleForward"
|
||||||
@keydown.enter="replaceEmoji"
|
@keydown.enter="replaceEmoji"
|
||||||
|
ref="input"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
<EmojiSelector @emoji="onEmoji" />
|
||||||
<div class="autocomplete-panel" v-if="suggestions">
|
<div class="autocomplete-panel" v-if="suggestions">
|
||||||
<div class="autocomplete-panel-body">
|
<div class="autocomplete-panel-body">
|
||||||
<div
|
<div
|
||||||
|
@ -58,6 +60,8 @@
|
||||||
@import '../../_variables.scss';
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
.emoji-input {
|
.emoji-input {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
.form-control {
|
.form-control {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,11 @@ const EmojiSelector = {
|
||||||
methods: {
|
methods: {
|
||||||
togglePanel () {
|
togglePanel () {
|
||||||
this.open = !this.open
|
this.open = !this.open
|
||||||
|
},
|
||||||
|
onEmoji (emoji) {
|
||||||
|
const value = emoji.image_url ? `:${emoji.shortcode}:` : emoji.utf
|
||||||
|
this.$emit('emoji', ` ${value} `)
|
||||||
|
this.open = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -14,7 +14,13 @@
|
||||||
<div class="emoji-groups">
|
<div class="emoji-groups">
|
||||||
<div v-for="(value, key) in emojis" :key="key" class="emoji-group">
|
<div v-for="(value, key) in emojis" :key="key" class="emoji-group">
|
||||||
<h6 class="emoji-group-title">{{value.text}}</h6>
|
<h6 class="emoji-group-title">{{value.text}}</h6>
|
||||||
<span v-for="emoji in value.emojis" :key="key + emoji.shortcode" :title="emoji.shortcode" class="emoji-item">
|
<span
|
||||||
|
v-for="emoji in value.emojis"
|
||||||
|
:key="key + emoji.shortcode"
|
||||||
|
:title="emoji.shortcode"
|
||||||
|
class="emoji-item"
|
||||||
|
@click="onEmoji(emoji)"
|
||||||
|
>
|
||||||
<span v-if="!emoji.image_url">{{emoji.utf}}</span>
|
<span v-if="!emoji.image_url">{{emoji.utf}}</span>
|
||||||
<img :src="'https://bikeshed.party' + emoji.image_url" v-else>
|
<img :src="'https://bikeshed.party' + emoji.image_url" v-else>
|
||||||
</span>
|
</span>
|
||||||
|
@ -32,20 +38,27 @@
|
||||||
|
|
||||||
.emoji {
|
.emoji {
|
||||||
&-dropdown {
|
&-dropdown {
|
||||||
position: relative;
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 2px;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
&-toggle {
|
&-toggle {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-menu {
|
&-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
top: 25px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
margin: 0 !important;
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
flex: 1 1 1px;
|
flex: 1 1 1px;
|
||||||
|
|
Loading…
Reference in a new issue