-
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
Block API: Adding the keywords property to enhance filtering the blocks #2115
Conversation
…iltering the blocks
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Love it! Works great for me. 👍 👍 |
blocks/library/verse/index.js
Outdated
@@ -21,6 +21,8 @@ registerBlockType( 'core/verse', { | |||
|
|||
category: 'formatting', | |||
|
|||
keywords: [ 'poetry' ], |
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.
We would need to consider translation of these in the future.
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.
Good point. I can wrap it in i18n.__
. Would that be enough?
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.
I don't see why it wouldn't.
c698a89
to
4da242a
Compare
@@ -67,6 +67,12 @@ export function registerBlockType( name, settings ) { | |||
); | |||
return; | |||
} | |||
if ( 'keywords' in settings && settings.keywords.length > 3 ) { |
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 was the thinking behind the limit?
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.
Prevent plugin authors from abusing keywords (keep the inserter search "sane")
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.
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'],
@s-a-s-k-i-a yes, you can also just do |
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. |
Agree, we should just remove the limitation. |
[UI tests] Schedule runs for full UI tests suite
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"