AppFlowy/frontend/rust-lib/flowy-text-block/src/event_map.rs
2022-06-05 18:56:45 +08:00

31 lines
973 B
Rust

use crate::event_handler::*;
use crate::TextBlockManager;
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
use lib_dispatch::prelude::Module;
use std::sync::Arc;
use strum_macros::Display;
pub fn create(block_manager: Arc<TextBlockManager>) -> Module {
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(block_manager);
module = module
.event(TextBlockEvent::GetBlockData, get_block_data_handler)
.event(TextBlockEvent::ApplyDelta, apply_delta_handler)
.event(TextBlockEvent::ExportDocument, export_handler);
module
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "FlowyError"]
pub enum TextBlockEvent {
#[event(input = "TextBlockId", output = "TextBlockDelta")]
GetBlockData = 0,
#[event(input = "TextBlockDelta", output = "TextBlockDelta")]
ApplyDelta = 1,
#[event(input = "ExportPayload", output = "ExportData")]
ExportDocument = 2,
}