1 Attachment(s)
NEW CKEditor extension with example.
Hi Guys
I have been playing with CKEditor and Ext JS. I stripped down the FCKEditor example and created the following which seems to work for me. It is only the basics at the moment, not sure if more is needed.
the ckeditor.js extension file looks like this.
PHP Code:
/****************************************************
* CKEditor Extension
*****************************************************/
Ext.form.CKEditor = function(config){
this.config = config;
Ext.form.CKEditor.superclass.constructor.call(this, config);
};
Ext.extend(Ext.form.CKEditor, Ext.form.TextArea, {
onRender : function(ct, position){
if(!this.el){
this.defaultAutoCreate = {
tag: "textarea",
autocomplete: "off"
};
}
Ext.form.TextArea.superclass.onRender.call(this, ct, position);
CKEDITOR.replace(this.id, this.config.CKConfig);
},
setValue : function(value){
Ext.form.TextArea.superclass.setValue.apply(this,[value]);
CKEDITOR.instances[this.id].setData( value );
},
getValue : function(){
CKEDITOR.instances[this.id].updateElement();
return Ext.form.TextArea.superclass.getValue(this);
},
getRawValue : function(){
CKEDITOR.instances[this.id].updateElement();
return Ext.form.TextArea.superclass.getRawValue(this);
}
});
Ext.reg('ckeditor', Ext.form.CKEditor);
The Ext Js Form item is as follows:
PHP Code:
{
xtype: 'ckeditor',
fieldLabel: 'Editor',
name: 'htmlcode',
CKConfig: {
/* Enter your CKEditor config paramaters here or define a custom CKEditor config file. */
customConfig : '/ckeditor/config.js',
toolbar: 'Basic',
height : 200,
width: 250
}
}
You can enter CKEditor config paramaters in the CKConfig paramater or define a custom CKEditor config file and point to that.
I have also created an example application based on the "Form with embedded Grid" from the Ext JS 3.0 example file.
just download Ext JS 3.0 and CKEditor 3.0 and the example file extract them all and it should work, hopefully :).