FCKeditor与Extjs组合

Ext.form.FCKeditor.js

var oFCKeditorOptions = {
    BasePath : 'fckeditor/',   
    Config : {   
        ProcessHTMLEntities : true,   
        ProcessNumericEntities : false,   
        StartupShowBlocks : false,   
        ToolbarCanCollapse : false       
    },   
    ToolbarSet : 'Default'  
}; 
Ext.form.FCKeditor = function(config){
    Ext.form.FCKeditor.superclass.constructor.call(this, config);
    this.FCKid=0;
    this.MyisLoaded=false;
    this.MyValue='';
};

Ext.extend(Ext.form.FCKeditor, Ext.form.TextArea,  {
    onRender : function(ct, position){
        if(!this.el){
            this.defaultAutoCreate = {
                tag: "textarea",
                style:"width:100px;height:60px;",
                autocomplete: "off"
            };
        }
        Ext.form.TextArea.superclass.onRender.call(this, ct, position);
        if(this.grow){
            this.textSizeEl = Ext.DomHelper.append(document.body, {
                tag: "pre", cls: "x-form-grow-sizer"
            });
            if(this.preventScrollbars){
                this.el.setStyle("overflow", "hidden");
            }
            this.el.setHeight(this.growMin);
        }
        if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value()
        setTimeout("loadFCKeditor('"+this.name+"');",100);
    },
    setValue : function(value){
        this.MyValue=value;
        if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value()
        FCKeditorSetValue(this.FCKid,this.name,value)
        Ext.form.TextArea.superclass.setValue.apply(this,[value]);
    },
    
   
    
    getValue : function(){
        if (this.MyisLoaded){
            value=FCKeditorGetValue(this.name);
            Ext.form.TextArea.superclass.setValue.apply(this,[value]);
            return Ext.form.TextArea.superclass.getValue(this);
        }else{
            return this.MyValue;
        }
    },
    
    getRawValue : function(){
        if (this.MyisLoaded){
            value=FCKeditorGetValue(this.name);
            Ext.form.TextArea.superclass.setRawValue.apply(this,[value]);
            return Ext.form.TextArea.superclass.getRawValue(this);
        }else{
            return this.MyValue;
        }
    }
});
Ext.reg('fckeditor', Ext.form.FCKeditor);


function loadFCKeditor(element){
    oFCKeditor = new FCKeditor( element ) ;
    oFCKeditor.ToolbarSet = sFCKeditorToolbar ;
    oFCKeditor.Config['SkinPath'] = sFCKeditorSkinPath ;
    oFCKeditor.Config['PreloadImages'] = sFCKeditorSkinPath + 'images/toolbar.start.gif' + ';' +
                sFCKeditorSkinPath + 'images/toolbar.end.gif' + ';' +
                sFCKeditorSkinPath + 'images/toolbar.bg.gif' + ';' +
                sFCKeditorSkinPath + 'images/toolbar.buttonarrow.gif' ;
    oFCKeditor.BasePath = sFCKeditorBasePath ;
    oFCKeditor.Config['BaseHref']   = sFCKeditorBaseHref ;
    oFCKeditor.Height = 260 ;
    oFCKeditor.ReplaceTextarea();

}
function FCKeditor_OnComplete(editorInstance){

    Ext.getCmp(editorInstance.Name).MyisLoaded=true;

    editorInstance.Events.AttachEvent('OnStatusChange', function(){
        Ext.getCmp(editorInstance.Name).setValue();
    })
}
var FCKeditorvalue=new Array();
function FCKeditorSetValue(id,name,value){
    if ((id!=undefined)&&(name!=undefined)){
        if (value!=undefined) FCKeditor_value[id]=value;
        else if (FCKeditor_value[id]==undefined) FCKeditor_value[id]='';
        var oEditor = FCKeditorAPI.GetInstance(name) ;
        
        if(oEditor!=undefined) oEditor.SetData(FCKeditor_value[id])
    }
}
function FCKeditorGetValue(name){
    if ((id!=undefined)&&(name!=undefined)){
        var oEditor = FCKeditorAPI.GetInstance(name) ;
        data='';
        if(oEditor!=undefined) data=oEditor.GetData()
        return data;
    }
}
var FCKeditor_id_value;
function get_FCKeditor_id_value(){
    if (!FCKeditor_id_value){
        FCKeditor_idvalue=0;
    }
    FCKeditor_idvalue=FCKeditor_id_value+1;
    return FCKeditor_id_value;
}

导入相应的js

 <script type="text/javascript" src="fckeditor/fckeditor.js"></script>(fckeditor-java里面就是)
    <script type="text/javascript" src="js/fck.js"></script>(上面拓展js)

设置参数(设置fckeditor路径)

  <script type="text/javascript">
    	 var sFCKeditorToolbar = 'Default';
    	 var sFCKeditorBasePath = 'fckeditor/';
    	 var sFCKeditorBaseHref = 'http://localhost/HPDD1/';
    	 var sFCKeditorSkinPath = '../../fckeditor/editor/skins/office2003/';
    </script>

使用fckeditor js

 new Ext.form.FormPanel({
		title:'文章内容',
		labelAlign:'right',
                layout:'fit',
		labelWidth:60,
	        frame:true,
		items : [{
			id:n.id+'content',
                        name:id+'content',
			xtype:'fckeditor',      
			fieldLabel:'文章内容',
			height:100,
			anchor:'99%'
		}]
})
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值