Menu Manager

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

An instance of this class is always available as the inkdrop.menu global.

Here is an example from the inkdrop-paste-as-markdown:

[
  {
    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.

{
  "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(items)

Add Menu Items

Add items to the application menu.

Parameters

  • Name
    items
    Type
    array
    Required
    Description

    An array of menu item objects containing the following keys:

      item object
    • Name
      label
      Type
      string
      Description

      The String menu label.

    • Name
      submenu
      Type
      object
      Description

      An optional Array of sub menu items.

    • Name
      command
      Type
      string
      Description

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

Returns

Returns a Disposable on which .dispose() can be called to remove the added menu items.

Adding Menu Items Example

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

update()

Refresh the Menu

Refresh the currently visible menu to reflect any changes.


Can you help us improve the docs? 🙏

The source of these docs is here on GitHub. If you see a way these docs can be improved, please fork us!