Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add block directory to inserter menu #17431
Extend the inserter to show available blocks for download and silently install the block when the block is inserted into the editor
This PR is still a WIP. Can you help guide me with the implementation and avoiding any pitfalls? I'm new to the block editor.
Types of changes
[design] Mockup feedback
[dev] Block Directory Proposal
[dev] Block Registration
[dev] Block Registration - assets JSON structure
GitHub Block Directory issues
GitHub Block Directory project
From #16524 (comment):
Should we close all those PRs?
* Add new properties and panel for discover items * Add basic component with styling for discover blocks * Dynamically load block into editor. * Increase icon size. * Handle insert block properly. * Added another discover block. * Revert unncessary changes. * Retrieve discover blocks from a mock api. * Only show discover blocks when no blocks are found. * Style discover items header * Fill discover item footer elements. * Use BlockIcon components. * Update documentation. * Update mock URL. * Revert changes in BlockIcon for size and use Icon directly. * Use Fragment from wp.element. * Created BlockRatings component. * Update classNames to follow guidelines. * Moved mock api to WordPress rest api. * Separate DiscoverBlocksPanel to a component. * Implement basic block search. * Handle user without permission to install blocks. * Styling for discover blocks search description. * Handle error when script can't load. Cache search results. * Removed text to follow design. * Fixed search not returning as array from the mock API. * Refactor stars component to a shorter code using @talldan's recommendation. * Renamed class names based on guideline and recommendation. * Make React avoid rendering style attribute when icon is falsey. * Removed redundant styles. * Refactor DiscoverBlockListItem to smaller components. * Renamed class names based on guideline and recommendation. * Align @param descriptions. * Removed redundant comments. * Refactor DiscoverBlockListItem to smaller components. Renamed class names based on guideline and recommendation. * Tidy up blocks search controller code. * Implement Retry button when Block previews can't load. * Implement block search to api.wordpress.org. * Map plugin info to discover block. * Map available plugin properties to block. Comment for unavailable and ambigous properties. * Fix typo in comment. * Map updated metadata from api. Handle multiple script loads correctly. * Updated unit test. * Show loading state when requesting for discover blocks. * Only show uninstalled blocks. * Prevent fetching if user has not typed anything. * Update comments * Debounce search for blocks. * Implement spinner for loading state. * Install and activate plugin after loading to editor. * Handle error while installing block. * Added functionality to retry installing block. * Use regular HTML attributes without string evaluation. * Use shorthand property names. * Use WP_Error, improve and fix for feedback from PR. props @TimothyBJacobs. * Change install REST methods to allow PUT and POST only. Update to use get_item_schema. * Update REST to return response with snake case. * New downloadable-blocks package to fill a slot in inserter menu. * Update documentation. * Passing props to downloadable blocks. * Moved components from block-editor to its own package. * Load css for downloadable-blocks. * Moved debounce filterValue function to editor. * Moved to use its own data store in downloadable-blocks package. * Moved code to load block assets out of menu.js * Remove comment. * Removed block-icon from downloadable-blocks package. * Fixed bad reference in scss file. * Moved installBlock function to a be next to handleDownloadableBlock. * Moved the handleDownloadableBlock to actions. * Renamed downloadable-blocks package to block-directory. * Export DiscoverBlocksPanel as named exports. * Update README and package.json. * Renamed store to core/block-directory. * Renamed css class name. * Renamed css class name. * Renamed discover-block to downloadable-block * Rename block-ratings to prefix with block-directory. * Rename rest controller to block directory. * Limit the number of words in description. * Update background color to design specs. * Refactor to call loadAssets asynchronously. * Refactor downloadBlock and installBlock to be more extensible. * Rename handleDownloadableBlock to downloadBlock * Handle if FS_METHOD is not direct. * Fix retry of installing block. * Only install block after download is successful. Add error handling of block has no assets in the metadata. * Fix onSelect of item on success. * Remove block if failed to install block. * Update documentation. * Check for permission before fetch. * Fix unit test * Uninstall new blocks if user has removed them. * Remove debug messages from API. * Fix bug to filter installedBlockType after uninstall. * Add dependencies into package.json * Update package-lock.json * Fix flickering when search for blocks. * Update package.json * Update package-lock.json * Fix the search results flickering. * Update packages/block-directory/package.json Co-Authored-By: Grzegorz (Greg) Ziółkowski <email@example.com> * Update packages/block-directory/package.json Co-Authored-By: Grzegorz (Greg) Ziółkowski <firstname.lastname@example.org> * Update packages/block-directory/CHANGELOG.md Co-Authored-By: Grzegorz (Greg) Ziółkowski <email@example.com> * Improve accessibility. * Remove redudant line. * Rename the selector method. * Remove isDownloadableBlocksEnabled settings. If no fills registered for the slot, default to original behaviour. * Update data-core-block-editor.md * Added feature toggle for block directory in the experiment settings page. * Update README.md * Fix typo * Fixed phpcs errors. * Fix phpcs warning. * Rename REST base endpoint to block-directory. * Update comment for class. * Use noop instead of empty function. * Rename discover blocks to downloadable blocks. * Tidy up code. * Update bottom section to be footer in an article. * Fix phpcs warning. * Mapped author information for block directory * Remove experimental feature flag for block directory * Fix block inner-content overflowing rounded corners * Remove superfluous css rule * Use existing scss variables where possible * Use a `p` tag for the block description * Remove @access comments * s/get_items_permissions_check/permissions_check/ * Update @SInCE to 6.5.0 * Mark parse_block_metadata() as private * Update @SInCE to 6.5.0 * Include end of string anchor in image extension RegExp * Remove item.isDisabled * Use unicode apostrophe * Improve spoken message * Improve copy * Add whitespace * Fix comments and remove unused params * Pass storeConfig straight to registerStore * Remove empty quotes * Use Array.isArray * Add a comment explaining the block uninstall feature * Fix plugin rating calculation * s/isMenuEmpty/hasItems/ * Revert "Remove experimental feature flag for block directory" This reverts commit 882d178. Co-authored-by: CK <firstname.lastname@example.org> Co-authored-by: Robert Anderson <email@example.com>