mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: implement document editor trait (#1321)
This commit is contained in:
@ -14,7 +14,7 @@ async fn text_block_sync_current_rev_id_check() {
|
||||
AssertNextSyncRevId(None),
|
||||
AssertJson(r#"[{"insert":"123\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -28,7 +28,7 @@ async fn text_block_sync_state_check() {
|
||||
AssertRevisionState(3, RevisionState::Ack),
|
||||
AssertJson(r#"[{"insert":"123\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -40,7 +40,7 @@ async fn text_block_sync_insert_test() {
|
||||
AssertJson(r#"[{"insert":"123\n"}]"#),
|
||||
AssertNextSyncRevId(None),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -52,7 +52,7 @@ async fn text_block_sync_insert_in_chinese() {
|
||||
InsertText("好", offset),
|
||||
AssertJson(r#"[{"insert":"你好\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -64,7 +64,7 @@ async fn text_block_sync_insert_with_emoji() {
|
||||
InsertText("☺️", offset),
|
||||
AssertJson(r#"[{"insert":"😁☺️\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -76,7 +76,7 @@ async fn text_block_sync_delete_in_english() {
|
||||
Delete(Interval::new(0, 2)),
|
||||
AssertJson(r#"[{"insert":"3\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -89,7 +89,7 @@ async fn text_block_sync_delete_in_chinese() {
|
||||
Delete(Interval::new(0, offset)),
|
||||
AssertJson(r#"[{"insert":"好\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -101,5 +101,5 @@ async fn text_block_sync_replace_test() {
|
||||
Replace(Interval::new(0, 3), "abc"),
|
||||
AssertJson(r#"[{"insert":"abc\n"}]"#),
|
||||
];
|
||||
OldDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
DeltaDocumentEditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use flowy_document::old_editor::editor::OldDocumentEditor;
|
||||
use flowy_document::old_editor::editor::DeltaDocumentEditor;
|
||||
use flowy_document::TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS;
|
||||
use flowy_revision::disk::RevisionState;
|
||||
use flowy_test::{helper::ViewTest, FlowySDKTest};
|
||||
@ -17,18 +17,18 @@ pub enum EditorScript {
|
||||
AssertJson(&'static str),
|
||||
}
|
||||
|
||||
pub struct OldDocumentEditorTest {
|
||||
pub struct DeltaDocumentEditorTest {
|
||||
pub sdk: FlowySDKTest,
|
||||
pub editor: Arc<OldDocumentEditor>,
|
||||
pub editor: Arc<DeltaDocumentEditor>,
|
||||
}
|
||||
|
||||
impl OldDocumentEditorTest {
|
||||
impl DeltaDocumentEditorTest {
|
||||
pub async fn new() -> Self {
|
||||
let sdk = FlowySDKTest::default();
|
||||
let _ = sdk.init_user().await;
|
||||
let test = ViewTest::new_document_view(&sdk).await;
|
||||
let document_editor = sdk.document_manager.open_document_editor(&test.view.id).await.unwrap();
|
||||
let editor = match document_editor.as_any().downcast_ref::<Arc<OldDocumentEditor>>() {
|
||||
let editor = match document_editor.as_any().downcast_ref::<Arc<DeltaDocumentEditor>>() {
|
||||
None => panic!(),
|
||||
Some(editor) => editor.clone(),
|
||||
};
|
||||
|
Reference in New Issue
Block a user