<template>
|
<div id="area">
|
<a-form-item>
|
<a-textarea ref="targetArea" :rows="4" v-model="visitorContent" :placeholder="this.$attrs.replyHolder"
|
class="OwO-textarea" />
|
</a-form-item>
|
<MyOwO @insertOwO="insertOwO"></MyOwO>
|
</div>
|
</template>
|
|
<script>
|
import MyOwO from './MyOwO.vue'
|
|
export default {
|
components: {
|
MyOwO
|
},
|
props: {
|
content: String
|
},
|
data() {
|
return {
|
visitorContent: '',
|
}
|
},
|
watch: {
|
visitorContent: function(newValue, oldValue) {
|
// if (newValue.length > 0) {
|
// if (!this.init) {
|
// this.showTip = true;
|
// setTimeout(() => {
|
// this.showTip = false;
|
// }, 5000);
|
// }
|
// this.init = true;
|
// this.initOwO();
|
// }
|
this.$emit("update:content", newValue)
|
},
|
},
|
methods: {
|
insertOwO(text) {
|
console.log(text);
|
this.insertInputTxt(text)
|
},
|
insertInputTxt(insertTxt) {
|
var elInput = this.$refs.targetArea.$el
|
var startPos = elInput.selectionStart
|
var endPos = elInput.selectionEnd
|
if (startPos === undefined || endPos === undefined) return
|
var txt = elInput.value
|
var result = txt.substring(0, startPos) + insertTxt + txt.substring(endPos)
|
elInput.value = result
|
this.visitorContent = result
|
elInput.focus()
|
elInput.selectionStart = startPos + insertTxt.length
|
elInput.selectionEnd = startPos + insertTxt.length
|
|
this.$emit("update:content", this.visitorContent)
|
}
|
}
|
}
|
</script>
|
|
<style>
|
|
</style>
|