@wordpress/block-library 9.11.0 → 9.12.1-next.082ed6819.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 (272) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block-keyboard-shortcuts/index.js +7 -7
  3. package/build/block-keyboard-shortcuts/index.js.map +1 -1
  4. package/build/button/index.js +1 -1
  5. package/build/button/index.js.map +1 -1
  6. package/build/cover/deprecated.js +140 -4
  7. package/build/cover/deprecated.js.map +1 -1
  8. package/build/cover/edit/block-controls.js +1 -1
  9. package/build/cover/edit/block-controls.js.map +1 -1
  10. package/build/cover/edit/cover-placeholder.js +1 -2
  11. package/build/cover/edit/cover-placeholder.js.map +1 -1
  12. package/build/cover/edit/index.js +23 -23
  13. package/build/cover/edit/index.js.map +1 -1
  14. package/build/cover/index.js +10 -10
  15. package/build/cover/index.js.map +1 -1
  16. package/build/cover/save.js +13 -13
  17. package/build/cover/save.js.map +1 -1
  18. package/build/cover/shared.js +6 -7
  19. package/build/cover/shared.js.map +1 -1
  20. package/build/details/index.js +20 -0
  21. package/build/details/index.js.map +1 -1
  22. package/build/file/edit.js +8 -4
  23. package/build/file/edit.js.map +1 -1
  24. package/build/freeform/modal.js +1 -1
  25. package/build/freeform/modal.js.map +1 -1
  26. package/build/gallery/edit.js +1 -1
  27. package/build/gallery/edit.js.map +1 -1
  28. package/build/heading/index.js +1 -7
  29. package/build/heading/index.js.map +1 -1
  30. package/build/home-link/edit.js +20 -36
  31. package/build/home-link/edit.js.map +1 -1
  32. package/build/image/edit.js +1 -1
  33. package/build/image/edit.js.map +1 -1
  34. package/build/image/image.js +144 -78
  35. package/build/image/image.js.map +1 -1
  36. package/build/image/index.js +1 -1
  37. package/build/latest-posts/edit.js +0 -1
  38. package/build/latest-posts/edit.js.map +1 -1
  39. package/build/lock-unlock.js.map +1 -1
  40. package/build/navigation/edit/index.js +2 -23
  41. package/build/navigation/edit/index.js.map +1 -1
  42. package/build/navigation/use-template-part-area-label.js +6 -8
  43. package/build/navigation/use-template-part-area-label.js.map +1 -1
  44. package/build/page-list/index.js +14 -0
  45. package/build/page-list/index.js.map +1 -1
  46. package/build/paragraph/edit.js +26 -25
  47. package/build/paragraph/edit.js.map +1 -1
  48. package/build/post-content/index.js +13 -0
  49. package/build/post-content/index.js.map +1 -1
  50. package/build/post-template/edit.js +11 -0
  51. package/build/post-template/edit.js.map +1 -1
  52. package/build/post-template/index.js +1 -1
  53. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  54. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  55. package/build/query/edit/inspector-controls/index.js +3 -13
  56. package/build/query/edit/inspector-controls/index.js.map +1 -1
  57. package/build/query/edit/pattern-selection-modal.js +0 -3
  58. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  59. package/build/query/edit/query-content.js +10 -12
  60. package/build/query/edit/query-content.js.map +1 -1
  61. package/build/query/index.js +1 -1
  62. package/build/query/utils.js +38 -9
  63. package/build/query/utils.js.map +1 -1
  64. package/build/social-link/edit.js +22 -9
  65. package/build/social-link/edit.js.map +1 -1
  66. package/build/template-part/edit/advanced-controls.js +2 -7
  67. package/build/template-part/edit/advanced-controls.js.map +1 -1
  68. package/build/template-part/edit/index.js +1 -4
  69. package/build/template-part/edit/index.js.map +1 -1
  70. package/build/template-part/edit/selection-modal.js +0 -3
  71. package/build/template-part/edit/selection-modal.js.map +1 -1
  72. package/build/template-part/edit/utils/get-template-part-icon.js +23 -0
  73. package/build/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  74. package/build/template-part/edit/utils/hooks.js +1 -6
  75. package/build/template-part/edit/utils/hooks.js.map +1 -1
  76. package/build/template-part/variations.js +6 -12
  77. package/build/template-part/variations.js.map +1 -1
  78. package/build/video/edit.js +1 -1
  79. package/build/video/edit.js.map +1 -1
  80. package/build/video/tracks-editor.js +135 -123
  81. package/build/video/tracks-editor.js.map +1 -1
  82. package/build-module/block-keyboard-shortcuts/index.js +7 -7
  83. package/build-module/block-keyboard-shortcuts/index.js.map +1 -1
  84. package/build-module/button/index.js +1 -1
  85. package/build-module/button/index.js.map +1 -1
  86. package/build-module/cover/deprecated.js +140 -4
  87. package/build-module/cover/deprecated.js.map +1 -1
  88. package/build-module/cover/edit/block-controls.js +1 -1
  89. package/build-module/cover/edit/block-controls.js.map +1 -1
  90. package/build-module/cover/edit/cover-placeholder.js +1 -2
  91. package/build-module/cover/edit/cover-placeholder.js.map +1 -1
  92. package/build-module/cover/edit/index.js +23 -23
  93. package/build-module/cover/edit/index.js.map +1 -1
  94. package/build-module/cover/index.js +10 -10
  95. package/build-module/cover/index.js.map +1 -1
  96. package/build-module/cover/save.js +13 -13
  97. package/build-module/cover/save.js.map +1 -1
  98. package/build-module/cover/shared.js +6 -7
  99. package/build-module/cover/shared.js.map +1 -1
  100. package/build-module/details/index.js +21 -1
  101. package/build-module/details/index.js.map +1 -1
  102. package/build-module/file/edit.js +8 -4
  103. package/build-module/file/edit.js.map +1 -1
  104. package/build-module/freeform/modal.js +1 -1
  105. package/build-module/freeform/modal.js.map +1 -1
  106. package/build-module/gallery/edit.js +1 -1
  107. package/build-module/gallery/edit.js.map +1 -1
  108. package/build-module/heading/index.js +1 -7
  109. package/build-module/heading/index.js.map +1 -1
  110. package/build-module/home-link/edit.js +23 -39
  111. package/build-module/home-link/edit.js.map +1 -1
  112. package/build-module/image/edit.js +1 -1
  113. package/build-module/image/edit.js.map +1 -1
  114. package/build-module/image/image.js +149 -83
  115. package/build-module/image/image.js.map +1 -1
  116. package/build-module/image/index.js +1 -1
  117. package/build-module/latest-posts/edit.js +0 -1
  118. package/build-module/latest-posts/edit.js.map +1 -1
  119. package/build-module/lock-unlock.js.map +1 -1
  120. package/build-module/navigation/edit/index.js +2 -23
  121. package/build-module/navigation/edit/index.js.map +1 -1
  122. package/build-module/navigation/use-template-part-area-label.js +6 -8
  123. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  124. package/build-module/page-list/index.js +14 -0
  125. package/build-module/page-list/index.js.map +1 -1
  126. package/build-module/paragraph/edit.js +26 -25
  127. package/build-module/paragraph/edit.js.map +1 -1
  128. package/build-module/post-content/index.js +13 -0
  129. package/build-module/post-content/index.js.map +1 -1
  130. package/build-module/post-template/edit.js +11 -0
  131. package/build-module/post-template/edit.js.map +1 -1
  132. package/build-module/post-template/index.js +1 -1
  133. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
  134. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  135. package/build-module/query/edit/inspector-controls/index.js +3 -13
  136. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  137. package/build-module/query/edit/pattern-selection-modal.js +0 -3
  138. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  139. package/build-module/query/edit/query-content.js +10 -12
  140. package/build-module/query/edit/query-content.js.map +1 -1
  141. package/build-module/query/index.js +1 -1
  142. package/build-module/query/utils.js +35 -8
  143. package/build-module/query/utils.js.map +1 -1
  144. package/build-module/social-link/edit.js +24 -11
  145. package/build-module/social-link/edit.js.map +1 -1
  146. package/build-module/template-part/edit/advanced-controls.js +3 -8
  147. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  148. package/build-module/template-part/edit/index.js +1 -4
  149. package/build-module/template-part/edit/index.js.map +1 -1
  150. package/build-module/template-part/edit/selection-modal.js +0 -3
  151. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  152. package/build-module/template-part/edit/utils/get-template-part-icon.js +15 -0
  153. package/build-module/template-part/edit/utils/get-template-part-icon.js.map +1 -0
  154. package/build-module/template-part/edit/utils/hooks.js +1 -6
  155. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  156. package/build-module/template-part/variations.js +5 -11
  157. package/build-module/template-part/variations.js.map +1 -1
  158. package/build-module/video/edit.js +1 -1
  159. package/build-module/video/edit.js.map +1 -1
  160. package/build-module/video/tracks-editor.js +136 -124
  161. package/build-module/video/tracks-editor.js.map +1 -1
  162. package/build-style/cover/editor-rtl.css +3 -5
  163. package/build-style/cover/editor.css +3 -5
  164. package/build-style/cover/style-rtl.css +19 -15
  165. package/build-style/cover/style.css +19 -15
  166. package/build-style/editor-rtl.css +19 -30
  167. package/build-style/editor.css +19 -30
  168. package/build-style/group/editor-rtl.css +0 -10
  169. package/build-style/group/editor.css +0 -10
  170. package/build-style/image/editor-rtl.css +4 -0
  171. package/build-style/image/editor.css +4 -0
  172. package/build-style/image/style-rtl.css +0 -2
  173. package/build-style/image/style.css +0 -2
  174. package/build-style/latest-posts/editor-rtl.css +0 -7
  175. package/build-style/latest-posts/editor.css +0 -7
  176. package/build-style/media-text/style-rtl.css +1 -1
  177. package/build-style/media-text/style.css +1 -1
  178. package/build-style/navigation/style-rtl.css +1 -1
  179. package/build-style/navigation/style.css +1 -1
  180. package/build-style/page-list/style-rtl.css +4 -0
  181. package/build-style/page-list/style.css +4 -0
  182. package/build-style/query/editor-rtl.css +0 -4
  183. package/build-style/query/editor.css +0 -4
  184. package/build-style/search/style-rtl.css +3 -3
  185. package/build-style/search/style.css +3 -3
  186. package/build-style/social-link/editor-rtl.css +4 -4
  187. package/build-style/social-link/editor.css +4 -4
  188. package/build-style/style-rtl.css +28 -22
  189. package/build-style/style.css +28 -22
  190. package/build-style/video/editor-rtl.css +8 -0
  191. package/build-style/video/editor.css +8 -0
  192. package/build-types/lock-unlock.d.ts +2 -0
  193. package/build-types/lock-unlock.d.ts.map +1 -0
  194. package/package.json +39 -39
  195. package/src/block-keyboard-shortcuts/index.js +25 -11
  196. package/src/button/index.js +1 -1
  197. package/src/comments/block.json +3 -9
  198. package/src/cover/deprecated.js +182 -4
  199. package/src/cover/edit/block-controls.js +1 -1
  200. package/src/cover/edit/cover-placeholder.js +0 -3
  201. package/src/cover/edit/index.js +42 -27
  202. package/src/cover/editor.scss +4 -5
  203. package/src/cover/index.js +8 -8
  204. package/src/cover/save.js +27 -20
  205. package/src/cover/shared.js +10 -10
  206. package/src/cover/style.scss +40 -16
  207. package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
  208. package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
  209. package/src/cover/test/edit.js +2 -2
  210. package/src/cover/test/edit.native.js +4 -4
  211. package/src/cover/test/transforms.native.js +4 -4
  212. package/src/details/block.json +1 -0
  213. package/src/details/index.js +23 -1
  214. package/src/file/edit.js +9 -3
  215. package/src/freeform/modal.js +1 -1
  216. package/src/gallery/edit.js +1 -1
  217. package/src/group/editor.scss +0 -12
  218. package/src/heading/block.json +1 -7
  219. package/src/home-link/edit.js +27 -45
  220. package/src/home-link/index.php +0 -3
  221. package/src/image/block.json +1 -1
  222. package/src/image/edit.js +1 -1
  223. package/src/image/editor.scss +4 -0
  224. package/src/image/image.js +200 -109
  225. package/src/image/style.scss +0 -1
  226. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  227. package/src/latest-posts/edit.js +0 -1
  228. package/src/latest-posts/editor.scss +0 -11
  229. package/src/media-text/style.scss +1 -1
  230. package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
  231. package/src/navigation/edit/index.js +3 -30
  232. package/src/navigation/index.php +5 -151
  233. package/src/navigation/style.scss +1 -1
  234. package/src/navigation/use-template-part-area-label.js +10 -10
  235. package/src/page-list/block.json +14 -0
  236. package/src/page-list/style.scss +4 -0
  237. package/src/paragraph/edit.js +20 -17
  238. package/src/pattern/index.php +0 -7
  239. package/src/post-content/block.json +14 -1
  240. package/src/post-template/block.json +2 -1
  241. package/src/post-template/edit.js +19 -0
  242. package/src/query/block.json +1 -1
  243. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -5
  244. package/src/query/edit/inspector-controls/index.js +2 -12
  245. package/src/query/edit/pattern-selection-modal.js +0 -3
  246. package/src/query/edit/query-content.js +9 -17
  247. package/src/query/editor.scss +0 -4
  248. package/src/query/index.php +1 -1
  249. package/src/query/test/utils.js +59 -1
  250. package/src/query/utils.js +43 -15
  251. package/src/rss/index.php +11 -8
  252. package/src/search/index.php +2 -2
  253. package/src/search/style.scss +3 -5
  254. package/src/social-link/edit.js +47 -19
  255. package/src/social-link/editor.scss +6 -7
  256. package/src/template-part/edit/advanced-controls.js +13 -13
  257. package/src/template-part/edit/index.js +1 -4
  258. package/src/template-part/edit/selection-modal.js +0 -3
  259. package/src/template-part/edit/utils/get-template-part-icon.js +20 -0
  260. package/src/template-part/edit/utils/hooks.js +2 -7
  261. package/src/template-part/variations.js +4 -16
  262. package/src/video/edit.js +1 -1
  263. package/src/video/editor.scss +9 -0
  264. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  265. package/src/video/tracks-editor.js +157 -141
  266. package/tsconfig.tsbuildinfo +1 -1
  267. package/build/query/edit/inspector-controls/create-new-post-link.js +0 -40
  268. package/build/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  269. package/build-module/query/edit/inspector-controls/create-new-post-link.js +0 -33
  270. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
  271. package/src/query/edit/inspector-controls/create-new-post-link.js +0 -32
  272. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
@@ -73,33 +73,6 @@ import AccessibleDescription from './accessible-description';
73
73
  import AccessibleMenuDescription from './accessible-menu-description';
74
74
  import { unlock } from '../../lock-unlock';
75
75
 
76
- function useResponsiveMenu( navRef ) {
77
- const [ isResponsiveMenuOpen, setResponsiveMenuVisibility ] =
78
- useState( false );
79
-
80
- useEffect( () => {
81
- if ( ! navRef.current ) {
82
- return;
83
- }
84
-
85
- const htmlElement = navRef.current.ownerDocument.documentElement;
86
-
87
- // Add a `has-modal-open` class to the <html> when the responsive
88
- // menu is open. This reproduces the same behavior of the frontend.
89
- if ( isResponsiveMenuOpen ) {
90
- htmlElement.classList.add( 'has-modal-open' );
91
- } else {
92
- htmlElement.classList.remove( 'has-modal-open' );
93
- }
94
-
95
- return () => {
96
- htmlElement?.classList.remove( 'has-modal-open' );
97
- };
98
- }, [ navRef, isResponsiveMenuOpen ] );
99
-
100
- return [ isResponsiveMenuOpen, setResponsiveMenuVisibility ];
101
- }
102
-
103
76
  function ColorTools( {
104
77
  textColor,
105
78
  setTextColor,
@@ -311,10 +284,8 @@ function Navigation( {
311
284
  __unstableMarkNextChangeAsNotPersistent,
312
285
  } = useDispatch( blockEditorStore );
313
286
 
314
- const navRef = useRef();
315
-
316
287
  const [ isResponsiveMenuOpen, setResponsiveMenuVisibility ] =
317
- useResponsiveMenu( navRef );
288
+ useState( false );
318
289
 
319
290
  const [ overlayMenuPreview, setOverlayMenuPreview ] = useState( false );
320
291
 
@@ -396,6 +367,8 @@ function Navigation( {
396
367
  __unstableMarkNextChangeAsNotPersistent,
397
368
  ] );
398
369
 
370
+ const navRef = useRef();
371
+
399
372
  // The standard HTML5 tag for the block wrapper.
400
373
  const TagName = 'nav';
401
374
 
@@ -344,6 +344,10 @@ class WP_Navigation_Block_Renderer {
344
344
 
345
345
  $navigation_name = $attributes['ariaLabel'] ?? '';
346
346
 
347
+ if ( ! empty( $navigation_name ) ) {
348
+ return $navigation_name;
349
+ }
350
+
347
351
  // Load the navigation post.
348
352
  if ( array_key_exists( 'ref', $attributes ) ) {
349
353
  $navigation_post = get_post( $attributes['ref'] );
@@ -813,7 +817,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
813
817
  ) ) {
814
818
  // Add directives to the parent `<li>`.
815
819
  $tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
816
- $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu" }' );
820
+ $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null }' );
817
821
  $tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
818
822
  $tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
819
823
  $tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
@@ -1516,153 +1520,3 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
1516
1520
 
1517
1521
  return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
1518
1522
  }
1519
-
1520
- /**
1521
- * Insert ignoredHookedBlocks meta into the Navigation block and its inner blocks.
1522
- *
1523
- * Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
1524
- * this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a
1525
- * mock Navigation block wrapper.
1526
- *
1527
- * @since 6.5.0
1528
- *
1529
- * @param array $inner_blocks Parsed inner blocks of a Navigation block.
1530
- * @param WP_Post $post `wp_navigation` post object corresponding to the block.
1531
- * @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
1532
- */
1533
- function block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks, $post ) {
1534
- $mock_navigation_block = block_core_navigation_mock_parsed_block( $inner_blocks, $post );
1535
- $hooked_blocks = get_hooked_blocks();
1536
- $before_block_visitor = null;
1537
- $after_block_visitor = null;
1538
-
1539
- if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
1540
- $before_block_visitor = make_before_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
1541
- $after_block_visitor = make_after_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
1542
- }
1543
-
1544
- return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
1545
- }
1546
-
1547
- /**
1548
- * Updates the post meta with the list of ignored hooked blocks when the navigation is created or updated via the REST API.
1549
- *
1550
- * @access private
1551
- * @since 6.5.0
1552
- *
1553
- * @param stdClass $post Post object.
1554
- * @return stdClass The updated post object.
1555
- */
1556
- function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
1557
- /*
1558
- * In this scenario the user has likely tried to create a navigation via the REST API.
1559
- * In which case we won't have a post ID to work with and store meta against.
1560
- */
1561
- if ( empty( $post->ID ) ) {
1562
- return $post;
1563
- }
1564
-
1565
- /**
1566
- * Skip meta generation when consumers intentionally update specific Navigation fields
1567
- * and omit the content update.
1568
- */
1569
- if ( ! isset( $post->post_content ) ) {
1570
- return $post;
1571
- }
1572
-
1573
- /*
1574
- * We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
1575
- * all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
1576
- */
1577
- $blocks = parse_blocks( $post->post_content );
1578
-
1579
- /*
1580
- * Block Hooks logic requires a `WP_Post` object (rather than the `stdClass` with the updates that
1581
- * we're getting from the `rest_pre_insert_wp_navigation` filter) as its second argument (to be
1582
- * used as context for hooked blocks insertion).
1583
- * We thus have to look it up from the DB,based on `$post->ID`.
1584
- */
1585
- $markup = block_core_navigation_set_ignored_hooked_blocks_metadata( $blocks, get_post( $post->ID ) );
1586
-
1587
- $root_nav_block = parse_blocks( $markup )[0];
1588
- $ignored_hooked_blocks = isset( $root_nav_block['attrs']['metadata']['ignoredHookedBlocks'] )
1589
- ? $root_nav_block['attrs']['metadata']['ignoredHookedBlocks']
1590
- : array();
1591
-
1592
- if ( ! empty( $ignored_hooked_blocks ) ) {
1593
- $existing_ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );
1594
- if ( ! empty( $existing_ignored_hooked_blocks ) ) {
1595
- $existing_ignored_hooked_blocks = json_decode( $existing_ignored_hooked_blocks, true );
1596
- $ignored_hooked_blocks = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) );
1597
- }
1598
- update_post_meta( $post->ID, '_wp_ignored_hooked_blocks', json_encode( $ignored_hooked_blocks ) );
1599
- }
1600
-
1601
- $post->post_content = block_core_navigation_remove_serialized_parent_block( $markup );
1602
- return $post;
1603
- }
1604
-
1605
- /*
1606
- * Before adding our filter, we verify if it's already added in Core.
1607
- * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1608
- * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1609
- */
1610
- $rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ignore_hooked_blocks_meta'; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
1611
-
1612
- /*
1613
- * Do not add the `block_core_navigation_update_ignore_hooked_blocks_meta` filter in the following cases:
1614
- * - If Core has added the `update_ignored_hooked_blocks_postmeta` filter already (WP >= 6.6);
1615
- * - or if the `$rest_insert_wp_navigation_core_callback` filter has already been added.
1616
- */
1617
- if (
1618
- ! has_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' ) &&
1619
- ! has_filter( 'rest_pre_insert_wp_navigation', $rest_insert_wp_navigation_core_callback )
1620
- ) {
1621
- add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' );
1622
- }
1623
-
1624
- /**
1625
- * Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks.
1626
- *
1627
- * @since 6.5.0
1628
- *
1629
- * @param WP_REST_Response $response The response object.
1630
- * @param WP_Post $post Post object.
1631
- * @return WP_REST_Response The response object.
1632
- */
1633
- function block_core_navigation_insert_hooked_blocks_into_rest_response( $response, $post ) {
1634
- if ( ! isset( $response->data['content']['raw'] ) || ! isset( $response->data['content']['rendered'] ) ) {
1635
- return $response;
1636
- }
1637
- $parsed_blocks = parse_blocks( $response->data['content']['raw'] );
1638
- $content = block_core_navigation_insert_hooked_blocks( $parsed_blocks, $post );
1639
-
1640
- // Remove mock Navigation block wrapper.
1641
- $content = block_core_navigation_remove_serialized_parent_block( $content );
1642
-
1643
- $response->data['content']['raw'] = $content;
1644
-
1645
- /** This filter is documented in wp-includes/post-template.php */
1646
- $response->data['content']['rendered'] = apply_filters( 'the_content', $content );
1647
-
1648
- return $response;
1649
- }
1650
-
1651
- /*
1652
- * Before adding our filter, we verify if it's already added in Core.
1653
- * However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
1654
- * Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
1655
- */
1656
- $rest_prepare_wp_navigation_core_callback = 'block_core_navigation_' . 'insert_hooked_blocks_into_rest_response';
1657
-
1658
- /*
1659
- * Do not add the `block_core_navigation_insert_hooked_blocks_into_rest_response` filter in the following cases:
1660
- * - If Core has added the `insert_hooked_blocks_into_rest_response` filter already (WP >= 6.6);
1661
- * - or if the `$rest_prepare_wp_navigation_core_callback` filter has already been added.
1662
- */
1663
- if (
1664
- ! has_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response' ) &&
1665
- ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback )
1666
- ) {
1667
- add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
1668
- }
@@ -510,7 +510,7 @@ button.wp-block-navigation-item__content {
510
510
  padding-top: clamp(1rem, var(--wp--style--root--padding-top), 20rem);
511
511
  padding-right: clamp(1rem, var(--wp--style--root--padding-right), 20rem);
512
512
  padding-bottom: clamp(1rem, var(--wp--style--root--padding-bottom), 20rem);
513
- padding-left: clamp(1rem, var(--wp--style--root--padding-left), 20em);
513
+ padding-left: clamp(1rem, var(--wp--style--root--padding-left), 20rem);
514
514
 
515
515
  // Allow modal to scroll.
516
516
  overflow: auto;
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
11
11
 
12
12
  // TODO: this util should perhaps be refactored somewhere like core-data.
13
13
  import { createTemplatePartId } from '../template-part/edit/utils/create-template-part-id';
14
+ import { getTemplatePartIcon } from '../template-part/edit/utils/get-template-part-icon';
14
15
 
15
16
  export default function useTemplatePartAreaLabel( clientId ) {
16
17
  return useSelect(
@@ -35,16 +36,15 @@ export default function useTemplatePartAreaLabel( clientId ) {
35
36
  return;
36
37
  }
37
38
 
38
- // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
39
- // Blocks can be loaded into a *non-post* block editor.
40
- // This code is lifted from this file:
41
- // packages/block-library/src/template-part/edit/advanced-controls.js
42
- /* eslint-disable @wordpress/data-no-store-string-literals */
43
- const definedAreas =
44
- select(
45
- 'core/editor'
46
- ).__experimentalGetDefaultTemplatePartAreas();
47
- /* eslint-enable @wordpress/data-no-store-string-literals */
39
+ const defaultTemplatePartAreas =
40
+ select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
41
+ ?.default_template_part_areas || [];
42
+
43
+ const definedAreas = defaultTemplatePartAreas.map( ( item ) => ( {
44
+ ...item,
45
+ icon: getTemplatePartIcon( item.icon ),
46
+ } ) );
47
+
48
48
  const { getCurrentTheme, getEditedEntityRecord } =
49
49
  select( coreStore );
50
50
 
@@ -51,6 +51,20 @@
51
51
  },
52
52
  "interactivity": {
53
53
  "clientNavigation": true
54
+ },
55
+ "__experimentalBorder": {
56
+ "radius": true,
57
+ "color": true,
58
+ "width": true,
59
+ "style": true
60
+ },
61
+ "spacing": {
62
+ "padding": true,
63
+ "margin": true,
64
+ "__experimentalDefaultControls": {
65
+ "padding": false,
66
+ "margin": false
67
+ }
54
68
  }
55
69
  },
56
70
  "editorStyle": "wp-block-page-list-editor",
@@ -15,3 +15,7 @@
15
15
  background-color: inherit;
16
16
  }
17
17
  }
18
+ .wp-block-page-list {
19
+ // This block has customizable padding, border-box makes that more predictable.
20
+ box-sizing: border-box;
21
+ }
@@ -70,22 +70,24 @@ function DropCapControl( { clientId, attributes, setAttributes } ) {
70
70
  }
71
71
 
72
72
  return (
73
- <ToolsPanelItem
74
- hasValue={ () => !! dropCap }
75
- label={ __( 'Drop cap' ) }
76
- onDeselect={ () => setAttributes( { dropCap: undefined } ) }
77
- resetAllFilter={ () => ( { dropCap: undefined } ) }
78
- panelId={ clientId }
79
- >
80
- <ToggleControl
81
- __nextHasNoMarginBottom
73
+ <InspectorControls group="typography">
74
+ <ToolsPanelItem
75
+ hasValue={ () => !! dropCap }
82
76
  label={ __( 'Drop cap' ) }
83
- checked={ !! dropCap }
84
- onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
85
- help={ helpText }
86
- disabled={ hasDropCapDisabled( align ) ? true : false }
87
- />
88
- </ToolsPanelItem>
77
+ onDeselect={ () => setAttributes( { dropCap: undefined } ) }
78
+ resetAllFilter={ () => ( { dropCap: undefined } ) }
79
+ panelId={ clientId }
80
+ >
81
+ <ToggleControl
82
+ __nextHasNoMarginBottom
83
+ label={ __( 'Drop cap' ) }
84
+ checked={ !! dropCap }
85
+ onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
86
+ help={ helpText }
87
+ disabled={ hasDropCapDisabled( align ) }
88
+ />
89
+ </ToolsPanelItem>
90
+ </InspectorControls>
89
91
  );
90
92
  }
91
93
 
@@ -96,6 +98,7 @@ function ParagraphBlock( {
96
98
  onRemove,
97
99
  setAttributes,
98
100
  clientId,
101
+ isSelected: isSingleSelected,
99
102
  } ) {
100
103
  const { align, content, direction, dropCap, placeholder } = attributes;
101
104
  const blockProps = useBlockProps( {
@@ -131,13 +134,13 @@ function ParagraphBlock( {
131
134
  />
132
135
  </BlockControls>
133
136
  ) }
134
- <InspectorControls group="typography">
137
+ { isSingleSelected && (
135
138
  <DropCapControl
136
139
  clientId={ clientId }
137
140
  attributes={ attributes }
138
141
  setAttributes={ setAttributes }
139
142
  />
140
- </InspectorControls>
143
+ ) }
141
144
  <RichText
142
145
  identifier="content"
143
146
  tagName="p"
@@ -58,13 +58,6 @@ function render_block_core_pattern( $attributes ) {
58
58
  $pattern = $registry->get_registered( $slug );
59
59
  $content = $pattern['content'];
60
60
 
61
- // Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin.
62
- // This can be removed when the minimum supported WordPress is >= 6.4.
63
- if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) {
64
- $blocks = parse_blocks( $content );
65
- $content = gutenberg_serialize_blocks( $blocks );
66
- }
67
-
68
61
  $seen_refs[ $attributes['slug'] ] = true;
69
62
 
70
63
  $content = do_blocks( $content );
@@ -27,6 +27,7 @@
27
27
  "spacing": {
28
28
  "blockGap": true,
29
29
  "padding": true,
30
+ "margin": true,
30
31
  "__experimentalDefaultControls": {
31
32
  "margin": false,
32
33
  "padding": false
@@ -52,8 +53,20 @@
52
53
  "__experimentalDefaultControls": {
53
54
  "fontSize": true
54
55
  }
56
+ },
57
+ "__experimentalBorder": {
58
+ "radius": true,
59
+ "color": true,
60
+ "width": true,
61
+ "style": true,
62
+ "__experimentalDefaultControls": {
63
+ "radius": true,
64
+ "color": true,
65
+ "width": true,
66
+ "style": true
67
+ }
55
68
  }
56
69
  },
57
70
  "style": "wp-block-post-content",
58
71
  "editorStyle": "wp-block-post-content-editor"
59
- }
72
+ }
@@ -13,7 +13,8 @@
13
13
  "displayLayout",
14
14
  "templateSlug",
15
15
  "previewPostType",
16
- "enhancedPagination"
16
+ "enhancedPagination",
17
+ "postType"
17
18
  ],
18
19
  "supports": {
19
20
  "reusable": false,
@@ -119,6 +119,15 @@ export default function PostTemplateEdit( {
119
119
  _fields: [ 'id' ],
120
120
  slug: templateSlug.replace( 'category-', '' ),
121
121
  } );
122
+ const templateTag =
123
+ inherit &&
124
+ templateSlug?.startsWith( 'tag-' ) &&
125
+ getEntityRecords( 'taxonomy', 'post_tag', {
126
+ context: 'view',
127
+ per_page: 1,
128
+ _fields: [ 'id' ],
129
+ slug: templateSlug.replace( 'tag-', '' ),
130
+ } );
122
131
  const query = {
123
132
  offset: offset || 0,
124
133
  order,
@@ -182,6 +191,16 @@ export default function PostTemplateEdit( {
182
191
  postType = query.postType;
183
192
  } else if ( templateCategory ) {
184
193
  query.categories = templateCategory[ 0 ]?.id;
194
+ } else if ( templateTag ) {
195
+ query.tags = templateTag[ 0 ]?.id;
196
+ } else if (
197
+ templateSlug?.startsWith( 'taxonomy-post_format' )
198
+ ) {
199
+ // Get the post format slug from the template slug by removing the prefix.
200
+ query.format = templateSlug.replace(
201
+ 'taxonomy-post_format-post-format-',
202
+ ''
203
+ );
185
204
  }
186
205
  }
187
206
  // When we preview Query Loop blocks we should prefer the current
@@ -42,7 +42,7 @@
42
42
  "default": false
43
43
  }
44
44
  },
45
- "usesContext": [ "postType" ],
45
+ "usesContext": [ "templateSlug" ],
46
46
  "providesContext": {
47
47
  "queryId": "queryId",
48
48
  "query": "query",
@@ -18,15 +18,13 @@ export default function EnhancedPaginationControl( {
18
18
  const fullPageClientSideNavigation =
19
19
  window.__experimentalFullPageClientSideNavigation;
20
20
 
21
- let help = __( 'Browsing between pages requires a full page reload.' );
21
+ let help = __(
22
+ 'Reload the full page—instead of just the posts list—when visitors navigate between pages.'
23
+ );
22
24
  if ( fullPageClientSideNavigation ) {
23
25
  help = __(
24
26
  'Experimental full-page client-side navigation setting enabled.'
25
27
  );
26
- } else if ( enhancedPagination ) {
27
- help = __(
28
- 'Reload the full page—instead of just the posts list—when visitors navigate between pages.'
29
- );
30
28
  } else if ( hasUnsupportedBlocks ) {
31
29
  help = __(
32
30
  'Enhancement disabled because there are non-compatible blocks inside the Query block.'
@@ -15,7 +15,6 @@ import {
15
15
  import { useSelect } from '@wordpress/data';
16
16
  import { store as coreStore } from '@wordpress/core-data';
17
17
  import { __ } from '@wordpress/i18n';
18
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
19
18
  import { debounce } from '@wordpress/compose';
20
19
  import { useEffect, useState, useCallback } from '@wordpress/element';
21
20
 
@@ -28,11 +27,9 @@ import ParentControl from './parent-control';
28
27
  import { TaxonomyControls } from './taxonomy-controls';
29
28
  import FormatControls from './format-controls';
30
29
  import StickyControl from './sticky-control';
31
- import CreateNewPostLink from './create-new-post-link';
32
30
  import PerPageControl from './per-page-control';
33
31
  import OffsetControl from './offset-controls';
34
32
  import PagesControl from './pages-control';
35
- import { unlock } from '../../../lock-unlock';
36
33
  import {
37
34
  usePostTypes,
38
35
  useIsPostTypeHierarchical,
@@ -42,10 +39,8 @@ import {
42
39
  } from '../../utils';
43
40
  import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
44
41
 
45
- const { BlockInfo } = unlock( blockEditorPrivateApis );
46
-
47
42
  export default function QueryInspectorControls( props ) {
48
- const { attributes, setQuery, setDisplayLayout, isTemplate } = props;
43
+ const { attributes, setQuery, setDisplayLayout, isSingular } = props;
49
44
  const { query, displayLayout } = attributes;
50
45
  const {
51
46
  order,
@@ -118,7 +113,7 @@ export default function QueryInspectorControls( props ) {
118
113
  }, [ querySearch, onChangeDebounced ] );
119
114
 
120
115
  const showInheritControl =
121
- isTemplate && isControlAllowed( allowedControls, 'inherit' );
116
+ ! isSingular && isControlAllowed( allowedControls, 'inherit' );
122
117
  const showPostTypeControl =
123
118
  ! inherit && isControlAllowed( allowedControls, 'postType' );
124
119
  const postTypeControlLabel = __( 'Post type' );
@@ -191,11 +186,6 @@ export default function QueryInspectorControls( props ) {
191
186
 
192
187
  return (
193
188
  <>
194
- { !! postType && (
195
- <BlockInfo>
196
- <CreateNewPostLink postType={ postType } />
197
- </BlockInfo>
198
- ) }
199
189
  { showSettingsPanel && (
200
190
  <PanelBody title={ __( 'Settings' ) }>
201
191
  { showInheritControl && (
@@ -4,7 +4,6 @@
4
4
  import { useState, useMemo } from '@wordpress/element';
5
5
  import { useDispatch } from '@wordpress/data';
6
6
  import { Modal, SearchControl } from '@wordpress/components';
7
- import { useAsyncList } from '@wordpress/compose';
8
7
  import {
9
8
  BlockContextProvider,
10
9
  store as blockEditorStore,
@@ -55,7 +54,6 @@ export default function PatternSelectionModal( {
55
54
  const filteredBlockPatterns = useMemo( () => {
56
55
  return searchPatterns( blockPatterns, searchValue );
57
56
  }, [ blockPatterns, searchValue ] );
58
- const shownBlockPatterns = useAsyncList( filteredBlockPatterns );
59
57
 
60
58
  return (
61
59
  <Modal
@@ -77,7 +75,6 @@ export default function PatternSelectionModal( {
77
75
  <BlockContextProvider value={ blockPreviewContext }>
78
76
  <BlockPatternsList
79
77
  blockPatterns={ filteredBlockPatterns }
80
- shownPatterns={ shownBlockPatterns }
81
78
  onClickPattern={ onBlockPatternSelect }
82
79
  />
83
80
  </BlockContextProvider>
@@ -22,6 +22,7 @@ import EnhancedPaginationControl from './inspector-controls/enhanced-pagination-
22
22
  import QueryToolbar from './query-toolbar';
23
23
  import QueryInspectorControls from './inspector-controls';
24
24
  import EnhancedPaginationModal from './enhanced-pagination-modal';
25
+ import { getQueryContextFromTemplate } from '../utils';
25
26
 
26
27
  const DEFAULTS_POSTS_PER_PAGE = 3;
27
28
 
@@ -42,7 +43,8 @@ export default function QueryContent( {
42
43
  tagName: TagName = 'div',
43
44
  query: { inherit } = {},
44
45
  } = attributes;
45
- const { postType } = context;
46
+ const { templateSlug } = context;
47
+ const { isSingular } = getQueryContextFromTemplate( templateSlug );
46
48
  const { __unstableMarkNextChangeAsNotPersistent } =
47
49
  useDispatch( blockEditorStore );
48
50
  const instanceId = useInstanceId( QueryContent );
@@ -50,16 +52,6 @@ export default function QueryContent( {
50
52
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
51
53
  template: TEMPLATE,
52
54
  } );
53
- const isTemplate = useSelect(
54
- ( select ) => {
55
- const currentTemplate =
56
- select( coreStore ).__experimentalGetTemplateForLink()?.type;
57
- const isInTemplate = 'wp_template' === currentTemplate;
58
- const isInSingularContent = postType !== undefined;
59
- return isInTemplate && ! isInSingularContent;
60
- },
61
- [ postType ]
62
- );
63
55
  const { postsPerPage } = useSelect( ( select ) => {
64
56
  const { getSettings } = select( blockEditorStore );
65
57
  const { getEntityRecord, getEntityRecordEdits, canUser } =
@@ -106,9 +98,9 @@ export default function QueryContent( {
106
98
  } else if ( ! query.perPage && postsPerPage ) {
107
99
  newQuery.perPage = postsPerPage;
108
100
  }
109
- // We need to reset the `inherit` value if not in a template, as queries
110
- // are not inherited when outside a template (e.g. when in singular content).
111
- if ( ! isTemplate && query.inherit ) {
101
+ // We need to reset the `inherit` value if in a singular template, as queries
102
+ // are not inherited when in singular content (e.g. post, page, 404, blank).
103
+ if ( isSingular && query.inherit ) {
112
104
  newQuery.inherit = false;
113
105
  }
114
106
  if ( !! Object.keys( newQuery ).length ) {
@@ -117,10 +109,10 @@ export default function QueryContent( {
117
109
  }
118
110
  }, [
119
111
  query.perPage,
112
+ query.inherit,
120
113
  postsPerPage,
121
114
  inherit,
122
- isTemplate,
123
- query.inherit,
115
+ isSingular,
124
116
  __unstableMarkNextChangeAsNotPersistent,
125
117
  updateQuery,
126
118
  ] );
@@ -167,7 +159,7 @@ export default function QueryContent( {
167
159
  setDisplayLayout={ updateDisplayLayout }
168
160
  setAttributes={ setAttributes }
169
161
  clientId={ clientId }
170
- isTemplate={ isTemplate }
162
+ isSingular={ isSingular }
171
163
  />
172
164
  </InspectorControls>
173
165
  <BlockControls>
@@ -6,10 +6,6 @@
6
6
  }
7
7
  }
8
8
 
9
- .wp-block-query__create-new-link {
10
- padding: 0 $grid-unit-20 $grid-unit-20 52px;
11
- }
12
-
13
9
  .block-library-query__pattern-selection-content .block-editor-block-patterns-list {
14
10
  display: grid;
15
11
  grid-template-columns: 1fr 1fr 1fr;
@@ -79,7 +79,7 @@ add_action( 'init', 'register_block_core_query' );
79
79
  * @since 6.4.0
80
80
  *
81
81
  * @param array $parsed_block The block being rendered.
82
- * @return string Returns the parsed block, unmodified.
82
+ * @return array Returns the parsed block, unmodified.
83
83
  */
84
84
  function block_core_query_disable_enhanced_pagination( $parsed_block ) {
85
85
  static $enhanced_query_stack = array();