-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Gutenberg: Update selected editor when switching to classic (Calypso) #32421
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~122 bytes added 📈)
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
It seems like |
We use Right now we whitelist these origins (D25762-code): |
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.
This tests well for me and the API key gets set correctly. My only question (not a blocker) is whether it would be cleaner to drop the parameter off the URL once we've set the editor preference accordingly -- it would look cleaner and not expose the messy inner workings to users.
I agree it would look cleaner but I don't know how to properly do that. All the approaches I can think of involves a That redirect means that the whole controller logic will be executed again so I wonder if there is any way of changing the URL and making sure that the controller ignores that change. I'll defer this to a follow-up PR and possibly someone else with more knowledge about |
9ce0249
to
8536378
Compare
Changes proposed in this Pull Request
Previously, when a user clicked on the "Switch to Classic Editor" button available on the "More tools" menu, we were performing a request to the opt-in API endpoint to set the classic editor as the new desired editor and later redirecting the user to the classic editor URL.
This approach presents a problem with Jetpack sites since the opt-in API is not available there.
To workaround that, we have two options:
On this PR we're exploring the 2nd option, since the 1st one will involve a huge amount of work.
Now, when the "Switch to Classic Editor" button is clicked, we just redirect to the classic editor URL which will include a
set-editor=classic
param. The Calypso controller of that URL will check that param and update the selected editor toclassic
when found.Testing instructions
widgets.wp.com
./block-editor
and select your sandbox site.set-editor=classic
param on the URL.classic
on the API:GET https://public-api.wordpress.com/wpcom/v2/sites/:site/gutenberg
.set-editor=classic
param is not present on the URL.gutenberg
on the API:GET https://public-api.wordpress.com/wpcom/v2/sites/:site/gutenberg
.