在Tiny MCE自定义按钮中使用现有图标

时间:2013-12-23 08:18:04

标签: javascript css tinymce

我们可以使用现有的图标来自定义按钮吗? (不是图像)

我试过这个,但它不起作用:

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!!');
         }
      });
   }
});

1 个答案:

答案 0 :(得分:6)

是的,您可以使用现有的图标。

您可以从现有按钮中获取班级名称 - 例如" MCE-I-图像"正如你已经完成的那样 - 然后,不是将其应用于新按钮的类名,而是剥离" mce-i - "前缀并使用余数 - "图像"在这种情况下 - 作为图标键。

我已经修改了下面的例子。

e.g。

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