ux.form.field.KindEditor 所见所得编辑器

注意需要引入KindEditor相关资源

 //所见所得编辑器
Ext.define('ux.form.field.KindEditor', {
extend: 'Ext.form.field.TextArea',
alias: 'widget.kindEditor',
xtype: 'kindEditor',
//最大文本长度
maxLength:5000,
//配置
editorConfig: {
//选项功能
items: [
'source', '|', 'undo', 'redo', '|', 'preview', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'
],
minHeight: 200
},
afterRender: function () {
var me = this;
me.callParent(arguments);
//延迟输入验证
me.task = Ext.create('Ext.util.DelayedTask',
function (t) {
me.isValid();
},
me);
if (!me.editor) {
//创建富文本插件
me.editor = KindEditor.create("#" + me.getInputId(), Ext.apply(me.editorConfig, {
//编辑器创建成功
afterCreate: function () {
//标识完成
me.KindEditorIsReady = true;
},
//内容发生改变时
afterChange: function () {
//编辑器初始化完成才执行
if (me.KindEditorIsReady) {
//延迟输入验证
me.task.delay(100);
}
},
//失去焦点
afterBlur: function () {
//输入验证
me.isValid();
}
}));
} else {
me.editor.html(me.getValue());
}
},
setValue: function (value) {
//console.log('setValue');
var me = this;
if (!me.editor) {
me.setRawValue(me.valueToRaw(value));
} else {
if(value){
me.editor.html(value.toString());
}else{ }
}
me.callParent(arguments);
return me.mixins.field.setValue.call(me, value);
},
getRawValue: function () {
//console.log('getRawValue');
var me = this;
if (me.KindEditorIsReady) {
//自动同步值
me.editor.sync();
}
v = me.inputEl ? me.inputEl.getValue() : '';
me.rawValue = v;
return v;
},
//重置
reset: function () {
if (this.editor) {
this.editor.html('');
}
this.callParent();
},
//销毁富文本控件
destroyEditor: function () {
var me = this;
if (me.rendered) {
try {
me.editor.remove();
me.editor = null;
} catch (e) { }
}
},
//销毁
onDestroy: function () {
var me = this;
me.destroyEditor();
me.callParent(arguments);
}
});
上一篇:自动驾驶创业公司里,第一个IPO的可能是它


下一篇:asp.net 程序自动提交登陆表单并保持Session及Cookie