33 lines
727 B
Rust
Raw Normal View History

2021-08-11 11:42:46 +08:00
use crate::{
client::view::{InsertExt, PreserveInlineStyleExt},
2021-08-11 17:18:10 +08:00
core::Delta,
2021-08-11 11:42:46 +08:00
};
type InsertExtension = Box<dyn InsertExt>;
pub struct View {
insert_exts: Vec<InsertExtension>,
}
impl View {
pub(crate) fn new() -> Self {
let insert_exts = construct_insert_exts();
Self { insert_exts }
}
2021-08-11 17:18:10 +08:00
pub(crate) fn handle_insert(&self, delta: &Delta, s: &str, index: usize) -> Delta {
2021-08-11 11:42:46 +08:00
let mut new_delta = Delta::new();
self.insert_exts.iter().for_each(|ext| {
2021-08-11 17:18:10 +08:00
new_delta = ext.apply(delta, s, index);
2021-08-11 11:42:46 +08:00
});
new_delta
}
}
fn construct_insert_exts() -> Vec<InsertExtension> {
vec![
//
Box::new(PreserveInlineStyleExt::new()),
]
}