<template>
  <div>
    <div class="biaoqingContent" :style="{width:width}">
      <!--      表情选择框-->
      <div class="box" :style="{width:width}" @click.stop>
        <div class="left">
          <ul>
            <li v-for="(item,index) in biaoqingList" :key="index" :class="['cursor',biaoqingActive === index ? 'active': '']">
              <div @click="bqNameChange(index,item.iconArr)">{{ item.name }}</div>
            </li>
          </ul>
        </div>
        <div class="right">
          <button v-for="(i,index) in rightList" :key="index" class="emoji" @click.stop="handleEmojiSelect(i.className,i.icon)">
            <img src="/pic/custom-center/placeholder.png" :class="i.className" :alt="i.icon">
          </button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
// 定义最后光标对象

import { biaoqingArr } from './biaoqing.js'
export default {
  components: {},
  props: {
    // 表情框宽度
    width: {
      type: String,
      default: '100%'
    },
    // 表情框高度
    height: {
      type: String,
      default: '150px'
    },
    // 表情框ID
    id: {
      type: String,
      default: 'text'
    },
    // 内容
    value: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      lastEditRange: '',
      content: '',
      show: false,
      biaoqingList: biaoqingArr,
      biaoqingActive: 0,
      rightList: [],
      allList: []
    }
  },
  watch: {
    value() {
      // this.valueChange()
    }
  },
  mounted() {
    // this.valueChange()
    const that = this
    document.body.onclick = function () {
      that.show = false
    }
  },
  created() {
    this.rightList = biaoqingArr[0].iconArr
    biaoqingArr.forEach(e => {
      this.allList = this.allList.concat(e.iconArr)
    })
  },
  methods: {
    // 表情title点击事件
    bqNameChange(index, arr) {
      this.biaoqingActive = index
      this.rightList = arr
    },
    // 表情插入文本框
    handleEmojiSelect(className, icon) {
      // console.log(className + ', icon = ' + icon)
      this.$emit('handle-select', className, icon)
    }
  }
}
</script>
<style>
  @import "./emoji_sorites.css";
</style>
<style lang='less' scoped>
  .contentBox {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    font-size: 16px;
    position: relative;

  }
  .biaoqingContent {
    /*padding: 5px;*/
    margin: 5px auto;
    .expression{
      width: 30px;
      margin: 5px 0;

      cursor: pointer;
    }

    .box {
      border: 1px solid #1890FF;
      min-height: 300px;
      box-shadow: 0 0 16px rgba(0, 0, 0, 0.2);
      background: #fff;
      z-index: 10;
      position: absolute;
      width: 100%;
      display: flex;
    }
    .left {
      width: 90px;
      height: 100%;
      display: table-cell;
      border-right: 1px solid #ebebeb;

      padding: 4px;

      ul {
        padding: 0;
        margin: 0;
        text-align: center;
        list-style-type: none;

        li {
          height: 30px;
          line-height: 30px;
          cursor: pointer;
          font-size: 14px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;

          button {
            border: none;
            background: none;
            width: 100%;
            height: 100%;
          }
        }
      }

      .active {
        background-color: #1890FF;
        color: #ffffff;
        border-radius: 4px;
        button {
          color: #ffffff;
        }
      }
    }
    .right {
      flex: 1;
      padding-left: 10px;
      padding-top: 15px;
      overflow: auto;

      button {
        border: none;
        padding: 0;
        cursor: pointer;
      }

      .emoji {
        display: inline-block;
        padding: 3px;
        border: 1px solid transparent;
        cursor: pointer;
        background: #fff;

        &:hover {
          height: 32px;
          background-color: #ddded8;
          border: 1px solid #1890FF;
          border-radius: 4px;
        }
      }
    }
    //样式一
    .box0 {
    }

  }

</style>
