Skip to main content

MenuState

Struct MenuState 

Source
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>

Source

pub fn callbacks(&self) -> &MenuCallbacks

The menu’s onOpen, onClose and change callback.

Source

pub fn resolution(&self) -> Option<MenuResolution>

The resolution while the menu is open, which the view anchors it at.

Source

pub fn options(&self) -> Vec<Rc<O>>

The options (JS’s options prop).

Source

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.

Source

pub fn command_priority(&self) -> i8

The command priority its keyboard commands are registered at (JS’s commandPriority, COMMAND_PRIORITY_LOW by default).

Source

pub fn set_draws_empty_menu(&self, draws_empty_menu: bool)

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).

Source

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.

Source

pub fn set_highlighted_index(&self, index: Option<usize>)

setHighlightedIndex(index).

Source

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.

Source

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.

Trait Implementations§

Source§

impl<O> Clone for MenuState<O>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<O> !RefUnwindSafe for MenuState<O>

§

impl<O> !Send for MenuState<O>

§

impl<O> !Sync for MenuState<O>

§

impl<O> !UnwindSafe for MenuState<O>

§

impl<O> Forget for MenuState<O>

§

impl<O> Freeze for MenuState<O>
where Rc<RefCell<MenuInner<O>>>: Freeze, Rc<dyn Fn(&Rc<O>, Option<NodeRef>, &dyn Fn(), &str) -> Result<(), LexicalError>>: Freeze,

§

impl<O> Move for MenuState<O>

§

impl<O> Unpin for MenuState<O>
where Rc<RefCell<MenuInner<O>>>: Unpin, Rc<dyn Fn(&Rc<O>, Option<NodeRef>, &dyn Fn(), &str) -> Result<(), LexicalError>>: Unpin,

§

impl<O> UnsafeUnpin for MenuState<O>
where Rc<RefCell<MenuInner<O>>>: UnsafeUnpin, Rc<dyn Fn(&Rc<O>, Option<NodeRef>, &dyn Fn(), &str) -> Result<(), LexicalError>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.