@wordpress/block-library 7.11.0 → 7.12.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 (261) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +7 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/archives/index.js +4 -0
  5. package/build/archives/index.js.map +1 -1
  6. package/build/block/edit.js +4 -2
  7. package/build/block/edit.js.map +1 -1
  8. package/build/block/edit.native.js +4 -2
  9. package/build/block/edit.native.js.map +1 -1
  10. package/build/calendar/edit.js +12 -5
  11. package/build/calendar/edit.js.map +1 -1
  12. package/build/columns/edit.native.js +2 -1
  13. package/build/columns/edit.native.js.map +1 -1
  14. package/build/cover/edit/resizable-cover.js +6 -0
  15. package/build/cover/edit/resizable-cover.js.map +1 -1
  16. package/build/group/transforms.js +5 -0
  17. package/build/group/transforms.js.map +1 -1
  18. package/build/index.native.js +17 -4
  19. package/build/index.native.js.map +1 -1
  20. package/build/list/index.js +6 -0
  21. package/build/list/index.js.map +1 -1
  22. package/build/list/v2/edit.js +16 -5
  23. package/build/list/v2/edit.js.map +1 -1
  24. package/build/list/v2/tag-name.js +31 -0
  25. package/build/list/v2/tag-name.js.map +1 -0
  26. package/build/list/v2/tag-name.native.js +32 -0
  27. package/build/list/v2/tag-name.native.js.map +1 -0
  28. package/build/list/v2/transforms.js +1 -11
  29. package/build/list/v2/transforms.js.map +1 -1
  30. package/build/list-item/edit.js +1 -0
  31. package/build/list-item/edit.js.map +1 -1
  32. package/build/list-item/edit.native.js +158 -0
  33. package/build/list-item/edit.native.js.map +1 -0
  34. package/build/list-item/icons.native.js +53 -0
  35. package/build/list-item/icons.native.js.map +1 -0
  36. package/build/list-item/list-style-type.native.js +136 -0
  37. package/build/list-item/list-style-type.native.js.map +1 -0
  38. package/build/media-text/deprecated.js +188 -66
  39. package/build/media-text/deprecated.js.map +1 -1
  40. package/build/media-text/edit.js +2 -1
  41. package/build/media-text/edit.js.map +1 -1
  42. package/build/media-text/media-container.js +1 -1
  43. package/build/media-text/media-container.js.map +1 -1
  44. package/build/navigation/edit/index.js +68 -123
  45. package/build/navigation/edit/index.js.map +1 -1
  46. package/build/navigation/edit/navigation-menu-selector.js +11 -14
  47. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  48. package/build/navigation/edit/placeholder/index.js +4 -2
  49. package/build/navigation/edit/placeholder/index.js.map +1 -1
  50. package/build/navigation/edit/responsive-wrapper.js +13 -3
  51. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  52. package/build/navigation/edit/use-create-navigation-menu.js +5 -1
  53. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  54. package/build/navigation/edit/use-inner-blocks.js +43 -0
  55. package/build/navigation/edit/use-inner-blocks.js.map +1 -0
  56. package/build/navigation/edit/utils.js +28 -0
  57. package/build/navigation/edit/utils.js.map +1 -0
  58. package/build/navigation/use-navigation-menu.js +7 -3
  59. package/build/navigation/use-navigation-menu.js.map +1 -1
  60. package/build/post-author/edit.js +5 -2
  61. package/build/post-author/edit.js.map +1 -1
  62. package/build/post-author-biography/edit.js +7 -1
  63. package/build/post-author-biography/edit.js.map +1 -1
  64. package/build/post-content/edit.js +4 -2
  65. package/build/post-content/edit.js.map +1 -1
  66. package/build/post-featured-image/edit.js +16 -2
  67. package/build/post-featured-image/edit.js.map +1 -1
  68. package/build/post-featured-image/index.js +9 -0
  69. package/build/post-featured-image/index.js.map +1 -1
  70. package/build/query/edit/inspector-controls/index.js +42 -9
  71. package/build/query/edit/inspector-controls/index.js.map +1 -1
  72. package/build/query/edit/inspector-controls/taxonomy-controls.js +21 -14
  73. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  74. package/build/query-title/edit.js +20 -7
  75. package/build/query-title/edit.js.map +1 -1
  76. package/build/query-title/index.js +4 -0
  77. package/build/query-title/index.js.map +1 -1
  78. package/build/query-title/variations.js +10 -0
  79. package/build/query-title/variations.js.map +1 -1
  80. package/build/quote/transforms.js +2 -2
  81. package/build/quote/transforms.js.map +1 -1
  82. package/build/separator/edit.js +1 -1
  83. package/build/separator/edit.js.map +1 -1
  84. package/build/social-links/edit.js +1 -0
  85. package/build/social-links/edit.js.map +1 -1
  86. package/build/template-part/edit/index.js +4 -2
  87. package/build/template-part/edit/index.js.map +1 -1
  88. package/build-module/archives/edit.js +7 -0
  89. package/build-module/archives/edit.js.map +1 -1
  90. package/build-module/archives/index.js +4 -0
  91. package/build-module/archives/index.js.map +1 -1
  92. package/build-module/block/edit.js +5 -3
  93. package/build-module/block/edit.js.map +1 -1
  94. package/build-module/block/edit.native.js +5 -3
  95. package/build-module/block/edit.native.js.map +1 -1
  96. package/build-module/calendar/edit.js +12 -4
  97. package/build-module/calendar/edit.js.map +1 -1
  98. package/build-module/columns/edit.native.js +3 -2
  99. package/build-module/columns/edit.native.js.map +1 -1
  100. package/build-module/cover/edit/resizable-cover.js +6 -0
  101. package/build-module/cover/edit/resizable-cover.js.map +1 -1
  102. package/build-module/group/transforms.js +5 -0
  103. package/build-module/group/transforms.js.map +1 -1
  104. package/build-module/index.native.js +16 -4
  105. package/build-module/index.native.js.map +1 -1
  106. package/build-module/list/index.js +1 -1
  107. package/build-module/list/index.js.map +1 -1
  108. package/build-module/list/v2/edit.js +15 -5
  109. package/build-module/list/v2/edit.js.map +1 -1
  110. package/build-module/list/v2/tag-name.js +21 -0
  111. package/build-module/list/v2/tag-name.js.map +1 -0
  112. package/build-module/list/v2/tag-name.native.js +21 -0
  113. package/build-module/list/v2/tag-name.native.js.map +1 -0
  114. package/build-module/list/v2/transforms.js +1 -10
  115. package/build-module/list/v2/transforms.js.map +1 -1
  116. package/build-module/list-item/edit.js +1 -3
  117. package/build-module/list-item/edit.js.map +1 -1
  118. package/build-module/list-item/edit.native.js +141 -0
  119. package/build-module/list-item/edit.native.js.map +1 -0
  120. package/build-module/list-item/icons.native.js +37 -0
  121. package/build-module/list-item/icons.native.js.map +1 -0
  122. package/build-module/list-item/list-style-type.native.js +124 -0
  123. package/build-module/list-item/list-style-type.native.js.map +1 -0
  124. package/build-module/media-text/deprecated.js +189 -65
  125. package/build-module/media-text/deprecated.js.map +1 -1
  126. package/build-module/media-text/edit.js +2 -1
  127. package/build-module/media-text/edit.js.map +1 -1
  128. package/build-module/media-text/media-container.js +1 -1
  129. package/build-module/media-text/media-container.js.map +1 -1
  130. package/build-module/navigation/edit/index.js +66 -122
  131. package/build-module/navigation/edit/index.js.map +1 -1
  132. package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
  133. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  134. package/build-module/navigation/edit/placeholder/index.js +4 -2
  135. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  136. package/build-module/navigation/edit/responsive-wrapper.js +12 -3
  137. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  138. package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
  139. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  140. package/build-module/navigation/edit/use-inner-blocks.js +33 -0
  141. package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
  142. package/build-module/navigation/edit/utils.js +21 -0
  143. package/build-module/navigation/edit/utils.js.map +1 -0
  144. package/build-module/navigation/use-navigation-menu.js +7 -3
  145. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  146. package/build-module/post-author/edit.js +5 -2
  147. package/build-module/post-author/edit.js.map +1 -1
  148. package/build-module/post-author-biography/edit.js +6 -1
  149. package/build-module/post-author-biography/edit.js.map +1 -1
  150. package/build-module/post-content/edit.js +5 -3
  151. package/build-module/post-content/edit.js.map +1 -1
  152. package/build-module/post-featured-image/edit.js +17 -3
  153. package/build-module/post-featured-image/edit.js.map +1 -1
  154. package/build-module/post-featured-image/index.js +9 -0
  155. package/build-module/post-featured-image/index.js.map +1 -1
  156. package/build-module/query/edit/inspector-controls/index.js +42 -9
  157. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  158. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +16 -12
  159. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  160. package/build-module/query-title/edit.js +20 -8
  161. package/build-module/query-title/edit.js.map +1 -1
  162. package/build-module/query-title/index.js +4 -0
  163. package/build-module/query-title/index.js.map +1 -1
  164. package/build-module/query-title/variations.js +10 -0
  165. package/build-module/query-title/variations.js.map +1 -1
  166. package/build-module/quote/transforms.js +3 -3
  167. package/build-module/quote/transforms.js.map +1 -1
  168. package/build-module/separator/edit.js +1 -1
  169. package/build-module/separator/edit.js.map +1 -1
  170. package/build-module/social-links/edit.js +1 -0
  171. package/build-module/social-links/edit.js.map +1 -1
  172. package/build-module/template-part/edit/index.js +5 -3
  173. package/build-module/template-part/edit/index.js.map +1 -1
  174. package/build-style/editor-rtl.css +10 -0
  175. package/build-style/editor.css +10 -0
  176. package/build-style/latest-posts/editor-rtl.css +3 -0
  177. package/build-style/latest-posts/editor.css +3 -0
  178. package/build-style/navigation/style-rtl.css +17 -19
  179. package/build-style/navigation/style.css +17 -19
  180. package/build-style/query/editor-rtl.css +7 -0
  181. package/build-style/query/editor.css +7 -0
  182. package/build-style/query-pagination/style-rtl.css +6 -0
  183. package/build-style/query-pagination/style.css +6 -0
  184. package/build-style/search/style-rtl.css +2 -0
  185. package/build-style/search/style.css +2 -0
  186. package/build-style/style-rtl.css +26 -19
  187. package/build-style/style.css +26 -19
  188. package/build-style/tag-cloud/style-rtl.css +1 -0
  189. package/build-style/tag-cloud/style.css +1 -0
  190. package/package.json +28 -29
  191. package/src/archives/block.json +4 -0
  192. package/src/archives/edit.js +12 -1
  193. package/src/archives/index.php +5 -3
  194. package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
  195. package/src/block/edit.js +4 -4
  196. package/src/block/edit.native.js +4 -4
  197. package/src/calendar/edit.js +11 -4
  198. package/src/columns/edit.native.js +4 -2
  199. package/src/cover/edit/resizable-cover.js +6 -0
  200. package/src/cover/index.php +2 -2
  201. package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
  202. package/src/group/transforms.js +7 -0
  203. package/src/home-link/index.php +8 -17
  204. package/src/image/test/edit.native.js +6 -10
  205. package/src/index.native.js +15 -2
  206. package/src/latest-posts/editor.scss +5 -0
  207. package/src/list/index.js +1 -1
  208. package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
  209. package/src/list/test/edit.native.js +511 -7
  210. package/src/list/v2/edit.js +12 -4
  211. package/src/list/v2/tag-name.js +13 -0
  212. package/src/list/v2/tag-name.native.js +12 -0
  213. package/src/list/v2/transforms.js +1 -9
  214. package/src/list-item/edit.js +1 -1
  215. package/src/list-item/edit.native.js +148 -0
  216. package/src/list-item/icons.native.js +34 -0
  217. package/src/list-item/list-style-type.native.js +139 -0
  218. package/src/list-item/style.native.scss +45 -0
  219. package/src/media-text/deprecated.js +561 -415
  220. package/src/media-text/edit.js +1 -0
  221. package/src/media-text/media-container.js +3 -1
  222. package/src/media-text/test/media-container.js +24 -0
  223. package/src/navigation/edit/index.js +83 -164
  224. package/src/navigation/edit/navigation-menu-selector.js +12 -26
  225. package/src/navigation/edit/placeholder/index.js +4 -2
  226. package/src/navigation/edit/responsive-wrapper.js +24 -3
  227. package/src/navigation/edit/use-create-navigation-menu.js +4 -0
  228. package/src/navigation/edit/use-inner-blocks.js +39 -0
  229. package/src/navigation/edit/utils.js +30 -0
  230. package/src/navigation/index.php +6 -0
  231. package/src/navigation/style.scss +12 -22
  232. package/src/navigation/use-navigation-menu.js +9 -5
  233. package/src/navigation-link/index.php +1 -1
  234. package/src/navigation-submenu/index.php +1 -1
  235. package/src/page-list/index.php +4 -4
  236. package/src/post-author/edit.js +6 -3
  237. package/src/post-author-biography/edit.js +4 -1
  238. package/src/post-content/edit.js +4 -4
  239. package/src/post-featured-image/block.json +9 -0
  240. package/src/post-featured-image/edit.js +23 -1
  241. package/src/post-featured-image/index.php +3 -1
  242. package/src/post-title/index.php +2 -1
  243. package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -2
  244. package/src/query/edit/inspector-controls/index.js +129 -65
  245. package/src/query/edit/inspector-controls/taxonomy-controls.js +17 -10
  246. package/src/query/editor.scss +9 -0
  247. package/src/query-pagination/style.scss +14 -0
  248. package/src/query-title/block.json +4 -0
  249. package/src/query-title/edit.js +33 -6
  250. package/src/query-title/index.php +17 -1
  251. package/src/query-title/variations.js +13 -0
  252. package/src/quote/transforms.js +3 -7
  253. package/src/search/style.scss +2 -0
  254. package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
  255. package/src/separator/edit.js +1 -1
  256. package/src/separator/test/edit.js +5 -3
  257. package/src/site-title/index.php +8 -9
  258. package/src/social-link/index.php +1 -1
  259. package/src/social-links/edit.js +1 -0
  260. package/src/tag-cloud/style.scss +1 -0
  261. package/src/template-part/edit/index.js +4 -4
@@ -0,0 +1,30 @@
1
+ function getComputedStyle( node ) {
2
+ return node.ownerDocument.defaultView.getComputedStyle( node );
3
+ }
4
+
5
+ export function detectColors(
6
+ colorsDetectionElement,
7
+ setColor,
8
+ setBackground
9
+ ) {
10
+ if ( ! colorsDetectionElement ) {
11
+ return;
12
+ }
13
+ setColor( getComputedStyle( colorsDetectionElement ).color );
14
+
15
+ let backgroundColorNode = colorsDetectionElement;
16
+ let backgroundColor =
17
+ getComputedStyle( backgroundColorNode ).backgroundColor;
18
+ while (
19
+ backgroundColor === 'rgba(0, 0, 0, 0)' &&
20
+ backgroundColorNode.parentNode &&
21
+ backgroundColorNode.parentNode.nodeType ===
22
+ backgroundColorNode.parentNode.ELEMENT_NODE
23
+ ) {
24
+ backgroundColorNode = backgroundColorNode.parentNode;
25
+ backgroundColor =
26
+ getComputedStyle( backgroundColorNode ).backgroundColor;
27
+ }
28
+
29
+ setBackground( backgroundColor );
30
+ }
@@ -472,6 +472,12 @@ function render_block_core_navigation( $attributes, $content, $block ) {
472
472
  return '';
473
473
  }
474
474
 
475
+ // Only published posts are valid. If this is changed then a corresponding change
476
+ // must also be implemented in `use-navigation-menu.js`.
477
+ if ( 'publish' !== $navigation_post->post_status ) {
478
+ return '';
479
+ }
480
+
475
481
  $nav_menu_name = $navigation_post->post_title;
476
482
 
477
483
  if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
@@ -45,9 +45,6 @@ $navigation-icon-size: 24px;
45
45
  // but still allow them to be overridden by user-set colors.
46
46
  .wp-block-navigation-item__content {
47
47
  display: block;
48
-
49
- // Set the default menu item padding to zero, to allow text-only buttons.
50
- padding: 0;
51
48
  }
52
49
 
53
50
  // The following rules provide class based application of user selected text
@@ -154,10 +151,7 @@ $navigation-icon-size: 24px;
154
151
  // Styles for submenu flyout.
155
152
  // These are separated out with reduced specificity to allow better inheritance from Global Styles.
156
153
  .wp-block-navigation .has-child {
157
- // We use :where to keep specificity minimal, yet still scope it to only the navigation block.
158
- // That way if padding is set in theme.json, it still wins.
159
- // https://css-tricks.com/almanac/selectors/w/where/
160
- :where(.wp-block-navigation__submenu-container) {
154
+ .wp-block-navigation__submenu-container {
161
155
  background-color: inherit;
162
156
  color: inherit;
163
157
  position: absolute;
@@ -233,7 +227,7 @@ $navigation-icon-size: 24px;
233
227
 
234
228
  // Custom menu items.
235
229
  // Show submenus on hover unless they open on click.
236
- &:where(:not(.open-on-click)):hover > .wp-block-navigation__submenu-container {
230
+ &:not(.open-on-click):hover > .wp-block-navigation__submenu-container {
237
231
  visibility: visible;
238
232
  overflow: visible;
239
233
  opacity: 1;
@@ -243,7 +237,7 @@ $navigation-icon-size: 24px;
243
237
  }
244
238
 
245
239
  // Keep submenus open when focus is within.
246
- &:where(:not(.open-on-click):not(.open-on-hover-click)):focus-within > .wp-block-navigation__submenu-container {
240
+ &:not(.open-on-click):not(.open-on-hover-click):focus-within > .wp-block-navigation__submenu-container {
247
241
  visibility: visible;
248
242
  overflow: visible;
249
243
  opacity: 1;
@@ -339,17 +333,6 @@ button.wp-block-navigation-item__content {
339
333
  gap: inherit;
340
334
  }
341
335
 
342
- // Menu items with background.
343
- // We use :where to keep specificity minimal, yet still scope it to only the navigation block.
344
- // That way if padding is set in theme.json, it still wins.
345
- // https://css-tricks.com/almanac/selectors/w/where/
346
- .wp-block-navigation:where(.has-background) {
347
- &,
348
- .wp-block-navigation .wp-block-page-list,
349
- .wp-block-navigation__container {
350
- gap: inherit;
351
- }
352
- }
353
336
 
354
337
  /**
355
338
  * Paddings
@@ -361,15 +344,18 @@ button.wp-block-navigation-item__content {
361
344
 
362
345
  // When the menu has a background, items have paddings, reduce margins to compensate.
363
346
  // Treat margins and paddings differently when the block has a background.
364
- .wp-block-navigation:where(.has-background) .wp-block-navigation-item__content {
347
+ :where(.wp-block-navigation.has-background .wp-block-navigation-link a:not(.wp-element-button)),
348
+ :where(.wp-block-navigation.has-background .wp-block-navigation-submenu a:not(.wp-element-button)) {
365
349
  padding: 0.5em 1em;
366
350
  }
367
351
 
368
352
  // Provide a default padding for submenus who should always have some, regardless of the top level menu items.
369
- .wp-block-navigation :where(.wp-block-navigation__submenu-container) .wp-block-navigation-item__content {
353
+ :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-link a:not(.wp-element-button)),
354
+ :where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button)) {
370
355
  padding: 0.5em 1em;
371
356
  }
372
357
 
358
+
373
359
  /**
374
360
  * Justifications.
375
361
  */
@@ -452,6 +438,10 @@ button.wp-block-navigation-item__content {
452
438
  right: 0;
453
439
  bottom: 0;
454
440
 
441
+ .wp-block-navigation-link a {
442
+ color: inherit;
443
+ }
444
+
455
445
  .wp-block-navigation__responsive-container-content {
456
446
  display: flex;
457
447
  flex-wrap: var(--navigation-layout-wrap, wrap);
@@ -99,15 +99,19 @@ function selectExistingMenu( select, ref ) {
99
99
  args
100
100
  );
101
101
 
102
+ // Only published Navigation posts are considered valid.
103
+ // If this is changed then a corresponding change must also be made
104
+ // in the index.php file.
105
+ const isNavigationMenuPublished = editedNavigationMenu.status === 'publish';
106
+
102
107
  return {
103
108
  isNavigationMenuResolved: hasResolvedNavigationMenu,
104
- isNavigationMenuMissing: hasResolvedNavigationMenu && ! navigationMenu,
109
+ isNavigationMenuMissing:
110
+ hasResolvedNavigationMenu &&
111
+ ( ! navigationMenu || ! isNavigationMenuPublished ),
105
112
 
106
113
  // getEditedEntityRecord will return the post regardless of status.
107
114
  // Therefore if the found post is not published then we should ignore it.
108
- navigationMenu:
109
- editedNavigationMenu.status === 'publish'
110
- ? editedNavigationMenu
111
- : null,
115
+ navigationMenu: isNavigationMenuPublished ? editedNavigationMenu : null,
112
116
  };
113
117
  }
@@ -150,7 +150,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
150
150
 
151
151
  $css_classes = trim( implode( ' ', $classes ) );
152
152
  $has_submenu = count( $block->inner_blocks ) > 0;
153
- $is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
153
+ $is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
154
154
 
155
155
  $wrapper_attributes = get_block_wrapper_attributes(
156
156
  array(
@@ -148,7 +148,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
148
148
 
149
149
  $css_classes = trim( implode( ' ', $classes ) );
150
150
  $has_submenu = count( $block->inner_blocks ) > 0;
151
- $is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
151
+ $is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
152
152
 
153
153
  $show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
154
154
  $open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
@@ -328,9 +328,9 @@ function render_block_core_page_list( $attributes, $content, $block ) {
328
328
  );
329
329
  }
330
330
 
331
- /**
332
- * Registers the `core/pages` block on server.
333
- */
331
+ /**
332
+ * Registers the `core/pages` block on server.
333
+ */
334
334
  function register_block_core_page_list() {
335
335
  register_block_type_from_metadata(
336
336
  __DIR__ . '/page-list',
@@ -339,4 +339,4 @@ function register_block_core_page_list() {
339
339
  )
340
340
  );
341
341
  }
342
- add_action( 'init', 'register_block_core_page_list' );
342
+ add_action( 'init', 'register_block_core_page_list' );
@@ -162,9 +162,12 @@ function PostAuthorEdit( {
162
162
  { authorDetails?.name || __( 'Post Author' ) }
163
163
  </p>
164
164
  { showBio && (
165
- <p className="wp-block-post-author__bio">
166
- { authorDetails?.description }
167
- </p>
165
+ <p
166
+ className="wp-block-post-author__bio"
167
+ dangerouslySetInnerHTML={ {
168
+ __html: authorDetails?.description,
169
+ } }
170
+ />
168
171
  ) }
169
172
  </div>
170
173
  </div>
@@ -55,7 +55,10 @@ function PostAuthorBiographyEdit( {
55
55
  } }
56
56
  />
57
57
  </BlockControls>
58
- <div { ...blockProps }> { displayAuthorBiography } </div>
58
+ <div
59
+ { ...blockProps }
60
+ dangerouslySetInnerHTML={ { __html: displayAuthorBiography } }
61
+ />
59
62
  </>
60
63
  );
61
64
  }
@@ -7,7 +7,8 @@ import {
7
7
  useBlockProps,
8
8
  useInnerBlocksProps,
9
9
  useSetting,
10
- __experimentalUseNoRecursiveRenders as useNoRecursiveRenders,
10
+ __experimentalRecursionProvider as RecursionProvider,
11
+ __experimentalUseHasRecursion as useHasRecursion,
11
12
  store as blockEditorStore,
12
13
  Warning,
13
14
  } from '@wordpress/block-editor';
@@ -118,15 +119,14 @@ function RecursionError() {
118
119
  export default function PostContentEdit( { context, attributes } ) {
119
120
  const { postId: contextPostId, postType: contextPostType } = context;
120
121
  const { layout = {} } = attributes;
121
- const [ hasAlreadyRendered, RecursionProvider ] =
122
- useNoRecursiveRenders( contextPostId );
122
+ const hasAlreadyRendered = useHasRecursion( contextPostId );
123
123
 
124
124
  if ( contextPostId && contextPostType && hasAlreadyRendered ) {
125
125
  return <RecursionError />;
126
126
  }
127
127
 
128
128
  return (
129
- <RecursionProvider>
129
+ <RecursionProvider uniqueId={ contextPostId }>
130
130
  { contextPostId && contextPostType ? (
131
131
  <Content context={ context } layout={ layout } />
132
132
  ) : (
@@ -23,6 +23,15 @@
23
23
  },
24
24
  "sizeSlug": {
25
25
  "type": "string"
26
+ },
27
+ "rel": {
28
+ "type": "string",
29
+ "attribute": "rel",
30
+ "default": ""
31
+ },
32
+ "linkTarget": {
33
+ "type": "string",
34
+ "default": "_self"
26
35
  }
27
36
  },
28
37
  "usesContext": [ "postId", "postType", "queryId" ],
@@ -9,6 +9,7 @@ import {
9
9
  PanelBody,
10
10
  Placeholder,
11
11
  Button,
12
+ TextControl,
12
13
  } from '@wordpress/components';
13
14
  import {
14
15
  InspectorControls,
@@ -53,7 +54,8 @@ function PostFeaturedImageDisplay( {
53
54
  context: { postId, postType: postTypeSlug, queryId },
54
55
  } ) {
55
56
  const isDescendentOfQueryLoop = Number.isFinite( queryId );
56
- const { isLink, height, width, scale, sizeSlug } = attributes;
57
+ const { isLink, height, width, scale, sizeSlug, rel, linkTarget } =
58
+ attributes;
57
59
  const [ featuredImage, setFeaturedImage ] = useEntityProp(
58
60
  'postType',
59
61
  postTypeSlug,
@@ -128,6 +130,26 @@ function PostFeaturedImageDisplay( {
128
130
  onChange={ () => setAttributes( { isLink: ! isLink } ) }
129
131
  checked={ isLink }
130
132
  />
133
+ { isLink && (
134
+ <>
135
+ <ToggleControl
136
+ label={ __( 'Open in new tab' ) }
137
+ onChange={ ( value ) =>
138
+ setAttributes( {
139
+ linkTarget: value ? '_blank' : '_self',
140
+ } )
141
+ }
142
+ checked={ linkTarget === '_blank' }
143
+ />
144
+ <TextControl
145
+ label={ __( 'Link rel' ) }
146
+ value={ rel }
147
+ onChange={ ( newRel ) =>
148
+ setAttributes( { rel: newRel } )
149
+ }
150
+ />
151
+ </>
152
+ ) }
131
153
  </PanelBody>
132
154
  </InspectorControls>
133
155
  </>
@@ -29,7 +29,9 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
29
29
  }
30
30
  $wrapper_attributes = get_block_wrapper_attributes();
31
31
  if ( $is_link ) {
32
- $featured_image = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $featured_image );
32
+ $link_target = $attributes['linkTarget'];
33
+ $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
34
+ $featured_image = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $link_target ), $rel, $featured_image );
33
35
  }
34
36
 
35
37
  $has_width = ! empty( $attributes['width'] );
@@ -34,7 +34,8 @@ function render_block_core_post_title( $attributes, $content, $block ) {
34
34
  }
35
35
 
36
36
  if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
37
- $title = sprintf( '<a href="%1$s" target="%2$s" rel="%3$s">%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), esc_attr( $attributes['rel'] ), $title );
37
+ $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
38
+ $title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
38
39
  }
39
40
  $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
40
41
 
@@ -10,7 +10,14 @@ exports[`core/more/edit/native should match snapshot when content is empty 1`] =
10
10
  ]
11
11
  }
12
12
  >
13
- <View>
13
+ <View
14
+ style={
15
+ Array [
16
+ undefined,
17
+ undefined,
18
+ ]
19
+ }
20
+ >
14
21
  <TextInput
15
22
  accessibilityLabel="Text input. Empty"
16
23
  activeFormats={Array []}
@@ -50,7 +57,14 @@ exports[`core/more/edit/native should match snapshot when content is not empty 1
50
57
  ]
51
58
  }
52
59
  >
53
- <View>
60
+ <View
61
+ style={
62
+ Array [
63
+ undefined,
64
+ undefined,
65
+ ]
66
+ }
67
+ >
54
68
  <TextInput
55
69
  accessibilityLabel="Text input. <pre>Hello World!</pre>"
56
70
  activeFormats={Array []}
@@ -13,6 +13,8 @@ import {
13
13
  RangeControl,
14
14
  ToggleControl,
15
15
  Notice,
16
+ __experimentalToolsPanel as ToolsPanel,
17
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
18
  } from '@wordpress/components';
17
19
  import { __ } from '@wordpress/i18n';
18
20
  import { InspectorControls } from '@wordpress/block-editor';
@@ -26,7 +28,7 @@ import { store as coreStore } from '@wordpress/core-data';
26
28
  import OrderControl from './order-control';
27
29
  import AuthorControl from './author-control';
28
30
  import ParentControl from './parent-control';
29
- import TaxonomyControls from './taxonomy-controls';
31
+ import { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';
30
32
  import StickyControl from './sticky-control';
31
33
  import { usePostTypes } from '../../utils';
32
34
 
@@ -57,6 +59,7 @@ export default function QueryInspectorControls( {
57
59
  } = query;
58
60
  const [ showSticky, setShowSticky ] = useState( postType === 'post' );
59
61
  const { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();
62
+ const taxonomiesInfo = useTaxonomiesInfo( postType );
60
63
  const isPostTypeHierarchical = useIsPostTypeHierarchical( postType );
61
64
  useEffect( () => {
62
65
  setShowSticky( postType === 'post' );
@@ -100,78 +103,139 @@ export default function QueryInspectorControls( {
100
103
  return onChangeDebounced.cancel;
101
104
  }, [ querySearch, onChangeDebounced ] );
102
105
  return (
103
- <InspectorControls>
104
- <PanelBody title={ __( 'Settings' ) }>
105
- <ToggleControl
106
- label={ __( 'Inherit query from template' ) }
107
- help={ __(
108
- 'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
109
- ) }
110
- checked={ !! inherit }
111
- onChange={ ( value ) => setQuery( { inherit: !! value } ) }
112
- />
113
- { ! inherit && (
114
- <SelectControl
115
- options={ postTypesSelectOptions }
116
- value={ postType }
117
- label={ __( 'Post type' ) }
118
- onChange={ onPostTypeChange }
106
+ <>
107
+ <InspectorControls>
108
+ <PanelBody title={ __( 'Settings' ) }>
109
+ <ToggleControl
110
+ label={ __( 'Inherit query from template' ) }
119
111
  help={ __(
120
- 'WordPress contains different types of content and they are divided into collections called "Post types". By default there are a few different ones such as blog posts and pages, but plugins could add more.'
112
+ 'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
121
113
  ) }
114
+ checked={ !! inherit }
115
+ onChange={ ( value ) =>
116
+ setQuery( { inherit: !! value } )
117
+ }
122
118
  />
123
- ) }
124
- { displayLayout?.type === 'flex' && (
125
- <>
126
- <RangeControl
127
- label={ __( 'Columns' ) }
128
- value={ displayLayout.columns }
129
- onChange={ ( value ) =>
130
- setDisplayLayout( { columns: value } )
131
- }
132
- min={ 2 }
133
- max={ Math.max( 6, displayLayout.columns ) }
119
+ { ! inherit && (
120
+ <SelectControl
121
+ options={ postTypesSelectOptions }
122
+ value={ postType }
123
+ label={ __( 'Post type' ) }
124
+ onChange={ onPostTypeChange }
125
+ help={ __(
126
+ 'WordPress contains different types of content and they are divided into collections called "Post types". By default there are a few different ones such as blog posts and pages, but plugins could add more.'
127
+ ) }
134
128
  />
135
- { displayLayout.columns > 6 && (
136
- <Notice status="warning" isDismissible={ false }>
137
- { __(
138
- 'This column count exceeds the recommended amount and may cause visual breakage.'
139
- ) }
140
- </Notice>
141
- ) }
142
- </>
143
- ) }
144
- { ! inherit && (
145
- <OrderControl
146
- { ...{ order, orderBy } }
147
- onChange={ setQuery }
148
- />
149
- ) }
150
- { ! inherit && showSticky && (
151
- <StickyControl
152
- value={ sticky }
153
- onChange={ ( value ) => setQuery( { sticky: value } ) }
154
- />
155
- ) }
156
- </PanelBody>
157
- { ! inherit && (
158
- <PanelBody title={ __( 'Filters' ) }>
159
- <TaxonomyControls onChange={ setQuery } query={ query } />
160
- <AuthorControl value={ authorIds } onChange={ setQuery } />
161
- <TextControl
162
- label={ __( 'Keyword' ) }
163
- value={ querySearch }
164
- onChange={ setQuerySearch }
165
- />
166
- { isPostTypeHierarchical && (
167
- <ParentControl
168
- parents={ parents }
169
- postType={ postType }
129
+ ) }
130
+ { displayLayout?.type === 'flex' && (
131
+ <>
132
+ <RangeControl
133
+ label={ __( 'Columns' ) }
134
+ value={ displayLayout.columns }
135
+ onChange={ ( value ) =>
136
+ setDisplayLayout( { columns: value } )
137
+ }
138
+ min={ 2 }
139
+ max={ Math.max( 6, displayLayout.columns ) }
140
+ />
141
+ { displayLayout.columns > 6 && (
142
+ <Notice
143
+ status="warning"
144
+ isDismissible={ false }
145
+ >
146
+ { __(
147
+ 'This column count exceeds the recommended amount and may cause visual breakage.'
148
+ ) }
149
+ </Notice>
150
+ ) }
151
+ </>
152
+ ) }
153
+ { ! inherit && (
154
+ <OrderControl
155
+ { ...{ order, orderBy } }
170
156
  onChange={ setQuery }
171
157
  />
172
158
  ) }
159
+ { ! inherit && showSticky && (
160
+ <StickyControl
161
+ value={ sticky }
162
+ onChange={ ( value ) =>
163
+ setQuery( { sticky: value } )
164
+ }
165
+ />
166
+ ) }
173
167
  </PanelBody>
168
+ </InspectorControls>
169
+ { ! inherit && (
170
+ <InspectorControls>
171
+ <ToolsPanel
172
+ className="block-library-query-toolspanel__filters"
173
+ label={ __( 'Filters' ) }
174
+ resetAll={ () => {
175
+ setQuery( {
176
+ author: '',
177
+ parents: [],
178
+ search: '',
179
+ taxQuery: null,
180
+ } );
181
+ setQuerySearch( '' );
182
+ } }
183
+ >
184
+ { !! taxonomiesInfo?.length && (
185
+ <ToolsPanelItem
186
+ label={ __( 'Taxonomies' ) }
187
+ hasValue={ () =>
188
+ Object.values( taxQuery || {} ).some(
189
+ ( terms ) => !! terms.length
190
+ )
191
+ }
192
+ onDeselect={ () =>
193
+ setQuery( { taxQuery: null } )
194
+ }
195
+ >
196
+ <TaxonomyControls
197
+ onChange={ setQuery }
198
+ query={ query }
199
+ />
200
+ </ToolsPanelItem>
201
+ ) }
202
+ <ToolsPanelItem
203
+ hasValue={ () => !! authorIds }
204
+ label={ __( 'Authors' ) }
205
+ onDeselect={ () => setQuery( { author: '' } ) }
206
+ >
207
+ <AuthorControl
208
+ value={ authorIds }
209
+ onChange={ setQuery }
210
+ />
211
+ </ToolsPanelItem>
212
+ <ToolsPanelItem
213
+ hasValue={ () => !! querySearch }
214
+ label={ __( 'Keyword' ) }
215
+ onDeselect={ () => setQuerySearch( '' ) }
216
+ >
217
+ <TextControl
218
+ label={ __( 'Keyword' ) }
219
+ value={ querySearch }
220
+ onChange={ setQuerySearch }
221
+ />
222
+ </ToolsPanelItem>
223
+ { isPostTypeHierarchical && (
224
+ <ToolsPanelItem
225
+ hasValue={ () => !! parents?.length }
226
+ label={ __( 'Parents' ) }
227
+ onDeselect={ () => setQuery( { parents: [] } ) }
228
+ >
229
+ <ParentControl
230
+ parents={ parents }
231
+ postType={ postType }
232
+ onChange={ setQuery }
233
+ />
234
+ </ToolsPanelItem>
235
+ ) }
236
+ </ToolsPanel>
237
+ </InspectorControls>
174
238
  ) }
175
- </InspectorControls>
239
+ </>
176
240
  );
177
241
  }
@@ -33,8 +33,8 @@ const getTermIdByTermValue = ( termsMappedByName, termValue ) => {
33
33
  }
34
34
  };
35
35
 
36
- function TaxonomyControls( { onChange, query } ) {
37
- const taxonomies = useTaxonomies( query.postType );
36
+ export const useTaxonomiesInfo = ( postType ) => {
37
+ const taxonomies = useTaxonomies( postType );
38
38
  const taxonomiesInfo = useSelect(
39
39
  ( select ) => {
40
40
  const { getEntityRecords } = select( coreStore );
@@ -51,6 +51,11 @@ function TaxonomyControls( { onChange, query } ) {
51
51
  },
52
52
  [ taxonomies ]
53
53
  );
54
+ return taxonomiesInfo;
55
+ };
56
+
57
+ export function TaxonomyControls( { onChange, query } ) {
58
+ const taxonomiesInfo = useTaxonomiesInfo( query.postType );
54
59
  const onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {
55
60
  const taxonomyInfo = taxonomiesInfo.find(
56
61
  ( { slug } ) => slug === taxonomySlug
@@ -102,17 +107,19 @@ function TaxonomyControls( { onChange, query } ) {
102
107
  return null;
103
108
  }
104
109
  return (
105
- <FormTokenField
110
+ <div
106
111
  key={ slug }
107
- label={ name }
108
- value={ getExistingTaxQueryValue( slug ) }
109
- suggestions={ terms.names }
110
- onChange={ onTermsChange( slug ) }
111
- />
112
+ className="block-library-query-inspector__taxonomy-control"
113
+ >
114
+ <FormTokenField
115
+ label={ name }
116
+ value={ getExistingTaxQueryValue( slug ) }
117
+ suggestions={ terms.names }
118
+ onChange={ onTermsChange( slug ) }
119
+ />
120
+ </div>
112
121
  );
113
122
  } ) }
114
123
  </>
115
124
  );
116
125
  }
117
-
118
- export default TaxonomyControls;
@@ -43,3 +43,12 @@
43
43
  max-height: none;
44
44
  }
45
45
  }
46
+
47
+ .block-library-query-toolspanel__filters {
48
+ .components-form-token-field__help {
49
+ margin-bottom: 0;
50
+ }
51
+ .block-library-query-inspector__taxonomy-control:not(:last-child) {
52
+ margin-bottom: $grid-unit-30;
53
+ }
54
+ }