Skip to content

Commit

Permalink
Fixes #11949: Error: The block xxx can have a maximum of 3 keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameelmoses authored and gziolo committed Feb 13, 2019
1 parent 3293ee7 commit 95abd24
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ icon: {

* **Type:** `Array`

Sometimes a block could have aliases that help users discover it while searching. For example, an `image` block could also want to be discovered by `photo`. You can do so by providing an array of terms (which can be translated). It is only allowed to add as much as three terms per block.
Sometimes a block could have aliases that help users discover it while searching. For example, an `image` block could also want to be discovered by `photo`. You can do so by providing an array of terms (which can be translated).

```js
// Make it easier to discover a block with keyword aliases.
Expand Down
9 changes: 1 addition & 8 deletions packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */

/**
* External dependencies
Expand Down Expand Up @@ -140,13 +140,6 @@ export function registerBlockType( name, settings ) {
return;
}

if ( 'keywords' in settings && settings.keywords.length > 3 ) {
console.warn(
'The block "' + name + '" can have a maximum of 3 keywords.'
);
settings.keywords = settings.keywords.slice( 0, 3 );
}

dispatch( 'core/blocks' ).addBlockTypes( settings );

return settings;
Expand Down
7 changes: 0 additions & 7 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ describe( 'blocks', () => {
expect( block ).toBeUndefined();
} );

it( 'should reject blocks with more than 3 keywords', () => {
const blockType = { save: noop, keywords: [ 'apple', 'orange', 'lemon', 'pineapple' ], category: 'common', title: 'block title' },
block = registerBlockType( 'my-plugin/fancy-block-7', blockType );
expect( console ).toHaveErroredWith( 'The block "my-plugin/fancy-block-7" can have a maximum of 3 keywords.' );
expect( block ).toBeUndefined();
} );

it( 'should reject blocks without category', () => {
const blockType = { settingName: 'settingValue', save: noop, title: 'block title' },
block = registerBlockType( 'my-plugin/fancy-block-8', blockType );
Expand Down

0 comments on commit 95abd24

Please sign in to comment.