How to add a custom button to the toolbar that calls a JavaScript function?

后端 未结 10 1924
[愿得一人]
[愿得一人] 2020-11-30 17:15

I\'d like to add a button to the toolbar that calls a JavaScript function like Tada()?

Any ideas on how to add this?

10条回答
  •  天命终不由人
    2020-11-30 17:33

    You can add the button image as follows:

    CKEDITOR.plugins.add('showtime',   //name of our plugin
    {    
        requires: ['dialog'], //requires a dialog window
        init:function(a) {
      var b="showtime";
      var c=a.addCommand(b,new CKEDITOR.dialogCommand(b));
      c.modes={wysiwyg:1,source:1}; //Enable our plugin in both modes
      c.canUndo=true;
     
      //add new button to the editor
      a.ui.addButton("showtime",
      {
       label:'Show current time',
       command:b,
       icon:this.path+"showtime.png"   //path of the icon
      });
      CKEDITOR.dialog.add(b,this.path+"dialogs/ab.js") //path of our dialog file
     }
    });
    

    Here is the actual plugin with all steps described.

提交回复
热议问题