From 13aed59ae2b0d27072e6e94bec1ddf13f6bedc11 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 13 Apr 2021 15:41:57 +0300 Subject: [PATCH 1/4] Add wrapper in Query block --- .../src/query-pagination/block.json | 1 + packages/block-library/src/query/block.json | 1 + .../block-library/src/query/deprecated.js | 47 +++++++++++++++++++ packages/block-library/src/query/index.js | 2 + packages/block-library/src/query/save.js | 8 +++- .../fixtures/blocks/core__query.html | 4 +- .../fixtures/blocks/core__query.json | 2 +- .../fixtures/blocks/core__query.parsed.json | 15 +++++- .../blocks/core__query.serialized.html | 4 +- .../blocks/core__query__deprecated-1.html | 1 + .../blocks/core__query__deprecated-1.json | 29 ++++++++++++ .../core__query__deprecated-1.parsed.json | 18 +++++++ .../core__query__deprecated-1.serialized.html | 3 ++ 13 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 packages/block-library/src/query/deprecated.js create mode 100644 packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.serialized.html diff --git a/packages/block-library/src/query-pagination/block.json b/packages/block-library/src/query-pagination/block.json index edab3acc951d65..44ccb0f9ee3822 100644 --- a/packages/block-library/src/query-pagination/block.json +++ b/packages/block-library/src/query-pagination/block.json @@ -4,6 +4,7 @@ "category": "design", "usesContext": [ "queryId", "query" ], "supports": { + "align": true, "reusable": false, "html": false }, diff --git a/packages/block-library/src/query/block.json b/packages/block-library/src/query/block.json index fc557abee646e3..e64e3350b22d11 100644 --- a/packages/block-library/src/query/block.json +++ b/packages/block-library/src/query/block.json @@ -37,6 +37,7 @@ "layout": "layout" }, "supports": { + "align": [ "wide", "full" ], "html": false }, "editorStyle": "wp-block-query-editor" diff --git a/packages/block-library/src/query/deprecated.js b/packages/block-library/src/query/deprecated.js new file mode 100644 index 00000000000000..e39ad4cf372496 --- /dev/null +++ b/packages/block-library/src/query/deprecated.js @@ -0,0 +1,47 @@ +/** + * WordPress dependencies + */ +import { InnerBlocks } from '@wordpress/block-editor'; + +const deprecated = [ + // Version with NO wrapper `div` element. + { + attributes: { + queryId: { + type: 'number', + }, + query: { + type: 'object', + default: { + perPage: null, + pages: 0, + offset: 0, + postType: 'post', + categoryIds: [], + tagIds: [], + order: 'desc', + orderBy: 'date', + author: '', + search: '', + exclude: [], + sticky: '', + inherit: true, + }, + }, + layout: { + type: 'object', + default: { + type: 'list', + }, + }, + }, + supports: { + html: false, + }, + save() { + return ; + }, + }, +]; + +export default deprecated; diff --git a/packages/block-library/src/query/index.js b/packages/block-library/src/query/index.js index 317fd1b0445739..b5cd3ec4041fbc 100644 --- a/packages/block-library/src/query/index.js +++ b/packages/block-library/src/query/index.js @@ -11,6 +11,7 @@ import metadata from './block.json'; import edit from './edit'; import save from './save'; import variations from './variations'; +import deprecated from './deprecated'; const { name } = metadata; export { metadata, name }; @@ -22,4 +23,5 @@ export const settings = { edit, save, variations, + deprecated, }; diff --git a/packages/block-library/src/query/save.js b/packages/block-library/src/query/save.js index d9b9bec9c7bc26..4705f671580c5a 100644 --- a/packages/block-library/src/query/save.js +++ b/packages/block-library/src/query/save.js @@ -1,8 +1,12 @@ /** * WordPress dependencies */ -import { InnerBlocks } from '@wordpress/block-editor'; +import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; export default function QuerySave() { - return ; + return ( +
+ +
+ ); } diff --git a/packages/e2e-tests/fixtures/blocks/core__query.html b/packages/e2e-tests/fixtures/blocks/core__query.html index b15b17b5bd4197..3bc4085f4f090d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query.html +++ b/packages/e2e-tests/fixtures/blocks/core__query.html @@ -1 +1,3 @@ - + +
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__query.json b/packages/e2e-tests/fixtures/blocks/core__query.json index 19ef71fdf3bcb8..91150a3fdba46b 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query.json +++ b/packages/e2e-tests/fixtures/blocks/core__query.json @@ -24,6 +24,6 @@ } }, "innerBlocks": [], - "originalContent": "" + "originalContent": "
" } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__query.parsed.json b/packages/e2e-tests/fixtures/blocks/core__query.parsed.json index bbdd465acf5118..c26f382360fbb1 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__query.parsed.json @@ -3,7 +3,18 @@ "blockName": "core/query", "attrs": {}, "innerBlocks": [], - "innerHTML": "", - "innerContent": [] + "innerHTML": "\n
\n", + "innerContent": [ + "\n
\n" + ] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__query.serialized.html b/packages/e2e-tests/fixtures/blocks/core__query.serialized.html index b15b17b5bd4197..3bc4085f4f090d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query.serialized.html +++ b/packages/e2e-tests/fixtures/blocks/core__query.serialized.html @@ -1 +1,3 @@ - + +
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.html b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.html new file mode 100644 index 00000000000000..b15b17b5bd4197 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.html @@ -0,0 +1 @@ + diff --git a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.json b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.json new file mode 100644 index 00000000000000..19ef71fdf3bcb8 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.json @@ -0,0 +1,29 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/query", + "isValid": true, + "attributes": { + "query": { + "perPage": null, + "pages": 0, + "offset": 0, + "postType": "post", + "categoryIds": [], + "tagIds": [], + "order": "desc", + "orderBy": "date", + "author": "", + "search": "", + "exclude": [], + "sticky": "", + "inherit": true + }, + "layout": { + "type": "list" + } + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json new file mode 100644 index 00000000000000..3354da9130a84e --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json @@ -0,0 +1,18 @@ +[ + { + "blockName": "core/query", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + }, + { + "blockName": null, + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n", + "innerContent": [ + "\n" + ] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.serialized.html b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.serialized.html new file mode 100644 index 00000000000000..366975244609ab --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.serialized.html @@ -0,0 +1,3 @@ + +
+ From 26165b39a38fffb9b3c58cad79fc49dd7c6221e0 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 23 Apr 2021 14:17:39 +0300 Subject: [PATCH 2/4] fix fixtures --- .../e2e-tests/fixtures/blocks/core__query.parsed.json | 9 --------- .../blocks/core__query__deprecated-1.parsed.json | 9 --------- 2 files changed, 18 deletions(-) diff --git a/packages/e2e-tests/fixtures/blocks/core__query.parsed.json b/packages/e2e-tests/fixtures/blocks/core__query.parsed.json index c26f382360fbb1..a5700a3adad69d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__query.parsed.json @@ -7,14 +7,5 @@ "innerContent": [ "\n
\n" ] - }, - { - "blockName": null, - "attrs": {}, - "innerBlocks": [], - "innerHTML": "\n", - "innerContent": [ - "\n" - ] } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json index 3354da9130a84e..bbdd465acf5118 100644 --- a/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__query__deprecated-1.parsed.json @@ -5,14 +5,5 @@ "innerBlocks": [], "innerHTML": "", "innerContent": [] - }, - { - "blockName": null, - "attrs": {}, - "innerBlocks": [], - "innerHTML": "\n", - "innerContent": [ - "\n" - ] } ] From 4320a209d2bc86920e43338b2ebd7f00685c63a7 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 27 Apr 2021 09:59:13 +0300 Subject: [PATCH 3/4] remove unneeded await --- packages/e2e-tests/experimental-features.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-tests/experimental-features.js b/packages/e2e-tests/experimental-features.js index c58f08e018d4f3..c8a6b495dd8add 100644 --- a/packages/e2e-tests/experimental-features.js +++ b/packages/e2e-tests/experimental-features.js @@ -131,7 +131,7 @@ export const siteEditor = { }, async getEditedPostContent() { - return await page.evaluate( async () => { + return page.evaluate( async () => { const postId = window.wp.data .select( 'core/edit-site' ) .getEditedPostId(); From 2a3a8f4fa99d74419b70c989dad11d1cb856380e Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 27 Apr 2021 10:13:25 +0300 Subject: [PATCH 4/4] update GB Query patterns --- lib/block-patterns.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/block-patterns.php b/lib/block-patterns.php index d0ac6e9c081e93..d88f42fab05349 100644 --- a/lib/block-patterns.php +++ b/lib/block-patterns.php @@ -16,6 +16,7 @@ 'blockTypes' => array( 'core/query' ), 'categories' => array( 'query' ), 'content' => ' +
@@ -25,6 +26,7 @@ +
', ) ); @@ -36,6 +38,7 @@ 'blockTypes' => array( 'core/query' ), 'categories' => array( 'query' ), 'content' => ' +
@@ -47,6 +50,7 @@
+
', ) ); @@ -58,6 +62,7 @@ 'blockTypes' => array( 'core/query' ), 'categories' => array( 'query' ), 'content' => ' +
@@ -68,6 +73,7 @@
+
', ) ); @@ -79,6 +85,7 @@ 'blockTypes' => array( 'core/query' ), 'categories' => array( 'query' ), 'content' => ' +
@@ -86,6 +93,7 @@
+ ', ) ); @@ -98,7 +106,7 @@ 'categories' => array( 'query' ), 'content' => '
- +

@@ -112,7 +120,7 @@
- +
', ) @@ -128,26 +136,26 @@
- +
- +
- +
- +