import { shortcut, Widget, createWidget, isNotEmptyString } from "@/core"; import { TextAreaEditor, Msg } from "@/base"; @shortcut() export class CodeEditor extends Widget { static xtype = "demo.textarea_editor"; props = { baseCls: "demo-editor" }; render() { const editor = createWidget({ type: "bi.textarea_editor", cls: "bi-border", width: 600, height: 400, watermark: "请输入内容", errorText: "检测内容有误", validationChecker(v) { return isNotEmptyString(v); }, }); editor.on(TextAreaEditor.EVENT_FOCUS, () => { Msg.toast("Focus"); }); editor.on(TextAreaEditor.EVENT_BLUR, () => { Msg.toast("Blur"); }); createWidget({ type: "bi.vertical", element: this, hgap: 30, vgap: 20, items: [ editor, { type: "bi.button", text: "getValue", handler() { Msg.toast(JSON.stringify(editor.getValue())); }, }, { type: "bi.button", text: "setValue", handler() { editor.setValue("测试数据"); }, } ], }); } }