Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
382 views
in Technique[技术] by (71.8m points)

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

If I want to add a tab to the links plugin, what's the best practice approach? I don't want to alter the release code just override it with a version with my customizations. So it's easy to update with new releases. Does CKEDITOR 4.2 have a how-to for this? I'm using the new inline style toolbars.

If I get the source code can I rebuild the release version without the links plugin? and then do an external plugin using my customized version of the links plugin?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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' );

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...