feat: "Figure" block for posts and events in Payload
Back to our planNumbering: epic #813; banner #814; lightbox #815; figure #816; Payload block #817; blue tone #818; content edit #819; guidelines #820. Where the text below says 01 to 07, read these numbers (01=#815, 02=#816, 03=#817, 04=#819, 05=#814, 06=#818, 07=#820).
Problem
In plain words: the floated figure from 02 is only a component. Editors still need a way to add one, with its label, short caption, long caption and numbered key, from the post or event editor in Admin, without code.
Proposed fix
Use, configure or split (docs/guidelines/components-and-content.md):
mediaBlock(src/platform/richtext/blockConfigs.ts) has one field,media. It is also a page-builder block (SITE_LAYOUT_BLOCKSinsrc/modules/site/cms/layoutBlocks.ts).- Adding alignment, size, label, two captions and a key list to it would give page-builder editors fields that mean nothing there. It would also switch
MediaBlockinto another mode (inline float with lightbox versus section image). Both are "split" signs. - [DECISION] a new rich-text block,
figure(interfaceFigureBlock).mediaBlockstays as it is.
Fields:
media(upload →media, required). Alt text comes from the media document, as today.align: selectright(default) |left|nonesize: select with the values 02 defines (default from 02's answer). Each option's admin label says the share in words.label: text, optional,maxLengthabout 24, for example "Figure 2-9". Admin description: "Shown as a small gray label. Leave empty if the figure has no number."caption: text, required, short (maxLengthabout 140), shown under the small figure.details: rich text (the same small editor asBanner.content), optional, shown only in the lightbox: credit, source and conditions.items: the numbered key. It reuses thediagramKeyitem shape and validation (label/textrow,validateLabel,minRows/maxRows, fromsrc/platform/richtext/editorial/diagramKeyBlockConfig.ts). Export the field definition once and use it in both blocks. Don't copy it. Give the array anadminkey (theisRowCollapsedgotcha indocs/project.md). Optional: a figure without markers has no key.
Wiring:
- Add
figureto the blocks posts offer (RICH_TEXT_BLOCKS) and the blocks events offer (EVENT_RICH_TEXT_BLOCKS). - Add a mapper
toFigureProps(plain props for 02'sFigure, decision 0013), next totoDiagramKeyProps(src/platform/richtext/editorial/diagramKey.ts), reusing its trailing-empty-row rule. - Add a renderer in
src/platform/richtext/richTextBlocks.tsx. - Check that the article's text column treats
figureas a reading-width block (src/platform/richtext/articleColumn.tsonly widens for card rows, so no change is expected). - Run
npx payload migrate:create(SQLite; review it for data safety), thennpm run generate:typesand commitsrc/payload-types.ts.
Existing Milwaukee Street map: today it is a mediaBlock followed by a diagramKey block in the post and in event 12. Moving it is a content edit (04), not a data migration, because only two documents use it. The schema migration only adds the new block's tables. Nothing existing is rewritten, so every stored post and event renders exactly as before.
Card and link preview (owner's standing rule): a picture on a post or page also appears on its card and link preview. The figure is body content and doesn't set the card image. The post or event's own image (heroImage, and meta.image for the link preview) does. The block's admin description says so. The acceptance criteria check that both pages already have a card and link-preview image, and the issue says which one.
Live content: this PR changes no live content. Any later edit in Admin first notes the document's current version on the issue (event 12: version 34, published 2026-10-31 22:11 Central), so it can be restored from the Versions tab.
Native-first check:
- (1) Payload's
BlocksFeatureis the native way to put a structured block in Lexical, so we use it, as every editorial block does. - (1) Payload's Lexical
UploadFeature(an inline upload node) has fields per upload, but no list of numbered key rows with our validation, and no front-end float or lightbox. It would need a custom converter anyway. - (2) No official plugin adds a figure block.
- Conclusion: a block config plus our existing pieces.
Acceptance criteria
- Not done: Tests come first: failing tests for the block config (fields, defaults, required, the key's
adminkey, the sharedvalidateLabel), fortoFigureProps(trailing empty rows dropped, middle rows kept), and for the renderer (rendersFigurewith the mapped props), then the code.payload.config.test.tsandrichTextBlocks.test.tsxupdated. - Not done: The key's field definition is defined once and used by both
diagramKeyandfigure(no jscpd clone). - Not done: An editor can add a Figure in a post and in an event in Admin, with alignment, size, label, short caption, long caption and key. Live Preview shows it.
- Not done: The migration adds only the new block's tables. It is reviewed for data safety, runs on a copy of the database, and existing posts and events render unchanged (checked on the I-94 post and event 12 locally with a copy of the data, if available).
- Not done:
src/payload-types.tsis regenerated and committed, anddocs/reference/content-types/is regenerated (Knowledge syncgreen). - Not done: An axe check passes on a seeded post with a figure, and the gallery's rich-text sample (
RichTextGallery.tsx) shows one. - Not done: Both pages (the I-94 post, event 12) have a card and link-preview image. Which image is recorded on the issue. If one is missing, a
[SCOPE]issue is filed (not widened here). - Not done: Checked at 320, 430, 768, 1024, 1280 and 1920 px in light and dark. Keyboard: Escape closes the lightbox, focus returns, and the key is readable in it.
- Not done: Documentation follows behavior:
docs/ui/data-types.mdgets afigurerow (block → component), the block list indocs/guidelines/payload-cms.mdnamesfigure(a fact, not a rule), and the events notesrc/modules/events/README.mdmentions the block if it lists event content blocks.
Files likely touched
src/platform/richtext/blockConfigs.ts- new
src/platform/richtext/editorial/figureBlockConfig.ts,figure.ts(mapper) and tests src/platform/richtext/editorial/diagramKeyBlockConfig.ts(export the shared key field)src/platform/richtext/richTextBlocks.tsx(+ test)src/migrations/(new migration +index.ts),src/payload-types.tssrc/app/(frontend)/dev/gallery/RichTextGallery.tsx,blocksPostSample.tsdocs/ui/data-types.md,docs/guidelines/payload-cms.md,docs/reference/content-types/(generated)
Must not touch
src/modules/site/cms/layoutBlocks.tsand the page-buildermediaBlock(stays as is)src/platform/ui/Figure.tsxinternals (02), except a prop fix found while wiring, called out in the PR- Live content in Admin (04)
Area
cms, frontend, migration
Priority
priority: medium
Generated by Claude Code, opens in a new tab