-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks: Add supports lock flag #39568
Conversation
* @return {boolean} Whether a given block type can be locked/unlocked. | ||
*/ | ||
export function canLockBlockType( state, nameOrType ) { | ||
if ( ! hasBlockSupport( nameOrType, 'lock', true ) ) { |
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 went with a simple name for the flag, but happy to change it if necessary.
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.
One of the confusing aspects about this is that supporting lock
here might means two things:
- A block can be locked and unlocked (via attributes and UI).
- The UI to change locking is disabled.
I know that all blocks support locking, and this support flag is just for the UI, it feels a bit confusing but lockUI
doesn't look as clean.
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 agree; the support flag name doesn't really represent what the setting might do.
Maybe we should use __experimentalLock
while thinking about the permanent name.
@mtias What do you think?
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's okay to go with lock
as long as documentation explains what this flag does.
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.
Let's add it as experimental for a release or two but aim at formalizing it before 6.0 is released.
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.
Size Change: +1.25 kB (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
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'm assuming this PR is based on #39566? The doc is missing some key points, but the PR looks and tests good to me.
* @return {boolean} Whether a given block type can be locked/unlocked. | ||
*/ | ||
export function canLockBlockType( state, nameOrType ) { | ||
if ( ! hasBlockSupport( nameOrType, 'lock', true ) ) { |
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.
One of the confusing aspects about this is that supporting lock
here might means two things:
- A block can be locked and unlocked (via attributes and UI).
- The UI to change locking is disabled.
I know that all blocks support locking, and this support flag is just for the UI, it feels a bit confusing but lockUI
doesn't look as clean.
Do you mean missing documentation for this support flag? |
d935529
to
98abe7d
Compare
Yes, it was unclear to me what flag I should add until I digged into the code. |
Sorry about that. I included documentation now. |
@Mamaduka In a comment on the other issue, you suggested being able to base the lock on user capabilities. How would that be done using this approach? |
Hi, @carlomanf This will be a new block-level control. You can find general block lock settings PR here - #39566. |
Add documentation Make flag experimental Author: George Mamadashvili <[email protected]> Date: Mon Mar 28 18:01:27 2022 +0400
What?
Part of #29864.
Introduces new blocks
supports.__experimentalLock
flag.Why?
A new support flag will allow disabling locking UI on the block type level.
How?
PR adds a new
canLockBlockType
selector that checks block type supports flag and fallbacks to block editor settings.Todos
Testing Instructions
"__experimentalLock": false.