@wordpress/block-library 9.7.0 → 9.7.1-next.5368f64a9.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 (238) hide show
  1. package/build/archives/edit.js +1 -1
  2. package/build/archives/edit.js.map +1 -1
  3. package/build/block/edit.js +2 -3
  4. package/build/block/edit.js.map +1 -1
  5. package/build/buttons/index.js +1 -1
  6. package/build/comments/edit/comments-legacy.js +2 -4
  7. package/build/comments/edit/comments-legacy.js.map +1 -1
  8. package/build/cover/deprecated.js +1 -1
  9. package/build/cover/deprecated.js.map +1 -1
  10. package/build/cover/edit/index.js +4 -2
  11. package/build/cover/edit/index.js.map +1 -1
  12. package/build/embed/edit.js +5 -11
  13. package/build/embed/edit.js.map +1 -1
  14. package/build/embed/embed-placeholder.js +4 -8
  15. package/build/embed/embed-placeholder.js.map +1 -1
  16. package/build/embed/embed-preview.js +16 -4
  17. package/build/embed/embed-preview.js.map +1 -1
  18. package/build/file/transforms.js +18 -4
  19. package/build/file/transforms.js.map +1 -1
  20. package/build/freeform/modal.js +6 -12
  21. package/build/freeform/modal.js.map +1 -1
  22. package/build/image/edit.js +55 -15
  23. package/build/image/edit.js.map +1 -1
  24. package/build/image/image.js +23 -20
  25. package/build/image/image.js.map +1 -1
  26. package/build/image/transforms.js +0 -13
  27. package/build/image/transforms.js.map +1 -1
  28. package/build/image/use-max-width-observer.js +35 -0
  29. package/build/image/use-max-width-observer.js.map +1 -0
  30. package/build/image/utils.js +11 -0
  31. package/build/image/utils.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/missing/edit.js +2 -4
  35. package/build/missing/edit.js.map +1 -1
  36. package/build/navigation/edit/deleted-navigation-warning.js +14 -10
  37. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  38. package/build/navigation/edit/index.js +2 -4
  39. package/build/navigation/edit/index.js.map +1 -1
  40. package/build/navigation/edit/menu-inspector-controls.js +2 -1
  41. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  42. package/build/navigation/edit/navigation-menu-delete-control.js +2 -4
  43. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  44. package/build/navigation/edit/placeholder/index.js +2 -4
  45. package/build/navigation/edit/placeholder/index.js.map +1 -1
  46. package/build/navigation/edit/responsive-wrapper.js +4 -8
  47. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  48. package/build/navigation-link/link-ui.js +2 -4
  49. package/build/navigation-link/link-ui.js.map +1 -1
  50. package/build/page-list/convert-to-links-modal.js +4 -8
  51. package/build/page-list/convert-to-links-modal.js.map +1 -1
  52. package/build/page-list/edit.js +2 -4
  53. package/build/page-list/edit.js.map +1 -1
  54. package/build/post-comments-form/form.js +2 -4
  55. package/build/post-comments-form/form.js.map +1 -1
  56. package/build/post-featured-image/edit.js +2 -4
  57. package/build/post-featured-image/edit.js.map +1 -1
  58. package/build/post-title/index.js +4 -1
  59. package/build/post-title/index.js.map +1 -1
  60. package/build/query/edit/enhanced-pagination-modal.js +4 -6
  61. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  62. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
  63. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  64. package/build/query/edit/inspector-controls/index.js +2 -10
  65. package/build/query/edit/inspector-controls/index.js.map +1 -1
  66. package/build/query/edit/query-content.js +9 -3
  67. package/build/query/edit/query-content.js.map +1 -1
  68. package/build/query/edit/query-placeholder.js +4 -8
  69. package/build/query/edit/query-placeholder.js.map +1 -1
  70. package/build/site-logo/edit.js +4 -8
  71. package/build/site-logo/edit.js.map +1 -1
  72. package/build/site-title/index.js +4 -1
  73. package/build/site-title/index.js.map +1 -1
  74. package/build/social-link/edit.js +1 -1
  75. package/build/social-link/edit.js.map +1 -1
  76. package/build/template-part/edit/inner-blocks.js +10 -1
  77. package/build/template-part/edit/inner-blocks.js.map +1 -1
  78. package/build/template-part/edit/placeholder.js +4 -8
  79. package/build/template-part/edit/placeholder.js.map +1 -1
  80. package/build/video/edit.js +4 -8
  81. package/build/video/edit.js.map +1 -1
  82. package/build/video/tracks-editor.js +6 -12
  83. package/build/video/tracks-editor.js.map +1 -1
  84. package/build-module/archives/edit.js +1 -1
  85. package/build-module/archives/edit.js.map +1 -1
  86. package/build-module/block/edit.js +2 -3
  87. package/build-module/block/edit.js.map +1 -1
  88. package/build-module/buttons/index.js +1 -1
  89. package/build-module/comments/edit/comments-legacy.js +2 -4
  90. package/build-module/comments/edit/comments-legacy.js.map +1 -1
  91. package/build-module/cover/deprecated.js +1 -1
  92. package/build-module/cover/deprecated.js.map +1 -1
  93. package/build-module/cover/edit/index.js +4 -2
  94. package/build-module/cover/edit/index.js.map +1 -1
  95. package/build-module/embed/edit.js +6 -12
  96. package/build-module/embed/edit.js.map +1 -1
  97. package/build-module/embed/embed-placeholder.js +4 -8
  98. package/build-module/embed/embed-placeholder.js.map +1 -1
  99. package/build-module/embed/embed-preview.js +16 -4
  100. package/build-module/embed/embed-preview.js.map +1 -1
  101. package/build-module/file/transforms.js +18 -4
  102. package/build-module/file/transforms.js.map +1 -1
  103. package/build-module/freeform/modal.js +6 -12
  104. package/build-module/freeform/modal.js.map +1 -1
  105. package/build-module/image/edit.js +58 -18
  106. package/build-module/image/edit.js.map +1 -1
  107. package/build-module/image/image.js +23 -20
  108. package/build-module/image/image.js.map +1 -1
  109. package/build-module/image/transforms.js +0 -13
  110. package/build-module/image/transforms.js.map +1 -1
  111. package/build-module/image/use-max-width-observer.js +29 -0
  112. package/build-module/image/use-max-width-observer.js.map +1 -0
  113. package/build-module/image/utils.js +11 -1
  114. package/build-module/image/utils.js.map +1 -1
  115. package/build-module/latest-posts/edit.js +1 -1
  116. package/build-module/latest-posts/edit.js.map +1 -1
  117. package/build-module/missing/edit.js +2 -4
  118. package/build-module/missing/edit.js.map +1 -1
  119. package/build-module/navigation/edit/deleted-navigation-warning.js +15 -11
  120. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  121. package/build-module/navigation/edit/index.js +2 -4
  122. package/build-module/navigation/edit/index.js.map +1 -1
  123. package/build-module/navigation/edit/menu-inspector-controls.js +2 -1
  124. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  125. package/build-module/navigation/edit/navigation-menu-delete-control.js +2 -4
  126. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  127. package/build-module/navigation/edit/placeholder/index.js +2 -4
  128. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  129. package/build-module/navigation/edit/responsive-wrapper.js +4 -8
  130. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  131. package/build-module/navigation-link/link-ui.js +2 -4
  132. package/build-module/navigation-link/link-ui.js.map +1 -1
  133. package/build-module/page-list/convert-to-links-modal.js +4 -8
  134. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  135. package/build-module/page-list/edit.js +2 -4
  136. package/build-module/page-list/edit.js.map +1 -1
  137. package/build-module/post-comments-form/form.js +2 -4
  138. package/build-module/post-comments-form/form.js.map +1 -1
  139. package/build-module/post-featured-image/edit.js +2 -4
  140. package/build-module/post-featured-image/edit.js.map +1 -1
  141. package/build-module/post-title/index.js +4 -1
  142. package/build-module/post-title/index.js.map +1 -1
  143. package/build-module/query/edit/enhanced-pagination-modal.js +4 -6
  144. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  145. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
  146. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  147. package/build-module/query/edit/inspector-controls/index.js +2 -10
  148. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  149. package/build-module/query/edit/query-content.js +10 -4
  150. package/build-module/query/edit/query-content.js.map +1 -1
  151. package/build-module/query/edit/query-placeholder.js +4 -8
  152. package/build-module/query/edit/query-placeholder.js.map +1 -1
  153. package/build-module/site-logo/edit.js +4 -8
  154. package/build-module/site-logo/edit.js.map +1 -1
  155. package/build-module/site-title/index.js +4 -1
  156. package/build-module/site-title/index.js.map +1 -1
  157. package/build-module/social-link/edit.js +1 -1
  158. package/build-module/social-link/edit.js.map +1 -1
  159. package/build-module/template-part/edit/inner-blocks.js +10 -1
  160. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  161. package/build-module/template-part/edit/placeholder.js +4 -8
  162. package/build-module/template-part/edit/placeholder.js.map +1 -1
  163. package/build-module/video/edit.js +4 -8
  164. package/build-module/video/edit.js.map +1 -1
  165. package/build-module/video/tracks-editor.js +6 -12
  166. package/build-module/video/tracks-editor.js.map +1 -1
  167. package/build-style/buttons/editor-rtl.css +2 -2
  168. package/build-style/buttons/editor.css +2 -2
  169. package/build-style/buttons/style-rtl.css +2 -2
  170. package/build-style/buttons/style.css +2 -2
  171. package/build-style/common-rtl.css +2 -2
  172. package/build-style/common.css +2 -2
  173. package/build-style/editor-rtl.css +11 -31
  174. package/build-style/editor.css +11 -31
  175. package/build-style/image/editor-rtl.css +6 -26
  176. package/build-style/image/editor.css +6 -26
  177. package/build-style/navigation/editor-rtl.css +1 -1
  178. package/build-style/navigation/editor.css +1 -1
  179. package/build-style/post-title/style-rtl.css +21 -0
  180. package/build-style/post-title/style.css +21 -0
  181. package/build-style/site-title/style-rtl.css +21 -0
  182. package/build-style/site-title/style.css +21 -0
  183. package/build-style/style-rtl.css +46 -4
  184. package/build-style/style.css +46 -4
  185. package/package.json +42 -35
  186. package/src/archives/edit.js +1 -1
  187. package/src/block/edit.js +3 -7
  188. package/src/buttons/block.json +1 -1
  189. package/src/buttons/editor.scss +2 -2
  190. package/src/buttons/style.scss +2 -2
  191. package/src/comments/edit/comments-legacy.js +1 -2
  192. package/src/cover/deprecated.js +3 -2
  193. package/src/cover/edit/index.js +5 -1
  194. package/src/embed/edit.js +0 -7
  195. package/src/embed/embed-placeholder.js +2 -4
  196. package/src/embed/embed-preview.js +22 -2
  197. package/src/file/index.php +1 -1
  198. package/src/file/transforms.js +26 -6
  199. package/src/freeform/modal.js +3 -6
  200. package/src/image/edit.js +91 -20
  201. package/src/image/editor.scss +7 -38
  202. package/src/image/image.js +31 -20
  203. package/src/image/index.php +1 -1
  204. package/src/image/transforms.js +0 -23
  205. package/src/image/use-max-width-observer.js +32 -0
  206. package/src/image/utils.js +13 -1
  207. package/src/latest-posts/edit.js +1 -1
  208. package/src/missing/edit.js +1 -2
  209. package/src/navigation/edit/deleted-navigation-warning.js +23 -20
  210. package/src/navigation/edit/index.js +1 -2
  211. package/src/navigation/edit/menu-inspector-controls.js +3 -1
  212. package/src/navigation/edit/navigation-menu-delete-control.js +1 -2
  213. package/src/navigation/edit/placeholder/index.js +1 -2
  214. package/src/navigation/edit/responsive-wrapper.js +2 -4
  215. package/src/navigation/editor.scss +5 -1
  216. package/src/navigation/index.php +1 -1
  217. package/src/navigation-link/link-ui.js +1 -2
  218. package/src/page-list/convert-to-links-modal.js +2 -4
  219. package/src/page-list/edit.js +1 -2
  220. package/src/post-comments-form/form.js +1 -2
  221. package/src/post-featured-image/edit.js +1 -2
  222. package/src/post-title/block.json +4 -1
  223. package/src/post-title/style.scss +24 -0
  224. package/src/query/edit/enhanced-pagination-modal.js +3 -4
  225. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
  226. package/src/query/edit/inspector-controls/index.js +2 -9
  227. package/src/query/edit/query-content.js +7 -0
  228. package/src/query/edit/query-placeholder.js +2 -4
  229. package/src/query/index.php +1 -1
  230. package/src/search/index.php +1 -1
  231. package/src/site-logo/edit.js +2 -4
  232. package/src/site-title/block.json +4 -1
  233. package/src/site-title/style.scss +24 -0
  234. package/src/social-link/edit.js +1 -1
  235. package/src/template-part/edit/inner-blocks.js +20 -1
  236. package/src/template-part/edit/placeholder.js +2 -4
  237. package/src/video/edit.js +2 -4
  238. package/src/video/tracks-editor.js +3 -6
package/src/image/edit.js CHANGED
@@ -6,14 +6,14 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { isBlobURL } from '@wordpress/blob';
10
- import { store as blocksStore } from '@wordpress/blocks';
9
+ import { isBlobURL, createBlobURL } from '@wordpress/blob';
10
+ import { store as blocksStore, createBlock } from '@wordpress/blocks';
11
11
  import { Placeholder } from '@wordpress/components';
12
12
  import { useDispatch, useSelect } from '@wordpress/data';
13
13
  import {
14
14
  BlockIcon,
15
- MediaPlaceholder,
16
15
  useBlockProps,
16
+ MediaPlaceholder,
17
17
  store as blockEditorStore,
18
18
  __experimentalUseBorderProps as useBorderProps,
19
19
  __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
@@ -31,6 +31,8 @@ import { useResizeObserver } from '@wordpress/compose';
31
31
  import { unlock } from '../lock-unlock';
32
32
  import { useUploadMediaFromBlobURL } from '../utils/hooks';
33
33
  import Image from './image';
34
+ import { isValidFileType } from './utils';
35
+ import { useMaxWidthObserver } from './use-max-width-observer';
34
36
 
35
37
  /**
36
38
  * Module constants
@@ -108,11 +110,23 @@ export function ImageEdit( {
108
110
  align,
109
111
  metadata,
110
112
  } = attributes;
113
+
111
114
  const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
112
115
 
113
- const [ contentResizeListener, { width: containerWidth } ] =
116
+ const containerRef = useRef();
117
+ // Only observe the max width from the parent container when the parent layout is not flex nor grid.
118
+ // This won't work for them because the container width changes with the image.
119
+ // TODO: Find a way to observe the container width for flex and grid layouts.
120
+ const isMaxWidthContainerWidth =
121
+ ! parentLayout ||
122
+ ( parentLayout.type !== 'flex' && parentLayout.type !== 'grid' );
123
+ const [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();
124
+
125
+ const [ placeholderResizeListener, { width: placeholderWidth } ] =
114
126
  useResizeObserver();
115
127
 
128
+ const isSmallContainer = placeholderWidth && placeholderWidth < 160;
129
+
116
130
  const altRef = useRef();
117
131
  useEffect( () => {
118
132
  altRef.current = alt;
@@ -123,7 +137,7 @@ export function ImageEdit( {
123
137
  captionRef.current = caption;
124
138
  }, [ caption ] );
125
139
 
126
- const { __unstableMarkNextChangeAsNotPersistent } =
140
+ const { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =
127
141
  useDispatch( blockEditorStore );
128
142
 
129
143
  useEffect( () => {
@@ -138,7 +152,12 @@ export function ImageEdit( {
138
152
  }
139
153
  }, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );
140
154
 
141
- const { getSettings } = useSelect( blockEditorStore );
155
+ const {
156
+ getSettings,
157
+ getBlockRootClientId,
158
+ getBlockName,
159
+ canInsertBlockType,
160
+ } = useSelect( blockEditorStore );
142
161
  const blockEditingMode = useBlockEditingMode();
143
162
 
144
163
  const { createErrorNotice } = useDispatch( noticesStore );
@@ -152,7 +171,52 @@ export function ImageEdit( {
152
171
  } );
153
172
  }
154
173
 
174
+ function onSelectImagesList( images ) {
175
+ const win = containerRef.current?.ownerDocument.defaultView;
176
+
177
+ if ( images.every( ( file ) => file instanceof win.File ) ) {
178
+ /** @type {File[]} */
179
+ const files = images;
180
+ const rootClientId = getBlockRootClientId( clientId );
181
+
182
+ if ( files.some( ( file ) => ! isValidFileType( file ) ) ) {
183
+ // Copied from the same notice in the gallery block.
184
+ createErrorNotice(
185
+ __(
186
+ 'If uploading to a gallery all files need to be image formats'
187
+ ),
188
+ { id: 'gallery-upload-invalid-file', type: 'snackbar' }
189
+ );
190
+ }
191
+
192
+ const imageBlocks = files
193
+ .filter( ( file ) => isValidFileType( file ) )
194
+ .map( ( file ) =>
195
+ createBlock( 'core/image', {
196
+ blob: createBlobURL( file ),
197
+ } )
198
+ );
199
+
200
+ if ( getBlockName( rootClientId ) === 'core/gallery' ) {
201
+ replaceBlock( clientId, imageBlocks );
202
+ } else if ( canInsertBlockType( 'core/gallery', rootClientId ) ) {
203
+ const galleryBlock = createBlock(
204
+ 'core/gallery',
205
+ {},
206
+ imageBlocks
207
+ );
208
+
209
+ replaceBlock( clientId, galleryBlock );
210
+ }
211
+ }
212
+ }
213
+
155
214
  function onSelectImage( media ) {
215
+ if ( Array.isArray( media ) ) {
216
+ onSelectImagesList( media );
217
+ return;
218
+ }
219
+
156
220
  if ( ! media || ! media.url ) {
157
221
  setAttributes( {
158
222
  url: undefined,
@@ -296,7 +360,10 @@ export function ImageEdit( {
296
360
  Object.keys( borderProps.style ).length > 0 ),
297
361
  } );
298
362
 
299
- const blockProps = useBlockProps( { className: classes } );
363
+ const blockProps = useBlockProps( {
364
+ ref: containerRef,
365
+ className: classes,
366
+ } );
300
367
 
301
368
  // Much of this description is duplicated from MediaPlaceholder.
302
369
  const { lockUrlControls = false, lockUrlControlsMessage } = useSelect(
@@ -335,13 +402,17 @@ export function ImageEdit( {
335
402
  [ borderProps.className ]:
336
403
  !! borderProps.className && ! isSingleSelected,
337
404
  } ) }
338
- withIllustration
339
- icon={ lockUrlControls ? pluginsIcon : icon }
340
- label={ __( 'Image' ) }
405
+ icon={
406
+ ! isSmallContainer &&
407
+ ( lockUrlControls ? pluginsIcon : icon )
408
+ }
409
+ withIllustration={ ! isSingleSelected || isSmallContainer }
410
+ label={ ! isSmallContainer && __( 'Image' ) }
341
411
  instructions={
342
412
  ! lockUrlControls &&
413
+ ! isSmallContainer &&
343
414
  __(
344
- 'Upload an image file, pick one from your media library, or add one with a URL.'
415
+ 'Upload or drag an image file here, or pick one from your library.'
345
416
  )
346
417
  }
347
418
  style={ {
@@ -356,13 +427,12 @@ export function ImageEdit( {
356
427
  ...shadowProps.style,
357
428
  } }
358
429
  >
359
- { lockUrlControls ? (
360
- <span className="block-bindings-media-placeholder-message">
361
- { lockUrlControlsMessage }
362
- </span>
363
- ) : (
364
- content
365
- ) }
430
+ { lockUrlControls &&
431
+ ! isSmallContainer &&
432
+ lockUrlControlsMessage }
433
+
434
+ { ! lockUrlControls && ! isSmallContainer && content }
435
+ { placeholderResizeListener }
366
436
  </Placeholder>
367
437
  );
368
438
  };
@@ -384,7 +454,7 @@ export function ImageEdit( {
384
454
  clientId={ clientId }
385
455
  blockEditingMode={ blockEditingMode }
386
456
  parentLayoutType={ parentLayout?.type }
387
- containerWidth={ containerWidth }
457
+ maxContentWidth={ maxContentWidth }
388
458
  />
389
459
  <MediaPlaceholder
390
460
  icon={ <BlockIcon icon={ icon } /> }
@@ -394,6 +464,7 @@ export function ImageEdit( {
394
464
  placeholder={ placeholder }
395
465
  accept="image/*"
396
466
  allowedTypes={ ALLOWED_MEDIA_TYPES }
467
+ handleUpload={ ( files ) => files.length === 1 }
397
468
  value={ { id, src } }
398
469
  mediaPreview={ mediaPreview }
399
470
  disableMediaButtons={ temporaryURL || url }
@@ -402,7 +473,7 @@ export function ImageEdit( {
402
473
  {
403
474
  // The listener cannot be placed as the first element as it will break the in-between inserter.
404
475
  // See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120
405
- contentResizeListener
476
+ isSingleSelected && isMaxWidthContainerWidth && maxWidthObserver
406
477
  }
407
478
  </>
408
479
  );
@@ -1,44 +1,8 @@
1
1
  // Provide special styling for the placeholder.
2
2
  // @todo this particular minimal style of placeholder could be componentized further.
3
3
  .wp-block-image.wp-block-image {
4
-
5
- // Show Placeholder style on-select.
6
- &.is-selected .block-editor-media-placeholder {
7
- // Block UI appearance.
8
- color: $gray-900;
9
- background-color: $white;
10
- box-shadow: inset 0 0 0 $border-width $gray-900;
11
- border: none;
12
-
13
- // Disable any duotone filter applied in the selected state.
14
- filter: none !important;
15
-
16
- > svg {
17
- opacity: 0;
18
- }
19
-
20
- .components-placeholder__illustration {
21
- display: none;
22
- }
23
-
24
- &::before {
25
- opacity: 0;
26
- }
27
- }
28
- .block-bindings-media-placeholder-message {
29
- opacity: 0;
30
- }
31
- &.is-selected .block-bindings-media-placeholder-message {
32
- opacity: 1;
33
- }
34
-
35
- // Remove the transition while we still have a legacy placeholder style.
36
- // Otherwise the content jumps between the 1px placeholder border, and any inherited custom
37
- // parent border that may get applied when you deselect.
38
- .components-placeholder__label,
39
- .components-placeholder__instructions,
40
- .components-button {
41
- transition: none;
4
+ .block-editor-media-placeholder.is-small {
5
+ min-height: 60px;
42
6
  }
43
7
  }
44
8
 
@@ -149,6 +113,11 @@ figure.wp-block-image:not(.wp-block) {
149
113
  text-align: center;
150
114
  }
151
115
 
116
+ // Relatively position the alignment container to support the content resizer.
117
+ .wp-block[data-align]:has(> .wp-block-image) {
118
+ position: relative;
119
+ }
120
+
152
121
  .wp-block-image__crop-area {
153
122
  position: relative;
154
123
  max-width: 100%;
@@ -108,7 +108,7 @@ export default function Image( {
108
108
  clientId,
109
109
  blockEditingMode,
110
110
  parentLayoutType,
111
- containerWidth,
111
+ maxContentWidth,
112
112
  } ) {
113
113
  const {
114
114
  url = '',
@@ -556,6 +556,24 @@ export default function Image( {
556
556
 
557
557
  const showBlockControls = showUrlInput || allowCrop || showCoverControls;
558
558
 
559
+ const mediaReplaceFlow = isSingleSelected &&
560
+ ! isEditingImage &&
561
+ ! lockUrlControls && (
562
+ <BlockControls group="other">
563
+ <MediaReplaceFlow
564
+ mediaId={ id }
565
+ mediaURL={ url }
566
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
567
+ accept="image/*"
568
+ onSelect={ onSelectImage }
569
+ onSelectURL={ onSelectURL }
570
+ onError={ onUploadError }
571
+ name={ ! url ? __( 'Add image' ) : __( 'Replace' ) }
572
+ onReset={ () => onSelectImage( undefined ) }
573
+ />
574
+ </BlockControls>
575
+ );
576
+
559
577
  const controls = (
560
578
  <>
561
579
  { showBlockControls && (
@@ -592,20 +610,6 @@ export default function Image( {
592
610
  ) }
593
611
  </BlockControls>
594
612
  ) }
595
- { isSingleSelected && ! isEditingImage && ! lockUrlControls && (
596
- <BlockControls group="other">
597
- <MediaReplaceFlow
598
- mediaId={ id }
599
- mediaURL={ url }
600
- allowedTypes={ ALLOWED_MEDIA_TYPES }
601
- accept="image/*"
602
- onSelect={ onSelectImage }
603
- onSelectURL={ onSelectURL }
604
- onError={ onUploadError }
605
- onReset={ () => onSelectImage( undefined ) }
606
- />
607
- </BlockControls>
608
- ) }
609
613
  { isSingleSelected && externalBlob && (
610
614
  <BlockControls>
611
615
  <ToolbarGroup>
@@ -934,7 +938,7 @@ export default function Image( {
934
938
  // @todo It would be good to revisit this once a content-width variable
935
939
  // becomes available.
936
940
  const maxWidthBuffer = maxWidth * 2.5;
937
- const maxContentWidth = containerWidth || maxWidthBuffer;
941
+ const maxResizeWidth = maxContentWidth || maxWidthBuffer;
938
942
 
939
943
  let showRightHandle = false;
940
944
  let showLeftHandle = false;
@@ -980,9 +984,9 @@ export default function Image( {
980
984
  } }
981
985
  showHandle={ isSingleSelected }
982
986
  minWidth={ minWidth }
983
- maxWidth={ maxContentWidth }
987
+ maxWidth={ maxResizeWidth }
984
988
  minHeight={ minHeight }
985
- maxHeight={ maxContentWidth / ratio }
989
+ maxHeight={ maxResizeWidth / ratio }
986
990
  lockAspectRatio={ ratio }
987
991
  enable={ {
988
992
  top: false,
@@ -996,6 +1000,7 @@ export default function Image( {
996
1000
 
997
1001
  // Clear hardcoded width if the resized width is close to the max-content width.
998
1002
  if (
1003
+ maxContentWidth &&
999
1004
  // Only do this if the image is bigger than the container to prevent it from being squished.
1000
1005
  // TODO: Remove this check if the image support setting 100% width.
1001
1006
  naturalWidth >= maxContentWidth &&
@@ -1029,12 +1034,18 @@ export default function Image( {
1029
1034
  }
1030
1035
 
1031
1036
  if ( ! url && ! temporaryURL ) {
1032
- // Add all controls if the image attributes are connected.
1033
- return metadata?.bindings ? controls : sizeControls;
1037
+ return (
1038
+ <>
1039
+ { mediaReplaceFlow }
1040
+ { /* Add all controls if the image attributes are connected. */ }
1041
+ { metadata?.bindings ? controls : sizeControls }
1042
+ </>
1043
+ );
1034
1044
  }
1035
1045
 
1036
1046
  return (
1037
1047
  <>
1048
+ { mediaReplaceFlow }
1038
1049
  { controls }
1039
1050
  { img }
1040
1051
 
@@ -72,7 +72,7 @@ function render_block_core_image( $attributes, $content, $block ) {
72
72
  ) {
73
73
  $suffix = wp_scripts_get_suffix();
74
74
  if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
75
- $module_url = gutenberg_url( '/build/interactivity/image.min.js' );
75
+ $module_url = gutenberg_url( '/build-module/block-library/image/view.min.js' );
76
76
  }
77
77
 
78
78
  wp_register_script_module(
@@ -3,9 +3,6 @@
3
3
  */
4
4
  import { createBlobURL, isBlobURL } from '@wordpress/blob';
5
5
  import { createBlock, getBlockAttributes } from '@wordpress/blocks';
6
- import { dispatch } from '@wordpress/data';
7
- import { store as noticesStore } from '@wordpress/notices';
8
- import { __ } from '@wordpress/i18n';
9
6
 
10
7
  export function stripFirstImage( attributes, { shortcode } ) {
11
8
  const { body } = document.implementation.createHTMLDocument( '' );
@@ -138,26 +135,6 @@ const transforms = {
138
135
  // creating a new gallery.
139
136
  type: 'files',
140
137
  isMatch( files ) {
141
- // The following check is intended to catch non-image files when dropped together with images.
142
- if (
143
- files.some(
144
- ( file ) => file.type.indexOf( 'image/' ) === 0
145
- ) &&
146
- files.some(
147
- ( file ) => file.type.indexOf( 'image/' ) !== 0
148
- )
149
- ) {
150
- const { createErrorNotice } = dispatch( noticesStore );
151
- createErrorNotice(
152
- __(
153
- 'If uploading to a gallery all files need to be image formats'
154
- ),
155
- {
156
- id: 'gallery-transform-invalid-file',
157
- type: 'snackbar',
158
- }
159
- );
160
- }
161
138
  return files.every(
162
139
  ( file ) => file.type.indexOf( 'image/' ) === 0
163
140
  );
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useRef } from '@wordpress/element';
5
+ import { useResizeObserver } from '@wordpress/compose';
6
+
7
+ function useMaxWidthObserver() {
8
+ const [ contentResizeListener, { width } ] = useResizeObserver();
9
+ const observerRef = useRef();
10
+
11
+ const maxWidthObserver = (
12
+ <div
13
+ // Some themes set max-width on blocks.
14
+ className="wp-block"
15
+ aria-hidden="true"
16
+ style={ {
17
+ position: 'absolute',
18
+ inset: 0,
19
+ width: '100%',
20
+ height: 0,
21
+ margin: 0,
22
+ } }
23
+ ref={ observerRef }
24
+ >
25
+ { contentResizeListener }
26
+ </div>
27
+ );
28
+
29
+ return [ maxWidthObserver, width ];
30
+ }
31
+
32
+ export { useMaxWidthObserver };
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { NEW_TAB_REL } from './constants';
4
+ import { NEW_TAB_REL, ALLOWED_MEDIA_TYPES } from './constants';
5
5
 
6
6
  /**
7
7
  * Evaluates a CSS aspect-ratio property value as a number.
@@ -81,3 +81,15 @@ export function getImageSizeAttributes( image, size ) {
81
81
 
82
82
  return {};
83
83
  }
84
+
85
+ /**
86
+ * Checks if the file has a valid file type.
87
+ *
88
+ * @param {File} file - The file to check.
89
+ * @return {boolean} - Returns true if the file has a valid file type, otherwise false.
90
+ */
91
+ export function isValidFileType( file ) {
92
+ return ALLOWED_MEDIA_TYPES.some(
93
+ ( mediaType ) => file.type.indexOf( mediaType ) === 0
94
+ );
95
+ }
@@ -243,7 +243,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
243
243
  { displayPostContent && (
244
244
  <RadioControl
245
245
  className="wp-block-latest-posts__post-content-radio"
246
- label={ __( 'Show:' ) }
246
+ label={ __( 'Show' ) }
247
247
  selected={ displayPostContentRadio }
248
248
  options={ [
249
249
  { label: __( 'Excerpt' ), value: 'excerpt' },
@@ -50,8 +50,7 @@ export default function MissingEdit( { attributes, clientId } ) {
50
50
 
51
51
  const convertToHtmlButton = (
52
52
  <Button
53
- // TODO: Switch to `true` (40px size) if possible
54
- __next40pxDefaultSize={ false }
53
+ __next40pxDefaultSize
55
54
  key="convert"
56
55
  onClick={ convertToHTML }
57
56
  variant="primary"
@@ -2,29 +2,32 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { Warning } from '@wordpress/block-editor';
5
- import { Button } from '@wordpress/components';
5
+ import { Button, Notice } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
7
  import { createInterpolateElement } from '@wordpress/element';
8
8
 
9
- function DeletedNavigationWarning( { onCreateNew } ) {
10
- return (
11
- <Warning>
12
- { createInterpolateElement(
13
- __(
14
- 'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
15
- ),
16
- {
17
- button: (
18
- <Button
19
- // TODO: Switch to `true` (40px size) if possible
20
- __next40pxDefaultSize={ false }
21
- onClick={ onCreateNew }
22
- variant="link"
23
- />
24
- ),
25
- }
26
- ) }
27
- </Warning>
9
+ function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) {
10
+ const message = createInterpolateElement(
11
+ __(
12
+ 'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
13
+ ),
14
+ {
15
+ button: (
16
+ <Button
17
+ __next40pxDefaultSize
18
+ onClick={ onCreateNew }
19
+ variant="link"
20
+ />
21
+ ),
22
+ }
23
+ );
24
+
25
+ return isNotice ? (
26
+ <Notice status="warning" isDismissible={ false }>
27
+ { message }
28
+ </Notice>
29
+ ) : (
30
+ <Warning>{ message }</Warning>
28
31
  );
29
32
  }
30
33
 
@@ -591,8 +591,7 @@ function Navigation( {
591
591
  { isResponsive && (
592
592
  <>
593
593
  <Button
594
- // TODO: Switch to `true` (40px size) if possible
595
- __next40pxDefaultSize={ false }
594
+ __next40pxDefaultSize
596
595
  className={ overlayMenuPreviewClasses }
597
596
  onClick={ () => {
598
597
  setOverlayMenuPreview(
@@ -94,7 +94,9 @@ const MainContent = ( {
94
94
  const { navigationMenu } = useNavigationMenu( currentMenuId );
95
95
 
96
96
  if ( currentMenuId && isNavigationMenuMissing ) {
97
- return <DeletedNavigationWarning onCreateNew={ onCreateNew } />;
97
+ return (
98
+ <DeletedNavigationWarning onCreateNew={ onCreateNew } isNotice />
99
+ );
98
100
  }
99
101
 
100
102
  if ( isLoading ) {
@@ -19,8 +19,7 @@ export default function NavigationMenuDeleteControl( { onDelete } ) {
19
19
  return (
20
20
  <>
21
21
  <Button
22
- // TODO: Switch to `true` (40px size) if possible
23
- __next40pxDefaultSize={ false }
22
+ __next40pxDefaultSize
24
23
  className="wp-block-navigation-delete-menu-button"
25
24
  variant="secondary"
26
25
  isDestructive
@@ -76,8 +76,7 @@ export default function NavigationPlaceholder( {
76
76
 
77
77
  { canUserCreateNavigationMenus && (
78
78
  <Button
79
- // TODO: Switch to `true` (40px size) if possible
80
- __next40pxDefaultSize={ false }
79
+ __next40pxDefaultSize
81
80
  variant="tertiary"
82
81
  onClick={ onCreateEmpty }
83
82
  >
@@ -79,8 +79,7 @@ export default function ResponsiveWrapper( {
79
79
  <>
80
80
  { ! isOpen && (
81
81
  <Button
82
- // TODO: Switch to `true` (40px size) if possible
83
- __next40pxDefaultSize={ false }
82
+ __next40pxDefaultSize
84
83
  aria-haspopup="true"
85
84
  aria-label={ hasIcon && __( 'Open menu' ) }
86
85
  className={ openButtonClasses }
@@ -102,8 +101,7 @@ export default function ResponsiveWrapper( {
102
101
  >
103
102
  <div { ...dialogProps }>
104
103
  <Button
105
- // TODO: Switch to `true` (40px size) if possible
106
- __next40pxDefaultSize={ false }
104
+ __next40pxDefaultSize
107
105
  className="wp-block-navigation__responsive-container-close"
108
106
  aria-label={ hasIcon && __( 'Close menu' ) }
109
107
  onClick={ () => onToggle( false ) }
@@ -563,7 +563,11 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
563
563
  width: 100%;
564
564
  background-color: $gray-100;
565
565
  padding: 0 $grid-unit-30;
566
- height: $grid-unit-40 * 2;
566
+
567
+ // Adding !important to override default 40px size.
568
+ // Ref - https://github.com/WordPress/gutenberg/pull/65075#discussion_r1746282734
569
+ height: $grid-unit-40 * 2 !important;
570
+
567
571
  margin-bottom: $grid-unit-15;
568
572
 
569
573
  &.open {
@@ -624,7 +624,7 @@ class WP_Navigation_Block_Renderer {
624
624
  if ( static::is_interactive( $attributes, $inner_blocks ) ) {
625
625
  $suffix = wp_scripts_get_suffix();
626
626
  if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
627
- $module_url = gutenberg_url( '/build/interactivity/navigation.min.js' );
627
+ $module_url = gutenberg_url( '/build-module/block-library/navigation/view.min.js' );
628
628
  }
629
629
 
630
630
  wp_register_script_module(
@@ -310,8 +310,7 @@ const LinkUITools = ( { setAddingBlock, focusAddBlockButton } ) => {
310
310
  return (
311
311
  <VStack className="link-ui-tools">
312
312
  <Button
313
- // TODO: Switch to `true` (40px size) if possible
314
- __next40pxDefaultSize={ false }
313
+ __next40pxDefaultSize
315
314
  ref={ addBlockButtonRef }
316
315
  icon={ plus }
317
316
  onClick={ ( e ) => {
@@ -32,16 +32,14 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
32
32
  </p>
33
33
  <div className="wp-block-page-list-modal-buttons">
34
34
  <Button
35
- // TODO: Switch to `true` (40px size) if possible
36
- __next40pxDefaultSize={ false }
35
+ __next40pxDefaultSize
37
36
  variant="tertiary"
38
37
  onClick={ onClose }
39
38
  >
40
39
  { __( 'Cancel' ) }
41
40
  </Button>
42
41
  <Button
43
- // TODO: Switch to `true` (40px size) if possible
44
- __next40pxDefaultSize={ false }
42
+ __next40pxDefaultSize
45
43
  variant="primary"
46
44
  accessibleWhenDisabled
47
45
  disabled={ disabled }
@@ -342,8 +342,7 @@ export default function PageListEdit( {
342
342
  <PanelBody title={ __( 'Edit this menu' ) }>
343
343
  <p>{ convertDescription }</p>
344
344
  <Button
345
- // TODO: Switch to `true` (40px size) if possible
346
- __next40pxDefaultSize={ false }
345
+ __next40pxDefaultSize
347
346
  variant="primary"
348
347
  accessibleWhenDisabled
349
348
  disabled={ ! hasResolvedPages }