set plugin toolbar icon using class names in CK Ed

2019-09-16 14:51发布

问题:

How do I set plugin and/or widget toolbar button icon using class names (instead of using image URL)?

回答1:

I've found a hack for this seemingly obvious missing feature:

editor.ui.addButton('MyButton', {
    //className: '...' // this only adds the classes to the parent container, not the icon span
    icon: '_ fa fa-scissors _'  // this hacks the existing classes and injects extra classes to the icon span
});

Tested with CK Editor v4.6.2