pub trait RootElement: Any {
// Provided methods
fn live_region_host(self: Rc<Self>) -> Option<Rc<dyn LiveRegionHost>> { ... }
fn blur(&self) { ... }
fn focus(&self) { ... }
fn has_focus(&self) -> bool { ... }
fn caret_from_point(&self, _x: f64, _y: f64) -> Option<PointCaret> { ... }
fn computed_style(&self, _key: &str) -> Option<ComputedStyle> { ... }
fn is_connected(&self) -> bool { ... }
}Expand description
The editor’s root element: what JS’s HTMLElement root is to an app
without a DOM, the view that shows the document. Setting one
(Editor::set_root_element) runs the reconciler’s model half, so
mutation listeners hear from the editor. Root elements compare by
identity, as JS’s elements do.
Provided Methods§
Sourcefn live_region_host(self: Rc<Self>) -> Option<Rc<dyn LiveRegionHost>>
fn live_region_host(self: Rc<Self>) -> Option<Rc<dyn LiveRegionHost>>
JS appends @lexical/a11y’s live region to owner, or to the root
element’s ownerDocument.body: this is where a root element puts it,
or None (the default) for a root without one, where announcements
are dropped.
Sourcefn blur(&self)
fn blur(&self)
Gives up the focus and clears the platform’s selection, as
Editor::blur (editor.blur()) does to a DOM root. Does nothing
by default.
Sourcefn focus(&self)
fn focus(&self)
Takes the focus, as rootElement.focus() does. Does nothing by
default. (Editor::focus doesn’t call it: JS’s moves the focus by
setting the DOM selection, which the app’s view does when it draws
the selection of an update tagged FOCUS_TAG.)
Sourcefn has_focus(&self) -> bool
fn has_focus(&self) -> bool
Whether the root (or a view in it) has the focus, as
rootElement.contains(document.activeElement) says of a DOM root.
false by default.
Sourcefn caret_from_point(&self, _x: f64, _y: f64) -> Option<PointCaret>
fn caret_from_point(&self, _x: f64, _y: f64) -> Option<PointCaret>
The caret at a point in the root’s coordinates, as
caretFromPoint(x, y, rootElement) from @lexical/clipboard
hit-tests the DOM, which drop and drag handlers ask for the
position of a MouseEvent (clientX, clientY). It is read
inside an update. None (the default) when no caret resolves
there.
Sourcefn computed_style(&self, _key: &str) -> Option<ComputedStyle>
fn computed_style(&self, _key: &str) -> Option<ComputedStyle>
The computed style of the element rendered for the node key, as
getComputedStyle(editor.getElementByKey(key)), which
@lexical/selection’s $getComputedStyleForElement reads for the
text direction and writing mode the arrow keys follow. It is read
inside an update. None (the default) for a node with no element,
as a JS editor that renders nothing has none.
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Whether the root is attached, as a DOM element’s isConnected says
(for a view: whether it is in a window). The commit announces a
range selection (or none) with SELECTION_CHANGE_COMMAND only while
the root is connected. true by default.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".