Skip to content
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 block directory to inserter menu #17431

Merged
merged 160 commits into from
Sep 13, 2019
Merged

Add block directory to inserter menu #17431

merged 160 commits into from
Sep 13, 2019

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Sep 13, 2019

Moved over from #16524. Props to @ck-lee for all the hard work on the original PR.

Description

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.

Screenshots

Types of changes

  • Extend inserter to fetch a list of suggestBlocks similar to reusableBlocks
  • The list of suggestBlocks is currently served from a mock API. It is not built yet.
  • Extend the filter to show suggestBlocks if there are no results found.
  • When "Add" button is clicked, download the block assets from plugin.svn. Then, load and insert the block into the editor without installing it.
  • ...

Relevant Links

[design] Main thread
https://make.wordpress.org/design/2019/04/26/block-library-installing-blocks-from-within-gutenberg/

[design] Figma
https://www.figma.com/file/QKhoOKXkBN2mHacqvrtdNuI6/Gutenberg-Block-Library%3A-Installation

[design] Mockup feedback
https://make.wordpress.org/design/2019/06/07/block-library-mockups-prototype

[dev] Block Directory Proposal
https://make.wordpress.org/meta/2019/03/08/the-block-directory-and-a-new-type-of-plugin/

[dev] Block Registration
https://github.com/WordPress/gutenberg/blob/master/docs/rfc/block-registration.md

[dev] Block Registration - assets JSON structure
#13693 (comment)

GitHub Block Directory issues
https://github.com/WordPress/block-directory/issues

GitHub Block Directory project
https://github.com/WordPress/block-directory/projects/1

if ( ! asset ) {
return;
}
const existing = document.querySelector( `script[src="${ asset.src }"]` );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest challenge here is that it doesn't ensure that all dependencies of the script are loaded. It probably won't be the case on the edit post page though unless someone uses one of the WordPress script handles which are not used on this page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great point. Let's think about this some more and address it in a follow-up PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an update:
This problem could potentially be addressed here:

@gziolo
Copy link
Member

gziolo commented Sep 13, 2019

From #16524 (comment):

This PR has now been split to 4 PRs in preparation for further review and merging:

Add block directory search settings (#17182)
Add an extension slot for inserter menu. (#17183)
Implement REST controller for block directory features. (#17243)
Implement new block-directory package (#17244)

Should we close all those PRs?

@noisysocks noisysocks added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Sep 13, 2019
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in behind an experimental flag. Thanks so much to @ck-lee for all your hard work building this, and thanks @talldan for the final push!

@talldan talldan merged commit f37be8e into master Sep 13, 2019
@talldan talldan deleted the try/discover-new-blocks branch September 13, 2019 20:56
@youknowriad
Copy link
Contributor

Great work everyone ❤️

@TimothyBJacobs
Copy link
Member

All these return WP_Error need to be return new WP_Error, they'll fatal otherwise.

@ck-lee
Copy link
Contributor

ck-lee commented Sep 14, 2019

Thank you, team. @noisysocks, @talldan: You guys are awesome! I appreciate your final push to merge this big one!

All these return WP_Error need to be return new WP_Error, they'll fatal otherwise.
@TimothyBJacobs. I can help fix this as a separate PR.

@gziolo
Copy link
Member

gziolo commented Sep 14, 2019

@ck-lee great work on this PR 🎉
@noisysocks and @talldan - I appreciate your courage for polishing and merging the big version of PR 💪

import { DownloadableBlocksPanel } from '@wordpress/block-directory';
import { useState } from '@wordpress/element';

function InserterMenuDownloadableBlocksPanel() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noisysocks and @talldan - it looks like all the code from '@wordpress/block-directory' will still get downloaded even when it's disabled for the user with the GUTENBERG_PHASE flag. We need to find a way to tree-shake this code for WordPress core.

}

<div className="block-directory-downloadable-block-header__column">
<span role="heading" className="block-directory-downloadable-block-header__title" >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end-to-end AXE tests require an aria-level be provided when using role="heading"

https://dequeuniversity.com/rules/axe/3.5/aria-required-attr?application=axe-puppeteer

Normally it's not caught in end-to-end tests, but due to some unexpected circumstances, it's become an issue lately (#22712).

What is the intended level here?
Why can't it just be a semantic heading element, vs. role=?

See: #22713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants