Skip to content

Commit

Permalink
Update/first pre beta 4 (#52400)
Browse files Browse the repository at this point in the history
* add hint to show template part move (#52395)

* Page Content Focus: Ignore page content within a Query Loop block (#52351)

* Block Editor: Pass context and className props to editor.BlockEdit filter

* Page Content Focus: Ignore content blocks that are within a Query Loop

* Patterns: stop endless snackbars appearing (#52012)

* Patterns: Distinguish between theme patterns and template parts in category list (#52382)

* Allow opt out of auto-creation of Navigation fallback (#52319)

* Update welcome guide copy (#52282)

* Patterns: Update pattern copy (#52340)

* Post Title: The changes should be reflected when previewing a post (#52369)

* Update fixed block toolbar (#52123)

* update the icons for expanding and collapsing the fixed block toolbar

* hide the tools selector item in document tools for fixed toolbar preference

* reveal undo, redo and list view buttons

* tweaks for show icon labels and hide zoom out for top toolbar option

* improve the responsiveness of the fixed block toolbar

* remove the overflow rule - bad experiment

* update top toolbar test with the new label for buttons

* update the toolbar tests to account for moving the collapse button

* Drop PHP 5.6 CI jobs (#52345)

* Remove PHP 5.6 PHPUnit CI job
* Raise version in phpcs / WPCS

* Patterns: Add handling of sync status to the wp-admin patterns list page (#52346)

* Exit template focus when opening the W menu (#52235)

* wrap buttons (#52249)

* Update the behavior of the cached undo/redo stack (#51644)

Co-authored-by: Ella van Durpe <ella@vandurpe.com>

* Adjust top position (#52248)

* Patterns: add a hint about the rename of reusable blocks to menu and inserter  (#51771)

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>

* Site Editor: update headings hierarchy in the 'Manage all' screens (#52271)

* This commit:
- updates heading levels on the template and template part pages
- passes a `level` prop to Header from Page

* update h2 size

* Rolling back custom sizes

* Rolling back unnecessary classNames
There was a rogue space in trunk. Let's let it live

* Check randomizer experiment is enabled before rendering button (#52306)

* Hide parent selector when parent is 'disabled' or 'contentOnly' (#52264)

* Fix incorrect aria-describedby attributes for theme patterns (#52263)

* Patterns: rename sync_status and move to top level field on rest return instead of a meta field (#52146)

* Fix default block dimensions visibility (#52256)

* core/heading

* core/details

* core/list

* core/table

* core/video

* core/verse

* core/social-links

* core/site-title

* core/site-tagline

* core/site-logo

* core/post-time-to-read

* core/gallery

* core/code

* core/categories

* core/audio

* core/archives

* Patterns: Display all custom template part areas in sidebar nav (#52355)

* Revert phpcs back to PHP 5.6 (#52384)

Reverts phpcs PHP compatibility version back to 5.6.

* Check if experiment enabled fr this time (#52315)

* Navigation: Remove one preloaded endpoint (#52115)

* default to showing status (#52226)

* Command palette: rename (#52153)

* Revise use of “command menu” to “command palette”.

Dropping "global" where it was used as well.

* Find “command center” and replace with “command palette”

* Image block and behaviors: Fix some warnings (#52109)

* Fix first warning

* Fix second warning - dividing a NaN

* Turn off DFM for style book and style editing (#52117)

* Add confirmation step when deleting a Template (#52236)

* [Command Palette]: Remove suggestion for deleting templates/parts (#52168)

* Update stepper styling in Home template details panel (#51972)

* Update stepper styling

* Remove !important

* [Edit Post]: Add toggle fullscreen mode and list view commands (#52184)

* Style Book: Show tabs and make blocks clickable when entering edit mode from the Styles menu (#52222)

* Style Book: Show tabs and make blocks clickable when entering edit mode from the Styles menu

* Move lines

* !important (#52025)

* Navigation in Site View: Readd the edit button (#52111)

* Fix UnitControl crashing on regex control characters.

Units are now escaped using `escapeRegExp` before concatenating them into a regular expression.

Fixes #52211.
---------

Co-authored-by: Mitchell Austin <mr.fye@oneandthesame.net>

* Patterns: rename wp_block sync_status postmeta to wp_pattern_sync_status (#52232)

---------

Co-authored-by: Kai Hao <kai@kaihao.dev>

* Site Editor Frame: Ignore Spotlight in view mode (#52262)

* Guide: Place focus on the guide's container instead of its first tabbable (#52300)

* Guide: Place focus on the guide's container instead of its first tabbable

* Update CHANGELOG

* Post editor: Require confirmation before removing Footnotes (#52277)

* Post editor: Require confirmation before removing Footnotes

Context: #52176

* BlockRemovalWarningModal: Limit width to 40rem

* Explain that footnotes are preserved. Add warning to Site Editor

* Fix react-dropdown-menu version to avoid breaking change from one of … (#52356)

* Fix react-dropdown-menu version to avoid breaking change from one if its dependencies.

* Changelog update

* move changelog entry to the right place

* Update package-lock

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Robert Anderson <robert@noisysocks.com>
Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com>
Co-authored-by: James Koster <james@jameskoster.co.uk>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
Co-authored-by: Tonya Mork <tonya.mork@automattic.com>
Co-authored-by: Riad Benguella <benguella@gmail.com>
Co-authored-by: Ella van Durpe <ella@vandurpe.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Kai Hao <kevin830726@gmail.com>
Co-authored-by: Rich Tabor <hi@richtabor.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Ben Dwyer <ben@scruffian.com>
Co-authored-by: Mitchell Austin <mr.fye@oneandthesame.net>
Co-authored-by: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Co-authored-by: Timothy Jacobs <timothy@ironbounddesigns.com>
Co-authored-by: Kai Hao <kai@kaihao.dev>
Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com>
  • Loading branch information
1 parent 65fb4cd commit 20ea9f1
Show file tree
Hide file tree
Showing 116 changed files with 1,110 additions and 558 deletions.
1 change: 0 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ jobs:
fail-fast: true
matrix:
php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
Expand Down
12 changes: 9 additions & 3 deletions docs/explanations/architecture/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ For example, let's say a user edits the title of a post, followed by a modificat

The store also keep tracks of a "pointer" to the current "undo/redo" step. By default, the pointer always points to the last item in the stack. This pointer is updated when the user performs an undo or redo operation.

### Transient changes
### Cached changes

The undo/redo core behavior also supports what we call "transient modifications". These are modifications that are not stored in the undo/redo stack right away. For instance, when a user starts typing in a text field, the value of the field is modified in the store, but this modification is not stored in the undo/redo stack until after the user moves to the next word or after a few milliseconds. This is done to avoid creating a new undo/redo step for each character typed by the user.
The undo/redo core behavior also supports what we call "cached modifications". These are modifications that are not stored in the undo/redo stack right away. For instance, when a user starts typing in a text field, the value of the field is modified in the store, but this modification is not stored in the undo/redo stack until after the user moves to the next word or after a few milliseconds. This is done to avoid creating a new undo/redo step for each character typed by the user.

So by default, `core-data` store considers all modifications to properties that are marked as "transient" (like the `blocks` property in the post entity) as transient modifications. It keeps these modifications outside the undo/redo stack in what is called a "cache" of modifications and these modifications are only stored in the undo/redo stack when we explicitely call `__unstableCreateUndoLevel` or when the next non-transient modification is performed.
Cached changes are kept outside the undo/redo stack in what is called a "cache" of modifications and these modifications are only stored in the undo/redo stack when we explicitely call `__unstableCreateUndoLevel` or when the next modification is not a cached one.

By default all calls to `editEntityRecord` are considered "non-cached" unless the `isCached` option is passed as true. Example:

```js
wp.data.dispatch( 'core' ).editEntityRecord( 'postType', 'post', 1, { title: 'Hello World' }, { isCached: true } );
```
28 changes: 28 additions & 0 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,31 @@ function gutenberg_register_legacy_social_link_blocks() {
}

add_action( 'init', 'gutenberg_register_legacy_social_link_blocks' );

/**
* Migrate the legacy `sync_status` meta key (added 16.1) to the new `wp_pattern_sync_status` meta key (16.1.1).
*
* This filter is INTENTIONALLY left out of core as the meta key was fist introduced to core in 6.3 as `wp_pattern_sync_status`.
* see https://github.com/WordPress/gutenberg/pull/52232
*
* @param mixed $value The value to return, either a single metadata value or an array of values depending on the value of $single.
* @param int $object_id ID of the object metadata is for.
* @param string $meta_key Metadata key.
* @param bool $single Whether to return only the first value of the specified $meta_key.
*/
function gutenberg_legacy_wp_block_post_meta( $value, $object_id, $meta_key, $single ) {
if ( 'wp_pattern_sync_status' !== $meta_key ) {
return $value;
}

$sync_status = get_post_meta( $object_id, 'sync_status', $single );

if ( $single && 'unsynced' === $sync_status ) {
return $sync_status;
} elseif ( isset( $sync_status[0] ) && 'unsynced' === $sync_status[0] ) {
return $sync_status;
}

return $value;
}
add_filter( 'default_post_metadata', 'gutenberg_legacy_wp_block_post_meta', 10, 4 );
29 changes: 6 additions & 23 deletions lib/compat/wordpress-6.3/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function gutenberg_rename_reusable_block_cpt_to_pattern( $args, $post_type ) {
$args['labels']['item_reverted_to_draft'] = __( 'Pattern reverted to draft.' );
$args['labels']['item_scheduled'] = __( 'Pattern scheduled.' );
$args['labels']['item_updated'] = __( 'Pattern updated.' );
$args['rest_controller_class'] = 'Gutenberg_REST_Blocks_Controller';
}

return $args;
Expand Down Expand Up @@ -89,7 +90,7 @@ function gutenberg_add_custom_fields_to_wp_block( $args, $post_type ) {
add_filter( 'register_post_type_args', 'gutenberg_add_custom_fields_to_wp_block', 10, 2 );

/**
* Adds sync_status meta fields to the wp_block post type so an unsynced option can be added.
* Adds wp_pattern_sync_status meta fields to the wp_block post type so an unsynced option can be added.
*
* Note: This should be removed when the minimum required WP version is >= 6.3.
*
Expand All @@ -101,39 +102,21 @@ function gutenberg_wp_block_register_post_meta() {
$post_type = 'wp_block';
register_post_meta(
$post_type,
'sync_status',
'wp_pattern_sync_status',
array(
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
},
'sanitize_callback' => 'gutenberg_wp_block_sanitize_post_meta',
'sanitize_callback' => 'sanitize_text_field',
'single' => true,
'type' => 'string',
'show_in_rest' => array(
'schema' => array(
'type' => 'string',
'properties' => array(
'sync_status' => array(
'type' => 'string',
),
),
'type' => 'string',
'enum' => array( 'partial', 'unsynced' ),
),
),
)
);
}
/**
* Sanitizes the array of wp_block post meta sync_status string.
*
* Note: This should be removed when the minimum required WP version is >= 6.3.
*
* @see https://github.com/WordPress/gutenberg/pull/51144
*
* @param array $meta_value String to sanitize.
*
* @return array Sanitized string.
*/
function gutenberg_wp_block_sanitize_post_meta( $meta_value ) {
return sanitize_text_field( $meta_value );
}
add_action( 'init', 'gutenberg_wp_block_register_post_meta' );
11 changes: 10 additions & 1 deletion lib/compat/wordpress-6.3/class-gutenberg-navigation-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ class Gutenberg_Navigation_Fallback {
*/
public static function get_fallback() {

/**
* Filters whether or not a fallback should be created.
*
* @since 6.3.0
*
* @param bool Whether or not to create a fallback.
*/
$should_create_fallback = apply_filters( 'gutenberg_navigation_should_create_fallback', true );

$fallback = static::get_most_recently_published_navigation();

if ( $fallback ) {
if ( $fallback || ! $should_create_fallback ) {
return $fallback;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Reusable blocks REST API: WP_REST_Blocks_Controller class
*
* @package WordPress
* @subpackage REST_API
* @since 5.0.0
*/

/**
* Controller which provides a REST endpoint for the editor to read, create,
* edit and delete reusable blocks. Blocks are stored as posts with the wp_block
* post type.
*
* @since 5.0.0
*
* @see WP_REST_Posts_Controller
* @see WP_REST_Controller
*/
class Gutenberg_REST_Blocks_Controller extends WP_REST_Blocks_Controller {
/**
* Filters a response based on the context defined in the schema.
*
* @since 5.0.0
* @since 6.3 Adds the `wp_pattern_sync_status` property to the response.
*
* @param array $data Response data to filter.
* @param string $context Context defined in the schema.
* @return array Filtered response.
*/
public function filter_response_by_context( $data, $context ) {
$data = parent::filter_response_by_context( $data, $context );

/*
* Remove `title.rendered` and `content.rendered` from the response. It
* doesn't make sense for a reusable block to have rendered content on its
* own, since rendering a block requires it to be inside a post or a page.
*/
unset( $data['title']['rendered'] );
unset( $data['content']['rendered'] );

// Add the core wp_pattern_sync_status meta as top level property to the response.
$data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
unset( $data['meta']['wp_pattern_sync_status'] );
return $data;
}
}
18 changes: 0 additions & 18 deletions lib/compat/wordpress-6.3/navigation-block-preloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ function gutenberg_preload_navigation_posts( $preload_paths, $context ) {
// Preload the OPTIONS request for all Navigation posts request.
$preload_paths[] = array( $navigation_rest_route, 'OPTIONS' );

// Preload the GET request for ALL 'published' or 'draft' Navigation posts.
$preload_paths[] = array(
add_query_arg(
array(
'context' => 'edit',
'per_page' => 100,
'order' => 'desc',
'orderby' => 'date',
'_locale' => 'user',
// array indices are required to avoid query being encoded and not matching in cache.
'status[0]' => 'publish',
'status[1]' => 'draft',
),
$navigation_rest_route
),
'GET',
);

// Preload request for all menus in Browse Mode sidebar "Navigation" section.
$preload_paths[] = array(
add_query_arg(
Expand Down
2 changes: 2 additions & 0 deletions lib/experimental/interactivity-api/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
function gutenberg_block_update_interactive_view_script( $metadata ) {
if (
array_key_exists( 'name', $metadata ) &&
in_array( $metadata['name'], array( 'core/image' ), true ) &&
array_key_exists( 'file', $metadata ) &&
str_contains( $metadata['file'], 'build/block-library/blocks' )
) {
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
Expand Down
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/compat/wordpress-6.3/navigation-block-preloading.php';
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';

// Experimental.
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
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.

4 changes: 4 additions & 0 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ _Related_

Private @wordpress/block-editor APIs.

### ReusableBlocksRenameHint

Undocumented declaration.

### RichText

_Related_
Expand Down
35 changes: 26 additions & 9 deletions packages/block-editor/src/components/block-edit/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,25 @@ import BlockContext from '../block-context';
*/
const DEFAULT_BLOCK_CONTEXT = {};

export const Edit = ( props ) => {
const Edit = ( props ) => {
const { name } = props;
const blockType = getBlockType( name );

if ( ! blockType ) {
return null;
}

// `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;

return <Component { ...props } />;
};

const EditWithFilters = withFilters( 'editor.BlockEdit' )( Edit );

const EditWithGeneratedProps = ( props ) => {
const { attributes = {}, name } = props;
const blockType = getBlockType( name );
const blockContext = useContext( BlockContext );
Expand All @@ -49,13 +67,8 @@ export const Edit = ( props ) => {
return null;
}

// `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;

if ( blockType.apiVersion > 1 ) {
return <Component { ...props } context={ context } />;
return <EditWithFilters { ...props } context={ context } />;
}

// Generate a class name for the block's editable form.
Expand All @@ -69,8 +82,12 @@ export const Edit = ( props ) => {
);

return (
<Component { ...props } context={ context } className={ className } />
<EditWithFilters
{ ...props }
context={ context }
className={ className }
/>
);
};

export default withFilters( 'editor.BlockEdit' )( Edit );
export default EditWithGeneratedProps;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
/**
* Internal dependencies
*/
import { Edit } from '../edit';
import Edit from '../edit';
import { BlockContextProvider } from '../../block-context';

const noop = () => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
import BlockIcon from '../block-icon';
import { useShowMoversGestures } from '../block-toolbar/utils';
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';

/**
* Block parent selector component, displaying the hierarchy of the
Expand All @@ -24,14 +25,15 @@ import { store as blockEditorStore } from '../../store';
export default function BlockParentSelector() {
const { selectBlock, toggleBlockHighlight } =
useDispatch( blockEditorStore );
const { firstParentClientId, shouldHide, isDistractionFree } = useSelect(
const { firstParentClientId, isVisible, isDistractionFree } = useSelect(
( select ) => {
const {
getBlockName,
getBlockParents,
getSelectedBlockClientId,
getSettings,
} = select( blockEditorStore );
getBlockEditingMode,
} = unlock( select( blockEditorStore ) );
const { hasBlockSupport } = select( blocksStore );
const selectedBlockClientId = getSelectedBlockClientId();
const parents = getBlockParents( selectedBlockClientId );
Expand All @@ -41,11 +43,14 @@ export default function BlockParentSelector() {
const settings = getSettings();
return {
firstParentClientId: _firstParentClientId,
shouldHide: ! hasBlockSupport(
_parentBlockType,
'__experimentalParentSelector',
true
),
isVisible:
_firstParentClientId &&
getBlockEditingMode( _firstParentClientId ) === 'default' &&
hasBlockSupport(
_parentBlockType,
'__experimentalParentSelector',
true
),
isDistractionFree: settings.isDistractionFree,
};
},
Expand All @@ -66,7 +71,7 @@ export default function BlockParentSelector() {
},
} );

if ( shouldHide || firstParentClientId === undefined ) {
if ( ! isVisible ) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export function BlockRemovalWarningModal() {
<Modal
title={ __( 'Are you sure?' ) }
onRequestClose={ clearRemovalPrompt }
style={ {
maxWidth: '40rem',
} }
>
{ blockNamesForPrompt.length === 1 ? (
<p>{ blockTypePromptMessages[ blockNamesForPrompt[ 0 ] ] }</p>
Expand Down
Loading

0 comments on commit 20ea9f1

Please sign in to comment.