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 3 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,68 @@ | ||
| # Block Lock | ||
|
|
||
| The `Block Lock` module provides UI components and hooks for managing block locking in the WordPress editor. This includes locking block movement, editing, and removal. | ||
|
|
||
| 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. | ||
|
|
||
| ## Components | ||
|
|
||
| ### `BlockLockMenuItem` | ||
| A menu item component that allows users to lock or unlock a block via a modal. | ||
|
|
||
| #### Props | ||
| - `clientId` (string): The unique identifier of the block. | ||
|
|
||
| ### `BlockLockModal` | ||
| A modal component that provides detailed lock options for a block. | ||
|
|
||
| #### Props | ||
| - `clientId` (string): The unique identifier of the block. | ||
| - `onClose` (function): Callback function triggered when the modal is closed. | ||
|
|
||
| ### `BlockLockToolbar` | ||
| A toolbar button component that provides a lock/unlock button for a block. | ||
|
|
||
| #### Props | ||
| - `clientId` (string): The unique identifier of the block. | ||
|
|
||
| ## Hook | ||
|
|
||
| ### `useBlockLock` | ||
| A custom hook that returns lock status and permissions for a given block. | ||
|
|
||
| #### Parameters | ||
| - `clientId` (string): The unique identifier of the block. | ||
|
|
||
| #### Returns | ||
| An object containing: | ||
| - `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. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```jsx | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { BlockLockMenuItem, BlockLockToolbar } from '../block-lock'; | ||
|
|
||
| function MyBlockControls( { clientId } ) { | ||
| return ( | ||
| <> | ||
| <BlockLockToolbar clientId={ clientId } /> | ||
| <BlockLockMenuItem clientId={ clientId } /> | ||
| </> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Implementation Details | ||
| - The `BlockLockMenuItem` and `BlockLockToolbar` components toggle the `BlockLockModal`. | ||
| - The modal allows users to specify which lock features to apply. | ||
| - The `useBlockLock` hook determines the lock state and permissions based on the block's settings and editor state. | ||
|
|
||
| This module enhances block editing control by allowing users to enforce restrictions on movement, editing, and removal. | ||
|
|
||
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.
The
## Hooksection is a bit of a one-off, no other component README here has one, and the hooks that are documented (use-block-display-information,use-block-drop-zone) each live in their own folder with their own README.Since
useBlockLockships fromblock-lock/index.jsrather than its own folder, I don't think there's a clear precedent.Happy to leave it as-is.