CKEditor - “图像属性”对话框为空白

时间:2014-10-30 07:32:18

标签: javascript jquery ckeditor

我使用默认的Image插件,其常用值为:

  CKEDITOR.replace( 'editor', 

                      {
                        filebrowserBrowseUrl: '/app/myimages.html',
                        filebrowserUploadUrl: '/app/myfiles.html',
                        filebrowserImageBrowseUrl: '/app/myimages.html'
}

通过图像选择对话框选择后,图像在编辑器中正确显示。

但是当我右键单击图像并选择图像属性菜单时 打开的对话框不包含图片网址或宽度或高度等。它基本上没有值。

1 个答案:

答案 0 :(得分:1)

查看我的评论。但对我来说,它是在onShow()上覆盖的。

CKEDITOR.on('dialogDefinition', function( ev ) {
			// Take the dialog window name and its definition from the event data.
			var dialogName = ev.data.name;
			var dialogDefinition = ev.data.definition;
			
			if ( dialogName == 'image' ) {
				/*dialogDefinition.onShow = function() {
					this.selectPage( 'info' );
				};*/ // do not override this function, it will cause a JS on save (setCustomData can not be found on null object), and the edit image will not fill in its fields.
				
				dialogDefinition.removeContents( 'Link' ); // remove these tabs
				dialogDefinition.removeContents( 'advanced' );
				dialogDefinition.removeContents( 'Upload' );
				
				var contents = dialogDefinition.getContents( 'info' );
				//contents.remove( 'htmlPreview' ); // will cause a JS error if disabled.
				contents.remove( 'ratioLock' );
				contents.remove( 'txtHSpace' );
				contents.remove( 'txtVSpace' );
				contents.remove( 'txtAlt' );
				contents.remove( 'txtBorder' );
				
				contents.get('txtWidth').width = 'auto';
				contents.get('txtHeight').width = 'auto';
				contents.get('txtUrl').disabled = 'disabled';
			}
		});