32 lines
862 B
Rust
Raw Normal View History

2021-08-16 15:02:57 +08:00
pub use delete::*;
pub use format::*;
pub use insert::*;
2021-12-07 19:59:08 +08:00
use lib_ot::{
core::Interval,
rich_text::{RichTextAttribute, RichTextDelta},
};
2021-08-11 08:40:58 +08:00
2021-08-16 15:02:57 +08:00
mod delete;
mod format;
mod insert;
2021-09-13 23:09:57 +08:00
pub type InsertExtension = Box<dyn InsertExt + Send + Sync>;
pub type FormatExtension = Box<dyn FormatExt + Send + Sync>;
pub type DeleteExtension = Box<dyn DeleteExt + Send + Sync>;
2021-08-15 00:05:18 +08:00
2021-08-11 08:40:58 +08:00
pub trait InsertExt {
2021-08-15 21:11:48 +08:00
fn ext_name(&self) -> &str;
2021-12-07 10:39:01 +08:00
fn apply(&self, delta: &RichTextDelta, replace_len: usize, text: &str, index: usize) -> Option<RichTextDelta>;
2021-08-11 08:40:58 +08:00
}
pub trait FormatExt {
2021-08-15 21:11:48 +08:00
fn ext_name(&self) -> &str;
2021-12-07 10:39:01 +08:00
fn apply(&self, delta: &RichTextDelta, interval: Interval, attribute: &RichTextAttribute) -> Option<RichTextDelta>;
2021-08-11 08:40:58 +08:00
}
pub trait DeleteExt {
2021-08-15 21:11:48 +08:00
fn ext_name(&self) -> &str;
2021-12-07 10:39:01 +08:00
fn apply(&self, delta: &RichTextDelta, interval: Interval) -> Option<RichTextDelta>;
2021-08-11 08:40:58 +08:00
}