From 02e039a745c9303bd80ccaa763e17360ab376890 Mon Sep 17 00:00:00 2001 From: Jameel Moses Date: Thu, 15 Nov 2018 21:29:47 -0500 Subject: [PATCH 1/3] Fixes #11949: Error: The block "xxx" can have a maximum of 3 keywords. --- packages/blocks/src/api/registration.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index 14cf00652b728c..a11c20c1e8b892 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -103,12 +103,6 @@ export function registerBlockType( name, settings ) { ); return; } - if ( 'keywords' in settings && settings.keywords.length > 3 ) { - console.error( - 'The block "' + name + '" can have a maximum of 3 keywords.' - ); - return; - } if ( ! ( 'category' in settings ) ) { console.error( 'The block "' + name + '" must have a category.' @@ -146,6 +140,13 @@ export function registerBlockType( name, settings ) { return; } + if ( 'keywords' in settings && settings.keywords.length > 3 ) { + console.error( + 'The block "' + name + '" can have a maximum of 3 keywords.' + ); + settings.keywords = settings.keywords.slice( 0, 3 ); + } + dispatch( 'core/blocks' ).addBlockTypes( settings ); return settings; From 3293ee7bfb9194220a6f1b629aef5fa9aacc4191 Mon Sep 17 00:00:00 2001 From: Jameel Moses Date: Sat, 17 Nov 2018 16:26:44 -0500 Subject: [PATCH 2/3] Fixes #11949: Error: The block "xxx" can have a maximum of 3 keywords. --- packages/blocks/src/api/registration.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index a11c20c1e8b892..4d0f22ebee6bec 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -1,4 +1,4 @@ -/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */ +/* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ /** * External dependencies @@ -141,7 +141,7 @@ export function registerBlockType( name, settings ) { } if ( 'keywords' in settings && settings.keywords.length > 3 ) { - console.error( + console.warn( 'The block "' + name + '" can have a maximum of 3 keywords.' ); settings.keywords = settings.keywords.slice( 0, 3 ); From 95abd24b7b34b434894e2855cffd0bb7c628726d Mon Sep 17 00:00:00 2001 From: Jameel Moses Date: Tue, 5 Feb 2019 12:46:16 -0500 Subject: [PATCH 3/3] Fixes #11949: Error: The block xxx can have a maximum of 3 keywords. --- .../developers/block-api/block-registration.md | 2 +- packages/blocks/src/api/registration.js | 9 +-------- packages/blocks/src/api/test/registration.js | 7 ------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/docs/designers-developers/developers/block-api/block-registration.md b/docs/designers-developers/developers/block-api/block-registration.md index 4bc32fb9f4e0fa..f4a214b741fbe2 100644 --- a/docs/designers-developers/developers/block-api/block-registration.md +++ b/docs/designers-developers/developers/block-api/block-registration.md @@ -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. diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index 4d0f22ebee6bec..d32a49f8b7ff00 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -1,4 +1,4 @@ -/* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ +/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */ /** * External dependencies @@ -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; diff --git a/packages/blocks/src/api/test/registration.js b/packages/blocks/src/api/test/registration.js index e881943d5168ee..f7b20bcda9db07 100644 --- a/packages/blocks/src/api/test/registration.js +++ b/packages/blocks/src/api/test/registration.js @@ -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 );