-
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: add oembed support #27486
Conversation
Test live: https://calypso.live/?branch=add/oembed |
cfc1bd7
to
2b63c05
Compare
* @param {String} embedUrl the fallback embed url | ||
* @returns {Object} transformed response | ||
*/ | ||
const transformOembedResponseFromWpcomToCore = ( response, embedUrl ) => { |
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.
since we could get an error
here we should probably rename this maybeTransformOembedResponseFromWpcomToCore
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.
Hah well that's one way to get me to refactor code :) updated in 445f074
Though I'll probably leave any polishing of error cases for follow ups
From #27296, it sounds like Gutenberg on Calypso is trying to access The correct endpoint is Naturally, there are some gotchas :)
Both gotchas can be fixed, but are issues separate to the issue of just getting things working in Gutenberg. This PR (or whatever works for you all) is probably the fastest way forward for now. Hopefully future gotcha fixing will allow us to remove (or at least simplify) this middleware. (PS: Sorry if this is all old news.) |
😡 😡 😡 |
I don't have enough knowledge of the middleware to give a really educated review, but this LGTM and it works as expected! |
Going to rebase, so we can drop the diff d6f52db |
Thanks @mdawaffe for the clarification! We'll at least need some minimal middleware to update the path to be site aware. I'll give it a try! We'll need to test later if that endpoint already includes items on our wpcom +jetpack whitelist that should contain more embeds than core. |
Just a comment on the Gutenberg should work fine with both. However, if the Pinterest embed is implemented with a shortcode, and that shortcode enqueues scripts. The That's the only embed that I found has this behaviour at the moment, however that might be a factor in which endpoint we use. I noticed that Calypso's existing editor uses the Hopefully that makes sense? Happy to work with all you lovely peeps on this :) |
@mdawaffe looks like this behaves okay on the oembed/1.0 namespace from some brief testing. I'll land this once test are green, and I'll follow up with another issue to audit if we support extra wpcom/jetpack embeds that should be whitelisted. cc @notnownikki |
Thanks for the reviews folks! ✨ |
Fixes #27296 and alternative to #27437 and builds heavily on @notnownikki's earlier integration work.
This adds a middleware handler to transform the
oembed/1.0
requests to be site aware!Testing Instructions
/gutenberg
https://www.youtube.com/watch?v=kfVsfOSbJY0
or a tweet💖 Props to @notnownikki for figuring out that we were missing a style causing iframes to be set to a width of 0