Link to home
Start Free TrialLog in
Avatar of David Rudlin
David RudlinFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to add submenu to Tinymce v5.8 Splitbutton dropdown list

Using Tinymce v5.8 in a asp.net web application. I have added a splitbutton component to the toolbar and successfully added items to the splitbutton's dropdown list. Is there now a way to add a submenu to the list?

I have tried the attached code but the submenu does not appear. I guess that the "type: 'submenu' may be causing the issue but can find no documentation on this or could be that submenus simply are not a feature of this component. Any help or suggestions would be gratefully received.
  editor.ui.registry.addSplitButton('myButton', {
                     text: 'My Button',
                     icon: 'info',
                     tooltip: 'This is an example split-button',
                     onAction: function () {
                         //editor.insertContent('<p>You clicked the main button</p>');
                     },
                     onItemAction: function (api, value) {
                         editor.insertContent(value);
                     },
                     fetch: function (callback) {
                     
                         var items = [
                             { type: 'choiceitem', text: 'One', value: 'one ' },
                             { type: 'choiceitem', text: 'Two', value: 'two ' },
                             {
                              type: 'submenu',  text: 'Submenu', items: [
                                     { type: 'choiceitem', text: 'Three', value: 'three' }
                                 ]
                             }
                         ];

                         callback(items);
                     }
                 });

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Alfredo Luis Torres Serrano
Alfredo Luis Torres Serrano
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Rudlin

ASKER

Thank you for the suggestion Alfredo. So that works as a menu item but is there anyway of doing the same with a toolbar item?



Open in new window





Thanks Alfredo. This helped. Some of the syntax and methods needed updating in line with version 5 and there was considerable work required in getting data to populate the menu items and also the nested menu items.