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

Query Title: Add levelOptions attribute to control available heading levels #64107

Merged
merged 1 commit into from
Jul 31, 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 @@ -775,7 +775,7 @@ Display the query title. ([Source](https://github.com/WordPress/gutenberg/tree/t
- **Name:** core/query-title
- **Category:** theme
- **Supports:** align (full, wide), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** level, showPrefix, showSearchTerm, textAlign, type
- **Attributes:** level, levelOptions, showPrefix, showSearchTerm, textAlign, type

## Quote

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/query-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"type": "number",
"default": 1
},
"levelOptions": {
"type": "array"
},
"showPrefix": {
"type": "boolean",
"default": true
Expand Down
10 changes: 9 additions & 1 deletion packages/block-library/src/query-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ import { useArchiveLabel } from './use-archive-label';
const SUPPORTED_TYPES = [ 'archive', 'search' ];

export default function QueryTitleEdit( {
attributes: { type, level, textAlign, showPrefix, showSearchTerm },
attributes: {
type,
level,
levelOptions,
textAlign,
showPrefix,
showSearchTerm,
},
setAttributes,
} ) {
const { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();
Expand Down Expand Up @@ -130,6 +137,7 @@ export default function QueryTitleEdit( {
<BlockControls group="block">
<HeadingLevelDropdown
value={ level }
options={ levelOptions }
onChange={ ( newLevel ) =>
setAttributes( { level: newLevel } )
}
Expand Down
Loading