Skip to main content
This feature is experimental and may change or be removed in future releases.
Views define named rendering modes for a rich text field. Editors can switch views in the Admin Panel without changing the saved editor state, and a view’s node map can also render that state through a JSX converter.

Views and JSX converters

JSX converters are the simplest choice when content only needs custom frontend rendering. Views are useful when you want an Admin Panel preview, multiple rendering modes for one field, or one node map shared by the editor and frontend. When both converters and nodeMap are passed to RichText, the node map wins for each overlapping node type. Block and inline-block maps are merged by slug, with the node map winning for an overlapping slug.

Define views

The following view map uses real node narrowing and declares every custom block represented by its node union:
Reference the named export from the rich text field. The path follows the same component path rules as other Admin Panel components.
When views are configured, the Admin Panel displays a selector beside the field label. Selecting another view changes rendering and editor configuration, not the underlying content.

View configuration

Each key of the view map is a view name. Add a default key to replace the editor’s default rendering; other keys add views editors can switch to. Each view accepts:

Admin settings

View-level admin settings use the same options as rich text admin customization, except that placeholder must be a plain string because the view map is loaded in the browser:

Feature filtering

filterFeatures receives the active client feature map. Return a new map to remove or add features for that view. Removing toolbar features is useful for a read-focused preview, as shown in the complete map above.

Lexical configuration

Pass a function to extend the default Lexical editor configuration:
Pass an object when the view should replace the configuration entirely:

Node overrides

A node override can use these rendering approaches: For a decorator node that defines both createDOM and html, the editor uses createDOM; JSX conversion uses html. The node map follows the organization described in Converting JSX: built-in node types are top-level keys, while custom block slugs belong under blocks and inlineBlocks.

Customize block chrome

For a configured block, Block replaces the block’s content while retaining its surrounding form behavior. Narrow props.isEditor before calling useBlockComponentContext; that hook is available only in the editor variant.
Assign it to nodes.blocks.banner.Block. Label replaces only the collapsible block label and is used only in the editor. The equivalent collection-level block customization is documented under Block custom components. ViewMapBlockComponentProps is a union narrowed by isEditor. Block and Label components for inline blocks receive the same props, except that the editor variant provides useInlineBlockComponentContext instead of useBlockComponentContext.
A top-level import is included in every bundle that imports the view map. An isEditor branch controls runtime behavior but does not remove an editor-only top-level import. Keep shared view files free of imports from @frogbotai/richtext-lexical/client and @frogbotai/ui/admin; use the context hooks supplied through narrowed component props instead.

Read the active view

Client components rendered within a rich text field can read the current view:

Reuse a view on the frontend

Pass a view’s node map to RichText to use the same rendering outside the editor. Type the content with the generated field type from frogbot-types.
PostBody is a Client Component because it reads properties of the client-exported postViews map. A Server Component can render <PostBody content={content} />, but cannot read postViews.preview.nodes itself. The frontend imports the entire module containing postViews. Keep that module safe for the frontend bundle and move editor-only components into separate component paths when they require client editor or Admin Panel dependencies.