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-06-05 10:56:45 +00:00
|
|
|
.event(TextBlockEvent::GetBlockData, get_block_data_handler)
|
|
|
|
.event(TextBlockEvent::ApplyDelta, apply_delta_handler)
|
|
|
|
.event(TextBlockEvent::ExportDocument, export_handler);
|
2022-03-05 13:15:10 +00:00
|
|
|
|
|
|
|
module
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
|
|
|
#[event_err = "FlowyError"]
|
2022-06-05 10:56:45 +00:00
|
|
|
pub enum TextBlockEvent {
|
2022-07-18 03:58:39 +00:00
|
|
|
#[event(input = "TextBlockIdPB", output = "TextBlockDeltaPB")]
|
2022-03-06 13:22:42 +00:00
|
|
|
GetBlockData = 0,
|
|
|
|
|
2022-07-18 03:58:39 +00:00
|
|
|
#[event(input = "TextBlockDeltaPB", output = "TextBlockDeltaPB")]
|
2022-03-06 13:22:42 +00:00
|
|
|
ApplyDelta = 1,
|
2022-03-05 13:15:10 +00:00
|
|
|
|
2022-07-18 03:58:39 +00:00
|
|
|
#[event(input = "ExportPayloadPB", output = "ExportDataPB")]
|
2022-03-06 13:22:42 +00:00
|
|
|
ExportDocument = 2,
|
2022-03-05 13:15:10 +00:00
|
|
|
}
|