Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/social-mover-orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
richtabor committed Feb 27, 2023
2 parents 50183ef + b4e9e0a commit 465b761
Show file tree
Hide file tree
Showing 50 changed files with 2,255 additions and 2,572 deletions.
25 changes: 25 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
== Changelog ==

= 15.2.2 =



## Changelog

### Bug Fixes

#### Layout
- Post Editor: Update postContentBlock check to see if the block is valid. ([48386](https://github.com/WordPress/gutenberg/pull/48386))


## First time contributors

The following PRs were merged by first time contributors:



## Contributors

The following contributors merged PRs in this release:

@andrewserong


= 15.2.1 =


Expand Down
9 changes: 9 additions & 0 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,15 @@ Post terms. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages
- **Supports:** anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** prefix, separator, suffix, term, textAlign

## 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))

- **Name:** core/post-time-to-read
- **Category:** theme
- **Supports:** ~~html~~, ~~multiple~~
- **Attributes:** textAlign

## Post Title

Displays the title of a post, page, or any other content-type. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/post-title))
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.0
* Requires PHP: 5.6
* Version: 15.2.1
* Version: 15.2.2
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
1 change: 1 addition & 0 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function gutenberg_reregister_core_block_types() {
'post-featured-image.php' => 'core/post-featured-image',
'post-navigation-link.php' => 'core/post-navigation-link',
'post-terms.php' => 'core/post-terms',
'post-time-to-read.php' => 'core/post-time-to-read',
'post-title.php' => 'core/post-title',
'query.php' => 'core/query',
'post-template.php' => 'core/post-template',
Expand Down
139 changes: 139 additions & 0 deletions lib/experimental/l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php
/**
* PHP and WordPress configuration compatibility functions for the Gutenberg
* editor plugin changes related to i18n.
*
* @package gutenberg
*/

/**
* Override core's wp_get_word_count_type() introduced in WordPress 6.2.
* Originally, get_word_count_type() method of the WP_Locale class is executed,
* but the process is simulated here.
*
* This function should not be backported to core.
*/
if ( ! function_exists( 'wp_get_word_count_type' ) ) {
/**
* Retrieves the word count type based on the locale.
*
* @return string Locale-specific word count type.
*/
function wp_get_word_count_type() {
$word_count_type = _x( 'words', 'Word count type. Do not translate!', 'gutenberg' );

// Check for valid types.
if ( 'characters_excluding_spaces' !== $word_count_type && 'characters_including_spaces' !== $word_count_type ) {
// Defaults to 'words'.
$word_count_type = 'words';
}
return $word_count_type;
}
}

if ( ! function_exists( 'wp_word_count' ) ) {
/**
* Count words or characters in a provided text string.
*
* @param string $text Text to count elements in.
* @param string $type The type of count. Accepts 'words', 'characters_excluding_spaces', or 'characters_including_spaces'.
* @param array $settings {
* Optional. Array of arguments used to overrides for settings.
*
* @type string $html_regexp Optional. Regular expression to find HTML elements.
* @type string $html_comment_regexp Optional. Regular expression to find HTML comments.
* @type string $space_regexp Optional. Regular expression to find irregular space
* characters.
* @type string $html_entity_regexp Optional. Regular expression to find HTML entities.
* @type string $connector_regexp Optional. Regular expression to find connectors that
* split words.
* @type string $remove_regexp Optional. Regular expression to find remove unwanted
* characters to reduce false-positives.
* @type string $astral_regexp Optional. Regular expression to find unwanted
* characters when searching for non-words.
* @type string $words_regexp Optional. Regular expression to find words by spaces.
* @type string $characters_excluding_spaces_regexp Optional. Regular expression to find characters which
* are non-spaces.
* @type string $characters_including_spaces_regexp Optional. Regular expression to find characters
* including spaces.
* @type array $shortcodes Optional. Array of shortcodes that should be removed
* from the text.
* }
* @return int The word or character count.
*/
function wp_word_count( $text, $type, $settings = array() ) {
$defaults = array(
'html_regexp' => '/<\/?[a-z][^>]*?>/i',
'html_comment_regexp' => '/<!--[\s\S]*?-->/',
'space_regexp' => '/&nbsp;|&#160;/i',
'html_entity_regexp' => '/&\S+?;/',
'connector_regexp' => "/--|\x{2014}/u",
'remove_regexp' => "/[\x{0021}-\x{0040}\x{005B}-\x{0060}\x{007B}-\x{007E}\x{0080}-\x{00BF}\x{00D7}\x{00F7}\x{2000}-\x{2BFF}\x{2E00}-\x{2E7F}]/u",
'astral_regexp' => "/[\x{010000}-\x{10FFFF}]/u",
'words_regexp' => '/\S\s+/u',
'characters_excluding_spaces_regexp' => '/\S/u',
'characters_including_spaces_regexp' => "/[^\f\n\r\t\v\x{00AD}\x{2028}\x{2029}]/u",
'shortcodes' => array(),
);

$count = 0;

if ( ! $text ) {
return $count;
}

$settings = wp_parse_args( $settings, $defaults );

// If there are any shortcodes, add this as a shortcode regular expression.
if ( is_array( $settings['shortcodes'] ) && ! empty( $settings['shortcodes'] ) ) {
$settings['shortcodes_regexp'] = '/\\[\\/?(?:' . implode( '|', $settings['shortcodes'] ) . ')[^\\]]*?\\]/';
}

// Sanitize type to one of three possibilities: 'words', 'characters_excluding_spaces' or 'characters_including_spaces'.
if ( 'characters_excluding_spaces' !== $type && 'characters_including_spaces' !== $type ) {
$type = 'words';
}

$text .= "\n";

// Replace all HTML with a new-line.
$text = preg_replace( $settings['html_regexp'], "\n", $text );

// Remove all HTML comments.
$text = preg_replace( $settings['html_comment_regexp'], '', $text );

// If a shortcode regular expression has been provided use it to remove shortcodes.
if ( ! empty( $settings['shortcodes_regexp'] ) ) {
$text = preg_replace( $settings['shortcodes_regexp'], "\n", $text );
}

// Normalize non-breaking space to a normal space.
$text = preg_replace( $settings['space_regexp'], ' ', $text );

if ( 'words' === $type ) {
// Remove HTML Entities.
$text = preg_replace( $settings['html_entity_regexp'], '', $text );

// Convert connectors to spaces to count attached text as words.
$text = preg_replace( $settings['connector_regexp'], ' ', $text );

// Remove unwanted characters.
$text = preg_replace( $settings['remove_regexp'], '', $text );
} else {
// Convert HTML Entities to "a".
$text = preg_replace( $settings['html_entity_regexp'], 'a', $text );

// Remove surrogate points.
$text = preg_replace( $settings['astral_regexp'], 'a', $text );
}

// Match with the selected type regular expression to count the items.
preg_match_all( $settings[ $type . '_regexp' ], $text, $matches );

if ( $matches ) {
return count( $matches[0] );
}

return $count;
}
}
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/experimental/blocks.php';
require __DIR__ . '/experimental/navigation-theme-opt-in.php';
require __DIR__ . '/experimental/kses.php';
require __DIR__ . '/experimental/l10n.php';

// Fonts API.
if ( ! class_exists( 'WP_Fonts' ) ) {
Expand Down
3 changes: 2 additions & 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": "15.2.1",
"version": "15.2.2",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/block-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ function BlockStyles( { clientId, onSwitch = noop, onHoverClassName = noop } ) {
} ) }
</div>
{ hoveredStyle && ! isMobileViewport && (
<Popover placement="left-start" offset={ 20 }>
<Popover
placement="left-start"
offset={ 20 }
focusOnMount={ false }
>
<div
className="block-editor-block-styles__preview-panel"
onMouseLeave={ () => styleItemHandler( null ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
updateBlockAttributes( clientIds, newAttributes, true );
},
[
cleanEmptyObject,
getBlockAttributes,
getMultiSelectedBlockClientIds,
hasMultiSelection,
Expand Down
8 changes: 7 additions & 1 deletion packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ function ListViewBlock( {
selectedClientIds,
} );

// Detect if there is a block in the canvas currently being edited and multi-selection is not happening.
const currentlyEditingBlockInCanvas =
isSelected && selectedClientIds.length === 1;

return (
<ListViewLeaf
className={ classes }
Expand Down Expand Up @@ -268,7 +272,9 @@ function ListViewBlock( {
siblingBlockCount={ siblingBlockCount }
level={ level }
ref={ ref }
tabIndex={ tabIndex }
tabIndex={
currentlyEditingBlockInCanvas ? 0 : tabIndex
}
onFocus={ onFocus }
isExpanded={ isExpanded }
selectedClientIds={ selectedClientIds }
Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,10 @@ export const __unstableGetContentLockingParent = createSelector(
let result;
while ( state.blocks.parents.has( current ) ) {
current = state.blocks.parents.get( current );
if ( getTemplateLock( state, current ) === 'contentOnly' ) {
if (
current &&
getTemplateLock( state, current ) === 'contentOnly'
) {
result = current;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@wordpress/server-side-render": "file:../server-side-render",
"@wordpress/url": "file:../url",
"@wordpress/viewport": "file:../viewport",
"@wordpress/wordcount": "file:../wordcount",
"change-case": "^4.1.2",
"classnames": "^2.3.1",
"colord": "^2.7.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/block-library/src/avatar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,14 @@ const ResizableAvatar = ( {
<img
src={ doubledSizedSrc }
alt={ avatar.alt }
{ ...borderProps }
className={ classnames(
'avatar',
'avatar-' + attributes.size,
'photo',
'wp-block-avatar__image',
borderProps.className
) }
style={ {
...borderProps.style, // Border radius, width and style.
} }
style={ borderProps.style }
/>
</ResizableBox>
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import * as postFeaturedImage from './post-featured-image';
import * as postNavigationLink from './post-navigation-link';
import * as postTemplate from './post-template';
import * as postTerms from './post-terms';
import * as postTimeToRead from './post-time-to-read';
import * as postTitle from './post-title';
import * as preformatted from './preformatted';
import * as pullquote from './pullquote';
Expand Down Expand Up @@ -197,6 +198,7 @@ const getAllBlocks = () =>
postTerms,
postNavigationLink,
postTemplate,
postTimeToRead,
queryPagination,
queryPaginationNext,
queryPaginationNumbers,
Expand Down
20 changes: 20 additions & 0 deletions packages/block-library/src/post-time-to-read/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"__experimental": true,
"name": "core/post-time-to-read",
"title": "Time To Read",
"category": "theme",
"description": "Show minutes required to finish reading the post.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"attributes": {
"textAlign": {
"type": "string"
}
},
"supports": {
"html": false,
"multiple": false
}
}
Loading

0 comments on commit 465b761

Please sign in to comment.