From 9c846e28c8b1f0e067400d9863acfb01241db601 Mon Sep 17 00:00:00 2001 From: Nick Diego Date: Sun, 14 Jul 2024 11:27:36 -0400 Subject: [PATCH] Add a levelOptions attribute to the Heading block. --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/heading/block.json | 3 +++ packages/block-library/src/heading/edit.js | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 67cebe47fc41bb..b0264b36251fa7 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -360,7 +360,7 @@ Introduce new sections and organize content to help visitors (and search engines - **Name:** core/heading - **Category:** text - **Supports:** __unstablePasteTextInline, align (full, wide), anchor, className, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fontSize, lineHeight) -- **Attributes:** content, level, placeholder, textAlign +- **Attributes:** content, level, levelOptions, placeholder, textAlign ## Home Link diff --git a/packages/block-library/src/heading/block.json b/packages/block-library/src/heading/block.json index 39e985038c323a..5b65f1ad50d2a5 100644 --- a/packages/block-library/src/heading/block.json +++ b/packages/block-library/src/heading/block.json @@ -21,6 +21,9 @@ "type": "number", "default": 2 }, + "levelOptions": { + "type": "array" + }, "placeholder": { "type": "string" } diff --git a/packages/block-library/src/heading/edit.js b/packages/block-library/src/heading/edit.js index 86ac776b9b16e4..ea58a75d51cda5 100644 --- a/packages/block-library/src/heading/edit.js +++ b/packages/block-library/src/heading/edit.js @@ -32,7 +32,8 @@ function HeadingEdit( { style, clientId, } ) { - const { textAlign, content, level, placeholder, anchor } = attributes; + const { textAlign, content, level, levelOptions, placeholder, anchor } = + attributes; const tagName = 'h' + level; const blockProps = useBlockProps( { className: clsx( { @@ -95,6 +96,7 @@ function HeadingEdit( { setAttributes( { level: newLevel } ) }