@wordpress/block-library 7.9.0 → 7.10.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 (205) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/comment-template/index.js +1 -1
  3. package/build/comments/deprecated.js +65 -0
  4. package/build/comments/deprecated.js.map +1 -0
  5. package/build/comments/index.js +5 -2
  6. package/build/comments/index.js.map +1 -1
  7. package/build/comments-pagination/index.js +1 -1
  8. package/build/comments-title/deprecated.js +1 -1
  9. package/build/comments-title/index.js +1 -1
  10. package/build/cover/edit/block-controls.js +2 -12
  11. package/build/cover/edit/block-controls.js.map +1 -1
  12. package/build/cover/edit/cover-placeholder.js +3 -1
  13. package/build/cover/edit/cover-placeholder.js.map +1 -1
  14. package/build/cover/edit/index.js +19 -4
  15. package/build/cover/edit/index.js.map +1 -1
  16. package/build/gallery/edit.js +9 -17
  17. package/build/gallery/edit.js.map +1 -1
  18. package/build/gallery/transforms.js +30 -20
  19. package/build/gallery/transforms.js.map +1 -1
  20. package/build/gallery/use-get-media.js +7 -18
  21. package/build/gallery/use-get-media.js.map +1 -1
  22. package/build/group/edit.js +1 -3
  23. package/build/group/edit.js.map +1 -1
  24. package/build/heading/heading-level-dropdown.js +2 -1
  25. package/build/heading/heading-level-dropdown.js.map +1 -1
  26. package/build/heading/index.js +9 -4
  27. package/build/heading/index.js.map +1 -1
  28. package/build/latest-posts/edit.js +1 -1
  29. package/build/latest-posts/edit.js.map +1 -1
  30. package/build/more/edit.js +2 -4
  31. package/build/more/edit.js.map +1 -1
  32. package/build/navigation/view.js +7 -4
  33. package/build/navigation/view.js.map +1 -1
  34. package/build/navigation-link/hooks.js +0 -16
  35. package/build/navigation-link/hooks.js.map +1 -1
  36. package/build/navigation-link/index.js +1 -1
  37. package/build/navigation-link/index.js.map +1 -1
  38. package/build/navigation-submenu/view.js +7 -4
  39. package/build/navigation-submenu/view.js.map +1 -1
  40. package/build/nextpage/edit.js +1 -3
  41. package/build/nextpage/edit.js.map +1 -1
  42. package/build/page-list/edit.js +2 -2
  43. package/build/page-list/edit.js.map +1 -1
  44. package/build/post-comments-form/edit.js +2 -4
  45. package/build/post-comments-form/edit.js.map +1 -1
  46. package/build/post-terms/index.js +1 -1
  47. package/build/post-terms/index.js.map +1 -1
  48. package/build/post-title/index.js +1 -0
  49. package/build/post-title/index.js.map +1 -1
  50. package/build/query/edit/inspector-controls/index.js +1 -1
  51. package/build/query/edit/inspector-controls/index.js.map +1 -1
  52. package/build/query/index.js +1 -1
  53. package/build/query/index.js.map +1 -1
  54. package/build/site-logo/edit.js +5 -13
  55. package/build/site-logo/edit.js.map +1 -1
  56. package/build/site-title/edit/level-toolbar.js +2 -1
  57. package/build/site-title/edit/level-toolbar.js.map +1 -1
  58. package/build/template-part/index.js +1 -1
  59. package/build/template-part/index.js.map +1 -1
  60. package/build/template-part/variations.js +0 -16
  61. package/build/template-part/variations.js.map +1 -1
  62. package/build/utils/clean-empty-object.js +5 -3
  63. package/build/utils/clean-empty-object.js.map +1 -1
  64. package/build/video/tracks-editor.js +9 -11
  65. package/build/video/tracks-editor.js.map +1 -1
  66. package/build-module/comment-template/index.js +1 -1
  67. package/build-module/comments/deprecated.js +54 -0
  68. package/build-module/comments/deprecated.js.map +1 -0
  69. package/build-module/comments/index.js +4 -2
  70. package/build-module/comments/index.js.map +1 -1
  71. package/build-module/comments-pagination/index.js +1 -1
  72. package/build-module/comments-title/deprecated.js +1 -1
  73. package/build-module/comments-title/index.js +1 -1
  74. package/build-module/cover/edit/block-controls.js +3 -13
  75. package/build-module/cover/edit/block-controls.js.map +1 -1
  76. package/build-module/cover/edit/cover-placeholder.js +3 -1
  77. package/build-module/cover/edit/cover-placeholder.js.map +1 -1
  78. package/build-module/cover/edit/index.js +19 -4
  79. package/build-module/cover/edit/index.js.map +1 -1
  80. package/build-module/gallery/edit.js +9 -16
  81. package/build-module/gallery/edit.js.map +1 -1
  82. package/build-module/gallery/transforms.js +30 -20
  83. package/build-module/gallery/transforms.js.map +1 -1
  84. package/build-module/gallery/use-get-media.js +6 -16
  85. package/build-module/gallery/use-get-media.js.map +1 -1
  86. package/build-module/group/edit.js +1 -3
  87. package/build-module/group/edit.js.map +1 -1
  88. package/build-module/heading/heading-level-dropdown.js +2 -1
  89. package/build-module/heading/heading-level-dropdown.js.map +1 -1
  90. package/build-module/heading/index.js +9 -4
  91. package/build-module/heading/index.js.map +1 -1
  92. package/build-module/latest-posts/edit.js +2 -2
  93. package/build-module/latest-posts/edit.js.map +1 -1
  94. package/build-module/more/edit.js +2 -4
  95. package/build-module/more/edit.js.map +1 -1
  96. package/build-module/navigation/view.js +7 -4
  97. package/build-module/navigation/view.js.map +1 -1
  98. package/build-module/navigation-link/hooks.js +0 -13
  99. package/build-module/navigation-link/hooks.js.map +1 -1
  100. package/build-module/navigation-link/index.js +1 -1
  101. package/build-module/navigation-link/index.js.map +1 -1
  102. package/build-module/navigation-submenu/view.js +7 -4
  103. package/build-module/navigation-submenu/view.js.map +1 -1
  104. package/build-module/nextpage/edit.js +1 -3
  105. package/build-module/nextpage/edit.js.map +1 -1
  106. package/build-module/page-list/edit.js +2 -2
  107. package/build-module/page-list/edit.js.map +1 -1
  108. package/build-module/post-comments-form/edit.js +2 -4
  109. package/build-module/post-comments-form/edit.js.map +1 -1
  110. package/build-module/post-terms/index.js +1 -1
  111. package/build-module/post-terms/index.js.map +1 -1
  112. package/build-module/post-title/index.js +1 -0
  113. package/build-module/post-title/index.js.map +1 -1
  114. package/build-module/query/edit/inspector-controls/index.js +1 -1
  115. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  116. package/build-module/query/index.js +1 -1
  117. package/build-module/query/index.js.map +1 -1
  118. package/build-module/site-logo/edit.js +5 -13
  119. package/build-module/site-logo/edit.js.map +1 -1
  120. package/build-module/site-title/edit/level-toolbar.js +2 -1
  121. package/build-module/site-title/edit/level-toolbar.js.map +1 -1
  122. package/build-module/template-part/index.js +1 -1
  123. package/build-module/template-part/index.js.map +1 -1
  124. package/build-module/template-part/variations.js +0 -13
  125. package/build-module/template-part/variations.js.map +1 -1
  126. package/build-module/utils/clean-empty-object.js +5 -2
  127. package/build-module/utils/clean-empty-object.js.map +1 -1
  128. package/build-module/video/tracks-editor.js +9 -11
  129. package/build-module/video/tracks-editor.js.map +1 -1
  130. package/build-style/comment-template/style-rtl.css +12 -0
  131. package/build-style/comment-template/style.css +12 -0
  132. package/build-style/editor-rtl.css +1 -1
  133. package/build-style/editor.css +1 -1
  134. package/build-style/elements-rtl.css +82 -0
  135. package/build-style/elements.css +82 -0
  136. package/build-style/query/editor-rtl.css +1 -1
  137. package/build-style/query/editor.css +1 -1
  138. package/build-style/search/theme-rtl.css +5 -0
  139. package/build-style/search/theme.css +5 -0
  140. package/build-style/style-rtl.css +19 -0
  141. package/build-style/style.css +19 -0
  142. package/build-style/theme-rtl.css +5 -0
  143. package/build-style/theme.css +5 -0
  144. package/package.json +28 -28
  145. package/src/comment-template/block.json +1 -1
  146. package/src/comment-template/style.scss +14 -0
  147. package/src/comments/block.json +1 -1
  148. package/src/comments/deprecated.js +53 -0
  149. package/src/comments/index.js +2 -0
  150. package/src/comments-pagination/block.json +1 -1
  151. package/src/comments-title/block.json +1 -1
  152. package/src/cover/edit/block-controls.js +4 -20
  153. package/src/cover/edit/cover-placeholder.js +2 -0
  154. package/src/cover/edit/index.js +16 -0
  155. package/src/elements.scss +6 -0
  156. package/src/gallery/edit.js +8 -21
  157. package/src/gallery/index.php +1 -1
  158. package/src/gallery/transforms.js +25 -10
  159. package/src/gallery/use-get-media.js +11 -28
  160. package/src/group/edit.js +1 -3
  161. package/src/heading/heading-level-dropdown.js +1 -0
  162. package/src/heading/index.js +8 -2
  163. package/src/latest-posts/edit.js +2 -6
  164. package/src/more/edit.js +9 -11
  165. package/src/navigation/style.scss +1 -1
  166. package/src/navigation/view.js +6 -6
  167. package/src/navigation-link/hooks.js +0 -14
  168. package/src/navigation-link/index.js +1 -1
  169. package/src/navigation-link/test/__snapshots__/hooks.js.snap +0 -93
  170. package/src/navigation-link/test/hooks.js +0 -12
  171. package/src/navigation-submenu/view.js +6 -6
  172. package/src/nextpage/edit.js +1 -3
  173. package/src/page-list/edit.js +3 -5
  174. package/src/post-comments-form/edit.js +4 -7
  175. package/src/post-template/index.php +8 -14
  176. package/src/post-terms/index.js +1 -1
  177. package/src/post-title/block.json +1 -0
  178. package/src/query/edit/inspector-controls/index.js +1 -1
  179. package/src/query/editor.scss +1 -1
  180. package/src/query/index.js +1 -1
  181. package/src/query-no-results/index.php +10 -8
  182. package/src/search/theme.scss +5 -0
  183. package/src/site-logo/edit.js +2 -11
  184. package/src/site-title/edit/level-toolbar.js +1 -0
  185. package/src/social-link/index.php +16 -0
  186. package/src/style.scss +1 -0
  187. package/src/template-part/index.js +1 -1
  188. package/src/template-part/variations.js +0 -11
  189. package/src/utils/clean-empty-object.js +8 -2
  190. package/src/video/tracks-editor.js +1 -1
  191. package/build/gallery/use-short-code-transform.js +0 -64
  192. package/build/gallery/use-short-code-transform.js.map +0 -1
  193. package/build/navigation-link/fallback-variations.js +0 -75
  194. package/build/navigation-link/fallback-variations.js.map +0 -1
  195. package/build/template-part/fallback-variations.js +0 -59
  196. package/build/template-part/fallback-variations.js.map +0 -1
  197. package/build-module/gallery/use-short-code-transform.js +0 -54
  198. package/build-module/gallery/use-short-code-transform.js.map +0 -1
  199. package/build-module/navigation-link/fallback-variations.js +0 -65
  200. package/build-module/navigation-link/fallback-variations.js.map +0 -1
  201. package/build-module/template-part/fallback-variations.js +0 -47
  202. package/build-module/template-part/fallback-variations.js.map +0 -1
  203. package/src/gallery/use-short-code-transform.js +0 -55
  204. package/src/navigation-link/fallback-variations.js +0 -65
  205. package/src/template-part/fallback-variations.js +0 -51
@@ -14,22 +14,17 @@ import { __ } from '@wordpress/i18n';
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
- import { ALLOWED_MEDIA_TYPES, IMAGE_BACKGROUND_TYPE } from '../shared';
17
+ import { ALLOWED_MEDIA_TYPES } from '../shared';
18
18
 
19
19
  export default function CoverBlockControls( {
20
20
  attributes,
21
21
  setAttributes,
22
22
  onSelectMedia,
23
23
  currentSettings,
24
+ toggleUseFeaturedImage,
24
25
  } ) {
25
- const {
26
- contentPosition,
27
- id,
28
- useFeaturedImage,
29
- dimRatio,
30
- minHeight,
31
- minHeightUnit,
32
- } = attributes;
26
+ const { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =
27
+ attributes;
33
28
  const { hasInnerBlocks, url } = currentSettings;
34
29
 
35
30
  const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
@@ -63,17 +58,6 @@ export default function CoverBlockControls( {
63
58
  } );
64
59
  };
65
60
 
66
- const toggleUseFeaturedImage = () => {
67
- setAttributes( {
68
- id: undefined,
69
- url: undefined,
70
- useFeaturedImage: ! useFeaturedImage,
71
- dimRatio: dimRatio === 100 ? 50 : dimRatio,
72
- backgroundType: useFeaturedImage
73
- ? IMAGE_BACKGROUND_TYPE
74
- : undefined,
75
- } );
76
- };
77
61
  return (
78
62
  <>
79
63
  <BlockControls group="block">
@@ -16,6 +16,7 @@ export default function CoverPlaceholder( {
16
16
  onSelectMedia,
17
17
  onError,
18
18
  style,
19
+ toggleUseFeaturedImage,
19
20
  } ) {
20
21
  return (
21
22
  <MediaPlaceholder
@@ -30,6 +31,7 @@ export default function CoverPlaceholder( {
30
31
  accept="image/*,video/*"
31
32
  allowedTypes={ ALLOWED_MEDIA_TYPES }
32
33
  disableMediaButtons={ disableMediaButtons }
34
+ onToggleFeaturedImage={ toggleUseFeaturedImage }
33
35
  onError={ onError }
34
36
  style={ style }
35
37
  >
@@ -211,12 +211,25 @@ function CoverEdit( {
211
211
  overlayColor,
212
212
  };
213
213
 
214
+ const toggleUseFeaturedImage = () => {
215
+ setAttributes( {
216
+ id: undefined,
217
+ url: undefined,
218
+ useFeaturedImage: ! useFeaturedImage,
219
+ dimRatio: dimRatio === 100 ? 50 : dimRatio,
220
+ backgroundType: useFeaturedImage
221
+ ? IMAGE_BACKGROUND_TYPE
222
+ : undefined,
223
+ } );
224
+ };
225
+
214
226
  const blockControls = (
215
227
  <CoverBlockControls
216
228
  attributes={ attributes }
217
229
  setAttributes={ setAttributes }
218
230
  onSelectMedia={ onSelectMedia }
219
231
  currentSettings={ currentSettings }
232
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
220
233
  />
221
234
  );
222
235
 
@@ -228,6 +241,7 @@ function CoverEdit( {
228
241
  setOverlayColor={ setOverlayColor }
229
242
  coverRef={ ref }
230
243
  currentSettings={ currentSettings }
244
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
231
245
  />
232
246
  );
233
247
 
@@ -249,6 +263,7 @@ function CoverEdit( {
249
263
  style={ {
250
264
  minHeight: minHeightWithUnit || undefined,
251
265
  } }
266
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
252
267
  >
253
268
  <div className="wp-block-cover__placeholder-background-options">
254
269
  <ColorPalette
@@ -384,6 +399,7 @@ function CoverEdit( {
384
399
  disableMediaButtons
385
400
  onSelectMedia={ onSelectMedia }
386
401
  onError={ onUploadError }
402
+ toggleUseFeaturedImage={ toggleUseFeaturedImage }
387
403
  />
388
404
  <div { ...innerBlocksProps } />
389
405
  </div>
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Element styles.
3
+ */
4
+ .wp-element-button {
5
+ cursor: pointer;
6
+ }
@@ -51,7 +51,6 @@ import {
51
51
  LINK_DESTINATION_NONE,
52
52
  } from './constants';
53
53
  import useImageSizes from './use-image-sizes';
54
- import useShortCodeTransform from './use-short-code-transform';
55
54
  import useGetNewImages from './use-get-new-images';
56
55
  import useGetMedia from './use-get-media';
57
56
  import GapStyles from './gap-styles';
@@ -87,14 +86,7 @@ function GalleryEdit( props ) {
87
86
  insertBlocksAfter,
88
87
  } = props;
89
88
 
90
- const {
91
- columns,
92
- imageCrop,
93
- linkTarget,
94
- linkTo,
95
- shortCodeTransforms,
96
- sizeSlug,
97
- } = attributes;
89
+ const { columns, imageCrop, linkTarget, linkTo, sizeSlug } = attributes;
98
90
 
99
91
  const {
100
92
  __unstableMarkNextChangeAsNotPersistent,
@@ -151,6 +143,8 @@ function GalleryEdit( props ) {
151
143
 
152
144
  useEffect( () => {
153
145
  newImages?.forEach( ( newImage ) => {
146
+ // Update the images data without creating new undo levels.
147
+ __unstableMarkNextChangeAsNotPersistent();
154
148
  updateBlockAttributes( newImage.clientId, {
155
149
  ...buildImageAttributes( newImage.attributes ),
156
150
  id: newImage.id,
@@ -162,16 +156,6 @@ function GalleryEdit( props ) {
162
156
  }
163
157
  }, [ newImages ] );
164
158
 
165
- const shortCodeImages = useShortCodeTransform( shortCodeTransforms );
166
-
167
- useEffect( () => {
168
- if ( ! shortCodeTransforms || ! shortCodeImages ) {
169
- return;
170
- }
171
- updateImages( shortCodeImages );
172
- setAttributes( { shortCodeTransforms: undefined } );
173
- }, [ shortCodeTransforms, shortCodeImages ] );
174
-
175
159
  const imageSizeOptions = useImageSizes(
176
160
  imageData,
177
161
  isSelected,
@@ -208,8 +192,9 @@ function GalleryEdit( props ) {
208
192
  ...getHrefAndDestination( image, linkTo ),
209
193
  ...getUpdatedLinkTargetSettings( linkTarget, attributes ),
210
194
  className: newClassName,
211
- caption: imageAttributes.caption,
212
195
  sizeSlug,
196
+ caption: imageAttributes.caption || image.caption?.raw,
197
+ alt: imageAttributes.alt || image.alt_text,
213
198
  };
214
199
  }
215
200
 
@@ -547,7 +532,9 @@ function GalleryEdit( props ) {
547
532
  onSelect={ updateImages }
548
533
  name={ __( 'Add' ) }
549
534
  multiple={ true }
550
- mediaIds={ images.map( ( image ) => image.id ) }
535
+ mediaIds={ images
536
+ .filter( ( image ) => image.id )
537
+ .map( ( image ) => image.id ) }
551
538
  addToGallery={ hasImageIds }
552
539
  />
553
540
  </BlockControls>
@@ -81,7 +81,7 @@ function block_core_gallery_render( $attributes, $content ) {
81
81
  }
82
82
 
83
83
  // Set the CSS variable to the column value, and the `gap` property to the combined gap value.
84
- $style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
84
+ $style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
85
85
 
86
86
  gutenberg_enqueue_block_support_styles( $style, 11 );
87
87
  return $content;
@@ -195,16 +195,6 @@ const transforms = {
195
195
  }
196
196
  },
197
197
  },
198
- shortCodeTransforms: {
199
- type: 'array',
200
- shortcode: ( { named: { ids } } ) => {
201
- if ( isGalleryV2Enabled() ) {
202
- return parseShortcodeIds( ids ).map( ( id ) => ( {
203
- id: parseInt( id ),
204
- } ) );
205
- }
206
- },
207
- },
208
198
  columns: {
209
199
  type: 'number',
210
200
  shortcode: ( { named: { columns = '3' } } ) => {
@@ -235,6 +225,31 @@ const transforms = {
235
225
  },
236
226
  },
237
227
  },
228
+ transform( { named: { ids, columns = 3, link } } ) {
229
+ const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
230
+ parseInt( id, 10 )
231
+ );
232
+
233
+ let linkTo = LINK_DESTINATION_NONE;
234
+ if ( link === 'post' ) {
235
+ linkTo = LINK_DESTINATION_ATTACHMENT;
236
+ } else if ( link === 'file' ) {
237
+ linkTo = LINK_DESTINATION_MEDIA;
238
+ }
239
+
240
+ const galleryBlock = createBlock(
241
+ 'core/gallery',
242
+ {
243
+ columns: parseInt( columns, 10 ),
244
+ linkTo,
245
+ },
246
+ imageIds.map( ( imageId ) =>
247
+ createBlock( 'core/image', { id: imageId } )
248
+ )
249
+ );
250
+
251
+ return galleryBlock;
252
+ },
238
253
  isMatch( { named } ) {
239
254
  return undefined !== named.ids;
240
255
  },
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useState } from '@wordpress/element';
5
4
  import { useSelect } from '@wordpress/data';
6
5
  import { store as coreStore } from '@wordpress/core-data';
7
6
 
7
+ const EMPTY_IMAGE_MEDIA = [];
8
+
8
9
  /**
9
10
  * Retrieves the extended media info for each gallery image from the store. This is used to
10
11
  * determine which image size options are available for the current gallery.
@@ -14,42 +15,24 @@ import { store as coreStore } from '@wordpress/core-data';
14
15
  * @return {Array} An array of media info options for each gallery image.
15
16
  */
16
17
  export default function useGetMedia( innerBlockImages ) {
17
- const [ currentImageMedia, setCurrentImageMedia ] = useState( [] );
18
-
19
- const imageMedia = useSelect(
18
+ return useSelect(
20
19
  ( select ) => {
21
- if ( ! innerBlockImages?.length ) {
22
- return currentImageMedia;
23
- }
24
-
25
20
  const imageIds = innerBlockImages
26
21
  .map( ( imageBlock ) => imageBlock.attributes.id )
27
22
  .filter( ( id ) => id !== undefined );
28
23
 
29
24
  if ( imageIds.length === 0 ) {
30
- return currentImageMedia;
25
+ return EMPTY_IMAGE_MEDIA;
31
26
  }
32
27
 
33
- return select( coreStore ).getMediaItems( {
34
- include: imageIds.join( ',' ),
35
- per_page: imageIds.length,
36
- orderby: 'include',
37
- } );
28
+ return (
29
+ select( coreStore ).getMediaItems( {
30
+ include: imageIds.join( ',' ),
31
+ per_page: imageIds.length,
32
+ orderby: 'include',
33
+ } ) ?? EMPTY_IMAGE_MEDIA
34
+ );
38
35
  },
39
36
  [ innerBlockImages ]
40
37
  );
41
-
42
- if (
43
- imageMedia?.length !== currentImageMedia?.length ||
44
- imageMedia?.some(
45
- ( newImage ) =>
46
- ! currentImageMedia.find(
47
- ( currentImage ) => currentImage.id === newImage.id
48
- )
49
- )
50
- ) {
51
- setCurrentImageMedia( imageMedia );
52
- return imageMedia;
53
- }
54
- return currentImageMedia;
55
38
  }
package/src/group/edit.js CHANGED
@@ -52,9 +52,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
52
52
  const { type = 'default' } = usedLayout;
53
53
  const layoutSupportEnabled = themeSupportsLayout || type !== 'default';
54
54
 
55
- const blockProps = useBlockProps( {
56
- className: `is-layout-${ type }`,
57
- } );
55
+ const blockProps = useBlockProps();
58
56
 
59
57
  const innerBlocksProps = useInnerBlocksProps(
60
58
  layoutSupportEnabled
@@ -60,6 +60,7 @@ export default function HeadingLevelDropdown( { selectedLevel, onChange } ) {
60
60
  onClick() {
61
61
  onChange( targetLevel );
62
62
  },
63
+ role: 'menuitemradio',
63
64
  };
64
65
  }
65
66
  } ) }
@@ -31,9 +31,15 @@ export const settings = {
31
31
  },
32
32
  },
33
33
  __experimentalLabel( attributes, { context } ) {
34
- if ( context === 'accessibility' ) {
35
- const { content, level } = attributes;
34
+ const { content, level } = attributes;
35
+
36
+ // In the list view, use the block's content as the label.
37
+ // If the content is empty, fall back to the default label.
38
+ if ( context === 'list-view' && content ) {
39
+ return content;
40
+ }
36
41
 
42
+ if ( context === 'accessibility' ) {
37
43
  return isEmpty( content )
38
44
  ? sprintf(
39
45
  /* translators: accessibility text. %s: heading level. */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, includes, invoke, pickBy } from 'lodash';
4
+ import { get, includes, pickBy } from 'lodash';
5
5
  import classnames from 'classnames';
6
6
 
7
7
  /**
@@ -432,11 +432,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
432
432
  </BlockControls>
433
433
  <ul { ...blockProps }>
434
434
  { displayPosts.map( ( post, i ) => {
435
- const titleTrimmed = invoke( post, [
436
- 'title',
437
- 'rendered',
438
- 'trim',
439
- ] );
435
+ const titleTrimmed = post.title.rendered.trim();
440
436
  let excerpt = post.excerpt.rendered;
441
437
  const currentAuthor = authorList?.find(
442
438
  ( author ) => author.id === post.author
package/src/more/edit.js CHANGED
@@ -53,17 +53,15 @@ export default function MoreEdit( {
53
53
  </PanelBody>
54
54
  </InspectorControls>
55
55
  <div { ...useBlockProps() }>
56
- <div className="wp-block-more">
57
- <input
58
- aria-label={ __( 'Read more link text' ) }
59
- type="text"
60
- value={ customText }
61
- placeholder={ DEFAULT_TEXT }
62
- onChange={ onChangeInput }
63
- onKeyDown={ onKeyDown }
64
- style={ style }
65
- />
66
- </div>
56
+ <input
57
+ aria-label={ __( 'Read more link text' ) }
58
+ type="text"
59
+ value={ customText }
60
+ placeholder={ DEFAULT_TEXT }
61
+ onChange={ onChangeInput }
62
+ onKeyDown={ onKeyDown }
63
+ style={ style }
64
+ />
67
65
  </div>
68
66
  </>
69
67
  );
@@ -105,7 +105,7 @@ $navigation-icon-size: 24px;
105
105
  width: inherit;
106
106
  height: inherit;
107
107
 
108
- // Position the arrow to balance with the the text.
108
+ // Position the arrow to balance with the text.
109
109
  margin-top: 0.075em;
110
110
  }
111
111
  }
@@ -4,8 +4,6 @@ function closeSubmenus( element ) {
4
4
  .querySelectorAll( '[aria-expanded="true"]' )
5
5
  .forEach( function ( toggle ) {
6
6
  toggle.setAttribute( 'aria-expanded', 'false' );
7
- // Always focus the trigger, this becomes especially useful in closing submenus with escape key to ensure focus doesn't get trapped.
8
- toggle.focus();
9
7
  } );
10
8
  }
11
9
 
@@ -63,11 +61,13 @@ window.addEventListener( 'load', () => {
63
61
  '.wp-block-navigation-item.has-child'
64
62
  );
65
63
  submenuBlocks.forEach( function ( block ) {
66
- if (
67
- ! block.contains( event.target ) ||
68
- ( block.contains( event.target ) && event.key === 'Escape' )
69
- ) {
64
+ if ( ! block.contains( event.target ) ) {
65
+ closeSubmenus( block );
66
+ } else if ( event.key === 'Escape' ) {
67
+ const toggle = block.querySelector( '[aria-expanded="true"]' );
70
68
  closeSubmenus( block );
69
+ // Focus the submenu trigger so focus does not get trapped in the closed submenu.
70
+ toggle?.focus();
71
71
  }
72
72
  } );
73
73
  } );
@@ -9,11 +9,6 @@ import {
9
9
  customPostType,
10
10
  } from '@wordpress/icons';
11
11
 
12
- /**
13
- * Internal dependencies
14
- */
15
- import fallbackVariations from './fallback-variations';
16
-
17
12
  function getIcon( variationName ) {
18
13
  switch ( variationName ) {
19
14
  case 'post':
@@ -34,15 +29,6 @@ export function enhanceNavigationLinkVariations( settings, name ) {
34
29
  return settings;
35
30
  }
36
31
 
37
- // Fallback handling may be deleted after supported WP ranges understand the `variations`
38
- // property when passed to register_block_type in index.php.
39
- if ( ! settings.variations ) {
40
- return {
41
- ...settings,
42
- variations: fallbackVariations,
43
- };
44
- }
45
-
46
32
  // Otherwise decorate server passed variations with an icon and isActive function.
47
33
  if ( settings.variations ) {
48
34
  const isActive = ( blockAttributes, variationAttributes ) => {
@@ -88,7 +88,7 @@ export const settings = {
88
88
  transforms,
89
89
  };
90
90
 
91
- // importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects
91
+ // importing this file includes side effects. This is added in block-library/package.json under sideEffects
92
92
  addFilter(
93
93
  'blocks.registerBlockType',
94
94
  'core/navigation-link',
@@ -1,98 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`hooks enhanceNavigationLinkVariations adds fallback variations when variations are missing 1`] = `
4
- Object {
5
- "name": "core/navigation-link",
6
- "one": "one",
7
- "three": "three",
8
- "two": "two",
9
- "variations": Array [
10
- Object {
11
- "attributes": Object {},
12
- "description": "A link to a custom URL.",
13
- "isActive": [Function],
14
- "isDefault": true,
15
- "name": "link",
16
- "title": "Custom Link",
17
- },
18
- Object {
19
- "attributes": Object {
20
- "kind": "post-type",
21
- "type": "post",
22
- },
23
- "description": "A link to a post.",
24
- "icon": <SVG
25
- viewBox="0 0 24 24"
26
- xmlns="https://www.w3.org/2000/svg"
27
- >
28
- <Path
29
- d="M4 20h16v-1.5H4V20zm0-4.8h16v-1.5H4v1.5zm0-6.4v1.5h16V8.8H4zM16 4H4v1.5h12V4z"
30
- />
31
- </SVG>,
32
- "isActive": [Function],
33
- "name": "post",
34
- "title": "Post Link",
35
- },
36
- Object {
37
- "attributes": Object {
38
- "kind": "post-type",
39
- "type": "page",
40
- },
41
- "description": "A link to a page.",
42
- "icon": <SVG
43
- viewBox="0 0 24 24"
44
- xmlns="http://www.w3.org/2000/svg"
45
- >
46
- <Path
47
- d="M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
48
- />
49
- </SVG>,
50
- "isActive": [Function],
51
- "name": "page",
52
- "title": "Page Link",
53
- },
54
- Object {
55
- "attributes": Object {
56
- "kind": "taxonomy",
57
- "type": "category",
58
- },
59
- "description": "A link to a category.",
60
- "icon": <SVG
61
- viewBox="0 0 24 24"
62
- xmlns="http://www.w3.org/2000/svg"
63
- >
64
- <Path
65
- clipRule="evenodd"
66
- d="M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z"
67
- fillRule="evenodd"
68
- />
69
- </SVG>,
70
- "isActive": [Function],
71
- "name": "category",
72
- "title": "Category Link",
73
- },
74
- Object {
75
- "attributes": Object {
76
- "kind": "taxonomy",
77
- "type": "tag",
78
- },
79
- "description": "A link to a tag.",
80
- "icon": <SVG
81
- viewBox="0 0 24 24"
82
- xmlns="http://www.w3.org/2000/svg"
83
- >
84
- <Path
85
- d="M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
86
- />
87
- </SVG>,
88
- "isActive": [Function],
89
- "name": "tag",
90
- "title": "Tag Link",
91
- },
92
- ],
93
- }
94
- `;
95
-
96
3
  exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and isActive functions 1`] = `
97
4
  Object {
98
5
  "extraProp": "extraProp",
@@ -26,18 +26,6 @@ describe( 'hooks', () => {
26
26
  three: 'three',
27
27
  } );
28
28
  } );
29
- it( 'adds fallback variations when variations are missing', () => {
30
- const updatedSettings = enhanceNavigationLinkVariations(
31
- {
32
- name: 'core/navigation-link',
33
- one: 'one',
34
- two: 'two',
35
- three: 'three',
36
- },
37
- 'core/navigation-link'
38
- );
39
- expect( updatedSettings ).toMatchSnapshot();
40
- } );
41
29
  it( 'enhances variations with icon and isActive functions', () => {
42
30
  const updatedSettings = enhanceNavigationLinkVariations(
43
31
  {
@@ -3,8 +3,6 @@ const closeSubmenus = ( element ) => {
3
3
  .querySelectorAll( '[aria-expanded="true"]' )
4
4
  .forEach( ( toggle ) => {
5
5
  toggle.setAttribute( 'aria-expanded', 'false' );
6
- // Always focus the trigger, this becomes especially useful in closing submenus with escape key to ensure focus doesn't get trapped.
7
- toggle.focus();
8
6
  } );
9
7
  };
10
8
 
@@ -57,11 +55,13 @@ document.addEventListener( 'keyup', function ( event ) {
57
55
  '.wp-block-navigation-submenu'
58
56
  );
59
57
  submenuBlocks.forEach( ( block ) => {
60
- if (
61
- ! block.contains( event.target ) ||
62
- ( block.contains( event.target ) && event.key === 'Escape' )
63
- ) {
58
+ if ( ! block.contains( event.target ) ) {
59
+ closeSubmenus( block );
60
+ } else if ( event.key === 'Escape' ) {
61
+ const toggle = block.querySelector( '[aria-expanded="true"]' );
64
62
  closeSubmenus( block );
63
+ // Focus the submenu trigger so focus does not get trapped in the closed submenu.
64
+ toggle?.focus();
65
65
  }
66
66
  } );
67
67
  } );
@@ -7,9 +7,7 @@ import { useBlockProps } from '@wordpress/block-editor';
7
7
  export default function NextPageEdit() {
8
8
  return (
9
9
  <div { ...useBlockProps() }>
10
- <div className="wp-block-nextpage">
11
- <span>{ __( 'Page break' ) }</span>
12
- </div>
10
+ <span>{ __( 'Page break' ) }</span>
13
11
  </div>
14
12
  );
15
13
  }
@@ -76,11 +76,9 @@ export default function PageListEdit( { context, clientId } ) {
76
76
 
77
77
  { hasResolvedPages && totalPages === null && (
78
78
  <div { ...blockProps }>
79
- <div { ...blockProps }>
80
- <Notice status={ 'warning' } isDismissible={ false }>
81
- { __( 'Page List: Cannot retrieve Pages.' ) }
82
- </Notice>
83
- </div>
79
+ <Notice status={ 'warning' } isDismissible={ false }>
80
+ { __( 'Page List: Cannot retrieve Pages.' ) }
81
+ </Notice>
84
82
  </div>
85
83
  ) }
86
84