-
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
Block Patterns: Remove scope
from Query patterns and introduce blockTypes
#30471
Conversation
Size Change: +164 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
onFinish( [ [ 'core/query-loop', {}, blocks ] ] ); | ||
const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) ); | ||
// We need to override the attributes that can be set in the Placeholder. | ||
Object.assign( clonedBlocks[ 0 ].attributes.query, { |
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.
do you think we should ensure that there's only one block and that it's a "query"?
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.
I have addressed this here: 0c7683a.
I now search in top level blocks though for Query and properly handle the needed changes by deep cloning these attributes.
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 looks good to me.
Do we have an e2e test for this Query flow?
Not yet, but I'm waiting a bit with all these patterns work that is going on. It will soon change with a unified |
scope
from Query patterns and introduce blockTypes
scope
from Query patterns and introduce blockTypes
So if I create a block pattern for a header, do I now include the template part block, just like this includes the query block? |
I haven't checked the nuances about template part yet. I believe it will be handled/explored better on this PR: #29602, that is unblocked now. |
Description
After various explorations in integrating block patterns with blocks in different contexts (Placeholder, transforms) it seems that a better approach should be to remove the experimental
scope
, previously introduced here: #28891The new approach is that every pattern is shown in the
Inserter
and if a pattern wants to be used in the other contexts (Placeholder, transforms) should instead declare ablockTypes
property. This property will be anarray
containing theblock names
.In this PR I'm implementing this change and use it for
Query
patterns that exist in the plugin.Notes
allowed patterns
based on the providedrootClientId
.site-editor
lots ofappenders
are shown. This exists on trunk as well and can be handled maybe separately.InnerBlocks
forQueryLoop
ascontent
and now a pattern has theQuery
block itself. What this means is that theQuery
previews doesn't show just apost
. This is good because now a Query pattern could have attributes likelayout:flex
(for columns). In addition, we keep the value of posts per page (query.perPage
) from Query patterns, so as to preview the pattern as intended, without possible big previews. During insertion we unset theperPage
value to be set appropriately by Query block.post
.Testing Instructions
Query
block