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: (24 commits)
  Add filter to turn off Interactivity API for a block (#52579)
  Search: Remove unnecessary useEffect (#52604)
  Navigation: Simplify the useSelect for useNavigationMenus (#51977)
  Item: Unify focus style and add default font styles (#52495)
  Update Changelog for 16.2.1
  Bump plugin version to 16.2.1
  Avoid passing undefined `selectedBlockClientId` in `BlockActionsMenu` (#52595)
  Cover Block: Fix block deprecation when fixed background is enabled (#51612)
  Nav block: link text color inheritance fixes and tests (#51710)
  Stabilize defaultBlock, directInsert API's and getDirectInsertBlock selector (#52083)
  Fix console warning by improving error handling in Nav block classic menu conversion (#52591)
  Fix: Remove link action of Link UI for draft pages created from Nav block does not correctly remove link. (#52415)
  Lodash: Remove remaining `_.get()` from block editor and deprecate (#52561)
  Fix importing classic menus (#52573)
  ResizableFrame: Make keyboard accessible (#52443)
  Site Editor: Fix navigation menu sidebar actions order and label (#52592)
  correct a typo: sapce -> space (#52578)
  Avoid errors in Dimension visualizers when switching between iframed and non-iframed editors (#52588)
  Patterns: Add client side pagination to patterns list (#52538)
  Site Editor: Make sidebar back button go *back* instead of *up* if possible (#52456)
  ...
  • Loading branch information
westonruter committed Jul 13, 2023
2 parents 4f7301b + b690db2 commit 3e7c73e
Show file tree
Hide file tree
Showing 69 changed files with 1,460 additions and 461 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const restrictedImports = [
'flowRight',
'forEach',
'fromPairs',
'get',
'groupBy',
'has',
'identity',
Expand Down
21 changes: 21 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
== Changelog ==

= 16.2.1 =

## Changelog

### Enhancements

#### Footnotes
- Footnotes: show in inserter and placeholder. ([52445](https://github.com/WordPress/gutenberg/pull/52445))

### Bug Fixes

#### Patterns
- Make Pattern title text clickable. ([52599](https://github.com/WordPress/gutenberg/pull/52599))

## Contributors

The following contributors merged PRs in this release:

@getdave @mcsf


= 16.2.0 =

## Changelog
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Add a link to a downloadable file. ([Source](https://github.com/WordPress/gutenb

- **Name:** core/file
- **Category:** media
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~), interactivity
- **Supports:** align, anchor, color (background, gradients, link, ~~text~~)
- **Attributes:** displayPreview, downloadButtonText, fileId, fileName, href, id, previewHeight, showDownloadButton, textLinkHref, textLinkTarget

## Footnotes
Expand Down Expand Up @@ -421,7 +421,7 @@ A collection of blocks that allow visitors to get around your site. ([Source](ht

- **Name:** core/navigation
- **Category:** theme
- **Supports:** align (full, wide), inserter, interactivity, layout (allowSizingOnChildren, default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), inserter, layout (allowSizingOnChildren, default, ~~allowInheriting~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** __unstableLocation, backgroundColor, customBackgroundColor, customOverlayBackgroundColor, customOverlayTextColor, customTextColor, hasIcon, icon, maxNestingLevel, openSubmenusOnClick, overlayBackgroundColor, overlayMenu, overlayTextColor, ref, rgbBackgroundColor, rgbTextColor, showSubmenuIcon, templateLock, textColor

## Custom Link
Expand Down
23 changes: 23 additions & 0 deletions docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,29 @@ _Returns_
- `Array`: ids of top-level and descendant blocks.
### getDirectInsertBlock
Returns the block to be directly inserted by the block appender.
_Parameters_
- _state_ `Object`: Editor state.
- _rootClientId_ `?string`: Optional root client ID of block list.
_Returns_
- `?WPDirectInsertBlock`: The block type to be directly inserted.
_Type Definition_
- _WPDirectInsertBlock_ `Object`
_Properties_
- _name_ `string`: The type of block.
- _attributes_ `?Object`: Attributes to pass to the newly created block.
- _attributesToCopy_ `?Array<string>`: Attributes to be copied from adjecent blocks when inserted.
### getDraggedBlockClientIds
Returns the client ids of any blocks being directly dragged.
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
* Version: 16.2.1
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
21 changes: 21 additions & 0 deletions lib/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
* @package gutenberg
*/

/**
* Checks whether the experimental Interactivity API should be used for a block.
*
* Note: This function is located here instead of in interactivity-api/blocks.php because it has to be available earler.
*
* @param string $block_name Block name.
* @return bool Whether Interactivity API is used for block.
*/
function gutenberg_should_block_use_interactivity_api( $block_name ) {

/**
* Filters whether the experimental Interactivity API should be used for a block.
*
* @since 6.3.0
*
* @param bool $enabled Whether Interactivity API is used for block.
* @param string $block_name Block name.
*/
return (bool) apply_filters( 'gutenberg_should_block_use_interactivity_api', true, $block_name );
}

if ( ! function_exists( 'wp_enqueue_block_view_script' ) ) {
/**
* Enqueues a frontend script for a specific block.
Expand Down
3 changes: 1 addition & 2 deletions 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",
"version": "16.2.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
1 change: 0 additions & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"dom-scroll-into-view": "^1.2.1",
"fast-deep-equal": "^3.1.3",
"inherits": "^2.0.3",
"lodash": "^4.17.21",
"react-autosize-textarea": "^7.1.0",
"react-easy-crop": "^4.5.1",
"rememo": "^4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ const BlockActionsMenu = ( {
} = getMoversSetup( isStackedHorizontally, moversOptions );

// Check if selected block is Groupable and/or Ungroupable.
const convertToGroupButtonProps = useConvertToGroupButtonProps( [
selectedBlockClientId,
] );
const convertToGroupButtonProps = useConvertToGroupButtonProps(
// `selectedBlockClientId` can be undefined in some cases where this
// component gets re-rendered right after the block is removed.
selectedBlockClientId ? [ selectedBlockClientId ] : []
);
const { isGroupable, isUngroupable } = convertToGroupButtonProps;
const showConvertToGroupButton =
( isGroupable || isUngroupable ) && canRemove;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* Internal dependencies
*/
import { scopeSelector } from './utils';
import { getValueFromObjectPath } from '../../utils/object';

/**
* Determine the CSS selector for the block type and target provided, returning
Expand Down Expand Up @@ -69,15 +65,15 @@ export function getBlockCSSSelector(
if ( hasSelectors ) {
// Get selector from either `feature.root` or shorthand path.
const featureSelector =
get( selectors, `${ path }.root`, null ) ||
get( selectors, path, null );
getValueFromObjectPath( selectors, `${ path }.root`, null ) ||
getValueFromObjectPath( selectors, path, null );

// Return feature selector if found or any available fallback.
return featureSelector || fallbackSelector;
}

// Try getting old experimental supports selector value.
const featureSelector = get(
const featureSelector = getValueFromObjectPath(
supports,
`${ path }.__experimentalSelector`,
null
Expand All @@ -98,7 +94,7 @@ export function getBlockCSSSelector(

// Use selectors API if available.
if ( hasSelectors ) {
subfeatureSelector = get( selectors, path, null );
subfeatureSelector = getValueFromObjectPath( selectors, path, null );
}

// Only return if we have a subfeature selector.
Expand Down
18 changes: 9 additions & 9 deletions packages/block-editor/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import fastDeepEqual from 'fast-deep-equal/es6';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -16,7 +15,7 @@ import { _x } from '@wordpress/i18n';
* Internal dependencies
*/
import { getValueFromVariable, getPresetVariableFromValue } from './utils';
import { setImmutably } from '../../utils/object';
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
import { GlobalStylesContext } from './context';
import { unlock } from '../../lock-unlock';

Expand Down Expand Up @@ -104,18 +103,19 @@ export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {

if ( propertyPath ) {
return (
get( configToUse, contextualPath ) ??
get( configToUse, globalPath )
getValueFromObjectPath( configToUse, contextualPath ) ??
getValueFromObjectPath( configToUse, globalPath )
);
}

let result = {};
VALID_SETTINGS.forEach( ( setting ) => {
const value =
get(
getValueFromObjectPath(
configToUse,
`settings${ appendedBlockPath }.${ setting }`
) ?? get( configToUse, `settings.${ setting }` );
) ??
getValueFromObjectPath( configToUse, `settings.${ setting }` );
if ( value ) {
result = setImmutably( result, setting.split( '.' ), value );
}
Expand Down Expand Up @@ -176,19 +176,19 @@ export function useGlobalStyle(
let rawResult, result;
switch ( source ) {
case 'all':
rawResult = get( mergedConfig, finalPath );
rawResult = getValueFromObjectPath( mergedConfig, finalPath );
result = shouldDecodeEncode
? getValueFromVariable( mergedConfig, blockName, rawResult )
: rawResult;
break;
case 'user':
rawResult = get( userConfig, finalPath );
rawResult = getValueFromObjectPath( userConfig, finalPath );
result = shouldDecodeEncode
? getValueFromVariable( mergedConfig, blockName, rawResult )
: rawResult;
break;
case 'base':
rawResult = get( baseConfig, finalPath );
rawResult = getValueFromObjectPath( baseConfig, finalPath );
result = shouldDecodeEncode
? getValueFromVariable( baseConfig, blockName, rawResult )
: rawResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -32,7 +27,11 @@ import { PresetDuotoneFilter } from '../duotone/components';
import { getGapCSSValue } from '../../hooks/gap';
import { store as blockEditorStore } from '../../store';
import { LAYOUT_DEFINITIONS } from '../../layouts/definitions';
import { kebabCase, setImmutably } from '../../utils/object';
import {
getValueFromObjectPath,
kebabCase,
setImmutably,
} from '../../utils/object';

// List of block support features that can have their related styles
// generated under their own feature level selector rather than the block's.
Expand Down Expand Up @@ -69,7 +68,11 @@ function compileStyleValue( uncompiledValue ) {
function getPresetsDeclarations( blockPresets = {}, mergedSettings ) {
return PRESET_METADATA.reduce(
( declarations, { path, valueKey, valueFunc, cssVarInfix } ) => {
const presetByOrigin = get( blockPresets, path, [] );
const presetByOrigin = getValueFromObjectPath(
blockPresets,
path,
[]
);
[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
if ( presetByOrigin[ origin ] ) {
presetByOrigin[ origin ].forEach( ( value ) => {
Expand Down Expand Up @@ -113,7 +116,11 @@ function getPresetsClasses( blockSelector = '*', blockPresets = {} ) {
return declarations;
}

const presetByOrigin = get( blockPresets, path, [] );
const presetByOrigin = getValueFromObjectPath(
blockPresets,
path,
[]
);
[ 'default', 'theme', 'custom' ].forEach( ( origin ) => {
if ( presetByOrigin[ origin ] ) {
presetByOrigin[ origin ].forEach( ( { slug } ) => {
Expand Down Expand Up @@ -147,7 +154,11 @@ function getPresetsSvgFilters( blockPresets = {} ) {
// Duotone are the only type of filters for now.
( metadata ) => metadata.path.at( -1 ) === 'duotone'
).flatMap( ( metadata ) => {
const presetByOrigin = get( blockPresets, metadata.path, {} );
const presetByOrigin = getValueFromObjectPath(
blockPresets,
metadata.path,
{}
);
return [ 'default', 'theme' ]
.filter( ( origin ) => presetByOrigin[ origin ] )
.flatMap( ( origin ) =>
Expand Down Expand Up @@ -319,7 +330,10 @@ export function getStylesDeclarations(
return declarations;
}

const styleValue = get( blockStyles, pathToValue );
const styleValue = getValueFromObjectPath(
blockStyles,
pathToValue
);

// Root-level padding styles don't currently support strings with CSS shorthand values.
// This may change: https://github.com/WordPress/gutenberg/issues/40132.
Expand All @@ -334,7 +348,9 @@ export function getStylesDeclarations(
Object.entries( properties ).forEach( ( entry ) => {
const [ name, prop ] = entry;

if ( ! get( styleValue, [ prop ], false ) ) {
if (
! getValueFromObjectPath( styleValue, [ prop ], false )
) {
// Do not create a declaration
// for sub-properties that don't have any value.
return;
Expand All @@ -345,17 +361,19 @@ export function getStylesDeclarations(
: kebabCase( name );
declarations.push(
`${ cssProperty }: ${ compileStyleValue(
get( styleValue, [ prop ] )
getValueFromObjectPath( styleValue, [ prop ] )
) }`
);
} );
} else if ( get( blockStyles, pathToValue, false ) ) {
} else if (
getValueFromObjectPath( blockStyles, pathToValue, false )
) {
const cssProperty = key.startsWith( '--' )
? key
: kebabCase( key );
declarations.push(
`${ cssProperty }: ${ compileStyleValue(
get( blockStyles, pathToValue )
getValueFromObjectPath( blockStyles, pathToValue )
) }`
);
}
Expand Down Expand Up @@ -384,7 +402,7 @@ export function getStylesDeclarations(
let ruleValue = rule.value;
if ( typeof ruleValue !== 'string' && ruleValue?.ref ) {
const refPath = ruleValue.ref.split( '.' );
ruleValue = get( tree, refPath );
ruleValue = getValueFromObjectPath( tree, refPath );
// Presence of another ref indicates a reference to another dynamic value.
// Pointing to another dynamic value is not supported.
if ( ! ruleValue || ruleValue?.ref ) {
Expand Down Expand Up @@ -680,7 +698,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => {
const pickPresets = ( treeToPickFrom ) => {
let presets = {};
PRESET_METADATA.forEach( ( { path } ) => {
const value = get( treeToPickFrom, path, false );
const value = getValueFromObjectPath( treeToPickFrom, path, false );
if ( value !== false ) {
presets = setImmutably( presets, path, value );
}
Expand Down
Loading

0 comments on commit 3e7c73e

Please sign in to comment.