Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-murugan authored Dec 9, 2024
2 parents b81e6ff + 9e03973 commit efe57e5
Show file tree
Hide file tree
Showing 65 changed files with 629 additions and 436 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.appium
Expand All @@ -52,7 +52,7 @@ jobs:
# AVD cache disabled as it caused emulator termination to hang indefinitely.
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
# - name: AVD cache
# uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
# uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
# id: avd-cache
# with:
# path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: ./.github/setup-node

- name: Restore tests setup cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.appium
Expand All @@ -55,15 +55,15 @@ jobs:
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

- name: Restore build cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
packages/react-native-editor/ios/build/WDA
key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ matrix.device }}-${{ hashFiles('ios-checksums.txt') }}

- name: Restore pods cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
packages/react-native-editor/ios/Pods
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT

- name: Cache PHPCS scan cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
Expand Down
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7976.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7976

* https://github.com/WordPress/gutenberg/pull/67716
2 changes: 2 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,8 @@ public function get_settings() {
* - `variables`: only the CSS Custom Properties for presets & custom ones.
* - `styles`: only the styles section in theme.json.
* - `presets`: only the classes for the presets.
* - `base-layout-styles`: only the base layout styles.
* - `custom-css`: only the custom CSS.
* @param array $origins A list of origins to include. By default it includes VALID_ORIGINS.
* @param array $options An array of options for now used for internal purposes only (may change without notice).
* The options currently supported are:
Expand Down
4 changes: 3 additions & 1 deletion lib/global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Returns the stylesheet resulting of merging core, theme, and user data.
*
* @param array $types Types of styles to load. Optional.
* It accepts as values: 'variables', 'presets', 'styles', 'base-layout-styles.
* See {@see 'WP_Theme_JSON::get_stylesheet'} for all valid types.
* If empty, it'll load the following:
* - for themes without theme.json: 'variables', 'presets', 'base-layout-styles'.
* - for themes with theme.json: 'variables', 'presets', 'styles'.
Expand Down Expand Up @@ -142,6 +142,8 @@ function gutenberg_get_global_settings( $path = array(), $context = array() ) {
/**
* Gets the global styles custom css from theme.json.
*
* @deprecated Gutenberg 18.6.0 Use {@see 'gutenberg_get_global_stylesheet'} instead for top-level custom CSS, or {@see 'WP_Theme_JSON_Gutenberg::get_styles_for_block'} for block-level custom CSS.
*
* @return string
*/
function gutenberg_get_global_styles_custom_css() {
Expand Down
10 changes: 4 additions & 6 deletions packages/block-editor/src/components/block-lock/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
>
<fieldset className="block-editor-block-lock-modal__options">
<legend>
{ __(
'Choose specific attributes to restrict or lock all available options.'
) }
{ __( 'Select the features you want to lock' ) }
</legend>
{ /*
* Disable reason: The `list` ARIA role is redundant but
Expand Down Expand Up @@ -137,7 +135,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Restrict editing' ) }
label={ __( 'Lock editing' ) }
checked={ !! lock.edit }
onChange={ ( edit ) =>
setLock( ( prevLock ) => ( {
Expand All @@ -159,7 +157,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Disable movement' ) }
label={ __( 'Lock movement' ) }
checked={ lock.move }
onChange={ ( move ) =>
setLock( ( prevLock ) => ( {
Expand All @@ -178,7 +176,7 @@ export default function BlockLockModal( { clientId, onClose } ) {
<li className="block-editor-block-lock-modal__checklist-item">
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Prevent removal' ) }
label={ __( 'Lock removal' ) }
checked={ lock.remove }
onChange={ ( remove ) =>
setLock( ( prevLock ) => ( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export default [
background: '#000000',
},
},
tagName: 'hr',
},
innerBlocks: [],
originalContent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,11 @@
margin-bottom: 0;
}

.is-marked {
.components-range-control__track {
transition: width ease 0.1s;
@include reduce-motion("transition");
}

.components-range-control__thumb-wrapper {
transition: left ease 0.1s;
@include reduce-motion("transition");
}
}

.spacing-sizes-control__range-control,
.spacing-sizes-control__custom-value-range {
flex: 1;
margin-bottom: 0; // Needed for some instances of the range control, such as the Spacer block.
}

.components-range-control__mark {
transform: translateX(-50%);
height: $grid-unit-05;
width: math.div($grid-unit-05, 2);
background-color: $white;
z-index: 1;
top: -#{$grid-unit-05};
}

.components-range-control__marks {
margin-top: 17px;
}

.components-range-control__thumb-wrapper {
z-index: 3;
}
}

.spacing-sizes-control__header {
Expand Down
7 changes: 3 additions & 4 deletions packages/block-editor/src/components/warning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { Children } from '@wordpress/element';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreVertical } from '@wordpress/icons';
Expand All @@ -20,10 +19,10 @@ function Warning( { className, actions, children, secondaryActions } ) {
{ children }
</p>

{ ( Children.count( actions ) > 0 || secondaryActions ) && (
{ ( actions?.length > 0 || secondaryActions ) && (
<div className="block-editor-warning__actions">
{ Children.count( actions ) > 0 &&
Children.map( actions, ( action, i ) => (
{ actions?.length > 0 &&
actions.map( ( action, i ) => (
<span
key={ i }
className="block-editor-warning__action"
Expand Down
4 changes: 3 additions & 1 deletion packages/block-editor/src/components/warning/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ describe( 'Warning', () => {

it( 'should show primary actions', () => {
render(
<Warning actions={ <button>Click me</button> }>Message</Warning>
<Warning actions={ [ <button key="test">Click me</button> ] }>
Message
</Warning>
);

expect(
Expand Down
64 changes: 48 additions & 16 deletions packages/block-editor/src/hooks/use-zoom-out.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { useEffect, useRef } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -12,32 +12,64 @@ import { unlock } from '../lock-unlock';

/**
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
* Concepts:
* - If we most recently changed the zoom level for them (in or out), we always resetZoomLevel() level when unmounting.
* - If the user most recently changed the zoom level (manually toggling), we do nothing when unmounting.
*
* @param {boolean} zoomOut If we should enter into zoomOut mode or not
* @param {boolean} enabled If we should enter into zoomOut mode or not
*/
export function useZoomOut( zoomOut = true ) {
export function useZoomOut( enabled = true ) {
const { setZoomLevel, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);
const { isZoomOut } = unlock( useSelect( blockEditorStore ) );

/**
* We need access to both the value and the function. The value is to trigger a useEffect hook
* and the function is to check zoom out within another hook without triggering a re-render.
*/
const { isZoomedOut, isZoomOut } = useSelect( ( select ) => {
const { isZoomOut: _isZoomOut } = unlock( select( blockEditorStore ) );
return {
isZoomedOut: _isZoomOut(),
isZoomOut: _isZoomOut,
};
}, [] );

const controlZoomLevelRef = useRef( false );
const isEnabledRef = useRef( enabled );

/**
* This hook tracks if the zoom state was changed manually by the user via clicking
* the zoom out button. We only want this to run when isZoomedOut changes, so we use
* a ref to track the enabled state.
*/
useEffect( () => {
const isZoomOutOnMount = isZoomOut();
// If the zoom state changed (isZoomOut) and it does not match the requested zoom
// state (zoomOut), then it means the user manually changed the zoom state while
// this hook was mounted, and we should no longer control the zoom state.
if ( isZoomedOut !== isEnabledRef.current ) {
controlZoomLevelRef.current = false;
}
}, [ isZoomedOut ] );

return () => {
if ( isZoomOutOnMount ) {
useEffect( () => {
isEnabledRef.current = enabled;

if ( enabled !== isZoomOut() ) {
controlZoomLevelRef.current = true;

if ( enabled ) {
setZoomLevel( 'auto-scaled' );
} else {
resetZoomLevel();
}
};
}, [] );

useEffect( () => {
if ( zoomOut ) {
setZoomLevel( 'auto-scaled' );
} else {
resetZoomLevel();
}
}, [ zoomOut, setZoomLevel, resetZoomLevel ] );

return () => {
// If we are controlling zoom level and are zoomed out, reset the zoom level.
if ( controlZoomLevelRef.current && isZoomOut() ) {
resetZoomLevel();
}
};
}, [ enabled, isZoomOut, resetZoomLevel, setZoomLevel ] );
}
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- `GradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))
- `CustomGradientPicker`: Add `enableAlpha` prop ([#66974](https://github.com/WordPress/gutenberg/pull/66974))
- `RangeControl`: Update the design of the range control marks ([#67611](https://github.com/WordPress/gutenberg/pull/67611))

### Deprecations

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/date-time/stories/date-time.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const Template: StoryFn< typeof DateTimePicker > = ( {
};

export const Default: StoryFn< typeof DateTimePicker > = Template.bind( {} );
Default.args = {
currentDate: new Date(),
};

export const WithEvents: StoryFn< typeof DateTimePicker > = Template.bind( {} );
WithEvents.args = {
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/date-time/stories/date.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const Template: StoryFn< typeof DatePicker > = ( {
};

export const Default: StoryFn< typeof DatePicker > = Template.bind( {} );
Default.args = {
currentDate: new Date(),
};

export const WithEvents: StoryFn< typeof DatePicker > = Template.bind( {} );
WithEvents.args = {
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/date-time/stories/time.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const Template: StoryFn< typeof TimePicker > = ( {
};

export const Default: StoryFn< typeof TimePicker > = Template.bind( {} );
Default.args = {
currentTime: new Date(),
};

const TimeInputTemplate: StoryFn< typeof TimePicker.TimeInput > = ( args ) => {
return <TimePicker.TimeInput { ...args } />;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/disabled/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Default.args = {
export const ContentEditable: StoryFn< typeof Disabled > = ( args ) => {
return (
<Disabled { ...args }>
<div contentEditable tabIndex={ 0 }>
<div contentEditable tabIndex={ 0 } suppressContentEditableWarning>
contentEditable
</div>
</Disabled>
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/popover/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ const meta: Meta< typeof Popover > = {
export default meta;

const PopoverWithAnchor = ( args: PopoverProps ) => {
const anchorRef = useRef( null );
const [ popoverAnchor, setPopoverAnchor ] = useState< Element | null >(
null
);

return (
<div
Expand All @@ -71,11 +73,11 @@ const PopoverWithAnchor = ( args: PopoverProps ) => {
>
<p
style={ { padding: '8px', background: 'salmon' } }
ref={ anchorRef }
ref={ setPopoverAnchor }
>
Popover&apos;s anchor
</p>
<Popover { ...args } anchorRef={ anchorRef } />
<Popover { ...args } anchor={ popoverAnchor } />
</div>
);
};
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/range-control/mark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default function RangeMark(
{ ...otherProps }
aria-hidden="true"
className={ classes }
isFilled={ isFilled }
style={ style }
/>
{ label && (
Expand Down
Loading

0 comments on commit efe57e5

Please sign in to comment.