2019-03-26 13:38:15 +11:00
|
|
|
<template>
|
|
|
|
<div class="emoji-input">
|
|
|
|
<input
|
2019-03-27 04:40:37 +11:00
|
|
|
v-if="type !== 'textarea'"
|
|
|
|
:class="classname"
|
2019-03-26 13:38:15 +11:00
|
|
|
:type="type"
|
|
|
|
:value="value"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
@input="onInput"
|
|
|
|
@click="setCaret"
|
|
|
|
@keyup="setCaret"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
@keydown.down="cycleForward"
|
|
|
|
@keydown.up="cycleBackward"
|
|
|
|
@keydown.shift.tab="cycleBackward"
|
|
|
|
@keydown.tab="cycleForward"
|
|
|
|
@keydown.enter="replaceEmoji"
|
|
|
|
/>
|
2019-03-27 04:40:37 +11:00
|
|
|
<textarea
|
|
|
|
v-else
|
|
|
|
:class="classname"
|
|
|
|
:value="value"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
@input="onInput"
|
|
|
|
@click="setCaret"
|
|
|
|
@keyup="setCaret"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
@keydown.down="cycleForward"
|
|
|
|
@keydown.up="cycleBackward"
|
|
|
|
@keydown.shift.tab="cycleBackward"
|
|
|
|
@keydown.tab="cycleForward"
|
|
|
|
@keydown.enter="replaceEmoji"
|
|
|
|
></textarea>
|
2019-03-26 13:38:15 +11:00
|
|
|
<div class="autocomplete-panel" v-if="suggestions">
|
|
|
|
<div class="autocomplete-panel-body">
|
|
|
|
<div
|
|
|
|
v-for="(emoji, index) in suggestions"
|
|
|
|
:key="index"
|
|
|
|
@click="replace(emoji.utf || (emoji.shortcode + ' '))"
|
|
|
|
class="autocomplete-item"
|
|
|
|
:class="{ highlighted: emoji.highlighted }"
|
|
|
|
>
|
|
|
|
<span v-if="emoji.img">
|
|
|
|
<img :src="emoji.img" />
|
|
|
|
</span>
|
|
|
|
<span v-else>{{emoji.utf}}</span>
|
|
|
|
<span>{{emoji.shortcode}}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script src="./emoji-input.js"></script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '../../_variables.scss';
|
|
|
|
|
|
|
|
.emoji-input {
|
|
|
|
.form-control {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|