@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.
Files changed (87) hide show
  1. package/build/button/edit.js +6 -1
  2. package/build/button/edit.js.map +1 -1
  3. package/build/button/edit.native.js +1 -1
  4. package/build/button/edit.native.js.map +1 -1
  5. package/build/image/edit.native.js +1 -1
  6. package/build/image/edit.native.js.map +1 -1
  7. package/build/image/image.js +5 -8
  8. package/build/image/image.js.map +1 -1
  9. package/build/image/save.js +6 -2
  10. package/build/image/save.js.map +1 -1
  11. package/build/navigation/edit/index.js +0 -1
  12. package/build/navigation/edit/index.js.map +1 -1
  13. package/build/post-date/edit.js +2 -1
  14. package/build/post-date/edit.js.map +1 -1
  15. package/build/post-featured-image/edit.js +7 -2
  16. package/build/post-featured-image/edit.js.map +1 -1
  17. package/build/post-title/edit.js +8 -2
  18. package/build/post-title/edit.js.map +1 -1
  19. package/build/query/edit/pattern-selection.js +9 -1
  20. package/build/query/edit/pattern-selection.js.map +1 -1
  21. package/build/query/index.js +2 -1
  22. package/build/query/index.js.map +1 -1
  23. package/build/rss/edit.js +6 -1
  24. package/build/rss/edit.js.map +1 -1
  25. package/build/site-tagline/index.js +1 -0
  26. package/build/site-tagline/index.js.map +1 -1
  27. package/build/social-link/edit.js +6 -1
  28. package/build/social-link/edit.js.map +1 -1
  29. package/build/spacer/edit.js +2 -1
  30. package/build/spacer/edit.js.map +1 -1
  31. package/build/terms-query/inspector-controls.js +20 -35
  32. package/build/terms-query/inspector-controls.js.map +1 -1
  33. package/build/utils/hooks.js +3 -0
  34. package/build/utils/hooks.js.map +1 -1
  35. package/build-module/button/edit.js +7 -2
  36. package/build-module/button/edit.js.map +1 -1
  37. package/build-module/button/edit.native.js +1 -1
  38. package/build-module/button/edit.native.js.map +1 -1
  39. package/build-module/image/edit.native.js +1 -1
  40. package/build-module/image/edit.native.js.map +1 -1
  41. package/build-module/image/image.js +5 -8
  42. package/build-module/image/image.js.map +1 -1
  43. package/build-module/image/save.js +6 -2
  44. package/build-module/image/save.js.map +1 -1
  45. package/build-module/navigation/edit/index.js +0 -1
  46. package/build-module/navigation/edit/index.js.map +1 -1
  47. package/build-module/post-date/edit.js +3 -2
  48. package/build-module/post-date/edit.js.map +1 -1
  49. package/build-module/post-featured-image/edit.js +9 -4
  50. package/build-module/post-featured-image/edit.js.map +1 -1
  51. package/build-module/post-title/edit.js +9 -3
  52. package/build-module/post-title/edit.js.map +1 -1
  53. package/build-module/query/edit/pattern-selection.js +9 -1
  54. package/build-module/query/edit/pattern-selection.js.map +1 -1
  55. package/build-module/query/index.js +2 -1
  56. package/build-module/query/index.js.map +1 -1
  57. package/build-module/rss/edit.js +8 -3
  58. package/build-module/rss/edit.js.map +1 -1
  59. package/build-module/site-tagline/index.js +1 -0
  60. package/build-module/site-tagline/index.js.map +1 -1
  61. package/build-module/social-link/edit.js +8 -3
  62. package/build-module/social-link/edit.js.map +1 -1
  63. package/build-module/spacer/edit.js +3 -2
  64. package/build-module/spacer/edit.js.map +1 -1
  65. package/build-module/terms-query/inspector-controls.js +20 -35
  66. package/build-module/terms-query/inspector-controls.js.map +1 -1
  67. package/build-module/utils/hooks.js +3 -0
  68. package/build-module/utils/hooks.js.map +1 -1
  69. package/package.json +35 -35
  70. package/src/button/edit.js +12 -1
  71. package/src/button/edit.native.js +1 -1
  72. package/src/image/edit.native.js +1 -1
  73. package/src/image/image.js +5 -8
  74. package/src/image/save.js +7 -1
  75. package/src/navigation/edit/index.js +0 -1
  76. package/src/post-date/edit.js +64 -53
  77. package/src/post-date/index.php +0 -13
  78. package/src/post-featured-image/edit.js +19 -3
  79. package/src/post-title/edit.js +14 -2
  80. package/src/query/block.json +2 -1
  81. package/src/query/edit/pattern-selection.js +10 -1
  82. package/src/rss/edit.js +13 -2
  83. package/src/site-tagline/block.json +1 -0
  84. package/src/social-link/edit.js +13 -2
  85. package/src/spacer/edit.js +5 -1
  86. package/src/terms-query/inspector-controls.js +32 -26
  87. 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
- { ! RichText.isEmpty( caption ) && (
93
+ { displayCaption && (
88
94
  <RichText.Content
89
95
  className={ __experimentalGetElementClassName( 'caption' ) }
90
96
  tagName="figcaption"
@@ -112,7 +112,6 @@ function NavigationAddPageButton( { clientId } ) {
112
112
  <ToolbarButton
113
113
  name="add-page"
114
114
  icon={ page }
115
- title={ __( 'Add page' ) }
116
115
  onClick={ onAddPage }
117
116
  >
118
117
  { __( 'Add page' ) }
@@ -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
- <BlockControls group="block">
124
- <AlignmentControl
125
- value={ textAlign }
126
- onChange={ ( nextAlign ) => {
127
- setAttributes( { textAlign: nextAlign } );
128
- } }
129
- />
130
- { displayType !== 'modified' && ! isDescendentOfQueryLoop && (
131
- <ToolbarGroup>
132
- <Dropdown
133
- popoverProps={ popoverProps }
134
- renderContent={ ( { onClose } ) => (
135
- <PublishDateTimePicker
136
- title={
137
- displayType === 'date'
138
- ? __( 'Publish Date' )
139
- : __( 'Date' )
140
- }
141
- currentDate={ datetime }
142
- onChange={ ( newDatetime ) =>
143
- setAttributes( {
144
- datetime: newDatetime,
145
- } )
146
- }
147
- is12Hour={ is12HourFormat(
148
- siteTimeFormat
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
- onClose={ onClose }
151
- dateOrder={
152
- /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
153
- _x( 'dmy', 'date order' )
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
- renderToggle={ ( { isOpen, onToggle } ) => {
158
- const openOnArrowDown = ( event ) => {
159
- if ( ! isOpen && event.keyCode === DOWN ) {
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
@@ -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 { useMemo, useEffect, useState } from '@wordpress/element';
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 rel' ) }
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 rel' ) }
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 } )
@@ -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 rel' ) }
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 rel' ) }
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 } )
@@ -53,7 +53,8 @@
53
53
  "align": [ "wide", "full" ],
54
54
  "html": false,
55
55
  "layout": true,
56
- "interactivity": true
56
+ "interactivity": true,
57
+ "contentRole": true
57
58
  },
58
59
  "editorStyle": "wp-block-query-editor"
59
60
  }
@@ -43,7 +43,16 @@ export function useBlockPatterns( clientId, attributes ) {
43
43
  clientId,
44
44
  attributes
45
45
  );
46
- return usePatterns( clientId, blockNameForPatterns );
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 rel' ) }
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
  />
@@ -36,6 +36,7 @@
36
36
  "text": true
37
37
  }
38
38
  },
39
+ "contentRole": true,
39
40
  "spacing": {
40
41
  "margin": true,
41
42
  "padding": true,
@@ -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 rel' ) }
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
  />
@@ -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
- { resizableBoxWithOrientation( inheritedOrientation ) }
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={ () => termQuery.order !== 'asc' }
93
- label={ __( 'Order' ) }
94
- onDeselect={ () => setQuery( { order: 'asc' } ) }
95
- isShownByDefault
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={ () => setQuery( { orderBy: 'name' } ) }
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
- { label: __( 'Name' ), value: 'name' },
122
- { label: __( 'Slug' ), value: 'slug' },
123
- { label: __( 'Count' ), value: 'count' },
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 ) => setQuery( { 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
 
@@ -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( {