Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions packages/block-editor/src/components/block-lock/README.md
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.

Copy link
Copy Markdown
Contributor

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?


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.
Loading