-
Notifications
You must be signed in to change notification settings - Fork 4.8k
On Locking and TemplateLocking #29864
Copy link
Copy link
Closed
Labels
Needs Design FeedbackNeeds general design feedback.Needs general design feedback.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] Block LockingThe API allowing for the ability to lock/unlock blocksThe API allowing for the ability to lock/unlock blocks[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Feature] List ViewMenu item in the top toolbar to select blocks from a list of links.Menu item in the top toolbar to select blocks from a list of links.
Metadata
Metadata
Assignees
Labels
Needs Design FeedbackNeeds general design feedback.Needs general design feedback.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] Block LockingThe API allowing for the ability to lock/unlock blocksThe API allowing for the ability to lock/unlock blocks[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Feature] List ViewMenu item in the top toolbar to select blocks from a list of links.Menu item in the top toolbar to select blocks from a list of links.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Background
The block editor has had template locking support since very early on. Template locking allowed to designate the original content templates (the ones you could use on custom post types) to prevent insertion or moving blocks. Inner blocks also has supported a
templateLockattribute. This was extended in #26128 to be used directly in columns and group as attributes, not just as internal props of<InnerBlocks>.Limitations
While powerful on its own, template locking has not offered too much granular control nor has the UI adapted to communicate different locking states.
With block themes, the necessity for locking down elements of the page is more pronounced. For example, it might be desirable that by default the "post-content" block of a
singletemplate is locked so that it cannot be removed. This extends to many other blocks and template parts in all sorts of ways.Proposal
Let's establish a new block-level API representing
lockstatus. This is in addition totemplateLock. The lock attribute would allow control over what UI interactions are present.Lock status needs to allow a few state options. A locked block could imply any or all of these:
lockAttributeprop down the line.While
templateLockseparately governs the inner blocks state (blocks cannot be added, etc).This lock status can be toggled by the user. A user can choose to lock down a block so that they don't accidentally remove it, like on most design applications.
This could be represented in the UI as follows:
Note: block locking has nothing to do with capabilities for editing and it only governs interface controls.
If a block lock state is editable by the user, clicking on the "lock" icon should bring about a modal with the lock configuration. If only "remove" is locked, the movers and drag handle should remain and the lock indication should go somewhere else (in the ellipsis menu, for example.)
Lock status should be reflected in more places than just the Toolbar: