我想为我的所有tinyMCE组件添加一个自定义菜单(如文件,编辑) . 喜欢做什么here . 我尝试使用该代码,但它不起作用,我想是否有可能以另一种方式,不创建插件,只是在tinyMCE.init()函数中添加我的自定义菜单,在安装程序 . 我找到了一种方法来添加这样的子菜单
tinyMCE.init({
mode: "textareas",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste "
],
toolbar: " undo redo | styleselect | bullist numlist outdent indent | link image",
setup: function (ed) {
ed.addMenuItem('example', {
text: 'My menu item',
context: 'tools',
onclick: function () {
ed.insertContent('Hello world!!');
}
});
}
});
这会在“工具”菜单中添加一个菜单项 . 而不是那个菜单项,我需要添加一个完整的菜单,如上面的链接,但我不知道如何 . 我尝试在我的设置功能中添加用于创建菜单的代码
tinyMCE.init({
mode: "textareas",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste "
],
toolbar: " undo redo | styleselect | bullist numlist outdent indent | link image",
setup: function (ed) {
var c = ed.createMenuButton('mymenubutton', {
title: 'My menu button',
image: 'img/example.gif',
icons: false
});
c.onRenderMenu.add(function (c, m) {
var sub;
m.add({ title: 'Some item 1', onclick: function () {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, 'Some item 1');
}
});
m.add({ title: 'Some item 2', onclick: function () {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, 'Some item 2');
}
});
sub = m.addMenu({ title: 'Some item 3' });
sub.add({ title: 'Some item 3.1', onclick: function () {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, 'Some item 3.1');
}
});
sub.add({ title: 'Some item 3.2', onclick: function () {
tinyMCE.activeEditor.execCommand('mceInsertContent', false, 'Some item 3.2');
}
});
});
}
});
但它不起作用 . 这样做最简单的方法是什么?
1 回答
管理通过在工具栏中添加新菜单来解决它,如here