import { __decorate } from "tslib";
import { Component } from 'vue-property-decorator';
import { VueLifeCycleProcessing } from '../../../decorators';
import { EditorBase } from '../editor-base/editor-base';
/**
 * 富文本编辑器
 *
 * @export
 * @class HtmlEditor
 * @extends {EditorBase}
 */
let HtmlEditor = class HtmlEditor extends EditorBase {
    /**
     * 编辑器初始化
     *
     * @memberof HtmlEditor
     */
    async initEditor() {
        var _a, _b;
        await super.initEditor();
        const { editorType, editorHeight } = this.editorInstance;
        this.customProps.uploadparams = ((_a = this.editorInstance.editorParams) === null || _a === void 0 ? void 0 : _a['uploadparams']) || {};
        this.customProps.exportparams = ((_b = this.editorInstance.editorParams) === null || _b === void 0 ? void 0 : _b['exportparams']) || {};
        if (editorType == "HTMLEDITOR" && editorHeight > 0) {
            this.customProps.height = editorHeight;
        }
    }
    /**
     * 编辑器change事件
     *
     * @param {*} value
     * @memberof HtmlEditor
     */
    handleChange($event) {
        this.editorChange({ name: this.editorInstance.name, value: $event });
    }
    /**
     * 绘制默认内容
     *
     * @returns {*}
     * @memberof TextboxEditor
     */
    renderHtml() {
        return this.$createElement(this.editorComponentName, {
            props: Object.assign({ name: this.editorInstance.name, value: this.value, disabled: this.disabled, context: this.context, viewparams: this.viewparams, data: JSON.stringify(this.contextData) }, this.customProps),
            on: { change: this.handleChange },
            style: this.customStyle
        });
    }
    /**
     * 绘制内置插件内容
     *
     * @returns {*}
     * @memberof TextboxEditor
     */
    renderHtmlInfo() {
        return this.$createElement(this.editorComponentName, {
            props: Object.assign({ name: this.editorInstance.name, content: this.value }, this.customProps),
            style: this.customStyle
        });
    }
    /**
     * 绘制内容
     *
     * @returns {*}
     * @memberof HtmlEditor
     */
    render() {
        if (!this.editorIsLoaded) {
            return null;
        }
        const { editorType: type, editorStyle: style } = this.editorInstance;
        const editorTypeStyle = `${type}${style && style != 'DEFAULT' ? '_' + style : ''}`;
        switch (editorTypeStyle) {
            case "HTMLEDITOR":
                return this.renderHtml();
            case "HTMLEDITOR_INFO":
                return this.renderHtmlInfo();
        }
    }
};
HtmlEditor = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], HtmlEditor);
export default HtmlEditor;
