<template>
  <VueUeditorWrap
    :value="value"
    :config="config"
    @input="handleInput"
    @ready="ready"
  />
</template>
<script>
import VueUeditorWrap from 'vue-ueditor-wrap'
// import { UPLOAD_URL } from '@/const/urlKey'

export default {
  name: 'ZRichText',

  components: {
    VueUeditorWrap
  },

  props: {
    value: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      intance: null,
      config: {
        // 你的UEditor资源存放的路径，相对于打包后的index.html
        UEDITOR_HOME_URL: './static/UE/',
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: 400,
        // 初始容器宽度
        initialFrameWidth: '90%',

        toolbars: [
          [
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'insertcode', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help'
          ]
        ]
      }
    }
  },

  mounted() {
  },

  methods: {
    handleInput(payload) {
      this.$emit('input', payload)
    },
    ready(intance) {
      this.intance = intance
      this.$emit('ready', intance)
    }
  }
}
</script>
