CKEDITOR - 在工具栏中创建新按钮

时间:2015-04-10 09:47:14

标签: ckeditor

我正在尝试在CKEDITOR工具栏中创建一个新按钮并使用它做一些事情但是没办法......

我的控制台中没有任何错误,工具栏中没有任何内容......

我的代码:

var textarea = $('#tiny_mce_block').find('textarea');
var textareaId;

$(document).ready(function () {
    textareaId = textarea.attr('id'); // Récupère l'ID du textarea pour être transformé par CKEDITOR
    ckeditor_init(); // Initialisation de CKEDITOR
});

/*************************
 CKEDITOR
 ************************/
function ckeditor_init() {
    CKEDITOR.replace(textareaId, {
        removePlugins: 'autosave, elementspath', //, liststyle, tabletools, contextmenu <= à ajouter pour supprimer click droit
        language: 'fr',
        entities: false,
        entities_latin: false,
        contentsCss: [
            '/css/ckeditor_audio_transcription_v1.css',
            '/plugins/bower_components/ckeditor/contents.css'
        ],
        allowedContent: true,
        extraAllowedContent: 'show, word',
        disallowedContent: 'script, script; *[on*]',
        enterMode: CKEDITOR.ENTER_P,
        autoParagraph: false,
        ignoreEmptyParagraph: true,
        toolbar: [
            ['Bold', 'Italic', 'Underline', '-', 'TextColor'],
            ['Undo', 'Redo'],
            ['Find', 'Replace', 'SelectAll'],
            ['Maximize']
        ],
        on: {
            // Register command and button along with other plugins.
            pluginsLoaded: function () {
                var editor = this;

                // Registers a command that applies the style.
                // Note: it automatically adds Advanced Content Filter rules.
                this.addCommand("alignementCommand", { // create named command
                    exec: function (edt) {
                        alert(edt.getData());
                    }
                });

                // Add toolbar button for this command.
                this.ui.addButton && this.ui.addButton('alignementBoutton', {
                    label: 'Alignement',
                    command: 'alignementCommand',
                    toolbar: 'insert'
                });
            }
        }
    });
}

问题出在哪里?

谢谢!

0 个答案:

没有答案