-
Notifications
You must be signed in to change notification settings - Fork 828
feat: Expand editor assets endpoint allowed block types #44979
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
Draft
dcalhoun
wants to merge
5
commits into
trunk
Choose a base branch
from
feat/expand-editor-assets-endpoint-allowed-block-types
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−3
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a4f67fe
feat: Editor assets endpoint allows Jetpack Forms blocks
dcalhoun e448d29
feat: Enqueue contact form styles for non-admin REST API requests
dcalhoun aca49ef
fix: Correct field-multiple-choice typo
dcalhoun dcb53db
feat: Expand editor assets allowed block types
dcalhoun 5f8fb91
changelog
dcalhoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/feat-expand-editor-assets-endpoint-allowed-block-types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: other | ||
|
||
Block editor: expand allowed block types for the mobile editor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@coder-karen my understanding is that utilizing
is_admin()
is the latest recommendation for enqueueing block editor content assets intended for the editor only (excluded from the site's front end). Unfortunately, the approach is problematic for REST API endpoints (like the block editor assets endpoint used for the mobile apps), as they are not "admin," which leads to the absence of this asset entirely—it's neither registered or enqueued.To be clear, removing this
is_admin()
check does results in loading an additional stylesheet for the site's front end:I recognize this is likely undesired. I do not plan to merge this as-is currently.
My questions:
is_admin()
usage cease and the REST API issue become moot when VULCAN-68 is completed?Thank you for your help! 🙇🏻♂️
Uh oh!
There was an error while loading. Please reload this page.
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.
Then that's a no-go, we shouldn't load more bytes in the frontend.
Have you looked at adding "is rest request" check? Looks like there's a helper:
jetpack/projects/packages/assets/src/class-script-data.php
Lines 107 to 114 in 4ec0394
There's also
REST_REQUEST
constant, some usage example here as alternative:jetpack/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php
Lines 712 to 719 in 4ec0394
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.
@simison thank you for providing feedback.
I agree. If the stylesheet in question should not be loaded in the site's front end, then we should not load the unnecessary bytes. My questions largely sought to under why the stylesheet should not be loaded (i.e., is it duplicating styles provided elsewhere?) and if there might be alternative style organization that would negate the need to avoid loading it.
Yes, I actually introduced the referenced helper to the Jetpack codebase in 21ec749.
The aforementioned helper and the utilities provided by WordPress core rely upon the
REST_REQUEST
. Unfortunately, as mentioned in #44979 (comment), I believe theREST_REQUEST
constant is defined too late for the particular problem discussed in this thread. The constant is set after Jetpack decides whether to enqueue the targeted stylesheet.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.
Yes, there's some CSS that specifically addresses editor only in the file. Much of it could be only in a separate view CSS file, but there's a lot of legacy here and much of the frontend styles are in grunion.scss.
Because some of the styles are needed just in editor, moving shared CSS around now wouldn't help though?
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.
Thank you for sharing the context regarding the editor stylesheet and accompanying grunion stylesheet.
It's unclear to me currently if there is a possibility of relocating the missing styles to an always-loaded shared stylesheet. We'd need to dive a bit deeper into the specific missing styles to understand if they are truly editor-only or could be relocated to a shared place.
For example, elements like
form-step
andform-progress-indicator
are un-styled in the mobile app editor due to the missing stylesheet.Presumably, those styles—
form-step
andform-progress-indicator
—are necessary for both the admin editor and the site front end. For the editor, it appears those disparate styles are ultimately bundled withcontact-form/editor.scss
and that is the currently admin-only stylesheet; on the site front end, those styles appear to be loaded as an individual stylesheets—e.g.,jetpack-forms/dist/blocks/form-progress-indicator/style.css
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.
@lezama was looking a bit at organising our styles better for new fields, so I wonder if he would have thoughts here on short-term improvements?
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 attempted to refactor how we enqueue/register things in #45190. But after testing the endpoint before and after the change, I realized that form-progress-indicator/style.css was already being returned by the endpoint when running trunk 😅. I might be missing something, happy to jump on a quick call.
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.
@lezama thank you for looking into this. It's surprising that you say the
form-progress-indicator
styles are included in the endpoint return when testing the trunk branch. What specificlink
tag is returned that contains those styles?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.
ha! I am sorry, I just tested again and now I don't see the styles in trunk but I do if I am running #45190. Not sure what I did Yesterday differently.