ckeditor插件中是否可以有子菜单?IE
问问题
694 次
2 回答
4
是的。支持子菜单(菜单组)。有一个如何定义它们的示例。如果您tabletools
在编辑器中加载了插件,则可以通过右键单击某个表格单元格来观察它。
于 2013-04-22T08:28:40.850 回答
1
此代码段必须添加父菜单项并从服务器获取子菜单项并将其添加到父菜单下。
var myMenu{
openEditor: function(sender) {
sender.ckeditor(function(element) {
}, {
on: {
instanceReady: function(c) {
myMenu.setupParameterMenu(c.editor);
}
}
});
},
setupParameterMenu: function(ceditor) {
ceditor.addMenuGroup('Parameters');
var subItems = {};
var parentMenu = {};
parentMenu.label = "Dynamic Parameters";
parentMenu.group = 'Parameters';
parentMenu.order = 1;
parentMenu.getItems = function() {
return subItems;
};
ceditor.addMenuItem("Dynamic Parameters", parentMenu);
ceditor.contextMenu.addListener(function(element, selection) {
return {"Dynamic Parameters": CKEDITOR.TRISTATE_OFF};
});
$.getJSON("/JSON/Parameters", function(json) {
for (var i = 0; i < json.length; i++) {
var subMenu = myMenu.subMenuItem(json[i], ceditor);
for (var key in subMenu) {
subItems[key] = subMenu[key];
}
}
});
},
subMenuItem: function(param, ceditor) {
ceditor.addCommand(param, {
exec: function(editor)
{
var element = CKEDITOR.dom.element.createFromHtml('<span contenteditable="false">' + param + '</span>');
editor.insertElement(element);
}
});
var zet = {};
zet.label = param;
zet.command = param;
zet.group = 'Parameters';
zet.order = i + 1;
ceditor.addMenuItem("" + param, zet);
var n = {};
n[param] = CKEDITOR.TRISTATE_OFF;
return n;
}
}
于 2014-10-18T09:23:46.503 回答