-
Notifications
You must be signed in to change notification settings - Fork 4.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
Add new registerInserterMediaCategory
API to make media categories extensible
#51542
Conversation
4e66a1f
to
e542fed
Compare
/** | ||
* Interface for inserter media requests. | ||
* | ||
* @typedef {Object} InserterMediaRequest |
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.
What I need for docs is to export these type definitions(InserterMediaRequest
, InserterMediaItem
, InserterMediaCategoryLabels
, InserterMediaCategory
). Is there a standarized way to do that, that I'm not aware of?
Currently are docs formatter supports generating only one typedef
in docs. So one way to go(if there is no standarized way) would be to augment or update our formatter to handle this use case. Another way would be to just add them as comments in the function's description, but I'd like to avoid the duplication of the types descriptions.
Size Change: +340 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
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.
Tested this and it works as described. The code makes sense to me.
I've been playing around with this and it works nicely 👍 |
e542fed
to
4abdad1
Compare
I didn't test but the code looks good to me now. 👍 |
9f77dfd
to
b092365
Compare
Flaky tests detected in b092365. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5353817841
|
…extensible (WordPress#51542) * Add new `registerInserterMediaCategory` API to make media categories extensible * make `registerInserterMediaCategory` an action * add tests * add docs
@ntsekouras, I'm sorry if this is not the best place for this, but I have a question: is it possible to use this functionality to add a list of images that come not from an external source, but from a theme or a plugin directory? I wonder if this would be a nice way to provide "Theme suggested assets" that are not uploaded to the media library but are not necessarily external to the server. |
Sorry for the delayed reply. Each category has to implement a |
What?
In #44918 and #46222 we added a new media tab in the inserter and integrated Openverse respectively. Currently the media categories are stored in a private block editor setting(
inserterMediaCategories
), which means they are not extensible.This PR adds a new
blockEditor
action for registering additional media categories. The used setting is preserved as a private one, so extenders can only add new categories without having any control over the core media categories.Tasks
Testing Instructions
Run the below function in dev tools console and observe the new category in inserter's media tab. The example uses the Openverse category object and just updates the names used.