Skip to content

Commit

Permalink
Merge branch 'trunk' into update/library-template-part-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan committed Jun 28, 2023
2 parents 43de9f9 + ea76918 commit d86ad54
Show file tree
Hide file tree
Showing 68 changed files with 733 additions and 340 deletions.
132 changes: 51 additions & 81 deletions changelog.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/how-to-guides/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ To retain backward compatibility, the existing `add_theme_support` declarations
| `editor-color-palette` | Provide the list of colors via `color.palette`. |
| `editor-font-sizes` | Provide the list of font size via `typography.fontSizes`. |
| `editor-gradient-presets` | Provide the list of gradients via `color.gradients`. |
| `experimental-link-color` | Set `color.link` to `true`. `experimental-link-color` will be removed when the plugin requires WordPress 5.9 as the minimum version. |
| `appearance-tools` | Set `appearanceTools` to `true`. |
| `border` | Set `border: color, radius, style, width` to `true`. |
| `link-color ` | Set `color.link` to `true`. |

#### Presets

Expand Down
16 changes: 16 additions & 0 deletions docs/how-to-guides/themes/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,22 @@ Use this setting to enable the following Global Styles settings:
add_theme_support( 'appearance-tools' );
```

## Border

Use this to enable all border settings:

```php
add_theme_support( 'border' );
```

## Link color

Use this to enable the link color setting:

```php
add_theme_support( 'link-color' );
```

## Block Based Template Parts

Block Based Template parts allow administrators to edit parts of the site using blocks. This is off by default, and requires the theme to opt in by declaring support:
Expand Down
1 change: 1 addition & 0 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ Edit the different global regions of your site, like the header, footer, sidebar
Display the description of categories, tags and custom taxonomies when viewing an archive. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/term-description))

- **Name:** core/term-description
- **Experimental:** fse
- **Category:** theme
- **Supports:** align (full, wide), color (background, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** textAlign
Expand Down
1 change: 0 additions & 1 deletion docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ _Parameters_
- _state_ `Object`: Editor state.
- _rootClientId_ `?string`: Optional root client ID of block list.
- _syncStatus_ `?string`: Optional sync status to filter pattern blocks by.
_Returns_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Settings related to typography.
| lineHeight | boolean | false | |
| textColumns | boolean | false | |
| textDecoration | boolean | true | |
| writingMode | boolean | false | |
| textTransform | boolean | true | |
| dropCap | boolean | true | |
| fontSizes | array | | fluid, name, size, slug |
Expand Down Expand Up @@ -239,6 +240,7 @@ Typography styles.
| lineHeight | string, object | |
| textColumns | string | |
| textDecoration | string, object | |
| writingMode | string, object | |
| textTransform | string, object | |

---
Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
* Requires at least: 6.1
* Requires PHP: 5.6
* Version: 16.1.0-rc.2
* Version: 16.1.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
10 changes: 9 additions & 1 deletion lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function gutenberg_register_typography_support( $block_type ) {
$has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false );
$has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
$has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false );

$has_typography_support = $has_font_family_support
|| $has_font_size_support
Expand All @@ -38,7 +39,8 @@ function gutenberg_register_typography_support( $block_type ) {
|| $has_line_height_support
|| $has_text_columns_support
|| $has_text_decoration_support
|| $has_text_transform_support;
|| $has_text_transform_support
|| $has_writing_mode_support;

if ( ! $block_type->attributes ) {
$block_type->attributes = array();
Expand Down Expand Up @@ -96,6 +98,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
$has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false );
$has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
$has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false );

// Whether to skip individual block support features.
$should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' );
Expand All @@ -107,6 +110,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
$should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
$should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
$should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' );
$should_skip_writing_mode = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'writingMode' );

$typography_block_styles = array();
if ( $has_font_size_support && ! $should_skip_font_size ) {
Expand Down Expand Up @@ -158,6 +162,10 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
gutenberg_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['letterSpacing'], 'letter-spacing' );
}

if ( $has_writing_mode_support && ! $should_skip_writing_mode && isset( $block_attributes['style']['typography']['writingMode'] ) ) {
$typography_block_styles['writingMode'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'writingMode' ), null );
}

$attributes = array();
$styles = gutenberg_style_engine_get_styles(
array( 'typography' => $typography_block_styles ),
Expand Down
6 changes: 5 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class WP_Theme_JSON_Gutenberg {
* `--wp--style--root--padding-*`, and `box-shadow` properties,
* removed the `--wp--style--block-gap` property.
* @since 6.2.0 Added `outline-*`, and `min-height` properties.
* @since 6.3.0 Added `writing-mode` property.
*
* @var array
*/
Expand Down Expand Up @@ -260,6 +261,7 @@ class WP_Theme_JSON_Gutenberg {
'text-transform' => array( 'typography', 'textTransform' ),
'filter' => array( 'filter', 'duotone' ),
'box-shadow' => array( 'shadow' ),
'writing-mode' => array( 'typography', 'writingMode' ),
);

/**
Expand Down Expand Up @@ -339,7 +341,7 @@ class WP_Theme_JSON_Gutenberg {
* @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`.
* @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets',
* `position.fixed` and `position.sticky`.
* @since 6.3.0 Removed `layout.definitions`.
* @since 6.3.0 Removed `layout.definitions`. Added `typography.writingMode`.
* @var array
*/
const VALID_SETTINGS = array(
Expand Down Expand Up @@ -406,6 +408,7 @@ class WP_Theme_JSON_Gutenberg {
'textColumns' => null,
'textDecoration' => null,
'textTransform' => null,
'writingMode' => null,
),
'behaviors' => null,
);
Expand Down Expand Up @@ -468,6 +471,7 @@ class WP_Theme_JSON_Gutenberg {
'textColumns' => null,
'textDecoration' => null,
'textTransform' => null,
'writingMode' => null,
),
'css' => null,
);
Expand Down
20 changes: 20 additions & 0 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,26 @@ public static function get_theme_data( $deprecated = array(), $options = array()
// Classic themes without a theme.json don't support global duotone.
$theme_support_data['settings']['color']['defaultDuotone'] = false;

// Allow themes to enable all border settings via theme_support.
if ( current_theme_supports( 'border' ) ) {
$theme_support_data['settings']['border']['color'] = true;
$theme_support_data['settings']['border']['radius'] = true;
$theme_support_data['settings']['border']['style'] = true;
$theme_support_data['settings']['border']['width'] = true;
}

// Allow themes to enable link colors via theme_support.
if ( current_theme_supports( 'link-color' ) ) {
$theme_support_data['settings']['color']['link'] = true;
}
if ( current_theme_supports( 'experimental-link-color' ) ) {
_doing_it_wrong(
current_theme_supports( 'experimental-link-color' ),
__( '`experimental-link-color` is no longer supported. Use `link-color` instead.', 'gutenberg' ),
'6.3.0'
);
}

// BEGIN EXPERIMENTAL.
// Allow themes to enable appearance tools via theme_support.
// This feature was backported for WordPress 6.2 as of https://core.trac.wordpress.org/ticket/56487
Expand Down
3 changes: 2 additions & 1 deletion lib/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@
"lineHeight": false,
"textColumns": false,
"textDecoration": true,
"textTransform": true
"textTransform": true,
"writingMode": false
},
"blocks": {
"core/button": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "16.1.0-rc.2",
"version": "16.1.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,12 @@ const BlockActionsMenu = ( {
id: 'convertToRegularBlocksOption',
label:
innerBlockCount > 1
? __( 'Convert to regular blocks' )
: __( 'Convert to regular block' ),
? __( 'Detach patterns' )
: __( 'Detach pattern' ),
value: 'convertToRegularBlocksOption',
onSelect: () => {
const successNotice =
innerBlockCount > 1
? /* translators: %s: name of the reusable block */
__( '%s converted to regular blocks' )
: /* translators: %s: name of the reusable block */
__( '%s converted to regular block' );
/* translators: %s: name of the synced block */
const successNotice = __( '%s detached' );
createSuccessNotice(
sprintf(
successNotice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
opacity: 0.62;
}

// In "constrained" layout containers, the first and last paragraphs have their margins zeroed out.
// In the case of this appender, it needs to apply those same rules to avoid layout shifts.
// Such shifts happen when the bottom margin of the Title block has been set to less than the default 1em margin of paragraphs.
:where(body .is-layout-constrained) & {
> :first-child:first-child {
margin-block-start: 0;
}

// Since this particular appender will only ever appear on an entirely empty document, we don't account for last-child.
}

// Dropzone.
.components-drop-zone__content-icon {
display: none;
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const VALID_SETTINGS = [
'typography.textColumns',
'typography.textDecoration',
'typography.textTransform',
'typography.writingMode',
];

export const useGlobalStylesReset = () => {
Expand Down Expand Up @@ -292,6 +293,7 @@ export function useSettingsForBlockElement(
'letterSpacing',
'textTransform',
'textDecoration',
'writingMode',
].forEach( ( key ) => {
if ( ! supportedStyles.includes( key ) ) {
updatedSettings.typography = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import LineHeightControl from '../line-height-control';
import LetterSpacingControl from '../letter-spacing-control';
import TextTransformControl from '../text-transform-control';
import TextDecorationControl from '../text-decoration-control';
import WritingModeControl from '../writing-mode-control';
import { getValueFromVariable } from './utils';
import { setImmutably } from '../../utils/object';

Expand All @@ -32,6 +33,7 @@ export function useHasTypographyPanel( settings ) {
const hasLetterSpacing = useHasLetterSpacingControl( settings );
const hasTextTransform = useHasTextTransformControl( settings );
const hasTextDecoration = useHasTextDecorationControl( settings );
const hasWritingMode = useHasWritingModeControl( settings );
const hasTextColumns = useHasTextColumnsControl( settings );
const hasFontSize = useHasFontSizeControl( settings );

Expand All @@ -43,6 +45,7 @@ export function useHasTypographyPanel( settings ) {
hasTextTransform ||
hasFontSize ||
hasTextDecoration ||
hasWritingMode ||
hasTextColumns
);
}
Expand Down Expand Up @@ -103,6 +106,10 @@ function useHasTextDecorationControl( settings ) {
return settings?.typography?.textDecoration;
}

function useHasWritingModeControl( settings ) {
return settings?.typography?.writingMode;
}

function useHasTextColumnsControl( settings ) {
return settings?.typography?.textColumns;
}
Expand Down Expand Up @@ -138,6 +145,7 @@ const DEFAULT_CONTROLS = {
letterSpacing: true,
textTransform: true,
textDecoration: true,
writingMode: true,
textColumns: true,
};

Expand Down Expand Up @@ -310,6 +318,21 @@ export default function TypographyPanel( {
const hasTextDecoration = () => !! value?.typography?.textDecoration;
const resetTextDecoration = () => setTextDecoration( undefined );

// Text Orientation
const hasWritingModeControl = useHasWritingModeControl( settings );
const writingMode = decodeValue( inheritedValue?.typography?.writingMode );
const setWritingMode = ( newValue ) => {
onChange(
setImmutably(
value,
[ 'typography', 'writingMode' ],
newValue || undefined
)
);
};
const hasWritingMode = () => !! value?.typography?.writingMode;
const resetWritingMode = () => setWritingMode( undefined );

const resetAllFilter = useCallback( ( previousValue ) => {
return {
...previousValue,
Expand Down Expand Up @@ -456,6 +479,23 @@ export default function TypographyPanel( {
/>
</ToolsPanelItem>
) }
{ hasWritingModeControl && (
<ToolsPanelItem
className="single-column"
label={ __( 'Text orientation' ) }
hasValue={ hasWritingMode }
onDeselect={ resetWritingMode }
isShownByDefault={ defaultControls.writingMode }
panelId={ panelId }
>
<WritingModeControl
value={ writingMode }
onChange={ setWritingMode }
size="__unstable-large"
__nextHasNoMarginBottom
/>
</ToolsPanelItem>
) }
{ hasTextTransformControl && (
<ToolsPanelItem
label={ __( 'Letter case' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export { default as __experimentalFontFamilyControl } from './font-family';
export { default as __experimentalLetterSpacingControl } from './letter-spacing-control';
export { default as __experimentalTextDecorationControl } from './text-decoration-control';
export { default as __experimentalTextTransformControl } from './text-transform-control';
export { default as __experimentalWritingModeControl } from './writing-mode-control';
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
onInsertBlocks,
destinationRootClientId
);

const registeredPatternCategories = useMemo(
() =>
patternCategories.map(
Expand All @@ -75,7 +76,12 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
);
}
return searchItems( allPatterns, filterValue );
}, [ filterValue, selectedCategory, allPatterns ] );
}, [
filterValue,
allPatterns,
selectedCategory,
registeredPatternCategories,
] );

// Announce search results on change.
useEffect( () => {
Expand All @@ -89,7 +95,7 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
count
);
debouncedSpeak( resultsFoundMessage );
}, [ filterValue, debouncedSpeak ] );
}, [ filterValue, debouncedSpeak, filteredBlockPatterns.length ] );

const currentShownPatterns = useAsyncList( filteredBlockPatterns, {
step: INITIAL_INSERTER_RESULTS,
Expand Down
Loading

0 comments on commit d86ad54

Please sign in to comment.