Skip to content
Closed
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
28 changes: 14 additions & 14 deletions docs/reference-guides/core-blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Display code snippets that respect your spacing and tabs.

- **Name:** [core/code](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** align (wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight)
- **Supports:** align (wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight), ~~alignToolbar~~
- **Attributes:** content

## Column
Expand Down Expand Up @@ -294,7 +294,7 @@ Displays a title with the number of comments.
- **Name:** [core/comments-title](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-comments-title/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Ancestor:** core/comments
- **Supports:** align, anchor, background (gradient), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align, anchor, background (gradient), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** level, levelOptions, showCommentsCount, showPostTitle

## Cover
Expand Down Expand Up @@ -375,7 +375,7 @@ Introduce new sections and organize content to help visitors (and search engines

- **Name:** [core/heading](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-heading/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), className, color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight, textAlign, textIndent, textShadow)
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), className, color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight, textAlign, textIndent, textShadow), ~~alignToolbar~~
- **Attributes:** content, level, levelOptions, placeholder

## Home Link
Expand Down Expand Up @@ -440,7 +440,7 @@ An organized collection of items displayed in a specific order.
- **Name:** [core/list](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-list/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Allowed Blocks:** core/list-item
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), listView, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), listView, spacing (margin, padding), typography (fontSize, lineHeight), ~~alignToolbar~~, ~~html~~
- **Attributes:** ordered, placeholder, reversed, start, type, values

## List Item
Expand Down Expand Up @@ -574,7 +574,7 @@ Start with the basic building block of all narrative.

- **Name:** [core/paragraph](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-paragraph/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight, textAlign, textColumns, textIndent, textShadow), ~~className~~
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fitText, fontSize, lineHeight, textAlign, textColumns, textIndent, textShadow), ~~alignToolbar~~, ~~className~~
- **Attributes:** content, direction, dropCap, placeholder

## Pattern Placeholder
Expand Down Expand Up @@ -745,7 +745,7 @@ Displays the title of a post, page, or any other content-type.

- **Name:** [core/post-title](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-post-title/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** isLink, level, levelOptions, linkTarget, placeholder, rel

## Preformatted
Expand All @@ -763,7 +763,7 @@ Give special visual emphasis to a quote from your text.

- **Name:** [core/pullquote](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-pullquote/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** align (full, left, right, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign)
- **Supports:** align (full, left, right, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~
- **Attributes:** citation, value

## Query Loop
Expand Down Expand Up @@ -831,7 +831,7 @@ Display the query title.

- **Name:** [core/query-title](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-query-title/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (gradient), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (gradient), color (background, gradients, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** level, levelOptions, showPrefix, showSearchTerm, type

## Query Total
Expand All @@ -841,7 +841,7 @@ Display the total number of results in a query.
- **Name:** [core/query-total](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-query-total/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Ancestor:** core/query
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight), ~~alignToolbar~~, ~~html~~
- **Attributes:** displayType

## Quote
Expand All @@ -850,7 +850,7 @@ Give quoted text visual emphasis. "In quoting others, we cite ourselves." — Ju

- **Name:** [core/quote](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-quote/)
- **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
- **Supports:** align (full, left, right, wide), allowedBlocks, anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, heading, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), layout (~~allowEditing~~), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, left, right, wide), allowedBlocks, anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, heading, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), layout (~~allowEditing~~), shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~alignToolbar~~, ~~html~~
- **Attributes:** citation, textAlign, value

## Read More
Expand Down Expand Up @@ -913,7 +913,7 @@ Describe in a few words what this site is about. This is important for search re

- **Name:** [core/site-tagline](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-site-tagline/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), contentRole, dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fitText, fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, text), contentRole, dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fitText, fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** level, levelOptions

## Site Title
Expand All @@ -922,7 +922,7 @@ Displays the name of this site. Update the block, and the changes apply everywhe

- **Name:** [core/site-title](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-site-title/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fitText, fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fitText, fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** isLink, level, levelOptions, linkTarget

## Social Icon
Expand Down Expand Up @@ -1046,15 +1046,15 @@ Display the description of categories, tags and custom taxonomies when viewing a

- **Name:** [core/term-description](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-term-description/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~

## Term Name

Displays the name of a taxonomy term.

- **Name:** [core/term-name](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/core-block-term-name/)
- **Category:** [theme](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-theme/)
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~html~~
- **Supports:** align (full, wide), anchor, background (backgroundImage, backgroundSize, gradient), color (background, gradients, link, text), dimensions (minHeight, minWidth), interactivity (clientNavigation), shadow, spacing (margin, padding), typography (fontSize, lineHeight, textAlign), ~~alignToolbar~~, ~~html~~
- **Attributes:** isLink, level, levelOptions

## Term Template
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Enhancements

- Block alignment is now available in the Layout panel of the block inspector for every block that supports it, as an option that is not shown by default. A new `alignToolbar` block support, defaulting to `true`, controls whether the alignment control also appears in the block toolbar ([#83955](https://github.com/WordPress/gutenberg/pull/83955)).
- Inserter: Open faster when many block types are registered ([#83446](https://github.com/WordPress/gutenberg/pull/83446)).
- State control badges: migrate from the private `@wordpress/components` `Badge` to `@wordpress/ui` `Badge` ([#82608](https://github.com/WordPress/gutenberg/pull/82608)).
- Use the `inertValue` helper to set `inert` attributes, for better React 18/19 compatibility ([#83871](https://github.com/WordPress/gutenberg/pull/83871)).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { __ } from '@wordpress/i18n';
import { Icon } from '@wordpress/icons';
import { SelectControl } from '@wordpress/ui';
import { useAlignmentMenu } from './use-available-alignments';
import { BLOCK_ALIGNMENTS_CONTROLS, DEFAULT_CONTROL } from './constants';

interface BlockAlignmentSelectProps {
/** The current alignment. */
value?: string;
/** Called with the next alignment, or `undefined` for none. */
onChange: ( value?: string ) => void;
/** The alignments the block supports. */
controls?: string[];
}

interface AlignmentItem {
value: string;
label: string;
icon: JSX.Element;
description?: string;
disabled?: boolean;
}

/**
* The block alignment as a select, for the inspector's Layout panel.
*
* The toolbar control is curated away from blocks whose toolbar is about text
* rather than layout, so for those this is the only place the alignment can be
* set. It carries the same icons, labels and help text as the toolbar menu,
* including listing the wide alignments a parent layout withholds as
* unavailable.
*/
export default function BlockAlignmentSelect( {
value,
onChange,
controls,
}: BlockAlignmentSelectProps ) {
const { enabled, unavailable } = useAlignmentMenu( controls );

// A select of nothing but unavailable options could never change anything.
if ( ! enabled.length ) {
return null;
}

const items: AlignmentItem[] = enabled.map(
( { name, info }: { name: string; info?: string } ) => ( {
value: name,
label: BLOCK_ALIGNMENTS_CONTROLS[ name ].title,
icon: BLOCK_ALIGNMENTS_CONTROLS[ name ].icon,
description: info,
} )
);

// Unavailable alignments sit where they would have sat had they been
// offered, which is directly after `none`.
items.splice(
items.findIndex( ( item ) => item.value === DEFAULT_CONTROL ) + 1,
0,
...unavailable.map( ( name: string ) => ( {
value: name,
label: BLOCK_ALIGNMENTS_CONTROLS[ name ].title,
icon: BLOCK_ALIGNMENTS_CONTROLS[ name ].icon,
description: __( 'Not available' ),
disabled: true,
} ) )
);

/*
* An alignment a parent layout has taken away can still be the saved value.
* Showing it as selected is how the select says the setting exists but has
* no effect in this position, so look through the unavailable items too.
*/
const selected =
items.find( ( item ) => item.value === value ) ??
items.find( ( item ) => item.value === DEFAULT_CONTROL );

return (
<SelectControl
label={ __( 'Alignment' ) }
items={ items }
value={ selected }
onValueChange={ ( item ) =>
onChange(
! item || item.value === DEFAULT_CONTROL
? undefined
: ( item.value as string )
)
}
popupWidth="anchor"
>
{ items.map( ( item ) => (
<SelectControl.Item
key={ item.value }
value={ item }
label={ item.label }
disabled={ item.disabled }
>
<SelectControl.ItemLabel>
<span className="block-editor-block-alignment-control__item-label">
<Icon icon={ item.icon } size={ 24 } />
{ item.label }
</span>
</SelectControl.ItemLabel>
{ item.description ? (
<SelectControl.ItemDescription>
{ item.description }
</SelectControl.ItemDescription>
) : null }
</SelectControl.Item>
) ) }
</SelectControl>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
@use "@wordpress/base-styles/variables" as *;

.block-editor-block-alignment-control__menu-group {
.components-menu-item__info {
margin-top: 0;
}
}

.block-editor-block-alignment-control__item-label {
align-items: center;
display: flex;
gap: $grid-unit-10;
}
Loading
Loading