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

[WIP] Stabilize experimental Typography block support features within the block type class #7069

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Jul 23, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/61728

🚧 🚧 🚧 WIP: This is currently a work in progress and is not yet ready for review as the Gutenberg PR has not been merged yet. 🚧 🚧 🚧

This PR syncs the PHP changes from WordPress/gutenberg#63401, however uses a slightly different approach for applying the transformations so that we do not depend on filters. The overall goal is the following:

Stabilize the following typography block supports by no longer requiring the __experimental prefix in supports.typography in block.json and when registering block types:

  1. __experimentalFontFamilyfontFamily
  2. __experimentalFontStylefontStyle
  3. __experimentalFontWeightfontWeight
  4. __experimentalLetterSpacingletterSpacing
  5. __experimentalTextDecorationtextDecoration
  6. __experimentalTextTransformtextTransform

The proposal here is to transform the __experimental form of the typography supports marks for stabilization when props are set on a block type instance. This occurs during registration or when a WP_Block_Type object is instantiated. There was some discussion in an earlier Gutenberg PR about potentially performing this transformation in the block registry instead — however I couldn't find a good precedent for it, and it seems slightly more encapsulated to me to keep the transformation close to where the supports key is stored.

I'm very happy for feedback on this, though!

For full testing instructions, please see the original Gutenberg PR: WordPress/gutenberg#63401

The short version is that all the typography block supports for static blocks such as Group or dynamic blocks such as Post Title should work just the same with this PR applied as without. Then, in follow-up work we can look at updating core blocks to use the non __experimental syntax.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@@ -562,6 +580,29 @@ public function set_props( $args ) {
}
}

// Stabilize experimental block supports.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code intentionally does not unset the experimental version of the supports. This is so that the un-updated JS code in the editor can handle the experimental syntax, and (for now at least) feels slightly safer in terms of backwards compatibility.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@andrewserong
Copy link
Contributor Author

Based on discussion over in WordPress/gutenberg#63401 (comment), I've updated this to move the stabilization to after the filter is run. This ensures that any opt-outs, etc, performed by plugins are appropriately stabilized before the props are set.

I've also moved the logic into a private method so that set_props is easier to read.

@andrewserong andrewserong force-pushed the try/stabilize-typography-block-support-features branch from 76ceb8d to 886f3f1 Compare August 28, 2024 01:50
@andrewserong andrewserong marked this pull request as ready for review August 28, 2024 01:52
Copy link

github-actions bot commented Aug 28, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props andrewserong, aaronrobertshaw.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@aaronrobertshaw
Copy link

The latest plan is to backport all the block support stabilization updates in a single PR. This will include stabilizing border block supports and shared experimental flags such as __experimentalDefaultControls and __experimentalSkipSerialization.

More details can be found in WordPress/gutenberg#66918 (comment).

In the near future, I'll pick up this backport and update it accordingly, while @andrewserong is away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants