Skip to content
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

Merged
merged 22 commits into from
Nov 29, 2023

Conversation

juanmaguitar
Copy link
Contributor

Introduction to block wrapper
This PR is part of #56282

@juanmaguitar juanmaguitar added Developer Experience Ideas about improving block and theme developer experience [Type] Developer Documentation Documentation for developers labels Nov 28, 2023
@@ -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.
Copy link
Member

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

Copy link
Contributor Author

@juanmaguitar juanmaguitar Nov 28, 2023

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

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@juanmaguitar juanmaguitar merged commit a2ebf0b into trunk Nov 29, 2023
51 checks passed
@juanmaguitar juanmaguitar deleted the fundamentals-block-development/the-block-wrapper branch November 29, 2023 09:52
@github-actions github-actions bot added this to the Gutenberg 17.2 milestone Nov 29, 2023
@youknowriad
Copy link
Contributor

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

derekblank pushed a commit that referenced this pull request Dec 7, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants