pub struct RichText { /* private fields */ }Expand description
Collaborative rich text with formatting support.
Combines RGAText for the text content with a set of anchor-based marks for formatting.
Implementations§
Source§impl RichText
impl RichText
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
Get the underlying text as a String.
Sourcepub fn add_mark(
&mut self,
start: usize,
end: usize,
mark_type: MarkType,
) -> MarkId
pub fn add_mark( &mut self, start: usize, end: usize, mark_type: MarkType, ) -> MarkId
Add a formatting mark to a range.
Sourcepub fn link(
&mut self,
start: usize,
end: usize,
url: impl Into<String>,
) -> MarkId
pub fn link( &mut self, start: usize, end: usize, url: impl Into<String>, ) -> MarkId
Add a link.
Sourcepub fn comment(
&mut self,
start: usize,
end: usize,
author: impl Into<String>,
content: impl Into<String>,
) -> MarkId
pub fn comment( &mut self, start: usize, end: usize, author: impl Into<String>, content: impl Into<String>, ) -> MarkId
Add a comment/annotation.
Sourcepub fn highlight(
&mut self,
start: usize,
end: usize,
color: impl Into<String>,
) -> MarkId
pub fn highlight( &mut self, start: usize, end: usize, color: impl Into<String>, ) -> MarkId
Add a highlight.
Sourcepub fn remove_mark(&mut self, id: &MarkId) -> bool
pub fn remove_mark(&mut self, id: &MarkId) -> bool
Remove a mark by ID.
Sourcepub fn remove_marks_in_range(
&mut self,
start: usize,
end: usize,
mark_type: &MarkType,
)
pub fn remove_marks_in_range( &mut self, start: usize, end: usize, mark_type: &MarkType, )
Remove all marks of a type from a range.
Sourcepub fn has_mark(&self, position: usize, mark_type: &MarkType) -> bool
pub fn has_mark(&self, position: usize, mark_type: &MarkType) -> bool
Check if a position has a specific mark type.
Sourcepub fn all_marks(&self) -> impl Iterator<Item = &Mark> + '_
pub fn all_marks(&self) -> impl Iterator<Item = &Mark> + '_
Get all marks (including deleted for debugging).
Sourcepub fn active_marks(&self) -> impl Iterator<Item = &Mark> + '_
pub fn active_marks(&self) -> impl Iterator<Item = &Mark> + '_
Get only active marks.
Sourcepub fn take_delta(&mut self) -> Option<RichTextDelta>
pub fn take_delta(&mut self) -> Option<RichTextDelta>
Take the pending delta.
Sourcepub fn apply_delta(&mut self, delta: &RichTextDelta)
pub fn apply_delta(&mut self, delta: &RichTextDelta)
Apply a delta from another replica.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RichText
impl<'de> Deserialize<'de> for RichText
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Lattice for RichText
impl Lattice for RichText
Source§fn join(&self, other: &Self) -> Self
fn join(&self, other: &Self) -> Self
Join operation (least upper bound)
Must be commutative, associative, and idempotent
Source§fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
fn partial_cmp_lattice(&self, other: &Self) -> Option<Ordering>
Partial order derived from join: a ≤ b iff a ⊔ b = b
Source§fn join_assign(&mut self, other: &Self)
fn join_assign(&mut self, other: &Self)
Join-assign: self = self ⊔ other
impl Eq for RichText
Auto Trait Implementations§
impl Freeze for RichText
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnwindSafe for RichText
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
Mutably borrows from an owned value. Read more