Add menu items dynamically

Is there a way to add menu items to the plugin menu dynamically?

There exists MenuItems#insertAt( index: number, MenuItem ) (https://forums.adobeprerelease.com/photoshop/discussion/2034/update-uxp-release-4-1-2-214-pr41-m-1047).

But with the addition:
NOTE: this is misleading: it does not insert a new item, but overwrites the existing menu without properly removing it from the internal structure (meaning you can’t add the item back with the same id). You should avoid using this, as a future fix will change this behavior.

Are there any updates @kerrishotts?

That would be nice to have if XD supported flyout menus but I’d like to avoid those for edit context reasons. I’m thinking about adding new items to the Application > Plugins > My Plugin menu.

I’d like to add a few commands dynamically.

Right now the only way I can do that is to hard code the values in the manifest:

"uiEntryPoints": [
    {
        "type": "menu",
        "label": "My Plugin",
        "menuItems": [
            {
                "type": "menu",
                "label": {
                    "default": "Do something"
                },
                "commandId": "doSomething"
            },
            {
                "type": "menu",
                "label": {
                    "default": "Do something else"
                },
                "commandId": "somethingElse"
            },
            {
                "type": "menu",
                "label": {
                    "default": "Another menu"
                },
                "commandId": "anotherMenu"
            }
        ]
    }
]

Hi @Velara - curious if you could expand on your use case for the dynamic change, and why static/hardcoded menu items aren’t suitable for your plugin? For instance, do you want to see the items change depending on what the user has selected, or any other criteria?

This is feedback from my users that since there are a few ambiguous commands in my plugin a few actions can get confusing.

I’d like to make my menu items more specific to update the menu labels and possibly add more menus dynamically.

My menu is something like:

  • Send selected node via email

I’d like to make it more specific:

  • Email “Artboard 1 Group 2” to “Alvin”

Or if a user selects a group on the artboard I could add sub menu items :

Email menu > Group > Text 1
                   > Image 2
                   > Background Rectangle