-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try: add content flag to blocks with no content attributes #68162
base: trunk
Are you sure you want to change the base?
Try: add content flag to blocks with no content attributes #68162
Conversation
packages/blocks/src/api/utils.js
Outdated
const attributes = getBlockType( name )?.attributes; | ||
const blockType = getBlockType( name ); | ||
|
||
if ( blockType?.[ blockMetadataDisplayKey ]?.role === 'content' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the special sauce.
There are probably other scenarios where this key needs to be checked as well.
Size Change: +209 B (+0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in 31cdc45. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12425564615
|
So this only is useful to show the block in the list view and have it selectable right? It won't help with actually editing? |
Determining what the block does as a content block/in write mode would still have to be figured out, mostly likely at the block level |
What?
This is an experiment only. Do not commit. It's for discussion and exploration only.
Testing a private block setting to flag to the block editor environment that the block should be treated, and display, as a content block for the purposes of write mode.
Why?
Properties of certain blocks such as the Query block should be editable in write mode. These blocks, however, don't always have attributes with content roles.
A content flag ensures these blocks will always be treated as containing "content" despite their attributes.
Kapture.2024-12-20.at.14.42.14.mp4
How?
Via the
blocks.registerBlockType
filter, adding a private Symbol to a block settings.The side-effect is that iterating over these settings during registration and in the reducer needs to ensure Symbols are not filtered out.
Testing Instructions
I've conducted very limited testing.
I created a template with two Query blocks: one at the root level, and another nested in a Group block.
When switching to Write mode, the Query blocks should selectable and feature in the list view.