mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-14 12:36:12 +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>
40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
use std::{collections::HashMap, vec};
|
|
|
|
use collab_document::blocks::{Block, BlockAction, BlockActionPayload, BlockActionType};
|
|
use collab_document::document_data::PARAGRAPH_BLOCK_TYPE;
|
|
|
|
use crate::document::util;
|
|
use crate::document::util::gen_id;
|
|
|
|
#[tokio::test]
|
|
async fn document_apply_insert_block_with_empty_parent_id() {
|
|
let (_, document, page_id) = util::create_and_open_empty_document().await;
|
|
|
|
// create a text block with no parent
|
|
let text_block_id = gen_id();
|
|
let text_block = Block {
|
|
id: text_block_id.clone(),
|
|
ty: PARAGRAPH_BLOCK_TYPE.to_string(),
|
|
parent: "".to_string(),
|
|
children: gen_id(),
|
|
external_id: None,
|
|
external_type: None,
|
|
data: HashMap::new(),
|
|
};
|
|
let insert_text_action = BlockAction {
|
|
action: BlockActionType::Insert,
|
|
payload: BlockActionPayload {
|
|
block: Some(text_block),
|
|
parent_id: Some(page_id.clone()),
|
|
prev_id: None,
|
|
delta: None,
|
|
text_id: None,
|
|
},
|
|
};
|
|
document.lock().apply_action(vec![insert_text_action]);
|
|
|
|
// read the text block and it's parent id should be the page id
|
|
let block = document.lock().get_block(&text_block_id).unwrap();
|
|
assert_eq!(block.parent, page_id);
|
|
}
|