From f455ffef10633f2a4c97bb98347b20aceb1333a5 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sun, 9 Apr 2023 21:34:42 +0900 Subject: [PATCH 1/7] Table Block: Fixed width table cells on by default --- packages/block-library/src/table/block.json | 2 +- .../block-library/src/table/deprecated.js | 294 +++++++++++++++++- .../api/raw-handling/test/paste-handler.js | 4 +- ...llows-a-caption-to-be-added-1-chromium.txt | 2 +- ...able-header-body-and-footer-1-chromium.txt | 2 +- ...able-header-body-and-footer-2-chromium.txt | 2 +- ...-of-the-RichText-is-clicked-1-chromium.txt | 2 +- ...llows-columns-to-be-aligned-1-chromium.txt | 2 +- ...s-to-be-switched-on-and-off-1-chromium.txt | 2 +- ...s-to-be-switched-on-and-off-2-chromium.txt | 2 +- ...text-to-by-typed-into-cells-1-chromium.txt | 2 +- ...d-column-count-of-the-table-1-chromium.txt | 2 +- ...p-and-down-arrow-navigation-1-chromium.txt | 2 +- .../specs/editor/various/writing-flow.spec.js | 2 +- .../fixtures/blocks/core__table.html | 2 +- .../fixtures/blocks/core__table.parsed.json | 4 +- .../blocks/core__table.serialized.html | 2 +- .../fixtures/blocks/core__table__caption.html | 2 +- .../blocks/core__table__caption.parsed.json | 4 +- .../core__table__caption.serialized.html | 2 +- .../blocks/core__table__deprecated-1.html | 2 +- .../core__table__deprecated-1.parsed.json | 1 + .../core__table__deprecated-1.serialized.html | 2 +- .../blocks/core__table__deprecated-2.html | 2 +- .../core__table__deprecated-2.parsed.json | 4 +- .../core__table__deprecated-2.serialized.html | 2 +- .../blocks/core__table__deprecated-3.html | 2 +- .../core__table__deprecated-3.parsed.json | 4 +- .../core__table__deprecated-3.serialized.html | 2 +- .../blocks/core__table__deprecated-4.html | 3 + .../blocks/core__table__deprecated-4.json | 144 +++++++++ .../core__table__deprecated-4.parsed.json | 11 + .../core__table__deprecated-4.serialized.html | 3 + .../blocks/core__table__scope-attribute.html | 2 +- .../core__table__scope-attribute.parsed.json | 4 +- ...re__table__scope-attribute.serialized.html | 2 +- .../fixtures/documents/apple-out.html | 2 +- .../fixtures/documents/evernote-out.html | 2 +- .../fixtures/documents/google-docs-out.html | 2 +- .../documents/google-docs-table-out.html | 2 +- .../google-docs-table-with-colspan-out.html | 2 +- .../google-docs-table-with-comments-out.html | 2 +- .../google-docs-table-with-rowspan-out.html | 2 +- .../google-docs-with-comments-out.html | 2 +- .../fixtures/documents/markdown-out.html | 4 +- .../documents/ms-word-online-out.html | 2 +- .../fixtures/documents/ms-word-out.html | 2 +- 47 files changed, 508 insertions(+), 44 deletions(-) create mode 100644 test/integration/fixtures/blocks/core__table__deprecated-4.html create mode 100644 test/integration/fixtures/blocks/core__table__deprecated-4.json create mode 100644 test/integration/fixtures/blocks/core__table__deprecated-4.parsed.json create mode 100644 test/integration/fixtures/blocks/core__table__deprecated-4.serialized.html diff --git a/packages/block-library/src/table/block.json b/packages/block-library/src/table/block.json index 44177ef50a7e2..11dd5b5f323e3 100644 --- a/packages/block-library/src/table/block.json +++ b/packages/block-library/src/table/block.json @@ -9,7 +9,7 @@ "attributes": { "hasFixedLayout": { "type": "boolean", - "default": false + "default": true }, "caption": { "type": "rich-text", diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index ed138c4518aa3..3ad41d5d052a3 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -12,6 +12,7 @@ import { useBlockProps, __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles, + __experimentalGetElementClassName, } from '@wordpress/block-editor'; // As the previous arbitrary colors won't match theme color palettes, the hex @@ -24,6 +25,297 @@ const oldColors = { 'subtle-pale-pink': '#fcf0ef', }; +// Fixed width table cells on by default. +const v4 = { + attributes: { + hasFixedLayout: { + type: 'boolean', + default: false, + }, + caption: { + type: 'rich-text', + source: 'rich-text', + selector: 'figcaption', + }, + head: { + type: 'array', + default: [], + source: 'query', + selector: 'thead tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, + }, + }, + }, + body: { + type: 'array', + default: [], + source: 'query', + selector: 'tbody tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, + }, + }, + }, + foot: { + type: 'array', + default: [], + source: 'query', + selector: 'tfoot tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, + }, + }, + }, + }, + supports: { + anchor: true, + align: true, + color: { + __experimentalSkipSerialization: true, + gradients: true, + __experimentalDefaultControls: { + background: true, + text: true, + }, + }, + spacing: { + margin: true, + padding: true, + __experimentalDefaultControls: { + margin: false, + padding: false, + }, + }, + typography: { + fontSize: true, + lineHeight: true, + __experimentalFontFamily: true, + __experimentalFontStyle: true, + __experimentalFontWeight: true, + __experimentalLetterSpacing: true, + __experimentalTextTransform: true, + __experimentalTextDecoration: true, + __experimentalDefaultControls: { + fontSize: true, + }, + }, + __experimentalBorder: { + __experimentalSkipSerialization: true, + color: true, + style: true, + width: true, + __experimentalDefaultControls: { + color: true, + style: true, + width: true, + }, + }, + __experimentalSelector: '.wp-block-table > table', + }, + save( { attributes } ) { + const { hasFixedLayout, head, body, foot, caption } = attributes; + const isEmpty = ! head.length && ! body.length && ! foot.length; + + if ( isEmpty ) { + return null; + } + + const colorProps = getColorClassesAndStyles( attributes ); + const borderProps = getBorderClassesAndStyles( attributes ); + + const classes = classnames( + colorProps.className, + borderProps.className, + { + 'has-fixed-layout': hasFixedLayout, + } + ); + + const hasCaption = ! RichText.isEmpty( caption ); + + const Section = ( { type, rows } ) => { + if ( ! rows.length ) { + return null; + } + + const Tag = `t${ type }`; + + return ( + + { rows.map( ( { cells }, rowIndex ) => ( + + { cells.map( + ( + { + content, + tag, + scope, + align, + colspan, + rowspan, + }, + cellIndex + ) => { + const cellClasses = classnames( { + [ `has-text-align-${ align }` ]: align, + } ); + + return ( + + ); + } + ) } + + ) ) } + + ); + }; + + return ( +
+ +
+
+
+
+ { hasCaption && ( + + ) } +
+ ); + }, +}; + // In #41140 support was added to global styles for caption elements which // added a `wp-element-caption` classname to the embed figcaption element. const v3 = { @@ -665,4 +957,4 @@ const v1 = { * * See block-deprecation.md */ -export default [ v3, v2, v1 ]; +export default [ v4, v3, v2, v1 ]; diff --git a/packages/blocks/src/api/raw-handling/test/paste-handler.js b/packages/blocks/src/api/raw-handling/test/paste-handler.js index ffd98fd4dadab..40a28f3c35a33 100644 --- a/packages/blocks/src/api/raw-handling/test/paste-handler.js +++ b/packages/blocks/src/api/raw-handling/test/paste-handler.js @@ -77,7 +77,7 @@ describe( 'pasteHandler', () => { delete result.attributes.caption; expect( result.attributes ).toEqual( { - hasFixedLayout: false, + hasFixedLayout: true, head: [ { cells: [ @@ -117,7 +117,7 @@ describe( 'pasteHandler', () => { delete result.attributes.caption; expect( result.attributes ).toEqual( { - hasFixedLayout: false, + hasFixedLayout: true, head: [ { cells: [ diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-a-caption-to-be-added-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-a-caption-to-be-added-1-chromium.txt index 144b62e5e5341..cf4c71986ba85 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-a-caption-to-be-added-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-a-caption-to-be-added-1-chromium.txt @@ -1,3 +1,3 @@ -
Caption!
+
Caption!
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-1-chromium.txt index 12024dcd6a8a0..c29304a4c7480 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-1-chromium.txt @@ -1,3 +1,3 @@ -
+
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-2-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-2-chromium.txt index 867cde963258b..c17f3e0825416 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-2-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-adding-and-deleting-columns-across-the-table-header-body-and-footer-2-chromium.txt @@ -1,3 +1,3 @@ -
+
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-cells-to-be-selected-when-the-cell-area-outside-of-the-RichText-is-clicked-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-cells-to-be-selected-when-the-cell-area-outside-of-the-RichText-is-clicked-1-chromium.txt index 6be90e739c1bb..06a2ec73cd7e9 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-cells-to-be-selected-when-the-cell-area-outside-of-the-RichText-is-clicked-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-cells-to-be-selected-when-the-cell-area-outside-of-the-RichText-is-clicked-1-chromium.txt @@ -1,3 +1,3 @@ - +




Second cell.
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-columns-to-be-aligned-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-columns-to-be-aligned-1-chromium.txt index 6986d5c5b54cd..fbc0a773057dc 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-columns-to-be-aligned-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-columns-to-be-aligned-1-chromium.txt @@ -1,3 +1,3 @@ -
NoneTo the leftCenteredRight aligned
+
NoneTo the leftCenteredRight aligned
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-1-chromium.txt index 467ab42d76805..1d20e6018be8d 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-1-chromium.txt @@ -1,3 +1,3 @@ -
header
body
footer
+
header
body
footer
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-2-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-2-chromium.txt index 0aa0e667b7141..8fbd8207d2f1a 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-2-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-header-and-footer-rows-to-be-switched-on-and-off-2-chromium.txt @@ -1,3 +1,3 @@ -
body
+
body
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-text-to-by-typed-into-cells-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-text-to-by-typed-into-cells-1-chromium.txt index adce67703575d..80c17e6de4f55 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-text-to-by-typed-into-cells-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-allows-text-to-by-typed-into-cells-1-chromium.txt @@ -1,3 +1,3 @@ -
Thisis
tableblock
+
Thisis
tableblock
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-displays-a-form-for-choosing-the-row-and-column-count-of-the-table-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-displays-a-form-for-choosing-the-row-and-column-count-of-the-table-1-chromium.txt index 39b6f395f28ad..3688278430c92 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-displays-a-form-for-choosing-the-row-and-column-count-of-the-table-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-displays-a-form-for-choosing-the-row-and-column-count-of-the-table-1-chromium.txt @@ -1,3 +1,3 @@ -
+
\ No newline at end of file diff --git a/test/e2e/specs/editor/blocks/__snapshots__/Table-up-and-down-arrow-navigation-1-chromium.txt b/test/e2e/specs/editor/blocks/__snapshots__/Table-up-and-down-arrow-navigation-1-chromium.txt index ea42038e553f9..9c0a994f5d294 100644 --- a/test/e2e/specs/editor/blocks/__snapshots__/Table-up-and-down-arrow-navigation-1-chromium.txt +++ b/test/e2e/specs/editor/blocks/__snapshots__/Table-up-and-down-arrow-navigation-1-chromium.txt @@ -1,3 +1,3 @@ -
14
23
+
14
23
\ No newline at end of file diff --git a/test/e2e/specs/editor/various/writing-flow.spec.js b/test/e2e/specs/editor/various/writing-flow.spec.js index 1022e636345b8..ae46a478218e8 100644 --- a/test/e2e/specs/editor/various/writing-flow.spec.js +++ b/test/e2e/specs/editor/various/writing-flow.spec.js @@ -923,7 +923,7 @@ test.describe( 'Writing Flow (@firefox, @webkit)', () => { // Confirm correct setup. await expect.poll( editor.getEditedPostContent ) .toBe( ` -
2
+
2
` ); } ); diff --git a/test/integration/fixtures/blocks/core__table.html b/test/integration/fixtures/blocks/core__table.html index 7cc12a4efb3b5..efafdc625a889 100644 --- a/test/integration/fixtures/blocks/core__table.html +++ b/test/integration/fixtures/blocks/core__table.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table.parsed.json b/test/integration/fixtures/blocks/core__table.parsed.json index 7bf372efab4c0..f58d38cb7617f 100644 --- a/test/integration/fixtures/blocks/core__table.parsed.json +++ b/test/integration/fixtures/blocks/core__table.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/table", - "attrs": {}, + "attrs": { + "hasFixedLayout": false + }, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table.serialized.html b/test/integration/fixtures/blocks/core__table.serialized.html index 95fc72534da7d..2ee8e6d734543 100644 --- a/test/integration/fixtures/blocks/core__table.serialized.html +++ b/test/integration/fixtures/blocks/core__table.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__caption.html b/test/integration/fixtures/blocks/core__table__caption.html index 110d0695e5a93..e235c38f233ac 100644 --- a/test/integration/fixtures/blocks/core__table__caption.html +++ b/test/integration/fixtures/blocks/core__table__caption.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__caption.parsed.json b/test/integration/fixtures/blocks/core__table__caption.parsed.json index 531c2d7e605c6..9043ca37bf361 100644 --- a/test/integration/fixtures/blocks/core__table__caption.parsed.json +++ b/test/integration/fixtures/blocks/core__table__caption.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/table", - "attrs": {}, + "attrs": { + "hasFixedLayout": false + }, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table__caption.serialized.html b/test/integration/fixtures/blocks/core__table__caption.serialized.html index 66246c83295a9..3f2f2b362e378 100644 --- a/test/integration/fixtures/blocks/core__table__caption.serialized.html +++ b/test/integration/fixtures/blocks/core__table__caption.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.html b/test/integration/fixtures/blocks/core__table__deprecated-1.html index ee205fffa4010..0d76db56ae06f 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json index 3499ffab32b2f..aa994cb684da2 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json @@ -2,6 +2,7 @@ { "blockName": "core/table", "attrs": { + "hasFixedLayout": false, "backgroundColor": "subtle-pale-blue" }, "innerBlocks": [], diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html b/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html index 061aa7a2248b1..3f72ff591d56e 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-2.html b/test/integration/fixtures/blocks/core__table__deprecated-2.html index b9b41659e835a..29402d8d4782f 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-2.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-2.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json index 4bc37144afbb7..1b46a798fe310 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/table", - "attrs": {}, + "attrs": { + "hasFixedLayout": false + }, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table__deprecated-2.serialized.html b/test/integration/fixtures/blocks/core__table__deprecated-2.serialized.html index 95fc72534da7d..2ee8e6d734543 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-2.serialized.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-2.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-3.html b/test/integration/fixtures/blocks/core__table__deprecated-3.html index a22436c55bdb1..01ab0b79b5fe0 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-3.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-3.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json index 030ced272fcab..d64e1c4dab5db 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/table", - "attrs": {}, + "attrs": { + "hasFixedLayout": false + }, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table__deprecated-3.serialized.html b/test/integration/fixtures/blocks/core__table__deprecated-3.serialized.html index 66246c83295a9..3f2f2b362e378 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-3.serialized.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-3.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-4.html b/test/integration/fixtures/blocks/core__table__deprecated-4.html new file mode 100644 index 0000000000000..a22436c55bdb1 --- /dev/null +++ b/test/integration/fixtures/blocks/core__table__deprecated-4.html @@ -0,0 +1,3 @@ + +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+ diff --git a/test/integration/fixtures/blocks/core__table__deprecated-4.json b/test/integration/fixtures/blocks/core__table__deprecated-4.json new file mode 100644 index 0000000000000..4f500a7691fa8 --- /dev/null +++ b/test/integration/fixtures/blocks/core__table__deprecated-4.json @@ -0,0 +1,144 @@ +[ + { + "name": "core/table", + "isValid": true, + "attributes": { + "hasFixedLayout": false, + "caption": "A table for testing", + "head": [ + { + "cells": [ + { + "content": "Version", + "tag": "th" + }, + { + "content": "Musician", + "tag": "th" + }, + { + "content": "Date", + "tag": "th" + } + ] + } + ], + "body": [ + { + "cells": [ + { + "content": ".70", + "tag": "td" + }, + { + "content": "No musician chosen.", + "tag": "td" + }, + { + "content": "May 27, 2003", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "1.0", + "tag": "td" + }, + { + "content": "Miles Davis", + "tag": "td" + }, + { + "content": "January 3, 2004", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "Lots of versions skipped, see the full list", + "tag": "td" + }, + { + "content": "…", + "tag": "td" + }, + { + "content": "…", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.4", + "tag": "td" + }, + { + "content": "Clifford Brown", + "tag": "td" + }, + { + "content": "December 8, 2015", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.5", + "tag": "td" + }, + { + "content": "Coleman Hawkins", + "tag": "td" + }, + { + "content": "April 12, 2016", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.6", + "tag": "td" + }, + { + "content": "Pepper Adams", + "tag": "td" + }, + { + "content": "August 16, 2016", + "tag": "td" + } + ] + }, + { + "cells": [ + { + "content": "4.7", + "tag": "td" + }, + { + "content": "Sarah Vaughan", + "tag": "td" + }, + { + "content": "December 6, 2016", + "tag": "td" + } + ] + } + ], + "foot": [] + }, + "innerBlocks": [] + } +] diff --git a/test/integration/fixtures/blocks/core__table__deprecated-4.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-4.parsed.json new file mode 100644 index 0000000000000..030ced272fcab --- /dev/null +++ b/test/integration/fixtures/blocks/core__table__deprecated-4.parsed.json @@ -0,0 +1,11 @@ +[ + { + "blockName": "core/table", + "attrs": {}, + "innerBlocks": [], + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", + "innerContent": [ + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n" + ] + } +] diff --git a/test/integration/fixtures/blocks/core__table__deprecated-4.serialized.html b/test/integration/fixtures/blocks/core__table__deprecated-4.serialized.html new file mode 100644 index 0000000000000..3f2f2b362e378 --- /dev/null +++ b/test/integration/fixtures/blocks/core__table__deprecated-4.serialized.html @@ -0,0 +1,3 @@ + +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+ diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.html b/test/integration/fixtures/blocks/core__table__scope-attribute.html index dfe5cdd5c2616..957f3f06ec58b 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.html +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json b/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json index 42844cfdf62c6..cf548ba6f901e 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json @@ -1,7 +1,9 @@ [ { "blockName": "core/table", - "attrs": {}, + "attrs": { + "hasFixedLayout": false + }, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html b/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html index dfe5cdd5c2616..957f3f06ec58b 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/documents/apple-out.html b/test/integration/fixtures/documents/apple-out.html index d873c942ea9ce..afada0ee3136e 100644 --- a/test/integration/fixtures/documents/apple-out.html +++ b/test/integration/fixtures/documents/apple-out.html @@ -43,7 +43,7 @@ -
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
diff --git a/test/integration/fixtures/documents/evernote-out.html b/test/integration/fixtures/documents/evernote-out.html index 19102ab70dc48..a5ff509c7a173 100644 --- a/test/integration/fixtures/documents/evernote-out.html +++ b/test/integration/fixtures/documents/evernote-out.html @@ -47,7 +47,7 @@ -
OneTwoThree
FourFiveSix
+
OneTwoThree
FourFiveSix
diff --git a/test/integration/fixtures/documents/google-docs-out.html b/test/integration/fixtures/documents/google-docs-out.html index e88311fab7b1f..f2ec15cf4f92a 100644 --- a/test/integration/fixtures/documents/google-docs-out.html +++ b/test/integration/fixtures/documents/google-docs-out.html @@ -43,7 +43,7 @@

This is a heading

-
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
diff --git a/test/integration/fixtures/documents/google-docs-table-out.html b/test/integration/fixtures/documents/google-docs-table-out.html index 07fe4106f3a6a..da51f75f3644e 100644 --- a/test/integration/fixtures/documents/google-docs-table-out.html +++ b/test/integration/fixtures/documents/google-docs-table-out.html @@ -1,3 +1,3 @@ -
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
diff --git a/test/integration/fixtures/documents/google-docs-table-with-colspan-out.html b/test/integration/fixtures/documents/google-docs-table-with-colspan-out.html index 3c397c142e34d..f063d499b0179 100644 --- a/test/integration/fixtures/documents/google-docs-table-with-colspan-out.html +++ b/test/integration/fixtures/documents/google-docs-table-with-colspan-out.html @@ -1,3 +1,3 @@ -
Test colspan
+
Test colspan
diff --git a/test/integration/fixtures/documents/google-docs-table-with-comments-out.html b/test/integration/fixtures/documents/google-docs-table-with-comments-out.html index 07fe4106f3a6a..da51f75f3644e 100644 --- a/test/integration/fixtures/documents/google-docs-table-with-comments-out.html +++ b/test/integration/fixtures/documents/google-docs-table-with-comments-out.html @@ -1,3 +1,3 @@ -
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
diff --git a/test/integration/fixtures/documents/google-docs-table-with-rowspan-out.html b/test/integration/fixtures/documents/google-docs-table-with-rowspan-out.html index d451d6eb2988b..94e0124e280e0 100644 --- a/test/integration/fixtures/documents/google-docs-table-with-rowspan-out.html +++ b/test/integration/fixtures/documents/google-docs-table-with-rowspan-out.html @@ -1,3 +1,3 @@ -
Test rowspan
+
Test rowspan
diff --git a/test/integration/fixtures/documents/google-docs-with-comments-out.html b/test/integration/fixtures/documents/google-docs-with-comments-out.html index e88311fab7b1f..f2ec15cf4f92a 100644 --- a/test/integration/fixtures/documents/google-docs-with-comments-out.html +++ b/test/integration/fixtures/documents/google-docs-with-comments-out.html @@ -43,7 +43,7 @@

This is a heading

-
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
diff --git a/test/integration/fixtures/documents/markdown-out.html b/test/integration/fixtures/documents/markdown-out.html index 31fa8dacbebf0..ed57e4e05e717 100644 --- a/test/integration/fixtures/documents/markdown-out.html +++ b/test/integration/fixtures/documents/markdown-out.html @@ -51,11 +51,11 @@

Table

-
First HeaderSecond Header
Content from cell 1Content from cell 2
Content in the first columnContent in the second column
+
First HeaderSecond Header
Content from cell 1Content from cell 2
Content in the first columnContent in the second column
-
Table with empty cells.
+
Table with empty cells.
diff --git a/test/integration/fixtures/documents/ms-word-online-out.html b/test/integration/fixtures/documents/ms-word-online-out.html index 8187b598f9a91..2d8314bbf0fd6 100644 --- a/test/integration/fixtures/documents/ms-word-online-out.html +++ b/test/integration/fixtures/documents/ms-word-online-out.html @@ -39,7 +39,7 @@ -
One Two Three 
II III 
+
One Two Three 
II III 
diff --git a/test/integration/fixtures/documents/ms-word-out.html b/test/integration/fixtures/documents/ms-word-out.html index 98992494032b3..89eaa6f3bcd16 100644 --- a/test/integration/fixtures/documents/ms-word-out.html +++ b/test/integration/fixtures/documents/ms-word-out.html @@ -51,7 +51,7 @@

This is a heading level 2

-
OneTwoThree
123
IIIIII
+
OneTwoThree
123
IIIIII
From bebdaf94a499b08285276f6aa7aa1b2f6c2b07f0 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Tue, 19 Mar 2024 21:23:06 +0900 Subject: [PATCH 2/7] Add interactivity support to deprecation --- packages/block-library/src/table/deprecated.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index 3ad41d5d052a3..a8afbc2aab9b5 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -217,6 +217,9 @@ const v4 = { }, }, __experimentalSelector: '.wp-block-table > table', + interactivity: { + clientNavigation: true, + }, }, save( { attributes } ) { const { hasFixedLayout, head, body, foot, caption } = attributes; From 4ecaf7a1b0dc8f9a1c05648ce09bba5d079f0609 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Tue, 19 Mar 2024 21:40:29 +0900 Subject: [PATCH 3/7] Revert some fixture changes --- .../fixtures/blocks/core__table__deprecated-1.html | 2 +- .../fixtures/blocks/core__table__deprecated-1.parsed.json | 1 - .../fixtures/blocks/core__table__deprecated-2.html | 2 +- .../fixtures/blocks/core__table__deprecated-2.parsed.json | 4 +--- .../fixtures/blocks/core__table__deprecated-3.html | 2 +- .../fixtures/blocks/core__table__deprecated-3.parsed.json | 4 +--- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.html b/test/integration/fixtures/blocks/core__table__deprecated-1.html index 0d76db56ae06f..ee205fffa4010 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
Table Caption
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json index aa994cb684da2..3499ffab32b2f 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-1.parsed.json @@ -2,7 +2,6 @@ { "blockName": "core/table", "attrs": { - "hasFixedLayout": false, "backgroundColor": "subtle-pale-blue" }, "innerBlocks": [], diff --git a/test/integration/fixtures/blocks/core__table__deprecated-2.html b/test/integration/fixtures/blocks/core__table__deprecated-2.html index 29402d8d4782f..b9b41659e835a 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-2.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-2.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json index 1b46a798fe310..4bc37144afbb7 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-2.parsed.json @@ -1,9 +1,7 @@ [ { "blockName": "core/table", - "attrs": { - "hasFixedLayout": false - }, + "attrs": {}, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ diff --git a/test/integration/fixtures/blocks/core__table__deprecated-3.html b/test/integration/fixtures/blocks/core__table__deprecated-3.html index 01ab0b79b5fe0..a22436c55bdb1 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-3.html +++ b/test/integration/fixtures/blocks/core__table__deprecated-3.html @@ -1,3 +1,3 @@ - +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json b/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json index d64e1c4dab5db..030ced272fcab 100644 --- a/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json +++ b/test/integration/fixtures/blocks/core__table__deprecated-3.parsed.json @@ -1,9 +1,7 @@ [ { "blockName": "core/table", - "attrs": { - "hasFixedLayout": false - }, + "attrs": {}, "innerBlocks": [], "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", "innerContent": [ From c91fb5024bb5ae0c0013197f56593a6a9651e3bf Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Tue, 19 Mar 2024 22:06:35 +0900 Subject: [PATCH 4/7] Update some fixtures --- test/integration/fixtures/blocks/core__table.html | 4 ++-- test/integration/fixtures/blocks/core__table.json | 2 +- test/integration/fixtures/blocks/core__table.parsed.json | 8 +++----- .../fixtures/blocks/core__table.serialized.html | 4 ++-- .../integration/fixtures/blocks/core__table__caption.html | 4 ++-- .../integration/fixtures/blocks/core__table__caption.json | 2 +- .../fixtures/blocks/core__table__caption.parsed.json | 8 +++----- .../fixtures/blocks/core__table__caption.serialized.html | 4 ++-- .../fixtures/blocks/core__table__scope-attribute.html | 4 ++-- .../fixtures/blocks/core__table__scope-attribute.json | 2 +- .../blocks/core__table__scope-attribute.parsed.json | 8 +++----- .../blocks/core__table__scope-attribute.serialized.html | 4 ++-- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/test/integration/fixtures/blocks/core__table.html b/test/integration/fixtures/blocks/core__table.html index efafdc625a889..3ea74325cfb8c 100644 --- a/test/integration/fixtures/blocks/core__table.html +++ b/test/integration/fixtures/blocks/core__table.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table.json b/test/integration/fixtures/blocks/core__table.json index a694b52a94c39..015e57d8a45d7 100644 --- a/test/integration/fixtures/blocks/core__table.json +++ b/test/integration/fixtures/blocks/core__table.json @@ -3,7 +3,7 @@ "name": "core/table", "isValid": true, "attributes": { - "hasFixedLayout": false, + "hasFixedLayout": true, "caption": "", "head": [ { diff --git a/test/integration/fixtures/blocks/core__table.parsed.json b/test/integration/fixtures/blocks/core__table.parsed.json index f58d38cb7617f..c93936d8343ba 100644 --- a/test/integration/fixtures/blocks/core__table.parsed.json +++ b/test/integration/fixtures/blocks/core__table.parsed.json @@ -1,13 +1,11 @@ [ { "blockName": "core/table", - "attrs": { - "hasFixedLayout": false - }, + "attrs": {}, "innerBlocks": [], - "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ - "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__table.serialized.html b/test/integration/fixtures/blocks/core__table.serialized.html index 2ee8e6d734543..0a8200ad804bd 100644 --- a/test/integration/fixtures/blocks/core__table.serialized.html +++ b/test/integration/fixtures/blocks/core__table.serialized.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__caption.html b/test/integration/fixtures/blocks/core__table__caption.html index e235c38f233ac..26bf3950799d9 100644 --- a/test/integration/fixtures/blocks/core__table__caption.html +++ b/test/integration/fixtures/blocks/core__table__caption.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__caption.json b/test/integration/fixtures/blocks/core__table__caption.json index 4f500a7691fa8..ca284f20bdfa7 100644 --- a/test/integration/fixtures/blocks/core__table__caption.json +++ b/test/integration/fixtures/blocks/core__table__caption.json @@ -3,7 +3,7 @@ "name": "core/table", "isValid": true, "attributes": { - "hasFixedLayout": false, + "hasFixedLayout": true, "caption": "A table for testing", "head": [ { diff --git a/test/integration/fixtures/blocks/core__table__caption.parsed.json b/test/integration/fixtures/blocks/core__table__caption.parsed.json index 9043ca37bf361..bd6f605085e6f 100644 --- a/test/integration/fixtures/blocks/core__table__caption.parsed.json +++ b/test/integration/fixtures/blocks/core__table__caption.parsed.json @@ -1,13 +1,11 @@ [ { "blockName": "core/table", - "attrs": { - "hasFixedLayout": false - }, + "attrs": {}, "innerBlocks": [], - "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n", "innerContent": [ - "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n" + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__table__caption.serialized.html b/test/integration/fixtures/blocks/core__table__caption.serialized.html index 3f2f2b362e378..3cff780e78c3a 100644 --- a/test/integration/fixtures/blocks/core__table__caption.serialized.html +++ b/test/integration/fixtures/blocks/core__table__caption.serialized.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
A table for testing
diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.html b/test/integration/fixtures/blocks/core__table__scope-attribute.html index 957f3f06ec58b..65f558aa5c08a 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.html +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.json b/test/integration/fixtures/blocks/core__table__scope-attribute.json index 0b6f163489381..5cdf1d0ddd2fc 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.json +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.json @@ -3,7 +3,7 @@ "name": "core/table", "isValid": true, "attributes": { - "hasFixedLayout": false, + "hasFixedLayout": true, "caption": "", "head": [ { diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json b/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json index cf548ba6f901e..ec184dfefdf96 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.parsed.json @@ -1,13 +1,11 @@ [ { "blockName": "core/table", - "attrs": { - "hasFixedLayout": false - }, + "attrs": {}, "innerBlocks": [], - "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", + "innerHTML": "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n", "innerContent": [ - "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" + "\n
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
\n" ] } ] diff --git a/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html b/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html index 957f3f06ec58b..65f558aa5c08a 100644 --- a/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html +++ b/test/integration/fixtures/blocks/core__table__scope-attribute.serialized.html @@ -1,3 +1,3 @@ - -
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
+ +
VersionMusicianDate
.70No musician chosen.May 27, 2003
1.0Miles DavisJanuary 3, 2004
Lots of versions skipped, see the full list
4.4Clifford BrownDecember 8, 2015
4.5Coleman HawkinsApril 12, 2016
4.6Pepper AdamsAugust 16, 2016
4.7Sarah VaughanDecember 6, 2016
From 679c662dd5d36e96824bb6a6bede8d57a0158381 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Wed, 20 Mar 2024 12:17:20 +0900 Subject: [PATCH 5/7] Simplify attributes --- .../block-library/src/table/deprecated.js | 548 +++++------------- 1 file changed, 141 insertions(+), 407 deletions(-) diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index a8afbc2aab9b5..b4b31001038df 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -37,141 +37,57 @@ const v4 = { source: 'rich-text', selector: 'figcaption', }, - head: { - type: 'array', - default: [], - source: 'query', - selector: 'thead tr', - query: { - cells: { + ...[ 'head', 'body', 'foot' ].reduce( + ( acc, section ) => ( { + ...acc, + [ section ]: { type: 'array', default: [], source: 'query', - selector: 'td,th', + selector: `t${ section } tr`, query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, - }, - }, - }, - body: { - type: 'array', - default: [], - source: 'query', - selector: 'tbody tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, - }, - }, - }, - foot: { - type: 'array', - default: [], - source: 'query', - selector: 'tfoot tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, }, }, }, - }, - }, + } ), + {} + ), }, supports: { anchor: true, @@ -333,111 +249,47 @@ const v3 = { selector: 'figcaption', default: '', }, - head: { - type: 'array', - default: [], - source: 'query', - selector: 'thead tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, - }, - }, - }, - body: { - type: 'array', - default: [], - source: 'query', - selector: 'tbody tr', - query: { - cells: { + ...[ 'head', 'body', 'foot' ].reduce( + ( acc, section ) => ( { + ...acc, + [ section ]: { type: 'array', default: [], source: 'query', - selector: 'td,th', + selector: `t${ section } tr`, query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, }, }, }, - }, - }, - foot: { - type: 'array', - default: [], - source: 'query', - selector: 'tfoot tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, - }, - }, - }, + } ), + {} + ), }, supports: { anchor: true, @@ -579,111 +431,47 @@ const v2 = { selector: 'figcaption', default: '', }, - head: { - type: 'array', - default: [], - source: 'query', - selector: 'thead tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, - }, - }, - }, - body: { - type: 'array', - default: [], - source: 'query', - selector: 'tbody tr', - query: { - cells: { + ...[ 'head', 'body', 'foot' ].reduce( + ( acc, section ) => ( { + ...acc, + [ section ]: { type: 'array', default: [], source: 'query', - selector: 'td,th', + selector: `t${ section } tr`, query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, }, }, }, - }, - }, - foot: { - type: 'array', - default: [], - source: 'query', - selector: 'tfoot tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, - }, - }, - }, + } ), + {} + ), }, supports: { anchor: true, @@ -800,96 +588,42 @@ const v1 = { backgroundColor: { type: 'string', }, - head: { - type: 'array', - default: [], - source: 'query', - selector: 'thead tr', - query: { - cells: { + ...[ 'head', 'body', 'foot' ].reduce( + ( acc, section ) => ( { + ...acc, + [ section ]: { type: 'array', default: [], source: 'query', - selector: 'td,th', + selector: `t${ section } tr`, query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + }, }, }, }, - }, - }, - body: { - type: 'array', - default: [], - source: 'query', - selector: 'tbody tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, - }, - }, - }, - foot: { - type: 'array', - default: [], - source: 'query', - selector: 'tfoot tr', - query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, - }, - }, - }, + } ), + {} + ), }, supports: { align: true, From 4082dd8c19ae096e1702eab5995977a16c270ce0 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 21 Mar 2024 12:15:43 +0900 Subject: [PATCH 6/7] Revert "Simplify attributes" This reverts commit 679c662dd5d36e96824bb6a6bede8d57a0158381. --- .../block-library/src/table/deprecated.js | 548 +++++++++++++----- 1 file changed, 407 insertions(+), 141 deletions(-) diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index b4b31001038df..a8afbc2aab9b5 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -37,57 +37,141 @@ const v4 = { source: 'rich-text', selector: 'figcaption', }, - ...[ 'head', 'body', 'foot' ].reduce( - ( acc, section ) => ( { - ...acc, - [ section ]: { + head: { + type: 'array', + default: [], + source: 'query', + selector: 'thead tr', + query: { + cells: { type: 'array', default: [], source: 'query', - selector: `t${ section } tr`, + selector: 'td,th', query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, + }, + }, + }, + body: { + type: 'array', + default: [], + source: 'query', + selector: 'tbody tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, + }, + }, + }, + }, + foot: { + type: 'array', + default: [], + source: 'query', + selector: 'tfoot tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', }, }, }, - } ), - {} - ), + }, + }, }, supports: { anchor: true, @@ -249,47 +333,111 @@ const v3 = { selector: 'figcaption', default: '', }, - ...[ 'head', 'body', 'foot' ].reduce( - ( acc, section ) => ( { - ...acc, - [ section ]: { + head: { + type: 'array', + default: [], + source: 'query', + selector: 'thead tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, + }, + }, + }, + body: { + type: 'array', + default: [], + source: 'query', + selector: 'tbody tr', + query: { + cells: { type: 'array', default: [], source: 'query', - selector: `t${ section } tr`, + selector: 'td,th', query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', }, }, }, - } ), - {} - ), + }, + }, + foot: { + type: 'array', + default: [], + source: 'query', + selector: 'tfoot tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, + }, + }, + }, }, supports: { anchor: true, @@ -431,47 +579,111 @@ const v2 = { selector: 'figcaption', default: '', }, - ...[ 'head', 'body', 'foot' ].reduce( - ( acc, section ) => ( { - ...acc, - [ section ]: { + head: { + type: 'array', + default: [], + source: 'query', + selector: 'thead tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, + }, + }, + }, + body: { + type: 'array', + default: [], + source: 'query', + selector: 'tbody tr', + query: { + cells: { type: 'array', default: [], source: 'query', - selector: `t${ section } tr`, + selector: 'td,th', query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', }, }, }, - } ), - {} - ), + }, + }, + foot: { + type: 'array', + default: [], + source: 'query', + selector: 'tfoot tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + }, + }, + }, + }, }, supports: { anchor: true, @@ -588,42 +800,96 @@ const v1 = { backgroundColor: { type: 'string', }, - ...[ 'head', 'body', 'foot' ].reduce( - ( acc, section ) => ( { - ...acc, - [ section ]: { + head: { + type: 'array', + default: [], + source: 'query', + selector: 'thead tr', + query: { + cells: { type: 'array', default: [], source: 'query', - selector: `t${ section } tr`, + selector: 'td,th', query: { - cells: { - type: 'array', - default: [], - source: 'query', - selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', }, }, }, - } ), - {} - ), + }, + }, + body: { + type: 'array', + default: [], + source: 'query', + selector: 'tbody tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + }, + }, + }, + }, + foot: { + type: 'array', + default: [], + source: 'query', + selector: 'tfoot tr', + query: { + cells: { + type: 'array', + default: [], + source: 'query', + selector: 'td,th', + query: { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + }, + }, + }, + }, }, supports: { align: true, From d201b1cb534d8c82dd4269ead175f771d9c251aa Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 21 Mar 2024 12:32:11 +0900 Subject: [PATCH 7/7] Extract cell query --- .../block-library/src/table/deprecated.js | 372 +++++------------- 1 file changed, 105 insertions(+), 267 deletions(-) diff --git a/packages/block-library/src/table/deprecated.js b/packages/block-library/src/table/deprecated.js index a8afbc2aab9b5..43d4b0098a02f 100644 --- a/packages/block-library/src/table/deprecated.js +++ b/packages/block-library/src/table/deprecated.js @@ -26,6 +26,38 @@ const oldColors = { }; // Fixed width table cells on by default. +const v4Query = { + content: { + type: 'rich-text', + source: 'rich-text', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, + colspan: { + type: 'string', + source: 'attribute', + attribute: 'colspan', + }, + rowspan: { + type: 'string', + source: 'attribute', + attribute: 'rowspan', + }, +}; + const v4 = { attributes: { hasFixedLayout: { @@ -48,37 +80,7 @@ const v4 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, + query: v4Query, }, }, }, @@ -93,37 +95,7 @@ const v4 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, + query: v4Query, }, }, }, @@ -138,37 +110,7 @@ const v4 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'rich-text', - source: 'rich-text', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - colspan: { - type: 'string', - source: 'attribute', - attribute: 'colspan', - }, - rowspan: { - type: 'string', - source: 'attribute', - attribute: 'rowspan', - }, - }, + query: v4Query, }, }, }, @@ -321,6 +263,28 @@ const v4 = { // In #41140 support was added to global styles for caption elements which // added a `wp-element-caption` classname to the embed figcaption element. +const v3Query = { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, +}; + const v3 = { attributes: { hasFixedLayout: { @@ -344,27 +308,7 @@ const v3 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v3Query, }, }, }, @@ -379,27 +323,7 @@ const v3 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v3Query, }, }, }, @@ -414,27 +338,7 @@ const v3 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v3Query, }, }, }, @@ -564,6 +468,28 @@ const v3 = { }; // Deprecation migrating table block to use colors block support feature. +const v2Query = { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, + align: { + type: 'string', + source: 'attribute', + attribute: 'data-align', + }, +}; + const v2 = { attributes: { hasFixedLayout: { @@ -590,27 +516,7 @@ const v2 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v2Query, }, }, }, @@ -625,27 +531,7 @@ const v2 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v2Query, }, }, }, @@ -660,27 +546,7 @@ const v2 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - align: { - type: 'string', - source: 'attribute', - attribute: 'data-align', - }, - }, + query: v2Query, }, }, }, @@ -791,6 +657,23 @@ const v2 = { }, }; +const v1Query = { + content: { + type: 'string', + source: 'html', + }, + tag: { + type: 'string', + default: 'td', + source: 'tag', + }, + scope: { + type: 'string', + source: 'attribute', + attribute: 'scope', + }, +}; + const v1 = { attributes: { hasFixedLayout: { @@ -811,22 +694,7 @@ const v1 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, + query: v1Query, }, }, }, @@ -841,22 +709,7 @@ const v1 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, + query: v1Query, }, }, }, @@ -871,22 +724,7 @@ const v1 = { default: [], source: 'query', selector: 'td,th', - query: { - content: { - type: 'string', - source: 'html', - }, - tag: { - type: 'string', - default: 'td', - source: 'tag', - }, - scope: { - type: 'string', - source: 'attribute', - attribute: 'scope', - }, - }, + query: v1Query, }, }, },