如何自定义ckeditor 4.2内置插件像链接? [英] How do I customize a ckeditor 4.2 builtin plugin like links?

查看:109
本文介绍了如何自定义ckeditor 4.2内置插件像链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在链接插件中添加一个标签,最好的做法是什么?我不想改变发布代码,只是用我的自定义版本覆盖它。所以很容易更新与新版本。 CKEDITOR 4.2有这个怎么办?我正在使用新的内联样式工具栏。

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?

推荐答案

你必须观察 dialogDefinition 事件:

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

或修改它们:

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

或事件移除整个标签:

def.removeContents( 'anotherTab' );

这篇关于如何自定义ckeditor 4.2内置插件像链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆