mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* feat: support incremental to update textblock's delta * fix: update test code * fix: remove console * fix: update test * feat: integrate increamental delta in Flutter * fix: delete quill editor * fix: delete quill editor * feat: add csharp in codeblock (#3371) * chore: pt-PT & pt-BR translation updated (#3353) * chore: Ensure Cargo.lock Is Updated Alongside Changes to Cargo.toml (#3361) * ci: add cargo check workflow * ci: test cargo.toml * fix: update test * fix: code review * fix: update cargo.toml and cargo.lock * fix: code review * fix: rust format --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> Co-authored-by: Mayur Mahajan <47064215+MayurSMahajan@users.noreply.github.com> Co-authored-by: Carlos Silva <mtbf99@gmail.com>
80 lines
2.3 KiB
Rust
80 lines
2.3 KiB
Rust
use std::sync::Weak;
|
|
|
|
use strum_macros::Display;
|
|
|
|
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
|
use lib_dispatch::prelude::AFPlugin;
|
|
|
|
use crate::event_handler::get_snapshot_handler;
|
|
use crate::{event_handler::*, manager::DocumentManager};
|
|
|
|
pub fn init(document_manager: Weak<DocumentManager>) -> AFPlugin {
|
|
AFPlugin::new()
|
|
.name(env!("CARGO_PKG_NAME"))
|
|
.state(document_manager)
|
|
.event(DocumentEvent::CreateDocument, create_document_handler)
|
|
.event(DocumentEvent::OpenDocument, open_document_handler)
|
|
.event(DocumentEvent::CloseDocument, close_document_handler)
|
|
.event(DocumentEvent::ApplyAction, apply_action_handler)
|
|
.event(DocumentEvent::GetDocumentData, get_document_data_handler)
|
|
.event(
|
|
DocumentEvent::ConvertDataToDocument,
|
|
convert_data_to_document,
|
|
)
|
|
.event(DocumentEvent::Redo, redo_handler)
|
|
.event(DocumentEvent::Undo, undo_handler)
|
|
.event(DocumentEvent::CanUndoRedo, can_undo_redo_handler)
|
|
.event(DocumentEvent::GetDocumentSnapshots, get_snapshot_handler)
|
|
.event(DocumentEvent::CreateText, create_text_handler)
|
|
.event(DocumentEvent::ApplyTextDeltaEvent, apply_text_delta_handler)
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Display, ProtoBuf_Enum, Flowy_Event)]
|
|
#[event_err = "FlowyError"]
|
|
pub enum DocumentEvent {
|
|
#[event(input = "CreateDocumentPayloadPB")]
|
|
CreateDocument = 0,
|
|
|
|
#[event(input = "OpenDocumentPayloadPB", output = "DocumentDataPB")]
|
|
OpenDocument = 1,
|
|
|
|
#[event(input = "CloseDocumentPayloadPB")]
|
|
CloseDocument = 2,
|
|
|
|
#[event(input = "ApplyActionPayloadPB")]
|
|
ApplyAction = 3,
|
|
|
|
#[event(input = "OpenDocumentPayloadPB", output = "DocumentDataPB")]
|
|
GetDocumentData = 4,
|
|
|
|
#[event(input = "ConvertDataPayloadPB", output = "DocumentDataPB")]
|
|
ConvertDataToDocument = 5,
|
|
|
|
#[event(
|
|
input = "DocumentRedoUndoPayloadPB",
|
|
output = "DocumentRedoUndoResponsePB"
|
|
)]
|
|
Redo = 6,
|
|
|
|
#[event(
|
|
input = "DocumentRedoUndoPayloadPB",
|
|
output = "DocumentRedoUndoResponsePB"
|
|
)]
|
|
Undo = 7,
|
|
|
|
#[event(
|
|
input = "DocumentRedoUndoPayloadPB",
|
|
output = "DocumentRedoUndoResponsePB"
|
|
)]
|
|
CanUndoRedo = 8,
|
|
|
|
#[event(input = "OpenDocumentPayloadPB", output = "RepeatedDocumentSnapshotPB")]
|
|
GetDocumentSnapshots = 9,
|
|
|
|
#[event(input = "TextDeltaPayloadPB")]
|
|
CreateText = 10,
|
|
|
|
#[event(input = "TextDeltaPayloadPB")]
|
|
ApplyTextDeltaEvent = 11,
|
|
}
|