@wordpress/block-library 9.21.0 → 9.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/cover/index.js +1 -1
- package/build/cover/index.js.map +1 -1
- package/build/details/edit.js +1 -5
- package/build/details/edit.js.map +1 -1
- package/build/details/index.js +1 -1
- package/build/details/index.js.map +1 -1
- package/build/navigation/view.js +2 -1
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +0 -21
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +0 -3
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-link/transforms.js +0 -2
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/navigation-link/update-attributes.js +0 -1
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +1 -24
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/navigation-submenu/index.js +0 -3
- package/build/navigation-submenu/index.js.map +1 -1
- package/build/post-comments-count/index.js +0 -1
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-link/index.js +0 -1
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-featured-image/edit.js +15 -5
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +47 -59
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +2 -2
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-content.js +4 -17
- package/build/query/edit/query-content.js.map +1 -1
- package/build/quote/index.js +1 -1
- package/build/quote/index.js.map +1 -1
- package/build/social-links/edit.js +29 -31
- package/build/social-links/edit.js.map +1 -1
- package/build/table/index.js +3 -3
- package/build/table/index.js.map +1 -1
- package/build/table/transforms.js +11 -3
- package/build/table/transforms.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -1
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +6 -3
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build-module/cover/index.js +1 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/edit.js +1 -5
- package/build-module/details/edit.js.map +1 -1
- package/build-module/details/index.js +1 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/navigation/view.js +2 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +0 -21
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +0 -3
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-link/transforms.js +0 -2
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +0 -1
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +1 -24
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/navigation-submenu/index.js +0 -3
- package/build-module/navigation-submenu/index.js.map +1 -1
- package/build-module/post-comments-count/index.js +0 -1
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +0 -1
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +15 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +49 -61
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +2 -2
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-content.js +4 -17
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/quote/index.js +1 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/social-links/edit.js +30 -32
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/index.js +3 -3
- package/build-module/table/index.js.map +1 -1
- package/build-module/table/transforms.js +11 -3
- package/build-module/table/transforms.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +6 -3
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-style/editor-rtl.css +1 -50
- package/build-style/editor.css +1 -50
- package/build-style/media-text/style-rtl.css +0 -2
- package/build-style/media-text/style.css +0 -2
- package/build-style/search/style-rtl.css +1 -0
- package/build-style/search/style.css +1 -0
- package/build-style/social-links/editor-rtl.css +1 -50
- package/build-style/social-links/editor.css +1 -50
- package/build-style/style-rtl.css +1 -6
- package/build-style/style.css +1 -6
- package/build-style/tag-cloud/style-rtl.css +0 -4
- package/build-style/tag-cloud/style.css +0 -4
- package/package.json +35 -35
- package/src/button/index.php +2 -3
- package/src/cover/index.js +1 -1
- package/src/details/edit.js +6 -8
- package/src/details/index.js +1 -1
- package/src/file/index.php +2 -3
- package/src/latest-comments/index.php +1 -1
- package/src/latest-posts/index.php +3 -0
- package/src/media-text/style.scss +0 -2
- package/src/navigation/index.php +1 -1
- package/src/navigation/view.js +2 -1
- package/src/navigation-link/block.json +0 -3
- package/src/navigation-link/edit.js +1 -22
- package/src/navigation-link/index.php +1 -5
- package/src/navigation-link/transforms.js +1 -2
- package/src/navigation-link/update-attributes.js +0 -1
- package/src/navigation-submenu/block.json +0 -3
- package/src/navigation-submenu/edit.js +1 -24
- package/src/navigation-submenu/index.php +0 -4
- package/src/post-comments-count/block.json +0 -1
- package/src/post-comments-count/index.php +4 -0
- package/src/post-comments-link/block.json +0 -1
- package/src/post-comments-link/index.php +4 -0
- package/src/post-featured-image/edit.js +94 -77
- package/src/query/edit/inspector-controls/index.js +66 -91
- package/src/query/edit/inspector-controls/parent-control.js +2 -2
- package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/src/query/edit/query-content.js +7 -16
- package/src/quote/index.js +1 -1
- package/src/search/index.php +12 -9
- package/src/search/style.scss +1 -0
- package/src/social-links/edit.js +29 -30
- package/src/social-links/editor.scss +1 -59
- package/src/table/index.js +3 -3
- package/src/table/transforms.js +14 -2
- package/src/table-of-contents/edit.js +1 -1
- package/src/table-of-contents/hooks.js +5 -2
- package/src/tag-cloud/style.scss +0 -5
|
@@ -123,7 +123,6 @@ const useIsDraggingWithin = ( elementRef ) => {
|
|
|
123
123
|
* @property {number} [id] A post or term id.
|
|
124
124
|
* @property {boolean} [opensInNewTab] Sets link target to _blank when true.
|
|
125
125
|
* @property {string} [url] Link href.
|
|
126
|
-
* @property {string} [title] Link title attribute.
|
|
127
126
|
*/
|
|
128
127
|
|
|
129
128
|
export default function NavigationSubmenuEdit( {
|
|
@@ -135,7 +134,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
135
134
|
context,
|
|
136
135
|
clientId,
|
|
137
136
|
} ) {
|
|
138
|
-
const { label, url, description, rel
|
|
137
|
+
const { label, url, description, rel } = attributes;
|
|
139
138
|
|
|
140
139
|
const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
|
|
141
140
|
|
|
@@ -392,7 +391,6 @@ export default function NavigationSubmenuEdit( {
|
|
|
392
391
|
label: '',
|
|
393
392
|
url: '',
|
|
394
393
|
description: '',
|
|
395
|
-
title: '',
|
|
396
394
|
rel: '',
|
|
397
395
|
} );
|
|
398
396
|
} }
|
|
@@ -458,27 +456,6 @@ export default function NavigationSubmenuEdit( {
|
|
|
458
456
|
/>
|
|
459
457
|
</ToolsPanelItem>
|
|
460
458
|
|
|
461
|
-
<ToolsPanelItem
|
|
462
|
-
label={ __( 'Title attribute' ) }
|
|
463
|
-
isShownByDefault
|
|
464
|
-
hasValue={ () => !! title }
|
|
465
|
-
onDeselect={ () => setAttributes( { title: '' } ) }
|
|
466
|
-
>
|
|
467
|
-
<TextControl
|
|
468
|
-
__nextHasNoMarginBottom
|
|
469
|
-
__next40pxDefaultSize
|
|
470
|
-
value={ title || '' }
|
|
471
|
-
onChange={ ( titleValue ) => {
|
|
472
|
-
setAttributes( { title: titleValue } );
|
|
473
|
-
} }
|
|
474
|
-
label={ __( 'Title attribute' ) }
|
|
475
|
-
autoComplete="off"
|
|
476
|
-
help={ __(
|
|
477
|
-
'Additional information to help clarify the purpose of the link.'
|
|
478
|
-
) }
|
|
479
|
-
/>
|
|
480
|
-
</ToolsPanelItem>
|
|
481
|
-
|
|
482
459
|
<ToolsPanelItem
|
|
483
460
|
label={ __( 'Rel attribute' ) }
|
|
484
461
|
isShownByDefault
|
|
@@ -169,10 +169,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
169
169
|
$html .= ' rel="nofollow"';
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
if ( isset( $attributes['title'] ) ) {
|
|
173
|
-
$html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
172
|
$html .= '>';
|
|
177
173
|
// End appending HTML attributes to anchor tag.
|
|
178
174
|
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/post-comments-count` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.9.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
* @param WP_Block $block Block instance.
|
|
@@ -33,6 +35,8 @@ function render_block_core_post_comments_count( $attributes, $content, $block )
|
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Registers the `core/post-comments-count` block on the server.
|
|
38
|
+
*
|
|
39
|
+
* @since 6.9.0
|
|
36
40
|
*/
|
|
37
41
|
function register_block_core_post_comments_count() {
|
|
38
42
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/post-comments-link` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.9.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
* @param WP_Block $block Block instance.
|
|
@@ -59,6 +61,8 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) {
|
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Registers the `core/post-comments-link` block on the server.
|
|
64
|
+
*
|
|
65
|
+
* @since 6.9.0
|
|
62
66
|
*/
|
|
63
67
|
function register_block_core_post_comments_link() {
|
|
64
68
|
register_block_type_from_metadata(
|
|
@@ -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
|
-
|
|
232
|
-
<
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
<
|
|
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={ () =>
|
|
266
|
+
hasValue={ () => !! isLink }
|
|
283
267
|
onDeselect={ () =>
|
|
284
268
|
setAttributes( {
|
|
285
|
-
|
|
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
|
-
|
|
294
|
+
isShownByDefault
|
|
295
|
+
hasValue={ () => '_self' !== linkTarget }
|
|
296
|
+
onDeselect={ () =>
|
|
293
297
|
setAttributes( {
|
|
294
|
-
linkTarget:
|
|
298
|
+
linkTarget: '_self',
|
|
295
299
|
} )
|
|
296
300
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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={ (
|
|
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={
|
|
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 {
|
|
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,
|
|
44
|
-
const { query
|
|
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
|
|
103
|
-
debounce( () => {
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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={ () =>
|
|
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={
|
|
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.
|
|
@@ -38,7 +38,6 @@ export default function QueryContent( {
|
|
|
38
38
|
const {
|
|
39
39
|
queryId,
|
|
40
40
|
query,
|
|
41
|
-
displayLayout,
|
|
42
41
|
enhancedPagination,
|
|
43
42
|
tagName: TagName = 'div',
|
|
44
43
|
query: { inherit } = {},
|
|
@@ -86,8 +85,11 @@ export default function QueryContent( {
|
|
|
86
85
|
// because updates are batched after the render and changes in different query properties
|
|
87
86
|
// would cause to override previous wanted changes.
|
|
88
87
|
const updateQuery = useCallback(
|
|
89
|
-
( newQuery ) =>
|
|
90
|
-
|
|
88
|
+
( newQuery ) =>
|
|
89
|
+
setAttributes( ( prevAttributes ) => ( {
|
|
90
|
+
query: { ...prevAttributes.query, ...newQuery },
|
|
91
|
+
} ) ),
|
|
92
|
+
[ setAttributes ]
|
|
91
93
|
);
|
|
92
94
|
useEffect( () => {
|
|
93
95
|
const newQuery = {};
|
|
@@ -98,21 +100,15 @@ export default function QueryContent( {
|
|
|
98
100
|
} else if ( ! query.perPage && postsPerPage ) {
|
|
99
101
|
newQuery.perPage = postsPerPage;
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
// are not inherited when in singular content (e.g. post, page, 404, blank).
|
|
103
|
-
if ( isSingular && query.inherit ) {
|
|
104
|
-
newQuery.inherit = false;
|
|
105
|
-
}
|
|
103
|
+
|
|
106
104
|
if ( !! Object.keys( newQuery ).length ) {
|
|
107
105
|
__unstableMarkNextChangeAsNotPersistent();
|
|
108
106
|
updateQuery( newQuery );
|
|
109
107
|
}
|
|
110
108
|
}, [
|
|
111
109
|
query.perPage,
|
|
112
|
-
query.inherit,
|
|
113
|
-
postsPerPage,
|
|
114
110
|
inherit,
|
|
115
|
-
|
|
111
|
+
postsPerPage,
|
|
116
112
|
__unstableMarkNextChangeAsNotPersistent,
|
|
117
113
|
updateQuery,
|
|
118
114
|
] );
|
|
@@ -129,10 +125,6 @@ export default function QueryContent( {
|
|
|
129
125
|
__unstableMarkNextChangeAsNotPersistent,
|
|
130
126
|
setAttributes,
|
|
131
127
|
] );
|
|
132
|
-
const updateDisplayLayout = ( newDisplayLayout ) =>
|
|
133
|
-
setAttributes( {
|
|
134
|
-
displayLayout: { ...displayLayout, ...newDisplayLayout },
|
|
135
|
-
} );
|
|
136
128
|
|
|
137
129
|
return (
|
|
138
130
|
<>
|
|
@@ -146,7 +138,6 @@ export default function QueryContent( {
|
|
|
146
138
|
name={ name }
|
|
147
139
|
attributes={ attributes }
|
|
148
140
|
setQuery={ updateQuery }
|
|
149
|
-
setDisplayLayout={ updateDisplayLayout }
|
|
150
141
|
setAttributes={ setAttributes }
|
|
151
142
|
clientId={ clientId }
|
|
152
143
|
isSingular={ isSingular }
|