mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-11 07:57:33 +00:00
33 lines
748 B
Rust
33 lines
748 B
Rust
|
|
use crate::{
|
||
|
|
client::view::{InsertExt, PreserveInlineStyleExt},
|
||
|
|
core::{Delta, Interval},
|
||
|
|
};
|
||
|
|
|
||
|
|
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 }
|
||
|
|
}
|
||
|
|
|
||
|
|
pub(crate) fn handle_insert(&self, delta: &Delta, s: &str, interval: Interval) -> Delta {
|
||
|
|
let mut new_delta = Delta::new();
|
||
|
|
self.insert_exts.iter().for_each(|ext| {
|
||
|
|
new_delta = ext.apply(delta, s, interval);
|
||
|
|
});
|
||
|
|
new_delta
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn construct_insert_exts() -> Vec<InsertExtension> {
|
||
|
|
vec![
|
||
|
|
//
|
||
|
|
Box::new(PreserveInlineStyleExt::new()),
|
||
|
|
]
|
||
|
|
}
|