Repository navigation
Docs: Add Block Lock Readme #69434
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
Merged
im3dabasia
merged 5 commits into
WordPress:trunk
from
dhruvikpatel18:add/Block-lock-readme
Aug 12, 2026
Merged
Docs: Add Block Lock Readme #69434
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f93c471
Docs: Add Block Lock Readme.
dhruvikpatel18 3d8d1bb
Merge branch 'trunk' into add/Block-lock-readme
dhruvikpatel18 ad30605
Docs: Update Block Lock README with additional details and hook retur…
dhruvikpatel18 9fbdcbd
Revise Block Lock README for clarity and structure
dhruvikpatel18 338eda9
Docs: Clarify that edit locking is limited to allowlisted block types
dhruvikpatel18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Block Lock | ||
|
|
||
| The `BlockLock` components render the UI for locking a block's movement, editing and removal, and the `useBlockLock` hook exposes a block's current lock state. | ||
|
|
||
| These are private components of the `@wordpress/block-editor` package. They are not exported publicly and are meant to be consumed from within the package only. | ||
|
|
||
| ## Development guidelines | ||
|
|
||
| ### Usage | ||
|
|
||
| Renders a toolbar button that opens the block lock modal. | ||
|
|
||
| ```jsx | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { BlockLockToolbar } from '../block-lock'; | ||
|
|
||
| const MyBlockToolbar = ( { clientId } ) => ( | ||
| <BlockLockToolbar clientId={ clientId } /> | ||
| ); | ||
| ``` | ||
|
|
||
| ### Components | ||
|
|
||
| #### `BlockLockMenuItem` | ||
|
|
||
| A menu item that opens the block lock modal. Renders nothing when the block type does not allow locking. | ||
|
|
||
| #### `BlockLockModal` | ||
|
|
||
| A modal that lets the user choose which lock features to apply to the block. | ||
|
|
||
| #### `BlockLockToolbar` | ||
|
|
||
| A toolbar button that opens the block lock modal. Renders nothing until the block is locked. | ||
|
|
||
| ### Props | ||
|
|
||
| #### `clientId` | ||
|
|
||
| - **Type:** `String` | ||
| - **Required:** Yes | ||
|
|
||
| The client ID of the block. Accepted by all three components. | ||
|
|
||
| #### `onClose` | ||
|
|
||
| - **Type:** `Function` | ||
| - **Required:** Yes | ||
|
|
||
| A callback invoked when the modal is dismissed. Accepted by `BlockLockModal` only. | ||
|
|
||
| ### `useBlockLock` | ||
|
|
||
| A hook that returns the lock state of a block. It accepts the block's client ID and returns an object with the following properties. | ||
|
|
||
| - `isEditLocked` (`Boolean`): Whether editing the block is locked. | ||
| - `isMoveLocked` (`Boolean`): Whether moving the block is locked. | ||
| - `isRemoveLocked` (`Boolean`): Whether removing the block is locked. | ||
| - `canLock` (`Boolean`): Whether the block type allows locking. | ||
| - `isLocked` (`Boolean`): Whether any of the block's lock features are applied. | ||
|
|
||
| ## Related components | ||
|
|
||
| Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice and tight now. One small thing: the intro says the components cover movement, editing and removal, but editing is only offered for one allowlisted block type (modal.js#L20), everything else just gets move and remove.
Would half a sentence here save a reader hunting for a toggle that won't show up for them?