Я создал CodePen, чтобы проиллюстрировать этот вопрос: TinyMCE Menu IssueTinyMCE - Как исправить это выпадающее меню
tinymce.init({
selector: 'textarea',
menu: {
file: { title: 'File', items: 'newdocument' },
edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall' },
insert: { title: 'Insert', items: 'link media | template hr' },
view: { title: 'View', items: 'visualaid' },
format: { title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat' },
table: { title: 'Table', items: 'inserttable tableprops deletetable | cell row column' },
tools: { title: 'Tools', items: 'spellchecker code' },
myapp: { title: 'My Application', items: 'myapp' }
},
plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking save table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc'
],
toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'forecolor backcolor emoticons | codesample',
image_advtab: true,
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
'//www.tinymce.com/css/codepen.min.css'
],
setup: function (editor) {
editor.addMenuItem('myapp', {
text: 'My Application',
context: 'myapp',
menu: [{
text: 'Data Loop',
onclick: function() {
editor.insertContent('{LOOP:Data}');
}
}, {
text: 'Collection Loop',
onclick: function() {
editor.insertContent('{LOOP:Collection}');
}
}, {
text: 'Process Loop',
onclick: function() {
editor.insertContent('{LOOP:Process}');
}
}, {
text: 'Server Name',
onclick: function() {
editor.insertContent('{ServerName}');
}
}, {
text: 'Email Group Name',
onclick: function() {
editor.insertContent('{EmailGroupName}');
}
}, {
text: 'Alert Group Name',
onclick: function() {
editor.insertContent('{AlertGroupName}');
}
}]
});
}
});
Если вы посмотрите на эту codepen, вы увидите, что в меню «Мой Application» на самом деле падает в два раза , чего я действительно не хочу. Я хочу простой одноуровневый раскрывающийся список. Не знаю, почему я не могу понять это.
Любая помощь очень ценится!
Ах !!! Спасибо. Раньше у меня была кнопка, но я не мог добавить ее в меню. Я изменил его на MenuItem, прежде чем я переместил его в верхнее меню. Argh! Большое спасибо @Dekel! – Andrew
Уверенный :), пожалуйста. – Dekel