mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Integrate appflowy editor (#1040)
This commit is contained in:
@ -25,11 +25,16 @@ pub struct ViewTest {
|
||||
|
||||
impl ViewTest {
|
||||
#[allow(dead_code)]
|
||||
pub async fn new(sdk: &FlowySDKTest, data_type: ViewDataTypePB, layout: ViewLayoutTypePB, data: Vec<u8>) -> Self {
|
||||
pub async fn new(
|
||||
sdk: &FlowySDKTest,
|
||||
data_format: ViewDataFormatPB,
|
||||
layout: ViewLayoutTypePB,
|
||||
data: Vec<u8>,
|
||||
) -> Self {
|
||||
let workspace = create_workspace(sdk, "Workspace", "").await;
|
||||
open_workspace(sdk, &workspace.id).await;
|
||||
let app = create_app(sdk, "App", "AppFlowy GitHub Project", &workspace.id).await;
|
||||
let view = create_view(sdk, &app.id, data_type, layout, data).await;
|
||||
let view = create_view(sdk, &app.id, data_format, layout, data).await;
|
||||
Self {
|
||||
sdk: sdk.clone(),
|
||||
workspace,
|
||||
@ -39,15 +44,19 @@ impl ViewTest {
|
||||
}
|
||||
|
||||
pub async fn new_grid_view(sdk: &FlowySDKTest, data: Vec<u8>) -> Self {
|
||||
Self::new(sdk, ViewDataTypePB::Database, ViewLayoutTypePB::Grid, data).await
|
||||
Self::new(sdk, ViewDataFormatPB::DatabaseFormat, ViewLayoutTypePB::Grid, data).await
|
||||
}
|
||||
|
||||
pub async fn new_board_view(sdk: &FlowySDKTest, data: Vec<u8>) -> Self {
|
||||
Self::new(sdk, ViewDataTypePB::Database, ViewLayoutTypePB::Board, data).await
|
||||
Self::new(sdk, ViewDataFormatPB::DatabaseFormat, ViewLayoutTypePB::Board, data).await
|
||||
}
|
||||
|
||||
pub async fn new_document_view(sdk: &FlowySDKTest) -> Self {
|
||||
Self::new(sdk, ViewDataTypePB::Text, ViewLayoutTypePB::Document, vec![]).await
|
||||
let view_data_format = match sdk.document_version() {
|
||||
DocumentVersionPB::V0 => ViewDataFormatPB::DeltaFormat,
|
||||
DocumentVersionPB::V1 => ViewDataFormatPB::TreeFormat,
|
||||
};
|
||||
Self::new(sdk, view_data_format, ViewLayoutTypePB::Document, vec![]).await
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +106,7 @@ async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &s
|
||||
async fn create_view(
|
||||
sdk: &FlowySDKTest,
|
||||
app_id: &str,
|
||||
data_type: ViewDataTypePB,
|
||||
data_format: ViewDataFormatPB,
|
||||
layout: ViewLayoutTypePB,
|
||||
data: Vec<u8>,
|
||||
) -> ViewPB {
|
||||
@ -106,7 +115,7 @@ async fn create_view(
|
||||
name: "View A".to_string(),
|
||||
desc: "".to_string(),
|
||||
thumbnail: Some("http://1.png".to_string()),
|
||||
data_type,
|
||||
data_format,
|
||||
layout,
|
||||
view_content_data: data,
|
||||
};
|
||||
|
@ -3,6 +3,7 @@ pub mod helper;
|
||||
|
||||
use crate::helper::*;
|
||||
|
||||
use flowy_document::entities::DocumentVersionPB;
|
||||
use flowy_net::get_client_server_configuration;
|
||||
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
||||
use flowy_user::entities::UserProfilePB;
|
||||
@ -28,14 +29,16 @@ impl std::ops::Deref for FlowySDKTest {
|
||||
|
||||
impl std::default::Default for FlowySDKTest {
|
||||
fn default() -> Self {
|
||||
Self::new(false)
|
||||
Self::new(DocumentVersionPB::V0)
|
||||
}
|
||||
}
|
||||
|
||||
impl FlowySDKTest {
|
||||
pub fn new(use_new_editor: bool) -> Self {
|
||||
pub fn new(document_version: DocumentVersionPB) -> Self {
|
||||
let server_config = get_client_server_configuration().unwrap();
|
||||
let config = FlowySDKConfig::new(&root_dir(), &nanoid!(6), server_config, use_new_editor).log_filter("info");
|
||||
let config = FlowySDKConfig::new(&root_dir(), &nanoid!(6), server_config)
|
||||
.with_document_version(document_version)
|
||||
.log_filter("info");
|
||||
let sdk = std::thread::spawn(|| FlowySDK::new(config)).join().unwrap();
|
||||
std::mem::forget(sdk.dispatcher());
|
||||
Self { inner: sdk }
|
||||
@ -51,4 +54,8 @@ impl FlowySDKTest {
|
||||
init_user_setting(self.inner.dispatcher()).await;
|
||||
context.user_profile
|
||||
}
|
||||
|
||||
pub fn document_version(&self) -> DocumentVersionPB {
|
||||
self.inner.config.document.version.clone()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user