-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Extract Embed Block template code to a package. #19113
Conversation
This is currently a first pass, but I'd appreciate some early feedback on the direction. 🙂 |
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 is a very interesting idea to move all common code related to embeds to its own package. In fact, there is some prior-art for media utils. See @wordpress/media-utils package introduced by @jorgefilipecosta. It's definitely a good direction if we want to make it easier to build custom embeds.
The biggest challenge is how to ensure that only essential APIs are exposed from this package and are well documented. In particular utils.js
files, it seems like it shouldn't be part of the public API.
I agree, this will need auditing. I just went with |
b56162c
to
d8d21dd
Compare
I have some time to push this forward again, so I've updated the PR, and created a sample use: Automattic/jetpack#14648 @gziolo Do you have more thoughts on the viability of this approach? |
@mcsf, did you have a chance to look at embeds and how they could possibly be refactored to sue variations? Still, it might be necessary to expose some components as proposed in this PR. |
(Oops, I missed this ping due to some AFK time.) I looked at embeds very experimentally as a prelude to the work on Social Icons, which was more pressing. I still think it's fairly feasible to turn Embeds into variations of a single block type. @pento, if you're interested in this, I can cc you in that task so we can figure out what makes most sense to extract from |
@gziolo: looking at embeds, it becomes clear that we need slash-inserter support for variations. |
I'm putting it on my todo list 👍 |
@mcsf: I don't know that I'll have wild amounts of time to devote to this, but if you can give me some more details on what needs to be done, I'll see what I can wrangle. |
@pento: don't worry, I'll share a PR whenever I have something and it should become apparent what could be reused. Honestly, though, my wish is that we could, over the next quarter, greatly simplify the way that embeds work (and turning them into a variation would be a definite first step) so that there is actually very little that needs to be reused. I suspect that advances in React from the last year and half (cf. hooks) could help us untangle some design patterns in the embeds code base, too. |
Sounds like a plan, @mcsf. I'm going to close this PR out, then, and we'll pick it back up again when you've had a chance to explore the block variation idea. |
Description
Fixes #13490.
This PR extracts the common code used by Core's embed blocks into a new
@wordpress/embed-block
package, allowing plugins to make use of this simpler method for creating embed-style blocks.How has this been tested?
Automattic/jetpack#14648 is an experiment in making use of this new package.
Checklist: