pub struct MenuState<O> { /* private fields */ }Expand description
An open or closed menu and its options: the state LexicalMenu,
LexicalTypeaheadMenuPlugin and LexicalNodeMenuPlugin keep in React.
The view that draws the menu is told of each change (on_change), and
calls select_option_and_clean_up
and set_highlighted_index for its input.
Cloning it shares the menu.
Implementations§
Source§impl<O: MenuOption + 'static> MenuState<O>
impl<O: MenuOption + 'static> MenuState<O>
Sourcepub fn callbacks(&self) -> &MenuCallbacks
pub fn callbacks(&self) -> &MenuCallbacks
The menu’s onOpen, onClose and change callback.
Sourcepub fn resolution(&self) -> Option<MenuResolution>
pub fn resolution(&self) -> Option<MenuResolution>
The resolution while the menu is open, which the view anchors it at.
Sourcepub fn selected_index(&self) -> Option<usize>
pub fn selected_index(&self) -> Option<usize>
The highlighted option’s index, clamped to the options
(Math.min(options.length - 1, selectedIndex)); None when no
option is highlighted.
Sourcepub fn command_priority(&self) -> i8
pub fn command_priority(&self) -> i8
The command priority its keyboard commands are registered at (JS’s
commandPriority, COMMAND_PRIORITY_LOW by default).
Whether the view draws the menu even with no options, as a JS
menuRenderFn is called whatever the options are and may show a
“no results” panel. While it is false (the default renderer), an
empty menu draws nothing and its keys pass through to the editor
(rendersNothing).
Sourcepub fn set_options(&self, options: Vec<Rc<O>>)
pub fn set_options(&self, options: Vec<Rc<O>>)
Replaces the options (JS renders the menu with new options); an
open menu that preselects its first item highlights it.
Sourcepub fn set_highlighted_index(&self, index: Option<usize>)
pub fn set_highlighted_index(&self, index: Option<usize>)
setHighlightedIndex(index).
Sourcepub fn close(&self)
pub fn close(&self)
closeTypeahead() / closeNodeMenu(): onClose, then the menu is
cleared, or with on_close_async
once what it is given is finished, unless the menu opened again.
Sourcepub fn select_option_and_clean_up(
&self,
option: &Rc<O>,
) -> Result<(), LexicalError>
pub fn select_option_and_clean_up( &self, option: &Rc<O>, ) -> Result<(), LexicalError>
selectOptionAndCleanUp(option): in an update, splits off the query
($splitNodeContainingQuery) for a typeahead menu, then runs
onSelectOption.