HN 用户提问:这种富文本数据模型有先例吗?

2作者: chrisecker5 个月前
我用 Python 为桌面文字处理软件构建了一个富文本数据模型,该模型基于持久化的平衡 n 叉树,并缓存了权重,以实现 O(log n) 的索引转换。文档模型仅使用四种元素类型:文本 (Text)、容器 (Container)、单体 (Single) 和组 (Group) — 其中 Group 纯粹是结构性的(用于平衡),在文档中没有任何语义含义。 各个元素是不可变的;插入和取出操作会返回新的树,而不是修改旧的树。这保证了只要旧树存在,旧索引就保持有效。 我了解 Ropes、Finger Trees 和 ProseMirror 的扁平索引模型。对于具有这些属性的富文本文档模型,我是否应该了解一些前人的工作成果?
查看原文
I've built a rich text data model for a desktop word processor in Python, based on a persistent balanced n-ary tree with cached weights for O(log n) index translation. The document model uses only four element types: Text, Container, Single, and Group — where Group is purely structural (for balancing) and has no semantic meaning in the document. Individual elements are immutable; insert and takeout return new trees rather than mutating the old one. This guarantees that old indices remain valid as long as the old tree exists. I'm aware of Ropes, Finger Trees, and ProseMirror's flat index model. Is there prior art I should know about — specifically for rich text document models with these properties?