Rich text and blocks
How an entry's content is stored and printed, which blocks it may hold, and where a rich text field fits.
Every entry has content: one document of text and blocks. It is stored as a ProseMirror document, in a JSON column of its own, never as markup, so a block is typed data rather than HTML to parse. Like any JSON field, it is not filtered or sorted on.
What the text holds
Paragraphs, headings of six levels, bullet and numbered lists, quotes, code blocks, horizontal rules and line breaks, with links, emphasis, strong and inline code as marks. Printing the content draws all of it, and every block in it through the block's own view:
<div class="prose">{{ $entry->content }}</div>
Which blocks it may hold
A type names its blocks on its class. Without #[Blocks], its content is text alone:
#[Route('/{slug}')]
#[Blocks([Hero::class, Section::class, Cta::class])]
class Page extends Entry
{
#[Text(required: true, localized: true)]
public string $slug;
}
A type with no #[Route] has no page to build blocks on, so naming blocks on one is refused. A block can name blocks of its own, held inside it: see Writing a block.
Stored as data
A block in a document is a node with its id, its type and its fields, {type: 'block', attrs: {id, type, data}}, holding the blocks inside it as its content. Its fields are checked, cast and described by the same contract an entry's are, wherever in the document they sit. The id is given when the block is first written and kept, which is how a block that moved is told from one that was replaced.
Reading the blocks
$entry->content is a ?Document, null when the entry has no content, so $entry->content?->blocks() is the safe call. A Document's blocks() lists the blocks at its top level, in order, and block($id) finds one by its id. A view can look at what a page holds before it draws it, as a template asking whether the page opens on a hero.
Content in each language
Content is localized: each language has a document of its own, translated whole. A field inside a block is therefore neither localized nor internal on its own. A type that wants one content for every language redeclares $content with #[Content] and no localized.
Rich text fields
For a second body on an entry, an abstract beside the article, declare a field with #[RichText] on a ?Document property. It holds text alone, no blocks, and prints the same way. There is no empty document: a body left blank is null, so declare it nullable.