Fix tiptap selection sync and toolbar event loop

This commit is contained in:
lix-2026
2026-04-19 21:03:25 +08:00
parent 111a87d4fd
commit 394e2a155c
87 changed files with 17415 additions and 527 deletions
+119 -1
View File
@@ -352,6 +352,121 @@ pub struct KernelProjectionResult {
pub edges: Vec<KernelEdge>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DocumentReadNodeType {
Page,
Section,
ContentNode,
ReferenceAnchor,
Mindmap,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadNodeMeta {
pub title: Option<String>,
pub text_snippet: Option<String>,
pub block_type: Option<String>,
pub heading_level: Option<u32>,
pub numbering: Option<String>,
pub child_count: u32,
pub order: u32,
#[serde(default)]
pub path: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadNode {
pub id: String,
pub parent_node_id: Option<String>,
pub node_type: DocumentReadNodeType,
pub block_id: Option<String>,
pub anchor_block_id: Option<String>,
pub depth: u32,
pub metadata: DocumentReadNodeMeta,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadSubtree {
pub root_node_id: String,
pub nodes: Vec<DocumentReadNode>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadOutlineEntry {
pub id: String,
pub node_id: String,
pub anchor_block_id: Option<String>,
pub title: String,
pub level: u32,
pub numbering: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DocumentReadEvidenceKind {
Page,
Heading,
Paragraph,
List,
Todo,
Quote,
Code,
Media,
Reference,
Table,
Mindmap,
Text,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadEvidenceItem {
pub id: String,
pub node_id: String,
pub block_id: Option<String>,
pub kind: DocumentReadEvidenceKind,
pub snippet: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadStats {
pub block_count: u32,
pub heading_count: u32,
pub evidence_count: u32,
pub max_depth: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentReadPageSubtree {
pub projection_id: String,
pub projection: String,
pub root_node_id: String,
pub root_node: DocumentReadNode,
pub subtree: DocumentReadSubtree,
#[serde(default)]
pub outline: Vec<DocumentReadOutlineEntry>,
#[serde(default)]
pub evidence: Vec<DocumentReadEvidenceItem>,
pub stats: DocumentReadStats,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DocumentContentResult {
pub content: Value,
pub revision: u64,
pub conflict_detection_key: String,
pub title: Option<String>,
pub page_subtree: DocumentReadPageSubtree,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct KernelCreateNode {
@@ -508,7 +623,10 @@ mod tests {
assert_eq!(value["rowId"], json!("asset:page_1"));
assert_eq!(value["rowKind"], json!("asset"));
assert_eq!(value["projectionKind"], json!("file_tree"));
assert_eq!(value["capabilities"], json!(["expand", "open", "create-child"]));
assert_eq!(
value["capabilities"],
json!(["expand", "open", "create-child"])
);
assert_eq!(value["resourceMeta"]["resourceKind"], json!("document"));
assert_eq!(value["iconHint"], json!("page"));
}