[转]ExtJS3.0与KindEditor4.1.2整合

原文地址:http://blog.csdn.net/resigshy/article/details/7937021

ExtJS与KindEditor整合的方式。

[javascript] view plain copy print?
  1. /** 
  2.  * 将KindEditor4.1.2 功能封装到命名空间“KE“。 
  3.  * @author shuyuan 
  4.  */  
  5. Ext.namespace("KE");  
  6. KE.app = (function() {  
  7.     return {  
  8.         /** 
  9.          * 初始化editor 
  10.          * @param initParam 初始参数。 
  11.          * @returns 
  12.          */  
  13.         init : function (initParam){      
  14.             setTimeout(function(){  
  15.                 KindEditor.create('#' + initParam.renderTo, initParam);  
  16.             }, ((!initParam.delayTime || initParam.delayTime) <= 0 ? 5 : initParam.delayTime));  
  17.         },  
  18.         /** 
  19.          * 获取创建后的editor对象。 
  20.          * @param renderTO textarea的ID,根据此参数查找已创建的editor对象 
  21.          * @returns 
  22.          */  
  23.         getEditor : function(renderTO) {  
  24.             var editors = KindEditor.instances;  
  25.             for(var i = 0; i < editors.length; i++){  
  26.                 if(editors[i].renderTo && editors[i].renderTo === renderTO){  
  27.                     return editors[i];  
  28.                 }         
  29.             }     
  30.         }  
  31.     };  
  32. })();  


 

初始化KindEditor:

[javascript] view plain copy print?
    1. var contentFormPanelCn = new Ext.form.FormPanel({  
    2.     id : 'contentFormPanelCn',  
    3.     title:mpdLang.chinese, //'中文',  
    4.     layout : 'fit',  
    5.     bodyStyle:"border:0px;padding:0px",  
    6.     defaultType : 'textfield',  
    7.     items : [{  
    8.         xtype:'textarea',  
    9.         id:'contentCn',  
    10.         'auto',  
    11.         height:'auto'  
    12.     }],  
    13.     listeners:{  
    14.         'render':function(){  
    15.             KE.app.init({  
    16.                 renderTo : "contentCn",  
    17.                 delayTime : 1,  
    18.                 readonlyMode : false,  
    19.                 resizeType : 0,  
    20.                 width : '100%',  
    21.                 minChangeSize : 20,  
    22.                 imageTabIndex : 1,  
    23.                 uploadJson : ""
    24.                 
    25.             });  
    26.         }             
    27.     },  
    28.     buttons:[{  
    29.         text:commonality_save,//保存  
    30.         id:"btnEditContentCn",  
    31.         handler : function() {  
    32.             var html = KE.app.getEditor('contentCn').html();//取值  
    33.         }  
    34.     }],  
    35.     buttonAlign:'center'  
    36. });  
原文地址:https://www.cnblogs.com/dirgo/p/7416600.html