Skip to content

Commit f021d44

Browse files
committed
prep build 009/03
2 parents 6c67b8b + 9d4f918 commit f021d44

File tree

63 files changed

+1625
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1625
-791
lines changed
File renamed without changes.

docs/reference-guides/interactivity-api/api-reference.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ It provides a **local** state available to a specific HTML node and its children
8484
The `wp-context` directive accepts a stringified JSON as a value.
8585

8686
```php
87-
//render.php
87+
// render.php
8888
<div data-wp-context='{ "post": { "id": <?php echo $post->ID; ?> } }' >
8989
<button data-wp-on--click="actions.logId" >
9090
Click Me!
@@ -110,13 +110,13 @@ store( "myPlugin", {
110110
Different contexts can be defined at different levels, and deeper levels will merge their own context with any parent one:
111111

112112
```html
113-
<div data-wp-context="{ foo: 'bar' }">
113+
<div data-wp-context='{ "foo": "bar" }'>
114114
<span data-wp-text="context.foo"><!-- Will output: "bar" --></span>
115115

116-
<div data-wp-context="{ bar: 'baz' }">
116+
<div data-wp-context='{ "bar": "baz" }'>
117117
<span data-wp-text="context.foo"><!-- Will output: "bar" --></span>
118118

119-
<div data-wp-context="{ foo: 'bob' }">
119+
<div data-wp-context='{ "foo": "bob" }'>
120120
<span data-wp-text="context.foo"><!-- Will output: "bob" --></span>
121121
</div>
122122

@@ -356,8 +356,7 @@ The callback passed as the reference receives [the event](https://developer.mozi
356356

357357
### `wp-on-async`
358358

359-
This directive is a more performant approach for `wp-on`. It immediately yields to main to avoid contributing to a long task, allowing other interactions that otherwise would be waiting on the main thread
360-
to run sooner. Use this async version whenever there is no need for synchronous access to the `event` object, in particular the methods `event.preventDefault()`, `event.stopPropagation()`, and `event.stopImmediatePropagation()`.
359+
This directive is a more performant approach for `wp-on`. It immediately yields to main to avoid contributing to a long task, allowing other interactions that otherwise would be waiting on the main thread to run sooner. Use this async version whenever there is no need for synchronous access to the `event` object, in particular the methods `event.preventDefault()`, `event.stopPropagation()`, and `event.stopImmediatePropagation()`.
361360

362361
### `wp-on-window`
363362

@@ -369,8 +368,7 @@ This directive allows you to attach global window events like `resize`, `copy`,
369368

370369
[List of supported window events.](https://developer.mozilla.org/en-US/docs/Web/API/Window#events)
371370

372-
The syntax of this directive is `data-wp-on-window--[window-event]` (like `data-wp-on-window--resize`
373-
or `data-wp-on-window--languagechange`).
371+
The syntax of this directive is `data-wp-on-window--[window-event]` (like `data-wp-on-window--resize` or `data-wp-on-window--languagechange`).
374372

375373
```php
376374
<div data-wp-on-window--resize="callbacks.logWidth"></div>
@@ -406,8 +404,7 @@ This directive allows you to attach global document events like `scroll`, `mouse
406404

407405
[List of supported document events.](https://developer.mozilla.org/en-US/docs/Web/API/Document#events)
408406

409-
The syntax of this directive is `data-wp-on-document--[document-event]` (like `data-wp-on-document--keydown`
410-
or `data-wp-on-document--selectionchange`).
407+
The syntax of this directive is `data-wp-on-document--[document-event]` (like `data-wp-on-document--keydown` or `data-wp-on-document--selectionchange`).
411408

412409
```php
413410
<div data-wp-on-document--keydown="callbacks.logKeydown"></div>
@@ -520,6 +517,8 @@ Here's another example with several `wp-init` directives on the same DOM element
520517
<summary><em>See store used with the directive above</em></summary>
521518

522519
```js
520+
import { store, getElement } from '@wordpress/interactivity';
521+
523522
store( "myPlugin", {
524523
callbacks: {
525524
logTimeInit: () => console.log( `Init at ` + new Date() ),
@@ -882,10 +881,10 @@ const { state } = store( "myPlugin", {
882881
GBP: 0.85,
883882
},
884883
get amountInUSD() {
885-
return state.currencyExchange[ 'USD' ] * state.amount,
884+
return state.currencyExchange[ 'USD' ] * state.amount;
886885
},
887886
get amountInGBP() {
888-
return state.currencyExchange[ 'GBP' ] * state.amount,
887+
return state.currencyExchange[ 'GBP' ] * state.amount;
889888
},
890889
},
891890
} );
@@ -965,7 +964,7 @@ This approach enables some functionalities that make directives flexible and pow
965964

966965
*In the `view.js` file of each block* the developer can define both the state and the elements of the store referencing functions like actions, side effects or derived state.
967966

968-
The `store` method used to set the store in javascript can be imported from `@wordpress/interactivity`.
967+
The `store` method used to set the store in JavaScript can be imported from `@wordpress/interactivity`.
969968

970969
```js
971970
// store
@@ -1111,7 +1110,7 @@ store( "myPlugin", {
11111110
actions: {
11121111
log: () => {
11131112
const element = getElement();
1114-
// Logs "false"
1113+
// Logs attributes
11151114
console.log('element attributes => ', element.attributes)
11161115
},
11171116
},
@@ -1122,7 +1121,7 @@ The code will log:
11221121

11231122
```json
11241123
{
1125-
"data-wp-on--click": 'actions.increaseCounter',
1124+
"data-wp-on--click": 'actions.log',
11261125
"children": ['Log'],
11271126
"onclick": event => { evaluate(entry, event); }
11281127
}
@@ -1147,6 +1146,7 @@ store('mySliderPlugin', {
11471146
3_000
11481147
);
11491148
},
1149+
},
11501150
})
11511151
```
11521152

@@ -1245,7 +1245,7 @@ echo $processed_html;
12451245

12461246
will output:
12471247
```html
1248-
<div data-wp-text="create-block::state.greeting">Hello, World!</div>
1248+
<div data-wp-text="myPlugin::state.greeting">Hello, World!</div>
12491249
```
12501250

12511251
### wp_interactivity_data_wp_context

lib/compat/wordpress-6.6/html-api/class-gutenberg-html-decoder-6-6.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ public static function decode( $context, $text ) {
196196
*
197197
* @since 6.6.0
198198
*
199+
* @global WP_Token_Map $html5_named_character_references
200+
*
199201
* @param string $context `attribute` for decoding attribute values, `data` otherwise.
200202
* @param string $text Text document containing span of text to decode.
201203
* @param int $at Optional. Byte offset into text where span begins, defaults to the beginning (0).

lib/compat/wordpress-6.7/html-api/class-gutenberg-html-decoder-6-7.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ public static function decode( $context, $text ): string {
196196
*
197197
* @since 6.6.0
198198
*
199+
* @global WP_Token_Map $html5_named_character_references
200+
*
199201
* @param string $context `attribute` for decoding attribute values, `data` otherwise.
200202
* @param string $text Text document containing span of text to decode.
201203
* @param int $at Optional. Byte offset into text where span begins, defaults to the beginning (0).

packages/block-editor/src/components/block-list/block-invalid-warning.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ export default function BlockInvalidWarning( { clientId } ) {
107107
onClick={ convert.toRecoveredBlock }
108108
variant="primary"
109109
>
110-
{ __( 'Attempt Block Recovery' ) }
110+
{ __( 'Attempt recovery' ) }
111111
</Button>,
112112
] }
113113
secondaryActions={ secondaryActions }
114114
>
115-
{ __( 'This block contains unexpected or invalid content.' ) }
115+
{ __( 'Block contains unexpected or invalid content.' ) }
116116
</Warning>
117117
{ compare && (
118118
<Modal

packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { __ } from '@wordpress/i18n';
4+
import { __, isRTL } from '@wordpress/i18n';
55
import { Button } from '@wordpress/components';
66
import {
77
chevronRight,
@@ -38,7 +38,7 @@ const CarouselNavigation = ( {
3838
<Button
3939
// TODO: Switch to `true` (40px size) if possible
4040
__next40pxDefaultSize={ false }
41-
icon={ chevronLeft }
41+
icon={ isRTL() ? chevronRight : chevronLeft }
4242
label={ __( 'Previous pattern' ) }
4343
onClick={ handlePrevious }
4444
disabled={ activeSlide === 0 }
@@ -47,7 +47,7 @@ const CarouselNavigation = ( {
4747
<Button
4848
// TODO: Switch to `true` (40px size) if possible
4949
__next40pxDefaultSize={ false }
50-
icon={ chevronRight }
50+
icon={ isRTL() ? chevronLeft : chevronRight }
5151
label={ __( 'Next pattern' ) }
5252
onClick={ handleNext }
5353
disabled={ activeSlide === totalSlides - 1 }

packages/block-editor/src/components/block-patterns-list/index.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ import InserterDraggableBlocks from '../inserter-draggable-blocks';
2727
import BlockPatternsPaging from '../block-patterns-paging';
2828
import { INSERTER_PATTERN_TYPES } from '../inserter/block-patterns-tab/utils';
2929

30-
const {
31-
CompositeV2: Composite,
32-
CompositeItemV2: CompositeItem,
33-
useCompositeStoreV2: useCompositeStore,
34-
} = unlock( componentsPrivateApis );
30+
const { CompositeV2: Composite, CompositeItemV2: CompositeItem } = unlock(
31+
componentsPrivateApis
32+
);
3533

3634
const WithToolTip = ( { showTooltip, title, children } ) => {
3735
if ( showTooltip ) {
@@ -206,19 +204,23 @@ function BlockPatternsList(
206204
},
207205
ref
208206
) {
209-
const compositeStore = useCompositeStore( { orientation } );
210-
const { setActiveId } = compositeStore;
207+
const [ activeCompositeId, setActiveCompositeId ] = useState( undefined );
211208

212209
useEffect( () => {
213-
// We reset the active composite item whenever the
214-
// available patterns change, to make sure that
215-
// focus is put back to the start.
216-
setActiveId( undefined );
217-
}, [ setActiveId, shownPatterns, blockPatterns ] );
210+
// Reset the active composite item whenever the available patterns change,
211+
// to make sure that Composite widget can receive focus correctly when its
212+
// composite items change. The first composite item will receive focus.
213+
const firstCompositeItemId = blockPatterns.find( ( pattern ) =>
214+
shownPatterns.includes( pattern )
215+
)?.name;
216+
setActiveCompositeId( firstCompositeItemId );
217+
}, [ shownPatterns, blockPatterns ] );
218218

219219
return (
220220
<Composite
221-
store={ compositeStore }
221+
orientation={ orientation }
222+
activeId={ activeCompositeId }
223+
setActiveId={ setActiveCompositeId }
222224
role="listbox"
223225
className="block-editor-block-patterns-list"
224226
aria-label={ label }

packages/block-editor/src/components/block-toolbar/index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { useShowHoveredOrFocusedGestures } from './utils';
3434
import { store as blockEditorStore } from '../../store';
3535
import __unstableBlockNameContext from './block-name-context';
3636
import NavigableToolbar from '../navigable-toolbar';
37-
import Shuffle from './shuffle';
3837
import { useHasBlockToolbar } from './use-has-block-toolbar';
3938

4039
/**
@@ -66,22 +65,18 @@ export function PrivateBlockToolbar( {
6665
shouldShowVisualToolbar,
6766
showParentSelector,
6867
isUsingBindings,
69-
canRemove,
7068
} = useSelect( ( select ) => {
7169
const {
7270
getBlockName,
7371
getBlockMode,
7472
getBlockParents,
7573
getSelectedBlockClientIds,
7674
isBlockValid,
77-
getBlockRootClientId,
7875
getBlockEditingMode,
7976
getBlockAttributes,
80-
canRemoveBlock,
8177
} = select( blockEditorStore );
8278
const selectedBlockClientIds = getSelectedBlockClientIds();
8379
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
84-
const blockRootClientId = getBlockRootClientId( selectedBlockClientId );
8580
const parents = getBlockParents( selectedBlockClientId );
8681
const firstParentClientId = parents[ parents.length - 1 ];
8782
const parentBlockName = getBlockName( firstParentClientId );
@@ -106,7 +101,6 @@ export function PrivateBlockToolbar( {
106101
isDefaultEditingMode: _isDefaultEditingMode,
107102
blockType: selectedBlockClientId && getBlockType( _blockName ),
108103
shouldShowVisualToolbar: isValid && isVisual,
109-
rootClientId: blockRootClientId,
110104
toolbarKey: `${ selectedBlockClientId }${ firstParentClientId }`,
111105
showParentSelector:
112106
parentBlockType &&
@@ -119,7 +113,6 @@ export function PrivateBlockToolbar( {
119113
selectedBlockClientIds.length === 1 &&
120114
_isDefaultEditingMode,
121115
isUsingBindings: _isUsingBindings,
122-
canRemove: canRemoveBlock( selectedBlockClientId ),
123116
};
124117
}, [] );
125118

@@ -202,9 +195,6 @@ export function PrivateBlockToolbar( {
202195
</ToolbarGroup>
203196
</div>
204197
) }
205-
{ ! isMultiToolbar && canRemove && (
206-
<Shuffle clientId={ blockClientId } />
207-
) }
208198
{ shouldShowVisualToolbar && isMultiToolbar && (
209199
<BlockGroupToolbar />
210200
) }

packages/block-editor/src/components/color-palette/test/control.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* External dependencies
33
*/
4-
import { render } from '@testing-library/react';
4+
import { render, waitFor, queryByAttribute } from '@testing-library/react';
55

66
/**
77
* Internal dependencies
@@ -10,9 +10,22 @@ import ColorPaletteControl from '../control';
1010

1111
const noop = () => {};
1212

13+
async function renderAndValidate( ...renderArgs ) {
14+
const view = render( ...renderArgs );
15+
await waitFor( () => {
16+
const activeButton = queryByAttribute(
17+
'data-active-item',
18+
view.baseElement,
19+
'true'
20+
);
21+
expect( activeButton ).not.toBeNull();
22+
} );
23+
return view;
24+
}
25+
1326
describe( 'ColorPaletteControl', () => {
1427
it( 'matches the snapshot', async () => {
15-
const { container } = render(
28+
const { container } = await renderAndValidate(
1629
<ColorPaletteControl
1730
label="Test Color"
1831
value="#f00"

0 commit comments

Comments
 (0)