-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Fundamentals of Block Development - The block wrapper #56596
Docs: Fundamentals of Block Development - The block wrapper #56596
Conversation
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
docs/getting-started/fundamentals-block-development/the-block-wrapper.md
Outdated
Show resolved
Hide resolved
…wrapper.md Co-authored-by: Ryan Welcher <[email protected]>
…wrapper.md Co-authored-by: Ryan Welcher <[email protected]>
…wrapper.md Co-authored-by: Ryan Welcher <[email protected]>
…wrapper.md Co-authored-by: Ryan Welcher <[email protected]>
…wrapper.md Co-authored-by: Ryan Welcher <[email protected]>
@@ -0,0 +1,113 @@ | |||
# The block wrapper | |||
|
|||
Each block's markup is wrapped by a container HTML tag that needs to have the proper attributes to fully work in the Block Editor and to reflect the proper block's style settings when rendered in the Block Editor and the front end. As developers, when creating a custom block, we need to manually add these attributes to the markup using some of the tools provided by WordPress. |
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.
I find this sentence here a little confusing. It sounds like the markup of the block is wrapped by some markup we cannot control.
Which was the case with the apiVersion: 1
but with apiVersion: 2 & 3
that no longer ist the case and we have the useBlockProps
hook to get the attributes that need to exist on the wrapper to manually add to our own markup. So a developer has full control over the markup of the block including the wrapper
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.
@fabiankaegy I have rephrased that part inspired by the info in your comment.
Let me know what you think
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.
LGTM!
@juanmaguitar I'd love for this kind of documentation to be part of the platform docs as well (minus the WordPress jargon). Not necessarily something to act upon now, but I envision that the "platform docs" become some kind of "reference docs" and that the block editor handbook would link to it and just "augment it" with WordPress specifics. |
* Add The Block Wrapper * Refactor block wrapper and add useBlockProps hook * Update block wrapper in the Block Editor * Update block markup and wrappers * Update block markup and wrapper attributes * Update block wrapper attributes and add documentation * Content added * Fix server-side render definition for block wrapper * Refactor block wrapper markup * Update docs/getting-started/fundamentals-block-development/the-block-wrapper.md Co-authored-by: Ryan Welcher <[email protected]> * Update docs/getting-started/fundamentals-block-development/the-block-wrapper.md Co-authored-by: Ryan Welcher <[email protected]> * Update docs/getting-started/fundamentals-block-development/the-block-wrapper.md Co-authored-by: Ryan Welcher <[email protected]> * Update docs/getting-started/fundamentals-block-development/the-block-wrapper.md Co-authored-by: Ryan Welcher <[email protected]> * Update docs/getting-started/fundamentals-block-development/the-block-wrapper.md Co-authored-by: Ryan Welcher <[email protected]> * Fix save function in block wrapper * Refactor block wrapper markup to add attributes * update folder name * Add block-wrapper.md to toc.json * Add link create-block * fixed link Metadata in block.json --------- Co-authored-by: Ryan Welcher <[email protected]>
Introduction to block wrapper
This PR is part of #56282