Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Switch to HeadingLevelDropdown
  • Loading branch information
mikachan committed Oct 8, 2025
commit 13190801fab4b7b97e79a480662c11ea9ba2a19e
2 changes: 1 addition & 1 deletion packages/block-library/src/term-name/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"tagName": {
"type": "string",
"default": "div"
"default": "p"
},
"isLink": {
"type": "boolean",
Expand Down
41 changes: 15 additions & 26 deletions packages/block-library/src/term-name/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
BlockControls,
AlignmentControl,
InspectorControls,
privateApis as blockEditorPrivateApis,
HeadingLevelDropdown,
} from '@wordpress/block-editor';
import {
ToggleControl,
Expand All @@ -26,16 +26,13 @@ import { store as coreStore } from '@wordpress/core-data';
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
import { unlock } from '../lock-unlock';

const { HTMLElementControl } = unlock( blockEditorPrivateApis );

export default function TermNameEdit( {
attributes,
setAttributes,
context: { termId, taxonomy },
} ) {
const { textAlign, tagName = 'div', isLink } = attributes;
const { textAlign, tagName = 'p', isLink } = attributes;

const term = useSelect(
( select ) => {
Expand Down Expand Up @@ -76,34 +73,26 @@ export default function TermNameEdit( {
return (
<>
<BlockControls group="block">
<HeadingLevelDropdown
value={
tagName === 'p'
? 0
: parseInt( tagName.replace( 'h', '' ) )
}
options={ [ 0, 1, 2, 3, 4, 5, 6 ] }
onChange={ ( newLevel ) => {
setAttributes( {
tagName: newLevel === 0 ? 'p' : `h${ newLevel }`,
} );
} }
/>
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
<InspectorControls group="advanced">
<HTMLElementControl
__next40pxDefaultSize
__nextHasNoMarginBottom
label={ __( 'HTML element' ) }
value={ tagName }
options={ [
{ label: __( 'Default (div)' ), value: 'div' },
{ label: __( 'Paragraph (p)' ), value: 'p' },
{ label: __( 'Heading 1 (h1)' ), value: 'h1' },
{ label: __( 'Heading 2 (h2)' ), value: 'h2' },
{ label: __( 'Heading 3 (h3)' ), value: 'h3' },
{ label: __( 'Heading 4 (h4)' ), value: 'h4' },
{ label: __( 'Heading 5 (h5)' ), value: 'h5' },
{ label: __( 'Heading 6 (h6)' ), value: 'h6' },
] }
onChange={ ( value ) =>
setAttributes( { tagName: value } )
}
/>
</InspectorControls>
<InspectorControls>
<ToolsPanel
label={ __( 'Settings' ) }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/term-name/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function render_block_core_term_name( $attributes, $content, $block ) {
return '';
}

$tag_name = isset( $attributes['tagName'] ) ? $attributes['tagName'] : 'div';
$tag_name = isset( $attributes['tagName'] ) ? $attributes['tagName'] : 'p';

if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$term_link = get_term_link( $context['termId'], $context['taxonomy'] );
Expand Down