Skip to content

Commit

Permalink
Add a levelOptions attribute to the Heading block. (#63535)
Browse files Browse the repository at this point in the history
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: troychaplin <areziaal@git.wordpress.org>
Co-authored-by: skorasaurus <skorasaurus@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
  • Loading branch information
6 people authored Jul 29, 2024
1 parent 417e28a commit b03d835
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"type": "number",
"default": 2
},
"levelOptions": {
"type": "array"
},
"placeholder": {
"type": "string"
}
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/heading/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( {
Expand Down Expand Up @@ -95,6 +96,7 @@ function HeadingEdit( {
<BlockControls group="block">
<HeadingLevelDropdown
value={ level }
options={ levelOptions }
onChange={ ( newLevel ) =>
setAttributes( { level: newLevel } )
}
Expand Down

0 comments on commit b03d835

Please sign in to comment.