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

Block API #41236

Open
58 tasks
gziolo opened this issue May 23, 2022 · 27 comments
Open
58 tasks

Block API #41236

gziolo opened this issue May 23, 2022 · 27 comments
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Overview Comprehensive, high level view of an area of focus often with multiple tracking issues

Comments

@gziolo
Copy link
Member

gziolo commented May 23, 2022

This overview issue collects an actionable list of impactful tasks that capture possible enhancements to the various Block APIs that exist to power the WordPress block editor.

Block API is intentionally a vague term reflected in the list of action items grouped into categories like block registration, block attributes, block interactions, block modification, etc. What’s in common is that the tasks included aim to resolve the most common friction points or increase the potential of the APIs offered for WordPress block, plugin, and theme authors. In effect, it makes it possible to fulfill the needs of developers wanting to adopt the block editor in their projects.

🛠️ = in development
🤚 = needs to be unblocked

❗Top Things

High-impact projects in active development:

📖 Backlog

Planned tasks that are being actively researched, waiting for developers to pick them up or on hold until they get unblocked.

Block Registration

Block Assets

Block assets are JavaScript (editorScript, script, viewScript) and CSS (editorStyle, style) defined in block.json file.

Block Attributes

Block Variations

Block Interactions

Block Modification

Documentation

@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels May 23, 2022
@mtias mtias pinned this issue May 23, 2022
@mtias mtias added the [Type] Overview Comprehensive, high level view of an area of focus often with multiple tracking issues label May 23, 2022
@luisherranz
Copy link
Member

Develop strategies for loading JavaScript on the frontend - head vs footer, but also frontend hydration techniques explored in Implement different hydration techniques block-hydration-experiments#12.

This can be a good first step, but acknowledging that we need more than that in the near future: probably asycn/defer (something like what @adamsilverstein proposed in WordPress/performance#168) or even do the jump to ESM.

Apart from that, I think we should explore a mechanism to export different code depending on the context (Edit, Save, or Frontend): WordPress/block-interactivity-experiments#11

@gziolo
Copy link
Member Author

gziolo commented May 27, 2022

Thank you @luisherranz for your feedback. I included your suggestions together with references.

I also added two more items that I missed initially but have been following closely for a long time:

@fabiankaegy
Copy link
Member

@gziolo I have reviewed the items that are already tracked here and I myself have created 3 issues recently that I think could all be added:

pento pushed a commit to WordPress/wordpress-develop that referenced this issue Sep 14, 2022
Follow-up #54337, [52069]. Part of WordPress/gutenberg#41236. More details in WordPress/gutenberg#33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.



git-svn-id: https://develop.svn.wordpress.org/trunk@54155 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Sep 14, 2022
Follow-up #54337, [52069]. Part of WordPress/gutenberg#41236. More details in WordPress/gutenberg#33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.


Built from https://develop.svn.wordpress.org/trunk@54155


git-svn-id: http://core.svn.wordpress.org/trunk@53714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this issue Sep 14, 2022
Follow-up #54337, [52069]. Part of WordPress/gutenberg#41236. More details in WordPress/gutenberg#33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.


Built from https://develop.svn.wordpress.org/trunk@54155


git-svn-id: https://core.svn.wordpress.org/trunk@53714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
whereiscodedude pushed a commit to whereiscodedude/wpss that referenced this issue Sep 18, 2022
Follow-up #54337, [52069]. Part of WordPress/gutenberg#41236. More details in WordPress/gutenberg#33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.


Built from https://develop.svn.wordpress.org/trunk@54155
ootwch pushed a commit to ootwch/wordpress-develop that referenced this issue Nov 4, 2022
Follow-up #54337, [52069]. Part of WordPress/gutenberg#41236. More details in WordPress/gutenberg#33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.



git-svn-id: https://develop.svn.wordpress.org/trunk@54155 602fd350-edb4-49c9-b593-d223f7449a82
@carolinan carolinan unpinned this issue Feb 7, 2023
@gziolo gziolo pinned this issue Feb 11, 2023
@gziolo
Copy link
Member Author

gziolo commented Feb 13, 2023

☑️ Completed in WordPress 6.1 cycle

Block Registration

Block Assets

Some of the details were tracked in #33542.

Documentation

@gaambo
Copy link
Contributor

gaambo commented Sep 14, 2023

Regarding viewStyle: The initial issue was closed, therefore I'm posting this here:
I actually think this would be great to have. Not having this assumes, frontend styles can be used 1:1 in the editor. I've encountered many situations where that's just not true - it has gotten a lot better with the apiVersion: 2 blocks, but there are still many cases where I want to enqueue a style only in the frontend. Examples:

  • Very complex blocks - where I will develop a very specific block editing experience in the editor with components and editor styles and want to load the "real" styles for the (dynamically) rendered block only in the frontend.
  • JavaScript-heavy frontend - the most basic example being slider. I will have a lot of CSS which only styles the JS-initialized version of the block and they just don't need to be loaded in the editor.
  • There are cases where the frontend styles are just not used in the editor (and I know that while developing), so it's a performance slow-down if you have many such blocks. But there are also cases where the frontend styles may just "destroy" the editing experience of a block because they just don't work in that context.

Since we already have script, viewScript and editorScript I think it would keep clarity by also introducing viewStyle. Even if there are not many use cases where it's used, I don't see a real disadvantage.
It would also mean, that all assets of a block in all contexts could be managed through block.json - which would be great.

@gziolo
Copy link
Member Author

gziolo commented Sep 14, 2023

@gaambo, thank you for feedback.

Regarding viewStyle: The initial issue was closed, therefore I'm posting this here:

Can you share the link to the issue? I would like to learn why it was closed and potentially reopen. There is still an item listed in the Backlog that signals that we have this API on the roadmap but it doesn't link to the issue you referred to:

"Introduce viewStyle for styles used only on the front end to align with scripts and viewScript."

@gaambo
Copy link
Contributor

gaambo commented Sep 15, 2023

Can you share the link to the issue? I would like to learn why it was closed and potentially reopen. There is still an item listed in the Backlog that signals that we have this API on the roadmap but it doesn't link to the issue you referred to:

@gziolo
I've found #33542 where viewStyle was mentioned. I can open a new issue if required and we can link it in this overview issue.

@gziolo
Copy link
Member Author

gziolo commented Sep 15, 2023

I've found #33542 where viewStyle was mentioned. I can open a new issue if required and we can link it in this overview issue.

It was me who closed the issue with the note I moved the item to this issue - the one I quoted in #41236 (comment) 😄

If you could open a new issue that would be great, thank you! I'm happy to see this feature implemented if it's going to be useful for custom blocks.

@gziolo
Copy link
Member Author

gziolo commented Nov 3, 2023

Update

Completed during WP 6.4

Added

Needs review

@gziolo
Copy link
Member Author

gziolo commented Mar 15, 2024

Update

Completed during WordPress 6.5 cycle

New

Resources

@annezazu annezazu removed the [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Overview Comprehensive, high level view of an area of focus often with multiple tracking issues
Projects
None yet
Development

No branches or pull requests

10 participants