简体   繁体   中英

Use Existing Icon in Tiny MCE custom Button

could we use existing icon to custom button? (not an image)

I have tried this, but it doesn't work:

tinymce.init({
   ...

   toolbar: 'example'

   setup: function(ed) {
      ed.addButton('example', {
         title: 'My title',
         image: '../js/tinymce/plugins/example/img/example.gif',
         classes: 'mce-ico mce-i-image',
         onclick: function() {
            ed.insertContent('Hello world!!');
         }
      });
   }
});

Yes you can use an existing icon.

You can take the class name from an existing button - eg "mce-i-image" as you've done - then, rather than apply that to the class name of your new button, you strip off the "mce-i-" prefix and use the remainder - "image" in this case - as the icon key.

I've amended your example below.

eg

setup: function(ed) {
  ed.addButton('example', {
    title: 'My title',
    icon: 'image',  // This line sets the icon key.
    onclick: function() {
      ed.insertContent('Hello world!!');
    }
  });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM