4.8 KiB
4.8 KiB
[recycle] Rust Block Editor Model v0
更新时间:2026-04-18
关联文档:
/mnt/Data1T/mnote/design/old/05-editor-mainline/process/ai-first-rust-block-editor-baseline-v1.md/mnt/Data1T/mnote/design/old/05-editor-mainline/process/rust-block-editor-phase0-baseline-v1.md/mnt/Data1T/mnote/design/05-editor-mainline/reference-code/edita/edita-core/src/lib.rs/mnt/Data1T/mnote/design/05-editor-mainline/reference-code/blocks/src/document.rs/mnt/Data1T/mnote/rust/crates/core-protocol/src/editor/model.rs
1. 目的
本文冻结 task-053 的第一阶段 Rust block editor 模型口径。
目标不是一次定义最终全文档系统,而是先确定:
- 首批 Rust block type
BlockProps的最小字段面reference token的表示方式content_node的载荷格式- 哪些内容明确退出对 BlockNote JSON 的长期依赖
2. 第一阶段 block type
第一阶段固定以下块类型进入 canonical model:
paragraphheadingbullet_list_itemnumbered_list_itemquotetodocode_blockpage_referenceblock_reference
补充说明:
paragraph是默认文本块。heading是标题块,级别收敛到BlockProps.heading_level。bullet_list_item与numbered_list_item先保留为列表项,而不是先做复杂 list container。todo用来承接当前advancedTodo的第一阶段简化版。page_reference与block_reference先作为稳定引用块进入模型。
下面这些不进入第一阶段 canonical model,只保留 placeholder 或 compat:
mediaprogressMetermindmaponlineTable
3. BlockProps
第一阶段 BlockProps 固定为轻量可扩展对象。
核心字段:
indentheading_levelcheckedcollapsedlanguagereference_target_idreference_labelreference_token_strategyextra
固定口径:
indent表示有限缩进层级,不承诺长期树协议。heading_level只对heading生效。checked只对todo生效。collapsed只对heading生效,用于折叠标题。language只对code_block生效。reference_target_id与reference_label服务page_reference/block_reference。extra只用于迁移期兼容字段,不能成为长期语义事实源。
4. reference token 策略
第一阶段引用 token 固定区分两类:
page_referenceblock_reference
第一阶段 token strategy 固定支持三种:
double_bracketdouble_pareninline_chip
对应语义:
double_bracket对应[[page]]double_paren对应((block))inline_chip只用于 UI 渲染或迁移期兼容,不作为长期文本事实源
引用 token 最小字段:
kindstrategytarget_idlabelraw_token
5. content_node 载荷格式
第一阶段 content_node 是 block 内内容的最小结构单元。
固定 payload 类型:
texthard_breakreference_token
5.1 text
text 节点字段:
textmarks
marks 第一阶段只支持:
bolditalicunderlinestrikecode
5.2 hard_break
hard_break 用于显式换行,不引入复杂段内结构树。
5.3 reference_token
reference_token 节点直接挂稳定 token 对象,而不是把引用仅留在原始文本里。
6. 块对象与文档对象
第一阶段 canonical block 结构固定为:
block_idblock_typepropscontent_nodeschild_block_ids
第一阶段 canonical document 结构固定为:
document_idroot_block_idsblocks
设计原则:
blocks先按稳定数组序列输出,便于命令执行和导入导出。child_block_ids先表达父子关系,不强求复杂树索引结构。content_nodes替代对 BlockNote inline JSON 的长期依赖。
7. 与 BlockNote JSON 的边界
第一阶段固定口径:
- BlockNote JSON 只作为迁移期外部格式
- Rust editor model 才是长期事实层
BlockProps、content_node、reference token必须能独立表达核心语义
换句话说:
- 可以保留
BlockNote JSON -> Rust model适配器 - 不能继续把 BlockNote JSON 当作长期 canonical schema
8. 第一阶段不解决的事
下面这些明确不在 task-053 解决:
- 多人协作状态
- 复杂 mark 树
- 富媒体完整属性系统
mindmap/onlineTable的完整内嵌编辑语义- 完整批量选择与多块复制粘贴
9. 结论
task-053 的固定口径是:
- 用首批
paragraph、heading、bullet_list_item、todo、page_reference、block_reference等块型建立 Rust canonical model - 用
BlockProps收拢最小块属性 - 用
reference token固定[[page]]/((block))的稳定表示 - 用
content_node承接块内文本与引用 - 从这一阶段开始退出对 BlockNote JSON 的长期依赖