Custom Schemas
Chronicle’s editor is schema-driven. You can define custom document schemas to control what content types are available, how they nest, and what attributes they support.Default Schema
Out of the box, Chronicle provides a rich-text schema:Defining a Custom Schema
Schemas follow the ProseMirror schema specification:Using a Custom Schema
Pass your schema when initialising the editor:Schema Validation
Chronicle validates documents against their schema on load and on every operation:- Structural violations (e.g., a
titlenode appearing mid-document) are rejected - Invalid marks (e.g.,
strongon a node that doesn’t allow marks) are stripped - Missing required content triggers a validation error on save
Schema Migration
When evolving schemas, use the migration helpers:Schema compatibility with CRDTs
Schema compatibility with CRDTs
Custom schemas work seamlessly with Chronicle’s CRDT layer. The fork-node engine operates on structural operations (insert, delete, move) that are schema-agnostic. Schema validation happens at the editor level before operations are broadcast.This means:
- Two users with the same schema version always see consistent documents
- Schema version mismatches are caught on connection to the relay
- The relay rejects operations from clients with outdated schemas
Best Practices
- Start with the default schema and extend it rather than writing from scratch
- Keep schemas narrow — only allow the content types your application actually needs
- Version your schemas — include a
versionfield in your schema metadata - Test migrations before deploying schema changes to production
- Document node types — maintain a schema reference for your team