From ebab640e73c4a7aef385169ce2c1fc6b66709691 Mon Sep 17 00:00:00 2001 From: Sainath Poojary <53347682+SainathPoojary@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:03:43 +0530 Subject: [PATCH] Read More Block: Refactor settings panel to use ToolsPanel (#67925) Co-authored-by: SainathPoojary Co-authored-by: t-hamano Co-authored-by: fabiankaegy --- packages/block-library/src/read-more/edit.js | 46 +++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/read-more/edit.js b/packages/block-library/src/read-more/edit.js index 8486dd6e50141..8482d40d03791 100644 --- a/packages/block-library/src/read-more/edit.js +++ b/packages/block-library/src/read-more/edit.js @@ -6,31 +6,55 @@ import { RichText, useBlockProps, } from '@wordpress/block-editor'; -import { ToggleControl, PanelBody } from '@wordpress/components'; +import { + ToggleControl, + __experimentalToolsPanel as ToolsPanel, + __experimentalToolsPanelItem as ToolsPanelItem, +} from '@wordpress/components'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; + export default function ReadMore( { attributes: { content, linkTarget }, setAttributes, insertBlocksAfter, } ) { const blockProps = useBlockProps(); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + return ( <> - - setAttributes( { linkTarget: '_self' } ) } + dropdownMenuProps={ dropdownMenuProps } + > + - setAttributes( { - linkTarget: value ? '_blank' : '_self', - } ) + isShownByDefault + hasValue={ () => linkTarget !== '_self' } + onDeselect={ () => + setAttributes( { linkTarget: '_self' } ) } - checked={ linkTarget === '_blank' } - /> - + > + + setAttributes( { + linkTarget: value ? '_blank' : '_self', + } ) + } + checked={ linkTarget === '_blank' } + /> + +