@wordpress/block-library 9.30.1-next.6f42e1382.0 → 9.30.1-next.a730c9c8c.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/build/button/edit.js +6 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +5 -8
- package/build/image/image.js.map +1 -1
- package/build/image/save.js +6 -2
- package/build/image/save.js.map +1 -1
- package/build/navigation/edit/index.js +0 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/post-date/edit.js +2 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +7 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/edit.js +8 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query/edit/pattern-selection.js +9 -1
- package/build/query/edit/pattern-selection.js.map +1 -1
- package/build/query/index.js +2 -1
- package/build/query/index.js.map +1 -1
- package/build/rss/edit.js +6 -1
- package/build/rss/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/social-link/edit.js +6 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/spacer/edit.js +2 -1
- package/build/spacer/edit.js.map +1 -1
- package/build/terms-query/inspector-controls.js +20 -35
- package/build/terms-query/inspector-controls.js.map +1 -1
- package/build/utils/hooks.js +3 -0
- package/build/utils/hooks.js.map +1 -1
- package/build-module/button/edit.js +7 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +1 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +5 -8
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/save.js +6 -2
- package/build-module/image/save.js.map +1 -1
- package/build-module/navigation/edit/index.js +0 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/post-date/edit.js +3 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -4
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/edit.js +9 -3
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query/edit/pattern-selection.js +9 -1
- package/build-module/query/edit/pattern-selection.js.map +1 -1
- package/build-module/query/index.js +2 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/rss/edit.js +8 -3
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/social-link/edit.js +8 -3
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/spacer/edit.js +3 -2
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/terms-query/inspector-controls.js +20 -35
- package/build-module/terms-query/inspector-controls.js.map +1 -1
- package/build-module/utils/hooks.js +3 -0
- package/build-module/utils/hooks.js.map +1 -1
- package/package.json +35 -35
- package/src/button/edit.js +12 -1
- package/src/button/edit.native.js +1 -1
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +5 -8
- package/src/image/save.js +7 -1
- package/src/navigation/edit/index.js +0 -1
- package/src/post-date/edit.js +64 -53
- package/src/post-date/index.php +0 -13
- package/src/post-featured-image/edit.js +19 -3
- package/src/post-title/edit.js +14 -2
- package/src/query/block.json +2 -1
- package/src/query/edit/pattern-selection.js +10 -1
- package/src/rss/edit.js +13 -2
- package/src/site-tagline/block.json +1 -0
- package/src/social-link/edit.js +13 -2
- package/src/spacer/edit.js +5 -1
- package/src/terms-query/inspector-controls.js +32 -26
- package/src/utils/hooks.js +4 -0
package/src/image/save.js
CHANGED
|
@@ -31,6 +31,7 @@ export default function save( { attributes } ) {
|
|
|
31
31
|
linkTarget,
|
|
32
32
|
sizeSlug,
|
|
33
33
|
title,
|
|
34
|
+
metadata: { bindings = {} } = {},
|
|
34
35
|
} = attributes;
|
|
35
36
|
|
|
36
37
|
const newRel = ! rel ? undefined : rel;
|
|
@@ -70,6 +71,11 @@ export default function save( { attributes } ) {
|
|
|
70
71
|
/>
|
|
71
72
|
);
|
|
72
73
|
|
|
74
|
+
const displayCaption =
|
|
75
|
+
! RichText.isEmpty( caption ) ||
|
|
76
|
+
bindings.caption ||
|
|
77
|
+
bindings?.__default?.source === 'core/pattern-overrides';
|
|
78
|
+
|
|
73
79
|
const figure = (
|
|
74
80
|
<>
|
|
75
81
|
{ href ? (
|
|
@@ -84,7 +90,7 @@ export default function save( { attributes } ) {
|
|
|
84
90
|
) : (
|
|
85
91
|
image
|
|
86
92
|
) }
|
|
87
|
-
{
|
|
93
|
+
{ displayCaption && (
|
|
88
94
|
<RichText.Content
|
|
89
95
|
className={ __experimentalGetElementClassName( 'caption' ) }
|
|
90
96
|
tagName="figcaption"
|
package/src/post-date/edit.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
InspectorControls,
|
|
20
20
|
store as blockEditorStore,
|
|
21
21
|
useBlockProps,
|
|
22
|
+
useBlockEditingMode,
|
|
22
23
|
__experimentalDateFormatPicker as DateFormatPicker,
|
|
23
24
|
__experimentalPublishDateTimePicker as PublishDateTimePicker,
|
|
24
25
|
} from '@wordpress/block-editor';
|
|
@@ -99,6 +100,8 @@ export default function PostDateEdit( {
|
|
|
99
100
|
[ postTypeSlug ]
|
|
100
101
|
);
|
|
101
102
|
|
|
103
|
+
const blockEditingMode = useBlockEditingMode();
|
|
104
|
+
|
|
102
105
|
let postDate = (
|
|
103
106
|
<time dateTime={ dateI18n( 'c', datetime ) } ref={ setPopoverAnchor }>
|
|
104
107
|
{ format === 'human-diff'
|
|
@@ -120,61 +123,69 @@ export default function PostDateEdit( {
|
|
|
120
123
|
|
|
121
124
|
return (
|
|
122
125
|
<>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
126
|
+
{ ( blockEditingMode === 'default' ||
|
|
127
|
+
! isDescendentOfQueryLoop ) && (
|
|
128
|
+
<BlockControls group="block">
|
|
129
|
+
<AlignmentControl
|
|
130
|
+
value={ textAlign }
|
|
131
|
+
onChange={ ( nextAlign ) => {
|
|
132
|
+
setAttributes( { textAlign: nextAlign } );
|
|
133
|
+
} }
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
{ displayType !== 'modified' &&
|
|
137
|
+
! isDescendentOfQueryLoop && (
|
|
138
|
+
<ToolbarGroup>
|
|
139
|
+
<Dropdown
|
|
140
|
+
popoverProps={ popoverProps }
|
|
141
|
+
renderContent={ ( { onClose } ) => (
|
|
142
|
+
<PublishDateTimePicker
|
|
143
|
+
title={
|
|
144
|
+
displayType === 'date'
|
|
145
|
+
? __( 'Publish Date' )
|
|
146
|
+
: __( 'Date' )
|
|
147
|
+
}
|
|
148
|
+
currentDate={ datetime }
|
|
149
|
+
onChange={ ( newDatetime ) =>
|
|
150
|
+
setAttributes( {
|
|
151
|
+
datetime: newDatetime,
|
|
152
|
+
} )
|
|
153
|
+
}
|
|
154
|
+
is12Hour={ is12HourFormat(
|
|
155
|
+
siteTimeFormat
|
|
156
|
+
) }
|
|
157
|
+
onClose={ onClose }
|
|
158
|
+
dateOrder={
|
|
159
|
+
/* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
|
|
160
|
+
_x( 'dmy', 'date order' )
|
|
161
|
+
}
|
|
162
|
+
/>
|
|
149
163
|
) }
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
renderToggle={ ( { isOpen, onToggle } ) => {
|
|
165
|
+
const openOnArrowDown = ( event ) => {
|
|
166
|
+
if (
|
|
167
|
+
! isOpen &&
|
|
168
|
+
event.keyCode === DOWN
|
|
169
|
+
) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
onToggle();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return (
|
|
175
|
+
<ToolbarButton
|
|
176
|
+
aria-expanded={ isOpen }
|
|
177
|
+
icon={ edit }
|
|
178
|
+
title={ __( 'Change Date' ) }
|
|
179
|
+
onClick={ onToggle }
|
|
180
|
+
onKeyDown={ openOnArrowDown }
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
} }
|
|
155
184
|
/>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
event.preventDefault();
|
|
161
|
-
onToggle();
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
return (
|
|
165
|
-
<ToolbarButton
|
|
166
|
-
aria-expanded={ isOpen }
|
|
167
|
-
icon={ edit }
|
|
168
|
-
title={ __( 'Change Date' ) }
|
|
169
|
-
onClick={ onToggle }
|
|
170
|
-
onKeyDown={ openOnArrowDown }
|
|
171
|
-
/>
|
|
172
|
-
);
|
|
173
|
-
} }
|
|
174
|
-
/>
|
|
175
|
-
</ToolbarGroup>
|
|
176
|
-
) }
|
|
177
|
-
</BlockControls>
|
|
185
|
+
</ToolbarGroup>
|
|
186
|
+
) }
|
|
187
|
+
</BlockControls>
|
|
188
|
+
) }
|
|
178
189
|
|
|
179
190
|
<InspectorControls>
|
|
180
191
|
<ToolsPanel
|
package/src/post-date/index.php
CHANGED
|
@@ -105,18 +105,5 @@ function register_block_core_post_date() {
|
|
|
105
105
|
'render_callback' => 'render_block_core_post_date',
|
|
106
106
|
)
|
|
107
107
|
);
|
|
108
|
-
|
|
109
|
-
// The following filter can be removed once the minimum required WordPress version is 6.9 or newer.
|
|
110
|
-
add_filter(
|
|
111
|
-
'block_bindings_supported_attributes_core/post-date',
|
|
112
|
-
function ( $attributes ) {
|
|
113
|
-
if ( ! in_array( 'datetime', $attributes, true ) ) {
|
|
114
|
-
$attributes[] = 'datetime';
|
|
115
|
-
}
|
|
116
|
-
return $attributes;
|
|
117
|
-
},
|
|
118
|
-
10,
|
|
119
|
-
3
|
|
120
|
-
);
|
|
121
108
|
}
|
|
122
109
|
add_action( 'init', 'register_block_core_post_date' );
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Button,
|
|
16
16
|
Spinner,
|
|
17
17
|
TextControl,
|
|
18
|
+
ExternalLink,
|
|
18
19
|
__experimentalToolsPanel as ToolsPanel,
|
|
19
20
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
20
21
|
} from '@wordpress/components';
|
|
@@ -30,7 +31,12 @@ import {
|
|
|
30
31
|
privateApis as blockEditorPrivateApis,
|
|
31
32
|
store as blockEditorStore,
|
|
32
33
|
} from '@wordpress/block-editor';
|
|
33
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
useMemo,
|
|
36
|
+
useEffect,
|
|
37
|
+
useState,
|
|
38
|
+
createInterpolateElement,
|
|
39
|
+
} from '@wordpress/element';
|
|
34
40
|
import { __, sprintf } from '@wordpress/i18n';
|
|
35
41
|
import { upload } from '@wordpress/icons';
|
|
36
42
|
import { store as noticesStore } from '@wordpress/notices';
|
|
@@ -316,7 +322,7 @@ export default function PostFeaturedImageEdit( {
|
|
|
316
322
|
) }
|
|
317
323
|
{ isLink && (
|
|
318
324
|
<ToolsPanelItem
|
|
319
|
-
label={ __( 'Link
|
|
325
|
+
label={ __( 'Link relation' ) }
|
|
320
326
|
isShownByDefault
|
|
321
327
|
hasValue={ () => !! rel }
|
|
322
328
|
onDeselect={ () =>
|
|
@@ -328,7 +334,17 @@ export default function PostFeaturedImageEdit( {
|
|
|
328
334
|
<TextControl
|
|
329
335
|
__next40pxDefaultSize
|
|
330
336
|
__nextHasNoMarginBottom
|
|
331
|
-
label={ __( 'Link
|
|
337
|
+
label={ __( 'Link relation' ) }
|
|
338
|
+
help={ createInterpolateElement(
|
|
339
|
+
__(
|
|
340
|
+
'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'
|
|
341
|
+
),
|
|
342
|
+
{
|
|
343
|
+
a: (
|
|
344
|
+
<ExternalLink href="https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" />
|
|
345
|
+
),
|
|
346
|
+
}
|
|
347
|
+
) }
|
|
332
348
|
value={ rel }
|
|
333
349
|
onChange={ ( newRel ) =>
|
|
334
350
|
setAttributes( { rel: newRel } )
|
package/src/post-title/edit.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
ToggleControl,
|
|
20
20
|
TextControl,
|
|
21
|
+
ExternalLink,
|
|
21
22
|
__experimentalToolsPanel as ToolsPanel,
|
|
22
23
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
23
24
|
} from '@wordpress/components';
|
|
@@ -25,6 +26,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
25
26
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
26
27
|
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
27
28
|
import { useSelect } from '@wordpress/data';
|
|
29
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Internal dependencies
|
|
@@ -205,7 +207,7 @@ export default function PostTitleEdit( {
|
|
|
205
207
|
/>
|
|
206
208
|
</ToolsPanelItem>
|
|
207
209
|
<ToolsPanelItem
|
|
208
|
-
label={ __( 'Link
|
|
210
|
+
label={ __( 'Link relation' ) }
|
|
209
211
|
isShownByDefault
|
|
210
212
|
hasValue={ () => !! rel }
|
|
211
213
|
onDeselect={ () =>
|
|
@@ -215,7 +217,17 @@ export default function PostTitleEdit( {
|
|
|
215
217
|
<TextControl
|
|
216
218
|
__next40pxDefaultSize
|
|
217
219
|
__nextHasNoMarginBottom
|
|
218
|
-
label={ __( 'Link
|
|
220
|
+
label={ __( 'Link relation' ) }
|
|
221
|
+
help={ createInterpolateElement(
|
|
222
|
+
__(
|
|
223
|
+
'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'
|
|
224
|
+
),
|
|
225
|
+
{
|
|
226
|
+
a: (
|
|
227
|
+
<ExternalLink href="https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" />
|
|
228
|
+
),
|
|
229
|
+
}
|
|
230
|
+
) }
|
|
219
231
|
value={ rel }
|
|
220
232
|
onChange={ ( newRel ) =>
|
|
221
233
|
setAttributes( { rel: newRel } )
|
package/src/query/block.json
CHANGED
|
@@ -43,7 +43,16 @@ export function useBlockPatterns( clientId, attributes ) {
|
|
|
43
43
|
clientId,
|
|
44
44
|
attributes
|
|
45
45
|
);
|
|
46
|
-
|
|
46
|
+
const allPatterns = usePatterns( clientId, blockNameForPatterns );
|
|
47
|
+
// Filter out any patterns that don't have Query as their root block
|
|
48
|
+
// so that a Query block is always replaced by another Query block.
|
|
49
|
+
const rootBlockPatterns = useMemo( () => {
|
|
50
|
+
return allPatterns.filter( ( pattern ) => {
|
|
51
|
+
return pattern.blocks?.[ 0 ]?.name === blockNameForPatterns;
|
|
52
|
+
} );
|
|
53
|
+
}, [ allPatterns, blockNameForPatterns ] );
|
|
54
|
+
|
|
55
|
+
return rootBlockPatterns;
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
export default function PatternSelection( {
|
package/src/rss/edit.js
CHANGED
|
@@ -14,11 +14,12 @@ import {
|
|
|
14
14
|
ToggleControl,
|
|
15
15
|
ToolbarGroup,
|
|
16
16
|
TextControl,
|
|
17
|
+
ExternalLink,
|
|
17
18
|
__experimentalInputControl as InputControl,
|
|
18
19
|
__experimentalToolsPanel as ToolsPanel,
|
|
19
20
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
20
21
|
} from '@wordpress/components';
|
|
21
|
-
import { useState } from '@wordpress/element';
|
|
22
|
+
import { createInterpolateElement, useState } from '@wordpress/element';
|
|
22
23
|
import { grid, list, edit, rss } from '@wordpress/icons';
|
|
23
24
|
import { __, _x } from '@wordpress/i18n';
|
|
24
25
|
import { prependHTTP } from '@wordpress/url';
|
|
@@ -301,7 +302,17 @@ export default function RSSEdit( { attributes, setAttributes } ) {
|
|
|
301
302
|
<TextControl
|
|
302
303
|
__next40pxDefaultSize
|
|
303
304
|
__nextHasNoMarginBottom
|
|
304
|
-
label={ __( 'Link
|
|
305
|
+
label={ __( 'Link relation' ) }
|
|
306
|
+
help={ createInterpolateElement(
|
|
307
|
+
__(
|
|
308
|
+
'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'
|
|
309
|
+
),
|
|
310
|
+
{
|
|
311
|
+
a: (
|
|
312
|
+
<ExternalLink href="https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" />
|
|
313
|
+
),
|
|
314
|
+
}
|
|
315
|
+
) }
|
|
305
316
|
value={ rel || '' }
|
|
306
317
|
onChange={ ( value ) => setAttributes( { rel: value } ) }
|
|
307
318
|
/>
|
package/src/social-link/edit.js
CHANGED
|
@@ -17,13 +17,14 @@ import {
|
|
|
17
17
|
useBlockProps,
|
|
18
18
|
store as blockEditorStore,
|
|
19
19
|
} from '@wordpress/block-editor';
|
|
20
|
-
import { useState, useRef } from '@wordpress/element';
|
|
20
|
+
import { useState, useRef, createInterpolateElement } from '@wordpress/element';
|
|
21
21
|
import {
|
|
22
22
|
Icon,
|
|
23
23
|
Button,
|
|
24
24
|
Dropdown,
|
|
25
25
|
TextControl,
|
|
26
26
|
ToolbarButton,
|
|
27
|
+
ExternalLink,
|
|
27
28
|
__experimentalToolsPanel as ToolsPanel,
|
|
28
29
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
29
30
|
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
|
|
@@ -243,7 +244,17 @@ const SocialLinkEdit = ( {
|
|
|
243
244
|
<TextControl
|
|
244
245
|
__next40pxDefaultSize
|
|
245
246
|
__nextHasNoMarginBottom
|
|
246
|
-
label={ __( 'Link
|
|
247
|
+
label={ __( 'Link relation' ) }
|
|
248
|
+
help={ createInterpolateElement(
|
|
249
|
+
__(
|
|
250
|
+
'The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'
|
|
251
|
+
),
|
|
252
|
+
{
|
|
253
|
+
a: (
|
|
254
|
+
<ExternalLink href="https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" />
|
|
255
|
+
),
|
|
256
|
+
}
|
|
257
|
+
) }
|
|
247
258
|
value={ rel || '' }
|
|
248
259
|
onChange={ ( value ) => setAttributes( { rel: value } ) }
|
|
249
260
|
/>
|
package/src/spacer/edit.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getSpacingPresetCssVar,
|
|
13
13
|
store as blockEditorStore,
|
|
14
14
|
privateApis as blockEditorPrivateApis,
|
|
15
|
+
useBlockEditingMode,
|
|
15
16
|
} from '@wordpress/block-editor';
|
|
16
17
|
import { ResizableBox } from '@wordpress/components';
|
|
17
18
|
import { useState, useEffect } from '@wordpress/element';
|
|
@@ -346,6 +347,8 @@ const SpacerEdit = ( {
|
|
|
346
347
|
__unstableMarkNextChangeAsNotPersistent,
|
|
347
348
|
] );
|
|
348
349
|
|
|
350
|
+
const blockEditingMode = useBlockEditingMode();
|
|
351
|
+
|
|
349
352
|
return (
|
|
350
353
|
<>
|
|
351
354
|
<View
|
|
@@ -356,7 +359,8 @@ const SpacerEdit = ( {
|
|
|
356
359
|
} ),
|
|
357
360
|
} ) }
|
|
358
361
|
>
|
|
359
|
-
{
|
|
362
|
+
{ blockEditingMode === 'default' &&
|
|
363
|
+
resizableBoxWithOrientation( inheritedOrientation ) }
|
|
360
364
|
</View>
|
|
361
365
|
{ ! isFlexLayout && (
|
|
362
366
|
<SpacerControls
|
|
@@ -89,28 +89,14 @@ export default function TermsQueryInspectorControls( {
|
|
|
89
89
|
</ToolsPanelItem>
|
|
90
90
|
|
|
91
91
|
<ToolsPanelItem
|
|
92
|
-
hasValue={ () =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
>
|
|
97
|
-
<SelectControl
|
|
98
|
-
__nextHasNoMarginBottom
|
|
99
|
-
__next40pxDefaultSize
|
|
100
|
-
label={ __( 'Order' ) }
|
|
101
|
-
options={ [
|
|
102
|
-
{ label: __( 'Ascending' ), value: 'asc' },
|
|
103
|
-
{ label: __( 'Descending' ), value: 'desc' },
|
|
104
|
-
] }
|
|
105
|
-
value={ termQuery.order }
|
|
106
|
-
onChange={ ( order ) => setQuery( { order } ) }
|
|
107
|
-
/>
|
|
108
|
-
</ToolsPanelItem>
|
|
109
|
-
|
|
110
|
-
<ToolsPanelItem
|
|
111
|
-
hasValue={ () => termQuery.orderBy !== 'name' }
|
|
92
|
+
hasValue={ () =>
|
|
93
|
+
termQuery.orderBy !== 'name' ||
|
|
94
|
+
termQuery.order !== 'asc'
|
|
95
|
+
}
|
|
112
96
|
label={ __( 'Order by' ) }
|
|
113
|
-
onDeselect={ () =>
|
|
97
|
+
onDeselect={ () =>
|
|
98
|
+
setQuery( { orderBy: 'name', order: 'asc' } )
|
|
99
|
+
}
|
|
114
100
|
isShownByDefault
|
|
115
101
|
>
|
|
116
102
|
<SelectControl
|
|
@@ -118,12 +104,32 @@ export default function TermsQueryInspectorControls( {
|
|
|
118
104
|
__next40pxDefaultSize
|
|
119
105
|
label={ __( 'Order by' ) }
|
|
120
106
|
options={ [
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
107
|
+
{
|
|
108
|
+
label: __( 'Name: A → Z' ),
|
|
109
|
+
value: 'name/asc',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: __( 'Name: Z → A' ),
|
|
113
|
+
value: 'name/desc',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: __( 'Count, high to low' ),
|
|
117
|
+
value: 'count/desc',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: __( 'Count, low to high' ),
|
|
121
|
+
value: 'count/asc',
|
|
122
|
+
},
|
|
124
123
|
] }
|
|
125
|
-
value={ termQuery.orderBy }
|
|
126
|
-
onChange={ ( orderBy ) =>
|
|
124
|
+
value={ termQuery.orderBy + '/' + termQuery.order }
|
|
125
|
+
onChange={ ( orderBy ) => {
|
|
126
|
+
const [ newOrderBy, newOrder ] =
|
|
127
|
+
orderBy.split( '/' );
|
|
128
|
+
setQuery( {
|
|
129
|
+
orderBy: newOrderBy,
|
|
130
|
+
order: newOrder,
|
|
131
|
+
} );
|
|
132
|
+
} }
|
|
127
133
|
/>
|
|
128
134
|
</ToolsPanelItem>
|
|
129
135
|
|
package/src/utils/hooks.js
CHANGED
|
@@ -66,6 +66,10 @@ export function useUploadMediaFromBlobURL( args = {} ) {
|
|
|
66
66
|
const { url, allowedTypes, onChange, onError } = latestArgsRef.current;
|
|
67
67
|
const { mediaUpload } = getSettings();
|
|
68
68
|
|
|
69
|
+
if ( ! mediaUpload ) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
hasUploadStartedRef.current = true;
|
|
70
74
|
|
|
71
75
|
mediaUpload( {
|