
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@wordpress/block-directory
Advanced tools
Extend editor with block directory features to search, download and install blocks.
Package used to extend editor with block directory features to search and install blocks.
This package is meant to be used only with WordPress core. Feel free to use it in your own project but please keep in mind that it might never get fully documented.
Install the module
npm install @wordpress/block-directory --save
This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @wordpress/babel-preset-default
in your code.
This package builds a standalone JS file. When loaded on a page with the block editor, it extends the block inserter to search for blocks from WordPress.org.
To do this, it uses the __unstableInserterMenuExtension
, a slot-fill area hooked into the block types list. When the user runs a search and there are no results currently installed, it fires off a request to WordPress.org for matching blocks. These are listed for the user to install with a one-click process that installs, activates, and injects the block into the post. When the post is saved, if the block was not used, it will be silently uninstalled to avoid clutter.
See also the API endpoints for searching WordPress.org: /wp/v2/block-directory/search
, and installing & activating plugins: /wp/v2/plugins/
.
The following set of dispatching action creators are available on the object returned by wp.data.dispatch( 'core/block-directory' )
:
Returns an action object used to add a block type to the "newly installed" tracking list.
Parameters
Object
: The block item with the block id and name.Returns
Object
: Action object.Sets the error notice to empty for specific block.
Parameters
string
: The ID of the block plugin. eg: my-blockReturns
Object
: Action object.Returns an action object used in signalling that the downloadable blocks have been requested and are loading.
Parameters
string
: Search string.Returns
Object
: Action object.Action triggered to install a block plugin.
Parameters
Object
: The block item returned by search.Returns
boolean
: Whether the block was successfully installed & loaded.Returns an action object used in signalling that the downloadable blocks have been updated.
Parameters
Array
: Downloadable blocks.string
: Search string.Returns
Object
: Action object.Returns an action object used to remove a block type from the "newly installed" tracking list.
Parameters
string
: The block item with the block id and name.Returns
Object
: Action object.Sets an error notice to be displayed to the user for a given block.
Parameters
string
: The ID of the block plugin. eg: my-blockstring
: The message shown in the notice.boolean
: Whether the user can recover from the error.Returns
Object
: Action object.Returns an action object used to indicate install in progress.
Parameters
string
:boolean
:Returns
Object
: Action object.Action triggered to uninstall a block plugin.
Parameters
Object
: The blockType object.The following selectors are available on the object returned by wp.data.select( 'core/block-directory' )
:
Returns the available uninstalled blocks.
Parameters
Object
: Global application state.string
: Search string.Returns
Array
: Downloadable blocks.Returns the error notice for a given block.
Parameters
Object
: Global application state.string
: The ID of the block plugin. eg: my-blockReturns
string|boolean
: The error text, or false if no error.Returns all block error notices.
Parameters
Object
: Global application state.Returns
Object
: Object with error notices.Returns the block types that have been installed on the server in this session.
Parameters
Object
: Global application state.Returns
Array
: Block type itemsReturns block types that have been installed on the server and used in the current post.
Parameters
Object
: Global application state.Returns
Array
: Block type items.Returns the block types that have been installed on the server but are not used in the current post.
Parameters
Object
: Global application state.Returns
Array
: Block type items.Returns true if a block plugin install is in progress.
Parameters
Object
: Global application state.string
: Id of the block.Returns
boolean
: Whether this block is currently being installed.Returns true if application is requesting for downloadable blocks.
Parameters
Object
: Global application state.string
: Search string.Returns
boolean
: Whether a request is in progress for the blocks list.This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.
FAQs
Extend editor with block directory features to search, download and install blocks.
We found that @wordpress/block-directory demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 23 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.