pub struct EditorState { /* private fields */ }Expand description
The complete editor state.
Implementations§
Source§impl EditorState
impl EditorState
Sourcepub fn new(doc: Node, schema: Schema) -> Self
pub fn new(doc: Node, schema: Schema) -> Self
A fresh state for doc, caret at the document start.
Sourcepub fn with_plugins(doc: Node, schema: Schema, plugins: PluginSet) -> Self
pub fn with_plugins(doc: Node, schema: Schema, plugins: PluginSet) -> Self
A fresh state pre-loaded with a PluginSet. Each plugin’s
Plugin::init is called with the (partially-initialised) state,
so plugins can derive their initial value from the doc.
Sourcepub fn with_history(self, history: History) -> Self
pub fn with_history(self, history: History) -> Self
Use a custom history depth.
Sourcepub fn plugin<P: Plugin>(&self, _key: PluginKey<P>) -> Option<&P::State>
pub fn plugin<P: Plugin>(&self, _key: PluginKey<P>) -> Option<&P::State>
Borrow this state’s plugin value (returns None if no plugin
of type P was registered when the state was built).
Sourcepub fn tr(&self) -> Transaction
pub fn tr(&self) -> Transaction
Begin a transaction from the current state.
Sourcepub fn apply(&self, tx: Transaction) -> EditorState
pub fn apply(&self, tx: Transaction) -> EditorState
Apply tx, returning the next state. Selection is mapped through the
transaction unless the transaction set one explicitly; a changing,
history-tracked transaction records an undo group. Transactions
carrying a HistoryIntent resolve to undo /
redo on this state (and never push another history
entry); if the stack is empty the current state is returned unchanged.
Sourcepub fn undo(&self) -> Option<EditorState>
pub fn undo(&self) -> Option<EditorState>
Undo the most recent group, or None if nothing to undo.
Sourcepub fn redo(&self) -> Option<EditorState>
pub fn redo(&self) -> Option<EditorState>
Redo the most recently undone group, or None.
Trait Implementations§
Source§impl Clone for EditorState
impl Clone for EditorState
Source§fn clone(&self) -> EditorState
fn clone(&self) -> EditorState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more