Replace CKEditor toolbar images with font awesome icons

旧巷老猫 提交于 2019-12-11 03:59:43

问题


Is there some way to replace the default toolbar images (e.g. Bold, Italic, etc.) with Font Awesome icons?


回答1:


I know this is an old issue, but on a plugin by plugin basis I've been able to add font-awesome icons to ckeditor buttons with the following code inside the plugin's init function. In my case my plugin was called 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>';
  }
});

It hinges on knowing the class of the span inside the button, so it might not be the most convenient but it works.




回答2:


The best thing is you can use Bootstrap theme on CKEditor or you can use Froala editor,It has inbuilt image uploader



来源:https://stackoverflow.com/questions/24450396/replace-ckeditor-toolbar-images-with-font-awesome-icons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!