我需要将参数数据发送到对话框
这是我在 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
最好的祝福
最佳答案
最好的方法是在单独的文件中声明对话框
plugin.js:
CKEDITOR.dialog.add('editDialog', this.path + 'dialogs/editDialog.js');//
然后,将命令绑定(bind)到对话框实例化:
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
关于dialog - 将数据参数发送到 ckeditor 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36951460/