diff --git a/backport-changelog/6.8/8123.md b/backport-changelog/6.8/8123.md index bfb291a55f15e9..7955ec77416853 100644 --- a/backport-changelog/6.8/8123.md +++ b/backport-changelog/6.8/8123.md @@ -1,3 +1,4 @@ https://github.com/WordPress/wordpress-develop/pull/8123 * https://github.com/WordPress/gutenberg/pull/68549 +* https://github.com/WordPress/gutenberg/pull/68745 diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 820f0afccc2b57..158432cca5c48a 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -255,7 +255,7 @@ Hide and show additional content. ([Source](https://github.com/WordPress/gutenbe - **Name:** core/details - **Category:** text - **Supports:** align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~ -- **Attributes:** allowedBlocks, showContent, summary +- **Attributes:** allowedBlocks, name, showContent, summary ## Embed diff --git a/lib/compat/wordpress-6.8/post.php b/lib/compat/wordpress-6.8/post.php index 50324766488992..2477e94f7393c6 100644 --- a/lib/compat/wordpress-6.8/post.php +++ b/lib/compat/wordpress-6.8/post.php @@ -17,7 +17,7 @@ function gutenberg_update_page_editor_support( $args ) { if ( false !== $editor_support_key ) { unset( $args['supports'][ $editor_support_key ] ); $args['supports']['editor'] = array( - 'default_mode' => 'template-locked', + 'default-mode' => 'template-locked', ); } diff --git a/packages/block-library/src/details/block.json b/packages/block-library/src/details/block.json index e28d94c03b9aa0..e4fadc4a064f97 100644 --- a/packages/block-library/src/details/block.json +++ b/packages/block-library/src/details/block.json @@ -17,6 +17,12 @@ "source": "rich-text", "selector": "summary" }, + "name": { + "type": "string", + "source": "attribute", + "attribute": "name", + "selector": ".wp-block-details" + }, "allowedBlocks": { "type": "array" } diff --git a/packages/block-library/src/details/edit.js b/packages/block-library/src/details/edit.js index 89aac092df22c1..b7e8f815e21c06 100644 --- a/packages/block-library/src/details/edit.js +++ b/packages/block-library/src/details/edit.js @@ -8,6 +8,7 @@ import { InspectorControls, } from '@wordpress/block-editor'; import { + TextControl, ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, @@ -30,7 +31,7 @@ const TEMPLATE = [ ]; function DetailsEdit( { attributes, setAttributes } ) { - const { showContent, summary, allowedBlocks } = attributes; + const { name, showContent, summary, allowedBlocks } = attributes; const blockProps = useBlockProps(); const innerBlocksProps = useInnerBlocksProps( blockProps, { template: TEMPLATE, @@ -75,6 +76,20 @@ function DetailsEdit( { attributes, setAttributes } ) { </ToolsPanelItem> </ToolsPanel> </InspectorControls> + <InspectorControls group="advanced"> + <TextControl + __next40pxDefaultSize + __nextHasNoMarginBottom + label={ __( 'Name attribute' ) } + value={ name || '' } + onChange={ ( newName ) => + setAttributes( { name: newName } ) + } + help={ __( + 'Enables multiple Details blocks with the same name attribute to be connected, with only one open at a time.' + ) } + /> + </InspectorControls> <details { ...innerBlocksProps } open={ isOpen }> <summary onClick={ ( event ) => { diff --git a/packages/block-library/src/details/save.js b/packages/block-library/src/details/save.js index 0df5f63ce9410d..c7594d4d5aa3f4 100644 --- a/packages/block-library/src/details/save.js +++ b/packages/block-library/src/details/save.js @@ -4,12 +4,16 @@ import { RichText, useBlockProps, InnerBlocks } from '@wordpress/block-editor'; export default function save( { attributes } ) { - const { showContent } = attributes; + const { name, showContent } = attributes; const summary = attributes.summary ? attributes.summary : 'Details'; const blockProps = useBlockProps.save(); return ( - <details { ...blockProps } open={ showContent }> + <details + { ...blockProps } + name={ name || undefined } + open={ showContent } + > <summary> <RichText.Content value={ summary } /> </summary> diff --git a/packages/block-library/src/home-link/edit.js b/packages/block-library/src/home-link/edit.js index 793e13515411db..a4b975135b76f5 100644 --- a/packages/block-library/src/home-link/edit.js +++ b/packages/block-library/src/home-link/edit.js @@ -51,12 +51,6 @@ export default function HomeEdit( { attributes, setAttributes, context } ) { aria-label={ __( 'Home link text' ) } placeholder={ __( 'Add home link' ) } withoutInteractiveFormatting - allowedFormats={ [ - 'core/bold', - 'core/italic', - 'core/image', - 'core/strikethrough', - ] } /> </a> </div> diff --git a/packages/block-library/src/read-more/edit.js b/packages/block-library/src/read-more/edit.js index 8486dd6e50141a..8482d40d037916 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 ( <> <InspectorControls> - <PanelBody title={ __( 'Settings' ) }> - <ToggleControl - __nextHasNoMarginBottom + <ToolsPanel + label={ __( 'Settings' ) } + resetAll={ () => setAttributes( { linkTarget: '_self' } ) } + dropdownMenuProps={ dropdownMenuProps } + > + <ToolsPanelItem label={ __( 'Open in new tab' ) } - onChange={ ( value ) => - setAttributes( { - linkTarget: value ? '_blank' : '_self', - } ) + isShownByDefault + hasValue={ () => linkTarget !== '_self' } + onDeselect={ () => + setAttributes( { linkTarget: '_self' } ) } - checked={ linkTarget === '_blank' } - /> - </PanelBody> + > + <ToggleControl + __nextHasNoMarginBottom + label={ __( 'Open in new tab' ) } + onChange={ ( value ) => + setAttributes( { + linkTarget: value ? '_blank' : '_self', + } ) + } + checked={ linkTarget === '_blank' } + /> + </ToolsPanelItem> + </ToolsPanel> </InspectorControls> <RichText identifier="content" diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 81435d966b44e4..dfeaf19a5bd21e 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -198,8 +198,8 @@ export const ExperimentalEditorProvider = withRegistryProvider( const _defaultMode = Array.isArray( postTypeSupports?.editor ) ? postTypeSupports.editor.find( - ( features ) => 'default_mode' in features - )?.default_mode + ( features ) => 'default-mode' in features + )?.[ 'default-mode' ] : undefined; const hasDefaultMode = RENDERING_MODES.includes( _defaultMode );