# Menu Manager

Source: https://developers.inkdrop.app/modules/menu-manager

Provides a registry for menu items that you'd like to appear in the application menu.

Available as `env.menu` on the [Environment](https://developers.inkdrop.app/modules/environment) passed to `activate(env)`.

## Menu JSON Format

Here is an example from the [inkdrop-paste-as-markdown](https://github.com/inkdropapp/inkdrop-paste-as-markdown):

```js
[
  {
    label: 'Plugins',
    submenu: [
      {
        label: 'Paste as Markdown',
        command: 'paste-as-markdown'
      }
    ]
  }
]
```

Use in your package's menu `.json` file requires that you place your menu structure under a `menu` key.

```js
{
  "menu": [
    {
      "label": "File",
      "submenu": [
        {
          "label": "Import",
          "submenu": [
            { "label": "from HTML files..", "command": "import-html:import-from-file" }
          ]
        }
      ]
    }
  ]
}
```

See `::add` for more info about adding menu's directly.

---

## Add Menu Items `add(items)`

Add items to the application menu.

### Parameters

- **items** (array, required)

  An array of menu item objects containing the following keys:
  - **label** (string)

    The String menu label.
  - **submenu** (object)

    An optional Array of sub menu items.
  - **command** (string)

    An optional String command to trigger when the item is clicked.

### Returns

Returns a [Disposable](https://developers.inkdrop.app/event-subscription/disposable) on which `.dispose()` can be called to remove the added menu items.

```js
env.menu.add([
  {
    label: 'Hello',
    submenu: [{ label: 'World!', command: 'hello:world' }]
  }
])
```

---

## Refresh the Menu `update()`

Refresh the currently visible menu to reflect any changes.

---
