pub struct Document { /* private fields */ }rich-text-editor only.Expand description
A rich text document. It always has at least one block.
Implementations§
Source§impl Document
impl Document
pub fn from_blocks(blocks: impl IntoIterator<Item = Block>) -> Self
pub fn blocks(&self) -> &[Block]
pub fn block(&self, index: usize) -> Option<&Block>
Sourcepub fn has_formatting(&self) -> bool
pub fn has_formatting(&self) -> bool
Whether anything is styled, listed or quoted, so that sending the document as plain text would lose something.
pub fn start(&self) -> Position
pub fn end(&self) -> Position
Sourcepub fn number(&self, block: usize) -> Option<usize>
pub fn number(&self, block: usize) -> Option<usize>
The number shown before a numbered item, counting the numbered items directly above it.
Sourcepub fn style_for_insert(&self, at: Position) -> Style
pub fn style_for_insert(&self, at: Position) -> Style
The style text typed at at takes: that of the character before,
without a link unless the text on both sides has the same link.
Sourcepub fn slice(&self, start: Position, end: Position) -> Document
pub fn slice(&self, start: Position, end: Position) -> Document
A copy of the document between start and end.
Sourcepub fn delete(&mut self, start: Position, end: Position) -> Position
pub fn delete(&mut self, start: Position, end: Position) -> Position
Deletes the text between start and end, joining the blocks at
either end. Returns where the text was.
Sourcepub fn insert_text(
&mut self,
at: Position,
text: &str,
style: &Style,
) -> Position
pub fn insert_text( &mut self, at: Position, text: &str, style: &Style, ) -> Position
Inserts text in style at at, starting a new block at each line
break. Returns the end of the inserted text.
Sourcepub fn insert(&mut self, at: Position, fragment: &Document) -> Position
pub fn insert(&mut self, at: Position, fragment: &Document) -> Position
Inserts a fragment at at and returns its end. The first block of
the fragment joins the block at at, and the text after at joins
the last. Pasted paragraphs take the kind of the block they land in.
Sourcepub fn split(&mut self, at: Position) -> Position
pub fn split(&mut self, at: Position) -> Position
Splits the block at at. The new block keeps the kind, so a list
goes on. Returns the start of the new block.
Sourcepub fn restyle(
&mut self,
start: Position,
end: Position,
change: impl Fn(&mut Style),
)
pub fn restyle( &mut self, start: Position, end: Position, change: impl Fn(&mut Style), )
Changes the style of the text between start and end. An empty
block in the range keeps the style for what is typed into it.
Sourcepub fn set_kind(&mut self, first: usize, last: usize, kind: BlockKind)
pub fn set_kind(&mut self, first: usize, last: usize, kind: BlockKind)
Sets the kind of every block from first to last.
Sourcepub fn all_have(
&self,
start: Position,
end: Position,
test: impl Fn(&Style) -> bool,
) -> bool
pub fn all_have( &self, start: Position, end: Position, test: impl Fn(&Style) -> bool, ) -> bool
Whether every character between start and end has mark. An
empty range reads the style typed there.
Sourcepub fn size_between(&self, start: Position, end: Position) -> Option<Size>
pub fn size_between(&self, start: Position, end: Position) -> Option<Size>
The size used throughout the range, or None when it is mixed.
Sourcepub fn link_at(&self, at: Position) -> Option<(Position, Position, Arc<str>)>
pub fn link_at(&self, at: Position) -> Option<(Position, Position, Arc<str>)>
The link at at, and the range it covers.
Sourcepub fn previous(&self, at: Position) -> Position
pub fn previous(&self, at: Position) -> Position
One grapheme before at, moving to the end of the previous block
at the start of a block.
Sourcepub fn next(&self, at: Position) -> Position
pub fn next(&self, at: Position) -> Position
One grapheme after at, moving to the start of the next block at
the end of a block.
Sourcepub fn word_left(&self, at: Position) -> Position
pub fn word_left(&self, at: Position) -> Position
The start of the word before at, skipping spaces.
Sourcepub fn word_right(&self, at: Position) -> Position
pub fn word_right(&self, at: Position) -> Position
The end of the word after at, skipping spaces.
Trait Implementations§
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Forget for Document
impl Freeze for Document
impl Move for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.