@lexical/react/LexicalTypeaheadMenuPlugin
Type Aliases
MenuStatusMessageFn
MenuStatusMessageFn = (
count,loading) =>string|null
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:325
Returns the line announced for the current menu, or null to stay silent.
Parameters
count
number
loading
boolean
Returns
string | null
MenuTextMatch
MenuTextMatch =
object
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:56
Describes where a typeahead trigger matched the text before the cursor: the
leadOffset where the match starts, the captured matchingString (the query
after the trigger), and the replaceableString (the full matched text,
including the trigger, that should be replaced when an option is selected).
Properties
leadOffset
leadOffset:
number
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:57
matchingString
matchingString:
string
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:58
replaceableString
replaceableString:
string
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:59
TriggerFn
TriggerFn = (
text,editor) =>MenuTextMatch|null
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:1043
Detects whether the text before the cursor should open a typeahead menu.
Given the current text and editor, it returns a MenuTextMatch
describing the match, or null if there is none. See
useBasicTypeaheadTriggerMatch for a common implementation.
Parameters
text
string
editor
Returns
MenuTextMatch | null
TypeaheadMenuPluginProps
TypeaheadMenuPluginProps<
TOption> =object
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:129
Props for the LexicalTypeaheadMenuPlugin component.
Type Parameters
TOption
TOption extends MenuOption
Properties
anchorClassName?
optionalanchorClassName?:string
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:142
commandPriority?
optionalcommandPriority?:CommandListenerPriority
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:143
getStatusMessage?
optionalgetStatusMessage?:MenuStatusMessageFn
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:163
Replaces the spoken status line, for translation or to change the
wording. Return null to stay silent.
ignoreEntityBoundary?
optionalignoreEntityBoundary?:boolean
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:146
loading?
optionalloading?:boolean
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:158
True while options for the current query are still being fetched.
An empty menu then says "Loading" instead of "No results".
Default
false
menuAriaLabel?
optionalmenuAriaLabel?:string
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:152
Accessible label for the menu container. Screen readers will announce this when the menu opens.
Default
'Typeahead menu'
menuRenderFn?
optionalmenuRenderFn?:MenuRenderFn<TOption>
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:139
onClose?
optionalonClose?: () =>void|PromiseLike<void>
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:141
Returns
void | PromiseLike<void>
onOpen?
optionalonOpen?: (resolution) =>void
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:140
Parameters
resolution
Returns
void
onQueryChange
onQueryChange: (
matchingString) =>void
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:130
Parameters
matchingString
string | null
Returns
void
onSelectOption
onSelectOption: (
option,textNodeContainingQuery,closeMenu,matchingString) =>void
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:131
Parameters
option
TOption
textNodeContainingQuery
TextNode | null
closeMenu
() => void
matchingString
string
Returns
void
options
options:
TOption[]
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:137
parent?
optionalparent?:HTMLElement
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:144
preselectFirstItem?
optionalpreselectFirstItem?:boolean
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:145
triggerFn
triggerFn:
TriggerFn
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:138
Functions
LexicalTypeaheadMenuPlugin()
LexicalTypeaheadMenuPlugin<
TOption>(__namedParameters):Element|null
Defined in: packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx:175
Renders a floating menu (such as an @-mention or slash-command picker) while
the text before the cursor matches triggerFn. As the user types, the
current query is reported via onQueryChange; supply the options to show
and an onSelectOption handler to apply the chosen option. Use
useBasicTypeaheadTriggerMatch to build a simple triggerFn.
Type Parameters
TOption
TOption extends MenuOption
Parameters
__namedParameters
TypeaheadMenuPluginProps<TOption>
Returns
Element | null
The floating menu element, or null when no query is active.
useDynamicPositioning()
useDynamicPositioning(
resolution,targetElement,onReposition,onVisibilityChange?):void
Defined in: packages/lexical-react/src/shared/LexicalMenu.tsx:199
Keeps an open menu aligned with its trigger by calling onReposition on
scroll, window resize, and target element resize while resolution is set.
Optionally calls onVisibilityChange when the trigger enters or leaves its
nearest scroll container's viewport.
Parameters
resolution
MenuResolution | null
targetElement
HTMLElement | null
onReposition
() => void
onVisibilityChange?
(isInView) => void
Returns
void
References
getScrollParent
Re-exports getScrollParent
MenuOption
Re-exports MenuOption
MenuRenderFn
Re-exports MenuRenderFn
MenuResolution
Re-exports MenuResolution
PUNCTUATION
Re-exports PUNCTUATION
SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND
Re-exports SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND
useBasicTypeaheadTriggerMatch
Re-exports useBasicTypeaheadTriggerMatch