Skip to content

Commit

Permalink
Merge branch 'trunk' into update/all-pages-view-title
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster committed Feb 15, 2024
2 parents 3595e9e + 2349114 commit cd33f15
Show file tree
Hide file tree
Showing 112 changed files with 1,688 additions and 563 deletions.
2 changes: 1 addition & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Welcome to Gutenberg, a WordPress project. We hope you join us in creating the f

* Please see the [Contributing Guidelines](https://github.com/WordPress/gutenberg/blob/HEAD/CONTRIBUTING.md) for additional information on how to contribute.

* As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://github.com/WordPress/gutenberg/blob/HEAD/CODE_OF_CONDUCT.md).
* As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://make.wordpress.org/handbook/community-code-of-conduct/).

* Join us on Slack for real-time communication, it is where maintainers coordinate around the project. To get started using Slack, see: https://make.wordpress.org/chat/

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ test/storybook-playwright/specs/__snapshots__
test/storybook-playwright/specs/*-snapshots/**
test/gutenberg-test-themes/twentytwentyone
test/gutenberg-test-themes/twentytwentythree
test/gutenberg-test-themes/twentytwentyfour
packages/react-native-editor/src/setup-local.js
11 changes: 0 additions & 11 deletions CODE_OF_CONDUCT.md

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To learn all about contributing to the Gutenberg project, see the [Contributor G

## Guidelines

- As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](/CODE_OF_CONDUCT.md).
- As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://make.wordpress.org/handbook/community-code-of-conduct/).

- Contributors should review the [overall process and best practices for pull requests](https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/repository-management.md#pull-requests), adhering to WordPress' [JavaScript coding standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/) and [accessibility coding standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To get up and running quickly with **code contribution** see [Getting Started Wi

In whichever way you wish to contribute please be sure to read the [Contributing Guidelines](https://github.com/WordPress/gutenberg/blob/HEAD/CONTRIBUTING.md) first.

As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://github.com/WordPress/gutenberg/blob/HEAD/CODE_OF_CONDUCT.md).
As with all WordPress projects, we want to ensure a welcoming environment for everyone. With that in mind, all contributors are expected to follow our [Code of Conduct](https://make.wordpress.org/handbook/community-code-of-conduct/).

## Get Involved

Expand Down
604 changes: 604 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

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.3
* Requires PHP: 7.0
* Version: 17.7.0-rc.1
* Version: 17.7.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public function get_item( $request ) {
return $revision;
}

if ( (int) $parent->ID !== (int) $revision->post_parent ) {
return new WP_Error(
'rest_revision_parent_id_mismatch',
/* translators: %d: A post id. */
sprintf( __( 'The revision does not belong to the specified parent with id of "%d"' ), $parent->ID ),
array( 'status' => 404 )
);
}

$response = $this->prepare_item_for_response( $revision, $request );
return rest_ensure_response( $response );
}
Expand Down
6 changes: 4 additions & 2 deletions lib/compat/wordpress-6.5/fonts/class-wp-font-collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ private static function get_sanitization_schema() {
array(
'font_family_settings' => array(
'name' => 'sanitize_text_field',
'slug' => 'sanitize_title',
'fontFamily' => 'sanitize_text_field',
'slug' => static function ( $value ) {
return _wp_to_kebab_case( sanitize_title( $value ) );
},
'fontFamily' => 'WP_Font_Utils::sanitize_font_family',
'preview' => 'sanitize_url',
'fontFace' => array(
array(
Expand Down
65 changes: 44 additions & 21 deletions lib/compat/wordpress-6.5/fonts/class-wp-font-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,41 @@
* @access private
*/
class WP_Font_Utils {

/**
* Adds surrounding quotes to font family names that contain special characters.
*
* It follows the recommendations from the CSS Fonts Module Level 4.
* @link https://www.w3.org/TR/css-fonts-4/#font-family-prop
*
* @since 6.5.0
* @access private
*
* @see sanitize_font_family()
*
* @param string $item A font family name.
* @return string The font family name with surrounding quotes if necessary.
*/
private static function maybe_add_quotes( $item ) {
// Match any non alphabetic characters (a-zA-Z), dashes -, or parenthesis ().
$regex = '/[^a-zA-Z\-()]+/';
$item = trim( $item );
if ( preg_match( $regex, $item ) ) {
// Removes leading and trailing quotes.
$item = preg_replace( '/^["\']|["\']$/', '', $item );
return "\"$item\"";
}
return $item;
}

/**
* Sanitizes and formats font family names.
*
* - Applies `sanitize_text_field`
* - Adds surrounding quotes to names that contain spaces and are not already quoted
* - Adds surrounding quotes to names that special
*
* It follows the recommendations from the CSS Fonts Module Level 4.
* @link https://www.w3.org/TR/css-fonts-4/#font-family-prop
*
* @since 6.5.0
* @access private
Expand All @@ -39,26 +69,19 @@ public static function sanitize_font_family( $font_family ) {
return '';
}

$font_family = sanitize_text_field( $font_family );
$font_families = explode( ',', $font_family );
$wrapped_font_families = array_map(
function ( $family ) {
$trimmed = trim( $family );
if ( ! empty( $trimmed ) && str_contains( $trimmed, ' ' ) && ! str_contains( $trimmed, "'" ) && ! str_contains( $trimmed, '"' ) ) {
return '"' . $trimmed . '"';
$output = trim( sanitize_text_field( $font_family ) );
$formatted_items = array();
if ( str_contains( $output, ',' ) ) {
$items = explode( ',', $output );
foreach ( $items as $item ) {
$formatted_item = self::maybe_add_quotes( $item );
if ( ! empty( $formatted_item ) ) {
$formatted_items[] = $formatted_item;
}
return $trimmed;
},
$font_families
);

if ( count( $wrapped_font_families ) === 1 ) {
$font_family = $wrapped_font_families[0];
} else {
$font_family = implode( ', ', $wrapped_font_families );
}
return implode( ', ', $formatted_items );
}

return $font_family;
return self::maybe_add_quotes( $output );
}

/**
Expand Down Expand Up @@ -233,8 +256,8 @@ public static function get_allowed_font_mime_types() {
return array(
'otf' => 'application/vnd.ms-opentype',
'ttf' => PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type,
'woff' => PHP_VERSION_ID >= 80100 ? 'font/woff' : 'application/font-woff',
'woff2' => PHP_VERSION_ID >= 80100 ? 'font/woff2' : 'application/font-woff2',
'woff' => PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff',
'woff2' => PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2',
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,14 @@ public function print_router_loading_and_screen_reader_markup() {
echo <<<HTML
<div
class="wp-interactivity-router-loading-bar"
data-wp-interactive='{"namespace":"core/router"}'
data-wp-interactive="core/router"
data-wp-class--start-animation="state.navigation.hasStarted"
data-wp-class--finish-animation="state.navigation.hasFinished"
></div>
<div
class="screen-reader-text"
aria-live="polite"
data-wp-interactive='{"namespace":"core/router"}'
data-wp-interactive="core/router"
data-wp-text="state.navigation.message"
></div>
HTML;
Expand Down
4 changes: 2 additions & 2 deletions 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": "17.7.0-rc.1",
"version": "17.7.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
7 changes: 6 additions & 1 deletion packages/block-editor/src/components/block-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export function BlockPreview( {
[]
);
const settings = useMemo(
() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
() => ( {
...originalSettings,
focusMode: false, // Disable "Spotlight mode".
__unstableIsPreviewMode: true,
} ),
[ originalSettings ]
);
const renderedBlocks = useMemo(
Expand Down Expand Up @@ -117,6 +121,7 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
() => ( {
...originalSettings,
styles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
focusMode: false, // Disable "Spotlight mode".
__unstableIsPreviewMode: true,
} ),
[ originalSettings ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function NonDefaultControls( { format, onChange } ) {
return (
<VStack>
<CustomSelectControl
__nextUnconstrainedWidth
label={ __( 'Choose a format' ) }
options={ [ ...suggestedOptions, customOption ] }
value={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export default function FontAppearanceControl( props ) {
onChange={ ( { selectedItem } ) =>
onChange( selectedItem.style )
}
__nextUnconstrainedWidth
/>
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { __ } from '@wordpress/i18n';
import BorderRadiusControl from '../border-radius-control';
import { useColorsPerOrigin } from './hooks';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { mergeOrigins } from '../../store/get-block-settings';
import { overrideOrigins } from '../../store/get-block-settings';
import { setImmutably } from '../../utils/object';
import { getBorderPanelLabel } from '../../hooks/border';
import { ShadowPopover } from './shadow-panel-components';
Expand Down Expand Up @@ -154,12 +154,12 @@ export default function BorderPanel( {

// Shadow
const shadow = decodeValue( inheritedValue?.shadow );
const shadowPresets = settings?.shadow?.presets;
const mergedShadowPresets = shadowPresets
? mergeOrigins( shadowPresets )
const shadowPresets = settings?.shadow?.presets ?? {};
const overriddenShadowPresets = shadowPresets
? overrideOrigins( shadowPresets )
: [];
const setShadow = ( newValue ) => {
const slug = mergedShadowPresets?.find(
const slug = overriddenShadowPresets?.find(
( { shadow: shadowName } ) => shadowName === newValue
)?.slug;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { useCallback } from '@wordpress/element';
/**
* Internal dependencies
*/
import { mergeOrigins, hasMergedOrigins } from '../../store/get-block-settings';
import {
mergeOrigins,
overrideOrigins,
hasOriginValue,
} from '../../store/get-block-settings';
import FontFamilyControl from '../font-family';
import FontAppearanceControl from '../font-appearance-control';
import LineHeightControl from '../line-height-control';
Expand Down Expand Up @@ -53,13 +57,13 @@ export function useHasTypographyPanel( settings ) {

function useHasFontSizeControl( settings ) {
return (
hasMergedOrigins( settings?.typography?.fontSizes ) ||
hasOriginValue( settings?.typography?.fontSizes ) ||
settings?.typography?.customFontSize
);
}

function useHasFontFamilyControl( settings ) {
return hasMergedOrigins( settings?.typography?.fontFamilies );
return hasOriginValue( settings?.typography?.fontFamilies );
}

function useHasLineHeightControl( settings ) {
Expand Down Expand Up @@ -101,10 +105,10 @@ function useHasTextColumnsControl( settings ) {
}

function getUniqueFontSizesBySlug( settings ) {
const fontSizes = settings?.typography?.fontSizes;
const mergedFontSizes = fontSizes ? mergeOrigins( fontSizes ) : [];
const fontSizes = settings?.typography?.fontSizes ?? {};
const overriddenFontSizes = fontSizes ? overrideOrigins( fontSizes ) : [];
const uniqueSizes = [];
for ( const currentSize of mergedFontSizes ) {
for ( const currentSize of overriddenFontSizes ) {
if ( ! uniqueSizes.some( ( { slug } ) => slug === currentSize.slug ) ) {
uniqueSizes.push( currentSize );
}
Expand Down Expand Up @@ -162,7 +166,7 @@ export default function TypographyPanel( {

// Font Family
const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
const fontFamilies = settings?.typography?.fontFamilies;
const fontFamilies = settings?.typography?.fontFamilies ?? {};
const mergedFontFamilies = fontFamilies ? mergeOrigins( fontFamilies ) : [];
const fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );
const setFontFamily = ( newValue ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export default function SpacingInputControl( {
options={ options }
label={ ariaLabel }
hideLabelFromVision={ true }
__nextUnconstrainedWidth={ true }
size={ '__unstable-large' }
onMouseOver={ onMouseOver }
onMouseOut={ onMouseOut }
Expand Down
7 changes: 5 additions & 2 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
}

export const coordsToBackgroundPosition = ( value ) => {
if ( ! value || isNaN( value.x ) || isNaN( value.y ) ) {
if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
return undefined;
}

return `${ value.x * 100 }% ${ value.y * 100 }%`;
const x = isNaN( value.x ) ? 0.5 : value.x;
const y = isNaN( value.y ) ? 0.5 : value.y;

return `${ x * 100 }% ${ y * 100 }%`;
};

export const backgroundPositionToCoords = ( value ) => {
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/hooks/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ export function PositionPanelPure( {
help={ stickyHelpText }
>
<CustomSelectControl
__nextUnconstrainedWidth
__next40pxDefaultSize
className="block-editor-hooks__position-selection__select-control"
label={ __( 'Position' ) }
Expand Down
Loading

0 comments on commit cd33f15

Please sign in to comment.