我需要将参数数据发送到对话框 这是我在plugin.js中的代码(右键单击)
editor.addCommand( 'editDialog', {
exec: function( editor) {
CKEDITOR.currentInstance.openDialog('editDialog');
}
});
if ( editor.contextMenu )
{
editor.addMenuGroup( 'myGroup' );
editor.addMenuItem( 'sliderItem',
{
label : 'Edit Gallery',
command : 'editDialog',
group : 'myGroup'
});
editor.contextMenu.addListener( function( element )
{
if ( element ){
element = element.getAscendant( 'wscms-gallery', true );
}
if ( element && !element.isReadOnly() && !element.data( 'cke-realelement' ) ){
return { sliderItem : CKEDITOR.TRISTATE_OFF};
}
return null;
});
}
我想在右键单击并单击editgallery将任何参数发送到editDialog
最好的问候
答案 0 :(得分:0)
最好的方法是在单独的文件中声明对话框
plugin.js:
CKEDITOR.dialog.add('editDialog', this.path + 'dialogs/editDialog.js');//
然后,将命令绑定到对话框实例:
editor.addCommand('editCommand', new CKEDITOR.dialogCommand('editDialog'));
最后,在对话框中处理onShow事件,以确定是要编辑现有元素还是创建新元素:
editDialog.js:
onShow: function () {
var node = 'wscms-gallery';
var element = editor.getSelection().getStartElement();// Get the element at the start of the selection.
if (element) {
element = element.getAscendant(node, true);// Get the <node> element closest to the selection, if it exists.
}
if (!element || element.getName() !== node) {// Create a new <node> element if it does not exist.
element = editor.document.createElement(node);
this.insertMode = true;
} else {
this.insertMode = false;
}
this.element = element;
console.log(element);
if (!this.insertMode) {
this.setupContent(this.element); //you MUST to implement the setup: method to get the parameters
}
},
有关更多信息,请检查this example of simple plugin