Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:amitraj2203/gutenberg into fix/iss…
Browse files Browse the repository at this point in the history
…ue-62889
  • Loading branch information
amitraj2203 committed Jun 27, 2024
2 parents 361ac96 + 3200f90 commit 3cd98a8
Show file tree
Hide file tree
Showing 55 changed files with 804 additions and 201 deletions.
2 changes: 1 addition & 1 deletion docs/contributors/code/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ It is recommended to use the main `wp-polyfill` script handle which takes care o
| [Fetch Polyfill](https://www.npmjs.com/package/whatwg-fetch) | wp-polyfill-fetch | Polyfill that implements a subset of the standard Fetch specification |
| [Promise Polyfill](https://www.npmjs.com/package/promise-polyfill) | wp-polyfill-promise | Lightweight ES6 Promise polyfill for the browser and node |
| [Formdata Polyfill](https://www.npmjs.com/package/formdata-polyfill) | wp-polyfill-formdata | Polyfill conditionally replaces the native implementation |
| [Node Contains Polyfill](https://polyfill.io) | wp-polyfill-node-contains | Polyfill for Node.contains |
| [Node Contains Polyfill](https://www.npmjs.com/package/polyfill-library) | wp-polyfill-node-contains | Polyfill for Node.contains |
| [Element Closest Polyfill](https://www.npmjs.com/package/element-closest) | wp-polyfill-element-closest | Return the closest element matching a selector up the DOM tree |

## Bundling and code sharing
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/interactivity-api/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ The `unique-id` doesn't need to be unique globally. It just needs to be differen
<summary><em>See store used with the directive above</em></summary>

```js
import { store, useState, useEffect } from '@wordpress/interactivity';
import { getElement, store, useState, useEffect } from '@wordpress/interactivity';

// Unlike `data-wp-init` and `data-wp-watch`, you can use any hooks inside
// `data-wp-run` callbacks.
Expand Down Expand Up @@ -1071,7 +1071,7 @@ Those attributes will contain the directives of that element. In the button exam

```js
// store
import { store, getContext } from '@wordpress/interactivity';
import { store, getElement } from '@wordpress/interactivity';

store( "myPlugin", {
actions: {
Expand Down
16 changes: 0 additions & 16 deletions lib/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,3 @@ function gutenberg_register_block_style_variations_from_theme_json_partials( $va
}
}
}

// DO NOT BACKPORT TO CORE.
// To be removed when core has backported this PR.
if ( function_exists( 'wp_resolve_block_style_variations_from_styles_registry' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_styles_registry' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_primary_theme_json' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_primary_theme_json' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_theme_json_partials' ) ) {
remove_filter( 'wp_theme_json_data_theme', 'wp_resolve_block_style_variations_from_theme_json_partials' );
}
if ( function_exists( 'wp_resolve_block_style_variations_from_theme_style_variation' ) ) {
remove_filter( 'wp_theme_json_data_user', 'wp_resolve_block_style_variations_from_theme_style_variation' );
}
// END OF DO NOT BACKPORT TO CORE.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { isBlobURL } from '@wordpress/blob';
/**
* Internal dependencies
*/
import { TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { useToolsPanelDropdownMenuProps } from './utils';
import { setImmutably } from '../../utils/object';
import MediaReplaceFlow from '../media-replace-flow';
import { store as blockEditorStore } from '../../store';
Expand Down Expand Up @@ -600,6 +600,7 @@ function BackgroundToolsPanel( {
children,
headerLabel,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -612,7 +613,7 @@ function BackgroundToolsPanel( {
label={ headerLabel }
resetAll={ resetAll }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { __ } from '@wordpress/i18n';
*/
import BorderRadiusControl from '../border-radius-control';
import { useColorsPerOrigin } from './hooks';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
import { setImmutably } from '../../utils/object';
import { useBorderPanelLabel } from '../../hooks/border';
import { ShadowPopover, useShadowPresets } from './shadow-panel-components';
Expand Down Expand Up @@ -69,6 +69,7 @@ function BorderToolsPanel( {
children,
label,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -79,7 +80,7 @@ function BorderToolsPanel( {
label={ label }
resetAll={ resetAll }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</ToolsPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { __, sprintf } from '@wordpress/i18n';
*/
import ColorGradientControl from '../colors-gradients/control';
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
import { setImmutably } from '../../utils/object';
import { unlock } from '../../lock-unlock';

Expand Down Expand Up @@ -116,6 +116,7 @@ function ColorToolsPanel( {
panelId,
children,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -131,7 +132,7 @@ function ColorToolsPanel( {
className="color-block-support-panel"
__experimentalFirstVisibleItemClass="first"
__experimentalLastVisibleItemClass="last"
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
<div className="color-block-support-panel__inner-wrapper">
{ children }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useCallback, useState, Platform } from '@wordpress/element';
/**
* Internal dependencies
*/
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
import SpacingSizesControl from '../spacing-sizes-control';
import HeightControl from '../height-control';
import ChildLayoutControl from '../child-layout-control';
Expand Down Expand Up @@ -175,6 +175,7 @@ function DimensionsToolsPanel( {
panelId,
children,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -185,7 +186,7 @@ function DimensionsToolsPanel( {
label={ __( 'Dimensions' ) }
resetAll={ resetAll }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</ToolsPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useCallback, useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
import { setImmutably } from '../../utils/object';

const EMPTY_ARRAY = [];
Expand Down Expand Up @@ -72,6 +72,7 @@ function FiltersToolsPanel( {
panelId,
children,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -82,7 +83,7 @@ function FiltersToolsPanel( {
label={ _x( 'Filters', 'Name for applying graphical effects' ) }
resetAll={ resetAll }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</ToolsPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { __, _x } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { useToolsPanelDropdownMenuProps } from './utils';

export function useHasImageSettingsPanel( name, value, inheritedValue ) {
// Note: If lightbox `value` exists, that means it was
Expand All @@ -30,6 +30,7 @@ export default function ImageSettingsPanel( {
inheritedValue,
panelId,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetLightbox = () => {
onChange( undefined );
};
Expand All @@ -52,7 +53,7 @@ export default function ImageSettingsPanel( {
label={ _x( 'Settings', 'Image settings' ) }
resetAll={ resetLightbox }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
// We use the `userSettings` prop instead of `settings`, because `settings`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import TextAlignmentControl from '../text-alignment-control';
import TextTransformControl from '../text-transform-control';
import TextDecorationControl from '../text-decoration-control';
import WritingModeControl from '../writing-mode-control';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
import { setImmutably } from '../../utils/object';

const MIN_TEXT_COLUMNS = 1;
Expand Down Expand Up @@ -135,6 +135,7 @@ function TypographyToolsPanel( {
panelId,
children,
} ) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const resetAll = () => {
const updatedValue = resetAllFilter( value );
onChange( updatedValue );
Expand All @@ -145,7 +146,7 @@ function TypographyToolsPanel( {
label={ __( 'Typography' ) }
resetAll={ resetAll }
panelId={ panelId }
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</ToolsPanel>
Expand Down
23 changes: 17 additions & 6 deletions packages/block-editor/src/components/global-styles/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
*/
import fastDeepEqual from 'fast-deep-equal/es6';

/**
* WordPress dependencies
*/
import { useViewportMatch } from '@wordpress/compose';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -136,12 +141,18 @@ export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
'typography.fontFamily': 'fontFamily',
};

export const TOOLSPANEL_DROPDOWNMENU_PROPS = {
popoverProps: {
placement: 'left-start',
offset: 259, // Inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
},
};
export function useToolsPanelDropdownMenuProps() {
const isMobile = useViewportMatch( 'medium', '<' );
return ! isMobile
? {
popoverProps: {
placement: 'left-start',
// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)
offset: 259,
},
}
: {};
}

function findInPresetsBy(
features,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useCallback } from '@wordpress/element';
*/
import { store as blockEditorStore } from '../../store';
import { cleanEmptyObject } from '../../hooks/utils';
import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../global-styles/utils';
import { useToolsPanelDropdownMenuProps } from '../global-styles/utils';

export default function BlockSupportToolsPanel( { children, group, label } ) {
const { updateBlockAttributes } = useDispatch( blockEditorStore );
Expand All @@ -20,7 +20,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
getSelectedBlockClientId,
hasMultiSelection,
} = useSelect( blockEditorStore );

const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const panelId = getSelectedBlockClientId();
const resetAll = useCallback(
( resetFilters = [] ) => {
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function BlockSupportToolsPanel( { children, group, label } ) {
shouldRenderPlaceholderItems // Required to maintain fills ordering.
__experimentalFirstVisibleItemClass="first"
__experimentalLastVisibleItemClass="last"
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
dropdownMenuProps={ dropdownMenuProps }
>
{ children }
</ToolsPanel>
Expand Down
Loading

0 comments on commit 3cd98a8

Please sign in to comment.