Skip to content

Commit

Permalink
Bugfixes for 6.3 RC2 (#52863)
Browse files Browse the repository at this point in the history
* Filter out patterns that are not allowed in the inserter (#52675)

* Remove autofocus and improve placeholder text consistency. (#52634)

* Do not navigate to the styles pages unless you're in a random listing page (#52728)

* Patterns: Don't override the rootClientID  in create menu - only set if undefined (#52713)

* Footnotes: store in revisions (#52686)

* Fix: Block toolbar obscuring document tools when Top Toolbar is enabled (#52722)

* Update toolbar width

* Site editor needs specific width

* fixes top toolbar width for post editor when not in fullscreen

* remove the body rule

---------

Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com>

* Site Editor: Fix site link accessibility issues (#52744)

* Add id to pattern inserted notice to stop multiple notices stacking (#52746)

* Global Styles: Don't use named arguments for 'sprintf' (#52782)

* Footnotes: Use static closures when not using '' (#52781)

* removes check for active preview device type to enable the fixed toolbar preference (#52770)

* Parser / Site Editor: Ensure autop is not run when freeform block is set to core/html (#52716)

* Parse / Site Editor: Ensure autop is not run when freeform block is set to core/html

* Switch to equals freeform instead of not equals core/html

* Rename core/test-freeform to core/freeform in tests

* Adding @SInCE annotation for relevant 6.3 changes. (#52820)

* Navigation: Load the raw property on the navigation fallback (#52758)

* Navigation: Load the raw property on the navigation fallback

* Update lib/compat/wordpress-6.3/navigation-fallback.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update lib/compat/wordpress-6.3/navigation-fallback.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Add a test for these properties

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* Update phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

* add more comments

* add necessary method

* Fix php coding standards error

---------

Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>

* Allow styles to be changed dynamically through editor settings (#52767)

* ResizableFrame: Fix styling in Firefox (#52700)

* ResizableFrame: Fix styling in Firefox

* Remove unused class

* Patterns: Fix empty general template parts category (#52747)

---------

Co-authored-by: Glen Davies <glen.davies@automattic.com>

---------

Co-authored-by: Carolina Nymark <myazalea@hotmail.com>
Co-authored-by: Andrea Fercia <a.fercia@gmail.com>
Co-authored-by: Riad Benguella <benguella@gmail.com>
Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com>
Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com>
Co-authored-by: James Koster <james@jameskoster.co.uk>
Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Ben Dwyer <ben@scruffian.com>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>
Co-authored-by: Lena Morita <lena@jaguchi.com>
Co-authored-by: Kai Hao <kevin830726@gmail.com>
Co-authored-by: Glen Davies <glen.davies@automattic.com>
  • Loading branch information
18 people committed Jul 24, 2023
1 parent cedb8ca commit 439c458
Show file tree
Hide file tree
Showing 35 changed files with 656 additions and 196 deletions.
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.3/navigation-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ function gutenberg_add_fields_to_navigation_fallback_embeded_links( $schema ) {
$schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) );

// Expose sub properties of content field.
// These aren't exposed by the posts controller by default, see:
// https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2425.
$schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) );

// Expose sub properties of title field.
// These aren't exposed by the posts controller by default, see:
// https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2401.
$schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) );

return $schema;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,15 @@
// for the block inserter the publish button
@include break-large() {
&.is-fixed {
width: auto;
}
.is-fullscreen-mode &.is-fixed {
// in full screen mode we need to account for
// the combined with of the tools at the right of the header and the margin left
// of the toolbar which includes four buttons
width: calc(100% - 240px - #{4 * $grid-unit-80});
}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const usePatternsState = ( onInsert, rootClientId ) => {
),
{
type: 'snackbar',
id: 'block-pattern-inserted-notice',
}
);
},
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe( 'selectors', () => {
parent: [ 'core/test-block-b' ],
} );

registerBlockType( 'core/test-freeform', {
registerBlockType( 'core/freeform', {
save: ( props ) => <RawHTML>{ props.attributes.content }</RawHTML>,
category: 'text',
title: 'Test Freeform Content Handler',
Expand Down Expand Up @@ -177,7 +177,7 @@ describe( 'selectors', () => {
ancestor: [ 'core/test-block-ancestor' ],
} );

setFreeformContentHandlerName( 'core/test-freeform' );
setFreeformContentHandlerName( 'core/freeform' );

cachedSelectors.forEach( ( { clear } ) => clear() );
} );
Expand All @@ -187,7 +187,7 @@ describe( 'selectors', () => {
unregisterBlockType( 'core/test-block-a' );
unregisterBlockType( 'core/test-block-b' );
unregisterBlockType( 'core/test-block-c' );
unregisterBlockType( 'core/test-freeform' );
unregisterBlockType( 'core/freeform' );
unregisterBlockType( 'core/post-content-child' );
unregisterBlockType( 'core/test-block-ancestor' );
unregisterBlockType( 'core/test-block-parent' );
Expand Down Expand Up @@ -3450,7 +3450,7 @@ describe( 'selectors', () => {
expect( firstBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
'core/test-block-a',
'core/test-block-b',
'core/test-freeform',
'core/freeform',
'core/test-block-ancestor',
'core/test-block-parent',
'core/block/1',
Expand All @@ -3466,7 +3466,7 @@ describe( 'selectors', () => {
expect( secondBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
'core/test-block-a',
'core/test-block-b',
'core/test-freeform',
'core/freeform',
'core/test-block-ancestor',
'core/test-block-parent',
'core/block/1',
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/comment-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Function that recursively renders a list of nested comments.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @global int $comment_depth
*
* @param WP_Comment[] $comments The array of comments.
Expand Down
138 changes: 138 additions & 0 deletions packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/footnotes` block on the server.
*
* @since 6.3.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down Expand Up @@ -57,6 +59,8 @@ function render_block_core_footnotes( $attributes, $content, $block ) {

/**
* Registers the `core/footnotes` block on the server.
*
* @since 6.3.0
*/
function register_block_core_footnotes() {
foreach ( array( 'post', 'page' ) as $post_type ) {
Expand All @@ -78,3 +82,137 @@ function register_block_core_footnotes() {
);
}
add_action( 'init', 'register_block_core_footnotes' );

add_action(
'wp_after_insert_post',
/**
* Saves the footnotes meta value to the revision.
*
* @since 6.3.0
*
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
$post_id = wp_is_post_revision( $revision_id );

if ( $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
}
}
}
);

add_action(
'_wp_put_post_revision',
/**
* Keeps track of the revision ID for "rest_after_insert_{$post_type}".
*
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
global $_gutenberg_revision_id;
$_gutenberg_revision_id = $revision_id;
}
);

foreach ( array( 'post', 'page' ) as $post_type ) {
add_action(
"rest_after_insert_{$post_type}",
/**
* This is a specific fix for the REST API. The REST API doesn't update
* the post and post meta in one go (through `meta_input`). While it
* does fix the `wp_after_insert_post` hook to be called correctly after
* updating meta, it does NOT fix hooks such as post_updated and
* save_post, which are normally also fired after post meta is updated
* in `wp_insert_post()`. Unfortunately, `wp_save_post_revision` is
* added to the `post_updated` action, which means the meta is not
* available at the time, so we have to add it afterwards through the
* `"rest_after_insert_{$post_type}"` action.
*
* @since 6.3.0
*
* @param WP_Post $post The post object.
*/
static function( $post ) {
global $_gutenberg_revision_id;

if ( $_gutenberg_revision_id ) {
$revision = get_post( $_gutenberg_revision_id );
$post_id = $revision->post_parent;

// Just making sure we're updating the right revision.
if ( $post->ID === $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $_gutenberg_revision_id, 'footnotes', $footnotes );
}
}
}
}
);
}

add_action(
'wp_restore_post_revision',
/**
* Restores the footnotes meta value from the revision.
*
* @since 6.3.0
*
* @param int $post_id The post ID.
* @param int $revision_id The revision ID.
*/
static function( $post_id, $revision_id ) {
$footnotes = get_post_meta( $revision_id, 'footnotes', true );

if ( $footnotes ) {
update_post_meta( $post_id, 'footnotes', $footnotes );
} else {
delete_post_meta( $post_id, 'footnotes' );
}
},
10,
2
);

add_filter(
'_wp_post_revision_fields',
/**
* Adds the footnotes field to the revision.
*
* @since 6.3.0
*
* @param array $fields The revision fields.
* @return array The revision fields.
*/
static function( $fields ) {
$fields['footnotes'] = __( 'Footnotes' );
return $fields;
}
);

add_filter(
'wp_post_revision_field_footnotes',
/**
* Gets the footnotes field from the revision.
*
* @since 6.3.0
*
* @param string $revision_field The field value, but $revision->$field
* (footnotes) does not exist.
* @param string $field The field name, in this case "footnotes".
* @param object $revision The revision object to compare against.
* @return string The field value.
*/
static function( $revision_field, $field, $revision ) {
return get_metadata( 'post', $revision->ID, $field, true );
},
10,
3
);
2 changes: 2 additions & 0 deletions packages/block-library/src/pattern/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function register_block_core_pattern() {
/**
* Renders the `core/pattern` block on the server.
*
* @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
*
* @param array $attributes Block attributes.
*
* @return string Returns the output of the pattern.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
/**
* Renders the `core/post-template` block on the server.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/post-title` block on the server.
*
* @since 6.3.0 Omitting the $post argument from the `get_the_title`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Dynamically renders the `core/search` block.
*
* @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
*
* @param array $attributes The block attributes.
* @param string $content The saved content.
* @param WP_Block $block The parsed block.
Expand Down
1 change: 1 addition & 0 deletions packages/blocks/src/api/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function normalizeRawBlock( rawBlock, options ) {
// meaning there are no negative consequences to repeated autop calls.
if (
rawBlockName === fallbackBlockName &&
rawBlockName === 'core/freeform' &&
! options?.__unstableSkipAutop
) {
rawInnerHTML = autop( rawInnerHTML ).trim();
Expand Down
23 changes: 17 additions & 6 deletions packages/blocks/src/api/parser/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,30 @@ describe( 'block parser', () => {
} );

it( 'should fall back to the freeform content handler if block type not specified', () => {
registerBlockType( 'core/freeform-block', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform-block' );
registerBlockType( 'core/freeform', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform' );

const block = parseRawBlock( {
innerHTML: 'content',
} );
expect( block.name ).toEqual( 'core/freeform-block' );
expect( block.name ).toEqual( 'core/freeform' );
expect( block.attributes ).toEqual( { content: '<p>content</p>' } );
} );

it( 'skips adding paragraph tags if freeform block is set to core/html', () => {
registerBlockType( 'core/html', unknownBlockSettings );
setFreeformContentHandlerName( 'core/html' );

const block = parseRawBlock( {
innerHTML: 'content',
} );
expect( block.name ).toEqual( 'core/html' );
expect( block.attributes ).toEqual( { content: 'content' } );
} );

it( 'skips adding paragraph tags if __unstableSkipAutop is passed as an option', () => {
registerBlockType( 'core/freeform-block', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform-block' );
registerBlockType( 'core/freeform', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform' );

const block = parseRawBlock(
{
Expand All @@ -112,7 +123,7 @@ describe( 'block parser', () => {
__unstableSkipAutop: true,
}
);
expect( block.name ).toEqual( 'core/freeform-block' );
expect( block.name ).toEqual( 'core/freeform' );
expect( block.attributes ).toEqual( { content: 'content' } );
} );

Expand Down
3 changes: 2 additions & 1 deletion packages/blocks/src/api/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ export function __unstableSerializeAndClean( blocks ) {
// pre-block-editor removep'd content formatting.
if (
blocks.length === 1 &&
blocks[ 0 ].name === getFreeformContentHandlerName()
blocks[ 0 ].name === getFreeformContentHandlerName() &&
blocks[ 0 ].name === 'core/freeform'
) {
content = removep( content );
}
Expand Down
Loading

0 comments on commit 439c458

Please sign in to comment.