2021-08-16 15:02:57 +08:00
|
|
|
pub use delete::*;
|
|
|
|
pub use format::*;
|
|
|
|
pub use insert::*;
|
|
|
|
|
2021-08-14 16:44:39 +08:00
|
|
|
use crate::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-08-15 00:05:18 +08:00
|
|
|
pub type InsertExtension = Box<dyn InsertExt>;
|
|
|
|
pub type FormatExtension = Box<dyn FormatExt>;
|
|
|
|
pub type DeleteExtension = Box<dyn DeleteExt>;
|
|
|
|
|
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
|
|
|
}
|