@wordpress/block-library 9.21.0 → 9.23.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 (201) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/calendar/index.js +1 -0
  3. package/build/calendar/index.js.map +1 -1
  4. package/build/comments/edit/comments-inspector-controls.js +13 -13
  5. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  6. package/build/comments/edit/index.js +4 -2
  7. package/build/comments/edit/index.js.map +1 -1
  8. package/build/cover/edit/inspector-controls.js +9 -12
  9. package/build/cover/edit/inspector-controls.js.map +1 -1
  10. package/build/cover/index.js +1 -1
  11. package/build/cover/index.js.map +1 -1
  12. package/build/details/edit.js +1 -5
  13. package/build/details/edit.js.map +1 -1
  14. package/build/details/index.js +1 -1
  15. package/build/details/index.js.map +1 -1
  16. package/build/group/edit.js +17 -13
  17. package/build/group/edit.js.map +1 -1
  18. package/build/image/edit.js +0 -6
  19. package/build/image/edit.js.map +1 -1
  20. package/build/latest-posts/edit.js +100 -54
  21. package/build/latest-posts/edit.js.map +1 -1
  22. package/build/navigation/view.js +2 -1
  23. package/build/navigation/view.js.map +1 -1
  24. package/build/navigation-link/edit.js +0 -21
  25. package/build/navigation-link/edit.js.map +1 -1
  26. package/build/navigation-link/index.js +0 -3
  27. package/build/navigation-link/index.js.map +1 -1
  28. package/build/navigation-link/transforms.js +0 -2
  29. package/build/navigation-link/transforms.js.map +1 -1
  30. package/build/navigation-link/update-attributes.js +0 -1
  31. package/build/navigation-link/update-attributes.js.map +1 -1
  32. package/build/navigation-submenu/edit.js +1 -24
  33. package/build/navigation-submenu/edit.js.map +1 -1
  34. package/build/navigation-submenu/index.js +0 -3
  35. package/build/navigation-submenu/index.js.map +1 -1
  36. package/build/post-comments-count/index.js +0 -1
  37. package/build/post-comments-count/index.js.map +1 -1
  38. package/build/post-comments-link/index.js +0 -1
  39. package/build/post-comments-link/index.js.map +1 -1
  40. package/build/post-featured-image/edit.js +15 -5
  41. package/build/post-featured-image/edit.js.map +1 -1
  42. package/build/query/edit/inspector-controls/index.js +47 -59
  43. package/build/query/edit/inspector-controls/index.js.map +1 -1
  44. package/build/query/edit/inspector-controls/parent-control.js +2 -2
  45. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  46. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  47. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  48. package/build/query/edit/query-content.js +15 -29
  49. package/build/query/edit/query-content.js.map +1 -1
  50. package/build/quote/index.js +1 -1
  51. package/build/quote/index.js.map +1 -1
  52. package/build/separator/edit.js +13 -12
  53. package/build/separator/edit.js.map +1 -1
  54. package/build/social-links/edit.js +29 -31
  55. package/build/social-links/edit.js.map +1 -1
  56. package/build/table/index.js +3 -3
  57. package/build/table/index.js.map +1 -1
  58. package/build/table/transforms.js +11 -3
  59. package/build/table/transforms.js.map +1 -1
  60. package/build/table-of-contents/edit.js +1 -1
  61. package/build/table-of-contents/edit.js.map +1 -1
  62. package/build/table-of-contents/hooks.js +6 -3
  63. package/build/table-of-contents/hooks.js.map +1 -1
  64. package/build/template-part/edit/advanced-controls.js +14 -12
  65. package/build/template-part/edit/advanced-controls.js.map +1 -1
  66. package/build/template-part/edit/index.js +2 -1
  67. package/build/template-part/edit/index.js.map +1 -1
  68. package/build-module/calendar/index.js +1 -0
  69. package/build-module/calendar/index.js.map +1 -1
  70. package/build-module/comments/edit/comments-inspector-controls.js +14 -14
  71. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  72. package/build-module/comments/edit/index.js +4 -2
  73. package/build-module/comments/edit/index.js.map +1 -1
  74. package/build-module/cover/edit/inspector-controls.js +10 -13
  75. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  76. package/build-module/cover/index.js +1 -1
  77. package/build-module/cover/index.js.map +1 -1
  78. package/build-module/details/edit.js +1 -5
  79. package/build-module/details/edit.js.map +1 -1
  80. package/build-module/details/index.js +1 -1
  81. package/build-module/details/index.js.map +1 -1
  82. package/build-module/group/edit.js +16 -14
  83. package/build-module/group/edit.js.map +1 -1
  84. package/build-module/image/edit.js +0 -6
  85. package/build-module/image/edit.js.map +1 -1
  86. package/build-module/latest-posts/edit.js +100 -54
  87. package/build-module/latest-posts/edit.js.map +1 -1
  88. package/build-module/navigation/view.js +2 -1
  89. package/build-module/navigation/view.js.map +1 -1
  90. package/build-module/navigation-link/edit.js +0 -21
  91. package/build-module/navigation-link/edit.js.map +1 -1
  92. package/build-module/navigation-link/index.js +0 -3
  93. package/build-module/navigation-link/index.js.map +1 -1
  94. package/build-module/navigation-link/transforms.js +0 -2
  95. package/build-module/navigation-link/transforms.js.map +1 -1
  96. package/build-module/navigation-link/update-attributes.js +0 -1
  97. package/build-module/navigation-link/update-attributes.js.map +1 -1
  98. package/build-module/navigation-submenu/edit.js +1 -24
  99. package/build-module/navigation-submenu/edit.js.map +1 -1
  100. package/build-module/navigation-submenu/index.js +0 -3
  101. package/build-module/navigation-submenu/index.js.map +1 -1
  102. package/build-module/post-comments-count/index.js +0 -1
  103. package/build-module/post-comments-count/index.js.map +1 -1
  104. package/build-module/post-comments-link/index.js +0 -1
  105. package/build-module/post-comments-link/index.js.map +1 -1
  106. package/build-module/post-featured-image/edit.js +15 -5
  107. package/build-module/post-featured-image/edit.js.map +1 -1
  108. package/build-module/query/edit/inspector-controls/index.js +49 -61
  109. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  110. package/build-module/query/edit/inspector-controls/parent-control.js +2 -2
  111. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  112. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  113. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  114. package/build-module/query/edit/query-content.js +16 -30
  115. package/build-module/query/edit/query-content.js.map +1 -1
  116. package/build-module/quote/index.js +1 -1
  117. package/build-module/quote/index.js.map +1 -1
  118. package/build-module/separator/edit.js +15 -14
  119. package/build-module/separator/edit.js.map +1 -1
  120. package/build-module/social-links/edit.js +30 -32
  121. package/build-module/social-links/edit.js.map +1 -1
  122. package/build-module/table/index.js +3 -3
  123. package/build-module/table/index.js.map +1 -1
  124. package/build-module/table/transforms.js +11 -3
  125. package/build-module/table/transforms.js.map +1 -1
  126. package/build-module/table-of-contents/edit.js +1 -1
  127. package/build-module/table-of-contents/edit.js.map +1 -1
  128. package/build-module/table-of-contents/hooks.js +6 -3
  129. package/build-module/table-of-contents/hooks.js.map +1 -1
  130. package/build-module/template-part/edit/advanced-controls.js +14 -12
  131. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  132. package/build-module/template-part/edit/index.js +2 -1
  133. package/build-module/template-part/edit/index.js.map +1 -1
  134. package/build-style/editor-rtl.css +1 -50
  135. package/build-style/editor.css +1 -50
  136. package/build-style/media-text/style-rtl.css +0 -2
  137. package/build-style/media-text/style.css +0 -2
  138. package/build-style/search/style-rtl.css +1 -0
  139. package/build-style/search/style.css +1 -0
  140. package/build-style/social-links/editor-rtl.css +1 -50
  141. package/build-style/social-links/editor.css +1 -50
  142. package/build-style/style-rtl.css +1 -6
  143. package/build-style/style.css +1 -6
  144. package/build-style/tag-cloud/style-rtl.css +0 -4
  145. package/build-style/tag-cloud/style.css +0 -4
  146. package/package.json +35 -35
  147. package/src/button/index.php +2 -3
  148. package/src/calendar/block.json +1 -0
  149. package/src/comments/edit/comments-inspector-controls.js +14 -12
  150. package/src/comments/edit/index.js +2 -1
  151. package/src/cover/edit/inspector-controls.js +9 -12
  152. package/src/cover/index.js +1 -1
  153. package/src/details/edit.js +6 -8
  154. package/src/details/index.js +1 -1
  155. package/src/file/index.php +2 -3
  156. package/src/group/edit.js +11 -10
  157. package/src/image/edit.js +0 -4
  158. package/src/latest-comments/index.php +1 -1
  159. package/src/latest-posts/edit.js +113 -81
  160. package/src/latest-posts/index.php +3 -0
  161. package/src/loginout/index.php +5 -1
  162. package/src/media-text/style.scss +0 -2
  163. package/src/navigation/index.php +1 -2
  164. package/src/navigation/view.js +2 -1
  165. package/src/navigation-link/block.json +0 -3
  166. package/src/navigation-link/edit.js +1 -22
  167. package/src/navigation-link/index.php +2 -6
  168. package/src/navigation-link/transforms.js +1 -2
  169. package/src/navigation-link/update-attributes.js +0 -1
  170. package/src/navigation-submenu/block.json +0 -3
  171. package/src/navigation-submenu/edit.js +1 -24
  172. package/src/navigation-submenu/index.php +1 -5
  173. package/src/post-author/index.php +1 -1
  174. package/src/post-author-name/index.php +1 -1
  175. package/src/post-comments-count/block.json +0 -1
  176. package/src/post-comments-count/index.php +4 -0
  177. package/src/post-comments-link/block.json +0 -1
  178. package/src/post-comments-link/index.php +4 -0
  179. package/src/post-featured-image/edit.js +94 -77
  180. package/src/query/edit/inspector-controls/index.js +66 -91
  181. package/src/query/edit/inspector-controls/parent-control.js +2 -2
  182. package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -2
  183. package/src/query/edit/query-content.js +17 -27
  184. package/src/quote/index.js +1 -1
  185. package/src/search/index.php +12 -9
  186. package/src/search/style.scss +1 -0
  187. package/src/separator/edit.js +16 -12
  188. package/src/social-links/edit.js +29 -30
  189. package/src/social-links/editor.scss +1 -59
  190. package/src/table/index.js +3 -3
  191. package/src/table/transforms.js +14 -2
  192. package/src/table-of-contents/edit.js +1 -1
  193. package/src/table-of-contents/hooks.js +5 -2
  194. package/src/tag-cloud/style.scss +0 -5
  195. package/src/template-part/edit/advanced-controls.js +9 -8
  196. package/src/template-part/edit/index.js +1 -0
  197. package/build/utils/messages.js +0 -22
  198. package/build/utils/messages.js.map +0 -1
  199. package/build-module/utils/messages.js +0 -15
  200. package/build-module/utils/messages.js.map +0 -1
  201. package/src/utils/messages.js +0 -31
@@ -196,6 +196,17 @@ export default function PostFeaturedImageEdit( {
196
196
  }
197
197
  };
198
198
 
199
+ // On reset image
200
+ const onResetImage = () => {
201
+ setAttributes( {
202
+ isLink: false,
203
+ linkTarget: '_self',
204
+ rel: '',
205
+ sizeSlug: undefined,
206
+ } );
207
+ setFeaturedImage( 0 );
208
+ };
209
+
199
210
  // Reset temporary url when media is available.
200
211
  useEffect( () => {
201
212
  if ( mediaUrl && temporaryURL ) {
@@ -228,38 +239,20 @@ export default function PostFeaturedImageEdit( {
228
239
  media={ media }
229
240
  />
230
241
  </InspectorControls>
231
- <InspectorControls>
232
- <ToolsPanel
233
- label={ __( 'Settings' ) }
234
- resetAll={ () => {
235
- setAttributes( {
236
- isLink: false,
237
- linkTarget: '_self',
238
- rel: '',
239
- } );
240
- } }
241
- dropdownMenuProps={ dropdownMenuProps }
242
- >
243
- <ToolsPanelItem
244
- label={
245
- postType?.labels.singular_name
246
- ? sprintf(
247
- // translators: %s: Name of the post type e.g: "post".
248
- __( 'Link to %s' ),
249
- postType.labels.singular_name
250
- )
251
- : __( 'Link to post' )
252
- }
253
- isShownByDefault
254
- hasValue={ () => !! isLink }
255
- onDeselect={ () =>
242
+ { ( featuredImage || isDescendentOfQueryLoop || ! postId ) && (
243
+ <InspectorControls>
244
+ <ToolsPanel
245
+ label={ __( 'Settings' ) }
246
+ resetAll={ () => {
256
247
  setAttributes( {
257
248
  isLink: false,
258
- } )
259
- }
249
+ linkTarget: '_self',
250
+ rel: '',
251
+ } );
252
+ } }
253
+ dropdownMenuProps={ dropdownMenuProps }
260
254
  >
261
- <ToggleControl
262
- __nextHasNoMarginBottom
255
+ <ToolsPanelItem
263
256
  label={
264
257
  postType?.labels.singular_name
265
258
  ? sprintf(
@@ -269,66 +262,91 @@ export default function PostFeaturedImageEdit( {
269
262
  )
270
263
  : __( 'Link to post' )
271
264
  }
272
- onChange={ () =>
273
- setAttributes( { isLink: ! isLink } )
274
- }
275
- checked={ isLink }
276
- />
277
- </ToolsPanelItem>
278
- { isLink && (
279
- <ToolsPanelItem
280
- label={ __( 'Open in new tab' ) }
281
265
  isShownByDefault
282
- hasValue={ () => '_self' !== linkTarget }
266
+ hasValue={ () => !! isLink }
283
267
  onDeselect={ () =>
284
268
  setAttributes( {
285
- linkTarget: '_self',
269
+ isLink: false,
286
270
  } )
287
271
  }
288
272
  >
289
273
  <ToggleControl
290
274
  __nextHasNoMarginBottom
275
+ label={
276
+ postType?.labels.singular_name
277
+ ? sprintf(
278
+ // translators: %s: Name of the post type e.g: "post".
279
+ __( 'Link to %s' ),
280
+ postType.labels.singular_name
281
+ )
282
+ : __( 'Link to post' )
283
+ }
284
+ onChange={ () =>
285
+ setAttributes( { isLink: ! isLink } )
286
+ }
287
+ checked={ isLink }
288
+ />
289
+ </ToolsPanelItem>
290
+
291
+ { isLink && (
292
+ <ToolsPanelItem
291
293
  label={ __( 'Open in new tab' ) }
292
- onChange={ ( value ) =>
294
+ isShownByDefault
295
+ hasValue={ () => '_self' !== linkTarget }
296
+ onDeselect={ () =>
293
297
  setAttributes( {
294
- linkTarget: value ? '_blank' : '_self',
298
+ linkTarget: '_self',
295
299
  } )
296
300
  }
297
- checked={ linkTarget === '_blank' }
298
- />
299
- </ToolsPanelItem>
300
- ) }
301
- { isLink && (
302
- <ToolsPanelItem
303
- label={ __( 'Link rel' ) }
304
- isShownByDefault
305
- hasValue={ () => !! rel }
306
- onDeselect={ () =>
307
- setAttributes( {
308
- rel: '',
309
- } )
310
- }
311
- >
312
- <TextControl
313
- __next40pxDefaultSize
314
- __nextHasNoMarginBottom
301
+ >
302
+ <ToggleControl
303
+ __nextHasNoMarginBottom
304
+ label={ __( 'Open in new tab' ) }
305
+ onChange={ ( value ) =>
306
+ setAttributes( {
307
+ linkTarget: value
308
+ ? '_blank'
309
+ : '_self',
310
+ } )
311
+ }
312
+ checked={ linkTarget === '_blank' }
313
+ />
314
+ </ToolsPanelItem>
315
+ ) }
316
+ { isLink && (
317
+ <ToolsPanelItem
315
318
  label={ __( 'Link rel' ) }
316
- value={ rel }
317
- onChange={ ( newRel ) =>
318
- setAttributes( { rel: newRel } )
319
+ isShownByDefault
320
+ hasValue={ () => !! rel }
321
+ onDeselect={ () =>
322
+ setAttributes( {
323
+ rel: '',
324
+ } )
325
+ }
326
+ >
327
+ <TextControl
328
+ __next40pxDefaultSize
329
+ __nextHasNoMarginBottom
330
+ label={ __( 'Link rel' ) }
331
+ value={ rel }
332
+ onChange={ ( newRel ) =>
333
+ setAttributes( { rel: newRel } )
334
+ }
335
+ />
336
+ </ToolsPanelItem>
337
+ ) }
338
+ { !! media && (
339
+ <FeaturedImageResolutionTool
340
+ image={ media }
341
+ value={ sizeSlug }
342
+ onChange={ ( nextSizeSlug ) =>
343
+ setAttributes( { sizeSlug: nextSizeSlug } )
319
344
  }
320
345
  />
321
- </ToolsPanelItem>
322
- ) }
323
- <FeaturedImageResolutionTool
324
- image={ media }
325
- value={ sizeSlug }
326
- onChange={ ( nextSizeSlug ) =>
327
- setAttributes( { sizeSlug: nextSizeSlug } )
328
- }
329
- />
330
- </ToolsPanel>
331
- </InspectorControls>
346
+ ) }
347
+ </ToolsPanel>
348
+ </InspectorControls>
349
+ ) }
332
350
  </>
333
351
  );
334
352
 
@@ -398,8 +416,7 @@ export default function PostFeaturedImageEdit( {
398
416
  label={ label }
399
417
  showTooltip
400
418
  tooltipPosition="top center"
401
- onClick={ ( e ) => {
402
- e.preventDefault();
419
+ onClick={ () => {
403
420
  open();
404
421
  } }
405
422
  />
@@ -451,7 +468,7 @@ export default function PostFeaturedImageEdit( {
451
468
  accept="image/*"
452
469
  onSelect={ onSelectImage }
453
470
  onError={ onUploadError }
454
- onReset={ () => setFeaturedImage( 0 ) }
471
+ onReset={ onResetImage }
455
472
  />
456
473
  </BlockControls>
457
474
  ) }
@@ -4,18 +4,18 @@
4
4
  import {
5
5
  TextControl,
6
6
  SelectControl,
7
- RangeControl,
8
- __experimentalToggleGroupControl as ToggleGroupControl,
9
- __experimentalToggleGroupControlOption as ToggleGroupControlOption,
10
7
  Notice,
8
+ __experimentalVStack as VStack,
11
9
  __experimentalToolsPanel as ToolsPanel,
12
10
  __experimentalToolsPanelItem as ToolsPanelItem,
11
+ __experimentalToggleGroupControl as ToggleGroupControl,
12
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
13
13
  } from '@wordpress/components';
14
14
  import { useSelect } from '@wordpress/data';
15
15
  import { store as coreStore } from '@wordpress/core-data';
16
16
  import { __ } from '@wordpress/i18n';
17
17
  import { debounce } from '@wordpress/compose';
18
- import { useEffect, useState, useCallback } from '@wordpress/element';
18
+ import { useState, useMemo } from '@wordpress/element';
19
19
 
20
20
  /**
21
21
  * Internal dependencies
@@ -40,8 +40,8 @@ import {
40
40
  import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
41
41
 
42
42
  export default function QueryInspectorControls( props ) {
43
- const { attributes, setQuery, setDisplayLayout, isSingular } = props;
44
- const { query, displayLayout } = attributes;
43
+ const { attributes, setQuery, isSingular } = props;
44
+ const { query } = attributes;
45
45
  const {
46
46
  order,
47
47
  orderBy,
@@ -99,29 +99,20 @@ export default function QueryInspectorControls( props ) {
99
99
  setQuery( updateQuery );
100
100
  };
101
101
  const [ querySearch, setQuerySearch ] = useState( query.search );
102
- const onChangeDebounced = useCallback(
103
- debounce( () => {
104
- if ( query.search !== querySearch ) {
105
- setQuery( { search: querySearch } );
106
- }
107
- }, 250 ),
108
- [ querySearch, query.search ]
109
- );
110
- useEffect( () => {
111
- onChangeDebounced();
112
- return onChangeDebounced.cancel;
113
- }, [ querySearch, onChangeDebounced ] );
102
+ const debouncedQuerySearch = useMemo( () => {
103
+ return debounce( ( newQuerySearch ) => {
104
+ setQuery( { search: newQuerySearch } );
105
+ }, 250 );
106
+ }, [ setQuery ] );
114
107
 
115
108
  const orderByOptions = useOrderByOptions( postType );
116
- const showInheritControl =
117
- ! isSingular && isControlAllowed( allowedControls, 'inherit' );
109
+ const showInheritControl = isControlAllowed( allowedControls, 'inherit' );
118
110
  const showPostTypeControl =
119
111
  ! inherit && isControlAllowed( allowedControls, 'postType' );
120
112
  const postTypeControlLabel = __( 'Post type' );
121
113
  const postTypeControlHelp = __(
122
114
  'Select the type of content to display: posts, pages, or custom post types.'
123
115
  );
124
- const showColumnsControl = false;
125
116
  const showOrderControl =
126
117
  ! inherit && isControlAllowed( allowedControls, 'order' );
127
118
  const showStickyControl =
@@ -131,7 +122,6 @@ export default function QueryInspectorControls( props ) {
131
122
  const showSettingsPanel =
132
123
  showInheritControl ||
133
124
  showPostTypeControl ||
134
- showColumnsControl ||
135
125
  showOrderControl ||
136
126
  showStickyControl;
137
127
  const showTaxControl =
@@ -185,6 +175,10 @@ export default function QueryInspectorControls( props ) {
185
175
  const showDisplayPanel =
186
176
  showPostCountControl || showOffSetControl || showPagesControl;
187
177
 
178
+ // The block cannot inherit a default WordPress query in singular content (e.g., post, page, 404, blank).
179
+ // Warn users but still permit this type of query for exceptional cases in Classic and Hybrid themes.
180
+ const hasInheritanceWarning = isSingular && inherit;
181
+
188
182
  return (
189
183
  <>
190
184
  { showSettingsPanel && (
@@ -208,36 +202,48 @@ export default function QueryInspectorControls( props ) {
208
202
  onDeselect={ () => setQuery( { inherit: true } ) }
209
203
  isShownByDefault
210
204
  >
211
- <ToggleGroupControl
212
- __next40pxDefaultSize
213
- __nextHasNoMarginBottom
214
- label={ __( 'Query type' ) }
215
- isBlock
216
- onChange={ ( value ) => {
217
- setQuery( {
218
- inherit: value === 'default',
219
- } );
220
- } }
221
- help={
222
- inherit
223
- ? __(
224
- 'Display a list of posts or custom post types based on the current template.'
225
- )
226
- : __(
227
- 'Display a list of posts or custom post types based on specific criteria.'
228
- )
229
- }
230
- value={ !! inherit ? 'default' : 'custom' }
231
- >
232
- <ToggleGroupControlOption
233
- value="default"
234
- label={ __( 'Default' ) }
235
- />
236
- <ToggleGroupControlOption
237
- value="custom"
238
- label={ __( 'Custom' ) }
239
- />
240
- </ToggleGroupControl>
205
+ <VStack spacing={ 4 }>
206
+ <ToggleGroupControl
207
+ __next40pxDefaultSize
208
+ __nextHasNoMarginBottom
209
+ label={ __( 'Query type' ) }
210
+ isBlock
211
+ onChange={ ( value ) => {
212
+ setQuery( {
213
+ inherit: value === 'default',
214
+ } );
215
+ } }
216
+ help={
217
+ inherit
218
+ ? __(
219
+ 'Display a list of posts or custom post types based on the current template.'
220
+ )
221
+ : __(
222
+ 'Display a list of posts or custom post types based on specific criteria.'
223
+ )
224
+ }
225
+ value={ !! inherit ? 'default' : 'custom' }
226
+ >
227
+ <ToggleGroupControlOption
228
+ value="default"
229
+ label={ __( 'Default' ) }
230
+ />
231
+ <ToggleGroupControlOption
232
+ value="custom"
233
+ label={ __( 'Custom' ) }
234
+ />
235
+ </ToggleGroupControl>
236
+ { hasInheritanceWarning && (
237
+ <Notice
238
+ status="warning"
239
+ isDismissible={ false }
240
+ >
241
+ { __(
242
+ 'Cannot inherit the current template query when placed inside the singular content (e.g., post, page, 404, blank).'
243
+ ) }
244
+ </Notice>
245
+ ) }
246
+ </VStack>
241
247
  </ToolsPanelItem>
242
248
  ) }
243
249
 
@@ -282,43 +288,6 @@ export default function QueryInspectorControls( props ) {
282
288
  </ToolsPanelItem>
283
289
  ) }
284
290
 
285
- { showColumnsControl && (
286
- <ToolsPanelItem
287
- hasValue={ () => displayLayout?.columns !== 2 }
288
- label={ __( 'Columns' ) }
289
- onDeselect={ () =>
290
- setDisplayLayout( { columns: 2 } )
291
- }
292
- isShownByDefault
293
- >
294
- <>
295
- <RangeControl
296
- __nextHasNoMarginBottom
297
- __next40pxDefaultSize
298
- label={ __( 'Columns' ) }
299
- value={ displayLayout.columns }
300
- onChange={ ( value ) =>
301
- setDisplayLayout( {
302
- columns: value,
303
- } )
304
- }
305
- min={ 2 }
306
- max={ Math.max( 6, displayLayout.columns ) }
307
- />
308
- { displayLayout.columns > 6 && (
309
- <Notice
310
- status="warning"
311
- isDismissible={ false }
312
- >
313
- { __(
314
- 'This column count exceeds the recommended amount and may cause visual breakage.'
315
- ) }
316
- </Notice>
317
- ) }
318
- </>
319
- </ToolsPanelItem>
320
- ) }
321
-
322
291
  { showOrderControl && (
323
292
  <ToolsPanelItem
324
293
  hasValue={ () =>
@@ -443,14 +412,20 @@ export default function QueryInspectorControls( props ) {
443
412
  <ToolsPanelItem
444
413
  hasValue={ () => !! querySearch }
445
414
  label={ __( 'Keyword' ) }
446
- onDeselect={ () => setQuerySearch( '' ) }
415
+ onDeselect={ () => {
416
+ setQuery( { search: '' } );
417
+ setQuerySearch( '' );
418
+ } }
447
419
  >
448
420
  <TextControl
449
421
  __nextHasNoMarginBottom
450
422
  __next40pxDefaultSize
451
423
  label={ __( 'Keyword' ) }
452
424
  value={ querySearch }
453
- onChange={ setQuerySearch }
425
+ onChange={ ( newQuerySearch ) => {
426
+ debouncedQuerySearch( newQuerySearch );
427
+ setQuerySearch( newQuerySearch );
428
+ } }
454
429
  />
455
430
  </ToolsPanelItem>
456
431
  ) }
@@ -51,7 +51,7 @@ function ParentControl( { parents, postType, onChange } ) {
51
51
  ),
52
52
  };
53
53
  },
54
- [ search, parents ]
54
+ [ search, postType, parents ]
55
55
  );
56
56
  const currentParents = useSelect(
57
57
  ( select ) => {
@@ -65,7 +65,7 @@ function ParentControl( { parents, postType, onChange } ) {
65
65
  per_page: parents.length,
66
66
  } );
67
67
  },
68
- [ parents ]
68
+ [ parents, postType ]
69
69
  );
70
70
  // Update the `value` state only after the selectors are resolved
71
71
  // to avoid emptying the input when we're changing parents.
@@ -120,7 +120,7 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) {
120
120
  ),
121
121
  };
122
122
  },
123
- [ search, termIds ]
123
+ [ search, taxonomy.slug, termIds ]
124
124
  );
125
125
  // `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.
126
126
  // They are used to extract the terms' names to populate the `FormTokenField` properly
@@ -137,7 +137,7 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) {
137
137
  per_page: termIds.length,
138
138
  } );
139
139
  },
140
- [ termIds ]
140
+ [ taxonomy.slug, termIds ]
141
141
  );
142
142
  // Update the `value` state only after the selectors are resolved
143
143
  // to avoid emptying the input when we're changing terms.
@@ -10,8 +10,8 @@ import {
10
10
  useBlockProps,
11
11
  store as blockEditorStore,
12
12
  useInnerBlocksProps,
13
+ privateApis as blockEditorPrivateApis,
13
14
  } from '@wordpress/block-editor';
14
- import { SelectControl } from '@wordpress/components';
15
15
  import { __ } from '@wordpress/i18n';
16
16
  import { store as coreStore } from '@wordpress/core-data';
17
17
 
@@ -19,11 +19,13 @@ import { store as coreStore } from '@wordpress/core-data';
19
19
  * Internal dependencies
20
20
  */
21
21
  import EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';
22
+ import { unlock } from '../../lock-unlock';
22
23
  import QueryInspectorControls from './inspector-controls';
23
24
  import EnhancedPaginationModal from './enhanced-pagination-modal';
24
25
  import { getQueryContextFromTemplate } from '../utils';
25
26
  import QueryToolbar from './query-toolbar';
26
- import { htmlElementMessages } from '../../utils/messages';
27
+
28
+ const { HTMLElementControl } = unlock( blockEditorPrivateApis );
27
29
 
28
30
  const DEFAULTS_POSTS_PER_PAGE = 3;
29
31
 
@@ -38,7 +40,6 @@ export default function QueryContent( {
38
40
  const {
39
41
  queryId,
40
42
  query,
41
- displayLayout,
42
43
  enhancedPagination,
43
44
  tagName: TagName = 'div',
44
45
  query: { inherit } = {},
@@ -86,8 +87,11 @@ export default function QueryContent( {
86
87
  // because updates are batched after the render and changes in different query properties
87
88
  // would cause to override previous wanted changes.
88
89
  const updateQuery = useCallback(
89
- ( newQuery ) => setAttributes( { query: { ...query, ...newQuery } } ),
90
- [ query, setAttributes ]
90
+ ( newQuery ) =>
91
+ setAttributes( ( prevAttributes ) => ( {
92
+ query: { ...prevAttributes.query, ...newQuery },
93
+ } ) ),
94
+ [ setAttributes ]
91
95
  );
92
96
  useEffect( () => {
93
97
  const newQuery = {};
@@ -98,21 +102,15 @@ export default function QueryContent( {
98
102
  } else if ( ! query.perPage && postsPerPage ) {
99
103
  newQuery.perPage = postsPerPage;
100
104
  }
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 ) {
104
- newQuery.inherit = false;
105
- }
105
+
106
106
  if ( !! Object.keys( newQuery ).length ) {
107
107
  __unstableMarkNextChangeAsNotPersistent();
108
108
  updateQuery( newQuery );
109
109
  }
110
110
  }, [
111
111
  query.perPage,
112
- query.inherit,
113
- postsPerPage,
114
112
  inherit,
115
- isSingular,
113
+ postsPerPage,
116
114
  __unstableMarkNextChangeAsNotPersistent,
117
115
  updateQuery,
118
116
  ] );
@@ -129,10 +127,6 @@ export default function QueryContent( {
129
127
  __unstableMarkNextChangeAsNotPersistent,
130
128
  setAttributes,
131
129
  ] );
132
- const updateDisplayLayout = ( newDisplayLayout ) =>
133
- setAttributes( {
134
- displayLayout: { ...displayLayout, ...newDisplayLayout },
135
- } );
136
130
 
137
131
  return (
138
132
  <>
@@ -146,7 +140,6 @@ export default function QueryContent( {
146
140
  name={ name }
147
141
  attributes={ attributes }
148
142
  setQuery={ updateQuery }
149
- setDisplayLayout={ updateDisplayLayout }
150
143
  setAttributes={ setAttributes }
151
144
  clientId={ clientId }
152
145
  isSingular={ isSingular }
@@ -156,21 +149,18 @@ export default function QueryContent( {
156
149
  <QueryToolbar attributes={ attributes } clientId={ clientId } />
157
150
  </BlockControls>
158
151
  <InspectorControls group="advanced">
159
- <SelectControl
160
- __nextHasNoMarginBottom
161
- __next40pxDefaultSize
162
- label={ __( 'HTML element' ) }
152
+ <HTMLElementControl
153
+ tagName={ TagName }
154
+ onChange={ ( value ) =>
155
+ setAttributes( { tagName: value } )
156
+ }
157
+ clientId={ clientId }
163
158
  options={ [
164
159
  { label: __( 'Default (<div>)' ), value: 'div' },
165
160
  { label: '<main>', value: 'main' },
166
161
  { label: '<section>', value: 'section' },
167
162
  { label: '<aside>', value: 'aside' },
168
163
  ] }
169
- value={ TagName }
170
- onChange={ ( value ) =>
171
- setAttributes( { tagName: value } )
172
- }
173
- help={ htmlElementMessages[ TagName ] }
174
164
  />
175
165
  <EnhancedPaginationControl
176
166
  enhancedPagination={ enhancedPagination }
@@ -22,7 +22,7 @@ export const settings = {
22
22
  icon,
23
23
  example: {
24
24
  attributes: {
25
- citation: 'Julio Cortázar',
25
+ citation: __( 'Julio Cortázar' ),
26
26
  },
27
27
  innerBlocks: [
28
28
  {
@@ -10,9 +10,7 @@
10
10
  *
11
11
  * @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
12
12
  *
13
- * @param array $attributes The block attributes.
14
- * @param string $content The saved content.
15
- * @param WP_Block $block The parsed block.
13
+ * @param array $attributes The block attributes.
16
14
  *
17
15
  * @return string The search block markup.
18
16
  */
@@ -152,17 +150,22 @@ function render_block_core_search( $attributes ) {
152
150
  }
153
151
  }
154
152
 
155
- $field_markup_classes = $is_button_inside ? $border_color_classes : '';
156
- $field_markup = sprintf(
157
- '<div class="wp-block-search__inside-wrapper %s" %s>%s</div>',
158
- esc_attr( $field_markup_classes ),
153
+ $field_markup_classes = array(
154
+ 'wp-block-search__inside-wrapper',
155
+ );
156
+ if ( $is_button_inside && ! empty( $border_color_classes ) ) {
157
+ $field_markup_classes[] = $border_color_classes;
158
+ }
159
+ $field_markup = sprintf(
160
+ '<div class="%s" %s>%s</div>',
161
+ esc_attr( implode( ' ', $field_markup_classes ) ),
159
162
  $inline_styles['wrapper'],
160
163
  $input . $query_params_markup . $button
161
164
  );
162
- $wrapper_attributes = get_block_wrapper_attributes(
165
+ $wrapper_attributes = get_block_wrapper_attributes(
163
166
  array( 'class' => $classnames )
164
167
  );
165
- $form_directives = '';
168
+ $form_directives = '';
166
169
 
167
170
  // If it's interactive, add the directives.
168
171
  if ( $is_expandable_searchfield ) {
@@ -110,6 +110,7 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
110
110
  :where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) {
111
111
  padding: $grid-unit-05;
112
112
  border: 1px solid $gray-600;
113
+ background-color: $white;
113
114
  box-sizing: border-box;
114
115
 
115
116
  .wp-block-search__input {