@wordpress/block-library 9.2.0 → 9.3.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 (302) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +20 -8
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/audio/index.js +4 -0
  5. package/build/audio/index.js.map +1 -1
  6. package/build/audio/transforms.js +1 -1
  7. package/build/audio/transforms.js.map +1 -1
  8. package/build/block/edit.js +0 -1
  9. package/build/block/edit.js.map +1 -1
  10. package/build/block/index.js +5 -1
  11. package/build/block/index.js.map +1 -1
  12. package/build/embed/embed-preview.js +4 -4
  13. package/build/embed/embed-preview.js.map +1 -1
  14. package/build/file/edit.js +14 -6
  15. package/build/file/edit.js.map +1 -1
  16. package/build/file/index.js +4 -0
  17. package/build/file/index.js.map +1 -1
  18. package/build/file/transforms.js +2 -3
  19. package/build/file/transforms.js.map +1 -1
  20. package/build/gallery/deprecated.js +6 -54
  21. package/build/gallery/deprecated.js.map +1 -1
  22. package/build/gallery/edit.js +9 -8
  23. package/build/gallery/edit.js.map +1 -1
  24. package/build/gallery/index.js +2 -2
  25. package/build/gallery/index.js.map +1 -1
  26. package/build/gallery/save.js +0 -11
  27. package/build/gallery/save.js.map +1 -1
  28. package/build/gallery/shared.js +0 -27
  29. package/build/gallery/shared.js.map +1 -1
  30. package/build/gallery/transforms.js +29 -80
  31. package/build/gallery/transforms.js.map +1 -1
  32. package/build/group/index.js +1 -0
  33. package/build/group/index.js.map +1 -1
  34. package/build/group/placeholder.js +5 -0
  35. package/build/group/placeholder.js.map +1 -1
  36. package/build/image/edit.js +13 -21
  37. package/build/image/edit.js.map +1 -1
  38. package/build/image/image.js +30 -17
  39. package/build/image/image.js.map +1 -1
  40. package/build/image/index.js +4 -0
  41. package/build/image/index.js.map +1 -1
  42. package/build/image/transforms.js +1 -1
  43. package/build/image/transforms.js.map +1 -1
  44. package/build/list-item/edit.js +1 -1
  45. package/build/list-item/edit.js.map +1 -1
  46. package/build/list-item/hooks/use-merge.js +8 -1
  47. package/build/list-item/hooks/use-merge.js.map +1 -1
  48. package/build/list-item/index.js +11 -1
  49. package/build/list-item/index.js.map +1 -1
  50. package/build/loginout/index.js +3 -0
  51. package/build/loginout/index.js.map +1 -1
  52. package/build/media-text/edit.js +3 -2
  53. package/build/media-text/edit.js.map +1 -1
  54. package/build/navigation-submenu/edit.js +1 -1
  55. package/build/navigation-submenu/edit.js.map +1 -1
  56. package/build/page-list/convert-to-links-modal.js +1 -1
  57. package/build/page-list/convert-to-links-modal.js.map +1 -1
  58. package/build/page-list/edit.js +1 -1
  59. package/build/page-list/edit.js.map +1 -1
  60. package/build/post-content/index.js +3 -0
  61. package/build/post-content/index.js.map +1 -1
  62. package/build/post-date/edit.js +3 -1
  63. package/build/post-date/edit.js.map +1 -1
  64. package/build/post-excerpt/index.js +3 -0
  65. package/build/post-excerpt/index.js.map +1 -1
  66. package/build/post-title/index.js +3 -0
  67. package/build/post-title/index.js.map +1 -1
  68. package/build/query/edit/inspector-controls/index.js +3 -2
  69. package/build/query/edit/inspector-controls/index.js.map +1 -1
  70. package/build/query/edit/query-toolbar.js +54 -61
  71. package/build/query/edit/query-toolbar.js.map +1 -1
  72. package/build/query/index.js +34 -0
  73. package/build/query/index.js.map +1 -1
  74. package/build/social-link/edit.js +27 -7
  75. package/build/social-link/edit.js.map +1 -1
  76. package/build/table/edit.js +8 -17
  77. package/build/table/edit.js.map +1 -1
  78. package/build/template-part/edit/title-modal.js +1 -1
  79. package/build/template-part/edit/title-modal.js.map +1 -1
  80. package/build/utils/hooks.js +12 -0
  81. package/build/utils/hooks.js.map +1 -1
  82. package/build/video/deprecated.js +4 -0
  83. package/build/video/deprecated.js.map +1 -1
  84. package/build/video/edit.js +17 -7
  85. package/build/video/edit.js.map +1 -1
  86. package/build/video/index.js +4 -0
  87. package/build/video/index.js.map +1 -1
  88. package/build/video/transforms.js +1 -1
  89. package/build/video/transforms.js.map +1 -1
  90. package/build-module/audio/edit.js +20 -8
  91. package/build-module/audio/edit.js.map +1 -1
  92. package/build-module/audio/index.js +4 -0
  93. package/build-module/audio/index.js.map +1 -1
  94. package/build-module/audio/transforms.js +1 -1
  95. package/build-module/audio/transforms.js.map +1 -1
  96. package/build-module/block/edit.js +0 -1
  97. package/build-module/block/edit.js.map +1 -1
  98. package/build-module/block/index.js +5 -1
  99. package/build-module/block/index.js.map +1 -1
  100. package/build-module/embed/embed-preview.js +4 -4
  101. package/build-module/embed/embed-preview.js.map +1 -1
  102. package/build-module/file/edit.js +15 -7
  103. package/build-module/file/edit.js.map +1 -1
  104. package/build-module/file/index.js +4 -0
  105. package/build-module/file/index.js.map +1 -1
  106. package/build-module/file/transforms.js +2 -3
  107. package/build-module/file/transforms.js.map +1 -1
  108. package/build-module/gallery/deprecated.js +6 -54
  109. package/build-module/gallery/deprecated.js.map +1 -1
  110. package/build-module/gallery/edit.js +10 -9
  111. package/build-module/gallery/edit.js.map +1 -1
  112. package/build-module/gallery/index.js +1 -1
  113. package/build-module/gallery/index.js.map +1 -1
  114. package/build-module/gallery/save.js +0 -11
  115. package/build-module/gallery/save.js.map +1 -1
  116. package/build-module/gallery/shared.js +0 -25
  117. package/build-module/gallery/shared.js.map +1 -1
  118. package/build-module/gallery/transforms.js +29 -80
  119. package/build-module/gallery/transforms.js.map +1 -1
  120. package/build-module/group/index.js +1 -0
  121. package/build-module/group/index.js.map +1 -1
  122. package/build-module/group/placeholder.js +5 -0
  123. package/build-module/group/placeholder.js.map +1 -1
  124. package/build-module/image/edit.js +12 -20
  125. package/build-module/image/edit.js.map +1 -1
  126. package/build-module/image/image.js +25 -12
  127. package/build-module/image/image.js.map +1 -1
  128. package/build-module/image/index.js +4 -0
  129. package/build-module/image/index.js.map +1 -1
  130. package/build-module/image/transforms.js +1 -1
  131. package/build-module/image/transforms.js.map +1 -1
  132. package/build-module/list-item/edit.js +1 -1
  133. package/build-module/list-item/edit.js.map +1 -1
  134. package/build-module/list-item/hooks/use-merge.js +8 -1
  135. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  136. package/build-module/list-item/index.js +11 -1
  137. package/build-module/list-item/index.js.map +1 -1
  138. package/build-module/loginout/index.js +3 -0
  139. package/build-module/loginout/index.js.map +1 -1
  140. package/build-module/media-text/edit.js +3 -2
  141. package/build-module/media-text/edit.js.map +1 -1
  142. package/build-module/navigation-submenu/edit.js +1 -1
  143. package/build-module/navigation-submenu/edit.js.map +1 -1
  144. package/build-module/page-list/convert-to-links-modal.js +1 -1
  145. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  146. package/build-module/page-list/edit.js +1 -1
  147. package/build-module/page-list/edit.js.map +1 -1
  148. package/build-module/post-content/index.js +3 -0
  149. package/build-module/post-content/index.js.map +1 -1
  150. package/build-module/post-date/edit.js +4 -2
  151. package/build-module/post-date/edit.js.map +1 -1
  152. package/build-module/post-excerpt/index.js +3 -0
  153. package/build-module/post-excerpt/index.js.map +1 -1
  154. package/build-module/post-title/index.js +3 -0
  155. package/build-module/post-title/index.js.map +1 -1
  156. package/build-module/query/edit/inspector-controls/index.js +3 -2
  157. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  158. package/build-module/query/edit/query-toolbar.js +55 -62
  159. package/build-module/query/edit/query-toolbar.js.map +1 -1
  160. package/build-module/query/index.js +34 -0
  161. package/build-module/query/index.js.map +1 -1
  162. package/build-module/social-link/edit.js +28 -8
  163. package/build-module/social-link/edit.js.map +1 -1
  164. package/build-module/table/edit.js +9 -18
  165. package/build-module/table/edit.js.map +1 -1
  166. package/build-module/template-part/edit/title-modal.js +1 -1
  167. package/build-module/template-part/edit/title-modal.js.map +1 -1
  168. package/build-module/utils/hooks.js +11 -0
  169. package/build-module/utils/hooks.js.map +1 -1
  170. package/build-module/video/deprecated.js +4 -0
  171. package/build-module/video/deprecated.js.map +1 -1
  172. package/build-module/video/edit.js +18 -8
  173. package/build-module/video/edit.js.map +1 -1
  174. package/build-module/video/index.js +4 -0
  175. package/build-module/video/index.js.map +1 -1
  176. package/build-module/video/transforms.js +1 -1
  177. package/build-module/video/transforms.js.map +1 -1
  178. package/build-style/editor-rtl.css +3 -0
  179. package/build-style/editor.css +3 -0
  180. package/build-style/post-comments-form/style-rtl.css +11 -10
  181. package/build-style/post-comments-form/style.css +11 -10
  182. package/build-style/query/editor-rtl.css +3 -0
  183. package/build-style/query/editor.css +3 -0
  184. package/build-style/social-links/style-rtl.css +91 -91
  185. package/build-style/social-links/style.css +91 -91
  186. package/build-style/style-rtl.css +102 -101
  187. package/build-style/style.css +102 -101
  188. package/package.json +35 -35
  189. package/src/audio/block.json +4 -0
  190. package/src/audio/edit.js +19 -7
  191. package/src/audio/transforms.js +1 -1
  192. package/src/block/block.json +5 -1
  193. package/src/block/edit.js +0 -1
  194. package/src/button/index.php +14 -1
  195. package/src/embed/embed-preview.js +4 -6
  196. package/src/file/block.json +4 -0
  197. package/src/file/edit.js +19 -6
  198. package/src/file/transforms.js +1 -2
  199. package/src/gallery/deprecated.js +6 -55
  200. package/src/gallery/edit.js +13 -10
  201. package/src/gallery/gallery-styles.native.scss +0 -2
  202. package/src/gallery/index.js +1 -1
  203. package/src/gallery/save.js +0 -10
  204. package/src/gallery/shared.js +0 -28
  205. package/src/gallery/transforms.js +56 -99
  206. package/src/group/block.json +1 -0
  207. package/src/group/placeholder.js +7 -0
  208. package/src/image/block.json +4 -0
  209. package/src/image/edit.js +10 -19
  210. package/src/image/image.js +36 -14
  211. package/src/image/index.php +26 -5
  212. package/src/image/transforms.js +1 -1
  213. package/src/list-item/block.json +11 -1
  214. package/src/list-item/edit.js +1 -1
  215. package/src/list-item/hooks/use-merge.js +19 -5
  216. package/src/loginout/block.json +3 -0
  217. package/src/media-text/edit.js +3 -2
  218. package/src/navigation-submenu/edit.js +1 -1
  219. package/src/page-list/convert-to-links-modal.js +1 -1
  220. package/src/page-list/edit.js +1 -1
  221. package/src/post-comments-form/style.scss +15 -12
  222. package/src/post-content/block.json +3 -0
  223. package/src/post-date/edit.js +5 -1
  224. package/src/post-date/index.php +8 -2
  225. package/src/post-excerpt/block.json +3 -0
  226. package/src/post-title/block.json +3 -0
  227. package/src/query/edit/inspector-controls/index.js +3 -2
  228. package/src/query/edit/query-toolbar.js +60 -72
  229. package/src/query/editor.scss +4 -0
  230. package/src/query/index.js +40 -0
  231. package/src/social-link/edit.js +29 -3
  232. package/src/social-links/style.scss +2 -2
  233. package/src/table/edit.js +11 -24
  234. package/src/template-part/edit/title-modal.js +1 -1
  235. package/src/utils/hooks.js +14 -1
  236. package/src/video/block.json +4 -0
  237. package/src/video/edit.js +23 -8
  238. package/src/video/transforms.js +1 -1
  239. package/tsconfig.tsbuildinfo +1 -1
  240. package/build/gallery/edit-wrapper.js +0 -37
  241. package/build/gallery/edit-wrapper.js.map +0 -1
  242. package/build/gallery/v1/constants.js +0 -10
  243. package/build/gallery/v1/constants.js.map +0 -1
  244. package/build/gallery/v1/edit.js +0 -399
  245. package/build/gallery/v1/edit.js.map +0 -1
  246. package/build/gallery/v1/gallery-button.native.js +0 -55
  247. package/build/gallery/v1/gallery-button.native.js.map +0 -1
  248. package/build/gallery/v1/gallery-image.js +0 -285
  249. package/build/gallery/v1/gallery-image.js.map +0 -1
  250. package/build/gallery/v1/gallery-image.native.js +0 -297
  251. package/build/gallery/v1/gallery-image.native.js.map +0 -1
  252. package/build/gallery/v1/gallery.js +0 -112
  253. package/build/gallery/v1/gallery.js.map +0 -1
  254. package/build/gallery/v1/gallery.native.js +0 -139
  255. package/build/gallery/v1/gallery.native.js.map +0 -1
  256. package/build/gallery/v1/save.js +0 -81
  257. package/build/gallery/v1/save.js.map +0 -1
  258. package/build/gallery/v1/shared.js +0 -17
  259. package/build/gallery/v1/shared.js.map +0 -1
  260. package/build/gallery/v1/tiles.native.js +0 -83
  261. package/build/gallery/v1/tiles.native.js.map +0 -1
  262. package/build/utils/constants.js +0 -15
  263. package/build/utils/constants.js.map +0 -1
  264. package/build-module/gallery/edit-wrapper.js +0 -31
  265. package/build-module/gallery/edit-wrapper.js.map +0 -1
  266. package/build-module/gallery/v1/constants.js +0 -4
  267. package/build-module/gallery/v1/constants.js.map +0 -1
  268. package/build-module/gallery/v1/edit.js +0 -393
  269. package/build-module/gallery/v1/edit.js.map +0 -1
  270. package/build-module/gallery/v1/gallery-button.native.js +0 -46
  271. package/build-module/gallery/v1/gallery-button.native.js.map +0 -1
  272. package/build-module/gallery/v1/gallery-image.js +0 -279
  273. package/build-module/gallery/v1/gallery-image.js.map +0 -1
  274. package/build-module/gallery/v1/gallery-image.native.js +0 -291
  275. package/build-module/gallery/v1/gallery-image.native.js.map +0 -1
  276. package/build-module/gallery/v1/gallery.js +0 -104
  277. package/build-module/gallery/v1/gallery.js.map +0 -1
  278. package/build-module/gallery/v1/gallery.native.js +0 -131
  279. package/build-module/gallery/v1/gallery.native.js.map +0 -1
  280. package/build-module/gallery/v1/save.js +0 -74
  281. package/build-module/gallery/v1/save.js.map +0 -1
  282. package/build-module/gallery/v1/shared.js +0 -10
  283. package/build-module/gallery/v1/shared.js.map +0 -1
  284. package/build-module/gallery/v1/tiles.native.js +0 -75
  285. package/build-module/gallery/v1/tiles.native.js.map +0 -1
  286. package/build-module/utils/constants.js +0 -9
  287. package/build-module/utils/constants.js.map +0 -1
  288. package/src/gallery/edit-wrapper.js +0 -27
  289. package/src/gallery/v1/constants.js +0 -3
  290. package/src/gallery/v1/edit.js +0 -450
  291. package/src/gallery/v1/gallery-button.native.js +0 -47
  292. package/src/gallery/v1/gallery-image-style.native.scss +0 -109
  293. package/src/gallery/v1/gallery-image.js +0 -293
  294. package/src/gallery/v1/gallery-image.native.js +0 -348
  295. package/src/gallery/v1/gallery-styles.native.scss +0 -8
  296. package/src/gallery/v1/gallery.js +0 -125
  297. package/src/gallery/v1/gallery.native.js +0 -162
  298. package/src/gallery/v1/save.js +0 -98
  299. package/src/gallery/v1/shared.js +0 -19
  300. package/src/gallery/v1/tiles-styles.native.scss +0 -11
  301. package/src/gallery/v1/tiles.native.js +0 -79
  302. package/src/utils/constants.js +0 -8
package/src/image/edit.js CHANGED
@@ -56,17 +56,6 @@ export const pickRelevantMediaFiles = ( image, size ) => {
56
56
  return imageProps;
57
57
  };
58
58
 
59
- /**
60
- * Is the URL a temporary blob URL? A blob URL is one that is used temporarily
61
- * while the image is being uploaded and will not have an id yet allocated.
62
- *
63
- * @param {number=} id The id of the image.
64
- * @param {string=} url The url of the image.
65
- *
66
- * @return {boolean} Is the URL a Blob URL
67
- */
68
- const isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );
69
-
70
59
  /**
71
60
  * Is the url for the image hosted externally. An externally hosted image has no
72
61
  * id and is not a blob url.
@@ -118,9 +107,7 @@ export function ImageEdit( {
118
107
  align,
119
108
  metadata,
120
109
  } = attributes;
121
- const [ temporaryURL, setTemporaryURL ] = useState( () => {
122
- return isTemporaryImage( id, url ) ? url : undefined;
123
- } );
110
+ const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
124
111
 
125
112
  const altRef = useRef();
126
113
  useEffect( () => {
@@ -157,8 +144,8 @@ export function ImageEdit( {
157
144
  src: undefined,
158
145
  id: undefined,
159
146
  url: undefined,
147
+ blob: undefined,
160
148
  } );
161
- setTemporaryURL( undefined );
162
149
  }
163
150
 
164
151
  function onSelectImage( media ) {
@@ -169,7 +156,9 @@ export function ImageEdit( {
169
156
  id: undefined,
170
157
  title: undefined,
171
158
  caption: undefined,
159
+ blob: undefined,
172
160
  } );
161
+ setTemporaryURL();
173
162
 
174
163
  return;
175
164
  }
@@ -179,8 +168,6 @@ export function ImageEdit( {
179
168
  return;
180
169
  }
181
170
 
182
- setTemporaryURL();
183
-
184
171
  const { imageDefaultSize } = getSettings();
185
172
 
186
173
  // Try to use the previous selected image size if its available
@@ -254,24 +241,28 @@ export function ImageEdit( {
254
241
  mediaAttributes.href = href;
255
242
 
256
243
  setAttributes( {
244
+ blob: undefined,
257
245
  ...mediaAttributes,
258
246
  ...additionalAttributes,
259
247
  linkDestination,
260
248
  } );
249
+ setTemporaryURL();
261
250
  }
262
251
 
263
252
  function onSelectURL( newURL ) {
264
253
  if ( newURL !== url ) {
265
254
  setAttributes( {
255
+ blob: undefined,
266
256
  url: newURL,
267
257
  id: undefined,
268
258
  sizeSlug: getSettings().imageDefaultSize,
269
259
  } );
260
+ setTemporaryURL();
270
261
  }
271
262
  }
272
263
 
273
264
  useUploadMediaFromBlobURL( {
274
- url,
265
+ url: temporaryURL,
275
266
  allowedTypes: ALLOWED_MEDIA_TYPES,
276
267
  onChange: onSelectImage,
277
268
  onError: onUploadError,
@@ -292,7 +283,7 @@ export function ImageEdit( {
292
283
  const shadowProps = getShadowClassesAndStyles( attributes );
293
284
 
294
285
  const classes = clsx( className, {
295
- 'is-transient': temporaryURL,
286
+ 'is-transient': !! temporaryURL,
296
287
  'is-resized': !! width || !! height,
297
288
  [ `size-${ sizeSlug }` ]: sizeSlug,
298
289
  'has-custom-border':
@@ -49,7 +49,7 @@ import { Caption } from '../utils/caption';
49
49
  /**
50
50
  * Module constants
51
51
  */
52
- import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../utils/constants';
52
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
53
53
  import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
54
54
  import { evalAspectRatio } from './utils';
55
55
 
@@ -182,8 +182,7 @@ export default function Image( {
182
182
  allowResize &&
183
183
  hasNonContentControls &&
184
184
  ! isWideAligned &&
185
- isLargeViewport &&
186
- parentLayoutType !== 'grid';
185
+ isLargeViewport;
187
186
  const imageSizeOptions = imageSizes
188
187
  .filter(
189
188
  ( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url
@@ -373,6 +372,8 @@ export default function Image( {
373
372
  const lightboxChecked =
374
373
  !! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );
375
374
 
375
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
376
+
376
377
  const dimensionsControl = (
377
378
  <DimensionsTool
378
379
  value={ { width, height, scale, aspectRatio } }
@@ -403,6 +404,20 @@ export default function Image( {
403
404
  />
404
405
  );
405
406
 
407
+ const aspectRatioControl = (
408
+ <DimensionsTool
409
+ value={ { aspectRatio } }
410
+ onChange={ ( { aspectRatio: newAspectRatio } ) => {
411
+ setAttributes( {
412
+ aspectRatio: newAspectRatio,
413
+ scale: 'cover',
414
+ } );
415
+ } }
416
+ defaultAspectRatio="auto"
417
+ tools={ [ 'aspectRatio' ] }
418
+ />
419
+ );
420
+
406
421
  const resetAll = () => {
407
422
  setAttributes( {
408
423
  alt: undefined,
@@ -419,9 +434,12 @@ export default function Image( {
419
434
  <ToolsPanel
420
435
  label={ __( 'Settings' ) }
421
436
  resetAll={ resetAll }
422
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
437
+ dropdownMenuProps={ dropdownMenuProps }
423
438
  >
424
- { isResizable && dimensionsControl }
439
+ { isResizable &&
440
+ ( parentLayoutType === 'grid'
441
+ ? aspectRatioControl
442
+ : dimensionsControl ) }
425
443
  </ToolsPanel>
426
444
  </InspectorControls>
427
445
  );
@@ -443,16 +461,12 @@ export default function Image( {
443
461
  return {};
444
462
  }
445
463
  const { getBlockBindingsSource } = unlock( select( blocksStore ) );
446
- const { getBlockParentsByBlockName } = unlock(
447
- select( blockEditorStore )
448
- );
449
464
  const {
450
465
  url: urlBinding,
451
466
  alt: altBinding,
452
467
  title: titleBinding,
453
468
  } = metadata?.bindings || {};
454
- const hasParentPattern =
455
- getBlockParentsByBlockName( clientId, 'core/block' ).length > 0;
469
+ const hasParentPattern = !! context[ 'pattern/overrides' ];
456
470
  const urlBindingSource = getBlockBindingsSource(
457
471
  urlBinding?.source
458
472
  );
@@ -508,7 +522,12 @@ export default function Image( {
508
522
  : __( 'Connected to dynamic data' ),
509
523
  };
510
524
  },
511
- [ clientId, isSingleSelected, metadata?.bindings ]
525
+ [
526
+ arePatternOverridesEnabled,
527
+ context,
528
+ isSingleSelected,
529
+ metadata?.bindings,
530
+ ]
512
531
  );
513
532
 
514
533
  const showUrlInput =
@@ -691,7 +710,7 @@ export default function Image( {
691
710
  <ToolsPanel
692
711
  label={ __( 'Settings' ) }
693
712
  resetAll={ resetAll }
694
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
713
+ dropdownMenuProps={ dropdownMenuProps }
695
714
  >
696
715
  { isSingleSelected && (
697
716
  <ToolsPanelItem
@@ -735,7 +754,10 @@ export default function Image( {
735
754
  />
736
755
  </ToolsPanelItem>
737
756
  ) }
738
- { isResizable && dimensionsControl }
757
+ { isResizable &&
758
+ ( parentLayoutType === 'grid'
759
+ ? aspectRatioControl
760
+ : dimensionsControl ) }
739
761
  { !! imageSizeOptions.length && (
740
762
  <ResolutionTool
741
763
  value={ sizeSlug }
@@ -845,7 +867,7 @@ export default function Image( {
845
867
  />
846
868
  </ImageWrapper>
847
869
  );
848
- } else if ( ! isResizable ) {
870
+ } else if ( ! isResizable || parentLayoutType === 'grid' ) {
849
871
  img = (
850
872
  <div style={ { width, height, aspectRatio } }>
851
873
  <ImageWrapper href={ href }>{ img }</ImageWrapper>
@@ -28,12 +28,33 @@ function render_block_core_image( $attributes, $content, $block ) {
28
28
  return '';
29
29
  }
30
30
 
31
+ $has_id_binding = isset( $attributes['metadata']['bindings']['id'] ) && isset( $attributes['id'] );
32
+
33
+ // Ensure the `wp-image-id` classname on the image block supports block bindings.
34
+ if ( $has_id_binding ) {
35
+ // If there's a mismatch with the 'wp-image-' class and the actual id, the id was
36
+ // probably overridden by block bindings. Update it to the correct value.
37
+ // See https://github.com/WordPress/gutenberg/issues/62886 for why this is needed.
38
+ $id = $attributes['id'];
39
+ $image_classnames = $p->get_attribute( 'class' );
40
+ $class_with_binding_value = "wp-image-$id";
41
+ if ( is_string( $image_classnames ) && ! str_contains( $image_classnames, $class_with_binding_value ) ) {
42
+ $image_classnames = preg_replace( '/wp-image-(\d+)/', $class_with_binding_value, $image_classnames );
43
+ $p->set_attribute( 'class', $image_classnames );
44
+ }
45
+ }
46
+
47
+ // For backwards compatibility, the data-id html attribute is only set for
48
+ // image blocks nested in a gallery. Detect if the image is in a gallery by
49
+ // checking the data-id attribute.
50
+ // See the `block_core_gallery_data_id_backcompatibility` function.
31
51
  if ( isset( $attributes['data-id'] ) ) {
32
- // Adds the data-id="$id" attribute to the img element to provide backwards
33
- // compatibility for the Gallery Block, which now wraps Image Blocks within
34
- // innerBlocks. The data-id attribute is added in a core/gallery
35
- // `render_block_data` hook.
36
- $p->set_attribute( 'data-id', $attributes['data-id'] );
52
+ // If there's a binding for the `id`, the `id` attribute is used for the
53
+ // value, since `data-id` does not support block bindings.
54
+ // Else the `data-id` is used for backwards compatibility, since
55
+ // third parties may be filtering its value.
56
+ $data_id = $has_id_binding ? $attributes['id'] : $attributes['data-id'];
57
+ $p->set_attribute( 'data-id', $data_id );
37
58
  }
38
59
 
39
60
  $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
@@ -159,7 +159,7 @@ const transforms = {
159
159
  transform( files ) {
160
160
  const blocks = files.map( ( file ) => {
161
161
  return createBlock( 'core/image', {
162
- url: createBlobURL( file ),
162
+ blob: createBlobURL( file ),
163
163
  } );
164
164
  } );
165
165
  return blocks;
@@ -21,8 +21,15 @@
21
21
  },
22
22
  "supports": {
23
23
  "className": false,
24
- "__experimentalSelector": ".wp-block-list > li",
25
24
  "splitting": true,
25
+ "color": {
26
+ "gradients": true,
27
+ "link": true,
28
+ "__experimentalDefaultControls": {
29
+ "background": true,
30
+ "text": true
31
+ }
32
+ },
26
33
  "spacing": {
27
34
  "margin": true,
28
35
  "padding": true,
@@ -47,5 +54,8 @@
47
54
  "interactivity": {
48
55
  "clientNavigation": true
49
56
  }
57
+ },
58
+ "selectors": {
59
+ "root": ".wp-block-list > li"
50
60
  }
51
61
  }
@@ -61,7 +61,7 @@ export function IndentUI( { clientId } ) {
61
61
  icon={ isRTL() ? formatIndentRTL : formatIndent }
62
62
  title={ __( 'Indent' ) }
63
63
  describedBy={ __( 'Indent list item' ) }
64
- isDisabled={ ! canIndent }
64
+ disabled={ ! canIndent }
65
65
  onClick={ () => indentListItem() }
66
66
  />
67
67
  </>
@@ -92,11 +92,25 @@ export default function useMerge( clientId, onMerge ) {
92
92
  // list.
93
93
  const [ nestedListClientId ] = getBlockOrder( clientIdB );
94
94
  if ( nestedListClientId ) {
95
- moveBlocksToPosition(
96
- getBlockOrder( nestedListClientId ),
97
- nestedListClientId,
98
- getBlockRootClientId( clientIdA )
99
- );
95
+ // If we are merging with the previous list item, and the
96
+ // previous list item does not have nested list, move the
97
+ // nested list to the previous list item.
98
+ if (
99
+ getPreviousBlockClientId( clientIdB ) === clientIdA &&
100
+ ! getBlockOrder( clientIdA ).length
101
+ ) {
102
+ moveBlocksToPosition(
103
+ [ nestedListClientId ],
104
+ clientIdB,
105
+ clientIdA
106
+ );
107
+ } else {
108
+ moveBlocksToPosition(
109
+ getBlockOrder( nestedListClientId ),
110
+ nestedListClientId,
111
+ getBlockRootClientId( clientIdA )
112
+ );
113
+ }
100
114
  }
101
115
  mergeBlocks( clientIdA, clientIdB );
102
116
  } );
@@ -17,6 +17,9 @@
17
17
  "default": true
18
18
  }
19
19
  },
20
+ "example": {
21
+ "viewportWidth": 350
22
+ },
20
23
  "supports": {
21
24
  "className": true,
22
25
  "spacing": {
@@ -46,7 +46,7 @@ import {
46
46
  TEMPLATE,
47
47
  } from './constants';
48
48
  import { unlock } from '../lock-unlock';
49
- import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../utils/constants';
49
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
50
50
 
51
51
  const { ResolutionTool } = unlock( blockEditorPrivateApis );
52
52
 
@@ -276,6 +276,7 @@ function MediaTextEdit( {
276
276
  mediaSizeSlug: newMediaSizeSlug,
277
277
  } );
278
278
  };
279
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
279
280
 
280
281
  const mediaTextGeneralSettings = (
281
282
  <ToolsPanel
@@ -290,7 +291,7 @@ function MediaTextEdit( {
290
291
  mediaSizeSlug: undefined,
291
292
  } );
292
293
  } }
293
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
294
+ dropdownMenuProps={ dropdownMenuProps }
294
295
  >
295
296
  <ToolsPanelItem
296
297
  label={ __( 'Media width' ) }
@@ -387,7 +387,7 @@ export default function NavigationSubmenuEdit( {
387
387
  title={ __( 'Convert to Link' ) }
388
388
  onClick={ transformToLink }
389
389
  className="wp-block-navigation__submenu__revert"
390
- isDisabled={ ! canConvertToLink }
390
+ disabled={ ! canConvertToLink }
391
391
  />
392
392
  </ToolbarGroup>
393
393
  </BlockControls>
@@ -36,7 +36,7 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
36
36
  </Button>
37
37
  <Button
38
38
  variant="primary"
39
- __experimentalIsFocusable
39
+ accessibleWhenDisabled
40
40
  disabled={ disabled }
41
41
  onClick={ onClick }
42
42
  >
@@ -338,7 +338,7 @@ export default function PageListEdit( {
338
338
  <p>{ convertDescription }</p>
339
339
  <Button
340
340
  variant="primary"
341
- __experimentalIsFocusable
341
+ accessibleWhenDisabled
342
342
  disabled={ ! hasResolvedPages }
343
343
  onClick={ convertToNavigationLinks }
344
344
  >
@@ -1,3 +1,18 @@
1
+ // Allow these default styles to be overridden by global styles.
2
+ :where(.wp-block-post-comments-form) {
3
+ textarea,
4
+ input:not([type="submit"]) {
5
+ border: 1px solid $gray-600;
6
+ font-size: 1em;
7
+ font-family: inherit;
8
+ }
9
+
10
+ textarea,
11
+ input:where(:not([type="submit"]):not([type="checkbox"])) {
12
+ padding: calc(0.667em + 2px); // The extra 2px is added to match outline buttons.
13
+ }
14
+ }
15
+
1
16
  .wp-block-post-comments-form {
2
17
  // This block has customizable padding, border-box makes that more predictable.
3
18
  box-sizing: border-box;
@@ -31,18 +46,6 @@
31
46
  overflow-wrap: break-word;
32
47
  }
33
48
 
34
- textarea,
35
- input:not([type="submit"]) {
36
- border: 1px solid $gray-600;
37
- font-size: 1em;
38
- font-family: inherit;
39
- }
40
-
41
- textarea,
42
- input:not([type="submit"]):not([type="checkbox"]) {
43
- padding: calc(0.667em + 2px); // The extra 2px is added to match outline buttons.
44
- }
45
-
46
49
  .comment-form {
47
50
  textarea,
48
51
  // Make sure to not set display block on hidden input fields, to prevent
@@ -7,6 +7,9 @@
7
7
  "description": "Displays the contents of a post or page.",
8
8
  "textdomain": "default",
9
9
  "usesContext": [ "postId", "postType", "queryId" ],
10
+ "example": {
11
+ "viewportWidth": 350
12
+ },
10
13
  "supports": {
11
14
  "align": [ "wide", "full" ],
12
15
  "html": false,
@@ -28,7 +28,7 @@ import {
28
28
  ToggleControl,
29
29
  PanelBody,
30
30
  } from '@wordpress/components';
31
- import { __, sprintf } from '@wordpress/i18n';
31
+ import { __, _x, sprintf } from '@wordpress/i18n';
32
32
  import { edit } from '@wordpress/icons';
33
33
  import { DOWN } from '@wordpress/keycodes';
34
34
  import { useSelect } from '@wordpress/data';
@@ -128,6 +128,10 @@ export default function PostDateEdit( {
128
128
  siteTimeFormat
129
129
  ) }
130
130
  onClose={ onClose }
131
+ dateOrder={
132
+ /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
133
+ _x( 'dmy', 'date order' )
134
+ }
131
135
  />
132
136
  ) }
133
137
  renderToggle={ ( { isOpen, onToggle } ) => {
@@ -23,8 +23,14 @@ function render_block_core_post_date( $attributes, $content, $block ) {
23
23
  $post_ID = $block->context['postId'];
24
24
 
25
25
  if ( isset( $attributes['format'] ) && 'human-diff' === $attributes['format'] ) {
26
- // translators: %s: human-readable time difference.
27
- $formatted_date = sprintf( __( '%s ago', 'gutenberg' ), human_time_diff( get_post_timestamp( $post_ID ) ) );
26
+ $post_timestamp = get_post_timestamp( $post_ID );
27
+ if ( $post_timestamp > time() ) {
28
+ // translators: %s: human-readable time difference.
29
+ $formatted_date = sprintf( __( '%s from now', 'gutenberg' ), human_time_diff( $post_timestamp ) );
30
+ } else {
31
+ // translators: %s: human-readable time difference.
32
+ $formatted_date = sprintf( __( '%s ago', 'gutenberg' ), human_time_diff( $post_timestamp ) );
33
+ }
28
34
  } else {
29
35
  $formatted_date = get_the_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );
30
36
  }
@@ -23,6 +23,9 @@
23
23
  }
24
24
  },
25
25
  "usesContext": [ "postId", "postType", "queryId" ],
26
+ "example": {
27
+ "viewportWidth": 350
28
+ },
26
29
  "supports": {
27
30
  "html": false,
28
31
  "color": {
@@ -29,6 +29,9 @@
29
29
  "default": "_self"
30
30
  }
31
31
  },
32
+ "example": {
33
+ "viewportWidth": 350
34
+ },
32
35
  "supports": {
33
36
  "align": [ "wide", "full" ],
34
37
  "html": false,
@@ -34,7 +34,7 @@ import {
34
34
  isControlAllowed,
35
35
  useTaxonomies,
36
36
  } from '../../utils';
37
- import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../../../utils/constants';
37
+ import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
38
38
 
39
39
  const { BlockInfo } = unlock( blockEditorPrivateApis );
40
40
 
@@ -128,6 +128,7 @@ export default function QueryInspectorControls( props ) {
128
128
  showAuthorControl ||
129
129
  showSearchControl ||
130
130
  showParentControl;
131
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
131
132
 
132
133
  return (
133
134
  <>
@@ -223,7 +224,7 @@ export default function QueryInspectorControls( props ) {
223
224
  } );
224
225
  setQuerySearch( '' );
225
226
  } }
226
- dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
227
+ dropdownMenuProps={ dropdownMenuProps }
227
228
  >
228
229
  { showTaxControl && (
229
230
  <ToolsPanelItem