@wordpress/block-library 9.33.1-next.ff1cebbba.0 → 9.33.2-next.36001005c.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.
Files changed (173) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/build/breadcrumbs/block.json +8 -2
  4. package/build/breadcrumbs/edit.js +113 -12
  5. package/build/breadcrumbs/edit.js.map +2 -2
  6. package/build/buttons/transforms.js +7 -7
  7. package/build/buttons/transforms.js.map +2 -2
  8. package/build/code/transforms.js +19 -15
  9. package/build/code/transforms.js.map +2 -2
  10. package/build/heading/index.js +1 -3
  11. package/build/heading/index.js.map +3 -3
  12. package/build/heading/transforms.js +22 -20
  13. package/build/heading/transforms.js.map +2 -2
  14. package/build/index.js +5 -3
  15. package/build/index.js.map +2 -2
  16. package/build/math/block.json +21 -0
  17. package/build/math/edit.js +132 -0
  18. package/build/math/edit.js.map +7 -0
  19. package/build/math/index.js +63 -0
  20. package/build/math/index.js.map +7 -0
  21. package/build/math/init.js +35 -0
  22. package/build/math/init.js.map +7 -0
  23. package/build/math/save.js +40 -0
  24. package/build/math/save.js.map +7 -0
  25. package/build/navigation/edit/menu-inspector-controls.js +2 -2
  26. package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
  27. package/build/navigation-link/edit.js +5 -2
  28. package/build/navigation-link/edit.js.map +2 -2
  29. package/build/navigation-link/link-ui/index.js +1 -1
  30. package/build/navigation-link/link-ui/index.js.map +2 -2
  31. package/build/navigation-link/shared/controls.js +39 -16
  32. package/build/navigation-link/shared/controls.js.map +3 -3
  33. package/build/navigation-link/shared/index.js +2 -0
  34. package/build/navigation-link/shared/index.js.map +2 -2
  35. package/build/navigation-link/shared/update-attributes.js +3 -1
  36. package/build/navigation-link/shared/update-attributes.js.map +2 -2
  37. package/build/navigation-link/shared/use-entity-binding.js +46 -13
  38. package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
  39. package/build/navigation-submenu/edit.js +5 -2
  40. package/build/navigation-submenu/edit.js.map +2 -2
  41. package/build/page-list/use-convert-to-navigation-links.js +6 -1
  42. package/build/page-list/use-convert-to-navigation-links.js.map +2 -2
  43. package/build/paragraph/index.js +1 -3
  44. package/build/paragraph/index.js.map +3 -3
  45. package/build/post-date/deprecated.js +98 -2
  46. package/build/post-date/deprecated.js.map +2 -2
  47. package/build/post-date/edit.js +1 -1
  48. package/build/post-date/edit.js.map +1 -1
  49. package/build/post-date/variations.js +4 -4
  50. package/build/post-date/variations.js.map +2 -2
  51. package/build/term-template/block.json +0 -1
  52. package/build/term-template/edit.js +4 -1
  53. package/build/term-template/edit.js.map +2 -2
  54. package/build/terms-query/block.json +0 -1
  55. package/build/utils/get-transformed-attributes.js +82 -0
  56. package/build/utils/get-transformed-attributes.js.map +7 -0
  57. package/build-module/breadcrumbs/block.json +8 -2
  58. package/build-module/breadcrumbs/edit.js +117 -14
  59. package/build-module/breadcrumbs/edit.js.map +2 -2
  60. package/build-module/buttons/transforms.js +7 -7
  61. package/build-module/buttons/transforms.js.map +2 -2
  62. package/build-module/code/transforms.js +19 -15
  63. package/build-module/code/transforms.js.map +2 -2
  64. package/build-module/heading/index.js +1 -3
  65. package/build-module/heading/index.js.map +2 -2
  66. package/build-module/heading/transforms.js +22 -20
  67. package/build-module/heading/transforms.js.map +2 -2
  68. package/build-module/index.js +5 -3
  69. package/build-module/index.js.map +2 -2
  70. package/build-module/math/block.json +21 -0
  71. package/build-module/math/edit.js +110 -0
  72. package/build-module/math/edit.js.map +7 -0
  73. package/build-module/math/index.js +26 -0
  74. package/build-module/math/index.js.map +7 -0
  75. package/build-module/math/init.js +8 -0
  76. package/build-module/math/init.js.map +7 -0
  77. package/build-module/math/save.js +20 -0
  78. package/build-module/math/save.js.map +7 -0
  79. package/build-module/navigation/edit/menu-inspector-controls.js +2 -2
  80. package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
  81. package/build-module/navigation-link/edit.js +5 -2
  82. package/build-module/navigation-link/edit.js.map +2 -2
  83. package/build-module/navigation-link/link-ui/index.js +1 -1
  84. package/build-module/navigation-link/link-ui/index.js.map +2 -2
  85. package/build-module/navigation-link/shared/controls.js +40 -17
  86. package/build-module/navigation-link/shared/controls.js.map +2 -2
  87. package/build-module/navigation-link/shared/index.js +5 -1
  88. package/build-module/navigation-link/shared/index.js.map +2 -2
  89. package/build-module/navigation-link/shared/update-attributes.js +3 -1
  90. package/build-module/navigation-link/shared/update-attributes.js.map +2 -2
  91. package/build-module/navigation-link/shared/use-entity-binding.js +45 -13
  92. package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
  93. package/build-module/navigation-submenu/edit.js +5 -2
  94. package/build-module/navigation-submenu/edit.js.map +2 -2
  95. package/build-module/page-list/use-convert-to-navigation-links.js +6 -1
  96. package/build-module/page-list/use-convert-to-navigation-links.js.map +2 -2
  97. package/build-module/paragraph/index.js +1 -3
  98. package/build-module/paragraph/index.js.map +2 -2
  99. package/build-module/post-date/deprecated.js +98 -2
  100. package/build-module/post-date/deprecated.js.map +2 -2
  101. package/build-module/post-date/edit.js +1 -1
  102. package/build-module/post-date/edit.js.map +1 -1
  103. package/build-module/post-date/variations.js +4 -4
  104. package/build-module/post-date/variations.js.map +2 -2
  105. package/build-module/term-template/block.json +0 -1
  106. package/build-module/term-template/edit.js +4 -1
  107. package/build-module/term-template/edit.js.map +2 -2
  108. package/build-module/terms-query/block.json +0 -1
  109. package/build-module/utils/get-transformed-attributes.js +58 -0
  110. package/build-module/utils/get-transformed-attributes.js.map +7 -0
  111. package/build-style/editor-rtl.css +2 -2
  112. package/build-style/editor.css +2 -2
  113. package/build-style/navigation-link/editor-rtl.css +1 -1
  114. package/build-style/navigation-link/editor.css +1 -1
  115. package/build-style/video/editor-rtl.css +1 -1
  116. package/build-style/video/editor.css +1 -1
  117. package/package.json +61 -36
  118. package/src/breadcrumbs/block.json +8 -2
  119. package/src/breadcrumbs/edit.js +163 -18
  120. package/src/breadcrumbs/index.php +118 -16
  121. package/src/buttons/transforms.js +6 -6
  122. package/src/code/transforms.js +16 -14
  123. package/src/heading/index.js +0 -2
  124. package/src/heading/transforms.js +25 -24
  125. package/src/index.js +5 -3
  126. package/src/math/block.json +21 -0
  127. package/src/math/edit.js +123 -0
  128. package/src/math/index.js +31 -0
  129. package/src/math/init.js +4 -0
  130. package/src/math/save.js +20 -0
  131. package/src/navigation/edit/menu-inspector-controls.js +7 -6
  132. package/src/navigation-link/edit.js +5 -2
  133. package/src/navigation-link/editor.scss +1 -1
  134. package/src/navigation-link/index.php +4 -18
  135. package/src/navigation-link/link-ui/index.js +4 -2
  136. package/src/navigation-link/shared/controls.js +69 -20
  137. package/src/navigation-link/shared/index.js +4 -1
  138. package/src/navigation-link/shared/test/controls.js +14 -9
  139. package/src/navigation-link/shared/test/update-attributes.test.js +8 -0
  140. package/src/navigation-link/shared/test/use-entity-binding.js +132 -17
  141. package/src/navigation-link/shared/update-attributes.js +1 -0
  142. package/src/navigation-link/shared/use-entity-binding.js +74 -19
  143. package/src/navigation-submenu/edit.js +5 -2
  144. package/src/navigation-submenu/index.php +3 -17
  145. package/src/page-list/test/{convert-to-links-modal.js → convert-to-navigation-links.js} +67 -0
  146. package/src/page-list/use-convert-to-navigation-links.js +11 -1
  147. package/src/paragraph/index.js +0 -2
  148. package/src/post-date/deprecated.js +104 -2
  149. package/src/post-date/edit.js +1 -1
  150. package/src/post-date/index.php +3 -3
  151. package/src/post-date/variations.js +5 -4
  152. package/src/term-template/block.json +0 -1
  153. package/src/term-template/edit.js +4 -1
  154. package/src/term-template/index.php +4 -6
  155. package/src/terms-query/block.json +0 -1
  156. package/src/utils/get-transformed-attributes.js +98 -0
  157. package/src/video/editor.scss +1 -1
  158. package/tsconfig.json +1 -0
  159. package/build/heading/variations.js +0 -48
  160. package/build/heading/variations.js.map +0 -7
  161. package/build/paragraph/variations.js +0 -48
  162. package/build/paragraph/variations.js.map +0 -7
  163. package/build/utils/get-transformed-metadata.js +0 -65
  164. package/build/utils/get-transformed-metadata.js.map +0 -7
  165. package/build-module/heading/variations.js +0 -28
  166. package/build-module/heading/variations.js.map +0 -7
  167. package/build-module/paragraph/variations.js +0 -28
  168. package/build-module/paragraph/variations.js.map +0 -7
  169. package/build-module/utils/get-transformed-metadata.js +0 -41
  170. package/build-module/utils/get-transformed-metadata.js.map +0 -7
  171. package/src/heading/variations.js +0 -29
  172. package/src/paragraph/variations.js +0 -29
  173. package/src/utils/get-transformed-metadata.js +0 -69
@@ -4,6 +4,46 @@
4
4
  import { useCallback } from '@wordpress/element';
5
5
  import { useBlockBindingsUtils } from '@wordpress/block-editor';
6
6
 
7
+ /**
8
+ * Builds entity binding configuration for navigation link URLs.
9
+ * This function generates the structure used to bind navigation link URLs to their entity sources.
10
+ *
11
+ * Using a function instead of a constant allows for future enhancements where the binding
12
+ * might need dynamic data (e.g., entity ID, context-specific arguments).
13
+ *
14
+ * @param {('post-type'|'taxonomy')} kind - The kind of entity. Only 'post-type' and 'taxonomy' are supported.
15
+ * @return {Object} Entity binding configuration object
16
+ * @throws {Error} If kind is not 'post-type' or 'taxonomy'
17
+ */
18
+ export function buildNavigationLinkEntityBinding( kind ) {
19
+ // Validate kind parameter exists
20
+ if ( kind === undefined ) {
21
+ throw new Error(
22
+ 'buildNavigationLinkEntityBinding requires a kind parameter. ' +
23
+ 'Only "post-type" and "taxonomy" are supported.'
24
+ );
25
+ }
26
+
27
+ // Validate kind parameter value
28
+ if ( kind !== 'post-type' && kind !== 'taxonomy' ) {
29
+ throw new Error(
30
+ `Invalid kind "${ kind }" provided to buildNavigationLinkEntityBinding. ` +
31
+ `Only 'post-type' and 'taxonomy' are supported.`
32
+ );
33
+ }
34
+
35
+ const source = kind === 'taxonomy' ? 'core/term-data' : 'core/post-data';
36
+
37
+ return {
38
+ url: {
39
+ source,
40
+ args: {
41
+ field: 'link',
42
+ },
43
+ },
44
+ };
45
+ }
46
+
7
47
  /**
8
48
  * Shared hook for entity binding functionality in Navigation blocks.
9
49
  *
@@ -17,33 +57,48 @@ import { useBlockBindingsUtils } from '@wordpress/block-editor';
17
57
  */
18
58
  export function useEntityBinding( { clientId, attributes } ) {
19
59
  const { updateBlockBindings } = useBlockBindingsUtils( clientId );
20
- const { metadata, id } = attributes;
60
+ const { metadata, id, kind } = attributes;
21
61
 
22
- // Check if there's a URL binding with the core/entity source
23
- const hasUrlBinding =
24
- metadata?.bindings?.url?.source === 'core/entity' && !! id;
62
+ const hasUrlBinding = !! metadata?.bindings?.url && !! id;
63
+ const expectedSource =
64
+ kind === 'post-type' ? 'core/post-data' : 'core/term-data';
65
+ const hasCorrectBinding =
66
+ hasUrlBinding && metadata?.bindings?.url?.source === expectedSource;
25
67
 
26
68
  const clearBinding = useCallback( () => {
27
- // Only clear if there's actually a valid binding to clear
28
69
  if ( hasUrlBinding ) {
29
- // Remove the URL binding by setting it to undefined
30
70
  updateBlockBindings( { url: undefined } );
31
71
  }
32
- }, [ hasUrlBinding, updateBlockBindings ] );
33
-
34
- const createBinding = useCallback( () => {
35
- updateBlockBindings( {
36
- url: {
37
- source: 'core/entity',
38
- args: {
39
- key: 'url',
40
- },
41
- },
42
- } );
43
- }, [ updateBlockBindings ] );
72
+ }, [ updateBlockBindings, hasUrlBinding ] );
73
+
74
+ const createBinding = useCallback(
75
+ ( updatedAttributes ) => {
76
+ // Use updated attributes if provided, otherwise fall back to closure attributes
77
+ // updatedAttributes needed to access the most up-to-date data when called synchronously
78
+ const kindToUse = updatedAttributes?.kind ?? kind;
79
+
80
+ // Avoid creating binding if no kind is provided
81
+ if ( ! kindToUse ) {
82
+ return;
83
+ }
84
+
85
+ try {
86
+ const binding = buildNavigationLinkEntityBinding( kindToUse );
87
+ updateBlockBindings( binding );
88
+ } catch ( error ) {
89
+ // eslint-disable-next-line no-console
90
+ console.warn(
91
+ 'Failed to create entity binding:',
92
+ error.message
93
+ );
94
+ // Don't create binding if validation fails
95
+ }
96
+ },
97
+ [ updateBlockBindings, kind, id ]
98
+ );
44
99
 
45
100
  return {
46
- hasUrlBinding,
101
+ hasUrlBinding: hasCorrectBinding,
47
102
  clearBinding,
48
103
  createBinding,
49
104
  };
@@ -432,7 +432,10 @@ export default function NavigationSubmenuEdit( {
432
432
  } }
433
433
  onChange={ ( updatedValue ) => {
434
434
  // updateAttributes determines the final state and returns metadata
435
- const { isEntityLink } = updateAttributes(
435
+ const {
436
+ isEntityLink,
437
+ attributes: updatedAttributes,
438
+ } = updateAttributes(
436
439
  updatedValue,
437
440
  setAttributes,
438
441
  attributes
@@ -442,7 +445,7 @@ export default function NavigationSubmenuEdit( {
442
445
  // Only create bindings for entity links (posts, pages, taxonomies)
443
446
  // Never create bindings for custom links (manual URLs)
444
447
  if ( isEntityLink ) {
445
- createBinding();
448
+ createBinding( updatedAttributes );
446
449
  } else {
447
450
  clearBinding();
448
451
  }
@@ -79,20 +79,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
79
79
  return '';
80
80
  }
81
81
 
82
- // Resolve URL binding if present
83
- $url = $attributes['url'] ?? '';
84
- if ( isset( $attributes['metadata']['bindings']['url']['source'] ) ) {
85
- $binding = $attributes['metadata']['bindings']['url'];
86
- $source = get_block_bindings_source( $binding['source'] );
87
- if ( $source ) {
88
- $source_args = $binding['args'] ?? array();
89
- $resolved_url = $source->get_value( $source_args, $block, 'url' );
90
- if ( $resolved_url ) {
91
- $url = $resolved_url;
92
- }
93
- }
94
- }
95
-
96
82
  $font_sizes = block_core_navigation_submenu_build_css_font_sizes( $block->context );
97
83
  $style_attribute = $font_sizes['inline_styles'];
98
84
 
@@ -100,9 +86,9 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
100
86
  $kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
101
87
  $is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
102
88
 
103
- if ( is_post_type_archive() && ! empty( $url ) ) {
89
+ if ( is_post_type_archive() && ! empty( $attributes['url'] ) ) {
104
90
  $queried_archive_link = get_post_type_archive_link( get_queried_object()->name );
105
- if ( $url === $queried_archive_link ) {
91
+ if ( $attributes['url'] === $queried_archive_link ) {
106
92
  $is_active = true;
107
93
  }
108
94
  }
@@ -156,7 +142,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
156
142
  // If Submenus open on hover, we render an anchor tag with attributes.
157
143
  // If submenu icons are set to show, we also render a submenu button, so the submenu can be opened on click.
158
144
  if ( ! $open_on_click ) {
159
- $item_url = $url;
145
+ $item_url = isset( $attributes['url'] ) ? $attributes['url'] : '';
160
146
  // Start appending HTML attributes to anchor tag.
161
147
  $html .= '<a class="wp-block-navigation-item__content"';
162
148
 
@@ -4,6 +4,16 @@
4
4
 
5
5
  import { convertToNavigationLinks } from '../use-convert-to-navigation-links';
6
6
 
7
+ // Expected entity binding structure for navigation links
8
+ const EXPECTED_ENTITY_BINDING = {
9
+ url: {
10
+ source: 'core/post-data',
11
+ args: {
12
+ field: 'link',
13
+ },
14
+ },
15
+ };
16
+
7
17
  // Mock createBlock to avoid creating the blocks in test environment
8
18
  // as convertToNavigationLinks calls this method internally.
9
19
  jest.mock( '@wordpress/blocks', () => {
@@ -117,6 +127,9 @@ describe( 'page list convert to links', () => {
117
127
  label: 'Sample Page',
118
128
  type: 'page',
119
129
  url: 'http://wordpress.local/sample-page/',
130
+ metadata: {
131
+ bindings: EXPECTED_ENTITY_BINDING,
132
+ },
120
133
  },
121
134
  innerBlocks: [],
122
135
  name: 'core/navigation-link',
@@ -128,6 +141,9 @@ describe( 'page list convert to links', () => {
128
141
  label: 'About',
129
142
  type: 'page',
130
143
  url: 'http://wordpress.local/about/',
144
+ metadata: {
145
+ bindings: EXPECTED_ENTITY_BINDING,
146
+ },
131
147
  },
132
148
  innerBlocks: [
133
149
  {
@@ -137,6 +153,9 @@ describe( 'page list convert to links', () => {
137
153
  label: 'About Sub 1',
138
154
  type: 'page',
139
155
  url: 'http://wordpress.local/about/about-sub-1/',
156
+ metadata: {
157
+ bindings: EXPECTED_ENTITY_BINDING,
158
+ },
140
159
  },
141
160
  innerBlocks: [],
142
161
  name: 'core/navigation-link',
@@ -148,6 +167,9 @@ describe( 'page list convert to links', () => {
148
167
  label: 'About Sub 2',
149
168
  type: 'page',
150
169
  url: 'http://wordpress.local/about/about-sub-2/',
170
+ metadata: {
171
+ bindings: EXPECTED_ENTITY_BINDING,
172
+ },
151
173
  },
152
174
  innerBlocks: [],
153
175
  name: 'core/navigation-link',
@@ -162,6 +184,9 @@ describe( 'page list convert to links', () => {
162
184
  label: 'Contact Page',
163
185
  type: 'page',
164
186
  url: 'http://wordpress.local/contact-page/',
187
+ metadata: {
188
+ bindings: EXPECTED_ENTITY_BINDING,
189
+ },
165
190
  },
166
191
  innerBlocks: [],
167
192
  name: 'core/navigation-link',
@@ -173,6 +198,9 @@ describe( 'page list convert to links', () => {
173
198
  label: 'Test',
174
199
  type: 'page',
175
200
  url: 'http://wordpress.local/test/',
201
+ metadata: {
202
+ bindings: EXPECTED_ENTITY_BINDING,
203
+ },
176
204
  },
177
205
  innerBlocks: [
178
206
  {
@@ -182,6 +210,9 @@ describe( 'page list convert to links', () => {
182
210
  label: 'Test Sub',
183
211
  type: 'page',
184
212
  url: 'http://wordpress.local/test/test-sub/',
213
+ metadata: {
214
+ bindings: EXPECTED_ENTITY_BINDING,
215
+ },
185
216
  },
186
217
  innerBlocks: [
187
218
  {
@@ -191,6 +222,9 @@ describe( 'page list convert to links', () => {
191
222
  label: 'Test Sub Sub',
192
223
  type: 'page',
193
224
  url: 'http://wordpress.local/test/test-sub/test-sub-sub/',
225
+ metadata: {
226
+ bindings: EXPECTED_ENTITY_BINDING,
227
+ },
194
228
  },
195
229
  innerBlocks: [],
196
230
  name: 'core/navigation-link',
@@ -297,6 +331,9 @@ describe( 'page list convert to links', () => {
297
331
  label: 'Sample Page',
298
332
  type: 'page',
299
333
  url: 'http://wordpress.local/sample-page/',
334
+ metadata: {
335
+ bindings: EXPECTED_ENTITY_BINDING,
336
+ },
300
337
  },
301
338
  innerBlocks: [],
302
339
  name: 'core/navigation-link',
@@ -308,6 +345,9 @@ describe( 'page list convert to links', () => {
308
345
  label: 'About',
309
346
  type: 'page',
310
347
  url: 'http://wordpress.local/about/',
348
+ metadata: {
349
+ bindings: EXPECTED_ENTITY_BINDING,
350
+ },
311
351
  },
312
352
  innerBlocks: [
313
353
  {
@@ -317,6 +357,9 @@ describe( 'page list convert to links', () => {
317
357
  label: 'About Sub 1',
318
358
  type: 'page',
319
359
  url: 'http://wordpress.local/about/about-sub-1/',
360
+ metadata: {
361
+ bindings: EXPECTED_ENTITY_BINDING,
362
+ },
320
363
  },
321
364
  innerBlocks: [],
322
365
  name: 'core/navigation-link',
@@ -328,6 +371,9 @@ describe( 'page list convert to links', () => {
328
371
  label: 'About Sub 2',
329
372
  type: 'page',
330
373
  url: 'http://wordpress.local/about/about-sub-2/',
374
+ metadata: {
375
+ bindings: EXPECTED_ENTITY_BINDING,
376
+ },
331
377
  },
332
378
  innerBlocks: [],
333
379
  name: 'core/navigation-link',
@@ -342,6 +388,9 @@ describe( 'page list convert to links', () => {
342
388
  label: 'Contact Page',
343
389
  type: 'page',
344
390
  url: 'http://wordpress.local/contact-page/',
391
+ metadata: {
392
+ bindings: EXPECTED_ENTITY_BINDING,
393
+ },
345
394
  },
346
395
  innerBlocks: [],
347
396
  name: 'core/navigation-link',
@@ -353,6 +402,9 @@ describe( 'page list convert to links', () => {
353
402
  label: 'Test',
354
403
  type: 'page',
355
404
  url: 'http://wordpress.local/test/',
405
+ metadata: {
406
+ bindings: EXPECTED_ENTITY_BINDING,
407
+ },
356
408
  },
357
409
  innerBlocks: [
358
410
  {
@@ -362,6 +414,9 @@ describe( 'page list convert to links', () => {
362
414
  label: 'Test Sub',
363
415
  type: 'page',
364
416
  url: 'http://wordpress.local/test/test-sub/',
417
+ metadata: {
418
+ bindings: EXPECTED_ENTITY_BINDING,
419
+ },
365
420
  },
366
421
  innerBlocks: [
367
422
  {
@@ -371,6 +426,9 @@ describe( 'page list convert to links', () => {
371
426
  label: 'Test Sub Sub',
372
427
  type: 'page',
373
428
  url: 'http://wordpress.local/test/test-sub/test-sub-sub/',
429
+ metadata: {
430
+ bindings: EXPECTED_ENTITY_BINDING,
431
+ },
374
432
  },
375
433
  innerBlocks: [],
376
434
  name: 'core/navigation-link',
@@ -481,6 +539,9 @@ describe( 'page list convert to links', () => {
481
539
  label: 'About Sub 1',
482
540
  type: 'page',
483
541
  url: 'http://wordpress.local/about/about-sub-1/',
542
+ metadata: {
543
+ bindings: EXPECTED_ENTITY_BINDING,
544
+ },
484
545
  },
485
546
  innerBlocks: [],
486
547
  name: 'core/navigation-link',
@@ -492,6 +553,9 @@ describe( 'page list convert to links', () => {
492
553
  label: 'About Sub 2',
493
554
  type: 'page',
494
555
  url: 'http://wordpress.local/about/about-sub-2/',
556
+ metadata: {
557
+ bindings: EXPECTED_ENTITY_BINDING,
558
+ },
495
559
  },
496
560
  innerBlocks: [],
497
561
  name: 'core/navigation-link',
@@ -511,6 +575,9 @@ describe( 'page list convert to links', () => {
511
575
  label: 'Test Sub Sub',
512
576
  type: 'page',
513
577
  url: 'http://wordpress.local/test/test-sub/test-sub-sub/',
578
+ metadata: {
579
+ bindings: EXPECTED_ENTITY_BINDING,
580
+ },
514
581
  },
515
582
  innerBlocks: [],
516
583
  name: 'core/navigation-link',
@@ -5,6 +5,11 @@ import { createBlock } from '@wordpress/blocks';
5
5
  import { useDispatch } from '@wordpress/data';
6
6
  import { store as blockEditorStore } from '@wordpress/block-editor';
7
7
 
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { buildNavigationLinkEntityBinding } from '../navigation-link/shared';
12
+
8
13
  /**
9
14
  * Converts an array of pages into a nested array of navigation link blocks.
10
15
  *
@@ -13,6 +18,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
13
18
  * @return {Array} A nested array of navigation link blocks.
14
19
  */
15
20
  function createNavigationLinks( pages = [] ) {
21
+ const POST_TYPE_KIND = 'post-type';
16
22
  const linkMap = {};
17
23
  const navigationLinks = [];
18
24
  pages.forEach( ( { id, title, link: url, type, parent } ) => {
@@ -25,7 +31,11 @@ function createNavigationLinks( pages = [] ) {
25
31
  label: title.rendered,
26
32
  url,
27
33
  type,
28
- kind: 'post-type',
34
+ kind: POST_TYPE_KIND,
35
+ metadata: {
36
+ bindings:
37
+ buildNavigationLinkEntityBinding( POST_TYPE_KIND ),
38
+ },
29
39
  },
30
40
  innerBlocks
31
41
  );
@@ -13,7 +13,6 @@ import edit from './edit';
13
13
  import metadata from './block.json';
14
14
  import save from './save';
15
15
  import transforms from './transforms';
16
- import variations from './variations';
17
16
 
18
17
  const { name } = metadata;
19
18
 
@@ -55,7 +54,6 @@ export const settings = {
55
54
  },
56
55
  edit,
57
56
  save,
58
- variations,
59
57
  };
60
58
 
61
59
  export const init = () => initBlock( { name, metadata, settings } );
@@ -8,6 +8,108 @@ import clsx from 'clsx';
8
8
  */
9
9
  import migrateFontFamily from '../utils/migrate-font-family';
10
10
 
11
+ const v3 = {
12
+ attributes: {
13
+ datetime: {
14
+ type: 'string',
15
+ role: 'content',
16
+ },
17
+ textAlign: {
18
+ type: 'string',
19
+ },
20
+ format: {
21
+ type: 'string',
22
+ },
23
+ isLink: {
24
+ type: 'boolean',
25
+ default: false,
26
+ role: 'content',
27
+ },
28
+ },
29
+ supports: {
30
+ html: false,
31
+ color: {
32
+ gradients: true,
33
+ link: true,
34
+ __experimentalDefaultControls: {
35
+ background: true,
36
+ text: true,
37
+ link: true,
38
+ },
39
+ },
40
+ spacing: {
41
+ margin: true,
42
+ padding: true,
43
+ },
44
+ typography: {
45
+ fontSize: true,
46
+ lineHeight: true,
47
+ __experimentalFontFamily: true,
48
+ __experimentalFontWeight: true,
49
+ __experimentalFontStyle: true,
50
+ __experimentalTextTransform: true,
51
+ __experimentalTextDecoration: true,
52
+ __experimentalLetterSpacing: true,
53
+ __experimentalDefaultControls: {
54
+ fontSize: true,
55
+ },
56
+ },
57
+ interactivity: {
58
+ clientNavigation: true,
59
+ },
60
+ __experimentalBorder: {
61
+ radius: true,
62
+ color: true,
63
+ width: true,
64
+ style: true,
65
+ __experimentalDefaultControls: {
66
+ radius: true,
67
+ color: true,
68
+ width: true,
69
+ style: true,
70
+ },
71
+ },
72
+ },
73
+ save() {
74
+ return null;
75
+ },
76
+ migrate( {
77
+ metadata: {
78
+ bindings: {
79
+ datetime: {
80
+ source,
81
+ args: { key, ...otherArgs },
82
+ },
83
+ ...otherBindings
84
+ },
85
+ ...otherMetadata
86
+ },
87
+ ...otherAttributes
88
+ } ) {
89
+ // Change the block bindings source argument name from "key" to "field".
90
+ return {
91
+ metadata: {
92
+ bindings: {
93
+ datetime: {
94
+ source,
95
+ args: { field: key, ...otherArgs },
96
+ },
97
+ ...otherBindings,
98
+ },
99
+ ...otherMetadata,
100
+ },
101
+ ...otherAttributes,
102
+ };
103
+ },
104
+ isEligible( attributes ) {
105
+ return (
106
+ attributes?.metadata?.bindings?.datetime?.source ===
107
+ 'core/post-data' &&
108
+ !! attributes?.metadata?.bindings?.datetime?.args?.key
109
+ );
110
+ },
111
+ };
112
+
11
113
  const v2 = {
12
114
  attributes: {
13
115
  textAlign: {
@@ -90,7 +192,7 @@ const v2 = {
90
192
  bindings: {
91
193
  datetime: {
92
194
  source: 'core/post-data',
93
- args: { key: displayType },
195
+ args: { field: displayType },
94
196
  },
95
197
  },
96
198
  },
@@ -152,4 +254,4 @@ const v1 = {
152
254
  *
153
255
  * See block-deprecation.md
154
256
  */
155
- export default [ v2, v1 ];
257
+ export default [ v3, v2, v1 ];
@@ -48,7 +48,7 @@ export default function PostDateEdit( {
48
48
  } ) {
49
49
  const displayType =
50
50
  metadata?.bindings?.datetime?.source === 'core/post-data' &&
51
- metadata?.bindings?.datetime?.args?.key;
51
+ metadata?.bindings?.datetime?.args?.field;
52
52
 
53
53
  const blockProps = useBlockProps( {
54
54
  className: clsx( {
@@ -32,17 +32,17 @@ function render_block_core_post_date( $attributes, $content, $block ) {
32
32
  $source = get_block_bindings_source( 'core/post-data' );
33
33
  if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
34
34
  $source_args = array(
35
- 'key' => 'modified',
35
+ 'field' => 'modified',
36
36
  );
37
37
  } else {
38
38
  $source_args = array(
39
- 'key' => 'date',
39
+ 'field' => 'date',
40
40
  );
41
41
  }
42
42
  $attributes['datetime'] = $source->get_value( $source_args, $block, 'datetime' );
43
43
  }
44
44
 
45
- if ( isset( $source_args['key'] ) && 'modified' === $source_args['key'] ) {
45
+ if ( isset( $source_args['field'] ) && 'modified' === $source_args['field'] ) {
46
46
  $classes[] = 'wp-block-post-date__modified-date';
47
47
  }
48
48
 
@@ -14,7 +14,7 @@ const variations = [
14
14
  bindings: {
15
15
  datetime: {
16
16
  source: 'core/post-data',
17
- args: { key: 'date' },
17
+ args: { field: 'date' },
18
18
  },
19
19
  },
20
20
  },
@@ -23,7 +23,8 @@ const variations = [
23
23
  isActive: ( blockAttributes ) =>
24
24
  blockAttributes?.metadata?.bindings?.datetime?.source ===
25
25
  'core/post-data' &&
26
- blockAttributes?.metadata?.bindings?.datetime?.args?.key === 'date',
26
+ blockAttributes?.metadata?.bindings?.datetime?.args?.field ===
27
+ 'date',
27
28
  icon: postDate,
28
29
  },
29
30
  {
@@ -35,7 +36,7 @@ const variations = [
35
36
  bindings: {
36
37
  datetime: {
37
38
  source: 'core/post-data',
38
- args: { key: 'modified' },
39
+ args: { field: 'modified' },
39
40
  },
40
41
  },
41
42
  },
@@ -45,7 +46,7 @@ const variations = [
45
46
  isActive: ( blockAttributes ) =>
46
47
  blockAttributes?.metadata?.bindings?.datetime?.source ===
47
48
  'core/post-data' &&
48
- blockAttributes?.metadata?.bindings?.datetime?.args?.key ===
49
+ blockAttributes?.metadata?.bindings?.datetime?.args?.field ===
49
50
  'modified',
50
51
  icon: postDate,
51
52
  },
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": true,
5
4
  "name": "core/term-template",
6
5
  "title": "Term Template",
7
6
  "category": "theme",
@@ -93,7 +93,10 @@ export default function TermTemplateEdit( {
93
93
  hide_empty: hideEmpty,
94
94
  order,
95
95
  orderby: orderBy,
96
- per_page: perPage,
96
+ // There is a mismatch between `WP_Term_Query` and the REST API parameter default
97
+ // values to fetch all items. In `WP_Term_Query`, the default is `''|0` and in
98
+ // the REST API is `-1`.
99
+ per_page: perPage || -1,
97
100
  };
98
101
 
99
102
  // Nested terms are returned by default from REST API as long as parent is not set.
@@ -85,27 +85,25 @@ function render_block_core_term_template( $attributes, $content, $block ) {
85
85
  return $context;
86
86
  };
87
87
 
88
- $block_content = '';
89
-
90
88
  // Use an early priority to so that other 'render_block_context' filters have access to the values.
91
89
  add_filter( 'render_block_context', $filter_block_context, 1 );
92
90
 
93
91
  // Render the inner blocks of the Term Template block with `dynamic` set to `false` to prevent calling
94
92
  // `render_callback` and ensure that no wrapper markup is included.
95
- $block_content .= ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
93
+ $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
96
94
 
97
95
  remove_filter( 'render_block_context', $filter_block_context, 1 );
98
96
 
99
97
  // Wrap the render inner blocks in a `li` element with the appropriate term classes.
100
- $term_classes = implode( ' ', array( 'wp-block-term', "term-{$term->term_id}", $term->taxonomy, "taxonomy-{$term->taxonomy}" ) );
98
+ $term_classes = "wp-block-term term-{$term->term_id} {$term->taxonomy} taxonomy-{$term->taxonomy}";
101
99
 
102
100
  $content .= '<li class="' . esc_attr( $term_classes ) . '">' . $block_content . '</li>';
103
101
  }
104
102
 
105
- $classnames = 'wp-block-term-template';
103
+ $classnames = '';
106
104
 
107
105
  if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
108
- $classnames .= ' has-link-color';
106
+ $classnames .= 'has-link-color';
109
107
  }
110
108
 
111
109
  $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) );
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": true,
5
4
  "name": "core/terms-query",
6
5
  "title": "Terms Query",
7
6
  "category": "theme",