我如何编程设置CKEditor的默认表属性? [英] How do I programatically set default table properties for CKEditor?

查看:138
本文介绍了我如何编程设置CKEditor的默认表属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置在CKEditor中创建的表的默认属性。
例如,有一种方法可以确保属性边框是0不是1,或者宽度默认设置为100%。

I am trying to set up the default properties of table that is created inside CKEditor. For example is there a way to make sure that the attribute border is 0 not 1, or the width is by default set to 100%.

谢谢

推荐答案

在这里。 dialogDefinition 事件解决了问题:

Here you go. dialogDefinition event solves the problem:

CKEDITOR.on( 'dialogDefinition', function( ev ) {
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;

    if ( dialogName == 'table' ) {
        var info = dialogDefinition.getContents( 'info' );

        info.get( 'txtWidth' )[ 'default' ] = '100%';       // Set default width to 100%
        info.get( 'txtBorder' )[ 'default' ] = '0';         // Set default border to 0
    }
});

CKEDITOR.replace( 'editor1' );

更多阅读:

  • This official guide will help you playing with dialog API (also with devtools plugin).
  • Devtools plugin is helpful when looking for IDs and elements in CKEditor dialogs.

有乐趣!

这篇关于我如何编程设置CKEditor的默认表属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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