-
6 May 2011 3:17 AM #1
CKEDITOR with EXTJS 4
CKEDITOR with EXTJS 4
Hello
I´m trying to adapt CKEDITOR in EXTJS 4 but I have the next error CKEDITOR.instances[this.id] is undefined in the line:
CKEDITOR.instances[this.id].setData(value);
In EXTJS 3 it works perfectly!
This is the code:
editorCK = Ext.create('widget.ckeditor',{
id:'editorCK',
CKConfig: {
customConfig : 'ckeditor/config.js',
toolbar: 'Basic',
height : 200,
width: 500
}
});
Ext.define('Ext.ux.CKeditor',{
extend: 'Ext.form.field.TextArea',
alias: 'widget.ckeditor',
initComponent: function(){
this.callParent(arguments);//Ext.ux.CKeditor.superclass.initComponent.apply(this, arguments);
},
onRender : function(ct, position){
if(!this.el){
this.defaultAutoCreate = {
tag: 'textarea',
autocomplete: 'off'
};
}
Ext.form.field.TextArea.superclass.onRender.call(this, ct, position);
CKEDITOR.replace(this.id, this.CKConfig);
},
setValue : function(value){
Ext.form.field.TextArea.superclass.setValue.apply(this,[value]);
CKEDITOR.instances[this.id].setData(value);
CKEDITOR.instances[this.id] is undefined
},
getValue : function(){
CKEDITOR.instances[this.id].updateElement();
var value=CKEDITOR.instances[this.id].getData();
Ext.form.field.TextArea.superclass.setValue.apply(this,[value]);
return Ext.form.field.TextArea.superclass.getValue.apply(this);
},
getRawValue : function(){
CKEDITOR.instances[this.id].updateElement();
return Ext.form.field.TextArea.superclass.getRawValue(this);
}
});
Can anyone help me, please?
Thanks!
-
10 May 2011 1:34 PM #2
It doesnt look like you've instantiated CKEDITOR anywhere. Shouldnt you be
creating CKEDITOR in the initComponent method, ie
this.CKEDITOR = new .....
and then referring to it in the methods as
this.CKEDITOR
also you probably want to be using callParent(arguments) rather than superclass
in the method overrides.
Ian.
-
11 May 2011 1:26 PM #3
I think this code
makes a instance of ckeditor.Code:CKEDITOR.replace(this.id, this.CKConfig);
-
26 May 2011 7:21 AM #4
Did you get this working? I need to explore alternatives to the htmlEditor.
-
26 May 2011 8:59 AM #5
Why explore alternatives?? Why not extend it you can add buttons and custom functionality.
-
26 May 2011 9:30 AM #6
I looked into extending the htmlEditor but I couldn't make sense of it. Specifically I wanted to be able to select h1, h2, h3 tags. As I want to enable text editing but still maintain control over the style.
the other problem I have is pasting. I want to be able to paste as plain text. not only can I not paste as plain text in the htmlEditor if the text is plain text to begin with it's automatically wrapped in font and style tags.
-
26 May 2011 10:05 AM #7
I would highly suggest looking at the src to the htmlEditor....when I needed to customize it thats what I did and found the proper functions to use to do everything I was trying to do.
-
20 Jun 2011 1:19 PM #8
Functionning code
Functionning code
Dear all,
here is a full functionning code :
Ext
.define('Ext.ux.CKeditor',{
extend
:'Ext.form.field.TextArea',
alias
:'widget.ckeditor',
initComponent
:function(){
this.callParent(arguments);
this.on('afterrender',function(){
Ext
.apply(this.CKConfig ,{
height
:this.getHeight()
});
this.editor = CKEDITOR.replace(this.inputEl.id,this.CKConfig);
this.editorId =this.editor.id;
},this);
},
onRender
:function(ct, position){
if(!this.el){
this.defaultAutoCreate ={
tag
:'textarea',
autocomplete
:'off'
};
}
this.callParent(arguments)
},
setValue
:function(value){
this.callParent(arguments);
if(this.editor){
this.editor.setData(value);
}
},
getRawValue
:function(){
if(this.editor){
returnthis.editor.getData()
}else{
return''
}
}
});
CKEDITOR
.on('instanceReady',function(e){
var o = Ext.ComponentQuery.query('ckeditor[editorId="'+ e.editor.id +'"]'),
comp
= o[0];
e
.editor.resize(comp.getWidth(), comp.getHeight())
comp
.on('resize',function(c,adjWidth,adjHeight){
c
.editor.resize(adjWidth, adjHeight)
})
});
-
22 Feb 2012 6:50 AM #9
I found a bug, I have a ckeditor in a tab panel, if i switch to a different tab before the editor is fully loaded, it collapses in firefox and IE. In IE even breaks so far the this.editor value is corrupt, and it won't respond to setvalue and getvalue.
In chrome it keeps working like it should.
Any advice ?
-
24 May 2012 12:00 AM #10
Try to add the parameter "deferredRender : false" in you tabPanel
Similar Threads
-
CKEditor Extension
By iosoftgame in forum Ext 3.x: User Extensions and PluginsReplies: 39Last Post: 5 Sep 2012, 9:16 AM -
ExtJs 3.x and CKEditor 3.5 causing problems
By johnmmr in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 26 Apr 2011, 12:03 PM -
CKEditor-GWT FitLayout
By elirov in forum Community DiscussionReplies: 4Last Post: 16 Feb 2011, 3:57 AM -
CkEditor and (Sencha) Extjs
By russall1985 in forum Community DiscussionReplies: 0Last Post: 10 Feb 2011, 7:15 AM -
Initialize panel as disabled with embedded ckeditor
By ChrisR in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 10 Jan 2011, 1:44 PM


Reply With Quote


