diff --git a/docs/designers-developers/developers/data/data-core-blocks.md b/docs/designers-developers/developers/data/data-core-blocks.md index 8d577f4fca040c..655c4f0d7a3390 100644 --- a/docs/designers-developers/developers/data/data-core-blocks.md +++ b/docs/designers-developers/developers/data/data-core-blocks.md @@ -83,7 +83,7 @@ _Parameters_ _Returns_ -- `Array`: Categories list. +- `Array`: Categories list. # **getChildBlockNames** diff --git a/docs/designers-developers/developers/tutorials/block-tutorial/applying-styles-with-stylesheets.md b/docs/designers-developers/developers/tutorials/block-tutorial/applying-styles-with-stylesheets.md index 05d78586ef0985..b8a4a94996b014 100644 --- a/docs/designers-developers/developers/tutorials/block-tutorial/applying-styles-with-stylesheets.md +++ b/docs/designers-developers/developers/tutorials/block-tutorial/applying-styles-with-stylesheets.md @@ -14,7 +14,7 @@ registerBlockType( 'gutenberg-examples/example-02-stylesheets', { icon: 'universal-access-alt', - category: 'layout', + category: 'design', example: {}, @@ -35,7 +35,7 @@ registerBlockType( 'gutenberg-examples/example-02-stylesheets', { blocks.registerBlockType( 'gutenberg-examples/example-02-stylesheets', { title: 'Example: Stylesheets', icon: 'universal-access-alt', - category: 'layout', + category: 'design', example: {}, edit: function( props ) { return el( diff --git a/docs/designers-developers/developers/tutorials/block-tutorial/block-controls-toolbar-and-sidebar.md b/docs/designers-developers/developers/tutorials/block-tutorial/block-controls-toolbar-and-sidebar.md index 423a3b6aa8248d..6d9268c3d225fe 100644 --- a/docs/designers-developers/developers/tutorials/block-tutorial/block-controls-toolbar-and-sidebar.md +++ b/docs/designers-developers/developers/tutorials/block-tutorial/block-controls-toolbar-and-sidebar.md @@ -24,7 +24,7 @@ import { registerBlockType( 'gutenberg-examples/example-04-controls-esnext', { title: 'Example: Controls (esnext)', icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { type: 'array', @@ -101,7 +101,7 @@ registerBlockType( 'gutenberg-examples/example-04-controls-esnext', { blocks.registerBlockType( 'gutenberg-examples/example-04-controls', { title: 'Example: Controls', icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { diff --git a/docs/designers-developers/developers/tutorials/block-tutorial/introducing-attributes-and-editable-fields.md b/docs/designers-developers/developers/tutorials/block-tutorial/introducing-attributes-and-editable-fields.md index d3000cc9c4c993..0956c6bdd9fa2e 100644 --- a/docs/designers-developers/developers/tutorials/block-tutorial/introducing-attributes-and-editable-fields.md +++ b/docs/designers-developers/developers/tutorials/block-tutorial/introducing-attributes-and-editable-fields.md @@ -61,7 +61,7 @@ import { RichText } from '@wordpress/block-editor'; registerBlockType( 'gutenberg-examples/example-03-editable-esnext', { title: 'Example: Editable (esnext)', icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { type: 'array', @@ -102,7 +102,7 @@ registerBlockType( 'gutenberg-examples/example-03-editable-esnext', { blocks.registerBlockType( 'gutenberg-examples/example-03-editable', { title: 'Example: Editable', icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { diff --git a/docs/designers-developers/developers/tutorials/block-tutorial/nested-blocks-inner-blocks.md b/docs/designers-developers/developers/tutorials/block-tutorial/nested-blocks-inner-blocks.md index 41748c56995bfe..27d6087cabfb2a 100644 --- a/docs/designers-developers/developers/tutorials/block-tutorial/nested-blocks-inner-blocks.md +++ b/docs/designers-developers/developers/tutorials/block-tutorial/nested-blocks-inner-blocks.md @@ -15,7 +15,7 @@ Here is the basic InnerBlocks usage. blocks.registerBlockType( 'gutenberg-examples/example-06', { title: 'Example: Inner Blocks', - category: 'layout', + category: 'design', edit: function( props ) { return el( diff --git a/docs/designers-developers/developers/tutorials/block-tutorial/writing-your-first-block-type.md b/docs/designers-developers/developers/tutorials/block-tutorial/writing-your-first-block-type.md index c25943645c50d2..6ba06f0981009a 100644 --- a/docs/designers-developers/developers/tutorials/block-tutorial/writing-your-first-block-type.md +++ b/docs/designers-developers/developers/tutorials/block-tutorial/writing-your-first-block-type.md @@ -61,7 +61,7 @@ const blockStyle = { registerBlockType( 'gutenberg-examples/example-01-basic-esnext', { title: 'Example: Basic (esnext)', icon: 'universal-access-alt', - category: 'layout', + category: 'design', example: {}, edit() { return
Hello World, step 1 (from the editor).
; @@ -85,7 +85,7 @@ registerBlockType( 'gutenberg-examples/example-01-basic-esnext', { blocks.registerBlockType( 'gutenberg-examples/example-01-basic', { title: 'Example: Basic', icon: 'universal-access-alt', - category: 'layout', + category: 'design', example: {}, edit: function() { return el( diff --git a/docs/designers-developers/developers/tutorials/javascript/js-build-setup.md b/docs/designers-developers/developers/tutorials/javascript/js-build-setup.md index c1a9214ee5e754..c917d1e59e7965 100644 --- a/docs/designers-developers/developers/tutorials/javascript/js-build-setup.md +++ b/docs/designers-developers/developers/tutorials/javascript/js-build-setup.md @@ -107,7 +107,7 @@ import { registerBlockType } from '@wordpress/blocks'; registerBlockType( 'myguten/test-block', { title: 'Basic Example', icon: 'smiley', - category: 'layout', + category: 'design', edit: () =>
Hola, mundo!
, save: () =>
Hola, mundo!
, } ); diff --git a/docs/designers-developers/developers/tutorials/metabox/meta-block-3-add.md b/docs/designers-developers/developers/tutorials/metabox/meta-block-3-add.md index 9d5eaf2e403e5c..726731f234f065 100644 --- a/docs/designers-developers/developers/tutorials/metabox/meta-block-3-add.md +++ b/docs/designers-developers/developers/tutorials/metabox/meta-block-3-add.md @@ -21,7 +21,7 @@ Add this code to your JavaScript file (this tutorial will call the file `myguten registerBlockType( 'myguten/meta-block', { title: 'Meta Block', icon: 'smiley', - category: 'common', + category: 'text', edit: function( props ) { var className = props.className; @@ -82,7 +82,7 @@ import { useEntityProp } from '@wordpress/core-data'; registerBlockType( 'myguten/meta-block', { title: 'Meta Block', icon: 'smiley', - category: 'common', + category: 'text', edit( { className, setAttributes, attributes } ) { const postType = useSelect( diff --git a/docs/rfc/block-registration.md b/docs/rfc/block-registration.md index 7455ed6b2f0398..4ade195f11b3b5 100644 --- a/docs/rfc/block-registration.md +++ b/docs/rfc/block-registration.md @@ -64,7 +64,7 @@ To register a new block type, start by creating a `block.json` file. This file: { "name": "my-plugin/notice", "title": "Notice", - "category": "common", + "category": "text", "parent": [ "core/group" ], "icon": "star", "description": "Shows warning, error or success notices ...", @@ -134,7 +134,7 @@ This is the display title for your block, which can be translated with our trans * Property: `category` ```json -{ "category": "common" } +{ "category": "text" } ``` Blocks are grouped into categories to help users browse and discover them. @@ -149,7 +149,7 @@ The core provided categories are: Plugins and Themes can also register [custom block categories](/docs/designers-developers/developers/filters/block-filters.md#managing-block-categories). -An implementation should expect and tolerate unknown categories, providing some reasonable fallback behavior (e.g. a "common" category). +An implementation should expect and tolerate unknown categories, providing some reasonable fallback behavior (e.g. a "text" category). ### Parent diff --git a/lib/compat.php b/lib/compat.php index 420cec1d39649d..9dd224adb2f19e 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -168,6 +168,67 @@ function gutenberg_get_post_from_context() { return get_post(); } +/** + * Filters default block categories to substitute legacy category names with new + * block categories. + * + * This can be removed when plugin support requires WordPress 5.5.0+. + * + * @see https://core.trac.wordpress.org/ticket/50278 + * + * @param array[] $default_categories Array of block categories. + * + * @return array[] Filtered block categories. + */ +function gutenberg_replace_default_block_categories( $default_categories ) { + $substitution = array( + 'common' => array( + 'slug' => 'text', + 'title' => __( 'Text', 'gutenberg' ), + 'icon' => null, + ), + 'formatting' => array( + 'slug' => 'media', + 'title' => __( 'Media', 'gutenberg' ), + 'icon' => null, + ), + 'layout' => array( + 'slug' => 'design', + 'title' => __( 'Design', 'gutenberg' ), + 'icon' => null, + ), + ); + + // Loop default categories to perform in-place substitution by legacy slug. + foreach ( $default_categories as $i => $default_category ) { + $slug = $default_category['slug']; + if ( isset( $substitution[ $slug ] ) ) { + $default_categories[ $i ] = $substitution[ $slug ]; + unset( $substitution[ $slug ] ); + } + } + + /* + * At this point, `$substitution` should contain only the categories which + * could not be in-place substituted with a default category, likely in the + * case that core has since been updated to use the default categories. + * Check to verify they exist. + */ + $default_category_slugs = wp_list_pluck( $default_categories, 'slug' ); + foreach ( $substitution as $i => $substitute_category ) { + if ( in_array( $substitute_category['slug'], $default_category_slugs, true ) ) { + unset( $substitution[ $i ] ); + } + } + + /* + * Any substitutes remaining should be appended, as they are not yet + * assigned in the default categories array. + */ + return array_merge( $default_categories, array_values( $substitution ) ); +} +add_filter( 'block_categories', 'gutenberg_replace_default_block_categories' ); + /** * Shim that hooks into `pre_render_block` so as to override `render_block` with * a function that assigns block context. diff --git a/packages/block-editor/src/autocompleters/test/block.js b/packages/block-editor/src/autocompleters/test/block.js index 91a7c164cf396e..11437cf1714984 100644 --- a/packages/block-editor/src/autocompleters/test/block.js +++ b/packages/block-editor/src/autocompleters/test/block.js @@ -73,14 +73,14 @@ describe( 'block', () => { name: 'core/foo', title: 'foo', keywords: [ 'foo-keyword-1', 'foo-keyword-2' ], - category: 'formatting', + category: 'design', }; const inserterItemWithTitleAndEmptyKeywords = { name: 'core/bar', title: 'bar', // Intentionally empty keyword list keywords: [], - category: 'common', + category: 'text', }; const inserterItemWithTitleAndUndefinedKeywords = { name: 'core/baz', @@ -91,12 +91,12 @@ describe( 'block', () => { expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndKeywords ) - ).toEqual( [ 'formatting', 'foo-keyword-1', 'foo-keyword-2', 'foo' ] ); + ).toEqual( [ 'design', 'foo-keyword-1', 'foo-keyword-2', 'foo' ] ); expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndEmptyKeywords ) - ).toEqual( [ 'common', 'bar' ] ); + ).toEqual( [ 'text', 'bar' ] ); expect( blockCompleter.getOptionKeywords( inserterItemWithTitleAndUndefinedKeywords diff --git a/packages/block-editor/src/components/block-edit/test/edit.js b/packages/block-editor/src/components/block-edit/test/edit.js index 6c273de2351961..8c8c312bbe7c3a 100644 --- a/packages/block-editor/src/components/block-edit/test/edit.js +++ b/packages/block-editor/src/components/block-edit/test/edit.js @@ -36,7 +36,7 @@ describe( 'Edit', () => { const edit = () =>
; registerBlockType( 'core/test-block', { save: noop, - category: 'common', + category: 'text', title: 'block title', edit, } ); @@ -50,7 +50,7 @@ describe( 'Edit', () => { const save = () =>
; registerBlockType( 'core/test-block', { save, - category: 'common', + category: 'text', title: 'block title', } ); @@ -67,7 +67,7 @@ describe( 'Edit', () => { registerBlockType( 'core/test-block', { edit, save: noop, - category: 'common', + category: 'text', title: 'block title', } ); @@ -84,7 +84,7 @@ describe( 'Edit', () => { it( 'should assign context', () => { const edit = ( { context } ) => context.value; registerBlockType( 'core/test-block', { - category: 'common', + category: 'text', title: 'block title', context: [ 'value' ], edit, @@ -104,7 +104,7 @@ describe( 'Edit', () => { it( 'should assign context', () => { const edit = ( { context } ) => context.value; registerBlockType( 'core/test-block', { - category: 'common', + category: 'text', title: 'block title', context: [ 'value' ], supports: { diff --git a/packages/block-editor/src/components/block-switcher/test/index.js b/packages/block-editor/src/components/block-switcher/test/index.js index ce4d0246a60901..5bef2c5a52ff45 100644 --- a/packages/block-editor/src/components/block-switcher/test/index.js +++ b/packages/block-editor/src/components/block-switcher/test/index.js @@ -49,7 +49,7 @@ describe( 'BlockSwitcher', () => { beforeAll( () => { registerBlockType( 'core/heading', { - category: 'common', + category: 'text', title: 'Heading', edit: () => {}, save: () => {}, @@ -71,7 +71,7 @@ describe( 'BlockSwitcher', () => { } ); registerBlockType( 'core/paragraph', { - category: 'common', + category: 'text', title: 'Paragraph', edit: () => {}, save: () => {}, diff --git a/packages/block-editor/src/components/inner-blocks/test/index.js b/packages/block-editor/src/components/inner-blocks/test/index.js index ac242fe9ddb112..04018b65eda35c 100644 --- a/packages/block-editor/src/components/inner-blocks/test/index.js +++ b/packages/block-editor/src/components/inner-blocks/test/index.js @@ -25,7 +25,7 @@ describe( 'InnerBlocks', () => { it( 'should return element as string, with inner blocks', () => { registerBlockType( 'core/fruit', { - category: 'common', + category: 'text', title: 'fruit', @@ -88,7 +88,7 @@ describe( 'InnerBlocks', () => {

); }, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block', blockType ); diff --git a/packages/block-editor/src/components/inserter/test/block-list.js b/packages/block-editor/src/components/inserter/test/block-list.js index 5e51597c4c64b6..2e3bf78b3ffb5f 100644 --- a/packages/block-editor/src/components/inserter/test/block-list.js +++ b/packages/block-editor/src/components/inserter/test/block-list.js @@ -104,7 +104,7 @@ describe( 'InserterMenu', () => { expect( embedTabTitle.textContent ).toBe( 'Embeds' ); expect( blocks ).toHaveLength( 2 ); expect( blocks[ 0 ].textContent ).toBe( 'YouTube' ); - expect( blocks[ 1 ].textContent ).toBe( 'A Text Embed' ); + expect( blocks[ 1 ].textContent ).toBe( 'A Paragraph Embed' ); assertNoResultsMessageNotToBePresent( container ); } ); @@ -140,10 +140,10 @@ describe( 'InserterMenu', () => { '.block-editor-block-types-list__item-title' ); - expect( commonTabTitle.textContent ).toBe( 'Common blocks' ); + expect( commonTabTitle.textContent ).toBe( 'Text' ); expect( blocks ).toHaveLength( 3 ); - expect( blocks[ 0 ].textContent ).toBe( 'Text' ); - expect( blocks[ 1 ].textContent ).toBe( 'Advanced Text' ); + expect( blocks[ 0 ].textContent ).toBe( 'Paragraph' ); + expect( blocks[ 1 ].textContent ).toBe( 'Advanced Paragraph' ); expect( blocks[ 2 ].textContent ).toBe( 'Some Other Block' ); assertNoResultsMessageNotToBePresent( container ); @@ -164,7 +164,7 @@ describe( 'InserterMenu', () => { it( 'should allow searching for items', () => { const { container } = render( - + ); const matchingCategories = container.querySelectorAll( @@ -172,7 +172,7 @@ describe( 'InserterMenu', () => { ); expect( matchingCategories ).toHaveLength( 3 ); - expect( matchingCategories[ 0 ].textContent ).toBe( 'Common blocks' ); + expect( matchingCategories[ 0 ].textContent ).toBe( 'Text' ); expect( matchingCategories[ 1 ].textContent ).toBe( 'Embeds' ); expect( matchingCategories[ 2 ].textContent ).toBe( 'Core' ); // "Core" namespace collection @@ -186,13 +186,13 @@ describe( 'InserterMenu', () => { expect( debouncedSpeak ).toHaveBeenCalledWith( '3 results found.' ); // Default block results. - expect( blocks[ 0 ].textContent ).toBe( 'Text' ); - expect( blocks[ 1 ].textContent ).toBe( 'Advanced Text' ); - expect( blocks[ 2 ].textContent ).toBe( 'A Text Embed' ); + expect( blocks[ 0 ].textContent ).toBe( 'Paragraph' ); + expect( blocks[ 1 ].textContent ).toBe( 'Advanced Paragraph' ); + expect( blocks[ 2 ].textContent ).toBe( 'A Paragraph Embed' ); // Collection results. - expect( blocks[ 3 ].textContent ).toBe( 'Text' ); - expect( blocks[ 4 ].textContent ).toBe( 'Advanced Text' ); + expect( blocks[ 3 ].textContent ).toBe( 'Paragraph' ); + expect( blocks[ 4 ].textContent ).toBe( 'Advanced Paragraph' ); assertNoResultsMessageNotToBePresent( container ); } ); @@ -243,7 +243,7 @@ describe( 'InserterMenu', () => { it( 'should trim whitespace of search terms', () => { const { container } = render( - + ); const matchingCategories = container.querySelectorAll( @@ -251,7 +251,7 @@ describe( 'InserterMenu', () => { ); expect( matchingCategories ).toHaveLength( 3 ); - expect( matchingCategories[ 0 ].textContent ).toBe( 'Common blocks' ); + expect( matchingCategories[ 0 ].textContent ).toBe( 'Text' ); expect( matchingCategories[ 1 ].textContent ).toBe( 'Embeds' ); const blocks = container.querySelectorAll( @@ -259,9 +259,9 @@ describe( 'InserterMenu', () => { ); expect( blocks ).toHaveLength( 5 ); - expect( blocks[ 0 ].textContent ).toBe( 'Text' ); - expect( blocks[ 1 ].textContent ).toBe( 'Advanced Text' ); - expect( blocks[ 2 ].textContent ).toBe( 'A Text Embed' ); + expect( blocks[ 0 ].textContent ).toBe( 'Paragraph' ); + expect( blocks[ 1 ].textContent ).toBe( 'Advanced Paragraph' ); + expect( blocks[ 2 ].textContent ).toBe( 'A Paragraph Embed' ); assertNoResultsMessageNotToBePresent( container ); } ); diff --git a/packages/block-editor/src/components/inserter/test/fixtures/index.js b/packages/block-editor/src/components/inserter/test/fixtures/index.js index e0290fa8bed3ce..061d2948d675dd 100644 --- a/packages/block-editor/src/components/inserter/test/fixtures/index.js +++ b/packages/block-editor/src/components/inserter/test/fixtures/index.js @@ -1,7 +1,7 @@ export const categories = [ - { slug: 'common', title: 'Common blocks' }, - { slug: 'formatting', title: 'Formatting' }, - { slug: 'layout', title: 'Layout elements' }, + { slug: 'text', title: 'Text' }, + { slug: 'media', title: 'Media' }, + { slug: 'design', title: 'Design' }, { slug: 'widgets', title: 'Widgets' }, { slug: 'embed', title: 'Embeds' }, { slug: 'reusable', title: 'Reusable blocks' }, @@ -14,12 +14,12 @@ export const collections = { }, }; -export const textItem = { - id: 'core/text-block', - name: 'core/text-block', +export const paragraphItem = { + id: 'core/paragraph-block', + name: 'core/paragraph-block', initialAttributes: {}, - title: 'Text', - category: 'common', + title: 'Paragraph', + category: 'text', isDisabled: false, utility: 1, }; @@ -48,12 +48,12 @@ export const withVariationsItem = { ], }; -export const advancedTextItem = { - id: 'core/advanced-text-block', - name: 'core/advanced-text-block', +export const advancedParagraphItem = { + id: 'core/advanced-paragraph-block', + name: 'core/advanced-paragraph-block', initialAttributes: {}, - title: 'Advanced Text', - category: 'common', + title: 'Advanced Paragraph', + category: 'text', isDisabled: false, utility: 1, }; @@ -63,7 +63,7 @@ export const someOtherItem = { name: 'core/some-other-block', initialAttributes: {}, title: 'Some Other Block', - category: 'common', + category: 'text', isDisabled: false, utility: 1, }; @@ -73,7 +73,7 @@ export const moreItem = { name: 'core/more-block', initialAttributes: {}, title: 'More', - category: 'layout', + category: 'design', isDisabled: true, utility: 1, }; @@ -89,11 +89,11 @@ export const youtubeItem = { utility: 1, }; -export const textEmbedItem = { - id: 'core-embed/a-text-embed', - name: 'core-embed/a-text-embed', +export const paragraphEmbedItem = { + id: 'core-embed/a-paragraph-embed', + name: 'core-embed/a-paragraph-embed', initialAttributes: {}, - title: 'A Text Embed', + title: 'A Paragraph Embed', category: 'embed', isDisabled: false, utility: 1, @@ -110,12 +110,12 @@ export const reusableItem = { }; export default [ - textItem, withVariationsItem, - advancedTextItem, + paragraphItem, + advancedParagraphItem, someOtherItem, moreItem, youtubeItem, - textEmbedItem, + paragraphEmbedItem, reusableItem, ]; diff --git a/packages/block-editor/src/components/inserter/test/search-items.js b/packages/block-editor/src/components/inserter/test/search-items.js index f4b24b14a28a46..1db4578daedfd8 100644 --- a/packages/block-editor/src/components/inserter/test/search-items.js +++ b/packages/block-editor/src/components/inserter/test/search-items.js @@ -4,11 +4,11 @@ import items, { categories, collections, - textItem, - advancedTextItem, + paragraphItem, + advancedParagraphItem, moreItem, youtubeItem, - textEmbedItem, + paragraphEmbedItem, } from './fixtures'; import { normalizeSearchTerm, searchBlockItems } from '../search-items'; @@ -45,8 +45,12 @@ describe( 'searchBlockItems', () => { it( 'should search items using the title ignoring case', () => { expect( - searchBlockItems( items, categories, collections, 'TEXT' ) - ).toEqual( [ textItem, advancedTextItem, textEmbedItem ] ); + searchBlockItems( items, categories, collections, 'paragraph' ) + ).toEqual( [ + paragraphItem, + advancedParagraphItem, + paragraphEmbedItem, + ] ); } ); it( 'should search items using the keywords and partial terms', () => { @@ -57,7 +61,7 @@ describe( 'searchBlockItems', () => { it( 'should search items using the categories', () => { expect( - searchBlockItems( items, categories, collections, 'LAYOUT' ) + searchBlockItems( items, categories, collections, 'DESIGN' ) ).toEqual( [ moreItem ] ); } ); diff --git a/packages/block-editor/src/components/inspector-controls/README.md b/packages/block-editor/src/components/inspector-controls/README.md index 50719c8ab672a5..b43a4fbe7fd267 100644 --- a/packages/block-editor/src/components/inspector-controls/README.md +++ b/packages/block-editor/src/components/inspector-controls/README.md @@ -25,7 +25,7 @@ registerBlockType( 'my-plugin/inspector-controls-example', { icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { @@ -253,7 +253,7 @@ registerBlockType( 'my-plugin/inspector-controls-example', { icon: 'universal-access-alt', - category: 'layout', + category: 'design', attributes: { content: { diff --git a/packages/block-editor/src/hooks/test/align.js b/packages/block-editor/src/hooks/test/align.js index 9242cff172eabb..3feb9473433b34 100644 --- a/packages/block-editor/src/hooks/test/align.js +++ b/packages/block-editor/src/hooks/test/align.js @@ -28,7 +28,7 @@ import { describe( 'align', () => { const blockSettings = { save: noop, - category: 'common', + category: 'text', title: 'block title', }; diff --git a/packages/block-editor/src/hooks/test/custom-class-name.js b/packages/block-editor/src/hooks/test/custom-class-name.js index 8429a657859bde..d01e1a965a8744 100644 --- a/packages/block-editor/src/hooks/test/custom-class-name.js +++ b/packages/block-editor/src/hooks/test/custom-class-name.js @@ -11,13 +11,13 @@ import { getHTMLRootElementClasses } from '../custom-class-name'; describe( 'custom className', () => { const blockSettings = { save: () =>
, - category: 'common', + category: 'text', title: 'block title', }; const dynamicBlockSettings = { save: () => null, - category: 'common', + category: 'text', title: 'block title', }; diff --git a/packages/block-editor/src/hooks/test/generated-class-name.js b/packages/block-editor/src/hooks/test/generated-class-name.js index 1bf447c48ce12c..7de89032719da5 100644 --- a/packages/block-editor/src/hooks/test/generated-class-name.js +++ b/packages/block-editor/src/hooks/test/generated-class-name.js @@ -17,7 +17,7 @@ describe( 'generated className', () => { const blockSettings = { name: 'chicken/ribs', save: noop, - category: 'common', + category: 'text', title: 'block title', }; diff --git a/packages/block-editor/src/hooks/test/utils.js b/packages/block-editor/src/hooks/test/utils.js index bb4d496ff477b2..adaa37f4816c63 100644 --- a/packages/block-editor/src/hooks/test/utils.js +++ b/packages/block-editor/src/hooks/test/utils.js @@ -16,7 +16,7 @@ import '../anchor'; describe( 'anchor', () => { const blockSettings = { save: noop, - category: 'common', + category: 'text', title: 'block title', }; diff --git a/packages/block-editor/src/store/test/effects.js b/packages/block-editor/src/store/test/effects.js index 9b8702bb3342c5..1832e7fe2a8292 100644 --- a/packages/block-editor/src/store/test/effects.js +++ b/packages/block-editor/src/store/test/effects.js @@ -39,7 +39,7 @@ describe( 'effects', () => { content: {}, }, save: () => 'Saved', - category: 'common', + category: 'text', title: 'block title', }; @@ -93,7 +93,7 @@ describe( 'effects', () => { }; }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); const blockA = deepFreeze( { @@ -165,7 +165,7 @@ describe( 'effects', () => { }; }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); registerBlockType( 'core/test-block-2', defaultBlockSettings ); @@ -216,7 +216,7 @@ describe( 'effects', () => { }; }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); registerBlockType( 'core/test-block-2', { @@ -239,7 +239,7 @@ describe( 'effects', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'test block 2', } ); const blockA = deepFreeze( { diff --git a/packages/block-editor/src/store/test/reducer.js b/packages/block-editor/src/store/test/reducer.js index fadf7b3f34ba9a..aa1b9fe8bcee97 100644 --- a/packages/block-editor/src/store/test/reducer.js +++ b/packages/block-editor/src/store/test/reducer.js @@ -169,7 +169,7 @@ describe( 'state', () => { registerBlockType( 'core/test-block', { save: noop, edit: noop, - category: 'common', + category: 'text', title: 'test block', } ); } ); @@ -183,13 +183,13 @@ describe( 'state', () => { registerBlockType( 'core/test-parent-block', { save: noop, edit: noop, - category: 'common', + category: 'text', title: 'test parent block', } ); registerBlockType( 'core/test-child-block', { save: noop, edit: noop, - category: 'common', + category: 'text', title: 'test child block 1', attributes: { attr: { diff --git a/packages/block-editor/src/store/test/selectors.js b/packages/block-editor/src/store/test/selectors.js index ad2311344b9ba1..9953f1c1188585 100644 --- a/packages/block-editor/src/store/test/selectors.js +++ b/packages/block-editor/src/store/test/selectors.js @@ -84,7 +84,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-a', { save: ( props ) => props.attributes.text, - category: 'formatting', + category: 'design', title: 'Test Block A', icon: 'test', keywords: [ 'testing' ], @@ -92,7 +92,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-b', { save: ( props ) => props.attributes.text, - category: 'common', + category: 'text', title: 'Test Block B', icon: 'test', keywords: [ 'testing' ], @@ -103,7 +103,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-c', { save: ( props ) => props.attributes.text, - category: 'common', + category: 'text', title: 'Test Block C', icon: 'test', keywords: [ 'testing' ], @@ -112,7 +112,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-freeform', { save: ( props ) => { props.attributes.content }, - category: 'common', + category: 'text', title: 'Test Freeform Content Handler', icon: 'test', attributes: { @@ -124,7 +124,7 @@ describe( 'selectors', () => { registerBlockType( 'core/post-content-child', { save: () => null, - category: 'common', + category: 'text', title: 'Test Block Post Content Child', icon: 'test', keywords: [ 'testing' ], @@ -2316,7 +2316,7 @@ describe( 'selectors', () => { icon: { src: 'test', }, - category: 'formatting', + category: 'design', keywords: [ 'testing' ], variations: [], isDisabled: false, diff --git a/packages/block-library/src/audio/block.json b/packages/block-library/src/audio/block.json index 685610017ad260..31c6c8f9efd8b9 100644 --- a/packages/block-library/src/audio/block.json +++ b/packages/block-library/src/audio/block.json @@ -1,6 +1,6 @@ { "name": "core/audio", - "category": "common", + "category": "media", "attributes": { "src": { "type": "string", diff --git a/packages/block-library/src/button/block.json b/packages/block-library/src/button/block.json index a342ad63c9ff21..b2af0f5a4c4c15 100644 --- a/packages/block-library/src/button/block.json +++ b/packages/block-library/src/button/block.json @@ -1,6 +1,6 @@ { "name": "core/button", - "category": "layout", + "category": "design", "parent": [ "core/buttons" ], diff --git a/packages/block-library/src/buttons/block.json b/packages/block-library/src/buttons/block.json index 93c7eea7015a16..4004a9591a99e6 100644 --- a/packages/block-library/src/buttons/block.json +++ b/packages/block-library/src/buttons/block.json @@ -1,6 +1,6 @@ { "name": "core/buttons", - "category": "layout", + "category": "design", "supports": { "align": true, "alignWide": false, diff --git a/packages/block-library/src/classic/block.json b/packages/block-library/src/classic/block.json index 7cbeb054412929..63d2c9f37ee566 100644 --- a/packages/block-library/src/classic/block.json +++ b/packages/block-library/src/classic/block.json @@ -1,6 +1,6 @@ { "name": "core/freeform", - "category": "formatting", + "category": "text", "attributes": { "content": { "type": "string", diff --git a/packages/block-library/src/code/block.json b/packages/block-library/src/code/block.json index 439190819d0118..d7cab6cf3424be 100644 --- a/packages/block-library/src/code/block.json +++ b/packages/block-library/src/code/block.json @@ -1,6 +1,6 @@ { "name": "core/code", - "category": "formatting", + "category": "text", "attributes": { "content": { "type": "string", diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index a0a6514998cb90..328dbb6201e6a1 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -1,6 +1,6 @@ { "name": "core/column", - "category": "common", + "category": "text", "parent": [ "core/columns" ], diff --git a/packages/block-library/src/columns/block.json b/packages/block-library/src/columns/block.json index 32081f92b1a484..a27c693b8134b8 100644 --- a/packages/block-library/src/columns/block.json +++ b/packages/block-library/src/columns/block.json @@ -1,6 +1,6 @@ { "name": "core/columns", - "category": "layout", + "category": "design", "attributes": { "verticalAlignment": { "type": "string" diff --git a/packages/block-library/src/cover/block.json b/packages/block-library/src/cover/block.json index c0ef0dcd5eb086..624d5509f60661 100644 --- a/packages/block-library/src/cover/block.json +++ b/packages/block-library/src/cover/block.json @@ -1,6 +1,6 @@ { "name": "core/cover", - "category": "common", + "category": "media", "attributes": { "url": { "type": "string" diff --git a/packages/block-library/src/file/block.json b/packages/block-library/src/file/block.json index 55e2f9114be0a7..664ec1154a4d00 100644 --- a/packages/block-library/src/file/block.json +++ b/packages/block-library/src/file/block.json @@ -1,6 +1,6 @@ { "name": "core/file", - "category": "common", + "category": "media", "attributes": { "id": { "type": "number" diff --git a/packages/block-library/src/gallery/block.json b/packages/block-library/src/gallery/block.json index b5f6115187ec51..c16a21e734f2c7 100644 --- a/packages/block-library/src/gallery/block.json +++ b/packages/block-library/src/gallery/block.json @@ -1,6 +1,6 @@ { "name": "core/gallery", - "category": "common", + "category": "media", "attributes": { "images": { "type": "array", diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json index c9e6415e1342f2..ab4e81aa334426 100644 --- a/packages/block-library/src/group/block.json +++ b/packages/block-library/src/group/block.json @@ -1,6 +1,6 @@ { "name": "core/group", - "category": "layout", + "category": "design", "attributes": { "tagName": { "type": "string", diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index 0068d10d793dfc..eb367c9c4bf735 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -1,6 +1,6 @@ { "name": "core/heading", - "category": "common", + "category": "text", "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/html/block.json b/packages/block-library/src/html/block.json index 9b713268b265f7..b9624b4b3ef1f0 100644 --- a/packages/block-library/src/html/block.json +++ b/packages/block-library/src/html/block.json @@ -1,6 +1,6 @@ { "name": "core/html", - "category": "formatting", + "category": "widgets", "attributes": { "content": { "type": "string", diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index 797f17822d790e..d403ec3827f81a 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -1,6 +1,6 @@ { "name": "core/image", - "category": "common", + "category": "media", "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/list/block.json b/packages/block-library/src/list/block.json index 201c6ab4749375..e195a1b6f4c191 100644 --- a/packages/block-library/src/list/block.json +++ b/packages/block-library/src/list/block.json @@ -1,6 +1,6 @@ { "name": "core/list", - "category": "common", + "category": "text", "attributes": { "ordered": { "type": "boolean", diff --git a/packages/block-library/src/media-text/block.json b/packages/block-library/src/media-text/block.json index ab046cb09c38ca..71a706fe1f3a69 100644 --- a/packages/block-library/src/media-text/block.json +++ b/packages/block-library/src/media-text/block.json @@ -1,6 +1,6 @@ { "name": "core/media-text", - "category": "layout", + "category": "media", "attributes": { "align": { "type": "string", diff --git a/packages/block-library/src/missing/block.json b/packages/block-library/src/missing/block.json index 5b5677b06934d1..57a246966d713c 100644 --- a/packages/block-library/src/missing/block.json +++ b/packages/block-library/src/missing/block.json @@ -1,6 +1,6 @@ { "name": "core/missing", - "category": "common", + "category": "text", "attributes": { "originalName": { "type": "string" diff --git a/packages/block-library/src/more/block.json b/packages/block-library/src/more/block.json index bed9393f543886..7697b06ac403e8 100644 --- a/packages/block-library/src/more/block.json +++ b/packages/block-library/src/more/block.json @@ -1,6 +1,6 @@ { "name": "core/more", - "category": "layout", + "category": "design", "attributes": { "customText": { "type": "string" diff --git a/packages/block-library/src/navigation-link/block.json b/packages/block-library/src/navigation-link/block.json index bf3b04e5884e77..b6be7a4206e4a8 100644 --- a/packages/block-library/src/navigation-link/block.json +++ b/packages/block-library/src/navigation-link/block.json @@ -1,6 +1,6 @@ { "name": "core/navigation-link", - "category": "layout", + "category": "design", "parent": [ "core/navigation" ], diff --git a/packages/block-library/src/navigation/block.json b/packages/block-library/src/navigation/block.json index 8eb6f9a0d74e72..2da6cd5b3fa207 100644 --- a/packages/block-library/src/navigation/block.json +++ b/packages/block-library/src/navigation/block.json @@ -1,6 +1,6 @@ { "name": "core/navigation", - "category": "layout", + "category": "design", "attributes": { "orientation": { "type": "string" diff --git a/packages/block-library/src/nextpage/block.json b/packages/block-library/src/nextpage/block.json index 1344807727186b..ed9293b2a9b95a 100644 --- a/packages/block-library/src/nextpage/block.json +++ b/packages/block-library/src/nextpage/block.json @@ -1,6 +1,6 @@ { "name": "core/nextpage", - "category": "layout", + "category": "design", "parent": [ "core/post-content" ], "supports": { "customClassName": false, diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index 4454e09926a216..ae17bc373f2062 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -1,6 +1,6 @@ { "name": "core/paragraph", - "category": "common", + "category": "text", "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/post-author/block.json b/packages/block-library/src/post-author/block.json index ee77d2aff0e0fa..6a59b0fe5f1b32 100644 --- a/packages/block-library/src/post-author/block.json +++ b/packages/block-library/src/post-author/block.json @@ -1,6 +1,6 @@ { "name": "core/post-author", - "category": "layout", + "category": "design", "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/post-comments-count/block.json b/packages/block-library/src/post-comments-count/block.json index d975f4a0a9f79a..f41d613f2e6b44 100644 --- a/packages/block-library/src/post-comments-count/block.json +++ b/packages/block-library/src/post-comments-count/block.json @@ -1,6 +1,6 @@ { "name": "core/post-comments-count", - "category": "layout", + "category": "design", "context": [ "postId" ], diff --git a/packages/block-library/src/post-comments-form/block.json b/packages/block-library/src/post-comments-form/block.json index ab6fb1a89d7dce..cbf6c6b7199b56 100644 --- a/packages/block-library/src/post-comments-form/block.json +++ b/packages/block-library/src/post-comments-form/block.json @@ -1,6 +1,6 @@ { "name": "core/post-comments-form", - "category": "layout", + "category": "design", "context": [ "postId" ], diff --git a/packages/block-library/src/post-comments/block.json b/packages/block-library/src/post-comments/block.json index 5dd415e52f047d..ae0e5317336c5c 100644 --- a/packages/block-library/src/post-comments/block.json +++ b/packages/block-library/src/post-comments/block.json @@ -1,5 +1,5 @@ { "name": "core/post-comments", - "category": "layout", + "category": "design", "context": [ "postId" ] } diff --git a/packages/block-library/src/post-content/block.json b/packages/block-library/src/post-content/block.json index 3d978ec2f8baa5..c67f01f5054048 100644 --- a/packages/block-library/src/post-content/block.json +++ b/packages/block-library/src/post-content/block.json @@ -1,6 +1,6 @@ { "name": "core/post-content", - "category": "layout", + "category": "design", "context": [ "postId", "postType" diff --git a/packages/block-library/src/post-date/block.json b/packages/block-library/src/post-date/block.json index 85e26c63edd835..95bb439c0b33f8 100644 --- a/packages/block-library/src/post-date/block.json +++ b/packages/block-library/src/post-date/block.json @@ -1,6 +1,6 @@ { "name": "core/post-date", - "category": "layout", + "category": "design", "attributes": { "format": { "type": "string" diff --git a/packages/block-library/src/post-excerpt/block.json b/packages/block-library/src/post-excerpt/block.json index 62d67975a9628c..764d519bb5b037 100644 --- a/packages/block-library/src/post-excerpt/block.json +++ b/packages/block-library/src/post-excerpt/block.json @@ -1,6 +1,6 @@ { "name": "core/post-excerpt", - "category": "layout", + "category": "design", "attributes": { "wordCount": { "type": "number", diff --git a/packages/block-library/src/post-featured-image/block.json b/packages/block-library/src/post-featured-image/block.json index 12001131982e9f..29fb3d2141cec7 100644 --- a/packages/block-library/src/post-featured-image/block.json +++ b/packages/block-library/src/post-featured-image/block.json @@ -1,6 +1,6 @@ { "name": "core/post-featured-image", - "category": "layout", + "category": "design", "context": [ "postId" ], diff --git a/packages/block-library/src/post-tags/block.json b/packages/block-library/src/post-tags/block.json index 974a7cb42995ba..a3c624b012d74f 100644 --- a/packages/block-library/src/post-tags/block.json +++ b/packages/block-library/src/post-tags/block.json @@ -1,6 +1,6 @@ { "name": "core/post-tags", - "category": "layout", + "category": "design", "context": [ "postId" ], diff --git a/packages/block-library/src/post-title/block.json b/packages/block-library/src/post-title/block.json index a136fc1cc36211..4142f4cb1d887c 100644 --- a/packages/block-library/src/post-title/block.json +++ b/packages/block-library/src/post-title/block.json @@ -1,6 +1,6 @@ { "name": "core/post-title", - "category": "layout", + "category": "design", "context": [ "postId", "postType" diff --git a/packages/block-library/src/preformatted/block.json b/packages/block-library/src/preformatted/block.json index 9c5728fe07fb19..8220666e29b470 100644 --- a/packages/block-library/src/preformatted/block.json +++ b/packages/block-library/src/preformatted/block.json @@ -1,6 +1,6 @@ { "name": "core/preformatted", - "category": "formatting", + "category": "text", "attributes": { "content": { "type": "string", diff --git a/packages/block-library/src/pullquote/block.json b/packages/block-library/src/pullquote/block.json index 91a7d738ee9e83..08ebd960d5e282 100644 --- a/packages/block-library/src/pullquote/block.json +++ b/packages/block-library/src/pullquote/block.json @@ -1,6 +1,6 @@ { "name": "core/pullquote", - "category": "formatting", + "category": "text", "attributes": { "value": { "type": "string", diff --git a/packages/block-library/src/query-loop/block.json b/packages/block-library/src/query-loop/block.json index d3ba95c748cc58..a3f8beb410c292 100644 --- a/packages/block-library/src/query-loop/block.json +++ b/packages/block-library/src/query-loop/block.json @@ -1,6 +1,6 @@ { "name": "core/query-loop", - "category": "layout", + "category": "design", "context": [ "queryId", "query", diff --git a/packages/block-library/src/query-pagination/block.json b/packages/block-library/src/query-pagination/block.json index 6ac6538e601188..f18886c44e2781 100644 --- a/packages/block-library/src/query-pagination/block.json +++ b/packages/block-library/src/query-pagination/block.json @@ -1,6 +1,6 @@ { "name": "core/query-pagination", - "category": "layout", + "category": "design", "context": [ "queryId", "query", diff --git a/packages/block-library/src/query/block.json b/packages/block-library/src/query/block.json index 598f5e970a167c..0fdba78eee4132 100644 --- a/packages/block-library/src/query/block.json +++ b/packages/block-library/src/query/block.json @@ -1,6 +1,6 @@ { "name": "core/query", - "category": "layout", + "category": "design", "attributes": { "queryId": { "type": "number" diff --git a/packages/block-library/src/quote/block.json b/packages/block-library/src/quote/block.json index 05b07ad5bb2d19..fe0ebe158638f5 100644 --- a/packages/block-library/src/quote/block.json +++ b/packages/block-library/src/quote/block.json @@ -1,6 +1,6 @@ { "name": "core/quote", - "category": "common", + "category": "text", "attributes": { "value": { "type": "string", diff --git a/packages/block-library/src/separator/block.json b/packages/block-library/src/separator/block.json index 98bcbb9150609f..be78a415d8d0ec 100644 --- a/packages/block-library/src/separator/block.json +++ b/packages/block-library/src/separator/block.json @@ -1,6 +1,6 @@ { "name": "core/separator", - "category": "layout", + "category": "design", "attributes": { "color": { "type": "string" diff --git a/packages/block-library/src/site-title/block.json b/packages/block-library/src/site-title/block.json index 8b72dd854e4b24..7087b059fa0f1e 100644 --- a/packages/block-library/src/site-title/block.json +++ b/packages/block-library/src/site-title/block.json @@ -1,6 +1,6 @@ { "name": "core/site-title", - "category": "layout", + "category": "design", "attributes": { "level": { "type": "number", diff --git a/packages/block-library/src/spacer/block.json b/packages/block-library/src/spacer/block.json index c8240f036ca774..4719c6305b78ae 100644 --- a/packages/block-library/src/spacer/block.json +++ b/packages/block-library/src/spacer/block.json @@ -1,6 +1,6 @@ { "name": "core/spacer", - "category": "layout", + "category": "design", "attributes": { "height": { "type": "number", diff --git a/packages/block-library/src/subhead/block.json b/packages/block-library/src/subhead/block.json index 2c212d0db960e1..b79fdf6a8f9abd 100644 --- a/packages/block-library/src/subhead/block.json +++ b/packages/block-library/src/subhead/block.json @@ -1,6 +1,6 @@ { "name": "core/subhead", - "category": "common", + "category": "text", "attributes": { "align": { "type": "string" diff --git a/packages/block-library/src/table/block.json b/packages/block-library/src/table/block.json index 0d4b05794a74d1..81583f20508cbb 100644 --- a/packages/block-library/src/table/block.json +++ b/packages/block-library/src/table/block.json @@ -1,6 +1,6 @@ { "name": "core/table", - "category": "formatting", + "category": "text", "attributes": { "hasFixedLayout": { "type": "boolean", diff --git a/packages/block-library/src/template-part/block.json b/packages/block-library/src/template-part/block.json index 86807ca749e084..bd381e4dd073dc 100644 --- a/packages/block-library/src/template-part/block.json +++ b/packages/block-library/src/template-part/block.json @@ -1,6 +1,6 @@ { "name": "core/template-part", - "category": "layout", + "category": "design", "attributes": { "postId": { "type": "number" diff --git a/packages/block-library/src/text-columns/block.json b/packages/block-library/src/text-columns/block.json index 066d5ddc47da4d..32f1651d4044cb 100644 --- a/packages/block-library/src/text-columns/block.json +++ b/packages/block-library/src/text-columns/block.json @@ -1,7 +1,7 @@ { "name": "core/text-columns", "icon": "columns", - "category": "layout", + "category": "design", "attributes": { "content": { "type": "array", diff --git a/packages/block-library/src/verse/block.json b/packages/block-library/src/verse/block.json index f6c4191456e560..88fc168d452061 100644 --- a/packages/block-library/src/verse/block.json +++ b/packages/block-library/src/verse/block.json @@ -1,6 +1,6 @@ { "name": "core/verse", - "category": "formatting", + "category": "text", "attributes": { "content": { "type": "string", diff --git a/packages/block-library/src/video/block.json b/packages/block-library/src/video/block.json index 7b28b024d19e6e..4ac3cf98a71fdd 100644 --- a/packages/block-library/src/video/block.json +++ b/packages/block-library/src/video/block.json @@ -1,6 +1,6 @@ { "name": "core/video", - "category": "common", + "category": "media", "attributes": { "autoplay": { "type": "boolean", diff --git a/packages/blocks/README.md b/packages/blocks/README.md index d6cf2684deaea6..d49ee820b9ed9b 100644 --- a/packages/blocks/README.md +++ b/packages/blocks/README.md @@ -99,7 +99,7 @@ add_action( 'enqueue_block_editor_assets', 'random_image_enqueue_block_editor_as icon: 'format-image', - category: 'common', + category: 'text', attributes: { category: { @@ -354,7 +354,7 @@ Returns all the block categories. _Returns_ -- `Array`: Block categories. +- `Array`: Block categories. # **getChildBlockNames** @@ -687,7 +687,7 @@ Sets the block categories. _Parameters_ -- _categories_ `Array`: Block categories. +- _categories_ `Array`: Block categories. # **setDefaultBlockName** @@ -789,7 +789,7 @@ Updates a category. _Parameters_ - _slug_ `string`: Block category slug. -- _category_ `Object`: Object containing the category properties that should be updated. +- _category_ `WPBlockCategory`: Object containing the category properties that should be updated. # **withBlockContentContext** diff --git a/packages/blocks/src/api/categories.js b/packages/blocks/src/api/categories.js index 55945bc973bfcd..6e89b489960b0e 100644 --- a/packages/blocks/src/api/categories.js +++ b/packages/blocks/src/api/categories.js @@ -3,10 +3,12 @@ */ import { dispatch, select } from '@wordpress/data'; +/** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ + /** * Returns all the block categories. * - * @return {Object[]} Block categories. + * @return {WPBlockCategory[]} Block categories. */ export function getCategories() { return select( 'core/blocks' ).getCategories(); @@ -15,7 +17,7 @@ export function getCategories() { /** * Sets the block categories. * - * @param {Object[]} categories Block categories. + * @param {WPBlockCategory[]} categories Block categories. */ export function setCategories( categories ) { dispatch( 'core/blocks' ).setCategories( categories ); @@ -24,8 +26,9 @@ export function setCategories( categories ) { /** * Updates a category. * - * @param {string} slug Block category slug. - * @param {Object} category Object containing the category properties that should be updated. + * @param {string} slug Block category slug. + * @param {WPBlockCategory} category Object containing the category properties + * that should be updated. */ export function updateCategory( slug, category ) { dispatch( 'core/blocks' ).updateCategory( slug, category ); diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index d20af322af4fd2..bc198a7f4eae9c 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -3,7 +3,7 @@ /** * External dependencies */ -import { get, isFunction, isPlainObject, omit, pick, some } from 'lodash'; +import { get, omit, pick, isFunction, isPlainObject, some } from 'lodash'; /** * WordPress dependencies @@ -113,6 +113,18 @@ import { DEPRECATED_ENTRY_KEYS } from './constants'; * then no preview is shown. */ +/** + * Mapping of legacy category slugs to their latest normal values, used to + * accommodate updates of the default set of block categories. + * + * @type {Record} + */ +const LEGACY_CATEGORY_MAPPING = { + common: 'text', + formatting: 'text', + layout: 'design', +}; + export let serverSideBlockDefinitions = {}; /** @@ -203,6 +215,12 @@ export function registerBlockType( name, settings ) { console.error( 'The "edit" property must be a valid function.' ); return; } + + // Canonicalize legacy categories to equivalent fallback. + if ( LEGACY_CATEGORY_MAPPING.hasOwnProperty( settings.category ) ) { + settings.category = LEGACY_CATEGORY_MAPPING[ settings.category ]; + } + if ( 'category' in settings && ! some( select( 'core/blocks' ).getCategories(), { @@ -218,6 +236,7 @@ export function registerBlockType( name, settings ) { ); delete settings.category; } + if ( ! ( 'title' in settings ) || settings.title === '' ) { console.error( 'The block "' + name + '" must have a title.' ); return; diff --git a/packages/blocks/src/api/test/factory.js b/packages/blocks/src/api/test/factory.js index 641745ddeeb3cc..767ddd761b0a7e 100644 --- a/packages/blocks/src/api/test/factory.js +++ b/packages/blocks/src/api/test/factory.js @@ -34,7 +34,7 @@ describe( 'block factory', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'block title', }; @@ -66,7 +66,7 @@ describe( 'block factory', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); const block = createBlock( 'core/test-block', { align: 'left' }, [ @@ -174,7 +174,7 @@ describe( 'block factory', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); const block = deepFreeze( @@ -209,7 +209,7 @@ describe( 'block factory', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); const block = deepFreeze( @@ -241,7 +241,7 @@ describe( 'block factory', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); const block = deepFreeze( @@ -293,7 +293,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -329,7 +329,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -363,7 +363,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -401,7 +401,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( @@ -443,7 +443,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -485,7 +485,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( @@ -536,7 +536,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -578,7 +578,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/another-text-block', { @@ -598,7 +598,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'another text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -640,7 +640,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -682,7 +682,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -719,7 +719,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -753,7 +753,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -788,7 +788,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -824,7 +824,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -859,7 +859,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -898,7 +898,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'A block that groups other blocks.', } ); } ); @@ -987,7 +987,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -1037,7 +1037,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'text-block', } ); @@ -1096,7 +1096,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -1129,7 +1129,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -1168,7 +1168,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -1212,7 +1212,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/text-block', defaultBlockSettings ); @@ -1253,7 +1253,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'text block', } ); @@ -1298,7 +1298,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'text block', } ); @@ -1344,7 +1344,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'text block', } ); @@ -1408,7 +1408,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated columns block', } ); registerBlockType( 'core/columns-block', defaultBlockSettings ); @@ -1467,7 +1467,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated columns block', } ); registerBlockType( 'core/columns-block', defaultBlockSettings ); @@ -1532,7 +1532,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'Test Group Block', } ); @@ -1593,7 +1593,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'Test Group Block', } ); @@ -1629,7 +1629,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); registerBlockType( 'core/transform-from-text-block-2', { @@ -1641,7 +1641,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'updated text block', } ); } ); @@ -1811,7 +1811,7 @@ describe( 'block factory', () => { ], }, save: noop, - category: 'common', + category: 'text', title: 'A Block with InnerBlocks that supports grouping', } ); } ); diff --git a/packages/blocks/src/api/test/parser.js b/packages/blocks/src/api/test/parser.js index be377dd956da0a..add399395072bd 100644 --- a/packages/blocks/src/api/test/parser.js +++ b/packages/blocks/src/api/test/parser.js @@ -39,12 +39,12 @@ describe( 'block parser', () => { }, }, save: ( { attributes } ) => attributes.fruit || null, - category: 'common', + category: 'text', title: 'block title', }; const unknownBlockSettings = { - category: 'common', + category: 'text', title: 'unknown block', attributes: { content: { @@ -892,7 +892,7 @@ describe( 'block parser', () => { chicken: { type: 'string' }, }, save: ( { attributes } ) => attributes.content, - category: 'common', + category: 'text', title: 'test block', } ); @@ -928,7 +928,7 @@ describe( 'block parser', () => { }, }, save: ( { attributes } ) => attributes.content, - category: 'common', + category: 'text', title: 'test block', } ); @@ -1054,7 +1054,7 @@ describe( 'block parser', () => { it( 'should parse with unicode escaped returned to original representation', () => { registerBlockType( 'core/code', { - category: 'common', + category: 'text', title: 'Code Block', attributes: { content: { diff --git a/packages/blocks/src/api/test/registration.js b/packages/blocks/src/api/test/registration.js index 08e4c11153e347..094a17674912f3 100644 --- a/packages/blocks/src/api/test/registration.js +++ b/packages/blocks/src/api/test/registration.js @@ -41,7 +41,7 @@ import { DEPRECATED_ENTRY_KEYS } from '../constants'; describe( 'blocks', () => { const defaultBlockSettings = { save: noop, - category: 'common', + category: 'text', title: 'block title', }; @@ -126,7 +126,7 @@ describe( 'blocks', () => { attributes: {}, keywords: [], save: noop, - category: 'common', + category: 'text', title: 'block title', } ); } ); @@ -160,7 +160,7 @@ describe( 'blocks', () => { const blockType = { save: noop, edit: 'not-a-function', - category: 'common', + category: 'text', title: 'block title', }, block = registerBlockType( @@ -173,6 +173,19 @@ describe( 'blocks', () => { expect( block ).toBeUndefined(); } ); + it( 'should canonicalize legacy block category.', () => { + const blockType = { + save: noop, + category: 'common', + title: 'block title', + }, + block = registerBlockType( + 'my-plugin/fancy-block-9', + blockType + ); + expect( block.category ).toBe( 'text' ); + } ); + it( 'should unset category of blocks with non registered category.', () => { const blockType = { save: noop, @@ -194,7 +207,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', }, block = registerBlockType( 'my-plugin/fancy-block-9', @@ -210,7 +223,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: '', }, block = registerBlockType( @@ -227,7 +240,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 12345, }, block = registerBlockType( @@ -243,13 +256,13 @@ describe( 'blocks', () => { it( 'should assign default settings', () => { registerBlockType( 'core/test-block-with-defaults', { title: 'block title', - category: 'common', + category: 'text', } ); expect( getBlockType( 'core/test-block-with-defaults' ) ).toEqual( { name: 'core/test-block-with-defaults', title: 'block title', - category: 'common', + category: 'text', icon: { src: blockIcon, }, @@ -268,7 +281,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block-with-attributes', blockType ); @@ -277,7 +290,7 @@ describe( 'blocks', () => { name: 'core/test-block-with-attributes', settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -295,7 +308,7 @@ describe( 'blocks', () => { it( 'should validate the icon', () => { const blockType = { save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { chicken: 'ribs' }, }; @@ -310,7 +323,7 @@ describe( 'blocks', () => { it( 'should normalize the icon containing an element', () => { const blockType = { save: noop, - category: 'common', + category: 'text', title: 'block title', icon: ( @@ -334,7 +347,7 @@ describe( 'blocks', () => { ).toEqual( { name: 'core/test-block-icon-normalize-element', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: ( @@ -358,7 +371,7 @@ describe( 'blocks', () => { it( 'should normalize the icon containing a string', () => { const blockType = { save: noop, - category: 'common', + category: 'text', title: 'block title', icon: 'foo', }; @@ -371,7 +384,7 @@ describe( 'blocks', () => { ).toEqual( { name: 'core/test-block-icon-normalize-string', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: 'foo', @@ -398,7 +411,7 @@ describe( 'blocks', () => { }; const blockType = { save: noop, - category: 'common', + category: 'text', title: 'block title', icon: MyTestIcon, }; @@ -411,7 +424,7 @@ describe( 'blocks', () => { ).toEqual( { name: 'core/test-block-icon-normalize-function', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: MyTestIcon, @@ -424,7 +437,7 @@ describe( 'blocks', () => { it( 'should correctly register an icon with background and a custom svg', () => { const blockType = { save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { background: '#f00', @@ -451,7 +464,7 @@ describe( 'blocks', () => { ).toEqual( { name: 'core/test-block-icon-normalize-background', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { background: '#f00', @@ -479,7 +492,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block-with-settings', blockType ); @@ -488,7 +501,7 @@ describe( 'blocks', () => { name: 'core/test-block-with-settings', settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -684,7 +697,7 @@ describe( 'blocks', () => { { name: 'core/test-block', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -699,7 +712,7 @@ describe( 'blocks', () => { expect( oldBlock ).toEqual( { name: 'core/test-block', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -775,7 +788,7 @@ describe( 'blocks', () => { expect( getBlockType( 'core/test-block' ) ).toEqual( { name: 'core/test-block', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -789,7 +802,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block-with-settings', blockType ); @@ -797,7 +810,7 @@ describe( 'blocks', () => { name: 'core/test-block-with-settings', settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -818,7 +831,7 @@ describe( 'blocks', () => { const blockType = { settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block-with-settings', blockType ); @@ -826,7 +839,7 @@ describe( 'blocks', () => { { name: 'core/test-block', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, @@ -839,7 +852,7 @@ describe( 'blocks', () => { name: 'core/test-block-with-settings', settingName: 'settingValue', save: noop, - category: 'common', + category: 'text', title: 'block title', icon: { src: blockIcon, diff --git a/packages/blocks/src/api/test/serializer.js b/packages/blocks/src/api/test/serializer.js index 6156a8e06d2c15..c659154db971d9 100644 --- a/packages/blocks/src/api/test/serializer.js +++ b/packages/blocks/src/api/test/serializer.js @@ -245,7 +245,7 @@ describe( 'block serializer', () => { describe( 'serializeBlock()', () => { it( 'serializes the freeform content fallback block without comment delimiters', () => { registerBlockType( 'core/freeform-block', { - category: 'common', + category: 'text', title: 'freeform block', attributes: { fruit: { @@ -265,7 +265,7 @@ describe( 'block serializer', () => { } ); it( 'serializes the freeform content fallback block with comment delimiters in nested context', () => { registerBlockType( 'core/freeform-block', { - category: 'common', + category: 'text', title: 'freeform block', attributes: { fruit: { @@ -289,7 +289,7 @@ describe( 'block serializer', () => { } ); it( 'serializes the unregistered fallback block without comment delimiters', () => { registerBlockType( 'core/unregistered-block', { - category: 'common', + category: 'text', title: 'unregistered block', attributes: { fruit: { @@ -335,7 +335,7 @@ describe( 'block serializer', () => { return

{ attributes.content }

; }, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/test-block', blockType ); @@ -392,7 +392,7 @@ describe( 'block serializer', () => { save( { attributes } ) { return attributes.content; }, - category: 'common', + category: 'text', title: 'block title', }; registerBlockType( 'core/chicken', blockType ); diff --git a/packages/blocks/src/api/test/templates.js b/packages/blocks/src/api/test/templates.js index 80350ebcb968d5..7dbee7062cb862 100644 --- a/packages/blocks/src/api/test/templates.js +++ b/packages/blocks/src/api/test/templates.js @@ -33,14 +33,14 @@ describe( 'templates', () => { registerBlockType( 'core/test-block', { attributes: {}, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); registerBlockType( 'core/test-block-2', { attributes: {}, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); } ); diff --git a/packages/blocks/src/api/test/utils.js b/packages/blocks/src/api/test/utils.js index c00f22cf28b6ea..f77e6ea2300bad 100644 --- a/packages/blocks/src/api/test/utils.js +++ b/packages/blocks/src/api/test/utils.js @@ -45,7 +45,7 @@ describe( 'block helpers', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); setDefaultBlockName( 'core/test-block' ); @@ -65,7 +65,7 @@ describe( 'block helpers', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); setDefaultBlockName( 'core/test-block' ); @@ -84,7 +84,7 @@ describe( 'block helpers', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); registerBlockType( 'core/test-block2', { @@ -95,7 +95,7 @@ describe( 'block helpers', () => { }, }, save: noop, - category: 'common', + category: 'text', title: 'test block', } ); setDefaultBlockName( 'core/test-block1' ); diff --git a/packages/blocks/src/api/test/validation.js b/packages/blocks/src/api/test/validation.js index ffc621640c83c2..0c759fb6b1c081 100644 --- a/packages/blocks/src/api/test/validation.js +++ b/packages/blocks/src/api/test/validation.js @@ -28,7 +28,7 @@ import { describe( 'validation', () => { const defaultBlockSettings = { save: ( { attributes } ) => attributes.fruit, - category: 'common', + category: 'text', title: 'block title', }; beforeAll( () => { diff --git a/packages/blocks/src/store/reducer.js b/packages/blocks/src/store/reducer.js index e746eb80b5949a..3bbe4ea1fa5619 100644 --- a/packages/blocks/src/store/reducer.js +++ b/packages/blocks/src/store/reducer.js @@ -20,12 +20,21 @@ import { combineReducers } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; /** - * Module Constants + * @typedef {Object} WPBlockCategory + * + * @property {string} slug Unique category slug. + * @property {string} title Category label, for display in user interface. + */ + +/** + * Default set of categories. + * + * @type {WPBlockCategory[]} */ export const DEFAULT_CATEGORIES = [ - { slug: 'common', title: __( 'Common blocks' ) }, - { slug: 'formatting', title: __( 'Formatting' ) }, - { slug: 'layout', title: __( 'Layout elements' ) }, + { slug: 'text', title: __( 'Text' ) }, + { slug: 'media', title: __( 'Media' ) }, + { slug: 'design', title: __( 'Design' ) }, { slug: 'widgets', title: __( 'Widgets' ) }, { slug: 'embed', title: __( 'Embeds' ) }, { slug: 'reusable', title: __( 'Reusable blocks' ) }, @@ -199,10 +208,10 @@ export const groupingBlockName = createBlockNameSetterReducer( /** * Reducer managing the categories * - * @param {Object} state Current state. - * @param {Object} action Dispatched action. + * @param {WPBlockCategory[]} state Current state. + * @param {Object} action Dispatched action. * - * @return {Object} Updated state. + * @return {WPBlockCategory[]} Updated state. */ export function categories( state = DEFAULT_CATEGORIES, action ) { switch ( action.type ) { diff --git a/packages/blocks/src/store/selectors.js b/packages/blocks/src/store/selectors.js index a0a2d02bdd3838..21e88311b522ff 100644 --- a/packages/blocks/src/store/selectors.js +++ b/packages/blocks/src/store/selectors.js @@ -15,8 +15,8 @@ import { } from 'lodash'; /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ - /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ +/** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ /** * Given a block name or block type object, returns the corresponding @@ -117,7 +117,7 @@ export function getDefaultBlockVariation( state, blockName, scope ) { * * @param {Object} state Data state. * - * @return {Array} Categories list. + * @return {WPBlockCategory[]} Categories list. */ export function getCategories( state ) { return state.categories; diff --git a/packages/blocks/src/store/test/selectors.js b/packages/blocks/src/store/test/selectors.js index daea899178fdf0..fde5d922536227 100644 --- a/packages/blocks/src/store/test/selectors.js +++ b/packages/blocks/src/store/test/selectors.js @@ -14,6 +14,7 @@ import { getDefaultBlockVariation, getGroupingBlockName, isMatchingSearchTerm, + getCategories, } from '../selectors'; describe( 'selectors', () => { @@ -68,6 +69,15 @@ describe( 'selectors', () => { } ); } ); + describe( 'getCategories', () => { + it( 'returns categories state', () => { + const categories = [ { slug: 'text', text: 'Text' } ]; + const state = deepFreeze( { categories } ); + + expect( getCategories( state ) ).toEqual( categories ); + } ); + } ); + describe( 'getChildBlockNames', () => { it( 'should return an empty array if state is empty', () => { const state = {}; @@ -284,8 +294,8 @@ describe( 'selectors', () => { const name = 'core/paragraph'; const blockType = { title: 'Paragraph', - category: 'common', - keywords: [ 'text' ], + category: 'text', + keywords: [ 'body' ], }; const state = { @@ -353,7 +363,7 @@ describe( 'selectors', () => { const result = isMatchingSearchTerm( state, nameOrType, - 'TEXT' + 'BODY' ); expect( result ).toBe( true ); @@ -364,7 +374,7 @@ describe( 'selectors', () => { const result = isMatchingSearchTerm( state, nameOrType, - 'COMMON' + 'TEXT' ); expect( result ).toBe( true ); diff --git a/packages/create-block/lib/prompts.js b/packages/create-block/lib/prompts.js index 5624f984f8292a..5c6d47ea46aa13 100644 --- a/packages/create-block/lib/prompts.js +++ b/packages/create-block/lib/prompts.js @@ -70,7 +70,7 @@ const category = { type: 'list', name: 'category', message: 'The category name to help users browse and discover your block:', - choices: [ 'common', 'embed', 'formatting', 'layout', 'widgets' ], + choices: [ 'text', 'embed', 'media', 'design', 'widgets' ], }; const author = { diff --git a/packages/e2e-tests/plugins/align-hook/index.js b/packages/e2e-tests/plugins/align-hook/index.js index 0380758fbaaf05..aae7758c613b17 100644 --- a/packages/e2e-tests/plugins/align-hook/index.js +++ b/packages/e2e-tests/plugins/align-hook/index.js @@ -9,7 +9,7 @@ var baseBlock = { icon: 'cart', - category: 'common', + category: 'text', edit: function( props ) { return el( 'div', @@ -43,7 +43,7 @@ title: 'Test Align True', supports: { align: true, - } + }, }, baseBlock ) @@ -56,7 +56,7 @@ title: 'Test Align Array', supports: { align: [ 'left', 'center' ], - } + }, }, baseBlock ) @@ -75,7 +75,7 @@ }, supports: { align: true, - } + }, }, baseBlock ) diff --git a/packages/e2e-tests/plugins/block-context/index.js b/packages/e2e-tests/plugins/block-context/index.js index 76e978a28dd20a..3ab0a67b9e6811 100644 --- a/packages/e2e-tests/plugins/block-context/index.js +++ b/packages/e2e-tests/plugins/block-context/index.js @@ -15,7 +15,7 @@ 'gutenberg/recordId': 'recordId', }, - category: 'common', + category: 'text', edit( { attributes, setAttributes } ) { return el( @@ -51,7 +51,7 @@ // `get_block_editor_server_block_settings`. context: [ 'gutenberg/recordId' ], - category: 'common', + category: 'text', edit( { context } ) { return 'The record ID is: ' + context[ 'gutenberg/recordId' ]; diff --git a/packages/e2e-tests/plugins/block-icons/index.js b/packages/e2e-tests/plugins/block-icons/index.js index fe05c1d23dcb33..e6873ab90e9118 100644 --- a/packages/e2e-tests/plugins/block-icons/index.js +++ b/packages/e2e-tests/plugins/block-icons/index.js @@ -2,32 +2,53 @@ var registerBlockType = wp.blocks.registerBlockType; var el = wp.element.createElement; var InnerBlocks = wp.blockEditor.InnerBlocks; - var circle = el( 'circle', { cx: 10, cy: 10, r: 10, fill: 'red', stroke: 'blue', strokeWidth: '10' } ); - var svg = el( 'svg', { width: 20, height: 20, viewBox: '0 0 20 20' }, circle ); + var circle = el( 'circle', { + cx: 10, + cy: 10, + r: 10, + fill: 'red', + stroke: 'blue', + strokeWidth: '10', + } ); + var svg = el( + 'svg', + { width: 20, height: 20, viewBox: '0 0 20 20' }, + circle + ); registerBlockType( 'test/test-single-svg-icon', { title: 'TestSimpleSvgIcon', icon: svg, - category: 'common', + category: 'text', edit: function() { - return el( 'div', { className: 'test-single-svg-icon', style: { outline: '1px solid gray', padding: 5 } }, - el( - InnerBlocks, - { - allowedBlocks: [ 'core/paragraph', 'core/image' ], - template: [ - [ 'core/paragraph', { + return el( + 'div', + { + className: 'test-single-svg-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, + el( InnerBlocks, { + allowedBlocks: [ 'core/paragraph', 'core/image' ], + template: [ + [ + 'core/paragraph', + { content: 'TestSimpleSvgIcon', - } ], + }, ], - } - ) + ], + } ) ); }, save: function() { - return el( 'div', { className: 'test-single-svg-icon', style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { + className: 'test-single-svg-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, el( InnerBlocks.Content, {} ) ); }, @@ -36,26 +57,36 @@ registerBlockType( 'test/test-dash-icon', { title: 'TestDashIcon', icon: 'cart', - category: 'common', + category: 'text', edit: function() { - return el( 'div', { className: 'test-dash-icon', style: { outline: '1px solid gray', padding: 5 } }, - el( - InnerBlocks, - { - allowedBlocks: [ 'core/paragraph', 'core/image' ], - template: [ - [ 'core/paragraph', { + return el( + 'div', + { + className: 'test-dash-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, + el( InnerBlocks, { + allowedBlocks: [ 'core/paragraph', 'core/image' ], + template: [ + [ + 'core/paragraph', + { content: 'TestDashIcon', - } ], + }, ], - } - ) + ], + } ) ); }, save: function() { - return el( 'div', { className: 'test-dash-icon', style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { + className: 'test-dash-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, el( InnerBlocks.Content, {} ) ); }, @@ -63,29 +94,39 @@ registerBlockType( 'test/test-function-icon', { title: 'TestFunctionIcon', - icon: function(){ + icon: function() { return svg; }, - category: 'common', + category: 'text', edit: function() { - return el( 'div', { className: 'test-function-icon', style: { outline: '1px solid gray', padding: 5 } }, - el( - InnerBlocks, - { - allowedBlocks: [ 'core/paragraph', 'core/image' ], - template: [ - [ 'core/paragraph', { + return el( + 'div', + { + className: 'test-function-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, + el( InnerBlocks, { + allowedBlocks: [ 'core/paragraph', 'core/image' ], + template: [ + [ + 'core/paragraph', + { content: 'TestFunctionIcon', - } ], + }, ], - } - ) + ], + } ) ); }, save: function() { - return el( 'div', { className: 'test-function-icon', style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { + className: 'test-function-icon', + style: { outline: '1px solid gray', padding: 5 }, + }, el( InnerBlocks.Content, {} ) ); }, @@ -98,26 +139,36 @@ foreground: '#fe0000', src: 'cart', }, - category: 'common', + category: 'text', edit: function() { - return el( 'div', { className: 'test-dash-icon-colors', style: { outline: '1px solid gray', padding: 5 } }, - el( - InnerBlocks, - { - allowedBlocks: [ 'core/paragraph', 'core/image' ], - template: [ - [ 'core/paragraph', { + return el( + 'div', + { + className: 'test-dash-icon-colors', + style: { outline: '1px solid gray', padding: 5 }, + }, + el( InnerBlocks, { + allowedBlocks: [ 'core/paragraph', 'core/image' ], + template: [ + [ + 'core/paragraph', + { content: 'TestIconColors', - } ], + }, ], - } - ) + ], + } ) ); }, save: function() { - return el( 'div', { className: 'test-dash-icon-colors', style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { + className: 'test-dash-icon-colors', + style: { outline: '1px solid gray', padding: 5 }, + }, el( InnerBlocks.Content, {} ) ); }, @@ -129,26 +180,36 @@ background: '#010000', src: svg, }, - category: 'common', + category: 'text', edit: function() { - return el( 'div', { className: 'test-svg-icon-background', style: { outline: '1px solid gray', padding: 5 } }, - el( - InnerBlocks, - { - allowedBlocks: [ 'core/paragraph', 'core/image' ], - template: [ - [ 'core/paragraph', { + return el( + 'div', + { + className: 'test-svg-icon-background', + style: { outline: '1px solid gray', padding: 5 }, + }, + el( InnerBlocks, { + allowedBlocks: [ 'core/paragraph', 'core/image' ], + template: [ + [ + 'core/paragraph', + { content: 'TestIconColors', - } ], + }, ], - } - ) + ], + } ) ); }, save: function() { - return el( 'div', { className: 'test-svg-icon-background', style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { + className: 'test-svg-icon-background', + style: { outline: '1px solid gray', padding: 5 }, + }, el( InnerBlocks.Content, {} ) ); }, diff --git a/packages/e2e-tests/plugins/container-without-paragraph/index.js b/packages/e2e-tests/plugins/container-without-paragraph/index.js index 7ec20eef893ace..9e43e0365e519c 100644 --- a/packages/e2e-tests/plugins/container-without-paragraph/index.js +++ b/packages/e2e-tests/plugins/container-without-paragraph/index.js @@ -1,17 +1,19 @@ ( function() { - wp.blocks.registerBlockType('test/container-without-paragraph', { + wp.blocks.registerBlockType( 'test/container-without-paragraph', { title: 'Container without paragraph', - category: 'common', + category: 'text', icon: 'yes', edit() { - return wp.element.createElement(wp.blockEditor.InnerBlocks, { - allowedBlocks: ['core/image', 'core/gallery'] - }); + return wp.element.createElement( wp.blockEditor.InnerBlocks, { + allowedBlocks: [ 'core/image', 'core/gallery' ], + } ); }, save() { - return wp.element.createElement(wp.blockEditor.InnerBlocks.Content); + return wp.element.createElement( + wp.blockEditor.InnerBlocks.Content + ); }, - }) + } ); } )(); diff --git a/packages/e2e-tests/plugins/custom-grouping-block/index.js b/packages/e2e-tests/plugins/custom-grouping-block/index.js index 591554ac1367ba..23897168176f4c 100644 --- a/packages/e2e-tests/plugins/custom-grouping-block/index.js +++ b/packages/e2e-tests/plugins/custom-grouping-block/index.js @@ -1,28 +1,42 @@ ( function() { wp.blocks.registerBlockType( 'test/alternative-group-block', { title: 'Alternative Group Block', - category: 'layout', + category: 'design', icon: 'yes', edit() { return wp.element.createElement( wp.blockEditor.InnerBlocks ); }, save() { - return wp.element.createElement( wp.blockEditor.InnerBlocks.Content ); + return wp.element.createElement( + wp.blockEditor.InnerBlocks.Content + ); }, transforms: { - from: [ { - type: 'block', - blocks: [ '*' ], - isMultiBlock: true, - __experimentalConvert( blocks ) { - const groupInnerBlocks = blocks.map( ( { name, attributes, innerBlocks } ) => { - return wp.blocks.createBlock( name, attributes, innerBlocks ); - } ); + from: [ + { + type: 'block', + blocks: [ '*' ], + isMultiBlock: true, + __experimentalConvert( blocks ) { + const groupInnerBlocks = blocks.map( + ( { name, attributes, innerBlocks } ) => { + return wp.blocks.createBlock( + name, + attributes, + innerBlocks + ); + } + ); - return wp.blocks.createBlock( 'test/alternative-group-block', {}, groupInnerBlocks ); + return wp.blocks.createBlock( + 'test/alternative-group-block', + {}, + groupInnerBlocks + ); + }, }, - } ], + ], }, } ); -}() ); +} )(); diff --git a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js index 0cb60aeff9a614..39429a7e3387f6 100644 --- a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js +++ b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js @@ -12,7 +12,7 @@ selector: 'p', }, }, - category: 'formatting', + category: 'text', edit: function( { attributes, setAttributes } ) { return el( RichText, { tagName: 'p', @@ -58,9 +58,11 @@ }, }, }, - category: 'formatting', + category: 'text', edit: function( { attributes, setAttributes } ) { - return el( 'blockquote', {}, + return el( + 'blockquote', + {}, el( RichText, { multiline: 'p', value: toRichTextValue( attributes.value ), @@ -73,7 +75,9 @@ ); }, save: function( { attributes } ) { - return el( 'blockquote', {}, + return el( + 'blockquote', + {}, el( RichText.Content, { value: toRichTextValue( attributes.value ), } ) diff --git a/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js b/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js index f85721b0d15e78..faf5c49d9f0bea 100644 --- a/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js @@ -22,7 +22,7 @@ registerBlockType( 'test/allowed-blocks-unset', { title: 'Allowed Blocks Unset', icon: 'carrot', - category: 'common', + category: 'text', edit() { return el( 'div', divProps, el( InnerBlocks, { template } ) ); @@ -34,7 +34,7 @@ registerBlockType( 'test/allowed-blocks-set', { title: 'Allowed Blocks Set', icon: 'carrot', - category: 'common', + category: 'text', edit() { return el( @@ -59,7 +59,7 @@ registerBlockType( 'test/allowed-blocks-dynamic', { title: 'Allowed Blocks Dynamic', icon: 'carrot', - category: 'common', + category: 'text', edit: withSelect( function( select, ownProps ) { var getBlockOrder = select( 'core/block-editor' ).getBlockOrder; diff --git a/packages/e2e-tests/plugins/inner-blocks-locking-all-embed/index.js b/packages/e2e-tests/plugins/inner-blocks-locking-all-embed/index.js index 31b7c745d3dcff..b021cc9e6bb6e8 100644 --- a/packages/e2e-tests/plugins/inner-blocks-locking-all-embed/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-locking-all-embed/index.js @@ -4,10 +4,13 @@ var InnerBlocks = wp.blockEditor.InnerBlocks; var __ = wp.i18n.__; var TEMPLATE = [ - [ 'core/paragraph', { - fontSize: 'large', - content: __( 'Content…' ), - } ], + [ + 'core/paragraph', + { + fontSize: 'large', + content: __( 'Content…' ), + }, + ], [ 'core/embed' ], ]; @@ -18,16 +21,13 @@ registerBlockType( 'test/test-inner-blocks-locking-all-embed', { title: 'Test Inner Blocks Locking All Embed', icon: 'cart', - category: 'common', + category: 'text', edit: function( props ) { - return el( - InnerBlocks, - { - template: TEMPLATE, - templateLock: 'all', - } - ); + return el( InnerBlocks, { + template: TEMPLATE, + templateLock: 'all', + } ); }, save, diff --git a/packages/e2e-tests/plugins/inner-blocks-render-appender/index.js b/packages/e2e-tests/plugins/inner-blocks-render-appender/index.js index 5d0f6af546a51e..dd3438e5594734 100644 --- a/packages/e2e-tests/plugins/inner-blocks-render-appender/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-render-appender/index.js @@ -8,36 +8,48 @@ var allowedBlocks = [ 'core/quote', 'core/video' ]; function myCustomAppender() { - return ( - el( 'div', { className: 'my-custom-awesome-appender' }, - el( 'span', {}, 'My custom awesome appender' ), - el( InnerBlocks.ButtonBlockAppender ) - ) + return el( + 'div', + { className: 'my-custom-awesome-appender' }, + el( 'span', {}, 'My custom awesome appender' ), + el( InnerBlocks.ButtonBlockAppender ) ); } function emptyBlockAppender() { - return ( - el( 'div', { className: 'my-dynamic-blocks-appender' }, - el( 'span', { className: 'empty-blocks-appender' }, 'Empty Blocks Appender' ), - el( InnerBlocks.ButtonBlockAppender ) - ) + return el( + 'div', + { className: 'my-dynamic-blocks-appender' }, + el( + 'span', + { className: 'empty-blocks-appender' }, + 'Empty Blocks Appender' + ), + el( InnerBlocks.ButtonBlockAppender ) ); } function singleBlockAppender() { - return ( - el( 'div', { className: 'my-dynamic-blocks-appender' }, - el( 'span', { className: 'single-blocks-appender' }, 'Single Blocks Appender' ), - el( InnerBlocks.ButtonBlockAppender ) - ) + return el( + 'div', + { className: 'my-dynamic-blocks-appender' }, + el( + 'span', + { className: 'single-blocks-appender' }, + 'Single Blocks Appender' + ), + el( InnerBlocks.ButtonBlockAppender ) ); } function multipleBlockAppender() { - return ( - el( 'div', { className: 'my-dynamic-blocks-appender' }, - el( 'span', { className: 'multiple-blocks-appender' }, 'Multiple Blocks Appender' ), + return el( + 'div', + { className: 'my-dynamic-blocks-appender' }, + el( + 'span', + { className: 'multiple-blocks-appender' }, + 'Multiple Blocks Appender' ) ); } @@ -45,10 +57,12 @@ registerBlockType( 'test/inner-blocks-render-appender', { title: 'InnerBlocks renderAppender', icon: 'carrot', - category: 'common', + category: 'text', edit() { - return el( 'div', { style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { style: { outline: '1px solid gray', padding: 5 } }, el( InnerBlocks, { allowedBlocks: allowedBlocks, renderAppender: myCustomAppender, @@ -57,7 +71,9 @@ }, save() { - return el( 'div', { style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { style: { outline: '1px solid gray', padding: 5 } }, el( InnerBlocks.Content ) ); }, @@ -66,13 +82,16 @@ registerBlockType( 'test/inner-blocks-render-appender-dynamic', { title: 'InnerBlocks renderAppender dynamic', icon: 'carrot', - category: 'common', + category: 'text', edit( props ) { - const numberOfChildren = useSelect( ( select ) => { - const { getBlockOrder } = select( 'core/block-editor' ); - return getBlockOrder( props.clientId ).length; - }, [ props.clientId ] ); + const numberOfChildren = useSelect( + ( select ) => { + const { getBlockOrder } = select( 'core/block-editor' ); + return getBlockOrder( props.clientId ).length; + }, + [ props.clientId ] + ); switch ( numberOfChildren ) { case 0: renderAppender = emptyBlockAppender; @@ -84,7 +103,9 @@ renderAppender = multipleBlockAppender; break; } - return el( 'div', { style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { style: { outline: '1px solid gray', padding: 5 } }, el( InnerBlocks, { allowedBlocks, renderAppender, @@ -93,9 +114,11 @@ }, save() { - return el( 'div', { style: { outline: '1px solid gray', padding: 5 } }, + return el( + 'div', + { style: { outline: '1px solid gray', padding: 5 } }, el( InnerBlocks.Content ) ); }, } ); -}() ); +} )(); diff --git a/packages/e2e-tests/plugins/inner-blocks-templates/index.js b/packages/e2e-tests/plugins/inner-blocks-templates/index.js index 7d3662f17dbfc4..e6897e4b7d9500 100644 --- a/packages/e2e-tests/plugins/inner-blocks-templates/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-templates/index.js @@ -5,17 +5,23 @@ var InnerBlocks = wp.blockEditor.InnerBlocks; var __ = wp.i18n.__; var TEMPLATE = [ - [ 'core/paragraph', { - fontSize: 'large', - content: 'Content…', - } ], + [ + 'core/paragraph', + { + fontSize: 'large', + content: 'Content…', + }, + ], ]; var TEMPLATE_PARAGRAPH_PLACEHOLDER = [ - [ 'core/paragraph', { - fontSize: 'large', - placeholder: 'Content…', - } ], + [ + 'core/paragraph', + { + fontSize: 'large', + placeholder: 'Content…', + }, + ], ]; var save = function() { @@ -25,15 +31,12 @@ registerBlockType( 'test/test-inner-blocks-no-locking', { title: 'Test Inner Blocks no locking', icon: 'cart', - category: 'common', + category: 'text', edit: function( props ) { - return el( - InnerBlocks, - { - template: TEMPLATE, - } - ); + return el( InnerBlocks, { + template: TEMPLATE, + } ); }, save, @@ -42,16 +45,13 @@ registerBlockType( 'test/test-inner-blocks-locking-all', { title: 'Test InnerBlocks locking all', icon: 'cart', - category: 'common', + category: 'text', edit: function( props ) { - return el( - InnerBlocks, - { - template: TEMPLATE, - templateLock: 'all', - } - ); + return el( InnerBlocks, { + template: TEMPLATE, + templateLock: 'all', + } ); }, save, @@ -60,15 +60,12 @@ registerBlockType( 'test/test-inner-blocks-paragraph-placeholder', { title: 'Test Inner Blocks Paragraph Placeholder', icon: 'cart', - category: 'common', + category: 'text', edit: function( props ) { - return el( - InnerBlocks, - { - template: TEMPLATE_PARAGRAPH_PLACEHOLDER, - } - ); + return el( InnerBlocks, { + template: TEMPLATE_PARAGRAPH_PLACEHOLDER, + } ); }, save, @@ -77,7 +74,7 @@ registerBlockType( 'test/test-inner-blocks-transformer-target', { title: 'Test Inner Blocks transformer target', icon: 'cart', - category: 'common', + category: 'text', transforms: { from: [ @@ -87,10 +84,14 @@ 'test/i-dont-exist', 'test/test-inner-blocks-no-locking', 'test/test-inner-blocks-locking-all', - 'test/test-inner-blocks-paragraph-placeholder' + 'test/test-inner-blocks-paragraph-placeholder', ], transform: function( attributes, innerBlocks ) { - return createBlock( 'test/test-inner-blocks-transformer-target', attributes, innerBlocks ); + return createBlock( + 'test/test-inner-blocks-transformer-target', + attributes, + innerBlocks + ); }, }, ], @@ -99,22 +100,22 @@ type: 'block', blocks: [ 'test/i-dont-exist' ], transform: function( attributes, innerBlocks ) { - return createBlock( 'test/test-inner-blocks-transformer-target', attributes, innerBlocks ); + return createBlock( + 'test/test-inner-blocks-transformer-target', + attributes, + innerBlocks + ); }, - } - ] + }, + ], }, edit: function( props ) { - return el( - InnerBlocks, - { - template: TEMPLATE, - } - ); + return el( InnerBlocks, { + template: TEMPLATE, + } ); }, save, } ); - } )(); diff --git a/packages/e2e-tests/plugins/meta-attribute-block/early.js b/packages/e2e-tests/plugins/meta-attribute-block/early.js index 7c2831e84e4de2..576a7bf236be77 100644 --- a/packages/e2e-tests/plugins/meta-attribute-block/early.js +++ b/packages/e2e-tests/plugins/meta-attribute-block/early.js @@ -5,7 +5,7 @@ registerBlockType( 'test/test-meta-attribute-block-early', { title: 'Test Meta Attribute Block (Early Registration)', icon: 'star', - category: 'common', + category: 'text', attributes: { content: { diff --git a/packages/e2e-tests/plugins/meta-attribute-block/late.js b/packages/e2e-tests/plugins/meta-attribute-block/late.js index 362acab0f776a7..98e9a2d46a2821 100644 --- a/packages/e2e-tests/plugins/meta-attribute-block/late.js +++ b/packages/e2e-tests/plugins/meta-attribute-block/late.js @@ -5,7 +5,7 @@ registerBlockType( 'test/test-meta-attribute-block-late', { title: 'Test Meta Attribute Block (Late Registration)', icon: 'star', - category: 'common', + category: 'text', attributes: { content: { diff --git a/packages/e2e-tests/specs/experiments/block-directory-add.test.js b/packages/e2e-tests/specs/experiments/block-directory-add.test.js index 84cc29dc741aed..7d21159c4b2562 100644 --- a/packages/e2e-tests/specs/experiments/block-directory-add.test.js +++ b/packages/e2e-tests/specs/experiments/block-directory-add.test.js @@ -62,7 +62,7 @@ const block = `( function() { registerBlockType( '${ MOCK_BLOCK1.name }', { title: 'Test Block for Block Directory', icon: 'hammer', - category: 'common', + category: 'text', attributes: {}, edit: function( props ) { return el( 'p', null, 'Test Copy' ); diff --git a/packages/editor/src/components/document-outline/test/index.js b/packages/editor/src/components/document-outline/test/index.js index 9277e7c4afd3a0..fad1694be35fb5 100644 --- a/packages/editor/src/components/document-outline/test/index.js +++ b/packages/editor/src/components/document-outline/test/index.js @@ -25,7 +25,7 @@ describe( 'DocumentOutline', () => { let paragraph, headingH1, headingParent, headingChild, nestedHeading; beforeAll( () => { registerBlockType( 'core/heading', { - category: 'common', + category: 'text', title: 'Heading', edit: () => {}, save: () => {}, @@ -41,14 +41,14 @@ describe( 'DocumentOutline', () => { } ); registerBlockType( 'core/paragraph', { - category: 'common', + category: 'text', title: 'Paragraph', edit: () => {}, save: () => {}, } ); registerBlockType( 'core/columns', { - category: 'common', + category: 'text', title: 'Paragraph', edit: () => {}, save: () => {}, diff --git a/packages/editor/src/store/effects/test/reusable-blocks.js b/packages/editor/src/store/effects/test/reusable-blocks.js index 40ed6d5bdc25d1..5a3b198b78dffa 100644 --- a/packages/editor/src/store/effects/test/reusable-blocks.js +++ b/packages/editor/src/store/effects/test/reusable-blocks.js @@ -44,7 +44,7 @@ describe( 'reusable blocks effects', () => { beforeAll( () => { registerBlockType( 'core/test-block', { title: 'Test block', - category: 'common', + category: 'text', save: () => null, attributes: { name: { type: 'string' }, @@ -53,7 +53,7 @@ describe( 'reusable blocks effects', () => { registerBlockType( 'core/block', { title: 'Reusable Block', - category: 'common', + category: 'text', save: () => null, attributes: { ref: { type: 'string' }, diff --git a/packages/editor/src/store/test/selectors.js b/packages/editor/src/store/test/selectors.js index 25782997c88ced..c0c37ad182b5da 100644 --- a/packages/editor/src/store/test/selectors.js +++ b/packages/editor/src/store/test/selectors.js @@ -196,7 +196,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-a', { save: ( props ) => props.attributes.text, - category: 'formatting', + category: 'design', title: 'Test Block A', icon: 'test', keywords: [ 'testing' ], @@ -204,7 +204,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-b', { save: ( props ) => props.attributes.text, - category: 'common', + category: 'text', title: 'Test Block B', icon: 'test', keywords: [ 'testing' ], @@ -215,7 +215,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-block-c', { save: ( props ) => props.attributes.text, - category: 'common', + category: 'text', title: 'Test Block C', icon: 'test', keywords: [ 'testing' ], @@ -224,7 +224,7 @@ describe( 'selectors', () => { registerBlockType( 'core/test-freeform', { save: ( props ) => { props.attributes.content }, - category: 'common', + category: 'text', title: 'Test Freeform Content Handler', icon: 'test', supports: { @@ -238,7 +238,7 @@ describe( 'selectors', () => { } ); registerBlockType( 'core/test-default', { - category: 'common', + category: 'text', title: 'default', attributes: { modified: { @@ -2249,7 +2249,7 @@ describe( 'selectors', () => { originalDefaultBlockName = getDefaultBlockName(); registerBlockType( 'core/default', { - category: 'common', + category: 'text', title: 'default', attributes: { modified: { diff --git a/test/integration/blocks-raw-handling.test.js b/test/integration/blocks-raw-handling.test.js index 60a0722e3837f6..f3ae6e3b2d6ca3 100644 --- a/test/integration/blocks-raw-handling.test.js +++ b/test/integration/blocks-raw-handling.test.js @@ -30,7 +30,7 @@ describe( 'Blocks raw handling', () => { registerCoreBlocks(); registerBlockType( 'test/gallery', { title: 'Test Gallery', - category: 'common', + category: 'text', attributes: { ids: { type: 'array', @@ -63,7 +63,7 @@ describe( 'Blocks raw handling', () => { registerBlockType( 'test/non-inline-block', { title: 'Test Non Inline Block', - category: 'common', + category: 'text', supports: { pasteTextInline: false, }, diff --git a/test/integration/shortcode-converter.test.js b/test/integration/shortcode-converter.test.js index 5f5fa0dfc44442..7a74533c6d7dd0 100644 --- a/test/integration/shortcode-converter.test.js +++ b/test/integration/shortcode-converter.test.js @@ -14,7 +14,7 @@ describe( 'segmentHTMLToShortcodeBlock', () => { registerCoreBlocks(); registerBlockType( 'test/gallery', { title: 'Test Gallery', - category: 'common', + category: 'text', attributes: { ids: { type: 'array', @@ -42,7 +42,7 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); registerBlockType( 'test/broccoli', { title: 'Test Broccoli', - category: 'common', + category: 'text', attributes: { id: { type: 'number', @@ -70,7 +70,7 @@ describe( 'segmentHTMLToShortcodeBlock', () => { } ); registerBlockType( 'test/fallback-broccoli', { title: 'Test Fallback Broccoli', - category: 'common', + category: 'text', attributes: { id: { type: 'number',