@wordpress/e2e-tests 9.3.0 → 9.4.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/align-hook/index.js +14 -11
- package/plugins/block-context/index.js +21 -12
- package/plugins/block-icons/index.js +86 -91
- package/plugins/child-blocks/index.js +17 -13
- package/plugins/container-without-paragraph/index.js +8 -2
- package/plugins/iframed-block/editor.js +1 -0
- package/plugins/inner-blocks-locking-all-embed/index.js +6 -3
- package/plugins/inner-blocks-prioritized-inserter-blocks/index.js +38 -35
- package/plugins/inner-blocks-render-appender/index.js +21 -22
- package/plugins/interactive-blocks/hydration-timing/block.json +15 -0
- package/plugins/interactive-blocks/hydration-timing/render.php +31 -0
- package/plugins/interactive-blocks/hydration-timing/view.asset.php +1 -0
- package/plugins/interactive-blocks/hydration-timing/view.js +23 -0
- package/plugins/interactive-blocks/hydration-timing-async/block.json +15 -0
- package/plugins/interactive-blocks/hydration-timing-async/render.php +36 -0
- package/plugins/interactive-blocks/hydration-timing-async/view.asset.php +8 -0
- package/plugins/interactive-blocks/hydration-timing-async/view.js +29 -0
- package/plugins/interactive-blocks/hydration-timing-slow/block.json +15 -0
- package/plugins/interactive-blocks/hydration-timing-slow/render.php +36 -0
- package/plugins/interactive-blocks/hydration-timing-slow/view.asset.php +1 -0
- package/plugins/interactive-blocks/hydration-timing-slow/view.js +22 -0
- package/plugins/interactive-blocks/router-regions/render.php +7 -0
- package/plugins/interactive-blocks/router-regions/view.js +3 -0
- package/plugins/meta-attribute-block/early.js +5 -2
- package/plugins/meta-attribute-block/late.js +5 -2
- package/plugins/meta-attribute-block.php +2 -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.4.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.39.0",
|
|
28
|
+
"@wordpress/interactivity-router": "^2.39.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": "eee1cfb1472f11183e40fb77465a5f13145df7ad"
|
|
40
40
|
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const registerBlockType = wp.blocks.registerBlockType;
|
|
3
3
|
const el = wp.element.createElement;
|
|
4
|
+
const { useBlockProps } = wp.blockEditor;
|
|
4
5
|
|
|
5
6
|
const baseBlock = {
|
|
6
7
|
icon: 'cart',
|
|
7
8
|
category: 'text',
|
|
8
|
-
edit() {
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
9
|
+
edit: function Edit() {
|
|
10
|
+
const blockProps = useBlockProps( {
|
|
11
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
12
|
+
} );
|
|
13
|
+
return el( 'div', blockProps, 'Test Align Hook' );
|
|
14
14
|
},
|
|
15
15
|
save() {
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
16
|
+
const blockProps = useBlockProps.save( {
|
|
17
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
18
|
+
} );
|
|
19
|
+
return el( 'div', blockProps, 'Test Align Hook' );
|
|
21
20
|
},
|
|
22
21
|
};
|
|
23
22
|
|
|
@@ -25,6 +24,7 @@
|
|
|
25
24
|
'test/test-no-alignment-set',
|
|
26
25
|
Object.assign(
|
|
27
26
|
{
|
|
27
|
+
apiVersion: 3,
|
|
28
28
|
title: 'Test No Alignment Set',
|
|
29
29
|
},
|
|
30
30
|
baseBlock
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
'test/test-align-true',
|
|
36
36
|
Object.assign(
|
|
37
37
|
{
|
|
38
|
+
apiVersion: 3,
|
|
38
39
|
title: 'Test Align True',
|
|
39
40
|
supports: {
|
|
40
41
|
align: true,
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
'test/test-align-array',
|
|
49
50
|
Object.assign(
|
|
50
51
|
{
|
|
52
|
+
apiVersion: 3,
|
|
51
53
|
title: 'Test Align Array',
|
|
52
54
|
supports: {
|
|
53
55
|
align: [ 'left', 'center' ],
|
|
@@ -61,6 +63,7 @@
|
|
|
61
63
|
'test/test-default-align',
|
|
62
64
|
Object.assign(
|
|
63
65
|
{
|
|
66
|
+
apiVersion: 3,
|
|
64
67
|
title: 'Test Default Align',
|
|
65
68
|
attributes: {
|
|
66
69
|
align: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
( function () {
|
|
2
|
-
const { createElement: el
|
|
2
|
+
const { createElement: el } = wp.element;
|
|
3
3
|
const { registerBlockType } = wp.blocks;
|
|
4
|
-
const { InnerBlocks } = wp.blockEditor;
|
|
4
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
5
5
|
|
|
6
6
|
registerBlockType( 'gutenberg/test-context-provider', {
|
|
7
|
+
apiVersion: 3,
|
|
7
8
|
title: 'Test Context Provider',
|
|
8
9
|
|
|
9
10
|
icon: 'list-view',
|
|
@@ -17,10 +18,16 @@
|
|
|
17
18
|
|
|
18
19
|
category: 'text',
|
|
19
20
|
|
|
20
|
-
edit( { attributes, setAttributes } ) {
|
|
21
|
+
edit: function Edit( { attributes, setAttributes } ) {
|
|
22
|
+
const blockProps = useBlockProps();
|
|
23
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
24
|
+
template: [ [ 'gutenberg/test-context-consumer', {} ] ],
|
|
25
|
+
templateLock: 'all',
|
|
26
|
+
templateInsertUpdatesSelection: true,
|
|
27
|
+
} );
|
|
21
28
|
return el(
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
'div',
|
|
30
|
+
innerBlocksProps,
|
|
24
31
|
el( 'input', {
|
|
25
32
|
value: attributes.recordId,
|
|
26
33
|
onChange( event ) {
|
|
@@ -29,11 +36,7 @@
|
|
|
29
36
|
} );
|
|
30
37
|
},
|
|
31
38
|
} ),
|
|
32
|
-
|
|
33
|
-
template: [ [ 'gutenberg/test-context-consumer', {} ] ],
|
|
34
|
-
templateLock: 'all',
|
|
35
|
-
templateInsertUpdatesSelection: true,
|
|
36
|
-
} )
|
|
39
|
+
innerBlocksProps.children
|
|
37
40
|
);
|
|
38
41
|
},
|
|
39
42
|
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
} );
|
|
44
47
|
|
|
45
48
|
registerBlockType( 'gutenberg/test-context-consumer', {
|
|
49
|
+
apiVersion: 3,
|
|
46
50
|
title: 'Test Context Consumer',
|
|
47
51
|
|
|
48
52
|
icon: 'list-view',
|
|
@@ -54,8 +58,13 @@
|
|
|
54
58
|
|
|
55
59
|
category: 'text',
|
|
56
60
|
|
|
57
|
-
edit( { context } ) {
|
|
58
|
-
|
|
61
|
+
edit: function Edit( { context } ) {
|
|
62
|
+
const blockProps = useBlockProps();
|
|
63
|
+
return el(
|
|
64
|
+
'div',
|
|
65
|
+
blockProps,
|
|
66
|
+
'The record ID is: ' + context[ 'gutenberg/recordId' ]
|
|
67
|
+
);
|
|
59
68
|
},
|
|
60
69
|
|
|
61
70
|
save() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const registerBlockType = wp.blocks.registerBlockType;
|
|
3
3
|
const el = wp.element.createElement;
|
|
4
|
-
const InnerBlocks = wp.blockEditor
|
|
4
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
5
5
|
const circle = el( 'circle', {
|
|
6
6
|
cx: 10,
|
|
7
7
|
cy: 10,
|
|
@@ -17,29 +17,28 @@
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
registerBlockType( 'test/test-single-svg-icon', {
|
|
20
|
+
apiVersion: 3,
|
|
20
21
|
title: 'TestSimpleSvgIcon',
|
|
21
22
|
icon: svg,
|
|
22
23
|
category: 'text',
|
|
23
24
|
|
|
24
|
-
edit() {
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
37
|
-
content: 'TestSimpleSvgIcon',
|
|
38
|
-
},
|
|
39
|
-
],
|
|
25
|
+
edit: function Edit() {
|
|
26
|
+
const blockProps = useBlockProps( {
|
|
27
|
+
className: 'test-single-svg-icon',
|
|
28
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
29
|
+
} );
|
|
30
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
31
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
32
|
+
template: [
|
|
33
|
+
[
|
|
34
|
+
'core/paragraph',
|
|
35
|
+
{
|
|
36
|
+
content: 'TestSimpleSvgIcon',
|
|
37
|
+
},
|
|
40
38
|
],
|
|
41
|
-
|
|
42
|
-
);
|
|
39
|
+
],
|
|
40
|
+
} );
|
|
41
|
+
return el( 'div', innerBlocksProps );
|
|
43
42
|
},
|
|
44
43
|
|
|
45
44
|
save() {
|
|
@@ -55,29 +54,28 @@
|
|
|
55
54
|
} );
|
|
56
55
|
|
|
57
56
|
registerBlockType( 'test/test-dash-icon', {
|
|
57
|
+
apiVersion: 3,
|
|
58
58
|
title: 'TestSimpleDashIcon',
|
|
59
59
|
icon: 'cart',
|
|
60
60
|
category: 'text',
|
|
61
61
|
|
|
62
|
-
edit() {
|
|
63
|
-
|
|
64
|
-
'
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
'
|
|
74
|
-
|
|
75
|
-
content: 'TestDashIcon',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
62
|
+
edit: function Edit() {
|
|
63
|
+
const blockProps = useBlockProps( {
|
|
64
|
+
className: 'test-dash-icon',
|
|
65
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
66
|
+
} );
|
|
67
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
68
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
69
|
+
template: [
|
|
70
|
+
[
|
|
71
|
+
'core/paragraph',
|
|
72
|
+
{
|
|
73
|
+
content: 'TestDashIcon',
|
|
74
|
+
},
|
|
78
75
|
],
|
|
79
|
-
|
|
80
|
-
);
|
|
76
|
+
],
|
|
77
|
+
} );
|
|
78
|
+
return el( 'div', innerBlocksProps );
|
|
81
79
|
},
|
|
82
80
|
|
|
83
81
|
save() {
|
|
@@ -93,31 +91,30 @@
|
|
|
93
91
|
} );
|
|
94
92
|
|
|
95
93
|
registerBlockType( 'test/test-function-icon', {
|
|
94
|
+
apiVersion: 3,
|
|
96
95
|
title: 'TestFunctionIcon',
|
|
97
96
|
icon() {
|
|
98
97
|
return svg;
|
|
99
98
|
},
|
|
100
99
|
category: 'text',
|
|
101
100
|
|
|
102
|
-
edit() {
|
|
103
|
-
|
|
104
|
-
'
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'
|
|
114
|
-
|
|
115
|
-
content: 'TestFunctionIcon',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
101
|
+
edit: function Edit() {
|
|
102
|
+
const blockProps = useBlockProps( {
|
|
103
|
+
className: 'test-function-icon',
|
|
104
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
105
|
+
} );
|
|
106
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
107
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
108
|
+
template: [
|
|
109
|
+
[
|
|
110
|
+
'core/paragraph',
|
|
111
|
+
{
|
|
112
|
+
content: 'TestFunctionIcon',
|
|
113
|
+
},
|
|
118
114
|
],
|
|
119
|
-
|
|
120
|
-
);
|
|
115
|
+
],
|
|
116
|
+
} );
|
|
117
|
+
return el( 'div', innerBlocksProps );
|
|
121
118
|
},
|
|
122
119
|
|
|
123
120
|
save() {
|
|
@@ -133,6 +130,7 @@
|
|
|
133
130
|
} );
|
|
134
131
|
|
|
135
132
|
registerBlockType( 'test/test-dash-icon-colors', {
|
|
133
|
+
apiVersion: 3,
|
|
136
134
|
title: 'TestDashIconColors',
|
|
137
135
|
icon: {
|
|
138
136
|
background: '#010000',
|
|
@@ -141,25 +139,23 @@
|
|
|
141
139
|
},
|
|
142
140
|
category: 'text',
|
|
143
141
|
|
|
144
|
-
edit() {
|
|
145
|
-
|
|
146
|
-
'
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
'
|
|
156
|
-
|
|
157
|
-
content: 'TestIconColors',
|
|
158
|
-
},
|
|
159
|
-
],
|
|
142
|
+
edit: function Edit() {
|
|
143
|
+
const blockProps = useBlockProps( {
|
|
144
|
+
className: 'test-dash-icon-colors',
|
|
145
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
146
|
+
} );
|
|
147
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
148
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
149
|
+
template: [
|
|
150
|
+
[
|
|
151
|
+
'core/paragraph',
|
|
152
|
+
{
|
|
153
|
+
content: 'TestIconColors',
|
|
154
|
+
},
|
|
160
155
|
],
|
|
161
|
-
|
|
162
|
-
);
|
|
156
|
+
],
|
|
157
|
+
} );
|
|
158
|
+
return el( 'div', innerBlocksProps );
|
|
163
159
|
},
|
|
164
160
|
|
|
165
161
|
save() {
|
|
@@ -175,6 +171,7 @@
|
|
|
175
171
|
} );
|
|
176
172
|
|
|
177
173
|
registerBlockType( 'test/test-svg-icon-background', {
|
|
174
|
+
apiVersion: 3,
|
|
178
175
|
title: 'TestSvgIconBackground',
|
|
179
176
|
icon: {
|
|
180
177
|
background: '#010000',
|
|
@@ -182,25 +179,23 @@
|
|
|
182
179
|
},
|
|
183
180
|
category: 'text',
|
|
184
181
|
|
|
185
|
-
edit() {
|
|
186
|
-
|
|
187
|
-
'
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
'
|
|
197
|
-
|
|
198
|
-
content: 'TestIconColors',
|
|
199
|
-
},
|
|
200
|
-
],
|
|
182
|
+
edit: function Edit() {
|
|
183
|
+
const blockProps = useBlockProps( {
|
|
184
|
+
className: 'test-svg-icon-background',
|
|
185
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
186
|
+
} );
|
|
187
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
188
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
189
|
+
template: [
|
|
190
|
+
[
|
|
191
|
+
'core/paragraph',
|
|
192
|
+
{
|
|
193
|
+
content: 'TestIconColors',
|
|
194
|
+
},
|
|
201
195
|
],
|
|
202
|
-
|
|
203
|
-
);
|
|
196
|
+
],
|
|
197
|
+
} );
|
|
198
|
+
return el( 'div', innerBlocksProps );
|
|
204
199
|
},
|
|
205
200
|
|
|
206
201
|
save() {
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
( function () {
|
|
2
|
-
const { InnerBlocks } = wp.blockEditor;
|
|
2
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
3
3
|
const { createElement: el } = wp.element;
|
|
4
4
|
const { registerBlockType } = wp.blocks;
|
|
5
5
|
|
|
6
6
|
registerBlockType( 'test/child-blocks-unrestricted-parent', {
|
|
7
|
+
apiVersion: 3,
|
|
7
8
|
title: 'Child Blocks Unrestricted Parent',
|
|
8
9
|
icon: 'carrot',
|
|
9
10
|
category: 'text',
|
|
10
11
|
|
|
11
|
-
edit() {
|
|
12
|
-
|
|
12
|
+
edit: function Edit() {
|
|
13
|
+
const blockProps = useBlockProps();
|
|
14
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps );
|
|
15
|
+
return el( 'div', innerBlocksProps );
|
|
13
16
|
},
|
|
14
17
|
|
|
15
18
|
save() {
|
|
@@ -18,18 +21,17 @@
|
|
|
18
21
|
} );
|
|
19
22
|
|
|
20
23
|
registerBlockType( 'test/child-blocks-restricted-parent', {
|
|
24
|
+
apiVersion: 3,
|
|
21
25
|
title: 'Child Blocks Restricted Parent',
|
|
22
26
|
icon: 'carrot',
|
|
23
27
|
category: 'text',
|
|
24
28
|
|
|
25
|
-
edit() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} )
|
|
32
|
-
);
|
|
29
|
+
edit: function Edit() {
|
|
30
|
+
const blockProps = useBlockProps();
|
|
31
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
32
|
+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
|
|
33
|
+
} );
|
|
34
|
+
return el( 'div', innerBlocksProps );
|
|
33
35
|
},
|
|
34
36
|
|
|
35
37
|
save() {
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
} );
|
|
39
41
|
|
|
40
42
|
registerBlockType( 'test/child-blocks-child', {
|
|
43
|
+
apiVersion: 3,
|
|
41
44
|
title: 'Child Blocks Child',
|
|
42
45
|
icon: 'carrot',
|
|
43
46
|
category: 'text',
|
|
@@ -47,8 +50,9 @@
|
|
|
47
50
|
'test/child-blocks-restricted-parent',
|
|
48
51
|
],
|
|
49
52
|
|
|
50
|
-
edit() {
|
|
51
|
-
|
|
53
|
+
edit: function Edit() {
|
|
54
|
+
const blockProps = useBlockProps();
|
|
55
|
+
return el( 'div', blockProps, 'Child' );
|
|
52
56
|
},
|
|
53
57
|
|
|
54
58
|
save() {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
( function () {
|
|
2
|
+
const { useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
3
|
+
const { createElement: el } = wp.element;
|
|
4
|
+
|
|
2
5
|
wp.blocks.registerBlockType( 'test/container-without-paragraph', {
|
|
6
|
+
apiVersion: 3,
|
|
3
7
|
title: 'Container without paragraph',
|
|
4
8
|
category: 'text',
|
|
5
9
|
icon: 'yes',
|
|
6
10
|
|
|
7
|
-
edit() {
|
|
8
|
-
|
|
11
|
+
edit: function Edit() {
|
|
12
|
+
const blockProps = useBlockProps();
|
|
13
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
9
14
|
allowedBlocks: [ 'core/image', 'core/gallery' ],
|
|
10
15
|
} );
|
|
16
|
+
return el( 'div', innerBlocksProps );
|
|
11
17
|
},
|
|
12
18
|
|
|
13
19
|
save() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const registerBlockType = wp.blocks.registerBlockType;
|
|
3
3
|
const el = wp.element.createElement;
|
|
4
|
-
const InnerBlocks = wp.blockEditor
|
|
4
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
5
5
|
const __ = wp.i18n.__;
|
|
6
6
|
const TEMPLATE = [
|
|
7
7
|
[
|
|
@@ -19,15 +19,18 @@
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
registerBlockType( 'test/test-inner-blocks-locking-all-embed', {
|
|
22
|
+
apiVersion: 3,
|
|
22
23
|
title: 'Test Inner Blocks Locking All Embed',
|
|
23
24
|
icon: 'cart',
|
|
24
25
|
category: 'text',
|
|
25
26
|
|
|
26
|
-
edit() {
|
|
27
|
-
|
|
27
|
+
edit: function Edit() {
|
|
28
|
+
const blockProps = useBlockProps();
|
|
29
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
28
30
|
template: TEMPLATE,
|
|
29
31
|
templateLock: 'all',
|
|
30
32
|
} );
|
|
33
|
+
return el( 'div', innerBlocksProps );
|
|
31
34
|
},
|
|
32
35
|
|
|
33
36
|
save,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const { registerBlockType } = wp.blocks;
|
|
3
3
|
const { createElement: el } = wp.element;
|
|
4
|
-
const { InnerBlocks } = wp.blockEditor;
|
|
4
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
5
5
|
|
|
6
6
|
const divProps = {
|
|
7
7
|
className: 'product',
|
|
@@ -16,34 +16,38 @@
|
|
|
16
16
|
return el( 'div', divProps, el( InnerBlocks.Content ) );
|
|
17
17
|
};
|
|
18
18
|
registerBlockType( 'test/prioritized-inserter-blocks-unset', {
|
|
19
|
+
apiVersion: 3,
|
|
19
20
|
title: 'Prioritized Inserter Blocks Unset',
|
|
20
21
|
icon: 'carrot',
|
|
21
22
|
category: 'text',
|
|
22
23
|
|
|
23
|
-
edit() {
|
|
24
|
-
|
|
24
|
+
edit: function Edit() {
|
|
25
|
+
const blockProps = useBlockProps( divProps );
|
|
26
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
27
|
+
template,
|
|
28
|
+
} );
|
|
29
|
+
return el( 'div', innerBlocksProps );
|
|
25
30
|
},
|
|
26
31
|
|
|
27
32
|
save,
|
|
28
33
|
} );
|
|
29
34
|
|
|
30
35
|
registerBlockType( 'test/prioritized-inserter-blocks-set', {
|
|
36
|
+
apiVersion: 3,
|
|
31
37
|
title: 'Prioritized Inserter Blocks Set',
|
|
32
38
|
icon: 'carrot',
|
|
33
39
|
category: 'text',
|
|
34
|
-
edit() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} )
|
|
46
|
-
);
|
|
40
|
+
edit: function Edit() {
|
|
41
|
+
const blockProps = useBlockProps( divProps );
|
|
42
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
43
|
+
template,
|
|
44
|
+
prioritizedInserterBlocks: [
|
|
45
|
+
'core/audio',
|
|
46
|
+
'core/spacer',
|
|
47
|
+
'core/code',
|
|
48
|
+
],
|
|
49
|
+
} );
|
|
50
|
+
return el( 'div', innerBlocksProps );
|
|
47
51
|
},
|
|
48
52
|
|
|
49
53
|
save,
|
|
@@ -52,28 +56,27 @@
|
|
|
52
56
|
registerBlockType(
|
|
53
57
|
'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks',
|
|
54
58
|
{
|
|
59
|
+
apiVersion: 3,
|
|
55
60
|
title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
|
|
56
61
|
icon: 'carrot',
|
|
57
62
|
category: 'text',
|
|
58
|
-
edit() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} )
|
|
76
|
-
);
|
|
63
|
+
edit: function Edit() {
|
|
64
|
+
const blockProps = useBlockProps( divProps );
|
|
65
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
66
|
+
template,
|
|
67
|
+
allowedBlocks: [
|
|
68
|
+
'core/spacer',
|
|
69
|
+
'core/code',
|
|
70
|
+
'core/paragraph',
|
|
71
|
+
'core/heading',
|
|
72
|
+
],
|
|
73
|
+
prioritizedInserterBlocks: [
|
|
74
|
+
'core/audio', // this is **not** in the allowedBlocks list
|
|
75
|
+
'core/spacer',
|
|
76
|
+
'core/code',
|
|
77
|
+
],
|
|
78
|
+
} );
|
|
79
|
+
return el( 'div', innerBlocksProps );
|
|
77
80
|
},
|
|
78
81
|
|
|
79
82
|
save,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const { wp } = window;
|
|
3
3
|
const { registerBlockType } = wp.blocks;
|
|
4
4
|
const { createElement: el } = wp.element;
|
|
5
|
-
const { InnerBlocks } = wp.blockEditor;
|
|
5
|
+
const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
|
|
6
6
|
const { useSelect } = wp.data;
|
|
7
7
|
|
|
8
8
|
const allowedBlocks = [ 'core/quote', 'core/video' ];
|
|
@@ -55,19 +55,20 @@
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
registerBlockType( 'test/inner-blocks-render-appender', {
|
|
58
|
+
apiVersion: 3,
|
|
58
59
|
title: 'InnerBlocks renderAppender',
|
|
59
60
|
icon: 'carrot',
|
|
60
61
|
category: 'text',
|
|
61
62
|
|
|
62
|
-
edit() {
|
|
63
|
-
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
63
|
+
edit: function Edit() {
|
|
64
|
+
const blockProps = useBlockProps( {
|
|
65
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
66
|
+
} );
|
|
67
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
68
|
+
allowedBlocks,
|
|
69
|
+
renderAppender: myCustomAppender,
|
|
70
|
+
} );
|
|
71
|
+
return el( 'div', innerBlocksProps );
|
|
71
72
|
},
|
|
72
73
|
|
|
73
74
|
save() {
|
|
@@ -80,14 +81,15 @@
|
|
|
80
81
|
} );
|
|
81
82
|
|
|
82
83
|
registerBlockType( 'test/inner-blocks-render-appender-dynamic', {
|
|
84
|
+
apiVersion: 3,
|
|
83
85
|
title: 'InnerBlocks renderAppender dynamic',
|
|
84
86
|
icon: 'carrot',
|
|
85
87
|
category: 'text',
|
|
86
88
|
|
|
87
|
-
edit( props ) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
edit: function Edit( props ) {
|
|
90
|
+
const blockProps = useBlockProps( {
|
|
91
|
+
style: { outline: '1px solid gray', padding: 5 },
|
|
92
|
+
} );
|
|
91
93
|
const numberOfChildren = useSelect(
|
|
92
94
|
( select ) => {
|
|
93
95
|
const { getBlockOrder } = select( 'core/block-editor' );
|
|
@@ -107,14 +109,11 @@
|
|
|
107
109
|
renderAppender = multipleBlockAppender;
|
|
108
110
|
break;
|
|
109
111
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
renderAppender,
|
|
116
|
-
} )
|
|
117
|
-
);
|
|
112
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
113
|
+
allowedBlocks,
|
|
114
|
+
renderAppender,
|
|
115
|
+
} );
|
|
116
|
+
return el( 'div', innerBlocksProps );
|
|
118
117
|
},
|
|
119
118
|
|
|
120
119
|
save() {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/hydration-timing",
|
|
5
|
+
"title": "E2E Interactivity tests - hydration timing",
|
|
6
|
+
"category": "text",
|
|
7
|
+
"icon": "heart",
|
|
8
|
+
"description": "",
|
|
9
|
+
"supports": {
|
|
10
|
+
"interactivity": true
|
|
11
|
+
},
|
|
12
|
+
"textdomain": "e2e-interactivity",
|
|
13
|
+
"viewScriptModule": "file:./view.js",
|
|
14
|
+
"render": "file:./render.php"
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing hydration timing with delayed module loading.
|
|
4
|
+
*
|
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
|
6
|
+
*
|
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
8
|
+
*/
|
|
9
|
+
?>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
data-wp-interactive="test/hydration-timing"
|
|
13
|
+
<?php echo wp_interactivity_data_wp_context( array( 'initialized' => false ) ); ?>
|
|
14
|
+
>
|
|
15
|
+
<p
|
|
16
|
+
data-wp-text="state.moduleLoaded"
|
|
17
|
+
data-testid="module-loaded"
|
|
18
|
+
>no</p>
|
|
19
|
+
|
|
20
|
+
<p
|
|
21
|
+
data-wp-text="context.initialized"
|
|
22
|
+
data-testid="context-initialized"
|
|
23
|
+
>no</p>
|
|
24
|
+
|
|
25
|
+
<div
|
|
26
|
+
data-wp-init="callbacks.init"
|
|
27
|
+
data-testid="hydration-status"
|
|
28
|
+
>
|
|
29
|
+
Hydration test block
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
|
5
|
+
|
|
6
|
+
// This is the "fast" module that loads immediately. It imports
|
|
7
|
+
// @wordpress/interactivity, which initializes the runtime.
|
|
8
|
+
//
|
|
9
|
+
// The test pairs this with a "slow" module (hydration-timing-slow) that is
|
|
10
|
+
// artificially delayed. The race condition occurs when this fast module
|
|
11
|
+
// triggers hydration before the slow module has finished loading.
|
|
12
|
+
|
|
13
|
+
store( 'test/hydration-timing', {
|
|
14
|
+
state: {
|
|
15
|
+
moduleLoaded: 'yes',
|
|
16
|
+
},
|
|
17
|
+
callbacks: {
|
|
18
|
+
init() {
|
|
19
|
+
const context = getContext();
|
|
20
|
+
context.initialized = true;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
} );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/hydration-timing-async",
|
|
5
|
+
"title": "E2E Interactivity tests - hydration timing async import",
|
|
6
|
+
"category": "text",
|
|
7
|
+
"icon": "heart",
|
|
8
|
+
"description": "",
|
|
9
|
+
"supports": {
|
|
10
|
+
"interactivity": true
|
|
11
|
+
},
|
|
12
|
+
"textdomain": "e2e-interactivity",
|
|
13
|
+
"viewScriptModule": "file:./view.js",
|
|
14
|
+
"render": "file:./render.php"
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing hydration timing - async import block.
|
|
4
|
+
*
|
|
5
|
+
* This block's view module dynamically imports @wordpress/interactivity
|
|
6
|
+
* on DOMContentLoaded, simulating a lazy-loading scenario. The test verifies
|
|
7
|
+
* that hydration still occurs even when the library is loaded after
|
|
8
|
+
* DOMContentLoaded has fired.
|
|
9
|
+
*
|
|
10
|
+
* @package gutenberg-test-interactive-blocks
|
|
11
|
+
*
|
|
12
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
13
|
+
*/
|
|
14
|
+
?>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
data-wp-interactive="test/hydration-timing-async"
|
|
18
|
+
<?php echo wp_interactivity_data_wp_context( array( 'hydrated' => false ) ); ?>
|
|
19
|
+
>
|
|
20
|
+
<p
|
|
21
|
+
data-wp-text="state.asyncModuleLoaded"
|
|
22
|
+
data-testid="async-module-loaded"
|
|
23
|
+
>no</p>
|
|
24
|
+
|
|
25
|
+
<p
|
|
26
|
+
data-wp-text="context.hydrated"
|
|
27
|
+
data-testid="async-hydrated"
|
|
28
|
+
>no</p>
|
|
29
|
+
|
|
30
|
+
<div
|
|
31
|
+
data-wp-init="callbacks.init"
|
|
32
|
+
data-testid="async-hydration-status"
|
|
33
|
+
>
|
|
34
|
+
Async import hydration test block
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module dynamically imports @wordpress/interactivity on DOMContentLoaded.
|
|
3
|
+
*
|
|
4
|
+
* This simulates a lazy-loading scenario where the Interactivity API is not
|
|
5
|
+
* statically imported. The test verifies that hydration still occurs even
|
|
6
|
+
* when the library is loaded after DOMContentLoaded has already fired.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const initStore = async () => {
|
|
10
|
+
const { store, getContext } = await import( '@wordpress/interactivity' );
|
|
11
|
+
|
|
12
|
+
store( 'test/hydration-timing-async', {
|
|
13
|
+
state: {
|
|
14
|
+
asyncModuleLoaded: 'yes',
|
|
15
|
+
},
|
|
16
|
+
callbacks: {
|
|
17
|
+
// TODO: this could be unavailable during hydration. Fix
|
|
18
|
+
// `data-wp-init` to support that case.
|
|
19
|
+
init() {
|
|
20
|
+
const context = getContext();
|
|
21
|
+
context.hydrated = true;
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
} );
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
document.addEventListener( 'DOMContentLoaded', () =>
|
|
28
|
+
setTimeout( initStore, 1 )
|
|
29
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/hydration-timing-slow",
|
|
5
|
+
"title": "E2E Interactivity tests - hydration timing slow module",
|
|
6
|
+
"category": "text",
|
|
7
|
+
"icon": "heart",
|
|
8
|
+
"description": "",
|
|
9
|
+
"supports": {
|
|
10
|
+
"interactivity": true
|
|
11
|
+
},
|
|
12
|
+
"textdomain": "e2e-interactivity",
|
|
13
|
+
"viewScriptModule": "file:./view.js",
|
|
14
|
+
"render": "file:./render.php"
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing hydration timing - slow module block.
|
|
4
|
+
*
|
|
5
|
+
* This block's view module will be artificially delayed in the test
|
|
6
|
+
* to simulate a slow network connection. The test verifies that
|
|
7
|
+
* hydration waits for this module to load even when other modules
|
|
8
|
+
* that import @wordpress/interactivity have already been evaluated.
|
|
9
|
+
*
|
|
10
|
+
* @package gutenberg-test-interactive-blocks
|
|
11
|
+
*
|
|
12
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
13
|
+
*/
|
|
14
|
+
?>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
data-wp-interactive="test/hydration-timing"
|
|
18
|
+
<?php echo wp_interactivity_data_wp_context( array( 'slowInitialized' => false ) ); ?>
|
|
19
|
+
>
|
|
20
|
+
<p
|
|
21
|
+
data-wp-text="state.slowModuleLoaded"
|
|
22
|
+
data-testid="slow-module-loaded"
|
|
23
|
+
>no</p>
|
|
24
|
+
|
|
25
|
+
<p
|
|
26
|
+
data-wp-text="context.slowInitialized"
|
|
27
|
+
data-testid="slow-context-initialized"
|
|
28
|
+
>no</p>
|
|
29
|
+
|
|
30
|
+
<div
|
|
31
|
+
data-wp-init="callbacks.slowInit"
|
|
32
|
+
data-testid="slow-hydration-status"
|
|
33
|
+
>
|
|
34
|
+
Slow module hydration test block
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
|
5
|
+
|
|
6
|
+
// This module will be artificially delayed in the test.
|
|
7
|
+
// It also imports @wordpress/interactivity, so when it's evaluated,
|
|
8
|
+
// the interactivity runtime will have already been initialized by
|
|
9
|
+
// the fast module. The test verifies that hydration waits for this
|
|
10
|
+
// module to finish loading before running.
|
|
11
|
+
|
|
12
|
+
store( 'test/hydration-timing', {
|
|
13
|
+
state: {
|
|
14
|
+
slowModuleLoaded: 'yes',
|
|
15
|
+
},
|
|
16
|
+
callbacks: {
|
|
17
|
+
slowInit() {
|
|
18
|
+
const context = getContext();
|
|
19
|
+
context.slowInitialized = true;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
} );
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<section>
|
|
12
12
|
<h2>Region 1</h2>
|
|
13
13
|
<div
|
|
14
|
+
data-testid="region-1"
|
|
14
15
|
data-wp-interactive="router-regions"
|
|
15
16
|
data-wp-router-region="region-1"
|
|
16
17
|
>
|
|
@@ -54,8 +55,11 @@
|
|
|
54
55
|
<section>
|
|
55
56
|
<h2>Region 2</h2>
|
|
56
57
|
<div
|
|
58
|
+
data-testid="region-2"
|
|
59
|
+
data-wp-key="region-2"
|
|
57
60
|
data-wp-interactive="router-regions"
|
|
58
61
|
data-wp-router-region="region-2"
|
|
62
|
+
data-wp-run="callbacks.nope"
|
|
59
63
|
>
|
|
60
64
|
<p
|
|
61
65
|
data-testid="region-2-text"
|
|
@@ -113,6 +117,7 @@
|
|
|
113
117
|
<!-- Router region inside data-wp-interactive -->
|
|
114
118
|
<div
|
|
115
119
|
data-testid="valid-inside-interactive"
|
|
120
|
+
data-wp-key="valid-inside-interactive"
|
|
116
121
|
data-wp-interactive="router-regions"
|
|
117
122
|
data-wp-router-region="valid-inside-interactive"
|
|
118
123
|
data-wp-context='{ "counter": { "value": 0 } }'
|
|
@@ -131,6 +136,7 @@
|
|
|
131
136
|
<!-- Router region inside data-wp-router-region -->
|
|
132
137
|
<div
|
|
133
138
|
data-testid="valid-inside-router-region"
|
|
139
|
+
data-wp-key="valid-inside-router-region"
|
|
134
140
|
data-wp-interactive="router-regions"
|
|
135
141
|
data-wp-router-region="valid-inside-router-region"
|
|
136
142
|
data-wp-context='{ "counter": { "value": 0 } }'
|
|
@@ -192,6 +198,7 @@
|
|
|
192
198
|
data-wp-interactive="router-regions"
|
|
193
199
|
data-wp-router-region='$region_data'
|
|
194
200
|
data-testid="$region_id"
|
|
201
|
+
data-wp-key="$region_id"
|
|
195
202
|
$has_directives
|
|
196
203
|
>
|
|
197
204
|
<div $context_data>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const registerBlockType = wp.blocks.registerBlockType;
|
|
3
3
|
const el = wp.element.createElement;
|
|
4
|
+
const { useBlockProps } = wp.blockEditor;
|
|
4
5
|
|
|
5
6
|
registerBlockType( 'test/test-meta-attribute-block-early', {
|
|
7
|
+
apiVersion: 3,
|
|
6
8
|
title: 'Test Meta Attribute Block (Early Registration)',
|
|
7
9
|
icon: 'star',
|
|
8
10
|
category: 'text',
|
|
@@ -15,14 +17,15 @@
|
|
|
15
17
|
},
|
|
16
18
|
},
|
|
17
19
|
|
|
18
|
-
edit( props ) {
|
|
19
|
-
|
|
20
|
+
edit: function Edit( props ) {
|
|
21
|
+
const blockProps = useBlockProps( {
|
|
20
22
|
className: 'my-meta-input',
|
|
21
23
|
value: props.attributes.content,
|
|
22
24
|
onChange( event ) {
|
|
23
25
|
props.setAttributes( { content: event.target.value } );
|
|
24
26
|
},
|
|
25
27
|
} );
|
|
28
|
+
return el( 'input', blockProps );
|
|
26
29
|
},
|
|
27
30
|
|
|
28
31
|
save() {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const registerBlockType = wp.blocks.registerBlockType;
|
|
3
3
|
const el = wp.element.createElement;
|
|
4
|
+
const { useBlockProps } = wp.blockEditor;
|
|
4
5
|
|
|
5
6
|
registerBlockType( 'test/test-meta-attribute-block-late', {
|
|
7
|
+
apiVersion: 3,
|
|
6
8
|
title: 'Test Meta Attribute Block (Late Registration)',
|
|
7
9
|
icon: 'star',
|
|
8
10
|
category: 'text',
|
|
@@ -15,14 +17,15 @@
|
|
|
15
17
|
},
|
|
16
18
|
},
|
|
17
19
|
|
|
18
|
-
edit( props ) {
|
|
19
|
-
|
|
20
|
+
edit: function Edit( props ) {
|
|
21
|
+
const blockProps = useBlockProps( {
|
|
20
22
|
className: 'my-meta-input',
|
|
21
23
|
value: props.attributes.content,
|
|
22
24
|
onChange( event ) {
|
|
23
25
|
props.setAttributes( { content: event.target.value } );
|
|
24
26
|
},
|
|
25
27
|
} );
|
|
28
|
+
return el( 'input', blockProps );
|
|
26
29
|
},
|
|
27
30
|
|
|
28
31
|
save() {
|
|
@@ -33,6 +33,7 @@ function enqueue_test_meta_attribute_block() {
|
|
|
33
33
|
plugins_url( 'meta-attribute-block/early.js', __FILE__ ),
|
|
34
34
|
array(
|
|
35
35
|
'wp-blocks',
|
|
36
|
+
'wp-block-editor',
|
|
36
37
|
'wp-element',
|
|
37
38
|
),
|
|
38
39
|
filemtime( plugin_dir_path( __FILE__ ) . 'meta-attribute-block/early.js' )
|
|
@@ -43,6 +44,7 @@ function enqueue_test_meta_attribute_block() {
|
|
|
43
44
|
plugins_url( 'meta-attribute-block/late.js', __FILE__ ),
|
|
44
45
|
array(
|
|
45
46
|
'wp-blocks',
|
|
47
|
+
'wp-block-editor',
|
|
46
48
|
'wp-element',
|
|
47
49
|
),
|
|
48
50
|
filemtime( plugin_dir_path( __FILE__ ) . 'meta-attribute-block/late.js' ),
|