AppFlowy/frontend/rust-lib/flowy-block/src/event_map.rs

31 lines
941 B
Rust
Raw Normal View History

use crate::event_handler::*;
2022-03-10 09:14:10 +00:00
use crate::TextBlockManager;
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 {
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)
.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,
#[event(input = "BlockDelta", output = "BlockDelta")]
2022-03-06 13:22:42 +00:00
ApplyDelta = 1,
#[event(input = "ExportPayload", output = "ExportData")]
2022-03-06 13:22:42 +00:00
ExportDocument = 2,
}