Repository navigation
Docs: Add Block List Readme #69432
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
Docs: Add Block List Readme #69432
Changes from 2 commits
0f3dbdf
2a163c8
d99df62
cd6afc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Block List | ||
|
|
||
| The `BlockList` component is responsible for rendering a list of blocks within the WordPress block editor. It manages the layout, interactions, and UI behaviors for blocks within the editor interface. | ||
|
|
||
| ## Usage | ||
|
|
||
| This component is used internally within the WordPress block editor and is not typically used directly by block developers. It renders blocks inside a parent container, applying necessary UI behaviors such as selection handling, focus management, and appender display. | ||
|
|
||
| ### Example | ||
|
|
||
| ```jsx | ||
| import BlockList from '@wordpress/block-editor/components/block-list'; | ||
|
|
||
| function MyEditorComponent( props ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example can be misleading because it doesn’t show the full picture of how this component can be used. Perhaps we could present it as just one example. What do you think? Picked from here |
||
| return ( | ||
| <BlockList rootClientId={ props.clientId } /> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Props | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we switch from the tabular format to per-prop subheadings with type/default bullets? This would help us achieve consistency! |
||
|
|
||
| | Prop | Type | Description | | ||
| |---------------------------|------------|-------------| | ||
| | `rootClientId` | `string?` | The client ID of the root block whose inner blocks will be rendered. If omitted, renders the top-level blocks. | | ||
| | `placeholder` | `ReactNode?` | Placeholder content displayed when no blocks are present. | | ||
| | `renderAppender` | `Function?` | Custom function to render an appender component (e.g., the "+" button for adding new blocks). Defaults to the standard block appender. | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ref usage in style-book
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also have a missing |
||
| | `__experimentalAppenderTagName` | `string?` | Tag name for the appender element. | | ||
| | `layout` | `Object?` | The layout configuration for blocks, affecting their positioning and arrangement. | | ||
|
|
||
| ## Features | ||
|
|
||
| - **Block Rendering:** Displays a list of blocks based on the provided `rootClientId`. | ||
| - **Selection & Focus Handling:** Manages block selection, focus state, and block visibility. | ||
| - **Zoom-Out Mode:** Provides UI behavior for zooming out from nested block structures. | ||
| - **Block Editing Mode Integration:** Supports different block editing modes, including content-only editing and disabled states. | ||
| - **Block Appender Support:** Displays an appender UI when appropriate, allowing users to insert new blocks. | ||
|
|
||
| ## Related Components | ||
|
|
||
| - [`BlockListBlock`](./block) - Renders individual blocks within the `BlockList`. | ||
| - [`BlockListAppender`](../block-list-appender) - Provides UI for adding new blocks. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Might be better to mention them as plain text for now, and link them up if/when those READMEs get added. |
||
| - [`useInnerBlocksProps`](../inner-blocks) - Hook for managing inner blocks and their props. | ||
|
|
||
| ## Notes | ||
|
|
||
| The `BlockList` component plays a crucial role in structuring the block editor. While it is used internally, developers working on extending or modifying the editor interface may need to interact with it for advanced customization. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notes isn't a heading used anywhere else in this package, and the content here mostly repeats the opening of Usage above. Could the one new bit be folded into the intro paragraph and the section dropped? Same thought for Features, most of the READMEs here use Development guidelines for that kind of prose. |
||
Uh oh!
There was an error while loading. Please reload this page.
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.
It’d be nice to replace this with the one below.