DOC-108 实现 NoteAnchor 模型 #13

Closed
opened 2026-05-30 19:49:15 +08:00 by wangdl · 2 comments
Owner

定义 NoteAnchor:Material / MarkdownBlock / TextLine / PdfPage / Image / EpubChapter / KnowledgeItem

非目标:不做富文本编辑器、不做笔记保存接口。

验收标准:NoteAnchor 支持 serde、能从 ReadingPosition 生成 NoteAnchor、有单元测试

定义 NoteAnchor:Material / MarkdownBlock / TextLine / PdfPage / Image / EpubChapter / KnowledgeItem 非目标:不做富文本编辑器、不做笔记保存接口。 验收标准:NoteAnchor 支持 serde、能从 ReadingPosition 生成 NoteAnchor、有单元测试
wangdl added this to the M1:Document Core v0.1 milestone 2026-05-30 19:49:15 +08:00
wangdl added the
priority:p1
type:implementation
area:notes
labels 2026-05-30 19:49:15 +08:00
Author
Owner

完成项

NoteAnchor 模型已定义
from_position(material_id, position) 构造函数
7 种锚点类型

from_position 映射

ReadingPosition NoteAnchor
Markdown MarkdownBlock {material_id, block_id}
Text TextLine {material_id, line_number}
Pdf PdfPage {material_id, page_number}
Image Image {material_id}
Epub EpubChapter {material_id, chapter_id}
Unknown/None Material {material_id}

测试

  • 5 个单元测试(46 总计)
  • 覆盖 serde + from_position 所有分支 + Unknown 回退
## 完成项 ✅ NoteAnchor 模型已定义 ✅ from_position(material_id, position) 构造函数 ✅ 7 种锚点类型 ## from_position 映射 | ReadingPosition | NoteAnchor | |------|------| | Markdown | MarkdownBlock {material_id, block_id} | | Text | TextLine {material_id, line_number} | | Pdf | PdfPage {material_id, page_number} | | Image | Image {material_id} | | Epub | EpubChapter {material_id, chapter_id} | | Unknown/None | Material {material_id} | ## 测试 - 5 个单元测试(46 总计) - 覆盖 serde + from_position 所有分支 + Unknown 回退
Author
Owner

审查补充 (2026-06-02)

NoteAnchor::from_position 已通过 UDL 暴露到 FFI:

  • UDL 新增 create_note_anchor(string material_id, ReadingPosition? position) → NoteAnchor
  • 支持从 ReadingPosition 的 6 个变体自动映射到对应的 NoteAnchor 变体
  • Unknown 位置 fallback 到 Material 级别锚点

测试全部通过。

## 审查补充 (2026-06-02) `NoteAnchor::from_position` 已通过 UDL 暴露到 FFI: - UDL 新增 `create_note_anchor(string material_id, ReadingPosition? position) → NoteAnchor` - 支持从 ReadingPosition 的 6 个变体自动映射到对应的 NoteAnchor 变体 - Unknown 位置 fallback 到 Material 级别锚点 测试全部通过。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/zhixi-document-runtime#13
No description provided.