@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.
- package/CHANGELOG.md +4 -0
- package/build/calendar/index.js +1 -0
- package/build/calendar/index.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +13 -13
- package/build/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments/edit/index.js +4 -2
- package/build/comments/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +9 -12
- package/build/cover/edit/inspector-controls.js.map +1 -1
- 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/group/edit.js +17 -13
- package/build/group/edit.js.map +1 -1
- package/build/image/edit.js +0 -6
- package/build/image/edit.js.map +1 -1
- package/build/latest-posts/edit.js +100 -54
- package/build/latest-posts/edit.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 +15 -29
- 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/separator/edit.js +13 -12
- package/build/separator/edit.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/template-part/edit/advanced-controls.js +14 -12
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/calendar/index.js +1 -0
- package/build-module/calendar/index.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +14 -14
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments/edit/index.js +4 -2
- package/build-module/comments/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +10 -13
- package/build-module/cover/edit/inspector-controls.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/group/edit.js +16 -14
- package/build-module/group/edit.js.map +1 -1
- package/build-module/image/edit.js +0 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +100 -54
- package/build-module/latest-posts/edit.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 +16 -30
- 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/separator/edit.js +15 -14
- package/build-module/separator/edit.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-module/template-part/edit/advanced-controls.js +14 -12
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.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/calendar/block.json +1 -0
- package/src/comments/edit/comments-inspector-controls.js +14 -12
- package/src/comments/edit/index.js +2 -1
- package/src/cover/edit/inspector-controls.js +9 -12
- 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/group/edit.js +11 -10
- package/src/image/edit.js +0 -4
- package/src/latest-comments/index.php +1 -1
- package/src/latest-posts/edit.js +113 -81
- package/src/latest-posts/index.php +3 -0
- package/src/loginout/index.php +5 -1
- package/src/media-text/style.scss +0 -2
- package/src/navigation/index.php +1 -2
- 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 +2 -6
- 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 +1 -5
- package/src/post-author/index.php +1 -1
- package/src/post-author-name/index.php +1 -1
- 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 +17 -27
- package/src/quote/index.js +1 -1
- package/src/search/index.php +12 -9
- package/src/search/style.scss +1 -0
- package/src/separator/edit.js +16 -12
- 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
- package/src/template-part/edit/advanced-controls.js +9 -8
- package/src/template-part/edit/index.js +1 -0
- package/build/utils/messages.js +0 -22
- package/build/utils/messages.js.map +0 -1
- package/build-module/utils/messages.js +0 -15
- package/build-module/utils/messages.js.map +0 -1
- 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
|
-
|
|
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.
|
|
@@ -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
|
-
|
|
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 ) =>
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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 }
|
package/src/quote/index.js
CHANGED
package/src/search/index.php
CHANGED
|
@@ -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
|
|
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 =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
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 ) {
|
package/src/search/style.scss
CHANGED
|
@@ -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 {
|