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

[pull] trunk from WordPress:trunk #170

Merged
merged 4 commits into from
Jan 17, 2025
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
1 change: 1 addition & 0 deletions backport-changelog/6.8/8123.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.8/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}

Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/details/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"source": "rich-text",
"selector": "summary"
},
"name": {
"type": "string",
"source": "attribute",
"attribute": "name",
"selector": ".wp-block-details"
},
"allowedBlocks": {
"type": "array"
}
Expand Down
17 changes: 16 additions & 1 deletion packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
InspectorControls,
} from '@wordpress/block-editor';
import {
TextControl,
ToggleControl,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
Expand All @@ -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,
Expand Down Expand Up @@ -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 ) => {
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/details/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 0 additions & 6 deletions packages/block-library/src/home-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
46 changes: 35 additions & 11 deletions packages/block-library/src/read-more/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
Loading