ckeditor - 通过 Skin 更改特定的 CKEditor 工具栏按钮图标

标签 ckeditor ckeditor4.x

阅读 documentation on skin icons 后我仍然想知道如何定义自己的按钮图标来覆盖核心的图像图标。我已经使用文件 icons/image.png 实现了自定义皮肤(其中 image 旨在作为按钮的名称),但这还不够。 我能做什么?

澄清一下:我希望替换此图标:

example of icon

最佳答案

这是我针对类似场景的方法。

我禁用了默认图像图标和其他不需要的图标。

我添加了自己的按钮,对于图标,我使用字体很棒的图标而不是默认的 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>';
            }

        }
    }
});

关于ckeditor - 通过 Skin 更改特定的 CKEditor 工具栏按钮图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41227216/

相关文章:

javascript - CKEditor 4.7 无法读取未定义的属性 'on',请用ajax咨询并重置

ckeditor - 每当用户粘贴任何数据时自动应用某种字体

javascript - CKEditor 5 和图像按钮

CKEditor 4.7 : Is it possible to apply css class to specific elements only in the WYSIWYG mode?

javascript - 通过 jQuery 重置表单不清除 ckeditor cktext_area 字段

grails - 如何让Grails不逃避CK编辑器生成的html标签

javascript - ckeditor - 在编辑器外编辑 contenteditable div

javascript - 关键事件不适用于多个 ckeditor

jquery - 在提交之前以编程方式编辑 CKEditor 的内容

javascript - Apache 将 JavaScript 脚本解释为 text/html