@wordpress/e2e-tests 9.13.1 → 9.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/package.json +4 -4
- package/plugins/format-api/index.js +30 -0
- package/plugins/observe-typing/index.js +0 -1
- package/plugins/react-18-compat-block/block.json +14 -0
- package/plugins/react-18-compat-block/editor.js +124 -0
- package/plugins/react-18-compat-block.php +27 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/e2e-tests",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"description": "Test plugins and mu-plugins for E2E tests in WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"npm": ">=8.19.2"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@wordpress/interactivity": "^6.
|
|
28
|
-
"@wordpress/interactivity-router": "^2.
|
|
27
|
+
"@wordpress/interactivity": "^6.49.0",
|
|
28
|
+
"@wordpress/interactivity-router": "^2.49.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"jest": ">=29",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "0e7112a4f4fde4ea15bd9060489b8f6fe11eb6ca"
|
|
40
40
|
}
|
|
@@ -27,4 +27,34 @@
|
|
|
27
27
|
);
|
|
28
28
|
},
|
|
29
29
|
} );
|
|
30
|
+
|
|
31
|
+
// Format with an unregistered attribute (`data-test` is not listed in
|
|
32
|
+
// `attributes`), used to test that manually applied formats merge with
|
|
33
|
+
// their parsed counterparts when typing within them.
|
|
34
|
+
wp.richText.registerFormatType( 'my-plugin/testing', {
|
|
35
|
+
title: 'Testing',
|
|
36
|
+
tagName: 'span',
|
|
37
|
+
className: 'testing',
|
|
38
|
+
edit( props ) {
|
|
39
|
+
return wp.element.createElement(
|
|
40
|
+
wp.blockEditor.RichTextToolbarButton,
|
|
41
|
+
{
|
|
42
|
+
icon: 'editor-code',
|
|
43
|
+
title: 'Testing',
|
|
44
|
+
onClick() {
|
|
45
|
+
props.onChange(
|
|
46
|
+
wp.richText.toggleFormat( props.value, {
|
|
47
|
+
type: 'my-plugin/testing',
|
|
48
|
+
attributes: {
|
|
49
|
+
'data-test': 'hello',
|
|
50
|
+
},
|
|
51
|
+
} )
|
|
52
|
+
);
|
|
53
|
+
props.onFocus();
|
|
54
|
+
},
|
|
55
|
+
isActive: props.isActive,
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
} );
|
|
30
60
|
} )();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/react-18-compat-block",
|
|
5
|
+
"title": "React 18 Compat Block",
|
|
6
|
+
"category": "text",
|
|
7
|
+
"icon": "smiley",
|
|
8
|
+
"description": "",
|
|
9
|
+
"supports": {
|
|
10
|
+
"html": false
|
|
11
|
+
},
|
|
12
|
+
"textdomain": "react-18-compat-block",
|
|
13
|
+
"editorScript": "react-18-compat-block-editor"
|
|
14
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
( function () {
|
|
2
|
+
const { registerBlockType } = wp.blocks;
|
|
3
|
+
const { useBlockProps } = wp.blockEditor;
|
|
4
|
+
|
|
5
|
+
// The externalized React JSX runtime (the `react-jsx-runtime` script
|
|
6
|
+
// handle). When the React 19 experiment is enabled this is React 19's
|
|
7
|
+
// runtime, which tags elements with `Symbol.for( 'react.transitional.element' )`
|
|
8
|
+
// and no longer resolves `defaultProps` for function components.
|
|
9
|
+
const { jsx } = window.ReactJSXRuntime;
|
|
10
|
+
|
|
11
|
+
// --- Bundled React 18 development JSX runtime ----------------------------
|
|
12
|
+
//
|
|
13
|
+
// A faithful, self-contained reimplementation of `jsxDEV` from React 18's
|
|
14
|
+
// `react/cjs/react-jsx-dev-runtime.development.js`. A real-world plugin
|
|
15
|
+
// would get this by bundling `react/jsx-dev-runtime` instead of using the
|
|
16
|
+
// externalized WordPress handle.
|
|
17
|
+
//
|
|
18
|
+
// It reads `ReactCurrentOwner` and `ReactCurrentDispatcher` from React's
|
|
19
|
+
// shared internals (removed in React 19, polyfilled by `tools/react-19`)
|
|
20
|
+
// and produces "legacy" elements tagged with `Symbol.for( 'react.element' )`.
|
|
21
|
+
const REACT_ELEMENT_TYPE = Symbol.for( 'react.element' );
|
|
22
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
23
|
+
const RESERVED_PROPS = {
|
|
24
|
+
key: true,
|
|
25
|
+
ref: true,
|
|
26
|
+
__self: true,
|
|
27
|
+
__source: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function jsxDEV( type, config, maybeKey ) {
|
|
31
|
+
const internals =
|
|
32
|
+
window.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
33
|
+
const { ReactCurrentOwner, ReactCurrentDispatcher } = internals;
|
|
34
|
+
|
|
35
|
+
// The real development runtime consults the current dispatcher; touch
|
|
36
|
+
// it so that a missing polyfill fails loudly here as well.
|
|
37
|
+
void ReactCurrentDispatcher.current;
|
|
38
|
+
|
|
39
|
+
let propName;
|
|
40
|
+
const props = {};
|
|
41
|
+
let key = null;
|
|
42
|
+
const ref = config.ref !== undefined ? config.ref : null;
|
|
43
|
+
|
|
44
|
+
if ( maybeKey !== undefined ) {
|
|
45
|
+
key = '' + maybeKey;
|
|
46
|
+
}
|
|
47
|
+
if ( config.key !== undefined ) {
|
|
48
|
+
key = '' + config.key;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for ( propName in config ) {
|
|
52
|
+
if (
|
|
53
|
+
hasOwnProperty.call( config, propName ) &&
|
|
54
|
+
! hasOwnProperty.call( RESERVED_PROPS, propName )
|
|
55
|
+
) {
|
|
56
|
+
props[ propName ] = config[ propName ];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// React 18's runtime resolves `defaultProps`.
|
|
61
|
+
if ( type && type.defaultProps ) {
|
|
62
|
+
const defaultProps = type.defaultProps;
|
|
63
|
+
for ( propName in defaultProps ) {
|
|
64
|
+
if ( props[ propName ] === undefined ) {
|
|
65
|
+
props[ propName ] = defaultProps[ propName ];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
72
|
+
type,
|
|
73
|
+
key,
|
|
74
|
+
ref,
|
|
75
|
+
props,
|
|
76
|
+
_owner: ReactCurrentOwner.current,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// A function component that relies on `defaultProps`. Rendered through the
|
|
81
|
+
// externalized React runtime.
|
|
82
|
+
function Greeting( props ) {
|
|
83
|
+
return jsx( 'span', {
|
|
84
|
+
className: 'react-18-compat-block__greeting',
|
|
85
|
+
children: props.label,
|
|
86
|
+
} );
|
|
87
|
+
}
|
|
88
|
+
Greeting.defaultProps = {
|
|
89
|
+
label: 'Hello from defaultProps',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
registerBlockType( 'test/react-18-compat-block', {
|
|
93
|
+
apiVersion: 3,
|
|
94
|
+
edit: function Edit() {
|
|
95
|
+
const blockProps = useBlockProps( {
|
|
96
|
+
className: 'react-18-compat-block',
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
return jsx( 'div', {
|
|
100
|
+
...blockProps,
|
|
101
|
+
children: [
|
|
102
|
+
// An element that relies on the `inert` attribute, created with
|
|
103
|
+
// the bundled React 18 runtime (legacy `react.element` symbol).
|
|
104
|
+
jsxDEV(
|
|
105
|
+
'div',
|
|
106
|
+
{
|
|
107
|
+
className: 'react-18-compat-block__inert',
|
|
108
|
+
inert: 'inert',
|
|
109
|
+
children:
|
|
110
|
+
'This subtree is inert and built with the React 18 runtime.',
|
|
111
|
+
},
|
|
112
|
+
'inert'
|
|
113
|
+
),
|
|
114
|
+
// The `defaultProps` component, created with the
|
|
115
|
+
// externalized React runtime.
|
|
116
|
+
jsx( Greeting, {}, 'greeting' ),
|
|
117
|
+
],
|
|
118
|
+
} );
|
|
119
|
+
},
|
|
120
|
+
save: function Save() {
|
|
121
|
+
return null;
|
|
122
|
+
},
|
|
123
|
+
} );
|
|
124
|
+
} )();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: Gutenberg Test React 18 Compat Block
|
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
|
5
|
+
* Author: Gutenberg Team
|
|
6
|
+
*
|
|
7
|
+
* @package gutenberg-test-react-18-compat-block
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
add_action(
|
|
11
|
+
'init',
|
|
12
|
+
static function () {
|
|
13
|
+
wp_register_script(
|
|
14
|
+
'react-18-compat-block-editor',
|
|
15
|
+
plugin_dir_url( __FILE__ ) . 'react-18-compat-block/editor.js',
|
|
16
|
+
array(
|
|
17
|
+
'wp-blocks',
|
|
18
|
+
'wp-block-editor',
|
|
19
|
+
'wp-element',
|
|
20
|
+
'react',
|
|
21
|
+
'react-jsx-runtime',
|
|
22
|
+
),
|
|
23
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'react-18-compat-block/editor.js' )
|
|
24
|
+
);
|
|
25
|
+
register_block_type_from_metadata( __DIR__ . '/react-18-compat-block' );
|
|
26
|
+
}
|
|
27
|
+
);
|