feat: EditorRuntimeActor - 三层缓存/delta/事件架构
Phase A — EditorRuntimeActor 内存缓存层 - 新增 editor_actor.rs: EditorBlockDocument 内存态 + apply_command + load_or_init - block.rs 四个写工具(replace/insert/delete/move)接入 actor 路径 - editor_actor feature flag(MNOTE_WEB_ENABLE_EDITOR_ACTOR=true 默认开启) - bridge-runtime 三个核心函数公开化 - rust-toolchain: 1.89 → stable(修复 spike WASM 编译阻塞) Phase B — 编辑器增量 delta channel - BlockDelta/DeltaOperation 类型 + actor.build_block_delta() - leptos-tiptap spike: mnote:editor:block-delta CustomEvent 监听 + JSON patch - DocumentAiAgentPanel: 拦截 blockDelta → window dispatchEvent - 工具响应含 blockDelta 字段供前端消费 Phase C — 事件 stream delta - broadcast channel 在 AppState/actor/SSE 三层贯通 - tree_events SSE 端点发 block.delta 事件 - 旧客户端降级兼容 环境修复 - rustc recursion_limit = 1024(修复 Leptos SSR 类型深度溢出) - run-convex-deploy.js(封装 Convex function 部署到本地后端 3210) ref: design/07-ai/process/7-13-page-block-editor-runtime-actor-v1.md
This commit is contained in:
@@ -289,6 +289,13 @@ mod tests {
|
||||
content: serde_json::json!([]),
|
||||
revision: serde_json::json!(7),
|
||||
conflict_detection_key: serde_json::json!("page_1:7"),
|
||||
block_document: serde_json::json!({
|
||||
"documentId": "page_1",
|
||||
"rootBlockIds": [],
|
||||
"blocks": []
|
||||
}),
|
||||
block_projection_version: 1,
|
||||
projection_source: "fixture".into(),
|
||||
},
|
||||
tree: page_aggregate::PageTree {
|
||||
page_subtree: serde_json::json!({"rootNodeId": "page_1"}),
|
||||
|
||||
@@ -118,12 +118,28 @@ impl Default for PageOptions {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::PageOptions;
|
||||
use super::{PageBody, PageOptions};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn page_options_default_disables_heading_numbers() {
|
||||
assert!(!PageOptions::default().show_heading_numbers);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_body_accepts_legacy_payload_without_block_projection() {
|
||||
let body: PageBody = serde_json::from_value(json!({
|
||||
"content": [],
|
||||
"revision": 7,
|
||||
"conflictDetectionKey": "doc_1:7"
|
||||
}))
|
||||
.expect("legacy page body should deserialize");
|
||||
|
||||
assert_eq!(body.revision, json!(7));
|
||||
assert_eq!(body.block_projection_version, 0);
|
||||
assert_eq!(body.block_document, json!(null));
|
||||
assert_eq!(body.projection_source, "");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
@@ -132,6 +148,12 @@ pub struct PageBody {
|
||||
pub content: Value,
|
||||
pub revision: Value,
|
||||
pub conflict_detection_key: Value,
|
||||
#[serde(default)]
|
||||
pub block_document: Value,
|
||||
#[serde(default)]
|
||||
pub block_projection_version: u32,
|
||||
#[serde(default)]
|
||||
pub projection_source: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user