Adds editorial Lexical blocks to a Payload collection and an API-only markdown field that reads and writes the whole body using ::: directives. Markdown is only returned when re-importing it reproduces the stored content exactly; otherwise writes are refused. Server components render post bodies from CSS tokens. Requires Payload 3 or 4, Lexical, React 19 and an upload collection with the slug media.
Editorial blocks for Payload CMS 3 and 4: write markdown with ::: directives, store rich Lexical blocks, read them back losslessly, and render post bodies styled by your own tokens.
Installation
npm i ox-payload-editorial0
Stars
0
Forks
2
Open Issues
2 days ago
Last Updated
0
Weekly Downloads
v
npm Version
Dependencies
Trends appear once the first and last snapshots are 7 days apart. Collecting since Nov 29 — 7 daily snapshots so far.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1481433083-root)<a href="https://payloaddirectory.dev/plugins/1481433083-root"><img src="https://payloaddirectory.dev/badge/1481433083-root.svg" alt="Payload Directory"></a>README
Editorial blocks for Payload CMS 3 and 4. Agents and authors write markdown with ::: directives;
the plugin turns it into rich Lexical blocks and back without losing content, and the components render them as
magazine-style post bodies styled by your own tokens.

An agent that writes into a CMS should not have to learn a block editor, and a block editor should not lose content
when an agent touches it. This package gives a Payload collection one markdown field that reads and writes the whole
body, a set of blocks with rules that keep the prose honest (a pull quote can only repeat a sentence of the article, a
stat must be findable in the body), and server components that draw it all from --ed-* CSS tokens, with no site
styling inside.
Status: pre-1.0, the API can still change in a minor release. Releases are published from this repository's CI to npm with provenance.
pnpm add ox-payload-editorial
Peers: payload and @payloadcms/richtext-lexical ^3.93.0 || ^4.0.0-beta.12, react and react-dom ^19.3. next is
optional. Node ^22.23.5 || ^24.22.3 || >=26.13.1 (Payload 4 itself needs ^24.22.3 || >=26.13.1), ESM only. The body's figures point at an upload collection with the slug media,
which must exist.
Payload 3 (stable) and Payload 4 (beta), both tested in CI: the whole suite, including the real-Payload round trip, runs
against 3.94.2 and 4.0.0-beta.12. Payload 4 is not the default: a site on 3 installs and behaves exactly as before.
Payload 4's converter escapes literal [x] and keeps spaces inside inline code, so a few bodies that Payload 3 refuses to
offer as markdown are offered on 4 (they round-trip there); the read-back comparison decides, not a list.
// payload.config.ts
import { editorialPlugin } from 'ox-payload-editorial/plugin'
export default buildConfig({
collections: [Posts, Media], // Media is an upload collection with the slug "media"
plugins: [editorialPlugin({ collections: { posts: { related: 'relatedPosts' } } })],
})
posts now has a content rich-text field with the editorial blocks, an API-only markdown companion and a
relatedPosts relationship. Render the body in a server component:
import { PostBody, postOutline } from 'ox-payload-editorial/body'
import 'ox-payload-editorial/styles.css'
const outline = postOutline(post.content.root, 'example.com')
<PostBody nodes={outline.nodes} sections={outline.sections} />
A complete config and page are in examples/, with the markdown behind the screenshots on this page. docs/rendering.md covers contents, sources, FAQ data, figures and related reads.
A directive is :::name, a body and a closing :::. Plain markdown is styled by its shape: the first paragraph
becomes the lead, ## Heading a section opener, a list of bold lead-ins a timeline, ## FAQ an FAQ with structured
data.
| Directive | Renders as |
|---|---|
:::finding | a raised panel for the answer or key takeaways |
:::note | a muted note between two rules: method, caveat |
:::aside | a side note in the margin beside the paragraph it follows |
:::steps | a numbered sequence of 2 to 5 named steps |
:::pull | a large pull quote, which must repeat a sentence of the article word for word |
:::stats | a strip of 1 to 4 key figures, each of which must appear in the body; first in the body it can be drawn as a hero band |
:::table | a captioned table |
:::bars | a table drawn as proportional bars |
:::compare | a table with large figures in two or three columns |
:::delta | before and after per row, as a dot plot with the full table under it |
Code fences, tables and  figures work too. Every rule, with the error each break returns,
is in SYNTAX.md, which ships in the package.


Markdown cannot say everything a Lexical document can: an internal link, underline, a block of your own. A converter that ignores this silently deletes content on the next save. This package does not rewrite anything markdown cannot carry exactly.
Before it returns markdown, it exports the stored body, imports that markdown again with the same code a write uses,
and compares the result with what is stored, value by value. If they are identical, you get the markdown. If anything
differs, markdown is null and a markdown write to that document is refused with an error telling you to edit
content instead. It fails closed: a field the comparison has never heard of counts as a difference. Only generated ids
and node version numbers are ignored.
The markdown field is filled for Payload MCP requests and is never stored. The mechanism, step by step, is in
docs/round-trip.md.
Import styles.css and map your own tokens once, on any element above the post:
.post {
--ed-ink: var(--site-ink);
--ed-canvas: var(--site-paper);
--ed-hairline: var(--site-rule);
--ed-display: var(--site-font-sans);
--ed-text: var(--site-font-serif);
--ed-measure: 34em;
}
The defaults are neutral ink on white with system fonts, at zero specificity, so any mapping wins. Every class is
ed- prefixed and nothing is scoped to a site class. The full token list is in docs/tokens.md.
docs/INDEX.md lists every document: the round-trip guard, tokens, rendering, the generated MCP
instructions, and the migration helper unpadLegacyTables for bodies imported by an older importer.
pnpm install
pnpm test -- test/postRules.spec.ts # scoped tests
make preflight # lint, typecheck, test, build, export check: what CI runs
See CONTRIBUTING.md. Licensed under Apache-2.0.
payload markdown
Markdown fields for Payload with a CodeMirror editor, Shiki code blocks, directives, themes and server-side rendering
64876/wk8v3
payload paste as markdown
Lexical editor feature for pasting raw Markdown through a toolbar button, slash command, or drawer
631.2k/wk0v3
payload shiki code
Server-rendered Shiki syntax-highlighted code block for Payload Lexical richtext fields
372.2k/wk3v3
payload plugin lexical
Lexical-based rich text editor field for Payload 1.x with tables, embeds, and a customizable feature set
35152/wk213v1
payload callouts
Callout block for the Lexical editor with GitHub and Obsidian themes and server-rendered output
238/wk1v3
richtext
Rich-text child block, default Lexical editor preset and JSX renderer for Atomic Payload
6433/wk37v3