import { __decorate } from "tslib";
import { Component, Prop } from 'vue-property-decorator';
import { VueLifeCycleProcessing, EditorBase } from '@ibizstudio-ex/template-vue';
import { DataTypes } from '@ibizstudio-ex/runtime';
import MemoArea from '../../components/memo-area/memo-area.vue';
/**
 * 备注编辑器插件类
 *
 * @export
 * @class NoteEditor
 * @extends {EditorBase}
 */
let NoteEditor = class NoteEditor extends EditorBase {
    /**
     * 编辑器初始化
     *
     * @memberof TextboxEditor
     */
    async initEditor() {
        await super.initEditor();
        this.customProps.isDebounce = this.isDebounce;
        this.customProps.type = 'textarea';
        this.initFormatParams();
    }
    /**
     * 初始化格式化参数
     *
     * @param {*} value
     * @memberof TextboxEditor
     */
    initFormatParams() {
        var _a, _b, _c, _d, _e;
        this.customProps.valueFormat = '';
        let unitName = (_a = this.parentItem) === null || _a === void 0 ? void 0 : _a.unitName;
        let appDeField = (_c = (_b = this.parentItem) === null || _b === void 0 ? void 0 : _b.getPSAppDEField) === null || _c === void 0 ? void 0 : _c.call(_b);
        if (appDeField === null || appDeField === void 0 ? void 0 : appDeField.stdDataType) {
            this.customProps.dataType = DataTypes.toString(appDeField.stdDataType);
        }
        if (appDeField === null || appDeField === void 0 ? void 0 : appDeField.valueFormat) {
            this.customProps.valueFormat = appDeField === null || appDeField === void 0 ? void 0 : appDeField.valueFormat;
        }
        if (this.valueFormat) {
            this.customProps.valueFormat = this.valueFormat;
        }
        if ((_d = this.editorInstance.editorParams) === null || _d === void 0 ? void 0 : _d.valueFormat) {
            this.customProps.valueFormat = (_e = this.editorInstance.editorParams) === null || _e === void 0 ? void 0 : _e.valueFormat;
        }
        if (unitName) {
            this.customProps.unitName = unitName;
        }
    }
    /**
     * 编辑器change事件
     *
     * @param {*} value
     * @memberof TextboxEditor
     */
    handleChange($event) {
        this.editorChange({ name: this.editorInstance.name, value: $event });
    }
    /**
     * 编辑器enter事件
     *
     * @param {*} value
     * @memberof TextboxEditor
     */
    handleEnter($event) {
        this.$emit('enter', arguments);
    }
    /**
     * 绘制默认内容
     *
     * @returns {*}
     * @memberof TextboxEditor
     */
    renderTextbox() {
        return this.$createElement(MemoArea, {
            props: Object.assign({ name: this.editorInstance.name, itemValue: this.value, disabled: this.disabled }, this.customProps),
            on: {
                change: this.handleChange,
                enter: this.handleEnter
            },
            style: this.customStyle
        });
    }
    /**
     * 绘制内置插件内容
     *
     * @returns {*}
     * @memberof TextboxEditor
     */
    renderTextboxColorPicker() {
        return this.$createElement(this.editorComponentName, {
            props: Object.assign({ name: this.editorInstance.name, value: this.value, data: this.contextData }, this.customProps),
            on: { change: this.handleChange, colorChange: ($event) => { this.editorChange($event); } },
            style: this.customStyle
        });
    }
    /**
     * 绘制内容
     *
     * @returns {*}
     * @memberof TextboxEditor
     */
    render() {
        if (!this.editorIsLoaded) {
            return null;
        }
        return this.renderTextbox();
    }
};
__decorate([
    Prop()
], NoteEditor.prototype, "isDebounce", void 0);
NoteEditor = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], NoteEditor);
export { NoteEditor };
