Repository navigation
Block Supports: Add a Transform block support with a rotate feature - #86240
aaronrobertshaw wants to merge 15 commits into
Conversation
…nsform block support
🤖 PR meta 🤖📦 Bundle sizeSize Change: +1.28 kB (+0.01%) Total Size: 8.58 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Page List converts to Navigation Links with entity bindings in
|
Only the blocks from the original rotate PR opt in: Group, Heading, Image and Video. The :hover rotation tests now expect Button's root selector, and the e2e spec drops the Button hover test.
There was a problem hiding this comment.
🟡 Changes recommended
The new bundle can call an undefined hook when paired with an older wp.blockEditor, crashing the block screen or Blocks list.
3 open issues
What changed in this PR
Adds Transform block support with rotation as its first feature, integrating editor controls, Global Styles, and front-end rendering. Group, Heading, Image, and Video opt in.
Changes:
- Stores rotation in
style.transform.rotateand outputs the individual CSSrotateproperty through wrapper or feature selectors. - Adds Transform panels and shared responsive/state styling, while keeping enlarged lightbox images unrotated.
- Updates schemas, documentation, changelogs, and automated coverage.
| File | Description |
|---|---|
test/integration/theme-schema.test.js |
Tests permitted rotation style locations. |
test/e2e/specs/editor/various/block-transform-rotate.spec.js |
Covers image rotation, captions, and lightbox behavior. |
schemas/json/theme.json |
Defines transform settings and styles. |
schemas/json/block.json |
Defines transform support and selectors. |
phpunit/style-engine/style-engine-test.php |
Tests rotation declaration generation. |
phpunit/kses-rotate-test.php |
Tests allowed and rejected rotation values. |
phpunit/class-wp-theme-json-test.php |
Tests theme rotation rendering and sanitization. |
phpunit/block-supports/transform-test.php |
Tests wrapper and feature-selector output. |
phpunit/block-supports/states-test.php |
Tests responsive and hover rotation output. |
packages/style-engine/src/types.ts |
Adds rotation style typing. |
packages/style-engine/src/test/index.js |
Tests JavaScript rotation compilation. |
packages/style-engine/src/styles/transform/index.ts |
Validates angles and generates rotation rules. |
packages/style-engine/src/styles/index.ts |
Registers transform style definitions. |
packages/style-engine/src/class-wp-style-engine.php |
Adds PHP angle validation and declarations. |
packages/style-engine/CHANGELOG.md |
Records transform style support. |
packages/global-styles-ui/src/screen-block.tsx |
Adds the block-level Transform panel. |
packages/global-styles-ui/src/screen-block-list.tsx |
Recognizes transform-enabled blocks. |
packages/global-styles-ui/CHANGELOG.md |
Records Transform panel availability. |
packages/global-styles-engine/src/settings/get-setting.ts |
Recognizes the rotation setting. |
packages/global-styles-engine/CHANGELOG.md |
Records the new setting. |
packages/blocks/src/api/constants.ts |
Maps rotation to transform support. |
packages/blocks/CHANGELOG.md |
Records rotation property metadata. |
packages/block-library/src/video/README.md |
Documents Video rotation support and targeting. |
packages/block-library/src/video/block.json |
Enables rotation on the video element. |
packages/block-library/src/image/style.scss |
Resets rotation on enlarged lightbox images. |
packages/block-library/src/image/README.md |
Documents Image rotation support and targeting. |
packages/block-library/src/image/block.json |
Enables rotation on the image element. |
packages/block-library/src/heading/README.md |
Documents Heading rotation support. |
packages/block-library/src/heading/block.json |
Enables Heading rotation. |
packages/block-library/src/group/README.md |
Documents Group rotation support. |
packages/block-library/src/group/block.json |
Enables Group rotation. |
packages/block-editor/src/hooks/utils.tsx |
Includes rotation in resolved block settings. |
packages/block-editor/src/hooks/types.ts |
Defines transform hook types. |
packages/block-editor/src/hooks/transform.tsx |
Implements inspector integration and editor styling. |
packages/block-editor/src/hooks/test/transform.jsdom.test.ts |
Tests transform style routing. |
packages/block-editor/src/hooks/test/style.jsdom.test.tsx |
Tests hover and responsive rotation rules. |
packages/block-editor/src/hooks/supports.ts |
Recognizes transform as a style support. |
packages/block-editor/src/hooks/style.tsx |
Integrates controls and delegates transform serialization. |
packages/block-editor/src/hooks/index.ts |
Registers the transform editor hook. |
packages/block-editor/src/components/inspector-controls/groups.ts |
Adds the transform controls group. |
packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.ts |
Includes transform controls in tab detection. |
packages/block-editor/src/components/inspector-controls-tabs/styles-tab.tsx |
Adds the Transform panel slot. |
packages/block-editor/src/components/global-styles/types.ts |
Defines transform settings and panel types. |
packages/block-editor/src/components/global-styles/transform-panel.tsx |
Adds rotation controls and angle conversion. |
packages/block-editor/src/components/global-styles/test/transform-panel.jsdom.test.tsx |
Tests conversion, editing, and reset behavior. |
packages/block-editor/src/components/global-styles/index.ts |
Exports the Transform panel and availability hook. |
packages/block-editor/src/components/global-styles/hooks.ts |
Disables rotation controls where unsupported. |
packages/block-editor/src/components/block-inspector/index.tsx |
Adds default and state-specific Transform slots. |
packages/block-editor/CHANGELOG.md |
Records the panel and inspector group. |
lib/theme.json |
Enables rotation controls by default. |
lib/load.php |
Loads transform block support. |
lib/compat/wordpress-7.3/kses.php |
Allows and validates rotation declarations. |
lib/class-wp-theme-json-gutenberg.php |
Handles transform settings, sanitization, and CSS output. |
lib/block-supports/transform.php |
Registers attributes and renders block rotations. |
docs/reference-guides/theme-json-reference/theme-json-living.md |
Documents transform settings and styles. |
docs/reference-guides/theme-json-reference/styles-versions.md |
Records rotation version availability. |
docs/reference-guides/core-blocks/README.md |
Lists rotation support on opted-in blocks. |
docs/reference-guides/block-api/block-supports.md |
Documents the transform support contract. |
docs/how-to-guides/themes/global-settings-and-styles.md |
Adds rotation to the settings example. |
Review effort: Balanced
theme.json and Global Styles rotations rendered on the front end but not in the post or site editor canvas, because STYLE_KEYS left out transform. Also lists transform in the Global Styles change summary.
A fractional angle, such as 1rad shown as 57.3, failed the angle picker's step and was rewritten as soon as the field lost focus.
PHP's $ matched before a final newline, so "45deg\n" passed in PHP but not in JS.
Elements already forbid transform, but their :hover and other states referenced the complete style properties, which now include it. The PHP side strips it, so the schema now rejects it too.
The select and text input states still referenced the complete style properties, which include transform. Guard them the same way as the link and button states.
7aeccd0 to
a49cb25
Compare
|
Thanks for the early review @tellthemachines 🚀
Agreed. In part this helped test the block support with the selectors API and skipping serialization. Happy to allow it to go straight onto the wrapper.
I have a draft up for this too actually. We should be able to polish and merge these pretty soon I'd say. That is, assuming we are all good with leaving Z axis translation to a follow up. |
Yeah I'm not sure we have any use for translateZ so definitely not worth adding now. |



Related:
Core backport:
What?
Adds a Transform block support with rotation as its first feature. Group, Heading, Image and Video opt in.
Why?
Site owners and themes cannot rotate a block. A separate Transform support lets scale, skew or translate follow without schema or attribute changes.
How?
style.transform.rotateholds one CSS angle. Anything else outputs nothing.rotateproperty, nevertransform.transformfeature selector. Image and Video rotate theimgandvideo, so captions stay level.:hoverand viewport rotations use the shared block states path. No opted-in block has a:hoverstate yet.settings.transform.rotateturns it off.AnglePickerControl. It writesdegand shows other units in whole degrees.Note
AnglePickerControlonly accepts 0 to 360. A stored negative angle shows as entered, but becomes0degif the field is focused and left.Testing Instructions
"-0.025turn". Global Styles shows -9°, and the canvas matches the front end.Screenshots or screencast
Image with a caption, front end and lightbox
1-image-rotation.mp4
Rotation for Mobile only
2-heading-viewport.mp4
theme.json rotation in turns, in Global Styles
3-theme-json-turn.mp4
Use of AI Tools
Written with Claude Code, then reviewed and tested.