Skip to main content

@lexical/react/LexicalNodeContextMenuPlugin

Classes

NodeContextMenuOption

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:49

A selectable item in a NodeContextMenuPlugin. It pairs a title (and optional icon/disabled state) with a $onSelect callback that runs in an editor update when chosen, and an optional $showOn predicate that decides, per node, whether the item is shown for the right-clicked node.

Extends

  • MenuOption

Constructors

Constructor

new NodeContextMenuOption(title, options): NodeContextMenuOption

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:57

Parameters
title

string

options
$onSelect

() => void

$showOn?

(node) => boolean

disabled?

boolean

icon?

Element

Returns

NodeContextMenuOption

Overrides

MenuOption.constructor

Properties

$onSelect

$onSelect: () => void

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:54

Returns

void

$showOn?

optional $showOn?: (node) => boolean

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:55

Parameters
node

LexicalNode

Returns

boolean

disabled

disabled: boolean

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:53

icon

icon: Element | null

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:52

key

key: string

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:29

Inherited from

MenuOption.key

ref?

optional ref?: RefObject<HTMLElement | null>

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:30

Inherited from

NodeContextMenuSeparator.ref

title

title: string

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:51

type

type: string

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:50

Methods

setRefElement()

setRefElement(element): void

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:38

Parameters
element

HTMLElement | null

Returns

void

Inherited from

MenuOption.setRefElement


NodeContextMenuSeparator

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:83

A non-interactive divider between groups of NodeContextMenuOptions in a NodeContextMenuPlugin. Like menu options, it accepts an optional $showOn predicate to control when it is displayed.

Extends

  • MenuOption

Constructors

Constructor

new NodeContextMenuSeparator(options?): NodeContextMenuSeparator

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:87

Parameters
options?
$showOn?

(node) => boolean

Returns

NodeContextMenuSeparator

Overrides

MenuOption.constructor

Properties

$showOn?

optional $showOn?: (node) => boolean

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:85

Parameters
node

LexicalNode

Returns

boolean

key

key: string

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:29

Inherited from

MenuOption.key

ref?

optional ref?: RefObject<HTMLElement | null>

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:30

Inherited from

MenuOption.ref

type

type: string

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:84

Methods

setRefElement()

setRefElement(element): void

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:38

Parameters
element

HTMLElement | null

Returns

void

Inherited from

MenuOption.setRefElement

Variables

NodeContextMenuPlugin

const NodeContextMenuPlugin: ForwardRefExoticComponent<Omit<Props & HTMLProps<HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>

Defined in: packages/lexical-react/src/LexicalNodeContextMenuPlugin.tsx:161

Renders a custom context menu (replacing the browser's) when the user right-clicks inside the editor. Pass the items to display as NodeContextMenuOptions and NodeContextMenuSeparators; each item's optional $showOn predicate is evaluated against the node nearest the click so the menu can adapt to its target. Supports keyboard navigation and type-ahead.

Returns

A portal containing the floating context menu while it is open.