-
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
Patterns: disable editing of pattern entity in block editor #56534
Conversation
…f children if this is set
@SaxonF this implements the locking of the synced patterns in the editor. Some things we need to think about:
|
Size Change: +332 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
It is still possible to edit the children if accessed via the list view - I will get that fixed. |
Nice one @glendaviesnz !
Ideally we can follow the same pattern as template editing when switching from page which adds a back button to toolbar.
Yeah I'd consider this a separate optimisation. |
This is fixed now. |
|
||
- `'disabled'`: Prevents editing the block entirely, i.e. it cannot be | ||
selected. | ||
- `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the | ||
toolbar, the block movers, block settings. | ||
- `'default'`: Allows editing the block as normal. | ||
- `'syncedPattern'`: Restricts editing of synced pattern blocks to only child blocks that have attribute connections set. |
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.
Is it possible to avoid adding this new option?
I had hoped it would be possible to have the pattern block as disabled
and then the selected connected inner blocks as contentOnly
, with it all orchestrated by the pattern block.
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 think it'd be good to document where disabled
isn't working well, and then it makes it easier to consider what options there are.
As useBlockEditingMode
is a public API, there does need to be some careful consideration of the options added to it. Something like syncedPattern
might be useful internally as a convenient way to solve this problem, but I can't see how plugins would use it.
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.
Yeh, I did explore that, but it seemed like a slightly hacky modification of disabled
- but as you note that may be better for internal use rather than extending the external API. It is probably easier to put up a separate PR that uses useBlockEditingMode( 'disabled' )
than try and explain why it seemed slightly hacky. I will do that tomorrow. It is worth doing that I think to make it easier to decide which is the best approach.
I had hoped it would be possible to have the pattern block as disabled and then the selected connected inner blocks as contentOnly, with it all orchestrated by the pattern block.
That is basically what this approach will extend to once we have the attribute connections merged in - currently it is just setting all the children as disabled in order to limit the scope to disabling the inline editing of the synced patterns which can be merged as an independent feature to the partial syncing.
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 will also add some commits to each with the connected attributes included as it will be useful to see how the different approaches look with the connected innerBlocks actually wired up - should't take much extra work to do that.
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.
It is probably easier to put up a separate PR that uses useBlockEditingMode( 'disabled' ) than try and explain why it seemed slightly hacky. I will do that tomorrow. It is worth doing that I think to make it easier to decide which is the best approach.
Thanks, that would really help weigh up the trade-offs.
Closing this in favour of #56574 for now |
What?
Disables the editing of the synced pattern entity in the block editor and adds an
Edit
button to redirect to site editor pattern editor for full entity editing.Why?
As part of the work on allowing selective editing of synced patterns we want to disable full editing of the synced pattern entities within the block editor.
This will make it easier to indicate to users when they are editing just a section of the pattern for that instance of the pattern only, versus editing the global source pattern instance.
How?
Adds a new block editing mode of
syncedPattern
- this will make identifying blocks that are in the context of a synched pattern easier, and to apply custom editing controls accordingly. I played around with using the existing states but it made it less clear in the code what was happening, and would also require some additional checks to see if one of parents iscore/block
.While currently the child blocks are all disabled future work will allow
contentOnly
editing of some blocks if the blocks attributes are connected to the pattern parents attributes.Testing Instructions
Edit
button in the block toolbar redirects to site editor pattern edit canvas for blocked based theme and admin user, or post editor for entity for non-block themes or non-admin usersScreenshots or screencast
synced-pattern-edit.mp4