我一直在使用带有图像附件的ckeditor,并且使用javascript控制了图像对话框,我的代码如下:
$(document).ready(function(){
CKEDITOR.on( 'dialogDefinition', function( ev )
{
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if ( dialogName == 'image' ){
dialogDefinition.removeContents( 'advanced' );
dialogDefinition.removeContents( 'Link' );
var onOk = dialogDefinition.onOk;
var infoTab = dialogDefinition.getContents( 'info' );
infoTab.remove( 'ratioLock' );
//infoTab.remove( 'txtHeight' );
//infoTab.remove( 'txtWidth' );
infoTab.remove( 'txtBorder');
infoTab.remove( 'txtHSpace');
infoTab.remove( 'txtVSpace');
infoTab.remove( 'cmbAlign' );
//infoTab.remove( 'txtAlt' );
//infoTab.remove( 'htmlPreview' );
dialogDefinition.onOk = function (e) {
var width = this.getContentElement('info', 'txtWidth');
console.log(width.val);
width.setValue('350');//Set Default Width
var height = this.getContentElement('info', 'txtHeight');
height.setValue('200');////Set Default height
onOk && onOk.apply(this, e);
};
}
});
我的问题是我想控制宽度和高度,我用infoTab.remove
删除了这些字段,所以它没有得到该字段,因此它返回以下错误,
Uncaught TypeError: Cannot read property 'setValue' of undefined at CKEDITOR.dialog.dialogDefinition.onOk
所以我需要帮助隐藏width和height字段以控制图像的宽度和高度