@lexical/react/LexicalNodeMenuPlugin
Classes
MenuOption
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:70
The base class for an item shown in a LexicalTypeaheadMenuPlugin or
LexicalNodeMenuPlugin menu. Each option has a unique key and a ref
to its rendered element (used for scrolling and keyboard navigation).
Subclass it to attach your own data such as a label or callback.
Extended by
Constructors
Constructor
new MenuOption(
key):MenuOption
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:76
Parameters
key
string
Returns
Properties
icon?
optionalicon?:Element
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:73
key
key:
string
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:71
ref?
optionalref?:RefObject<HTMLElement|null>
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:72
title?
optionaltitle?:string|Element
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:74
Methods
setRefElement()
setRefElement(
element):void
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:82
Parameters
element
HTMLElement | null
Returns
void
Type Aliases
MenuRenderFn
MenuRenderFn<
TOption> = (anchorElementRef,itemProps,matchingString) =>ReactPortal|JSX.Element|null
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:94
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
MenuResolution =
object
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:59
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:61
Returns
DOMRect
match?
optionalmatch?:MenuTextMatch
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:60
NodeMenuPluginProps
NodeMenuPluginProps<
TOption> =object
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:29
Props for the LexicalNodeMenuPlugin component.
Type Parameters
TOption
TOption extends MenuOption
Properties
anchorClassName?
optionalanchorClassName?:string
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:41
commandPriority?
optionalcommandPriority?:CommandListenerPriority
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:42
menuRenderFn?
optionalmenuRenderFn?:MenuRenderFn<TOption>
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:38
nodeKey
nodeKey:
NodeKey|null
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:37
onClose?
optionalonClose?: () =>void
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:39
Returns
void
onOpen?
optionalonOpen?: (resolution) =>void
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:40
Parameters
resolution
Returns
void
onSelectOption
onSelectOption: (
option,textNodeContainingQuery,closeMenu,matchingString) =>void
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:30
Parameters
option
TOption
textNodeContainingQuery
TextNode | null
closeMenu
() => void
matchingString
string
Returns
void
options
options:
TOption[]
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:36
parent?
optionalparent?:HTMLElement
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:43
Functions
LexicalNodeMenuPlugin()
LexicalNodeMenuPlugin<
TOption>(__namedParameters):Element|null
Defined in: packages/lexical-react/src/LexicalNodeMenuPlugin.tsx:55
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.