<template>
  <div  v-show="myConfig.visible" @keydown.enter.stop="keyDown">
    <Editor ref="myControl" :myConfig="myConfig"  :value="value"  @updateValue="onEditorChange"/>
  </div>
</template>
<script>
// 工具栏配置
import Base from '@/components/base/controlbase.vue';
import Editor from './editor.vue';
export default {
    name: 'wrichtextbox',
    components:{
        Editor
    },
    extends: Base,
    data () {
        return {
            myConfig:{
                editorStyle:{
                    'height':'auto'
                },
              }
        };
    },

    mounted () {
        //eslint-disable-next-line no-labels
    },
    methods:{
        customInit () {
        },
        onEditorFocus () {
            if (this.$refs.myControl) {
                this.$refs.myControl.setReadOnly(this.myConfig.readOnly);
            }
            
        },
        onEditorChange (value) {
            this.value = value;
            // 内容改变事件
            this.setFatherValue();
            //this.$emit('inputValue', this.content);
        },
   
        keyDown (e) {
            //e.stopPropagation();
        },
        setDynamicText(value) {
            if (this.$refs.myControl) {
               this.$refs.myControl.insertText(value);
            }
        },
        setCustomPro(obj) {
            if (obj) {
                this.myConfig = Object.assign({}, this.myConfig, obj);
            }
            if (obj.readOnly !== undefined) {
                this.onEditorFocus();
            }   
        }
    }
};
</script>