2016-12-19 16 views
1

の特定のCKEditorツールバーのボタンアイコンを変更します。コアのイメージを上書きする独自のボタンアイコンを定義する方法は変わりません。アイコン。私は既にicons/image.pngというファイルでカスタムスキンを実装しましたが(ここではimageはボタンの名前になります)、これでは不十分です。 どうすればいいですか?明確にするために<a href="http://docs.ckeditor.com/#!/guide/skin_sdk_icons" rel="nofollow noreferrer">documentation on skin icons</a>を読んだ後で、スキン

:私は、このアイコンを交換することにしたい。

example of icon

答えて

3

これは、同様のシナリオのための私のアプローチです。

デフォルトの画像アイコンやその他の不要なアイコンを無効にしました。

私は自分のボタンを追加し、アイコンのために、デフォルトのpngの代わりにフォントのすばらしいアイコンを使用しました。

//In the config.js 
var editor; 

var plgnIconSize = "16px"; 
var plgnIcons = ["fa-file-image-o", ...]; 
var plgnNames = 'img,... Other plugins'; 
var plgnDefault = 'fa-plug'; 

CKEDITOR.editorConfig = function (config) { 

    config.toolbar = [ 
     { name: 'uploader', items: ['img'] }, 
     // Your other plugins as per your need goes here 
    ]; 

    config.extraPlugins = plgnNames; 
}); 

CKEDITOR.on("instanceReady", function (event) { 

    editor = event.editor; 

    var this_instance = document.getElementById(event.editor.id + '_toolbox'); 

    var plugins = plgnNames.split(','); 
    for (var i = 0; i < plugins.length; i++) { 
     var this_button = this_instance.querySelector('.cke_button__' + plugins[i] + '_icon'); 

     if (typeof this_button !== null) { 
      var icon; 
      if (typeof plgnIcons[i] === 'undefined') 
       icon = plgnDefault 
      else 
       icon = plgnIcons[i]; 

      if (typeof this_button !== notdefined) { 
       this_button.innerHTML = '<i class=" ' + plgnClass[i] + ' fa ' + icon + '" style="font: normal normal normal ' + plgnIconSize + '/1 FontAwesome !important;cursor: default;"></i>'; 
      } 

     } 
    } 
}); 
+0

TL; DRの場合、アイコンはDOM単位で置き換えられましたか?しかし、私はそれがインスピレーションのために行くだろうと思う! –

+1

うわー!私は解決策を見いだすことができなかったので、しばらくしてこのトリックを思いついた。しかし、この方法では、周りに遊ぶ素晴らしいフォントアイコンがたくさんあるので、アイコンを探す必要はありません。どういたしまして。 – Ozesh

関連する問題

 関連する問題