我目前正在尝试使用 CKEditor 添加 XML 条目。我修改了示例插件的代码:
CKEDITOR.dialog.add( 'abbrDialog', function( editor ) {
return {
title: 'Abbreviation Properties',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Basic Settings',
elements: [
{
type: 'text',
id: 'abbr',
label: 'Title',
validate: CKEDITOR.dialog.validate.notEmpty( "Title cannot be empty" )
},
{
type: 'text',
id: 'title',
label: 'Price',
validate: CKEDITOR.dialog.validate.notEmpty( "Price cannot be empty" )
}
]
},
{
id: 'tab-adv',
label: 'Advanced Settings',
elements: [
{
type: 'text',
id: 'id',
label: 'Id'
}
]
}
],
onOk: function() {
var dialog = this;
var abbr = editor.document.createElement( 'abbr' );
abbr.setAttribute( 'title', dialog.getValueOf( 'tab-basic', 'title' ) );
abbr.setText( dialog.getValueOf( 'tab-basic', 'abbr' ) );
var id = dialog.getValueOf( 'tab-adv', 'id' );
if ( id )
abbr.setAttribute( 'id', id );
editor.insertElement( abbr );
}
};
});
但是,当我再次单击编辑器以添加更多项目时,标签变成嵌套的,例如 . 这是不希望的。如何限制另一个标签内没有任何标签?谢谢