How do I customize a ckeditor 4.2 builtin plugin like links?

You got to observe dialogDefinition event to do this:

CKEDITOR.on( 'dialogDefinition', function( evt ) {
    var dialog = evt.data;

    if ( dialog.name == 'link' ) {
        // Get dialog definition.
        var def = evt.data.definition;

        // Add some stuff to definition.
        def.addContents( {
            id: 'custom',
            label: 'My custom tab',
            elements: [
                {
                    id: 'myField1',
                    type: 'text',
                    label: 'My Text Field'
                },
                {
                    id: 'myField2',
                    type: 'text',
                    label: 'Another Text Field'
                }
            ]
        });

    }
} );

CKEDITOR.replace( 'editor1' );

You can also remove existing fields:

var someTab = def.getContents( 'someTab' );
someTab.remove( 'someField' );

Or modify them:

var input = someTab.get( 'input' );
input[ 'default' ] = 'www.example.com';

Or event remove the whole tab:

def.removeContents( 'anotherTab' );

Leave a Comment