Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heading: Enable heading level curation #63535

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading