mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
feat(server): synthetic root doc (#14794)
This commit is contained in:
@@ -54,6 +54,12 @@ impl From<WorkspaceDocContent> for NativeWorkspaceDocContent {
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct PublicDocMetaInput {
|
||||
pub id: String,
|
||||
pub title: Option<String>,
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NativeBlockInfo {
|
||||
pub block_id: String,
|
||||
@@ -254,6 +260,19 @@ pub fn add_doc_to_root_doc(root_doc_bin: Buffer, doc_id: String, title: Option<S
|
||||
Ok(Buffer::from(result))
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn build_public_root_doc(root_doc_bin: Buffer, doc_metas: Vec<PublicDocMetaInput>) -> Result<Buffer> {
|
||||
let metas = doc_metas
|
||||
.iter()
|
||||
.map(|meta| (meta.id.as_str(), meta.title.as_deref()))
|
||||
.collect::<Vec<_>>();
|
||||
let result = map_napi_err(
|
||||
doc_parser::build_public_root_doc(&root_doc_bin, &metas),
|
||||
Status::GenericFailure,
|
||||
)?;
|
||||
Ok(Buffer::from(result))
|
||||
}
|
||||
|
||||
/// Updates a document title in the workspace root doc's meta.pages array.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
Reference in New Issue
Block a user