New block: Figure block - #79404
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Note
Please treat this PR as a baseline and a foundation. This is not meant to be the hard final version of the block. This PR is completely open to any additions, subtractions, or architectural pivots. The features included so far, the specific SVG icons used, the 5 chosen layout variations, and the block transformations are intended to demonstrate the block's technical capabilities and potential. Everything here is open for iteration, feedback, and discussion!
What?
Closes #78961
This PR introduces the new core/figure block: a native, semantic container for self-contained content (images, code, tables, composite media) with an optional caption. It features an initial setup state & block transforms.
Why?
Currently, Gutenberg lacks a proper, semantic
<figure>wrapper for composite content. When authors want to pair a chart with a raw data table, or show "Before & After" images side-by-side with a single shared caption, they are forced to hack together core/columns or core/group blocks.This PR solves that by providing a dedicated core/figure block that guides users into building perfectly structured, WCAG-compliant media layouts.
How?
<figcaption>.MutationObserverto actively track the physical presence of the<figcaption>in the DOM, ensuring the position toggle is intelligently disabled when the caption is turned off.Testing Instructions
MutationObserversuccessfully detects the missing DOM node and disables the position toggle in the toolbar.<figcaption>node moves to match the visual order.core/quoteblock, insert a citation, transform to Figure block & verify the citation is hoisted into the Figure caption.Screenshots or screencast
Figure.block.mov
Use of AI Tools
Used AI for test suits & research.