0001 Architecture
The document is an immutable JSON tree owned by an original TypeScript engine. Every content change compiles to primitive, invertible operations applied to an isolated transaction draft, then is normalised and committed atomically. The DOM, generated HTML and framework state are projections.
Nodes are records
{ id, type, attrs, children }; text leaves are{ id, type: 'text', text, marks }.The tree index stores only
parentIdand child index per node. Typing changes no parent relationships, so it never copies the index; structural operations copy it once per transaction.Normalisation is incremental: it descends only into dirty nodes, created nodes and their ancestors. Repairs are
replaceNodeoperations on the smallest changed subtrees, with leaf redirects so positions survive merges.Commands are declared with runtime schemas; the editor's command catalogue type is inferred from the installed plugin tuple, so unknown commands and wrong inputs fail to compile.