From 8bd016d1e9fb146fe28115d72ce9047a7f48ff17 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sat, 17 Jun 2023 19:09:53 +0900 Subject: [PATCH 1/5] Details Block: Add deprecation to remove unnecessary comment attributes --- packages/block-library/src/details/block.json | 4 +- .../block-library/src/details/deprecated.js | 41 +++++++++++++++++++ packages/block-library/src/details/index.js | 2 + .../blocks/core__details.serialized.html | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 packages/block-library/src/details/deprecated.js diff --git a/packages/block-library/src/details/block.json b/packages/block-library/src/details/block.json index f3a0c00defdc3..27b4d2d717dd6 100644 --- a/packages/block-library/src/details/block.json +++ b/packages/block-library/src/details/block.json @@ -13,7 +13,9 @@ "default": false }, "summary": { - "type": "string" + "type": "string", + "source": "html", + "selector": "summary" } }, "supports": { diff --git a/packages/block-library/src/details/deprecated.js b/packages/block-library/src/details/deprecated.js new file mode 100644 index 0000000000000..6cbd39864d295 --- /dev/null +++ b/packages/block-library/src/details/deprecated.js @@ -0,0 +1,41 @@ +/** + * WordPress dependencies + */ +import { RichText, useBlockProps, InnerBlocks } from '@wordpress/block-editor'; + +// Deprecation for blocks that also stores the contents of the summary element as a comment delimiter. +const v0 = { + attributes: { + showContent: { + type: 'boolean', + default: false, + }, + summary: { + type: 'string', + }, + }, + save( { attributes } ) { + const { showContent } = attributes; + const summary = attributes.summary ? attributes.summary : 'Details'; + const blockProps = useBlockProps.save(); + + return ( +
+ + + + +
+ ); + }, +}; + +/** + * New deprecations need to be placed first + * for them to have higher priority. + * + * Old deprecations may need to be updated as well. + * + * See block-deprecation.md + */ +export default [ v0 ]; diff --git a/packages/block-library/src/details/index.js b/packages/block-library/src/details/index.js index e30d1a8e04974..4a858993e08cc 100644 --- a/packages/block-library/src/details/index.js +++ b/packages/block-library/src/details/index.js @@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import initBlock from '../utils/init-block'; +import deprecated from './deprecated'; import metadata from './block.json'; import edit from './edit'; import save from './save'; @@ -35,6 +36,7 @@ export const settings = { }, save, edit, + deprecated, }; export const init = () => initBlock( { name, metadata, settings } ); diff --git a/test/integration/fixtures/blocks/core__details.serialized.html b/test/integration/fixtures/blocks/core__details.serialized.html index d5d169983bbf3..a3e979414ac0d 100644 --- a/test/integration/fixtures/blocks/core__details.serialized.html +++ b/test/integration/fixtures/blocks/core__details.serialized.html @@ -1,4 +1,4 @@ - +
Details Summary

Details Content

From c17211353f7612672f9b9ffb2d4d206eeb86dfc1 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Mon, 19 Jun 2023 10:45:57 +0900 Subject: [PATCH 2/5] Add support property to v0 replication --- .../block-library/src/details/deprecated.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/block-library/src/details/deprecated.js b/packages/block-library/src/details/deprecated.js index 6cbd39864d295..e64bf11ce168e 100644 --- a/packages/block-library/src/details/deprecated.js +++ b/packages/block-library/src/details/deprecated.js @@ -14,6 +14,40 @@ const v0 = { type: 'string', }, }, + supports: { + align: [ 'wide', 'full' ], + color: { + gradients: true, + link: true, + __experimentalDefaultControls: { + background: true, + text: true, + }, + }, + __experimentalBorder: { + color: true, + width: true, + style: true, + }, + html: false, + spacing: { + margin: true, + padding: true, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontWeight: true, + __experimentalFontStyle: true, + __experimentalTextTransform: true, + __experimentalTextDecoration: true, + __experimentalLetterSpacing: true, + __experimentalDefaultControls: { + fontSize: true, + }, + }, + }, save( { attributes } ) { const { showContent } = attributes; const summary = attributes.summary ? attributes.summary : 'Details'; From d9d4f23b69450e9d3f306252d6c6718076b431dd Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Mon, 19 Jun 2023 10:50:21 +0900 Subject: [PATCH 3/5] Add fixture --- .../blocks/core__details__deprecated-v0.html | 7 ++++++ .../blocks/core__details__deprecated-v0.json | 22 ++++++++++++++++ .../core__details__deprecated-v0.parsed.json | 25 +++++++++++++++++++ ...re__details__deprecated-v0.serialized.html | 5 ++++ 4 files changed, 59 insertions(+) create mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.html create mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.json create mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json create mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.html b/test/integration/fixtures/blocks/core__details__deprecated-v0.html new file mode 100644 index 0000000000000..855ea3f0a4f55 --- /dev/null +++ b/test/integration/fixtures/blocks/core__details__deprecated-v0.html @@ -0,0 +1,7 @@ + +
Details Summary + +

Details Content

+ +
+ diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.json b/test/integration/fixtures/blocks/core__details__deprecated-v0.json new file mode 100644 index 0000000000000..e3873e4702db3 --- /dev/null +++ b/test/integration/fixtures/blocks/core__details__deprecated-v0.json @@ -0,0 +1,22 @@ +[ + { + "name": "core/details", + "isValid": true, + "attributes": { + "showContent": false, + "summary": "Details Summary" + }, + "innerBlocks": [ + { + "name": "core/paragraph", + "isValid": true, + "attributes": { + "content": "Details Content", + "dropCap": false, + "placeholder": "Type / to add a hidden block" + }, + "innerBlocks": [] + } + ] + } +] diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json b/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json new file mode 100644 index 0000000000000..3240c013e8e86 --- /dev/null +++ b/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json @@ -0,0 +1,25 @@ +[ + { + "blockName": "core/details", + "attrs": { + "summary": "Details Summary" + }, + "innerBlocks": [ + { + "blockName": "core/paragraph", + "attrs": { + "placeholder": "Type / to add a hidden block" + }, + "innerBlocks": [], + "innerHTML": "\n\t

Details Content

\n\t", + "innerContent": [ "\n\t

Details Content

\n\t" ] + } + ], + "innerHTML": "\n
Details Summary\n\t\n
\n", + "innerContent": [ + "\n
Details Summary\n\t", + null, + "\n
\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html b/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html new file mode 100644 index 0000000000000..a3e979414ac0d --- /dev/null +++ b/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html @@ -0,0 +1,5 @@ + +
Details Summary +

Details Content

+
+ From d07bf695dbc0fc7438aa626b61ace49bc0452ed0 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 3 Aug 2023 19:23:02 +0900 Subject: [PATCH 4/5] Update supports --- packages/block-library/src/details/deprecated.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/src/details/deprecated.js b/packages/block-library/src/details/deprecated.js index e64bf11ce168e..de23dcbbe7727 100644 --- a/packages/block-library/src/details/deprecated.js +++ b/packages/block-library/src/details/deprecated.js @@ -33,6 +33,10 @@ const v0 = { spacing: { margin: true, padding: true, + __experimentalDefaultControls: { + margin: false, + padding: false, + }, }, typography: { fontSize: true, From 597cb483ca958f5c139296d99a0d297062e9682a Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Fri, 4 Aug 2023 21:22:11 +0900 Subject: [PATCH 5/5] Remove deprecation and fixture --- .../block-library/src/details/deprecated.js | 79 ------------------- packages/block-library/src/details/index.js | 2 - .../blocks/core__details__deprecated-v0.html | 7 -- .../blocks/core__details__deprecated-v0.json | 22 ------ .../core__details__deprecated-v0.parsed.json | 25 ------ ...re__details__deprecated-v0.serialized.html | 5 -- 6 files changed, 140 deletions(-) delete mode 100644 packages/block-library/src/details/deprecated.js delete mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.html delete mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.json delete mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json delete mode 100644 test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html diff --git a/packages/block-library/src/details/deprecated.js b/packages/block-library/src/details/deprecated.js deleted file mode 100644 index de23dcbbe7727..0000000000000 --- a/packages/block-library/src/details/deprecated.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * WordPress dependencies - */ -import { RichText, useBlockProps, InnerBlocks } from '@wordpress/block-editor'; - -// Deprecation for blocks that also stores the contents of the summary element as a comment delimiter. -const v0 = { - attributes: { - showContent: { - type: 'boolean', - default: false, - }, - summary: { - type: 'string', - }, - }, - supports: { - align: [ 'wide', 'full' ], - color: { - gradients: true, - link: true, - __experimentalDefaultControls: { - background: true, - text: true, - }, - }, - __experimentalBorder: { - color: true, - width: true, - style: true, - }, - html: false, - spacing: { - margin: true, - padding: true, - __experimentalDefaultControls: { - margin: false, - padding: false, - }, - }, - typography: { - fontSize: true, - lineHeight: true, - __experimentalFontFamily: true, - __experimentalFontWeight: true, - __experimentalFontStyle: true, - __experimentalTextTransform: true, - __experimentalTextDecoration: true, - __experimentalLetterSpacing: true, - __experimentalDefaultControls: { - fontSize: true, - }, - }, - }, - save( { attributes } ) { - const { showContent } = attributes; - const summary = attributes.summary ? attributes.summary : 'Details'; - const blockProps = useBlockProps.save(); - - return ( -
- - - - -
- ); - }, -}; - -/** - * New deprecations need to be placed first - * for them to have higher priority. - * - * Old deprecations may need to be updated as well. - * - * See block-deprecation.md - */ -export default [ v0 ]; diff --git a/packages/block-library/src/details/index.js b/packages/block-library/src/details/index.js index 4a858993e08cc..e30d1a8e04974 100644 --- a/packages/block-library/src/details/index.js +++ b/packages/block-library/src/details/index.js @@ -8,7 +8,6 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import initBlock from '../utils/init-block'; -import deprecated from './deprecated'; import metadata from './block.json'; import edit from './edit'; import save from './save'; @@ -36,7 +35,6 @@ export const settings = { }, save, edit, - deprecated, }; export const init = () => initBlock( { name, metadata, settings } ); diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.html b/test/integration/fixtures/blocks/core__details__deprecated-v0.html deleted file mode 100644 index 855ea3f0a4f55..0000000000000 --- a/test/integration/fixtures/blocks/core__details__deprecated-v0.html +++ /dev/null @@ -1,7 +0,0 @@ - -
Details Summary - -

Details Content

- -
- diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.json b/test/integration/fixtures/blocks/core__details__deprecated-v0.json deleted file mode 100644 index e3873e4702db3..0000000000000 --- a/test/integration/fixtures/blocks/core__details__deprecated-v0.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "name": "core/details", - "isValid": true, - "attributes": { - "showContent": false, - "summary": "Details Summary" - }, - "innerBlocks": [ - { - "name": "core/paragraph", - "isValid": true, - "attributes": { - "content": "Details Content", - "dropCap": false, - "placeholder": "Type / to add a hidden block" - }, - "innerBlocks": [] - } - ] - } -] diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json b/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json deleted file mode 100644 index 3240c013e8e86..0000000000000 --- a/test/integration/fixtures/blocks/core__details__deprecated-v0.parsed.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "blockName": "core/details", - "attrs": { - "summary": "Details Summary" - }, - "innerBlocks": [ - { - "blockName": "core/paragraph", - "attrs": { - "placeholder": "Type / to add a hidden block" - }, - "innerBlocks": [], - "innerHTML": "\n\t

Details Content

\n\t", - "innerContent": [ "\n\t

Details Content

\n\t" ] - } - ], - "innerHTML": "\n
Details Summary\n\t\n
\n", - "innerContent": [ - "\n
Details Summary\n\t", - null, - "\n
\n" - ] - } -] diff --git a/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html b/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html deleted file mode 100644 index a3e979414ac0d..0000000000000 --- a/test/integration/fixtures/blocks/core__details__deprecated-v0.serialized.html +++ /dev/null @@ -1,5 +0,0 @@ - -
Details Summary -

Details Content

-
-