@wordpress/block-library 7.17.0 → 7.18.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 (233) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +44 -4
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/button/edit.js +1 -1
  5. package/build/button/edit.js.map +1 -1
  6. package/build/buttons/edit.native.js +1 -1
  7. package/build/buttons/edit.native.js.map +1 -1
  8. package/build/comment-template/index.js +6 -2
  9. package/build/comment-template/index.js.map +1 -1
  10. package/build/cover/edit/inspector-controls.js +3 -7
  11. package/build/cover/edit/inspector-controls.js.map +1 -1
  12. package/build/embed/deprecated.js +43 -4
  13. package/build/embed/deprecated.js.map +1 -1
  14. package/build/file/deprecated.js +108 -4
  15. package/build/file/deprecated.js.map +1 -1
  16. package/build/file/transforms.js +3 -9
  17. package/build/file/transforms.js.map +1 -1
  18. package/build/gallery/deprecated.js +148 -23
  19. package/build/gallery/deprecated.js.map +1 -1
  20. package/build/gallery/gallery.js +3 -2
  21. package/build/gallery/gallery.js.map +1 -1
  22. package/build/gallery/use-image-sizes.js +2 -1
  23. package/build/gallery/use-image-sizes.js.map +1 -1
  24. package/build/gallery/v1/edit.js +2 -1
  25. package/build/gallery/v1/edit.js.map +1 -1
  26. package/build/group/edit.js +7 -3
  27. package/build/group/edit.js.map +1 -1
  28. package/build/image/edit.native.js +1 -1
  29. package/build/image/edit.native.js.map +1 -1
  30. package/build/image/image.js +6 -9
  31. package/build/image/image.js.map +1 -1
  32. package/build/latest-posts/edit.js +1 -1
  33. package/build/latest-posts/edit.js.map +1 -1
  34. package/build/list/utils.js +4 -8
  35. package/build/list/utils.js.map +1 -1
  36. package/build/list-item/hooks/use-outdent-list-item.js +5 -7
  37. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  38. package/build/navigation/edit/index.js +12 -11
  39. package/build/navigation/edit/index.js.map +1 -1
  40. package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
  41. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  42. package/build/navigation-link/edit.js +4 -2
  43. package/build/navigation-link/edit.js.map +1 -1
  44. package/build/navigation-submenu/edit.js +4 -4
  45. package/build/navigation-submenu/edit.js.map +1 -1
  46. package/build/page-list/edit.js +29 -10
  47. package/build/page-list/edit.js.map +1 -1
  48. package/build/post-comments-count/index.js +4 -0
  49. package/build/post-comments-count/index.js.map +1 -1
  50. package/build/post-comments-form/index.js +4 -0
  51. package/build/post-comments-form/index.js.map +1 -1
  52. package/build/post-comments-link/index.js +4 -0
  53. package/build/post-comments-link/index.js.map +1 -1
  54. package/build/post-content/edit.js +14 -6
  55. package/build/post-content/edit.js.map +1 -1
  56. package/build/pullquote/deprecated.js +6 -6
  57. package/build/pullquote/deprecated.js.map +1 -1
  58. package/build/search/edit.js +1 -3
  59. package/build/search/edit.js.map +1 -1
  60. package/build/site-logo/edit.js +1 -1
  61. package/build/site-logo/edit.js.map +1 -1
  62. package/build/site-tagline/edit.js +21 -9
  63. package/build/site-tagline/edit.js.map +1 -1
  64. package/build/site-title/edit/index.js +20 -8
  65. package/build/site-title/edit/index.js.map +1 -1
  66. package/build/social-link/edit.js +11 -2
  67. package/build/social-link/edit.js.map +1 -1
  68. package/build/social-link/index.js +3 -0
  69. package/build/social-link/index.js.map +1 -1
  70. package/build/spacer/controls.js +3 -7
  71. package/build/spacer/controls.js.map +1 -1
  72. package/build/table/deprecated.js +282 -27
  73. package/build/table/deprecated.js.map +1 -1
  74. package/build/table/state.js +1 -1
  75. package/build/table/state.js.map +1 -1
  76. package/build/utils/clean-empty-object.js +5 -4
  77. package/build/utils/clean-empty-object.js.map +1 -1
  78. package/build/video/deprecated.js +159 -0
  79. package/build/video/deprecated.js.map +1 -0
  80. package/build/video/edit.js +41 -5
  81. package/build/video/edit.js.map +1 -1
  82. package/build/video/index.js +3 -0
  83. package/build/video/index.js.map +1 -1
  84. package/build/video/tracks-editor.js +3 -28
  85. package/build/video/tracks-editor.js.map +1 -1
  86. package/build-module/audio/edit.js +46 -7
  87. package/build-module/audio/edit.js.map +1 -1
  88. package/build-module/button/edit.js +1 -1
  89. package/build-module/button/edit.js.map +1 -1
  90. package/build-module/buttons/edit.native.js +1 -1
  91. package/build-module/buttons/edit.native.js.map +1 -1
  92. package/build-module/comment-template/index.js +6 -2
  93. package/build-module/comment-template/index.js.map +1 -1
  94. package/build-module/cover/edit/inspector-controls.js +4 -8
  95. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  96. package/build-module/embed/deprecated.js +44 -5
  97. package/build-module/embed/deprecated.js.map +1 -1
  98. package/build-module/file/deprecated.js +108 -4
  99. package/build-module/file/deprecated.js.map +1 -1
  100. package/build-module/file/transforms.js +3 -8
  101. package/build-module/file/transforms.js.map +1 -1
  102. package/build-module/gallery/deprecated.js +147 -25
  103. package/build-module/gallery/deprecated.js.map +1 -1
  104. package/build-module/gallery/gallery.js +3 -2
  105. package/build-module/gallery/gallery.js.map +1 -1
  106. package/build-module/gallery/use-image-sizes.js +3 -2
  107. package/build-module/gallery/use-image-sizes.js.map +1 -1
  108. package/build-module/gallery/v1/edit.js +3 -2
  109. package/build-module/gallery/v1/edit.js.map +1 -1
  110. package/build-module/group/edit.js +7 -3
  111. package/build-module/group/edit.js.map +1 -1
  112. package/build-module/image/edit.native.js +1 -1
  113. package/build-module/image/edit.native.js.map +1 -1
  114. package/build-module/image/image.js +8 -11
  115. package/build-module/image/image.js.map +1 -1
  116. package/build-module/latest-posts/edit.js +2 -2
  117. package/build-module/latest-posts/edit.js.map +1 -1
  118. package/build-module/list/utils.js +5 -9
  119. package/build-module/list/utils.js.map +1 -1
  120. package/build-module/list-item/hooks/use-outdent-list-item.js +5 -6
  121. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  122. package/build-module/navigation/edit/index.js +12 -11
  123. package/build-module/navigation/edit/index.js.map +1 -1
  124. package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
  125. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  126. package/build-module/navigation-link/edit.js +4 -3
  127. package/build-module/navigation-link/edit.js.map +1 -1
  128. package/build-module/navigation-submenu/edit.js +4 -4
  129. package/build-module/navigation-submenu/edit.js.map +1 -1
  130. package/build-module/page-list/edit.js +29 -10
  131. package/build-module/page-list/edit.js.map +1 -1
  132. package/build-module/post-comments-count/index.js +4 -0
  133. package/build-module/post-comments-count/index.js.map +1 -1
  134. package/build-module/post-comments-form/index.js +4 -0
  135. package/build-module/post-comments-form/index.js.map +1 -1
  136. package/build-module/post-comments-link/index.js +4 -0
  137. package/build-module/post-comments-link/index.js.map +1 -1
  138. package/build-module/post-content/edit.js +14 -6
  139. package/build-module/post-content/edit.js.map +1 -1
  140. package/build-module/pullquote/deprecated.js +7 -7
  141. package/build-module/pullquote/deprecated.js.map +1 -1
  142. package/build-module/search/edit.js +1 -3
  143. package/build-module/search/edit.js.map +1 -1
  144. package/build-module/site-logo/edit.js +2 -2
  145. package/build-module/site-logo/edit.js.map +1 -1
  146. package/build-module/site-tagline/edit.js +23 -11
  147. package/build-module/site-tagline/edit.js.map +1 -1
  148. package/build-module/site-title/edit/index.js +22 -10
  149. package/build-module/site-title/edit/index.js.map +1 -1
  150. package/build-module/social-link/edit.js +11 -2
  151. package/build-module/social-link/edit.js.map +1 -1
  152. package/build-module/social-link/index.js +3 -0
  153. package/build-module/social-link/index.js.map +1 -1
  154. package/build-module/spacer/controls.js +4 -8
  155. package/build-module/spacer/controls.js.map +1 -1
  156. package/build-module/table/deprecated.js +282 -27
  157. package/build-module/table/deprecated.js.map +1 -1
  158. package/build-module/table/state.js +1 -1
  159. package/build-module/table/state.js.map +1 -1
  160. package/build-module/utils/clean-empty-object.js +5 -5
  161. package/build-module/utils/clean-empty-object.js.map +1 -1
  162. package/build-module/video/deprecated.js +147 -0
  163. package/build-module/video/deprecated.js.map +1 -0
  164. package/build-module/video/edit.js +45 -9
  165. package/build-module/video/edit.js.map +1 -1
  166. package/build-module/video/index.js +2 -0
  167. package/build-module/video/index.js.map +1 -1
  168. package/build-module/video/tracks-editor.js +4 -29
  169. package/build-module/video/tracks-editor.js.map +1 -1
  170. package/build-style/button/style-rtl.css +1 -0
  171. package/build-style/button/style.css +1 -0
  172. package/build-style/comment-template/style-rtl.css +1 -0
  173. package/build-style/comment-template/style.css +1 -0
  174. package/build-style/editor-rtl.css +4 -4
  175. package/build-style/editor.css +4 -4
  176. package/build-style/navigation/editor-rtl.css +4 -4
  177. package/build-style/navigation/editor.css +4 -4
  178. package/build-style/navigation/style-rtl.css +3 -1
  179. package/build-style/navigation/style.css +3 -1
  180. package/build-style/post-comments-form/style-rtl.css +3 -0
  181. package/build-style/post-comments-form/style.css +3 -0
  182. package/build-style/style-rtl.css +8 -1
  183. package/build-style/style.css +8 -1
  184. package/package.json +29 -28
  185. package/src/audio/edit.js +79 -24
  186. package/src/button/edit.js +1 -1
  187. package/src/button/style.scss +2 -0
  188. package/src/buttons/edit.native.js +1 -1
  189. package/src/comment-template/block.json +6 -2
  190. package/src/comment-template/style.scss +2 -0
  191. package/src/cover/edit/inspector-controls.js +11 -13
  192. package/src/embed/deprecated.js +53 -26
  193. package/src/file/deprecated.js +130 -2
  194. package/src/file/transforms.js +3 -8
  195. package/src/gallery/deprecated.js +129 -4
  196. package/src/gallery/gallery.js +2 -0
  197. package/src/gallery/index.php +19 -10
  198. package/src/gallery/use-image-sizes.js +3 -2
  199. package/src/gallery/v1/edit.js +3 -2
  200. package/src/group/edit.js +10 -2
  201. package/src/image/edit.native.js +1 -1
  202. package/src/image/image.js +22 -10
  203. package/src/latest-posts/edit.js +2 -2
  204. package/src/list/utils.js +3 -11
  205. package/src/list-item/hooks/use-outdent-list-item.js +3 -6
  206. package/src/navigation/edit/index.js +13 -15
  207. package/src/navigation/edit/unsaved-inner-blocks.js +9 -2
  208. package/src/navigation/editor.scss +4 -4
  209. package/src/navigation/style.scss +3 -1
  210. package/src/navigation-link/edit.js +5 -4
  211. package/src/navigation-submenu/edit.js +7 -5
  212. package/src/page-list/edit.js +36 -22
  213. package/src/post-comments-count/block.json +4 -0
  214. package/src/post-comments-form/block.json +4 -0
  215. package/src/post-comments-form/style.scss +3 -0
  216. package/src/post-comments-link/block.json +4 -0
  217. package/src/post-content/edit.js +8 -4
  218. package/src/pullquote/deprecated.js +7 -7
  219. package/src/search/edit.js +1 -1
  220. package/src/site-logo/edit.js +2 -2
  221. package/src/site-tagline/edit.js +25 -18
  222. package/src/site-title/edit/index.js +26 -12
  223. package/src/social-link/block.json +3 -0
  224. package/src/social-link/edit.js +8 -1
  225. package/src/social-link/index.php +11 -7
  226. package/src/spacer/controls.js +10 -12
  227. package/src/table/deprecated.js +587 -348
  228. package/src/table/state.js +1 -1
  229. package/src/utils/clean-empty-object.js +5 -6
  230. package/src/video/deprecated.js +57 -0
  231. package/src/video/edit.js +71 -23
  232. package/src/video/index.js +2 -0
  233. package/src/video/tracks-editor.js +12 -28
@@ -14,7 +14,7 @@ import {
14
14
  import { __, sprintf } from '@wordpress/i18n';
15
15
 
16
16
  // Version of the file block without PR#43050 removing the translated aria-label.
17
- const v2 = {
17
+ const v3 = {
18
18
  attributes: {
19
19
  id: {
20
20
  type: 'number',
@@ -143,6 +143,134 @@ const v2 = {
143
143
  },
144
144
  };
145
145
 
146
+ // In #41239 the button was made an element button which added a `wp-element-button` classname
147
+ // to the download link element.
148
+ const v2 = {
149
+ attributes: {
150
+ id: {
151
+ type: 'number',
152
+ },
153
+ href: {
154
+ type: 'string',
155
+ },
156
+ fileId: {
157
+ type: 'string',
158
+ source: 'attribute',
159
+ selector: 'a:not([download])',
160
+ attribute: 'id',
161
+ },
162
+ fileName: {
163
+ type: 'string',
164
+ source: 'html',
165
+ selector: 'a:not([download])',
166
+ },
167
+ textLinkHref: {
168
+ type: 'string',
169
+ source: 'attribute',
170
+ selector: 'a:not([download])',
171
+ attribute: 'href',
172
+ },
173
+ textLinkTarget: {
174
+ type: 'string',
175
+ source: 'attribute',
176
+ selector: 'a:not([download])',
177
+ attribute: 'target',
178
+ },
179
+ showDownloadButton: {
180
+ type: 'boolean',
181
+ default: true,
182
+ },
183
+ downloadButtonText: {
184
+ type: 'string',
185
+ source: 'html',
186
+ selector: 'a[download]',
187
+ },
188
+ displayPreview: {
189
+ type: 'boolean',
190
+ },
191
+ previewHeight: {
192
+ type: 'number',
193
+ default: 600,
194
+ },
195
+ },
196
+ supports: {
197
+ anchor: true,
198
+ align: true,
199
+ },
200
+ save( { attributes } ) {
201
+ const {
202
+ href,
203
+ fileId,
204
+ fileName,
205
+ textLinkHref,
206
+ textLinkTarget,
207
+ showDownloadButton,
208
+ downloadButtonText,
209
+ displayPreview,
210
+ previewHeight,
211
+ } = attributes;
212
+
213
+ const pdfEmbedLabel = RichText.isEmpty( fileName )
214
+ ? __( 'PDF embed' )
215
+ : sprintf(
216
+ /* translators: %s: filename. */
217
+ __( 'Embed of %s.' ),
218
+ fileName
219
+ );
220
+
221
+ const hasFilename = ! RichText.isEmpty( fileName );
222
+
223
+ // Only output an `aria-describedby` when the element it's referring to is
224
+ // actually rendered.
225
+ const describedById = hasFilename ? fileId : undefined;
226
+
227
+ return (
228
+ href && (
229
+ <div { ...useBlockProps.save() }>
230
+ { displayPreview && (
231
+ <>
232
+ <object
233
+ className="wp-block-file__embed"
234
+ data={ href }
235
+ type="application/pdf"
236
+ style={ {
237
+ width: '100%',
238
+ height: `${ previewHeight }px`,
239
+ } }
240
+ aria-label={ pdfEmbedLabel }
241
+ />
242
+ </>
243
+ ) }
244
+ { hasFilename && (
245
+ <a
246
+ id={ describedById }
247
+ href={ textLinkHref }
248
+ target={ textLinkTarget }
249
+ rel={
250
+ textLinkTarget
251
+ ? 'noreferrer noopener'
252
+ : undefined
253
+ }
254
+ >
255
+ <RichText.Content value={ fileName } />
256
+ </a>
257
+ ) }
258
+ { showDownloadButton && (
259
+ <a
260
+ href={ href }
261
+ className="wp-block-file__button"
262
+ download={ true }
263
+ aria-describedby={ describedById }
264
+ >
265
+ <RichText.Content value={ downloadButtonText } />
266
+ </a>
267
+ ) }
268
+ </div>
269
+ )
270
+ );
271
+ },
272
+ };
273
+
146
274
  // Version of the file block without PR#28062 accessibility fix.
147
275
  const v1 = {
148
276
  attributes: {
@@ -255,6 +383,6 @@ const v1 = {
255
383
  },
256
384
  };
257
385
 
258
- const deprecated = [ v2, v1 ];
386
+ const deprecated = [ v3, v2, v1 ];
259
387
 
260
388
  export default deprecated;
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { includes } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -92,7 +87,7 @@ const transforms = {
92
87
  }
93
88
  const { getMedia } = select( coreStore );
94
89
  const media = getMedia( id );
95
- return !! media && includes( media.mime_type, 'audio' );
90
+ return !! media && media.mime_type.includes( 'audio' );
96
91
  },
97
92
  transform: ( attributes ) => {
98
93
  return createBlock( 'core/audio', {
@@ -112,7 +107,7 @@ const transforms = {
112
107
  }
113
108
  const { getMedia } = select( coreStore );
114
109
  const media = getMedia( id );
115
- return !! media && includes( media.mime_type, 'video' );
110
+ return !! media && media.mime_type.includes( 'video' );
116
111
  },
117
112
  transform: ( attributes ) => {
118
113
  return createBlock( 'core/video', {
@@ -132,7 +127,7 @@ const transforms = {
132
127
  }
133
128
  const { getMedia } = select( coreStore );
134
129
  const media = getMedia( id );
135
- return !! media && includes( media.mime_type, 'image' );
130
+ return !! media && media.mime_type.includes( 'image' );
136
131
  },
137
132
  transform: ( attributes ) => {
138
133
  return createBlock( 'core/image', {
@@ -2,12 +2,16 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { map, some } from 'lodash';
5
+ import { map } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { RichText, useBlockProps } from '@wordpress/block-editor';
10
+ import {
11
+ RichText,
12
+ useBlockProps,
13
+ useInnerBlocksProps,
14
+ } from '@wordpress/block-editor';
11
15
 
12
16
  import { createBlock } from '@wordpress/blocks';
13
17
 
@@ -127,6 +131,127 @@ export function getImageBlock( image, sizeSlug, linkTo ) {
127
131
  } );
128
132
  }
129
133
 
134
+ // In #41140 support was added to global styles for caption elements which added a `wp-element-caption` classname
135
+ // to the gallery figcaption element.
136
+ const v7 = {
137
+ attributes: {
138
+ images: {
139
+ type: 'array',
140
+ default: [],
141
+ source: 'query',
142
+ selector: '.blocks-gallery-item',
143
+ query: {
144
+ url: {
145
+ type: 'string',
146
+ source: 'attribute',
147
+ selector: 'img',
148
+ attribute: 'src',
149
+ },
150
+ fullUrl: {
151
+ type: 'string',
152
+ source: 'attribute',
153
+ selector: 'img',
154
+ attribute: 'data-full-url',
155
+ },
156
+ link: {
157
+ type: 'string',
158
+ source: 'attribute',
159
+ selector: 'img',
160
+ attribute: 'data-link',
161
+ },
162
+ alt: {
163
+ type: 'string',
164
+ source: 'attribute',
165
+ selector: 'img',
166
+ attribute: 'alt',
167
+ default: '',
168
+ },
169
+ id: {
170
+ type: 'string',
171
+ source: 'attribute',
172
+ selector: 'img',
173
+ attribute: 'data-id',
174
+ },
175
+ caption: {
176
+ type: 'string',
177
+ source: 'html',
178
+ selector: '.blocks-gallery-item__caption',
179
+ },
180
+ },
181
+ },
182
+ ids: {
183
+ type: 'array',
184
+ items: {
185
+ type: 'number',
186
+ },
187
+ default: [],
188
+ },
189
+ shortCodeTransforms: {
190
+ type: 'array',
191
+ default: [],
192
+ items: {
193
+ type: 'object',
194
+ },
195
+ },
196
+ columns: {
197
+ type: 'number',
198
+ minimum: 1,
199
+ maximum: 8,
200
+ },
201
+ caption: {
202
+ type: 'string',
203
+ source: 'html',
204
+ selector: '.blocks-gallery-caption',
205
+ },
206
+ imageCrop: {
207
+ type: 'boolean',
208
+ default: true,
209
+ },
210
+ fixedHeight: {
211
+ type: 'boolean',
212
+ default: true,
213
+ },
214
+ linkTarget: {
215
+ type: 'string',
216
+ },
217
+ linkTo: {
218
+ type: 'string',
219
+ },
220
+ sizeSlug: {
221
+ type: 'string',
222
+ default: 'large',
223
+ },
224
+ allowResize: {
225
+ type: 'boolean',
226
+ default: false,
227
+ },
228
+ },
229
+ save( { attributes } ) {
230
+ const { caption, columns, imageCrop } = attributes;
231
+
232
+ const className = classnames( 'has-nested-images', {
233
+ [ `columns-${ columns }` ]: columns !== undefined,
234
+ [ `columns-default` ]: columns === undefined,
235
+ 'is-cropped': imageCrop,
236
+ } );
237
+ const blockProps = useBlockProps.save( { className } );
238
+ const innerBlocksProps = useInnerBlocksProps.save( blockProps );
239
+
240
+ return (
241
+ <figure { ...innerBlocksProps }>
242
+ { innerBlocksProps.children }
243
+ { ! RichText.isEmpty( caption ) && (
244
+ <RichText.Content
245
+ tagName="figcaption"
246
+ className="blocks-gallery-caption"
247
+ value={ caption }
248
+ />
249
+ ) }
250
+ </figure>
251
+ );
252
+ },
253
+ };
254
+
130
255
  const v6 = {
131
256
  attributes: {
132
257
  images: {
@@ -803,7 +928,7 @@ const v2 = {
803
928
  images.length > 0 &&
804
929
  ( ( ! ids && images ) ||
805
930
  ( ids && images && ids.length !== images.length ) ||
806
- some( images, ( id, index ) => {
931
+ images.some( ( id, index ) => {
807
932
  if ( ! id && ids[ index ] !== null ) {
808
933
  return true;
809
934
  }
@@ -984,4 +1109,4 @@ const v1 = {
984
1109
  },
985
1110
  };
986
1111
 
987
- export default [ v6, v5, v4, v3, v2, v1 ];
1112
+ export default [ v7, v6, v5, v4, v3, v2, v1 ];
@@ -26,6 +26,7 @@ export const Gallery = ( props ) => {
26
26
  mediaPlaceholder,
27
27
  insertBlocksAfter,
28
28
  blockProps,
29
+ __unstableLayoutClassNames: layoutClassNames,
29
30
  } = props;
30
31
 
31
32
  const { align, columns, caption, imageCrop } = attributes;
@@ -42,6 +43,7 @@ export const Gallery = ( props ) => {
42
43
  { ...innerBlocksProps }
43
44
  className={ classnames(
44
45
  blockProps.className,
46
+ layoutClassNames,
45
47
  'blocks-gallery-grid',
46
48
  {
47
49
  [ `align${ align }` ]: align,
@@ -76,13 +76,10 @@ function block_core_gallery_render( $attributes, $content ) {
76
76
  }
77
77
  }
78
78
 
79
- $class = wp_unique_id( 'wp-block-gallery-' );
80
- $content = preg_replace(
81
- '/' . preg_quote( 'class="', '/' ) . '/',
82
- 'class="' . $class . ' ',
83
- $content,
84
- 1
85
- );
79
+ $unique_gallery_classname = wp_unique_id( 'wp-block-gallery-' );
80
+ $processed_content = new WP_HTML_Tag_Processor( $content );
81
+ $processed_content->next_tag();
82
+ $processed_content->add_class( $unique_gallery_classname );
86
83
 
87
84
  // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
88
85
  // gap on the gallery.
@@ -102,10 +99,22 @@ function block_core_gallery_render( $attributes, $content ) {
102
99
  }
103
100
 
104
101
  // Set the CSS variable to the column value, and the `gap` property to the combined gap value.
105
- $style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
102
+ $gallery_styles = array();
103
+ $gallery_styles[] = array(
104
+ 'selector' => ".wp-block-gallery.{$unique_gallery_classname}",
105
+ 'declarations' => array(
106
+ '--wp--style--unstable-gallery-gap' => $gap_column,
107
+ 'gap' => $gap_value,
108
+ ),
109
+ );
106
110
 
107
- wp_enqueue_block_support_styles( $style, 11 );
108
- return $content;
111
+ gutenberg_style_engine_get_stylesheet_from_css_rules(
112
+ $gallery_styles,
113
+ array(
114
+ 'context' => 'block-supports',
115
+ )
116
+ );
117
+ return (string) $processed_content;
109
118
  }
110
119
  /**
111
120
  * Registers the `core/gallery` block on server.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, some } from 'lodash';
4
+ import { get } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -57,9 +57,10 @@ export default function useImageSizes( images, isSelected, getSettings ) {
57
57
  };
58
58
  }, {} );
59
59
  }
60
+ const resizedImageSizes = Object.values( resizedImages );
60
61
  return imageSizes
61
62
  .filter( ( { slug } ) =>
62
- some( resizedImages, ( sizes ) => sizes[ slug ] )
63
+ resizedImageSizes.some( ( sizes ) => sizes[ slug ] )
63
64
  )
64
65
  .map( ( { name, slug } ) => ( { value: slug, label: name } ) );
65
66
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { filter, find, get, isEmpty, map, reduce, some } from 'lodash';
4
+ import { filter, find, get, isEmpty, map, reduce } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -302,9 +302,10 @@ function GalleryEdit( props ) {
302
302
  }
303
303
 
304
304
  function getImagesSizeOptions() {
305
+ const resizedImageSizes = Object.values( resizedImages );
305
306
  return map(
306
307
  filter( imageSizes, ( { slug } ) =>
307
- some( resizedImages, ( sizes ) => sizes[ slug ] )
308
+ resizedImageSizes.some( ( sizes ) => sizes[ slug ] )
308
309
  ),
309
310
  ( { name, slug } ) => ( { value: slug, label: name } )
310
311
  );
package/src/group/edit.js CHANGED
@@ -35,7 +35,12 @@ const htmlElementMessages = {
35
35
  ),
36
36
  };
37
37
 
38
- function GroupEdit( { attributes, setAttributes, clientId } ) {
38
+ function GroupEdit( {
39
+ attributes,
40
+ setAttributes,
41
+ clientId,
42
+ __unstableLayoutClassNames: layoutClassNames,
43
+ } ) {
39
44
  const { hasInnerBlocks, themeSupportsLayout } = useSelect(
40
45
  ( select ) => {
41
46
  const { getBlock, getSettings } = select( blockEditorStore );
@@ -55,7 +60,9 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
55
60
  const { type = 'default' } = usedLayout;
56
61
  const layoutSupportEnabled = themeSupportsLayout || type === 'flex';
57
62
 
58
- const blockProps = useBlockProps();
63
+ const blockProps = useBlockProps( {
64
+ className: ! layoutSupportEnabled ? layoutClassNames : null,
65
+ } );
59
66
 
60
67
  const innerBlocksProps = useInnerBlocksProps(
61
68
  layoutSupportEnabled
@@ -67,6 +74,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
67
74
  ? undefined
68
75
  : InnerBlocks.ButtonBlockAppender,
69
76
  __experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,
77
+ __unstableDisableLayoutClassNames: ! layoutSupportEnabled,
70
78
  }
71
79
  );
72
80
 
@@ -878,7 +878,7 @@ export class ImageEdit extends Component {
878
878
  <BlockCaption
879
879
  clientId={ this.props.clientId }
880
880
  isSelected={ this.state.isCaptionSelected }
881
- accessible
881
+ accessible={ ! this.state.isCaptionSelected }
882
882
  accessibilityLabelCreator={ this.accessibilityLabelCreator }
883
883
  onFocus={ this.onFocusCaption }
884
884
  onBlur={ this.props.onBlur } // Always assign onBlur as props.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, filter, isEmpty, map, pick, includes } from 'lodash';
4
+ import { get, filter, isEmpty, map, pick } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -32,7 +32,13 @@ import {
32
32
  __experimentalGetElementClassName,
33
33
  __experimentalUseBorderProps as useBorderProps,
34
34
  } from '@wordpress/block-editor';
35
- import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
35
+ import {
36
+ useEffect,
37
+ useMemo,
38
+ useState,
39
+ useRef,
40
+ useCallback,
41
+ } from '@wordpress/element';
36
42
  import { __, sprintf, isRTL } from '@wordpress/i18n';
37
43
  import { getFilename } from '@wordpress/url';
38
44
  import {
@@ -93,7 +99,6 @@ export default function Image( {
93
99
  sizeSlug,
94
100
  } = attributes;
95
101
  const imageRef = useRef();
96
- const captionRef = useRef();
97
102
  const prevCaption = usePrevious( caption );
98
103
  const [ showCaption, setShowCaption ] = useState( !! caption );
99
104
  const { allowResize = true } = context;
@@ -151,7 +156,7 @@ export default function Image( {
151
156
  const { createErrorNotice, createSuccessNotice } =
152
157
  useDispatch( noticesStore );
153
158
  const isLargeViewport = useViewportMatch( 'medium' );
154
- const isWideAligned = includes( [ 'wide', 'full' ], align );
159
+ const isWideAligned = [ 'wide', 'full' ].includes( align );
155
160
  const [
156
161
  { loadedNaturalWidth, loadedNaturalHeight },
157
162
  setLoadedNaturalSize,
@@ -195,11 +200,14 @@ export default function Image( {
195
200
  }, [ caption, prevCaption ] );
196
201
 
197
202
  // Focus the caption when we click to add one.
198
- useEffect( () => {
199
- if ( showCaption && ! caption ) {
200
- captionRef.current?.focus();
201
- }
202
- }, [ caption, showCaption ] );
203
+ const captionRef = useCallback(
204
+ ( node ) => {
205
+ if ( node && ! caption ) {
206
+ node.focus();
207
+ }
208
+ },
209
+ [ caption ]
210
+ );
203
211
 
204
212
  // Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural
205
213
  // width and height. This resolves an issue in Safari where the loaded natural
@@ -343,7 +351,11 @@ export default function Image( {
343
351
  } }
344
352
  icon={ captionIcon }
345
353
  isPressed={ showCaption }
346
- label={ __( 'Caption' ) }
354
+ label={
355
+ showCaption
356
+ ? __( 'Remove caption' )
357
+ : __( 'Add caption' )
358
+ }
347
359
  />
348
360
  ) }
349
361
  { ! multiImageSelection && ! isEditingImage && (
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get, includes, pickBy } from 'lodash';
4
+ import { get, pickBy } from 'lodash';
5
5
  import classnames from 'classnames';
6
6
 
7
7
  /**
@@ -196,7 +196,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
196
196
  } );
197
197
  // We do nothing if the category is not selected
198
198
  // from suggestions.
199
- if ( includes( allCategories, null ) ) {
199
+ if ( allCategories.includes( null ) ) {
200
200
  return false;
201
201
  }
202
202
  setAttributes( { categories: allCategories } );
package/src/list/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createBlock } from '@wordpress/blocks';
4
+ import { createBlock, rawHandler } from '@wordpress/blocks';
5
5
 
6
6
  export function createListBlockFromDOMElement( listElement ) {
7
7
  const listAttributes = {
@@ -70,15 +70,7 @@ export function migrateToListV2( attributes ) {
70
70
  list.setAttribute( 'type', type );
71
71
  }
72
72
 
73
- const listBlock = createListBlockFromDOMElement( list );
73
+ const [ listBlock ] = rawHandler( { HTML: list.outerHTML } );
74
74
 
75
- const { values: omittedValues, ...restAttributes } = attributes;
76
-
77
- return [
78
- {
79
- ...restAttributes,
80
- ...listBlock.attributes,
81
- },
82
- listBlock.innerBlocks,
83
- ];
75
+ return [ listBlock.attributes, listBlock.innerBlocks ];
84
76
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { castArray } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -61,7 +56,9 @@ export default function useOutdentListItem( clientId ) {
61
56
  return [
62
57
  canOutdent,
63
58
  useCallback( ( clientIds = getSelectedBlockClientIds() ) => {
64
- clientIds = castArray( clientIds );
59
+ if ( ! Array.isArray( clientIds ) ) {
60
+ clientIds = [ clientIds ];
61
+ }
65
62
 
66
63
  if ( ! clientIds.length ) return;
67
64
 
@@ -272,7 +272,7 @@ function Navigation( {
272
272
  fallbackNavigationMenus?.length > 0 ||
273
273
  classicMenus?.length !== 1
274
274
  ) {
275
- return false;
275
+ return;
276
276
  }
277
277
 
278
278
  // If there's non fallback navigation menus and
@@ -481,24 +481,22 @@ function Navigation( {
481
481
 
482
482
  // Prompt the user to publish the menu they have set as a draft
483
483
  const isDraftNavigationMenu = navigationMenu?.status === 'draft';
484
- useEffect( async () => {
484
+ useEffect( () => {
485
485
  hideMenuAutoPublishDraftNotice();
486
- if ( ! isDraftNavigationMenu ) return;
487
- try {
488
- await editEntityRecord(
489
- 'postType',
490
- 'wp_navigation',
491
- navigationMenu?.id,
492
- {
493
- status: 'publish',
494
- },
495
- { throwOnError: true }
496
- );
497
- } catch {
486
+ if ( ! isDraftNavigationMenu ) {
487
+ return;
488
+ }
489
+ editEntityRecord(
490
+ 'postType',
491
+ 'wp_navigation',
492
+ navigationMenu?.id,
493
+ { status: 'publish' },
494
+ { throwOnError: true }
495
+ ).catch( () => {
498
496
  showMenuAutoPublishDraftNotice(
499
497
  __( 'Error occurred while publishing the navigation menu.' )
500
498
  );
501
- }
499
+ } );
502
500
  }, [ isDraftNavigationMenu, navigationMenu ] );
503
501
 
504
502
  const stylingInspectorControls = (
@@ -172,8 +172,15 @@ export default function UnsavedInnerBlocks( {
172
172
 
173
173
  return (
174
174
  <>
175
- <Wrapper { ...innerBlocksProps } />
176
- { isSaving && <Spinner /> }
175
+ { isSaving ? (
176
+ <Spinner
177
+ className={
178
+ 'wp-block-navigation__uncontrolled-inner-blocks-loading-indicator'
179
+ }
180
+ />
181
+ ) : (
182
+ <Wrapper { ...innerBlocksProps } />
183
+ ) }
177
184
  </>
178
185
  );
179
186
  }