Skip to main content

@lexical/react/LexicalNodeContextMenuPlugin

Classes​

NodeContextMenuOption​

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

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:69

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:66

Returns​

void

$showOn?​

optional $showOn?: (node) => boolean

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

Parameters​
node​

LexicalNode

Returns​

boolean

disabled​

disabled: boolean

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

icon​

icon: Element | null

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

key​

key: string

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

Inherited from​

MenuOption.key

ref?​

optional ref?: RefObject<HTMLElement | null>

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

Inherited from​

NodeContextMenuSeparator.ref

title​

title: string

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

type​

type: string

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

Methods​

setRefElement()​

setRefElement(element): void

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

Parameters​
element​

HTMLElement | null

Returns​

void

Inherited from​

MenuOption.setRefElement


NodeContextMenuSeparator​

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

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:99

Parameters​
options?​
$showOn?​

(node) => boolean

Returns​

NodeContextMenuSeparator

Overrides​

MenuOption.constructor

Properties​

$showOn?​

optional $showOn?: (node) => boolean

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

Parameters​
node​

LexicalNode

Returns​

boolean

key​

key: string

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

Inherited from​

MenuOption.key

ref?​

optional ref?: RefObject<HTMLElement | null>

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

Inherited from​

MenuOption.ref

type​

type: string

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

Methods​

setRefElement()​

setRefElement(element): void

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

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:176

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.