Skip to content

Commit

Permalink
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into a…
Browse files Browse the repository at this point in the history
…dd/defer-script-loading-strategy

* 'trunk' of https://github.com/WordPress/gutenberg:
  Update Changelog for 16.2.0
  Adding support for defined IDs in `TextControl` component (#52028)
  Bump plugin version to 16.2.0
  Revert "Bump plugin version to 16.2.0"
  Bump plugin version to 16.2.0
  Add maxLength to LinkControl search items (#52523)
  [RNMobile] Update Editor block inserter button styles and default text input placeholder/selection styles (#52269)
  Site Editor: Reset device preview type when exiting the editing mode (#52566)
  Trim footnote anchors from excerpts (#52518)
  Add back old Navigation and File blocks JavaScript implementation when Gutenberg is not installed (#52553)
  Block Editor: Ensure synced patterns are accounted for in 'getAllowedBlocks' (#52546)
  Fix md5 class messed up with new block key (#52557)
  Fix entity cache misses for single posts due to string as recordKey (#52338)
  Make "My patterns" permanently visible (#52531)
  Hide site hub when resizing frame upwards to avoid overlap (#52180)
  Fix "Manage all patterns" link appearance (#52532)
  Update navigation menu title size & weight in detail panels (#52477)
  Site Editor Patterns: Ensure sidebar does not shrink when long pattern titles are used (#52547)
  Site Editor: Restore quick inserter 'Browse all' button (#52529)
  Patterns: update the title of Pattern block in the block inspector card  (#52010)
  • Loading branch information
westonruter committed Jul 12, 2023
2 parents aefd67a + ee5482c commit f89e31a
Show file tree
Hide file tree
Showing 56 changed files with 1,129 additions and 358 deletions.
343 changes: 343 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Add a user’s avatar. ([Source](https://github.com/WordPress/gutenberg/tree/tru

## Pattern

Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))
Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))

- **Name:** core/block
- **Category:** reusable
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.2.0-rc.3
* Version: 16.2.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
25 changes: 25 additions & 0 deletions lib/compat/wordpress-6.3/footnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Compatiblity filters for improved footnotes support.
*
* In core, this could be fixed directly in key functions.
*
* @package gutenberg
*/

/**
* Trims footnote anchors from content.
*
* @param string $content HTML content.
* @return string Filtered content.
*/
function gutenberg_trim_footnotes( $content ) {
if ( ! doing_filter( 'get_the_excerpt' ) ) {
return $content;
}

static $footnote_pattern = '_<sup data-fn="[^"]+" class="[^"]+">\s*<a href="[^"]+" id="[^"]+">\d+</a>\s*</sup>_';
return preg_replace( $footnote_pattern, '', $content );
}

add_filter( 'the_content', 'gutenberg_trim_footnotes' );
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@
* to improve this code.
*/
class WP_Directive_Processor extends WP_HTML_Tag_Processor {

/**
* An array of root blocks.
*
* @var array
*/
static $root_blocks = array();

/**
* Add a root block to the list.
*
* @param array $block The block to add.
*
* @return void
*/
public static function add_root_block( $block ) {
self::$root_blocks[] = md5( serialize( $block ) );
}

/**
* Check if block is a root block.
*
* @param array $block The block to check.
*
* @return bool True if block is a root block, false otherwise.
*/
public static function is_root_block( $block ) {
return in_array( md5( serialize( $block ) ), self::$root_blocks, true );
}


/**
* Find the matching closing tag for an opening tag.
*
Expand Down
6 changes: 3 additions & 3 deletions lib/experimental/interactivity-api/directive-processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
function gutenberg_interactivity_process_directives_in_root_blocks( $block_content, $block ) {
// Don't process inner blocks or root blocks that don't contain directives.
if ( isset( $block['is_inner_block'] ) || strpos( $block_content, 'data-wp-' ) === false ) {
if ( ! WP_Directive_Processor::is_root_block( $block ) || strpos( $block_content, 'data-wp-' ) === false ) {
return $block_content;
}

Expand Down Expand Up @@ -47,8 +47,8 @@ function gutenberg_interactivity_process_directives_in_root_blocks( $block_conte
* @return array The parsed block.
*/
function gutenberg_interactivity_mark_inner_blocks( $parsed_block, $source_block, $parent_block ) {
if ( isset( $parent_block ) ) {
$parsed_block['is_inner_block'] = true;
if ( ! isset( $parent_block ) ) {
WP_Directive_Processor::add_root_block( $parsed_block );
}
return $parsed_block;
}
Expand Down
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/compat/wordpress-6.3/link-template.php';
require_once __DIR__ . '/compat/wordpress-6.3/block-patterns.php';
require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-blocks-controller.php';
require_once __DIR__ . '/compat/wordpress-6.3/footnotes.php';

// Experimental.
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
Expand Down
8 changes: 7 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": "16.2.0-rc.3",
"version": "16.2.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
53 changes: 17 additions & 36 deletions packages/block-editor/src/components/inserter/index.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { AccessibilityInfo, Platform, Text } from 'react-native';
import { AccessibilityInfo, Platform } from 'react-native';

/**
* WordPress dependencies
Expand Down Expand Up @@ -35,46 +35,30 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
const defaultRenderToggle = ( {
onToggle,
disabled,
style,
containerStyle,
iconStyle,
buttonStyle,
onLongPress,
useExpandedMode,
} ) => {
// The "expanded mode" refers to the editor's appearance when no blocks
// are currently selected. The "add block" button has a separate style
// for the "expanded mode", which are added via the below "expandedModeViewProps"
// and "expandedModeViewText" variables.
const expandedModeViewProps = useExpandedMode && {
icon: <Icon icon={ plus } style={ style } />,
customContainerStyles: containerStyle,
fixedRatio: false,
};
const expandedModeViewText = (
<Text style={ styles[ 'inserter-menu__add-block-button-text' ] }>
{ __( 'Add blocks' ) }
</Text>
);

return (
<ToolbarButton
title={ _x(
'Add block',
'Generic label for block inserter button'
) }
icon={ <Icon icon={ plusCircleFilled } style={ style } /> }
icon={ <Icon icon={ plus } style={ iconStyle } /> }
onClick={ onToggle }
extraProps={ {
hint: __( 'Double tap to add a block' ),
// testID is present to disambiguate this element for native UI tests. It's not
// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.
testID: 'add-block-button',
onLongPress,
hitSlop: { top: 10, bottom: 10, left: 10, right: 10 },
} }
isDisabled={ disabled }
{ ...expandedModeViewProps }
>
{ useExpandedMode && expandedModeViewText }
</ToolbarButton>
customContainerStyles={ buttonStyle }
fixedRatio={ false }
/>
);
};

Expand Down Expand Up @@ -249,23 +233,21 @@ export class Inserter extends Component {
renderToggle = defaultRenderToggle,
getStylesFromColorScheme,
showSeparator,
useExpandedMode,
} = this.props;
if ( showSeparator && isOpen ) {
return <BlockInsertionPoint />;
}
const style = useExpandedMode
? styles[ 'inserter-menu__add-block-button-icon--expanded' ]
: getStylesFromColorScheme(
styles[ 'inserter-menu__add-block-button-icon' ],
styles[ 'inserter-menu__add-block-button-icon--dark' ]
);

const containerStyle = getStylesFromColorScheme(

const buttonStyle = getStylesFromColorScheme(
styles[ 'inserter-menu__add-block-button' ],
styles[ 'inserter-menu__add-block-button--dark' ]
);

const iconStyle = getStylesFromColorScheme(
styles[ 'inserter-menu__add-block-button-icon' ],
styles[ 'inserter-menu__add-block-button-icon--dark' ]
);

const onPress = () => {
this.setState(
{
Expand Down Expand Up @@ -301,10 +283,9 @@ export class Inserter extends Component {
onToggle: onPress,
isOpen,
disabled,
style,
containerStyle,
iconStyle,
buttonStyle,
onLongPress,
useExpandedMode,
} ) }
<Picker
ref={ ( instance ) => ( this.picker = instance ) }
Expand Down
25 changes: 10 additions & 15 deletions packages/block-editor/src/components/inserter/style.native.scss
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
/** @format */

.inserter-menu__add-block-button-icon {
color: $blue-50;
.inserter-menu__add-block-button {
border-radius: 2px;
background-color: $black;
margin: 9px $grid-unit-20 10px $grid-unit-20;
padding: 0;
}

.inserter-menu__add-block-button-icon--dark {
color: $blue-30;
.inserter-menu__add-block-button--dark {
background-color: $white;
}

.inserter-menu__add-block-button-icon--expanded {
.inserter-menu__add-block-button-icon {
color: $white;
}

.inserter-menu__add-block-button {
border-radius: 22px;
background-color: $blue-50;
margin: 8px;
padding: 6px 16px 6px 12px;
}

.inserter-menu__add-block-button--dark {
background-color: $blue-30;
.inserter-menu__add-block-button-icon--dark {
color: $black;
}

.inserter-menu__add-block-button-text {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const LinkControlSearchItem = ( {
} ) => {
const info = isURL
? __( 'Press ENTER to add this link' )
: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );
: filterURLForDisplay( safeDecodeURI( suggestion?.url ), 24 );

return (
<MenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,28 @@ export default function useBlockDisplayInformation( clientId ) {
return useSelect(
( select ) => {
if ( ! clientId ) return null;
const { getBlockName, getBlockAttributes } =
select( blockEditorStore );
const {
getBlockName,
getBlockAttributes,
__experimentalGetReusableBlockTitle,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const blockName = getBlockName( clientId );
const blockType = getBlockType( blockName );
if ( ! blockType ) return null;
const attributes = getBlockAttributes( clientId );
const match = getActiveBlockVariation( blockName, attributes );
const isSynced =
isReusableBlock( blockType ) || isTemplatePart( blockType );
const isReusable = isReusableBlock( blockType );
const resusableTitle = isReusable
? __experimentalGetReusableBlockTitle( attributes.ref )
: undefined;
const title = resusableTitle || blockType.title;
const isSynced = isReusable || isTemplatePart( blockType );
const positionLabel = getPositionTypeLabel( attributes );
const blockTypeInfo = {
isSynced,
title: blockType.title,
title,
icon: blockType.icon,
description: blockType.description,
anchor: attributes?.anchor,
Expand Down
11 changes: 10 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2214,15 +2214,24 @@ export const getAllowedBlocks = createSelector(
return;
}

return getBlockTypes().filter( ( blockType ) =>
const blockTypes = getBlockTypes().filter( ( blockType ) =>
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
);
const hasReusableBlock =
canInsertBlockTypeUnmemoized( state, 'core/block', rootClientId ) &&
getReusableBlocks( state ).length > 0;

return [
...blockTypes,
...( hasReusableBlock ? [ 'core/block' ] : [] ),
];
},
( state, rootClientId ) => [
state.blockListSettings[ rootClientId ],
state.blocks.byClientId,
state.settings.allowedBlockTypes,
state.settings.templateLock,
getReusableBlocks( state ),
getBlockTypes(),
]
);
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 @@ -68,6 +68,7 @@
"fast-average-color": "^9.1.1",
"fast-deep-equal": "^3.1.3",
"memize": "^2.1.0",
"micromodal": "^0.4.10",
"remove-accents": "^0.4.2",
"uuid": "^8.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ exports[`Audio block renders audio block error state without crashing 1`] = `
onStartShouldSetResponder={[Function]}
placeholder="Add caption"
placeholderTextColor="gray"
selectionColor="black"
style={
{
"backgroundColor": undefined,
Expand Down Expand Up @@ -358,6 +359,7 @@ exports[`Audio block renders audio file without crashing 1`] = `
onStartShouldSetResponder={[Function]}
placeholder="Add caption"
placeholderTextColor="gray"
selectionColor="black"
style={
{
"backgroundColor": undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/block/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "core/block",
"title": "Pattern",
"category": "reusable",
"description": "Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used.",
"description": "Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used.",
"textdomain": "default",
"attributes": {
"ref": {
Expand Down
Loading

0 comments on commit f89e31a

Please sign in to comment.