2022-03-05 13:15:10 +00:00
|
|
|
use crate::event_handler::*;
|
2022-03-10 09:14:10 +00:00
|
|
|
use crate::TextBlockManager;
|
2022-03-05 13:15:10 +00:00
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
|
|
|
use lib_dispatch::prelude::Module;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use strum_macros::Display;
|
|
|
|
|
2022-03-10 09:14:10 +00:00
|
|
|
pub fn create(block_manager: Arc<TextBlockManager>) -> Module {
|
2022-03-05 13:15:10 +00:00
|
|
|
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(block_manager);
|
|
|
|
|
|
|
|
module = module
|
2022-03-06 13:22:42 +00:00
|
|
|
.event(BlockEvent::GetBlockData, get_block_data_handler)
|
|
|
|
.event(BlockEvent::ApplyDelta, apply_delta_handler)
|
2022-03-05 13:15:10 +00:00
|
|
|
.event(BlockEvent::ExportDocument, export_handler);
|
|
|
|
|
|
|
|
module
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
|
|
#[event_err = "FlowyError"]
|
|
|
|
pub enum BlockEvent {
|
2022-03-06 13:22:42 +00:00
|
|
|
#[event(input = "BlockId", output = "BlockDelta")]
|
|
|
|
GetBlockData = 0,
|
|
|
|
|
2022-03-05 13:15:10 +00:00
|
|
|
#[event(input = "BlockDelta", output = "BlockDelta")]
|
2022-03-06 13:22:42 +00:00
|
|
|
ApplyDelta = 1,
|
2022-03-05 13:15:10 +00:00
|
|
|
|
|
|
|
#[event(input = "ExportPayload", output = "ExportData")]
|
2022-03-06 13:22:42 +00:00
|
|
|
ExportDocument = 2,
|
2022-03-05 13:15:10 +00:00
|
|
|
}
|