An options object for creating a context menu item.

interface IItemOptions {
    args?: ReadonlyJSONObject;
    command?: string;
    rank?: number;
    selector: string;
    submenu?: null | Menu;
    type?: ItemType;
}

Hierarchy (view full)

Properties

The arguments for the command.

The default value is an empty object.

command?: string

The command to execute when the item is triggered.

The default value is an empty string.

rank?: number

The rank for the item.

The rank is used as a tie-breaker when ordering context menu items for display. Items are sorted in the following order:

  1. Depth in the DOM tree (deeper is better)
  2. Selector specificity (higher is better)
  3. Rank (lower is better)
  4. Insertion order

The default rank is Infinity.

selector: string

The CSS selector for the context menu item.

The context menu item will only be displayed in the context menu when the selector matches a node on the propagation path of the contextmenu event. This allows the menu item to be restricted to user-defined contexts.

The selector must not contain commas.

submenu?: null | Menu

The submenu for a 'submenu' type item.

The default value is null.

type?: ItemType

The type of the menu item.

The default value is 'command'.