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

.NET ProgrammingJavaScript

Avatar of undefined
Last Comment
David Rudlin
ASKER CERTIFIED SOLUTION
Avatar of Alfredo Luis Torres Serrano
Alfredo Luis Torres Serrano
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of David Rudlin
David Rudlin
Flag of United Kingdom of Great Britain and Northern Ireland image

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





Avatar of David Rudlin
David Rudlin
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo