<template>
  <div id="sheet-container">
  </div>
</template>

<script>
import { initSheet } from '../common/option';
export default {
  props: {
    option: {
      type: Object,
      default: ''
    },
    sheetInfo: {
      type: Object,
      default: ()=>{}
    },
    limit: {
      type: Boolean,
      default: ()=>{
        return {disabled:false}
      }
    },
  },
  data() {
    return {
      sheetObj: {}
    }
  },
  methods: {
    init() {
      let optionData = this.option ? this.option : {};
      let callbackItems={updated:this.updateEmit}
      initSheet('sheet-container',optionData,this.sheetInfo,this.limit,callbackItems)
    },
    copyDisable(e){
      // 变向的禁止复制
      // console.log(e.target.value && e.target.value.indexOf('lucksheet'));
      if(e.target.value && e.target.value.indexOf('lucksheet')){
        luckysheet.enterEditMode();
        // luckysheet.exitEditMode();
        return false
      }
    },
    updateEmit(){
      this.$emit("updated")
    }
  },
  destroyed() {
    luckysheet.destroy();
  },
  mounted() {
    this.init();
    if(this.limit.disabled){
      document.addEventListener('copy',this.copyDisable)
    }
  },
  beforeDestroy(){
    if(this.limit.disabled){
      document.removeEventListener('copy',this.copyDisable)
    }
  }
}
</script>
<style scoped lang="scss">
#sheet-container {
  margin:0;padding:0;
  position:absolute;
  width:100%;left: 0px;top: 0;bottom:0px;
}

</style>

<style lang="scss">
  .luckysheet .toolbar {
    background: none;
    margin: 0;
    padding: 0;
  }
.luckysheet-input-box {
  z-index: 99999;
}
</style>