@wordpress/block-library 8.25.1-next.79a6196f.0 → 8.27.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/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +75 -12
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -1
- package/build/paragraph/transforms.js +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +74 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -1
- package/build-module/paragraph/transforms.js +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +1 -2
- package/build-style/cover/style.css +1 -2
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +19 -11
- package/build-style/style.css +19 -11
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +96 -14
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -1
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import {
|
|
16
|
-
InspectorControls,
|
|
17
|
-
privateApis as blockEditorPrivateApis,
|
|
18
|
-
} from '@wordpress/block-editor';
|
|
15
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
19
16
|
import { debounce } from '@wordpress/compose';
|
|
20
17
|
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
21
18
|
|
|
@@ -138,156 +135,150 @@ export default function QueryInspectorControls( props ) {
|
|
|
138
135
|
<CreateNewPostLink { ...props } />
|
|
139
136
|
</BlockInfo>
|
|
140
137
|
{ showSettingsPanel && (
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
138
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
139
|
+
{ showInheritControl && (
|
|
140
|
+
<ToggleControl
|
|
141
|
+
__nextHasNoMarginBottom
|
|
142
|
+
label={ __( 'Inherit query from template' ) }
|
|
143
|
+
help={ __(
|
|
144
|
+
'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
|
|
145
|
+
) }
|
|
146
|
+
checked={ !! inherit }
|
|
147
|
+
onChange={ ( value ) =>
|
|
148
|
+
setQuery( { inherit: !! value } )
|
|
149
|
+
}
|
|
150
|
+
/>
|
|
151
|
+
) }
|
|
152
|
+
{ showPostTypeControl && (
|
|
153
|
+
<SelectControl
|
|
154
|
+
__nextHasNoMarginBottom
|
|
155
|
+
options={ postTypesSelectOptions }
|
|
156
|
+
value={ postType }
|
|
157
|
+
label={ __( 'Post type' ) }
|
|
158
|
+
onChange={ onPostTypeChange }
|
|
159
|
+
help={ __(
|
|
160
|
+
'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'
|
|
161
|
+
) }
|
|
162
|
+
/>
|
|
163
|
+
) }
|
|
164
|
+
{ showColumnsControl && (
|
|
165
|
+
<>
|
|
166
|
+
<RangeControl
|
|
158
167
|
__nextHasNoMarginBottom
|
|
159
|
-
|
|
160
|
-
value={
|
|
161
|
-
label={ __( 'Post type' ) }
|
|
162
|
-
onChange={ onPostTypeChange }
|
|
163
|
-
help={ __(
|
|
164
|
-
'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'
|
|
165
|
-
) }
|
|
166
|
-
/>
|
|
167
|
-
) }
|
|
168
|
-
{ showColumnsControl && (
|
|
169
|
-
<>
|
|
170
|
-
<RangeControl
|
|
171
|
-
__nextHasNoMarginBottom
|
|
172
|
-
label={ __( 'Columns' ) }
|
|
173
|
-
value={ displayLayout.columns }
|
|
174
|
-
onChange={ ( value ) =>
|
|
175
|
-
setDisplayLayout( {
|
|
176
|
-
columns: value,
|
|
177
|
-
} )
|
|
178
|
-
}
|
|
179
|
-
min={ 2 }
|
|
180
|
-
max={ Math.max( 6, displayLayout.columns ) }
|
|
181
|
-
/>
|
|
182
|
-
{ displayLayout.columns > 6 && (
|
|
183
|
-
<Notice
|
|
184
|
-
status="warning"
|
|
185
|
-
isDismissible={ false }
|
|
186
|
-
>
|
|
187
|
-
{ __(
|
|
188
|
-
'This column count exceeds the recommended amount and may cause visual breakage.'
|
|
189
|
-
) }
|
|
190
|
-
</Notice>
|
|
191
|
-
) }
|
|
192
|
-
</>
|
|
193
|
-
) }
|
|
194
|
-
{ showOrderControl && (
|
|
195
|
-
<OrderControl
|
|
196
|
-
{ ...{ order, orderBy } }
|
|
197
|
-
onChange={ setQuery }
|
|
198
|
-
/>
|
|
199
|
-
) }
|
|
200
|
-
{ showStickyControl && (
|
|
201
|
-
<StickyControl
|
|
202
|
-
value={ sticky }
|
|
168
|
+
label={ __( 'Columns' ) }
|
|
169
|
+
value={ displayLayout.columns }
|
|
203
170
|
onChange={ ( value ) =>
|
|
204
|
-
|
|
171
|
+
setDisplayLayout( {
|
|
172
|
+
columns: value,
|
|
173
|
+
} )
|
|
205
174
|
}
|
|
175
|
+
min={ 2 }
|
|
176
|
+
max={ Math.max( 6, displayLayout.columns ) }
|
|
206
177
|
/>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
178
|
+
{ displayLayout.columns > 6 && (
|
|
179
|
+
<Notice
|
|
180
|
+
status="warning"
|
|
181
|
+
isDismissible={ false }
|
|
182
|
+
>
|
|
183
|
+
{ __(
|
|
184
|
+
'This column count exceeds the recommended amount and may cause visual breakage.'
|
|
185
|
+
) }
|
|
186
|
+
</Notice>
|
|
187
|
+
) }
|
|
188
|
+
</>
|
|
189
|
+
) }
|
|
190
|
+
{ showOrderControl && (
|
|
191
|
+
<OrderControl
|
|
192
|
+
{ ...{ order, orderBy } }
|
|
193
|
+
onChange={ setQuery }
|
|
194
|
+
/>
|
|
195
|
+
) }
|
|
196
|
+
{ showStickyControl && (
|
|
197
|
+
<StickyControl
|
|
198
|
+
value={ sticky }
|
|
199
|
+
onChange={ ( value ) =>
|
|
200
|
+
setQuery( { sticky: value } )
|
|
201
|
+
}
|
|
212
202
|
/>
|
|
213
|
-
|
|
214
|
-
|
|
203
|
+
) }
|
|
204
|
+
<EnhancedPaginationControl
|
|
205
|
+
enhancedPagination={ enhancedPagination }
|
|
206
|
+
setAttributes={ setAttributes }
|
|
207
|
+
clientId={ clientId }
|
|
208
|
+
/>
|
|
209
|
+
</PanelBody>
|
|
215
210
|
) }
|
|
216
211
|
{ ! inherit && showFiltersPanel && (
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
212
|
+
<ToolsPanel
|
|
213
|
+
className="block-library-query-toolspanel__filters"
|
|
214
|
+
label={ __( 'Filters' ) }
|
|
215
|
+
resetAll={ () => {
|
|
216
|
+
setQuery( {
|
|
217
|
+
author: '',
|
|
218
|
+
parents: [],
|
|
219
|
+
search: '',
|
|
220
|
+
taxQuery: null,
|
|
221
|
+
} );
|
|
222
|
+
setQuerySearch( '' );
|
|
223
|
+
} }
|
|
224
|
+
dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
|
|
225
|
+
>
|
|
226
|
+
{ showTaxControl && (
|
|
227
|
+
<ToolsPanelItem
|
|
228
|
+
label={ __( 'Taxonomies' ) }
|
|
229
|
+
hasValue={ () =>
|
|
230
|
+
Object.values( taxQuery || {} ).some(
|
|
231
|
+
( terms ) => !! terms.length
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
onDeselect={ () => setQuery( { taxQuery: null } ) }
|
|
235
|
+
>
|
|
236
|
+
<TaxonomyControls
|
|
237
|
+
onChange={ setQuery }
|
|
238
|
+
query={ query }
|
|
239
|
+
/>
|
|
240
|
+
</ToolsPanelItem>
|
|
241
|
+
) }
|
|
242
|
+
{ showAuthorControl && (
|
|
243
|
+
<ToolsPanelItem
|
|
244
|
+
hasValue={ () => !! authorIds }
|
|
245
|
+
label={ __( 'Authors' ) }
|
|
246
|
+
onDeselect={ () => setQuery( { author: '' } ) }
|
|
247
|
+
>
|
|
248
|
+
<AuthorControl
|
|
249
|
+
value={ authorIds }
|
|
250
|
+
onChange={ setQuery }
|
|
251
|
+
/>
|
|
252
|
+
</ToolsPanelItem>
|
|
253
|
+
) }
|
|
254
|
+
{ showSearchControl && (
|
|
255
|
+
<ToolsPanelItem
|
|
256
|
+
hasValue={ () => !! querySearch }
|
|
257
|
+
label={ __( 'Keyword' ) }
|
|
258
|
+
onDeselect={ () => setQuerySearch( '' ) }
|
|
259
|
+
>
|
|
260
|
+
<TextControl
|
|
261
|
+
__nextHasNoMarginBottom
|
|
265
262
|
label={ __( 'Keyword' ) }
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
onChange={ setQuery }
|
|
286
|
-
/>
|
|
287
|
-
</ToolsPanelItem>
|
|
288
|
-
) }
|
|
289
|
-
</ToolsPanel>
|
|
290
|
-
</InspectorControls>
|
|
263
|
+
value={ querySearch }
|
|
264
|
+
onChange={ setQuerySearch }
|
|
265
|
+
/>
|
|
266
|
+
</ToolsPanelItem>
|
|
267
|
+
) }
|
|
268
|
+
{ showParentControl && (
|
|
269
|
+
<ToolsPanelItem
|
|
270
|
+
hasValue={ () => !! parents?.length }
|
|
271
|
+
label={ __( 'Parents' ) }
|
|
272
|
+
onDeselect={ () => setQuery( { parents: [] } ) }
|
|
273
|
+
>
|
|
274
|
+
<ParentControl
|
|
275
|
+
parents={ parents }
|
|
276
|
+
postType={ postType }
|
|
277
|
+
onChange={ setQuery }
|
|
278
|
+
/>
|
|
279
|
+
</ToolsPanelItem>
|
|
280
|
+
) }
|
|
281
|
+
</ToolsPanel>
|
|
291
282
|
) }
|
|
292
283
|
</>
|
|
293
284
|
);
|
|
@@ -112,13 +112,15 @@ export default function QueryContent( {
|
|
|
112
112
|
setAttributes={ setAttributes }
|
|
113
113
|
clientId={ clientId }
|
|
114
114
|
/>
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
<InspectorControls>
|
|
116
|
+
<QueryInspectorControls
|
|
117
|
+
attributes={ attributes }
|
|
118
|
+
setQuery={ updateQuery }
|
|
119
|
+
setDisplayLayout={ updateDisplayLayout }
|
|
120
|
+
setAttributes={ setAttributes }
|
|
121
|
+
clientId={ clientId }
|
|
122
|
+
/>
|
|
123
|
+
</InspectorControls>
|
|
122
124
|
<BlockControls>
|
|
123
125
|
<QueryToolbar
|
|
124
126
|
name={ name }
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
useBlockProps,
|
|
12
12
|
store as blockEditorStore,
|
|
13
13
|
__experimentalBlockVariationPicker,
|
|
14
|
-
__experimentalGetMatchingVariation as getMatchingVariation,
|
|
15
14
|
} from '@wordpress/block-editor';
|
|
16
15
|
import { Button, Placeholder } from '@wordpress/components';
|
|
17
16
|
import { __ } from '@wordpress/i18n';
|
|
@@ -34,31 +33,32 @@ export default function QueryPlaceholder( {
|
|
|
34
33
|
clientId,
|
|
35
34
|
attributes
|
|
36
35
|
);
|
|
37
|
-
|
|
38
|
-
const { blockType, allVariations, hasPatterns } = useSelect(
|
|
36
|
+
const { blockType, activeBlockVariation, hasPatterns } = useSelect(
|
|
39
37
|
( select ) => {
|
|
40
|
-
const {
|
|
38
|
+
const { getActiveBlockVariation, getBlockType } =
|
|
39
|
+
select( blocksStore );
|
|
41
40
|
const { getBlockRootClientId, getPatternsByBlockTypes } =
|
|
42
41
|
select( blockEditorStore );
|
|
43
42
|
const rootClientId = getBlockRootClientId( clientId );
|
|
44
43
|
return {
|
|
45
44
|
blockType: getBlockType( name ),
|
|
46
|
-
|
|
45
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
46
|
+
name,
|
|
47
|
+
attributes
|
|
48
|
+
),
|
|
47
49
|
hasPatterns: !! getPatternsByBlockTypes(
|
|
48
50
|
blockNameForPatterns,
|
|
49
51
|
rootClientId
|
|
50
52
|
).length,
|
|
51
53
|
};
|
|
52
54
|
},
|
|
53
|
-
[ name, blockNameForPatterns, clientId ]
|
|
55
|
+
[ name, blockNameForPatterns, clientId, attributes ]
|
|
54
56
|
);
|
|
55
|
-
|
|
56
|
-
const matchingVariation = getMatchingVariation( attributes, allVariations );
|
|
57
57
|
const icon =
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
activeBlockVariation?.icon?.src ||
|
|
59
|
+
activeBlockVariation?.icon ||
|
|
60
60
|
blockType?.icon?.src;
|
|
61
|
-
const label =
|
|
61
|
+
const label = activeBlockVariation?.title || blockType?.title;
|
|
62
62
|
if ( isStartingBlank ) {
|
|
63
63
|
return (
|
|
64
64
|
<QueryVariationPicker
|
package/src/query/index.php
CHANGED
|
@@ -17,12 +17,19 @@
|
|
|
17
17
|
* @return string Returns the modified output of the query block.
|
|
18
18
|
*/
|
|
19
19
|
function render_block_core_query( $attributes, $content, $block ) {
|
|
20
|
-
|
|
20
|
+
$is_interactive = isset( $attributes['enhancedPagination'] ) && true === $attributes['enhancedPagination'] && isset( $attributes['queryId'] );
|
|
21
|
+
|
|
22
|
+
// Enqueue the script module and add the necessary directives if the block is
|
|
23
|
+
// interactive.
|
|
24
|
+
if ( $is_interactive ) {
|
|
25
|
+
wp_enqueue_script_module( '@wordpress/block-library/query' );
|
|
26
|
+
|
|
21
27
|
$p = new WP_HTML_Tag_Processor( $content );
|
|
22
28
|
if ( $p->next_tag() ) {
|
|
23
29
|
// Add the necessary directives.
|
|
24
30
|
$p->set_attribute( 'data-wp-interactive', '{"namespace":"core/query"}' );
|
|
25
|
-
$p->set_attribute( 'data-wp-
|
|
31
|
+
$p->set_attribute( 'data-wp-router-region', 'query-' . $attributes['queryId'] );
|
|
32
|
+
$p->set_attribute( 'data-wp-init', 'callbacks.setQueryRef' );
|
|
26
33
|
// Use context to send translated strings.
|
|
27
34
|
$p->set_attribute(
|
|
28
35
|
'data-wp-context',
|
|
@@ -63,43 +70,17 @@ function render_block_core_query( $attributes, $content, $block ) {
|
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
$view_asset = 'wp-block-query-view';
|
|
69
|
-
$script_handles = $block->block_type->view_script_handles;
|
|
70
|
-
|
|
71
|
-
if ( $is_gutenberg_plugin ) {
|
|
72
|
-
if ( $should_load_view_script ) {
|
|
73
|
-
gutenberg_enqueue_module( '@wordpress/block-library/query' );
|
|
74
|
-
}
|
|
75
|
-
// Remove the view script because we are using the module.
|
|
76
|
-
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
|
77
|
-
} else {
|
|
78
|
-
if ( ! wp_script_is( $view_asset ) ) {
|
|
79
|
-
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
80
|
-
if ( ! $should_load_view_script && in_array( $view_asset, $script_handles, true )
|
|
81
|
-
) {
|
|
82
|
-
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
|
83
|
-
}
|
|
84
|
-
// If the script is needed, but it was previously removed, add it again.
|
|
85
|
-
if ( $should_load_view_script && ! in_array( $view_asset, $script_handles, true ) ) {
|
|
86
|
-
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_asset ) );
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
73
|
+
// Add the styles to the block type if the block is interactive and remove
|
|
74
|
+
// them if it's not.
|
|
91
75
|
$style_asset = 'wp-block-query';
|
|
92
76
|
if ( ! wp_style_is( $style_asset ) ) {
|
|
93
77
|
$style_handles = $block->block_type->style_handles;
|
|
94
78
|
// If the styles are not needed, and they are still in the `style_handles`, remove them.
|
|
95
|
-
if (
|
|
96
|
-
( ! $attributes['enhancedPagination'] || ! isset( $attributes['queryId'] ) )
|
|
97
|
-
&& in_array( $style_asset, $style_handles, true )
|
|
98
|
-
) {
|
|
79
|
+
if ( ! $is_interactive && in_array( $style_asset, $style_handles, true ) ) {
|
|
99
80
|
$block->block_type->style_handles = array_diff( $style_handles, array( $style_asset ) );
|
|
100
81
|
}
|
|
101
82
|
// If the styles are needed, but they were previously removed, add them again.
|
|
102
|
-
if ( $
|
|
83
|
+
if ( $is_interactive && ! in_array( $style_asset, $style_handles, true ) ) {
|
|
103
84
|
$block->block_type->style_handles = array_merge( $style_handles, array( $style_asset ) );
|
|
104
85
|
}
|
|
105
86
|
}
|
|
@@ -107,25 +88,6 @@ function render_block_core_query( $attributes, $content, $block ) {
|
|
|
107
88
|
return $content;
|
|
108
89
|
}
|
|
109
90
|
|
|
110
|
-
/**
|
|
111
|
-
* Ensure that the view script has the `wp-interactivity` dependency.
|
|
112
|
-
*
|
|
113
|
-
* @since 6.4.0
|
|
114
|
-
*
|
|
115
|
-
* @global WP_Scripts $wp_scripts
|
|
116
|
-
*/
|
|
117
|
-
function block_core_query_ensure_interactivity_dependency() {
|
|
118
|
-
global $wp_scripts;
|
|
119
|
-
if (
|
|
120
|
-
isset( $wp_scripts->registered['wp-block-query-view'] ) &&
|
|
121
|
-
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-query-view']->deps, true )
|
|
122
|
-
) {
|
|
123
|
-
$wp_scripts->registered['wp-block-query-view']->deps[] = 'wp-interactivity';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
add_action( 'wp_print_scripts', 'block_core_query_ensure_interactivity_dependency' );
|
|
128
|
-
|
|
129
91
|
/**
|
|
130
92
|
* Registers the `core/query` block on the server.
|
|
131
93
|
*/
|
|
@@ -137,14 +99,21 @@ function register_block_core_query() {
|
|
|
137
99
|
)
|
|
138
100
|
);
|
|
139
101
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
array(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
102
|
+
wp_register_script_module(
|
|
103
|
+
'@wordpress/block-library/query',
|
|
104
|
+
gutenberg_url( '/build/interactivity/query.min.js' ),
|
|
105
|
+
array(
|
|
106
|
+
array(
|
|
107
|
+
'id' => '@wordpress/interactivity',
|
|
108
|
+
'import' => 'static',
|
|
109
|
+
),
|
|
110
|
+
array(
|
|
111
|
+
'id' => '@wordpress/interactivity-router',
|
|
112
|
+
'import' => 'dynamic',
|
|
113
|
+
),
|
|
114
|
+
),
|
|
115
|
+
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
|
|
116
|
+
);
|
|
148
117
|
}
|
|
149
118
|
add_action( 'init', 'register_block_core_query' );
|
|
150
119
|
|
|
@@ -164,14 +133,10 @@ function block_core_query_disable_enhanced_pagination( $parsed_block ) {
|
|
|
164
133
|
static $dirty_enhanced_queries = array();
|
|
165
134
|
static $render_query_callback = null;
|
|
166
135
|
|
|
167
|
-
$
|
|
136
|
+
$is_interactive = isset( $parsed_block['attrs']['enhancedPagination'] ) && true === $parsed_block['attrs']['enhancedPagination'] && isset( $parsed_block['attrs']['queryId'] );
|
|
137
|
+
$block_name = $parsed_block['blockName'];
|
|
168
138
|
|
|
169
|
-
if (
|
|
170
|
-
'core/query' === $block_name &&
|
|
171
|
-
isset( $parsed_block['attrs']['enhancedPagination'] ) &&
|
|
172
|
-
true === $parsed_block['attrs']['enhancedPagination'] &&
|
|
173
|
-
isset( $parsed_block['attrs']['queryId'] )
|
|
174
|
-
) {
|
|
139
|
+
if ( 'core/query' === $block_name && $is_interactive ) {
|
|
175
140
|
$enhanced_query_stack[] = $parsed_block['attrs']['queryId'];
|
|
176
141
|
|
|
177
142
|
if ( ! isset( $render_query_callback ) ) {
|
|
@@ -186,12 +151,9 @@ function block_core_query_disable_enhanced_pagination( $parsed_block ) {
|
|
|
186
151
|
* @return string Returns the modified output of the query block.
|
|
187
152
|
*/
|
|
188
153
|
$render_query_callback = static function ( $content, $block ) use ( &$enhanced_query_stack, &$dirty_enhanced_queries, &$render_query_callback ) {
|
|
189
|
-
$
|
|
190
|
-
isset( $block['attrs']['enhancedPagination'] ) &&
|
|
191
|
-
true === $block['attrs']['enhancedPagination'] &&
|
|
192
|
-
isset( $block['attrs']['queryId'] );
|
|
154
|
+
$is_interactive = isset( $block['attrs']['enhancedPagination'] ) && true === $block['attrs']['enhancedPagination'] && isset( $block['attrs']['queryId'] );
|
|
193
155
|
|
|
194
|
-
if ( ! $
|
|
156
|
+
if ( ! $is_interactive ) {
|
|
195
157
|
return $content;
|
|
196
158
|
}
|
|
197
159
|
|
package/src/query/variations.js
CHANGED
|
@@ -39,6 +39,7 @@ const variations = [
|
|
|
39
39
|
),
|
|
40
40
|
icon: postList,
|
|
41
41
|
attributes: {
|
|
42
|
+
namespace: 'core/posts-list',
|
|
42
43
|
query: {
|
|
43
44
|
perPage: 4,
|
|
44
45
|
pages: 1,
|
|
@@ -53,6 +54,9 @@ const variations = [
|
|
|
53
54
|
},
|
|
54
55
|
},
|
|
55
56
|
scope: [ 'inserter' ],
|
|
57
|
+
isActive: ( { namespace, query } ) => {
|
|
58
|
+
return namespace === 'core/posts-list' && query.postType === 'post';
|
|
59
|
+
},
|
|
56
60
|
},
|
|
57
61
|
{
|
|
58
62
|
name: 'title-date',
|
package/src/query/view.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
store,
|
|
6
|
-
getContext,
|
|
7
|
-
getElement,
|
|
8
|
-
navigate,
|
|
9
|
-
prefetch,
|
|
10
|
-
} from '@wordpress/interactivity';
|
|
4
|
+
import { store, getContext, getElement } from '@wordpress/interactivity';
|
|
11
5
|
|
|
12
6
|
const isValidLink = ( ref ) =>
|
|
13
7
|
ref &&
|
|
@@ -37,22 +31,22 @@ store( 'core/query', {
|
|
|
37
31
|
*navigate( event ) {
|
|
38
32
|
const ctx = getContext();
|
|
39
33
|
const { ref } = getElement();
|
|
40
|
-
const
|
|
41
|
-
|
|
34
|
+
const { queryRef } = ctx;
|
|
35
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
42
36
|
|
|
43
37
|
if ( isValidLink( ref ) && isValidEvent( event ) && ! isDisabled ) {
|
|
44
38
|
event.preventDefault();
|
|
45
39
|
|
|
46
|
-
const id = ref.closest( '[data-wp-navigation-id]' ).dataset
|
|
47
|
-
.wpNavigationId;
|
|
48
|
-
|
|
49
40
|
// Don't announce the navigation immediately, wait 400 ms.
|
|
50
41
|
const timeout = setTimeout( () => {
|
|
51
42
|
ctx.message = ctx.loadingText;
|
|
52
43
|
ctx.animation = 'start';
|
|
53
44
|
}, 400 );
|
|
54
45
|
|
|
55
|
-
yield
|
|
46
|
+
const { actions } = yield import(
|
|
47
|
+
'@wordpress/interactivity-router'
|
|
48
|
+
);
|
|
49
|
+
yield actions.navigate( ref.href );
|
|
56
50
|
|
|
57
51
|
// Dismiss loading message if it hasn't been added yet.
|
|
58
52
|
clearTimeout( timeout );
|
|
@@ -68,16 +62,19 @@ store( 'core/query', {
|
|
|
68
62
|
ctx.url = ref.href;
|
|
69
63
|
|
|
70
64
|
// Focus the first anchor of the Query block.
|
|
71
|
-
const firstAnchor =
|
|
72
|
-
|
|
65
|
+
const firstAnchor = `.wp-block-post-template a[href]`;
|
|
66
|
+
queryRef.querySelector( firstAnchor )?.focus();
|
|
73
67
|
}
|
|
74
68
|
},
|
|
75
69
|
*prefetch() {
|
|
70
|
+
const { queryRef } = getContext();
|
|
76
71
|
const { ref } = getElement();
|
|
77
|
-
const isDisabled =
|
|
78
|
-
.wpNavigationDisabled;
|
|
72
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
79
73
|
if ( isValidLink( ref ) && ! isDisabled ) {
|
|
80
|
-
yield
|
|
74
|
+
const { actions } = yield import(
|
|
75
|
+
'@wordpress/interactivity-router'
|
|
76
|
+
);
|
|
77
|
+
yield actions.prefetch( ref.href );
|
|
81
78
|
}
|
|
82
79
|
},
|
|
83
80
|
},
|
|
@@ -86,8 +83,16 @@ store( 'core/query', {
|
|
|
86
83
|
const { url } = getContext();
|
|
87
84
|
const { ref } = getElement();
|
|
88
85
|
if ( url && isValidLink( ref ) ) {
|
|
89
|
-
yield
|
|
86
|
+
const { actions } = yield import(
|
|
87
|
+
'@wordpress/interactivity-router'
|
|
88
|
+
);
|
|
89
|
+
yield actions.prefetch( ref.href );
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
+
setQueryRef() {
|
|
93
|
+
const ctx = getContext();
|
|
94
|
+
const { ref } = getElement();
|
|
95
|
+
ctx.queryRef = ref;
|
|
96
|
+
},
|
|
92
97
|
},
|
|
93
98
|
} );
|