Skip to content

Commit

Permalink
prep build 02/13
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Feb 13, 2024
2 parents 6985598 + 1a63093 commit fc23582
Show file tree
Hide file tree
Showing 49 changed files with 1,844 additions and 696 deletions.
15 changes: 15 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
== Changelog ==

= 17.6.6 =

## Changelog

### Bug Fixes

- Script loader 6.4 compat: check for init hook completion ([58406](https://github.com/WordPress/gutenberg/pull/58406))

## Contributors

The following contributors merged PRs in this release:

@ramonjd


= 17.7.0-rc.1 =


Expand Down
6 changes: 5 additions & 1 deletion docs/how-to-guides/themes/theme-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ add_action( 'after_setup_theme', 'mytheme_setup_theme_supported_features' );

Core blocks include default structural styles. These are loaded in both the editor and the front end by default. An example of these styles is the CSS that powers the columns block. Without these rules, the block would result in a broken layout containing no columns at all.

The block editor allows themes to opt-in to slightly more opinionated styles for the front end. An example of these styles is the default color bar to the left of blockquotes. If you'd like to use these opinionated styles in your theme, add theme support for `wp-block-styles`:
### Opinionated block styles

The block editor allows themes to opt in to slightly more opinionated styles for the front end. An example of these styles is the default color bar to the left of blockquotes. If you'd like to use these opinionated styles in a classic theme, add theme support for `wp-block-styles`:

```php
add_theme_support( 'wp-block-styles' );
```

You can see the CSS that will be included in the [block library theme file](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/theme.scss).

For block themes or themes providing a `theme.json` file, it is not recommended to use this theme support. Instead, to ensure there is no styling conflict between global styles rules and block styles, add the desired block styles to the theme's `theme.json` file.

### Wide Alignment:

Some blocks such as the image block have the possibility to define a "wide" or "full" alignment by adding the corresponding classname to the block's wrapper ( `alignwide` or `alignfull` ). A theme can opt-in for this feature by calling:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ Returns an action used to set the rendering mode of the post editor. We support

_Parameters_

- _mode_ `string`: Mode (one of 'post-only', 'template-locked' or 'all').
- _mode_ `string`: Mode (one of 'post-only' or 'template-locked').

### setTemplateValidity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php
/**
* REST API: Gutenberg_REST_Template_Revision_Count class
* REST API: Gutenberg_REST_Templates_Controller_6_4 class
*
* @package gutenberg
*/

/**
* Gutenberg_REST_Template_Revision_Count class
* Gutenberg_REST_Templates_Controller_6_4 class
*
* Template revision changes are waiting on a core change to be merged.
* See: https://github.com/WordPress/gutenberg/pull/45215#issuecomment-1592704026
* When merging into core, prepare_revision_links() should be merged with
* WP_REST_Templates_Controller::prepare_links().
*/
class Gutenberg_REST_Template_Revision_Count extends WP_REST_Templates_Controller {
class Gutenberg_REST_Templates_Controller_6_4 extends WP_REST_Templates_Controller {
/**
* Add revisions to the response.
*
Expand Down
20 changes: 20 additions & 0 deletions lib/compat/wordpress-6.4/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,23 @@ function gutenberg_register_rest_block_patterns_routes() {
$block_patterns->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_rest_block_patterns_routes' );


if ( ! function_exists( 'wp_api_template_revision_args' ) ) {
/**
* Hook in to the template and template part post types and decorate
* the rest endpoint with the revision count.
*
* @param array $args Current registered post type args.
* @param string $post_type Name of post type.
*
* @return array
*/
function wp_api_template_revision_args( $args, $post_type ) {
if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) {
$args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_4';
}
return $args;
}
}
add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 );
22 changes: 0 additions & 22 deletions lib/experimental/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,3 @@ function gutenberg_auto_draft_get_sample_permalink( $permalink, $id, $title, $na
return $permalink;
}
add_filter( 'get_sample_permalink', 'gutenberg_auto_draft_get_sample_permalink', 10, 5 );

if ( ! function_exists( 'wp_api_template_revision_args' ) ) {
/**
* Hook in to the template and template part post types and decorate
* the rest endpoint with the revision count.
*
* When merging to core, this can be removed once Gutenberg_REST_Template_Revision_Count is
* merged with WP_REST_Template_Controller.
*
* @param array $args Current registered post type args.
* @param string $post_type Name of post type.
*
* @return array
*/
function wp_api_template_revision_args( $args, $post_type ) {
if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) {
$args['rest_controller_class'] = 'Gutenberg_REST_Template_Revision_Count';
}
return $args;
}
}
add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 );
2 changes: 1 addition & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function gutenberg_is_experiment_enabled( $name ) {
}

// WordPress 6.4 compat.
require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-templates-controller-6-4.php';
require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php';
require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-block-patterns-controller.php';
require_once __DIR__ . '/compat/wordpress-6.4/rest-api.php';
Expand All @@ -53,7 +54,6 @@ function gutenberg_is_experiment_enabled( $name ) {
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php';
}
require_once __DIR__ . '/experimental/class-gutenberg-rest-template-revision-count.php';
require_once __DIR__ . '/experimental/rest-api.php';

require_once __DIR__ . '/experimental/kses-allowed-html.php';
Expand Down
7 changes: 0 additions & 7 deletions packages/block-editor/src/components/link-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,6 @@ $block-editor-link-control-number-of-actions: 1;
}
}

.block-editor-link-control__drawer {
display: flex; // allow for ordering.
order: 30;
flex-direction: column;
flex-basis: 100%; // occupy full width.
}

// Inner div required to avoid padding/margin
// causing janky animation.
.block-editor-link-control__drawer-inner {
Expand Down
17 changes: 7 additions & 10 deletions packages/block-editor/src/components/observe-typing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ export function useMouseMoveTypingReset() {
* field, presses ESC or TAB, or moves the mouse in the document.
*/
export function useTypingObserver() {
const { isTyping, hasInlineToolbar } = useSelect( ( select ) => {
const { isTyping: _isTyping, getSettings } = select( blockEditorStore );
const { isTyping } = useSelect( ( select ) => {
const { isTyping: _isTyping } = select( blockEditorStore );
return {
isTyping: _isTyping(),
hasInlineToolbar: getSettings().hasInlineToolbar,
};
}, [] );
const { startTyping, stopTyping } = useDispatch( blockEditorStore );
Expand Down Expand Up @@ -183,12 +182,10 @@ export function useTypingObserver() {
node.addEventListener( 'focus', stopTypingOnNonTextField );
node.addEventListener( 'keydown', stopTypingOnEscapeKey );

if ( ! hasInlineToolbar ) {
ownerDocument.addEventListener(
'selectionchange',
stopTypingOnSelectionUncollapse
);
}
ownerDocument.addEventListener(
'selectionchange',
stopTypingOnSelectionUncollapse
);

return () => {
defaultView.clearTimeout( timerId );
Expand Down Expand Up @@ -245,7 +242,7 @@ export function useTypingObserver() {
node.removeEventListener( 'keydown', startTypingInTextField );
};
},
[ isTyping, hasInlineToolbar, startTyping, stopTyping ]
[ isTyping, startTyping, stopTyping ]
);

return useMergeRefs( [ ref1, ref2 ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,13 @@
*/
import { __ } from '@wordpress/i18n';
import { Popover, ToolbarGroup } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import {
isCollapsed,
getActiveFormats,
useAnchor,
store as richTextStore,
} from '@wordpress/rich-text';

/**
* Internal dependencies
*/
import BlockControls from '../block-controls';
import FormatToolbar from './format-toolbar';
import NavigableToolbar from '../navigable-toolbar';
import { store as blockEditorStore } from '../../store';

function InlineSelectionToolbar( { editableContentElement, activeFormats } ) {
const lastFormat = activeFormats[ activeFormats.length - 1 ];
const lastFormatType = lastFormat?.type;
const settings = useSelect(
( select ) => select( richTextStore ).getFormatType( lastFormatType ),
[ lastFormatType ]
);
const popoverAnchor = useAnchor( {
editableContentElement,
settings,
} );

return <InlineToolbar popoverAnchor={ popoverAnchor } />;
}

function InlineToolbar( { popoverAnchor } ) {
return (
Expand All @@ -56,35 +33,11 @@ function InlineToolbar( { popoverAnchor } ) {
);
}

const FormatToolbarContainer = ( {
inline,
editableContentElement,
value,
} ) => {
const hasInlineToolbar = useSelect(
( select ) => select( blockEditorStore ).getSettings().hasInlineToolbar,
[]
);

const FormatToolbarContainer = ( { inline, editableContentElement } ) => {
if ( inline ) {
return <InlineToolbar popoverAnchor={ editableContentElement } />;
}

if ( hasInlineToolbar ) {
const activeFormats = getActiveFormats( value );

if ( isCollapsed( value ) && ! activeFormats.length ) {
return null;
}

return (
<InlineSelectionToolbar
editableContentElement={ editableContentElement }
activeFormats={ activeFormats }
/>
);
}

// Render regular toolbar.
return (
<BlockControls group="inline">
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ export function RichTextWrapper(
<FormatToolbarContainer
inline={ inlineToolbar }
editableContentElement={ anchorRef.current }
value={ value }
/>
) }
<TagName
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/hooks/use-bindings-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createEditFunctionWithBindingsAttribute = () =>
settings.source
);

if ( source ) {
if ( source && source.useSource ) {
// Second argument (`updateMetaValue`) will be used to update the value in the future.
const {
placeholder,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ function blockBindingsSources( state = {}, action ) {
[ action.sourceName ]: {
label: action.sourceLabel,
useSource: action.useSource,
lockAttributesEditing: action.lockAttributesEditing,
lockAttributesEditing: action.lockAttributesEditing ?? true,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function ButtonEdit( props ) {
lockUrlControls:
!! metadata?.bindings?.url &&
getBlockBindingsSource( metadata?.bindings?.url?.source )
?.lockAttributesEditing === true,
?.lockAttributesEditing,
};
},
[ isSelected ]
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/details/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}
},
"supports": {
"__experimentalOnEnter": true,
"align": [ "wide", "full" ],
"color": {
"gradients": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/file/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static function ( $matches ) {

$processor = new WP_HTML_Tag_Processor( $content );
$processor->next_tag();
$processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' );
$processor->set_attribute( 'data-wp-interactive', 'core/file' );
$processor->next_tag( 'object' );
$processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
$processor->set_attribute( 'hidden', true );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export function ImageEdit( {
lockUrlControls:
!! metadata?.bindings?.url &&
getBlockBindingsSource( metadata?.bindings?.url?.source )
?.lockAttributesEditing === true,
?.lockAttributesEditing,
};
},
[ isSingleSelected ]
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,19 @@ export default function Image( {
lockUrlControls:
!! urlBinding &&
getBlockBindingsSource( urlBinding?.source )
?.lockAttributesEditing === true,
?.lockAttributesEditing,
lockHrefControls:
// Disable editing the link of the URL if the image is inside a pattern instance.
// This is a temporary solution until we support overriding the link on the frontend.
hasParentPattern,
lockAltControls:
!! altBinding &&
getBlockBindingsSource( altBinding?.source )
?.lockAttributesEditing === true,
?.lockAttributesEditing,
lockTitleControls:
!! titleBinding &&
getBlockBindingsSource( titleBinding?.source )
?.lockAttributesEditing === true,
?.lockAttributesEditing,
};
},
[ clientId, isSingleSelected, metadata?.bindings ]
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
$figure_class_names = $p->get_attribute( 'class' );
$figure_styles = $p->get_attribute( 'style' );
$p->add_class( 'wp-lightbox-container' );
$p->set_attribute( 'data-wp-interactive', '{"namespace":"core/image"}' );
$p->set_attribute( 'data-wp-interactive', 'core/image' );
$p->set_attribute(
'data-wp-context',
wp_json_encode(
Expand Down Expand Up @@ -240,7 +240,7 @@ function block_core_image_print_lightbox_overlay() {
echo <<<HTML
<div
class="wp-lightbox-overlay zoom"
data-wp-interactive='{"namespace":"core/image"}'
data-wp-interactive="core/image"
data-wp-context='{}'
data-wp-bind--role="state.roleAttribute"
data-wp-bind--aria-label="state.currentImage.ariaLabel"
Expand Down
Loading

0 comments on commit fc23582

Please sign in to comment.