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

Block API: Adding the keywords property to enhance filtering the blocks #2115

Merged
merged 2 commits into from
Aug 1, 2017

Conversation

youknowriad
Copy link
Contributor

This PR adds an optional keywords property taken into consideration when filtering the blocks in the inserter. As an example It's used currently to display the "verse" block if we search for "poetry"

@youknowriad youknowriad added [Feature] Block API API that allows to express the block paradigm. [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels Aug 1, 2017
@youknowriad youknowriad self-assigned this Aug 1, 2017
@codecov
Copy link

codecov bot commented Aug 1, 2017

Codecov Report

Merging #2115 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2115      +/-   ##
==========================================
+ Coverage   20.33%   20.47%   +0.13%     
==========================================
  Files         135      135              
  Lines        4238     4258      +20     
  Branches      722      727       +5     
==========================================
+ Hits          862      872      +10     
- Misses       2844     2853       +9     
- Partials      532      533       +1
Impacted Files Coverage Δ
blocks/library/verse/index.js 37.5% <ø> (ø) ⬆️
blocks/api/registration.js 100% <100%> (ø) ⬆️
editor/inserter/menu.js 45.52% <100%> (+1.83%) ⬆️
blocks/block-alignment-toolbar/index.js 33.33% <0%> (-4.17%) ⬇️
blocks/library/cover-text/index.js 29.62% <0%> (-0.38%) ⬇️
blocks/library/latest-posts/index.js 10.9% <0%> (+0.9%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ecd2ea...4da242a. Read the comment docs.

@jasmussen
Copy link
Contributor

Love it! Works great for me. 👍 👍

@@ -21,6 +21,8 @@ registerBlockType( 'core/verse', {

category: 'formatting',

keywords: [ 'poetry' ],
Copy link
Member

Choose a reason for hiding this comment

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

We would need to consider translation of these in the future.

Copy link
Contributor Author

@youknowriad youknowriad Aug 1, 2017

Choose a reason for hiding this comment

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

Good point. I can wrap it in i18n.__. Would that be enough?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see why it wouldn't.

@youknowriad youknowriad merged commit 3543d4c into master Aug 1, 2017
@youknowriad youknowriad deleted the add/block-keywords branch August 1, 2017 12:41
@@ -67,6 +67,12 @@ export function registerBlockType( name, settings ) {
);
return;
}
if ( 'keywords' in settings && settings.keywords.length > 3 ) {
Copy link
Member

Choose a reason for hiding this comment

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

What was the thinking behind the limit?

Copy link
Contributor Author

@youknowriad youknowriad Aug 4, 2017

Choose a reason for hiding this comment

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

Prevent plugin authors from abusing keywords (keep the inserter search "sane")

Copy link

@s-a-s-k-i-a s-a-s-k-i-a left a comment

Choose a reason for hiding this comment

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

maximum of 3 keywords allowed; however this code allows each keyword to be unlimited characters long.

Thus this will be abused.
We can for example have keywords defined like this:
keywords: ['wordpresspaypalwoocommercefrontendyoastsaskialundwearethegreatesbestpluginwhaterverstring', 'andwhileweareatitwecanaddsomemorestorytellinghere', 'andhereandhere'],

@mtias
Copy link
Member

mtias commented Nov 20, 2017

@s-a-s-k-i-a yes, you can also just do [ 'all my keywords here', 'other keywords here' ]

@aduth
Copy link
Member

aduth commented Nov 20, 2017

Honestly I'm not sure why we bother trying to restrict keywords. Seems like unnecessary hand-slapping that determined plugin developers could always get around anyways.

@mtias
Copy link
Member

mtias commented Nov 20, 2017

Agree, we should just remove the limitation.

Tug pushed a commit that referenced this pull request May 12, 2020
[UI tests] Schedule runs for full UI tests suite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Inserter The main way to insert blocks using the + button in the editing interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants