Commit 7d33ff72 by xinla

新增选择表情、扩展带 插入 表情/客户昵称 等工具栏的文本内容框 公共组件

1 parent b8a3e25c
// 选择表情组件
<script>
export default {
name: '',
components: {},
data() {
return {
visible: false,
emoji: Object.freeze([
'😀',
'😃',
'😄',
'😁',
'😆',
'😅',
'🤣',
'😂',
'🙂',
'🙃',
'🫠',
'😉',
'😊',
'😇',
'🥰',
'😍',
'🤩',
'😘',
'😗',
'😚',
'😙',
'🥲',
'😋',
'😛',
'😜',
'🤪',
'😝',
'🤑',
'🤗',
'🤭',
'🫢',
'🫣',
'🤫',
'🤔',
'🫡',
'🤐',
'🤨',
'😐',
'😑',
'😶',
'🫥',
'😏',
'😒',
'🙄',
'😬',
'🤥',
'😌',
'😔',
'😪',
'🤤',
'😴',
'😷',
'🤒',
'🤕',
'🤢',
'🤮',
'🤧',
'🥵',
'🥶',
'🥴',
'😵',
'🤯',
'🤠',
'🥳',
'🥸',
'😎',
'🤓',
'🧐',
'😕',
'🫤',
'😟',
'🙁',
'😮',
'😯',
'😲',
'😳',
'🥺',
'🥹',
'😦',
'😧',
'😨',
'😰',
'😥',
'😢',
'😭',
'😱',
'😖',
'😣',
'😞',
'😓',
'😩',
'😫',
'🥱',
'😤',
'😡',
'😠',
'🤬',
'😈',
'👿',
'💀',
'💩',
'🤡',
'👹',
'👺',
'👻',
'👽',
'👾',
'🤖',
'😺',
'😸',
'😹',
'😻',
'😼',
'😽',
'🙀',
'😿',
'😾',
'🙈',
'🙉',
'🙊',
'💌',
'💘',
'💝',
'💖',
'💗',
'💓',
'💞',
'💕',
'💟',
'💔',
'🧡',
'💛',
'💚',
'💙',
'💜',
'🤎',
'🖤',
'🤍',
'💋',
'💯',
'💢',
'💥',
'💫',
'💦',
'💨',
'💬',
'💭',
'💤',
'👋',
'🤚',
'✋',
'🖖',
'🫱',
'🫲',
'🫳',
'🫴',
'👌',
'🤌',
'🤏',
'🤞',
'🫰',
'🤟',
'🤘',
'🤙',
'👈',
'👉',
'👆',
'🖕',
'👇',
'🫵',
'👍',
'👎',
'✊',
'👊',
'🤛',
'🤜',
'👏',
'🙌',
'🫶',
'👐',
'🤲',
'🤝',
'🙏',
'💅',
'🤳',
'💪',
'🦾',
'🦿',
'🦵',
'🦶',
'👂',
'🦻',
'👃',
'🧠',
'🫀',
'🫁',
'🦷',
'🦴',
'👀',
'👅',
'👄',
'🫦',
'👶',
'🧒',
'👦',
'👧',
'🧑',
'👱',
'👨',
'🧔',
'👩',
'🧓',
'👴',
'👵',
'🙍',
'🙎',
'🙅',
'🙆',
'💁',
'🙋',
'🧏',
'🙇',
'🤦',
'🤷',
'👮',
'💂',
'🥷',
'👷',
'🫅',
'🤴',
'👸',
'👳',
'👲',
'🧕',
'🤵',
'👰',
]),
}
},
computed: {},
watch: {},
created() {},
mounted() {},
methods: {
select(emoji) {
this.visible = false
this.$emit('select', emoji)
},
},
}
</script>
<template>
<div class="copo-emoji" title="插入表情">
<el-popover placement="right" trigger="click" v-model="visible">
<ul class="emoji-wrap">
<li v-for="(item, index) in emoji" :key="index" class="emoji" @click="select(item)">{{ item }}</li>
</ul>
<div slot="reference">{{ emoji[0] }}</div>
</el-popover>
</div>
</template>
<style lang="scss" scoped>
.copo-emoji {
display: inline-block;
}
.emoji-wrap {
display: inline-block;
width: 400px;
height: 400px;
overflow: auto;
.emoji {
display: inline-block;
padding: 7px 7px 4px;
border-radius: 4px;
margin: 3px;
cursor: pointer;
&:hover {
background: #eee;
}
}
}
</style>
// 带 插入 表情/客户昵称 等扩展工具栏的文本内容框
<script>
export default {
name: '',
props: {
value: '',
// ['emoji','insertCustomerNickName']
toolbar: {
type: Array,
default: () => ['emoji'],
},
},
components: {
SelectEmoji: () => import('@/components/SelectEmoji'),
},
data() {
return {}
},
computed: {
proxyValue: {
get() {
return this.value
},
set(val) {
this.$emit('input', val)
},
},
},
watch: {},
created() {},
mounted() {},
methods: {
// 插入内容
insertContent(value) {
const $textarea = this.$refs.textarea.$el.children[0]
const content = this.proxyValue || ''
const textIndex = $textarea.selectionStart
this.proxyValue = content.slice(0, textIndex) + value + content.slice(textIndex)
},
},
}
</script>
<template>
<div>
<el-input ref="textarea" v-model="proxyValue" type="textarea" v-bind="$attrs" v-on="$listeners"></el-input>
<div class="mt10">
<el-button>
<SelectEmoji v-if="toolbar.includes('emoji')" @select="insertContent" />
</el-button>
<el-button v-if="toolbar.includes('insertCustomerNickName')" @click="insertContent('#客户昵称#')" class="ml10">
插入客户昵称
</el-button>
</div>
</div>
</template>
<style lang="scss" scoped></style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!