From 1744a97e0e3c072126fc475d8b207a316cc05a9f Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 5 Jan 2021 12:50:44 +0200 Subject: [PATCH 1/5] Add Archive Title block --- lib/blocks.php | 1 + .../src/archive-title/block.json | 68 +++++++++++++++++++ .../block-library/src/archive-title/edit.js | 58 ++++++++++++++++ .../block-library/src/archive-title/index.js | 21 ++++++ .../block-library/src/archive-title/index.php | 48 +++++++++++++ packages/block-library/src/index.js | 2 + .../fixtures/blocks/core__archive-title.html | 1 + .../fixtures/blocks/core__archive-title.json | 12 ++++ .../blocks/core__archive-title.parsed.json | 18 +++++ .../core__archive-title.serialized.html | 1 + packages/icons/src/library/post-title.js | 5 +- 11 files changed, 231 insertions(+), 4 deletions(-) create mode 100644 packages/block-library/src/archive-title/block.json create mode 100644 packages/block-library/src/archive-title/edit.js create mode 100644 packages/block-library/src/archive-title/index.js create mode 100644 packages/block-library/src/archive-title/index.php create mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html diff --git a/lib/blocks.php b/lib/blocks.php index f4f5a6536cee2..a5ee13c3afa8b 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -50,6 +50,7 @@ function gutenberg_reregister_core_block_types() { 'block_names' => array_merge( array( 'archives.php' => 'core/archives', + 'archive-title.php' => 'core/archive-title', 'block.php' => 'core/block', 'calendar.php' => 'core/calendar', 'categories.php' => 'core/categories', diff --git a/packages/block-library/src/archive-title/block.json b/packages/block-library/src/archive-title/block.json new file mode 100644 index 0000000000000..9d233d27e1ee7 --- /dev/null +++ b/packages/block-library/src/archive-title/block.json @@ -0,0 +1,68 @@ +{ + "apiVersion": 2, + "name": "core/archive-title", + "category": "design", + "attributes": { + "textAlign": { + "type": "string" + }, + "level": { + "type": "number", + "default": 2 + } + }, + "supports": { + "align": [ "wide", "full" ], + "html": false, + "color": { + "gradients": true + }, + "fontSize": true, + "lineHeight": true, + "__experimentalFontFamily": true, + "__experimentalSelector": { + "core/archive-title/h1": { + "title": "h1", + "selector": "h1.wp-block-archive-title", + "attributes": { + "level": 1 + } + }, + "core/archive-title/h2": { + "title": "h2", + "selector": "h2.wp-block-archive-title", + "attributes": { + "level": 2 + } + }, + "core/archive-title/h3": { + "title": "h3", + "selector": "h3.wp-block-archive-title", + "attributes": { + "level": 3 + } + }, + "core/archive-title/h4": { + "title": "h4", + "selector": "h4.wp-block-archive-title", + "attributes": { + "level": 4 + } + }, + "core/archive-title/h5": { + "title": "h5", + "selector": "h5.wp-block-archive-title", + "attributes": { + "level": 5 + } + }, + "core/archive-title/h6": { + "title": "h6", + "selector": "h6.wp-block-archive-title", + "attributes": { + "level": 6 + } + } + } + } +} diff --git a/packages/block-library/src/archive-title/edit.js b/packages/block-library/src/archive-title/edit.js new file mode 100644 index 0000000000000..b62f37febc7db --- /dev/null +++ b/packages/block-library/src/archive-title/edit.js @@ -0,0 +1,58 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + +/** + * WordPress dependencies + */ +// import { useSelect, useDispatch } from '@wordpress/data'; +import { + AlignmentToolbar, + BlockControls, + useBlockProps, +} from '@wordpress/block-editor'; +import { ToolbarGroup } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import HeadingLevelDropdown from '../heading/heading-level-dropdown'; + +export default function ArchiveTitleEdit( { + attributes: { level, textAlign }, + setAttributes, +} ) { + const TagName = `h${ level }`; + const blockProps = useBlockProps( { + className: classnames( { + [ `has-text-align-${ textAlign }` ]: textAlign, + } ), + } ); + + const titleElement = ( + { __( 'Archive Title' ) } + ); + return ( + <> + + + + setAttributes( { level: newLevel } ) + } + /> + + { + setAttributes( { textAlign: nextAlign } ); + } } + /> + + { titleElement } + + ); +} diff --git a/packages/block-library/src/archive-title/index.js b/packages/block-library/src/archive-title/index.js new file mode 100644 index 0000000000000..f9907249deacb --- /dev/null +++ b/packages/block-library/src/archive-title/index.js @@ -0,0 +1,21 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { postTitle as icon } from '@wordpress/icons'; + +/** + * Internal dependencies + */ +import metadata from './block.json'; +import edit from './edit'; + +const { name } = metadata; +export { metadata, name }; + +export const settings = { + title: __( 'Archive Title' ), + description: __( 'Display the archive title based on the queried object.' ), + icon, // TODO create new Icon. + edit, +}; diff --git a/packages/block-library/src/archive-title/index.php b/packages/block-library/src/archive-title/index.php new file mode 100644 index 0000000000000..db2912a07ef84 --- /dev/null +++ b/packages/block-library/src/archive-title/index.php @@ -0,0 +1,48 @@ + $align_class_name ) ); + + return sprintf( + '<%1$s %2$s>%3$s', + $tag_name, + $wrapper_attributes, + get_the_archive_title() + ); +} + +/** + * Registers the `core/archive-title` block on the server. + */ +function register_block_core_archive_title() { + register_block_type_from_metadata( + __DIR__ . '/archive-title', + array( + 'render_callback' => 'render_block_core_archive_title', + ) + ); +} +add_action( 'init', 'register_block_core_archive_title' ); + + + diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 7cfcb0e0c74a9..7e2328fb4e0cd 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -62,6 +62,7 @@ import * as socialLinks from './social-links'; import * as socialLink from './social-link'; // Full Site Editing Blocks +import * as archiveTitle from './archive-title'; import * as siteLogo from './site-logo'; import * as siteTagline from './site-tagline'; import * as siteTitle from './site-title'; @@ -208,6 +209,7 @@ export const __experimentalRegisterExperimentalCoreBlocks = // Register Full Site Editing Blocks. ...( enableFSEBlocks ? [ + archiveTitle, siteLogo, siteTagline, siteTitle, diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.html b/packages/e2e-tests/fixtures/blocks/core__archive-title.html new file mode 100644 index 0000000000000..dfe8a473440fd --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__archive-title.html @@ -0,0 +1 @@ + diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.json b/packages/e2e-tests/fixtures/blocks/core__archive-title.json new file mode 100644 index 0000000000000..cd3d3b8c9e9b4 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__archive-title.json @@ -0,0 +1,12 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/archive-title", + "isValid": true, + "attributes": { + "level": 2 + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json b/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json new file mode 100644 index 0000000000000..358bb0693cfa5 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/archive-title", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html b/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html new file mode 100644 index 0000000000000..dfe8a473440fd --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html @@ -0,0 +1 @@ + diff --git a/packages/icons/src/library/post-title.js b/packages/icons/src/library/post-title.js index d271282f2e1df..0408aa03e00a5 100644 --- a/packages/icons/src/library/post-title.js +++ b/packages/icons/src/library/post-title.js @@ -5,10 +5,7 @@ import { Path, SVG } from '@wordpress/primitives'; const postTitle = ( - + ); From a6ceb90167cca6dd122624656ded9905b1c93fe0 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 5 Jan 2021 13:02:21 +0200 Subject: [PATCH 2/5] remove extra lines --- packages/block-library/src/archive-title/index.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/block-library/src/archive-title/index.php b/packages/block-library/src/archive-title/index.php index db2912a07ef84..76a3012f6f495 100644 --- a/packages/block-library/src/archive-title/index.php +++ b/packages/block-library/src/archive-title/index.php @@ -43,6 +43,3 @@ function register_block_core_archive_title() { ); } add_action( 'init', 'register_block_core_archive_title' ); - - - From 03b2704329a1b49a8180bce1e162dbca3e4edbbb Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 5 Jan 2021 13:18:29 +0200 Subject: [PATCH 3/5] convert to int --- packages/block-library/src/archive-title/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/archive-title/index.php b/packages/block-library/src/archive-title/index.php index 76a3012f6f495..972915baa621c 100644 --- a/packages/block-library/src/archive-title/index.php +++ b/packages/block-library/src/archive-title/index.php @@ -19,7 +19,7 @@ function render_block_core_archive_title( $attributes, $content, $block ) { return ''; } - $tag_name = isset( $attributes['level'] ) ? 'h' . $attributes['level'] : 'h2'; + $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h2'; $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); From 47aae1bb0620673f226c8fa496526ee09fa186a4 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Wed, 6 Jan 2021 13:42:36 +0200 Subject: [PATCH 4/5] Add new ArchiveTitle icon --- .../block-library/src/archive-title/index.js | 4 ++-- packages/icons/src/index.js | 1 + packages/icons/src/library/archive-title.js | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 packages/icons/src/library/archive-title.js diff --git a/packages/block-library/src/archive-title/index.js b/packages/block-library/src/archive-title/index.js index f9907249deacb..843f191b27091 100644 --- a/packages/block-library/src/archive-title/index.js +++ b/packages/block-library/src/archive-title/index.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { postTitle as icon } from '@wordpress/icons'; +import { archiveTitle as icon } from '@wordpress/icons'; /** * Internal dependencies @@ -16,6 +16,6 @@ export { metadata, name }; export const settings = { title: __( 'Archive Title' ), description: __( 'Display the archive title based on the queried object.' ), - icon, // TODO create new Icon. + icon, edit, }; diff --git a/packages/icons/src/index.js b/packages/icons/src/index.js index 8a7f6dba0502a..15ce3266f6330 100644 --- a/packages/icons/src/index.js +++ b/packages/icons/src/index.js @@ -5,6 +5,7 @@ export { default as alignJustify } from './library/align-justify'; export { default as alignLeft } from './library/align-left'; export { default as alignRight } from './library/align-right'; export { default as archive } from './library/archive'; +export { default as archiveTitle } from './library/archive-title'; export { default as arrowDown } from './library/arrow-down'; export { default as arrowLeft } from './library/arrow-left'; export { default as arrowRight } from './library/arrow-right'; diff --git a/packages/icons/src/library/archive-title.js b/packages/icons/src/library/archive-title.js new file mode 100644 index 0000000000000..68d6264988942 --- /dev/null +++ b/packages/icons/src/library/archive-title.js @@ -0,0 +1,16 @@ +/** + * WordPress dependencies + */ +import { SVG, Path } from '@wordpress/primitives'; + +const archiveTitle = ( + + + + +); + +export default archiveTitle; From 00d949f3a2febe072cf7b53e8d1a0a5fcec34495 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 18 Jan 2021 13:27:43 +0200 Subject: [PATCH 5/5] query title with block variations --- lib/blocks.php | 2 +- .../block-library/src/archive-title/index.php | 45 -------------- packages/block-library/src/index.js | 4 +- .../{archive-title => query-title}/block.json | 32 +++++----- .../{archive-title => query-title}/edit.js | 33 +++++++++-- .../{archive-title => query-title}/index.js | 6 +- .../block-library/src/query-title/index.php | 58 +++++++++++++++++++ .../src/query-title/variations.js | 58 +++++++++++++++++++ .../fixtures/blocks/core__archive-title.html | 1 - .../fixtures/blocks/core__archive-title.json | 12 ---- .../blocks/core__archive-title.parsed.json | 18 ------ .../core__archive-title.serialized.html | 1 - .../fixtures/blocks/core__query-title.html | 1 + 13 files changed, 170 insertions(+), 101 deletions(-) delete mode 100644 packages/block-library/src/archive-title/index.php rename packages/block-library/src/{archive-title => query-title}/block.json (59%) rename packages/block-library/src/{archive-title => query-title}/edit.js (61%) rename packages/block-library/src/{archive-title => query-title}/index.js (71%) create mode 100644 packages/block-library/src/query-title/index.php create mode 100644 packages/block-library/src/query-title/variations.js delete mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.html delete mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.json delete mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json delete mode 100644 packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__query-title.html diff --git a/lib/blocks.php b/lib/blocks.php index a5ee13c3afa8b..538ec09b91979 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -50,7 +50,6 @@ function gutenberg_reregister_core_block_types() { 'block_names' => array_merge( array( 'archives.php' => 'core/archives', - 'archive-title.php' => 'core/archive-title', 'block.php' => 'core/block', 'calendar.php' => 'core/calendar', 'categories.php' => 'core/categories', @@ -79,6 +78,7 @@ function gutenberg_reregister_core_block_types() { 'post-hierarchical-terms.php' => 'core/post-hierarchical-terms', 'post-tags.php' => 'core/post-tags', 'post-title.php' => 'core/post-title', + 'query-title.php' => 'core/query-title', 'query.php' => 'core/query', 'query-loop.php' => 'core/query-loop', 'query-pagination.php' => 'core/query-pagination', diff --git a/packages/block-library/src/archive-title/index.php b/packages/block-library/src/archive-title/index.php deleted file mode 100644 index 972915baa621c..0000000000000 --- a/packages/block-library/src/archive-title/index.php +++ /dev/null @@ -1,45 +0,0 @@ - $align_class_name ) ); - - return sprintf( - '<%1$s %2$s>%3$s', - $tag_name, - $wrapper_attributes, - get_the_archive_title() - ); -} - -/** - * Registers the `core/archive-title` block on the server. - */ -function register_block_core_archive_title() { - register_block_type_from_metadata( - __DIR__ . '/archive-title', - array( - 'render_callback' => 'render_block_core_archive_title', - ) - ); -} -add_action( 'init', 'register_block_core_archive_title' ); diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 7e2328fb4e0cd..a8ac7e980faa2 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -62,11 +62,11 @@ import * as socialLinks from './social-links'; import * as socialLink from './social-link'; // Full Site Editing Blocks -import * as archiveTitle from './archive-title'; import * as siteLogo from './site-logo'; import * as siteTagline from './site-tagline'; import * as siteTitle from './site-title'; import * as templatePart from './template-part'; +import * as queryTitle from './query-title'; import * as query from './query'; import * as queryLoop from './query-loop'; import * as queryPagination from './query-pagination'; @@ -209,11 +209,11 @@ export const __experimentalRegisterExperimentalCoreBlocks = // Register Full Site Editing Blocks. ...( enableFSEBlocks ? [ - archiveTitle, siteLogo, siteTagline, siteTitle, templatePart, + queryTitle, query, queryLoop, queryPagination, diff --git a/packages/block-library/src/archive-title/block.json b/packages/block-library/src/query-title/block.json similarity index 59% rename from packages/block-library/src/archive-title/block.json rename to packages/block-library/src/query-title/block.json index 9d233d27e1ee7..4a17720601af1 100644 --- a/packages/block-library/src/archive-title/block.json +++ b/packages/block-library/src/query-title/block.json @@ -1,8 +1,14 @@ { "apiVersion": 2, - "name": "core/archive-title", + "name": "core/query-title", "category": "design", "attributes": { + "content": { + "type": "string" + }, + "type": { + "type": "string" + }, "textAlign": { "type": "string" }, @@ -21,44 +27,44 @@ "lineHeight": true, "__experimentalFontFamily": true, "__experimentalSelector": { - "core/archive-title/h1": { + "core/query-title/h1": { "title": "h1", - "selector": "h1.wp-block-archive-title", + "selector": "h1.wp-block-query-title", "attributes": { "level": 1 } }, - "core/archive-title/h2": { + "core/query-title/h2": { "title": "h2", - "selector": "h2.wp-block-archive-title", + "selector": "h2.wp-block-query-title", "attributes": { "level": 2 } }, - "core/archive-title/h3": { + "core/query-title/h3": { "title": "h3", - "selector": "h3.wp-block-archive-title", + "selector": "h3.wp-block-query-title", "attributes": { "level": 3 } }, - "core/archive-title/h4": { + "core/query-title/h4": { "title": "h4", - "selector": "h4.wp-block-archive-title", + "selector": "h4.wp-block-query-title", "attributes": { "level": 4 } }, - "core/archive-title/h5": { + "core/query-title/h5": { "title": "h5", - "selector": "h5.wp-block-archive-title", + "selector": "h5.wp-block-query-title", "attributes": { "level": 5 } }, - "core/archive-title/h6": { + "core/query-title/h6": { "title": "h6", - "selector": "h6.wp-block-archive-title", + "selector": "h6.wp-block-query-title", "attributes": { "level": 6 } diff --git a/packages/block-library/src/archive-title/edit.js b/packages/block-library/src/query-title/edit.js similarity index 61% rename from packages/block-library/src/archive-title/edit.js rename to packages/block-library/src/query-title/edit.js index b62f37febc7db..c0c2e55ee29c1 100644 --- a/packages/block-library/src/archive-title/edit.js +++ b/packages/block-library/src/query-title/edit.js @@ -11,6 +11,7 @@ import { AlignmentToolbar, BlockControls, useBlockProps, + RichText, } from '@wordpress/block-editor'; import { ToolbarGroup } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; @@ -20,20 +21,40 @@ import { __ } from '@wordpress/i18n'; */ import HeadingLevelDropdown from '../heading/heading-level-dropdown'; -export default function ArchiveTitleEdit( { - attributes: { level, textAlign }, +export default function QueryTitleEdit( { + attributes: { content, type, level, textAlign }, setAttributes, } ) { const TagName = `h${ level }`; + const tagName = `h${ level }`; const blockProps = useBlockProps( { className: classnames( { [ `has-text-align-${ textAlign }` ]: textAlign, } ), } ); - - const titleElement = ( - { __( 'Archive Title' ) } - ); + let titleElement; + if ( type === 'archive' ) { + titleElement = ( + + { __( 'Archive title placeholder' ) } + + ); + } else { + titleElement = ( +
+ + setAttributes( { content: newContent } ) + } + disableLineBreaks={ true } + /> +
+ ); + } return ( <> diff --git a/packages/block-library/src/archive-title/index.js b/packages/block-library/src/query-title/index.js similarity index 71% rename from packages/block-library/src/archive-title/index.js rename to packages/block-library/src/query-title/index.js index 843f191b27091..dc0185eba25a8 100644 --- a/packages/block-library/src/archive-title/index.js +++ b/packages/block-library/src/query-title/index.js @@ -9,13 +9,15 @@ import { archiveTitle as icon } from '@wordpress/icons'; */ import metadata from './block.json'; import edit from './edit'; +import variations from './variations'; const { name } = metadata; export { metadata, name }; export const settings = { - title: __( 'Archive Title' ), - description: __( 'Display the archive title based on the queried object.' ), + title: __( 'Query Title' ), + description: __( 'Display the query title.' ), icon, edit, + variations, }; diff --git a/packages/block-library/src/query-title/index.php b/packages/block-library/src/query-title/index.php new file mode 100644 index 0000000000000..662282955a9dc --- /dev/null +++ b/packages/block-library/src/query-title/index.php @@ -0,0 +1,58 @@ +found_posts, get_search_query() ); + $title = str_replace( $formats, $replacements, $title ); + } + $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h2'; + $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + return sprintf( + '<%1$s %2$s>%3$s', + $tag_name, + $wrapper_attributes, + $title + ); +} + +/** + * Registers the `core/query-title` block on the server. + */ +function register_block_core_query_title() { + register_block_type_from_metadata( + __DIR__ . '/query-title', + array( + 'render_callback' => 'render_block_core_query_title', + ) + ); +} +add_action( 'init', 'register_block_core_query_title' ); diff --git a/packages/block-library/src/query-title/variations.js b/packages/block-library/src/query-title/variations.js new file mode 100644 index 0000000000000..ed9a90438fb80 --- /dev/null +++ b/packages/block-library/src/query-title/variations.js @@ -0,0 +1,58 @@ +/** + * WordPress dependencies + */ +import { _x, __ } from '@wordpress/i18n'; +import { archiveTitle } from '@wordpress/icons'; +const variations = [ + { + name: 'custom-query-title', + title: __( 'Custom query Title' ), + description: __( 'Display a custom query title.' ), + icon: archiveTitle, + attributes: { type: 'custom', content: '' }, + scope: [ 'inserter', 'transform' ], + isDefault: true, + }, + { + name: 'archive-title', + title: __( 'Archive Title' ), + description: __( + 'Display the archive title based on the queried object.' + ), + icon: archiveTitle, + attributes: { + type: 'archive', + content: __( 'Archive title placeholder' ), + }, + scope: [ 'inserter', 'transform' ], + }, + { + name: 'search-title', + title: __( 'Search title' ), + description: __( + 'Displays a title in a search template, using search related format placeholders.' + ), + attributes: { + type: 'search', + // translators: Title for search template with dynamic content placeholders. + content: _x( + '%total% results found for "%search%"', + 'search template title' + ), + }, + scope: [ 'inserter', 'transform' ], + }, +]; + +/** + * Add `isActive` function to all `query-title` variations, if not defined. + * `isActive` function is used to find a variation match from a created + * Block by providing its attributes. + */ +variations.forEach( ( variation ) => { + if ( variation.isActive ) return; + variation.isActive = ( blockAttributes, variationAttributes ) => + blockAttributes.type === variationAttributes.type; +} ); + +export default variations; diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.html b/packages/e2e-tests/fixtures/blocks/core__archive-title.html deleted file mode 100644 index dfe8a473440fd..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__archive-title.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.json b/packages/e2e-tests/fixtures/blocks/core__archive-title.json deleted file mode 100644 index cd3d3b8c9e9b4..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__archive-title.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "clientId": "_clientId_0", - "name": "core/archive-title", - "isValid": true, - "attributes": { - "level": 2 - }, - "innerBlocks": [], - "originalContent": "" - } -] diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json b/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json deleted file mode 100644 index 358bb0693cfa5..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__archive-title.parsed.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "blockName": "core/archive-title", - "attrs": {}, - "innerBlocks": [], - "innerHTML": "", - "innerContent": [] - }, - { - "blockName": null, - "attrs": {}, - "innerBlocks": [], - "innerHTML": "\n", - "innerContent": [ - "\n" - ] - } -] diff --git a/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html b/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html deleted file mode 100644 index dfe8a473440fd..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__archive-title.serialized.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/e2e-tests/fixtures/blocks/core__query-title.html b/packages/e2e-tests/fixtures/blocks/core__query-title.html new file mode 100644 index 0000000000000..2fa05648f259f --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__query-title.html @@ -0,0 +1 @@ +