Skip to main content

@lexical/react/LexicalNodeMenuPlugin

Type Aliases​

MenuRenderFn<TOption> = (anchorElementRef, itemProps, matchingString) => ReactPortal | JSX.Element | null

Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:82

A render function for a menu's contents. It receives the anchor element ref, the current item props (selected index, options, and helpers to select or highlight an option), and the matching query string, and returns the menu element (or portal) to render, or null to render nothing. Provide one to fully customize a menu's appearance.

Type Parameters​

TOption​

TOption extends MenuOption

Parameters​

anchorElementRef​

RefObject<HTMLElement | null>

itemProps​
options​

TOption[]

selectedIndex​

number | null

selectOptionAndCleanUp​

(option) => void

setHighlightedIndex​

(index) => void

matchingString​

string

Returns​

ReactPortal | JSX.Element | null


MenuResolution = object

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

The position and match information for an open menu: a getRect function that returns the anchor rectangle the menu is positioned against, and the optional MenuTextMatch that opened it.

Properties​

getRect​

getRect: () => DOMRect

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

Returns​

DOMRect

match?​

optional match?: MenuTextMatch

Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:66


NodeMenuPluginProps​

NodeMenuPluginProps<TOption> = object

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:37

Props for the LexicalNodeMenuPlugin component.

Type Parameters​

TOption​

TOption extends MenuOption

Properties​

anchorClassName?​

optional anchorClassName?: string

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

commandPriority?​

optional commandPriority?: CommandListenerPriority

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

optional menuRenderFn?: MenuRenderFn<TOption>

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:46

nodeKey​

nodeKey: NodeKey | null

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:45

onClose?​

optional onClose?: () => void

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:47

Returns​

void

onOpen?​

optional onOpen?: (resolution) => void

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:48

Parameters​
resolution​

MenuResolution

Returns​

void

onSelectOption​

onSelectOption: (option, textNodeContainingQuery, closeMenu, matchingString) => void

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

Parameters​
option​

TOption

textNodeContainingQuery​

TextNode | null

closeMenu​

() => void

matchingString​

string

Returns​

void

options​

options: TOption[]

Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:44

parent?​

optional parent?: HTMLElement

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

Functions​

LexicalNodeMenuPlugin()​

LexicalNodeMenuPlugin<TOption>(__namedParameters): Element | null

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

Renders a floating menu anchored to a specific node (identified by nodeKey), for example to offer actions on a just-inserted node. It is the node-anchored counterpart to LexicalTypeaheadMenuPlugin: provide the options to show and an onSelectOption handler, and the menu opens while nodeKey refers to a node and closes when it becomes null.

Type Parameters​

TOption​

TOption extends MenuOption

Parameters​

__namedParameters​

NodeMenuPluginProps<TOption>

Returns​

Element | null

The floating menu element, or null when the menu is closed.

References​

Re-exports MenuOption