29 lines
768 B
Rust
Raw Normal View History

2021-08-16 15:02:57 +08:00
pub use delete::*;
pub use format::*;
pub use insert::*;
use flowy_ot::core::{Attribute, Delta, Interval};
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-08-11 23:34:35 +08:00
fn apply(&self, delta: &Delta, replace_len: usize, text: &str, index: usize) -> Option<Delta>;
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-08-11 23:34:35 +08:00
fn apply(&self, delta: &Delta, interval: Interval, attribute: &Attribute) -> Option<Delta>;
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-08-11 23:34:35 +08:00
fn apply(&self, delta: &Delta, interval: Interval) -> Option<Delta>;
2021-08-11 08:40:58 +08:00
}