Skip to content

Commit

Permalink
prep build 1/20
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jan 20, 2025
2 parents 8d97719 + be5ce8a commit 7a4ad8c
Show file tree
Hide file tree
Showing 23 changed files with 325 additions and 177 deletions.
8 changes: 4 additions & 4 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ An organized collection of items displayed in a specific order. ([Source](https:
- **Supports:** __unstablePasteTextInline, anchor, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** ordered, placeholder, reversed, start, type, values

## List item
## List Item

An individual item within a list. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/list-item))

Expand Down Expand Up @@ -534,7 +534,7 @@ Start with the basic building block of all narrative. ([Source](https://github.c
- **Supports:** __unstablePasteTextInline, anchor, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fontSize, lineHeight), ~~className~~
- **Attributes:** align, content, direction, dropCap, placeholder

## Pattern placeholder
## Pattern Placeholder

Show a block pattern. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/pattern))

Expand Down Expand Up @@ -672,7 +672,7 @@ Post terms. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages
- **Supports:** color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** prefix, separator, suffix, term, textAlign

## Time To Read
## Time to Read

Show minutes required to finish reading the post. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-time-to-read))

Expand Down Expand Up @@ -718,7 +718,7 @@ An advanced block that allows displaying post types based on different query par
- **Supports:** align (full, wide), interactivity, layout, ~~html~~
- **Attributes:** enhancedPagination, namespace, query, queryId, tagName

## No results
## No Results

Contains the block elements used to render content when no query results are found. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/query-no-results))

Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/hooks/custom-class-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export function addTransforms( result, source, index, results ) {
// if source N does not exists we do nothing.
if ( source[ index ] ) {
const originClassName = source[ index ]?.attributes.className;
if ( originClassName ) {
// Avoid overriding classes if the transformed block already includes them.
if ( originClassName && result.attributes.className === undefined ) {
return {
...result,
attributes: {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/archives/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
<ToolsPanelItem
label={ __( 'Show label' ) }
isShownByDefault
hasValue={ () => showLabel }
hasValue={ () => ! showLabel }
onDeselect={ () =>
setAttributes( { showLabel: false } )
}
Expand Down Expand Up @@ -102,7 +102,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
<ToolsPanelItem
label={ __( 'Group by' ) }
isShownByDefault
hasValue={ () => !! type }
hasValue={ () => type !== 'monthly' }
onDeselect={ () =>
setAttributes( { type: 'monthly' } )
}
Expand Down
178 changes: 133 additions & 45 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import clsx from 'clsx';
* WordPress dependencies
*/
import {
PanelBody,
Placeholder,
SelectControl,
Spinner,
ToggleControl,
VisuallyHidden,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { useInstanceId } from '@wordpress/compose';
import {
Expand All @@ -25,6 +26,11 @@ import { __, sprintf } from '@wordpress/i18n';
import { pin } from '@wordpress/icons';
import { useEntityRecords } from '@wordpress/core-data';

/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

export default function CategoriesEdit( {
attributes: {
displayAsDropdown,
Expand Down Expand Up @@ -180,72 +186,154 @@ export default function CategoriesEdit( {
const blockProps = useBlockProps( {
className: classes,
} );
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

return (
<TagName { ...blockProps }>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
<ToolsPanel
label={ __( 'Settings' ) }
resetAll={ () => {
setAttributes( {
taxonomy: 'category',
displayAsDropdown: false,
showHierarchy: false,
showPostCounts: false,
showOnlyTopLevel: false,
showEmpty: false,
showLabel: true,
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
{ Array.isArray( taxonomies ) && (
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
<ToolsPanelItem
hasValue={ () => {
return taxonomySlug !== 'category';
} }
label={ __( 'Taxonomy' ) }
options={ taxonomies.map( ( t ) => ( {
label: t.name,
value: t.slug,
} ) ) }
value={ taxonomySlug }
onChange={ ( selectedTaxonomy ) =>
setAttributes( {
taxonomy: selectedTaxonomy,
} )
}
/>
onDeselect={ () => {
setAttributes( { taxonomy: 'category' } );
} }
isShownByDefault
>
<SelectControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Taxonomy' ) }
options={ taxonomies.map( ( t ) => ( {
label: t.name,
value: t.slug,
} ) ) }
value={ taxonomySlug }
onChange={ ( selectedTaxonomy ) =>
setAttributes( {
taxonomy: selectedTaxonomy,
} )
}
/>
</ToolsPanelItem>
) }
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => !! displayAsDropdown }
label={ __( 'Display as dropdown' ) }
checked={ displayAsDropdown }
onChange={ toggleAttribute( 'displayAsDropdown' ) }
/>
{ displayAsDropdown && (
onDeselect={ () =>
setAttributes( { displayAsDropdown: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
className="wp-block-categories__indentation"
label={ __( 'Show label' ) }
checked={ showLabel }
onChange={ toggleAttribute( 'showLabel' ) }
label={ __( 'Display as dropdown' ) }
checked={ displayAsDropdown }
onChange={ toggleAttribute( 'displayAsDropdown' ) }
/>
</ToolsPanelItem>
{ displayAsDropdown && (
<ToolsPanelItem
hasValue={ () => ! showLabel }
label={ __( 'Show label' ) }
onDeselect={ () =>
setAttributes( { showLabel: true } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
className="wp-block-categories__indentation"
label={ __( 'Show label' ) }
checked={ showLabel }
onChange={ toggleAttribute( 'showLabel' ) }
/>
</ToolsPanelItem>
) }
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => !! showPostCounts }
label={ __( 'Show post counts' ) }
checked={ showPostCounts }
onChange={ toggleAttribute( 'showPostCounts' ) }
/>
{ isHierarchicalTaxonomy && (
onDeselect={ () =>
setAttributes( { showPostCounts: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show only top level terms' ) }
checked={ showOnlyTopLevel }
onChange={ toggleAttribute( 'showOnlyTopLevel' ) }
label={ __( 'Show post counts' ) }
checked={ showPostCounts }
onChange={ toggleAttribute( 'showPostCounts' ) }
/>
</ToolsPanelItem>
{ isHierarchicalTaxonomy && (
<ToolsPanelItem
hasValue={ () => !! showOnlyTopLevel }
label={ __( 'Show only top level terms' ) }
onDeselect={ () =>
setAttributes( { showOnlyTopLevel: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show only top level terms' ) }
checked={ showOnlyTopLevel }
onChange={ toggleAttribute(
'showOnlyTopLevel'
) }
/>
</ToolsPanelItem>
) }
<ToggleControl
__nextHasNoMarginBottom
<ToolsPanelItem
hasValue={ () => !! showEmpty }
label={ __( 'Show empty terms' ) }
checked={ showEmpty }
onChange={ toggleAttribute( 'showEmpty' ) }
/>
{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (
onDeselect={ () =>
setAttributes( { showEmpty: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show hierarchy' ) }
checked={ showHierarchy }
onChange={ toggleAttribute( 'showHierarchy' ) }
label={ __( 'Show empty terms' ) }
checked={ showEmpty }
onChange={ toggleAttribute( 'showEmpty' ) }
/>
</ToolsPanelItem>
{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (
<ToolsPanelItem
hasValue={ () => !! showHierarchy }
label={ __( 'Show hierarchy' ) }
onDeselect={ () =>
setAttributes( { showHierarchy: false } )
}
isShownByDefault
>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Show hierarchy' ) }
checked={ showHierarchy }
onChange={ toggleAttribute( 'showHierarchy' ) }
/>
</ToolsPanelItem>
) }
</PanelBody>
</ToolsPanel>
</InspectorControls>
{ isResolving && (
<Placeholder icon={ pin } label={ __( 'Terms' ) }>
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/embed/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createBlock } from '@wordpress/blocks';
* Internal dependencies
*/
import metadata from './block.json';
import { removeAspectRatioClasses } from './util';

const { name: EMBED_BLOCK } = metadata;

Expand All @@ -33,13 +34,14 @@ const transforms = {
type: 'block',
blocks: [ 'core/paragraph' ],
isMatch: ( { url } ) => !! url,
transform: ( { url, caption } ) => {
transform: ( { url, caption, className } ) => {
let value = `<a href="${ url }">${ url }</a>`;
if ( caption?.trim() ) {
value += `<br />${ caption }`;
}
return createBlock( 'core/paragraph', {
content: value,
className: removeAspectRatioClasses( className ),
} );
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/form/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const variations = [
},
{
name: 'wp-privacy-form',
title: __( 'Experimental privacy request form' ),
title: __( 'Experimental Privacy Request Form' ),
keywords: [ 'GDPR' ],
description: __( 'A form to request data exports and/or deletion.' ),
attributes: {
Expand Down
Loading

0 comments on commit 7a4ad8c

Please sign in to comment.