From 3e45bf2eeede301f6c24a7b15197cbd17226f843 Mon Sep 17 00:00:00 2001 From: Nick Diego Date: Tue, 30 Jul 2024 11:26:27 -0500 Subject: [PATCH 1/2] Add `levelOptions` attribute to Site Tagline block. --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/site-tagline/block.json | 4 ++++ packages/block-library/src/site-tagline/edit.js | 6 ++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index dfe0f224c8f36..a239b60cc50b3 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -847,7 +847,7 @@ Describe in a few words what the site is about. The tagline can be used in searc - **Name:** core/site-tagline - **Category:** theme - **Supports:** align (full, wide), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ -- **Attributes:** level, textAlign +- **Attributes:** level, levelOptions, textAlign ## Site Title diff --git a/packages/block-library/src/site-tagline/block.json b/packages/block-library/src/site-tagline/block.json index 25b3840cd663a..d42b7bcd4bed6 100644 --- a/packages/block-library/src/site-tagline/block.json +++ b/packages/block-library/src/site-tagline/block.json @@ -14,6 +14,10 @@ "level": { "type": "number", "default": 0 + }, + "levelOptions": { + "type": "array", + "default": [ 0, 1, 2, 3, 4, 5, 6 ] } }, "example": { diff --git a/packages/block-library/src/site-tagline/edit.js b/packages/block-library/src/site-tagline/edit.js index 15f8a789dfbe9..52b9c761ba4f5 100644 --- a/packages/block-library/src/site-tagline/edit.js +++ b/packages/block-library/src/site-tagline/edit.js @@ -18,14 +18,12 @@ import { import { __ } from '@wordpress/i18n'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; -const HEADING_LEVELS = [ 0, 1, 2, 3, 4, 5, 6 ]; - export default function SiteTaglineEdit( { attributes, setAttributes, insertBlocksAfter, } ) { - const { textAlign, level } = attributes; + const { textAlign, level, levelOptions } = attributes; const { canUserEdit, tagline } = useSelect( ( select ) => { const { canUser, getEntityRecord, getEditedEntityRecord } = select( coreStore ); @@ -82,8 +80,8 @@ export default function SiteTaglineEdit( { <> setAttributes( { level: newLevel } ) } From 8191636cf1395611b61f98f76da46b201d2cb35b Mon Sep 17 00:00:00 2001 From: Nick Diego Date: Tue, 30 Jul 2024 13:29:47 -0500 Subject: [PATCH 2/2] Fix test. --- test/integration/fixtures/blocks/core__site-tagline.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/fixtures/blocks/core__site-tagline.json b/test/integration/fixtures/blocks/core__site-tagline.json index e504bc75df30c..fe837d41df43b 100644 --- a/test/integration/fixtures/blocks/core__site-tagline.json +++ b/test/integration/fixtures/blocks/core__site-tagline.json @@ -3,7 +3,8 @@ "name": "core/site-tagline", "isValid": true, "attributes": { - "level": 0 + "level": 0, + "levelOptions": [ 0, 1, 2, 3, 4, 5, 6 ] }, "innerBlocks": [] }