#[RichText]

Attribute on parameters and properties.

use Saij\WpAppFramework\Value\RichText;

An inline field with HTML. Allowed on strings; the attribute gets role: content. The framework does not restrict the markup: templates print the value exactly as stored (|raw). WordPress filters it with wp_kses when a user without unfiltered_html saves the post.

With postContent: true the value is not stored in the block comment but as the block's inner HTML in the post content (inline HTML without wrapping element, source: html); the framework passes it to the attribute class like any other value. Allowed once per block, on a parameter of the block attribute class itself, in blocks without inner blocks and with the default ''.

Arguments

#[RichText(?array $allowedFormats = null, bool $inspector = false, bool $postContent = false, bool $excerpt = false)]
ParameterTypeDefaultDescription
allowedFormatslist<string>|nullnullFormats the editor offers, e.g. ["core/bold", "core/italic"]; null allows all registered formats, [] none.
inspectorboolfalseEdit the field in the block inspector instead of the canvas; the template then prints it without field(), and changing it re-renders the block.
postContentboolfalseStore the value as inline HTML in the post content instead of the block comment.
excerptboolfalseInclude the value in automatic excerpts; the block is then added to excerpt_allowed_blocks. Not allowed in blocks with inner blocks.