From baed8aff1db7f800118d6d9653755f8352a38c15 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Mon, 8 Apr 2024 02:12:01 +0200 Subject: [PATCH 1/2] Post title: Re-add the paragraph level --- packages/block-library/src/post-title/edit.js | 5 ++++- packages/block-library/src/post-title/index.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/post-title/edit.js b/packages/block-library/src/post-title/edit.js index 4a186276408da..af275f25c464c 100644 --- a/packages/block-library/src/post-title/edit.js +++ b/packages/block-library/src/post-title/edit.js @@ -21,13 +21,15 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; +const HEADING_LEVELS = [ 0, 1, 2, 3, 4, 5, 6 ]; + export default function PostTitleEdit( { attributes: { level, textAlign, isLink, rel, linkTarget }, setAttributes, context: { postType, postId, queryId }, insertBlocksAfter, } ) { - const TagName = 'h' + level; + const TagName = level === 0 ? 'p' : `h${ level }`; const isDescendentOfQueryLoop = Number.isFinite( queryId ); const userCanEdit = useSelect( ( select ) => { @@ -124,6 +126,7 @@ export default function PostTitleEdit( { <> setAttributes( { level: newLevel } ) diff --git a/packages/block-library/src/post-title/index.php b/packages/block-library/src/post-title/index.php index f4a91a6891ea8..ed27f2e4158eb 100644 --- a/packages/block-library/src/post-title/index.php +++ b/packages/block-library/src/post-title/index.php @@ -33,7 +33,7 @@ function render_block_core_post_title( $attributes, $content, $block ) { $tag_name = 'h2'; if ( isset( $attributes['level'] ) ) { - $tag_name = 'h' . $attributes['level']; + $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; } if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { From 197a7dc4e8f34931f8eaf75ddbd7314565aad563 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Mon, 8 Apr 2024 10:10:11 +0200 Subject: [PATCH 2/2] Remove the paragraph from the level dropdown --- packages/block-library/src/post-title/edit.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/block-library/src/post-title/edit.js b/packages/block-library/src/post-title/edit.js index af275f25c464c..f6bba60990731 100644 --- a/packages/block-library/src/post-title/edit.js +++ b/packages/block-library/src/post-title/edit.js @@ -21,8 +21,6 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; -const HEADING_LEVELS = [ 0, 1, 2, 3, 4, 5, 6 ]; - export default function PostTitleEdit( { attributes: { level, textAlign, isLink, rel, linkTarget }, setAttributes, @@ -126,7 +124,6 @@ export default function PostTitleEdit( { <> setAttributes( { level: newLevel } )