Change CKEditor toolbar dynamically

后端 未结 10 1720
猫巷女王i
猫巷女王i 2020-12-09 04:30

How do you change the CKEditor toolbar dynamically (without using a pre-defined toolbar)?

The CKEditor Developer\'s Guide only tells you how to set the toolbar durin

10条回答
  •  借酒劲吻你
    2020-12-09 05:30

    You can create toolbar dynamically as you like. I found that the best approach is to listen to CKE events regarding instance creation.

    CKEDITOR.on('instanceCreated', function(event) {
        var editor = event.editor;
        editor.config.toolbar = [
            { name: 'basicstyles', groups: [ 'basicstyles'], items: [ 'Bold', 'Italic','Subscript', 'Superscript' ] },
        ]; // could be from synchronous!!! XHR as well 
    });
    
    CKEDITOR.on('instanceReady', function(event) {
        var editor = event.editor;
        editor.config.toolbar = [
            { name: 'basicstyles', groups: [ 'basicstyles'], items: [ 'Bold', 'Italic','Subscript', 'Superscript' ] },
        ];
    });
    

提交回复
热议问题