From 3102e12908da480756ea89c6e84af0b76e39eeaa Mon Sep 17 00:00:00 2001 From: Ramon Date: Fri, 19 Aug 2022 13:50:56 +1000 Subject: [PATCH] Table of contents: add spacing supports (#43368) * Adding spacing block supports to table of contents * Now that the table of contents block has a block supports it will appear in the site editor block search results for the term 'header'. 'header' appears in the block.json description and is therefore a match. --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/table-of-contents/block.json | 6 +++++- .../specs/site-editor/global-styles-sidebar.test.js | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 55873c33be8c5..6c37192d1799d 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -788,7 +788,7 @@ Summarize your post with a list of headings. Add HTML anchors to Heading blocks - **Name:** core/table-of-contents - **Category:** layout -- **Supports:** ~~html~~ +- **Supports:** spacing (margin, padding), ~~html~~ - **Attributes:** headings, onlyIncludeCurrentPage ## Tag Cloud diff --git a/packages/block-library/src/table-of-contents/block.json b/packages/block-library/src/table-of-contents/block.json index f846334f402ef..b305cb3242683 100644 --- a/packages/block-library/src/table-of-contents/block.json +++ b/packages/block-library/src/table-of-contents/block.json @@ -21,7 +21,11 @@ } }, "supports": { - "html": false + "html": false, + "spacing": { + "margin": true, + "padding": true + } }, "example": {} } diff --git a/packages/e2e-tests/specs/site-editor/global-styles-sidebar.test.js b/packages/e2e-tests/specs/site-editor/global-styles-sidebar.test.js index 36b615d202926..bcc81670ce8f0 100644 --- a/packages/e2e-tests/specs/site-editor/global-styles-sidebar.test.js +++ b/packages/e2e-tests/specs/site-editor/global-styles-sidebar.test.js @@ -36,7 +36,8 @@ describe( 'Global styles sidebar', () => { const results = await page.$$( '.edit-site-block-types-item-list div[role="listitem"]' ); - expect( results.length ).toEqual( 1 ); + // Matches both Heading and Table of Contents blocks. (The latter contains "heading" in its description.) + expect( results.length ).toEqual( 2 ); } ); } ); } );