Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Filter block types with allow list #113

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

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Apr 1, 2025

Related:

What?

Filter the available block types via an allow list fetched from the API
endpoint.

Why?

Fix CMM-224. Used for selectively enabling stable block types and/or removing
unnecessary or problematic assets.

How?

Given block types are registered via the scripts loaded onto the page, we must
unregister each block type not within the allow list.

Testing Instructions

This small, conditional-wrapped change is likely safe to merge without additional testing. For posterity, the following are the explicit steps for testing:

Important

Testing this currently requires completing the testing instructions setup for Automattic/jetpack#42835 to your sandbox server and routing your testing device public-api.wordpress.com traffic to your sandbox server.

  1. In the Jetpack mobile app, enable the Experimental block editor plugins feature flag.
  2. Smoke test the editor and Jetpack blocks. The REST API endpoint currently allows all of the same block types as before, so there are no changes to observe.

Accessibility Testing Instructions

N/A, no navigation changes.

Screenshots or screencast

N/A, no visual changes.

@dcalhoun dcalhoun added the [Type] Enhancement A suggestion for improvement. label Apr 1, 2025
Base automatically changed from fix/remote-editor-failures to trunk April 4, 2025 19:50
dcalhoun added 2 commits April 4, 2025 20:15
To improve stability, the remote, site-specific editor un-registers
block types that are not on the allow list.
This is largely in place for development experience purposes, not user
facing. It allows the editor WebView to reload and retains its current
GBKit global.
@dcalhoun dcalhoun force-pushed the feat/block-types-allow-list branch from 7838da1 to 38fe2c7 Compare April 5, 2025 00:16
Comment on lines +241 to +247
if ( ! window.GBKit ) {
try {
window.GBKit = JSON.parse(
localStorage.getItem( 'GBKit' )
);
} catch ( error ) {}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This ensures that page reloads occurring in a development environment continue to work. This should have no impact on users.

@dcalhoun dcalhoun marked this pull request as ready for review April 5, 2025 00:19
Avoid exceptions invoking array methods on `undefined`.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant