A small document
A paragraph with strong and emphasized text, a link and inline code.
First item
Second item
A document is an immutable tree. Nodes reference their children by ID, so an edit deep inside costs a few entries, not a copy of every ancestor.
Every node has a stable NodeId and a type from the schema. Element nodes list their children as IDs; text runs carry text and marks.
Edit the document and watch the tree: typing changes one text run, formatting splits runs, Enter adds a paragraph.
A paragraph with strong and emphasized text, a link and inline code.
First item
Second item
Document.build checks five stages in order: identity, references, cycles, reachability and schema. It stops at the first failing stage, so one dangling reference does not drown in follow-up errors.
Insert, Remove, Move, Replace, SpliceText, SplitText and MergeText. Each returns the new document, a ChangeSet and a PositionMapping together, so they can never drift apart. On failure the starting document is unchanged.
A PositionMapping carries a point across an edit and says whether it was preserved or displaced. An upload bookmark whose text vanished is displaced, never silently moved elsewhere.