2017-07-22 298 views
0

嗨,我一直在使用Extjs的HTML编辑器。我想定制的HTML编辑器,就像我必须显示一个自定义的警告框,当我们点击按钮toolbar.how我们可以做到吗? 在此先感谢。Extjs的HTML编辑器和如何自定义编辑器

+0

问题有点模糊。为什么样的警报?什么工具栏?什么按钮?任何你想让警报看起来像什么样子的图像,以及你什么时候想要它显示出来? –

回答

2
Ext.define('MyApp.ux.MyOwnHtmlEditor',{ 
    extend: 'Ext.form.field.HtmlEditor', 
    xtype: 'myhtmleditor', 
    getToolbarCfg: function() { 
     // get original toolbar: 
     var toolbar = this.callParent(arguments); 
     // add custom item: 
     toolbar.items.push({ 
      xtype: 'button', 
      iconCls: 'x-fa fa-question-circle', 
      handler: function() { 
       Ext.Msg.alert('Dear user!', 'No, we won\'t help you!'); 
      } 
     }); 
     // Modify handler of existing button: 
     toolbar.items[3].handler = function() { 
      Ext.MessageBox.alert('Dear user!', 'If you want Italic, please go to Italy!'); 
     }; 
     // return toolbar to calling function 
     return toolbar; 
    } 
}) 

然后使用它像这样:

{ 
    xtype: 'myhtmleditor' 
} 

Example fiddle