feat: Chart block for posts and events, with a Markdown converter for agents
Back to our planRe-scoped 2026-11-03 (#645): the owner (Amine, 2026-11-03, Claude in Chrome side panel, text) asked for more charts, diagrams and infographics so a neighbor who knows nothing about taxes can follow the 2027 budget post, and told us to be inventive and think unconventionally. This issue now ships the MUST chart kinds
unitsandstacked(andbar), with the Markdown tag, and raises the post body cap inSUGGESTION_CAPSandsuggestion.schema.jsonfrom 3,000 to 12,000 characters (the budget post's Markdown is about 4 to 5 KB), with the JSON-versus-Zod contract test updated. Other kinds follow later. Depends on #639 and #663.
Problem
In plain words: editors and agents need to put a chart in a post or an event, by filling in a few rows of numbers in Admin, or by writing one tag in an agent's Markdown draft.
Summary of the owner's request (2026-11-02, Claude conversation, text): he wants graphs and diagrams that look good. The owner (Amine, 2026-11-03, Claude Code session, text) asked for the chart to be a common component across the app.
Today (checked 2026-11-03):
- Blocks. Editorial blocks are configured in
src/platform/richtext/editorial/*BlockConfig.ts, mapped byto…Props, and registered inEDITORIAL_BLOCKSandrichTextBlocks.tsx. - Markdown. Payload 3.91.0's block
jsxconverter writes array and object props asprop={[...]}(propsToJSXString, package source). Converters for the other blocks come with #593. - Depends on sub-issue 1 (
ChartandChartSpec).
Proposed fix
chartBlockConfig.ts:- title, summary (required: the takeaway in words), kind, a display or orientation shown by kind (
admin.condition), unit, as of - certainty (reused)
- sources (
linkFields) rows(label, series key, value, note; at most 60)links(from, to, value; only forflow, added in 3)
- title, summary (required: the takeaway in words), kind, a display or orientation shown by kind (
chart.ts:toChartSpec(stored)returns a validChartSpec, or the field error from the zod schema. A share that doesn't add to 100 ± 0.5 or a negative value is refused on save.- Register it in
EDITORIAL_BLOCKS(posts and events) and inrichTextBlocks.tsx(<Chart className="col-start-2" spec={toChartSpec(node.fields)} />). jsxconverter.<Chart kind="…" title="…" summary="…" unit="…" data={[…]} />(orx={[…]} series={[…]}). Import validates with the same schema, sosubmitSuggestionreturns the error to the agent. The tag goes inintelligence/prompts/draft.mdwith one example.- Watch out:
src/platform/richtext/is used by every post and event. Check that the existing blocks still render.
Native first, one line per step:
- Native: Payload
BlocksFeature, field validation,admin.conditionand the blockjsxconverter. - Official plugins: none.
- Open source: none beyond sub-issue 1.
- Our code: the block config, the mapper and the converter pair, with their tests.
Acceptance criteria
- Not done: An editor adds a Chart block to a post and to an event, and each kind from sub-issue 1 renders on the page.
- Not done: Saving an invalid chart (share ≠ 100, a negative value, an empty title or summary) shows a field error.
- Not done: Markdown → block → Markdown round-trips for each kind in a test.
payload.config.agentTools.test.tsrefuses a suggestion with a malformed<Chart>, with a clear error. - Not done: The existing editorial blocks' tests still pass. A post with every block renders at 320 and 1280, light and dark (screenshots in the PR).
Area
frontend, cms, visualization
Priority
high
Generated by Claude Code, opens in a new tab