是否有某种方法可以用 Font Awesome 图标替换默认的工具栏图像(例如粗体、斜体等)?
最佳答案
我知道这是一个老问题,但在逐个插件的基础上,我已经能够在插件的 init
函数中使用以下代码向 ckeditor 按钮添加字体很棒的图标。就我而言,我的插件名为 trim
:
//Set the button name and fontawesome icon
var button_name = 'trim';
var icon = 'fa-scissors';
//When a ckeditor with this plugin in it is created, find the button
//in the current instance and add the fontawesome icon
CKEDITOR.on("instanceReady", function(event) {
var this_instance = document.getElementById(event.editor.id + '_toolbox');
var this_button = this_instance.querySelector('.cke_button__' + button_name + '_icon');
if(typeof this_button != 'undefined') {
this_button.innerHTML = '<i class="fa ' + icon + '" style="font: normal normal normal 14px/1 FontAwesome !important;"></i>';
}
});
它取决于了解按钮内跨度的类,因此它可能不是最方便的,但它可以工作。
关于ckeditor - 用很棒的字体图标替换 CKEditor 工具栏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24450396/