Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: private the root node
appflowyac23f81e24bb
diff --git a/shared-lib/lib-ot/src/core/document/document.rs b/shared-lib/lib-ot/src/core/document/document.rsindex a7e97021d2..4165ff446c 100644--- a/shared-lib/lib-ot/src/core/document/document.rs+++ b/shared-lib/lib-ot/src/core/document/document.rs@@ -3,11 +3,11 @@ use crate::core::{DocumentOperation, NodeAttributes, NodeData, NodeSubTree, OperationTransform, TextDelta, Transaction,};use crate::errors::{ErrorBuilder, OTError, OTErrorCode};-use indextree::{Arena, Children, FollowingSiblings, Node, NodeId};+use indextree::{Arena, Children, FollowingSiblings, NodeId};pub struct DocumentTree {arena: Arena<NodeData>,- pub root: NodeId,+ root: NodeId,}impl Default for DocumentTree {@@ -19,6 +19,7 @@ impl Default for DocumentTree {impl DocumentTree {pub fn new() -> DocumentTree {let mut arena = Arena::new();+let root = arena.new_node(NodeData::new("root"));DocumentTree { arena, root }}@@ -104,7 +105,7 @@ impl DocumentTree {////// let inserted_note = document.node_at_path(&inserted_path).unwrap();/// let inserted_data = document.get_node_data(inserted_note).unwrap();- /// assert_eq!(inserted_data.node_type, node.node_type);+ /// assert_eq!(inserted_data.node_type, node.note_type);/// ```pub fn child_from_node_with_index(&self, at_node: NodeId, index: usize) -> Option<NodeId> {let children = at_node.children(&self.arena);diff --git a/shared-lib/lib-ot/src/core/document/document_operation.rs b/shared-lib/lib-ot/src/core/document/document_operation.rsindex a1143a1883..6e34c8cb77 100644--- a/shared-lib/lib-ot/src/core/document/document_operation.rs+++ b/shared-lib/lib-ot/src/core/document/document_operation.rs@@ -169,7 +169,7 @@ mod tests {let insert = DocumentOperation::Insert {path: Path(vec![0, 1]),nodes: vec![NodeSubTree {- node_type: "text".into(),+ note_type: "text".into(),attributes: NodeAttributes::new(),delta: None,children: vec![NodeSubTree::new("text")],diff --git a/shared-lib/lib-ot/src/core/document/node.rs b/shared-lib/lib-ot/src/core/document/node.rsindex 3aef136c9c..ea62f3f192 100644--- a/shared-lib/lib-ot/src/core/document/node.rs+++ b/shared-lib/lib-ot/src/core/document/node.rs@@ -20,10 +20,13 @@ impl NodeData {#[derive(Clone, serde::Serialize, serde::Deserialize)]pub struct NodeSubTree {#[serde(rename = "type")]- pub node_type: String,+ pub note_type: String,+pub attributes: NodeAttributes,+#[serde(skip_serializing_if = "Option::is_none")]pub delta: Option<TextDelta>,+#[serde(skip_serializing_if = "Vec::is_empty")]pub children: Vec<NodeSubTree>,}@@ -31,7 +34,7 @@ pub struct NodeSubTree {impl NodeSubTree {pub fn new(node_type: &str) -> NodeSubTree {NodeSubTree {- node_type: node_type.into(),+ note_type: node_type.into(),attributes: NodeAttributes::new(),delta: None,children: Vec::new(),@@ -40,7 +43,7 @@ impl NodeSubTree {pub fn to_node_data(&self) -> NodeData {NodeData {- node_type: self.node_type.clone(),+ node_type: self.note_type.clone(),attributes: self.attributes.clone(),delta: self.delta.clone(),}diff --git a/shared-lib/lib-ot/src/core/document/transaction.rs b/shared-lib/lib-ot/src/core/document/transaction.rsindex 74e7d893bc..1a9314d6f7 100644--- a/shared-lib/lib-ot/src/core/document/transaction.rs+++ b/shared-lib/lib-ot/src/core/document/transaction.rs@@ -134,7 +134,7 @@ impl<'a> TransactionBuilder<'a> {});NodeSubTree {- node_type: node_data.node_type.clone(),+ note_type: node_data.node_type.clone(),attributes: node_data.attributes.clone(),delta: node_data.delta.clone(),children,diff --git a/shared-lib/lib-ot/tests/main.rs b/shared-lib/lib-ot/tests/main.rsindex 56c7706c69..250708bcdc 100644--- a/shared-lib/lib-ot/tests/main.rs+++ b/shared-lib/lib-ot/tests/main.rs@@ -1,4 +1,4 @@-use lib_ot::core::{DocumentOperation, DocumentTree, NodeAttributes, NodeSubTree, Path, TransactionBuilder};+use lib_ot::core::{DocumentTree, NodeAttributes, NodeSubTree, Path, TransactionBuilder};use lib_ot::errors::OTErrorCode;use std::collections::HashMap;@@ -70,7 +70,7 @@ fn test_inserts_subtrees() {tb.insert_node_at_path(0,NodeSubTree {- node_type: "text".into(),+ note_type: "text".into(),attributes: NodeAttributes::new(),delta: None,children: vec![NodeSubTree::new("image")],