-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: Add Block Editing Mode Readme.
- Loading branch information
1 parent
e757d1d
commit 20470e2
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
packages/block-editor/src/components/block-editing-mode/README.md
This file contains 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,51 @@ | ||
# Block Editing Mode | ||
|
||
The `block-editing-mode` component allows a block to restrict the user interface that is displayed for editing that block and its inner blocks. | ||
|
||
## Usage | ||
|
||
### Importing | ||
|
||
```js | ||
import { useBlockEditingMode } from '../block-editing-mode'; | ||
``` | ||
|
||
### Example | ||
|
||
```js | ||
function MyBlock( { attributes, setAttributes } ) { | ||
useBlockEditingMode( 'disabled' ); | ||
return <div { ...useBlockProps() }></div>; | ||
} | ||
``` | ||
|
||
### Modes | ||
|
||
The `mode` parameter can be set to one of the following values: | ||
|
||
- `'disabled'`: Prevents editing the block entirely, i.e., it cannot be selected. | ||
- `'contentOnly'`: Hides all non-content UI, such as auxiliary controls in the toolbar, block movers, and block settings. | ||
- `'default'`: Allows editing the block as normal. | ||
|
||
The mode is inherited by all of the block's inner blocks unless they have their own mode explicitly set. | ||
|
||
If called outside of a block context, the mode is applied to all blocks. | ||
|
||
## API | ||
|
||
### `useBlockEditingMode( mode )` | ||
|
||
#### Parameters | ||
|
||
- `mode` (optional) - The editing mode to apply. If `undefined`, the current editing mode remains unchanged. | ||
|
||
#### Returns | ||
|
||
- The current `BlockEditingMode` for the block. | ||
|
||
## Related | ||
|
||
- `blockEditorStore` | ||
- `useBlockEditContext` | ||
- `blockEditingModeKey` | ||
|