What is a Schema?
In ProseMirror (and Tiptap), a schema is a specification that defines:Node Types
What block and inline elements can exist in your document (paragraphs, headings, images, etc.)
Mark Types
What formatting can be applied to text (bold, italic, links, etc.)
Content Rules
What content each node can contain (e.g., a paragraph can contain inline content)
Attributes
What attributes nodes and marks can have (e.g., heading level, link href)
How Tiptap Creates a Schema
Unlike ProseMirror where you define the schema manually, Tiptap automatically generates the schema from your extensions./home/daytona/workspace/source/packages/core/src/Editor.ts:469
Schema Generation Process
- Extensions are collected - All extensions (nodes, marks, and generic extensions) are gathered
- Extensions are resolved - Dependencies and priorities are resolved
- Schema is built - Node specs and mark specs are extracted and combined
- ProseMirror schema is created - A ProseMirror
Schemaobject is instantiated
/home/daytona/workspace/source/packages/core/src/helpers/getSchema.ts:8
Accessing the Schema
You can access the schema through the editor:/home/daytona/workspace/source/packages/core/src/Editor.ts:65
Schema Structure
Node Specs
Each node in the schema has a specification that defines its behavior:Mark Specs
Each mark in the schema has a specification:Content Expressions
Content expressions define what content a node can contain. They use a specific syntax:Syntax
Examples
/home/daytona/workspace/source/packages/core/src/Node.ts:42
Groups
Groups let you reference multiple node types in content expressions:Common Groups
block- Block-level content (paragraphs, headings, etc.)inline- Inline content (text, hard breaks, inline images, etc.)list- List-related nodes (bullet lists, ordered lists, etc.)
/home/daytona/workspace/source/packages/core/src/Node.ts:83
Document Structure
Every Tiptap document has a rootdoc node that contains all other content:
Schema Validation
The schema enforces content rules. Invalid content is rejected:Custom Schema Example
Here’s how to create a custom document structure:Inspecting the Schema
View Node Types
View Mark Types
Check Content Validity
Using Schema Types in Commands
Advanced: Schema Introspection
Best Practices
Start with StarterKit
Use StarterKit as a foundation, then add or remove extensions as needed.
Be Explicit with Content
Clearly define what content each node can contain to prevent invalid structures.
Use Groups Wisely
Group similar nodes together to simplify content expressions.
Validate Content
Enable content validation in development to catch schema violations early.
Schema vs Extensions
Tiptap’s extension system is built on top of ProseMirror’s schema. You get the power of ProseMirror with a much simpler API.
Related
Nodes & Marks
Learn how to create nodes and marks
Extensions
Learn about the extension system
Editor
Learn about the Editor class
Commands
Learn how to manipulate content