ckeditor 上的临时禁用按钮

use*_*292 3 ckeditor

如何在选择图像时启用或禁用 CKEditor 的段落按钮。我不想完全删除它。我目前使用 ckeditor 4.4 版

ole*_*leq 6

使用editor.getCommand()+ CKEDITOR.commandAPIenabledisable):

editor.getCommand( 'justifyleft' ).disable();
editor.getCommand( 'justifyleft' ).enable();
Run Code Online (Sandbox Code Playgroud)

例如:

CKEDITOR.instances.editor1.on( 'selectionChange', function( evt ) {
    var jLeftCommand = this.getCommand( 'justifyleft' ),
        jRightCommand = this.getCommand( 'justifyright' );

    if ( evt.data.path.lastElement.is( 'img' ) ) { 
        jLeftCommand.disable();
        jRightCommand.disable();
    } else {
        jLeftCommand.enable();
        jRightCommand.enable();
    }
} );
Run Code Online (Sandbox Code Playgroud)