@wordpress/block-library 8.25.0 → 8.25.1-next.79a6196f.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 (250) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/audio/edit.js +10 -12
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/block/edit.js +81 -34
  5. package/build/block/edit.js.map +1 -1
  6. package/build/comments-title/deprecated.js +1 -1
  7. package/build/comments-title/index.js +1 -1
  8. package/build/cover/edit/inspector-controls.js +1 -1
  9. package/build/cover/edit/inspector-controls.js.map +1 -1
  10. package/build/cover/edit.native.js +1 -0
  11. package/build/cover/edit.native.js.map +1 -1
  12. package/build/embed/util.js +4 -4
  13. package/build/embed/util.js.map +1 -1
  14. package/build/file/edit.js +19 -27
  15. package/build/file/edit.js.map +1 -1
  16. package/build/gallery/edit.js +36 -17
  17. package/build/gallery/edit.js.map +1 -1
  18. package/build/gallery/gallery.js +3 -2
  19. package/build/gallery/gallery.js.map +1 -1
  20. package/build/gallery/index.js +4 -0
  21. package/build/gallery/index.js.map +1 -1
  22. package/build/gallery/transforms.js +4 -68
  23. package/build/gallery/transforms.js.map +1 -1
  24. package/build/group/index.js +5 -1
  25. package/build/group/index.js.map +1 -1
  26. package/build/image/deprecated.js +11 -0
  27. package/build/image/deprecated.js.map +1 -1
  28. package/build/image/edit.native.js +3 -0
  29. package/build/image/edit.native.js.map +1 -1
  30. package/build/image/image.js +22 -21
  31. package/build/image/image.js.map +1 -1
  32. package/build/image/view.js +7 -1
  33. package/build/image/view.js.map +1 -1
  34. package/build/list/edit.js +10 -15
  35. package/build/list/edit.js.map +1 -1
  36. package/build/list-item/edit.js +17 -2
  37. package/build/list-item/edit.js.map +1 -1
  38. package/build/list-item/hooks/use-enter.js +5 -3
  39. package/build/list-item/hooks/use-enter.js.map +1 -1
  40. package/build/list-item/hooks/use-enter.native.js +4 -3
  41. package/build/list-item/hooks/use-enter.native.js.map +1 -1
  42. package/build/list-item/hooks/use-indent-list-item.js +2 -3
  43. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  44. package/build/list-item/hooks/use-merge.js +1 -1
  45. package/build/list-item/hooks/use-merge.js.map +1 -1
  46. package/build/list-item/hooks/use-outdent-list-item.js +3 -17
  47. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  48. package/build/list-item/hooks/use-space.js +8 -4
  49. package/build/list-item/hooks/use-space.js.map +1 -1
  50. package/build/media-text/media-container.native.js +3 -0
  51. package/build/media-text/media-container.native.js.map +1 -1
  52. package/build/navigation/constants.js +3 -1
  53. package/build/navigation/constants.js.map +1 -1
  54. package/build/navigation/edit/index.js +4 -0
  55. package/build/navigation/edit/index.js.map +1 -1
  56. package/build/navigation/view.js +25 -1
  57. package/build/navigation/view.js.map +1 -1
  58. package/build/paragraph/index.js +0 -1
  59. package/build/paragraph/index.js.map +1 -1
  60. package/build/paragraph/transforms.js +0 -1
  61. package/build/paragraph/transforms.js.map +1 -1
  62. package/build/pattern/edit.js +24 -2
  63. package/build/pattern/edit.js.map +1 -1
  64. package/build/pattern/recursion-detector.js +147 -0
  65. package/build/pattern/recursion-detector.js.map +1 -0
  66. package/build/post-featured-image/edit.js +19 -2
  67. package/build/post-featured-image/edit.js.map +1 -1
  68. package/build/post-featured-image/index.js +4 -0
  69. package/build/post-featured-image/index.js.map +1 -1
  70. package/build/query/edit/inspector-controls/index.js +3 -1
  71. package/build/query/edit/inspector-controls/index.js.map +1 -1
  72. package/build/query-pagination-numbers/index.js +1 -1
  73. package/build/search/edit.js +3 -5
  74. package/build/search/edit.js.map +1 -1
  75. package/build/search/index.js +0 -4
  76. package/build/search/index.js.map +1 -1
  77. package/build/site-logo/edit.js +7 -6
  78. package/build/site-logo/edit.js.map +1 -1
  79. package/build/spacer/edit.native.js +2 -2
  80. package/build/spacer/edit.native.js.map +1 -1
  81. package/build/tag-cloud/edit.js +5 -9
  82. package/build/tag-cloud/edit.js.map +1 -1
  83. package/build/utils/constants.js +16 -0
  84. package/build/utils/constants.js.map +1 -0
  85. package/build/video/edit.js +11 -8
  86. package/build/video/edit.js.map +1 -1
  87. package/build-module/audio/edit.js +10 -12
  88. package/build-module/audio/edit.js.map +1 -1
  89. package/build-module/block/edit.js +85 -38
  90. package/build-module/block/edit.js.map +1 -1
  91. package/build-module/comments-title/deprecated.js +1 -1
  92. package/build-module/comments-title/index.js +1 -1
  93. package/build-module/cover/edit/inspector-controls.js +1 -1
  94. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  95. package/build-module/cover/edit.native.js +1 -0
  96. package/build-module/cover/edit.native.js.map +1 -1
  97. package/build-module/embed/util.js +4 -4
  98. package/build-module/embed/util.js.map +1 -1
  99. package/build-module/file/edit.js +19 -27
  100. package/build-module/file/edit.js.map +1 -1
  101. package/build-module/gallery/edit.js +36 -17
  102. package/build-module/gallery/edit.js.map +1 -1
  103. package/build-module/gallery/gallery.js +3 -2
  104. package/build-module/gallery/gallery.js.map +1 -1
  105. package/build-module/gallery/index.js +4 -0
  106. package/build-module/gallery/index.js.map +1 -1
  107. package/build-module/gallery/transforms.js +4 -68
  108. package/build-module/gallery/transforms.js.map +1 -1
  109. package/build-module/group/index.js +5 -1
  110. package/build-module/group/index.js.map +1 -1
  111. package/build-module/image/deprecated.js +11 -0
  112. package/build-module/image/deprecated.js.map +1 -1
  113. package/build-module/image/edit.native.js +3 -0
  114. package/build-module/image/edit.native.js.map +1 -1
  115. package/build-module/image/image.js +17 -16
  116. package/build-module/image/image.js.map +1 -1
  117. package/build-module/image/view.js +7 -1
  118. package/build-module/image/view.js.map +1 -1
  119. package/build-module/list/edit.js +10 -15
  120. package/build-module/list/edit.js.map +1 -1
  121. package/build-module/list-item/edit.js +18 -3
  122. package/build-module/list-item/edit.js.map +1 -1
  123. package/build-module/list-item/hooks/use-enter.js +5 -3
  124. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  125. package/build-module/list-item/hooks/use-enter.native.js +4 -3
  126. package/build-module/list-item/hooks/use-enter.native.js.map +1 -1
  127. package/build-module/list-item/hooks/use-indent-list-item.js +2 -3
  128. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  129. package/build-module/list-item/hooks/use-merge.js +1 -1
  130. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  131. package/build-module/list-item/hooks/use-outdent-list-item.js +3 -17
  132. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  133. package/build-module/list-item/hooks/use-space.js +8 -4
  134. package/build-module/list-item/hooks/use-space.js.map +1 -1
  135. package/build-module/media-text/media-container.native.js +3 -0
  136. package/build-module/media-text/media-container.native.js.map +1 -1
  137. package/build-module/navigation/constants.js +1 -0
  138. package/build-module/navigation/constants.js.map +1 -1
  139. package/build-module/navigation/edit/index.js +5 -1
  140. package/build-module/navigation/edit/index.js.map +1 -1
  141. package/build-module/navigation/view.js +25 -1
  142. package/build-module/navigation/view.js.map +1 -1
  143. package/build-module/paragraph/index.js +0 -1
  144. package/build-module/paragraph/index.js.map +1 -1
  145. package/build-module/paragraph/transforms.js +0 -1
  146. package/build-module/paragraph/transforms.js.map +1 -1
  147. package/build-module/pattern/edit.js +26 -4
  148. package/build-module/pattern/edit.js.map +1 -1
  149. package/build-module/pattern/recursion-detector.js +139 -0
  150. package/build-module/pattern/recursion-detector.js.map +1 -0
  151. package/build-module/post-featured-image/edit.js +19 -2
  152. package/build-module/post-featured-image/edit.js.map +1 -1
  153. package/build-module/post-featured-image/index.js +4 -0
  154. package/build-module/post-featured-image/index.js.map +1 -1
  155. package/build-module/query/edit/inspector-controls/index.js +3 -1
  156. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  157. package/build-module/query-pagination-numbers/index.js +1 -1
  158. package/build-module/search/edit.js +3 -5
  159. package/build-module/search/edit.js.map +1 -1
  160. package/build-module/search/index.js +0 -4
  161. package/build-module/search/index.js.map +1 -1
  162. package/build-module/site-logo/edit.js +7 -6
  163. package/build-module/site-logo/edit.js.map +1 -1
  164. package/build-module/spacer/edit.native.js +2 -2
  165. package/build-module/spacer/edit.native.js.map +1 -1
  166. package/build-module/tag-cloud/edit.js +6 -10
  167. package/build-module/tag-cloud/edit.js.map +1 -1
  168. package/build-module/utils/constants.js +9 -0
  169. package/build-module/utils/constants.js.map +1 -0
  170. package/build-module/video/edit.js +11 -8
  171. package/build-module/video/edit.js.map +1 -1
  172. package/build-style/button/editor-rtl.css +0 -37
  173. package/build-style/button/editor.css +0 -37
  174. package/build-style/button/style-rtl.css +6 -6
  175. package/build-style/button/style.css +6 -6
  176. package/build-style/editor-rtl.css +2 -44
  177. package/build-style/editor.css +2 -44
  178. package/build-style/navigation/editor-rtl.css +2 -4
  179. package/build-style/navigation/editor.css +2 -4
  180. package/build-style/navigation/style-rtl.css +14 -18
  181. package/build-style/navigation/style.css +14 -18
  182. package/build-style/search/style-rtl.css +26 -27
  183. package/build-style/search/style.css +26 -27
  184. package/build-style/style-rtl.css +46 -51
  185. package/build-style/style.css +46 -51
  186. package/build-style/table/editor-rtl.css +0 -3
  187. package/build-style/table/editor.css +0 -3
  188. package/package.json +32 -32
  189. package/src/audio/edit.js +19 -19
  190. package/src/audio/test/__snapshots__/edit.native.js.snap +12 -0
  191. package/src/audio/test/edit.native.js +29 -0
  192. package/src/block/edit.js +120 -66
  193. package/src/button/editor.scss +0 -43
  194. package/src/button/style.scss +6 -6
  195. package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
  196. package/src/buttons/test/edit.native.js +49 -0
  197. package/src/comments-title/block.json +1 -1
  198. package/src/cover/edit/inspector-controls.js +1 -1
  199. package/src/cover/edit.native.js +1 -0
  200. package/src/embed/util.js +2 -2
  201. package/src/file/edit.js +17 -24
  202. package/src/gallery/block.json +4 -0
  203. package/src/gallery/edit.js +69 -42
  204. package/src/gallery/gallery.js +4 -1
  205. package/src/gallery/index.php +15 -0
  206. package/src/gallery/transforms.js +2 -55
  207. package/src/group/block.json +5 -1
  208. package/src/image/deprecated.js +8 -0
  209. package/src/image/edit.native.js +3 -0
  210. package/src/image/image.js +54 -35
  211. package/src/image/index.php +1 -6
  212. package/src/image/view.js +5 -2
  213. package/src/list/edit.js +27 -35
  214. package/src/list-item/edit.js +18 -2
  215. package/src/list-item/hooks/use-enter.js +63 -62
  216. package/src/list-item/hooks/use-enter.native.js +9 -5
  217. package/src/list-item/hooks/use-indent-list-item.js +43 -53
  218. package/src/list-item/hooks/use-merge.js +1 -1
  219. package/src/list-item/hooks/use-outdent-list-item.js +50 -69
  220. package/src/list-item/hooks/use-space.js +7 -4
  221. package/src/media-text/media-container.native.js +3 -1
  222. package/src/navigation/constants.js +2 -0
  223. package/src/navigation/edit/index.js +11 -1
  224. package/src/navigation/editor.scss +1 -1
  225. package/src/navigation/style.scss +18 -16
  226. package/src/navigation/view.js +29 -3
  227. package/src/paragraph/block.json +0 -1
  228. package/src/paragraph/test/__snapshots__/edit.native.js.snap +12 -0
  229. package/src/paragraph/test/edit.native.js +114 -0
  230. package/src/pattern/edit.js +35 -3
  231. package/src/pattern/index.php +16 -0
  232. package/src/pattern/recursion-detector.js +145 -0
  233. package/src/pattern/test/index.js +74 -0
  234. package/src/post-featured-image/block.json +4 -0
  235. package/src/post-featured-image/edit.js +32 -1
  236. package/src/post-featured-image/index.php +31 -0
  237. package/src/query/edit/inspector-controls/index.js +2 -0
  238. package/src/query-pagination-numbers/block.json +1 -1
  239. package/src/search/block.json +0 -4
  240. package/src/search/edit.js +2 -8
  241. package/src/search/index.php +3 -7
  242. package/src/search/style.scss +27 -29
  243. package/src/site-logo/edit.js +3 -4
  244. package/src/social-link/index.php +1 -1
  245. package/src/spacer/edit.native.js +4 -2
  246. package/src/table/editor.scss +0 -3
  247. package/src/tag-cloud/edit.js +7 -7
  248. package/src/template-part/index.php +6 -0
  249. package/src/utils/constants.js +8 -0
  250. package/src/video/edit.js +29 -27
@@ -74,6 +74,8 @@ const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
74
74
  ? { type: 'stepper' }
75
75
  : {};
76
76
 
77
+ const EMPTY_ARRAY = [];
78
+
77
79
  function GalleryEdit( props ) {
78
80
  const {
79
81
  setAttributes,
@@ -86,7 +88,8 @@ function GalleryEdit( props ) {
86
88
  onFocus,
87
89
  } = props;
88
90
 
89
- const { columns, imageCrop, linkTarget, linkTo, sizeSlug } = attributes;
91
+ const { columns, imageCrop, randomOrder, linkTarget, linkTo, sizeSlug } =
92
+ attributes;
90
93
 
91
94
  const {
92
95
  __unstableMarkNextChangeAsNotPersistent,
@@ -97,33 +100,44 @@ function GalleryEdit( props ) {
97
100
  const { createSuccessNotice, createErrorNotice } =
98
101
  useDispatch( noticesStore );
99
102
 
100
- const { getBlock, getSettings, preferredStyle } = useSelect( ( select ) => {
101
- const settings = select( blockEditorStore ).getSettings();
102
- const preferredStyleVariations =
103
- settings.__experimentalPreferredStyleVariations;
104
- return {
105
- getBlock: select( blockEditorStore ).getBlock,
106
- getSettings: select( blockEditorStore ).getSettings,
107
- preferredStyle: preferredStyleVariations?.value?.[ 'core/image' ],
108
- };
109
- }, [] );
110
-
111
- const innerBlockImages = useSelect(
112
- ( select ) => {
113
- const innerBlocks =
114
- select( blockEditorStore ).getBlock( clientId )?.innerBlocks ??
115
- [];
116
- return innerBlocks;
117
- },
118
- [ clientId ]
119
- );
120
-
121
- const wasBlockJustInserted = useSelect(
103
+ const {
104
+ getBlock,
105
+ getSettings,
106
+ preferredStyle,
107
+ innerBlockImages,
108
+ blockWasJustInserted,
109
+ multiGallerySelection,
110
+ } = useSelect(
122
111
  ( select ) => {
123
- return select( blockEditorStore ).wasBlockJustInserted(
124
- clientId,
125
- 'inserter_menu'
126
- );
112
+ const {
113
+ getBlockName,
114
+ getMultiSelectedBlockClientIds,
115
+ getSettings: _getSettings,
116
+ getBlock: _getBlock,
117
+ wasBlockJustInserted,
118
+ } = select( blockEditorStore );
119
+ const preferredStyleVariations =
120
+ _getSettings().__experimentalPreferredStyleVariations;
121
+ const multiSelectedClientIds = getMultiSelectedBlockClientIds();
122
+
123
+ return {
124
+ getBlock: _getBlock,
125
+ getSettings: _getSettings,
126
+ preferredStyle:
127
+ preferredStyleVariations?.value?.[ 'core/image' ],
128
+ innerBlockImages:
129
+ _getBlock( clientId )?.innerBlocks ?? EMPTY_ARRAY,
130
+ blockWasJustInserted: wasBlockJustInserted(
131
+ clientId,
132
+ 'inserter_menu'
133
+ ),
134
+ multiGallerySelection:
135
+ multiSelectedClientIds.length &&
136
+ multiSelectedClientIds.every(
137
+ ( _clientId ) =>
138
+ getBlockName( _clientId ) === 'core/gallery'
139
+ ),
140
+ };
127
141
  },
128
142
  [ clientId ]
129
143
  );
@@ -375,6 +389,10 @@ function GalleryEdit( props ) {
375
389
  : __( 'Thumbnails are not cropped.' );
376
390
  }
377
391
 
392
+ function toggleRandomOrder() {
393
+ setAttributes( { randomOrder: ! randomOrder } );
394
+ }
395
+
378
396
  function toggleOpenInNewTab( openInNewTab ) {
379
397
  const newLinkTarget = openInNewTab ? '_blank' : undefined;
380
398
  setAttributes( { linkTarget: newLinkTarget } );
@@ -463,7 +481,7 @@ function GalleryEdit( props ) {
463
481
  ( hasImages && ! isSelected ) || imagesUploading,
464
482
  value: hasImageIds ? images : {},
465
483
  autoOpenMediaUpload:
466
- ! hasImages && isSelected && wasBlockJustInserted,
484
+ ! hasImages && isSelected && blockWasJustInserted,
467
485
  onFocus,
468
486
  },
469
487
  } );
@@ -539,6 +557,12 @@ function GalleryEdit( props ) {
539
557
  onChange={ toggleImageCrop }
540
558
  help={ getImageCropHelp }
541
559
  />
560
+ <ToggleControl
561
+ __nextHasNoMarginBottom
562
+ label={ __( 'Random order' ) }
563
+ checked={ !! randomOrder }
564
+ onChange={ toggleRandomOrder }
565
+ />
542
566
  <SelectControl
543
567
  __nextHasNoMarginBottom
544
568
  label={ __( 'Link to' ) }
@@ -585,20 +609,22 @@ function GalleryEdit( props ) {
585
609
  </InspectorControls>
586
610
  { Platform.isWeb && (
587
611
  <>
588
- <BlockControls group="other">
589
- <MediaReplaceFlow
590
- allowedTypes={ ALLOWED_MEDIA_TYPES }
591
- accept="image/*"
592
- handleUpload={ false }
593
- onSelect={ updateImages }
594
- name={ __( 'Add' ) }
595
- multiple={ true }
596
- mediaIds={ images
597
- .filter( ( image ) => image.id )
598
- .map( ( image ) => image.id ) }
599
- addToGallery={ hasImageIds }
600
- />
601
- </BlockControls>
612
+ { ! multiGallerySelection && (
613
+ <BlockControls group="other">
614
+ <MediaReplaceFlow
615
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
616
+ accept="image/*"
617
+ handleUpload={ false }
618
+ onSelect={ updateImages }
619
+ name={ __( 'Add' ) }
620
+ multiple={ true }
621
+ mediaIds={ images
622
+ .filter( ( image ) => image.id )
623
+ .map( ( image ) => image.id ) }
624
+ addToGallery={ hasImageIds }
625
+ />
626
+ </BlockControls>
627
+ ) }
602
628
  <GapStyles
603
629
  blockGap={ attributes.style?.spacing?.blockGap }
604
630
  clientId={ clientId }
@@ -616,6 +642,7 @@ function GalleryEdit( props ) {
616
642
  }
617
643
  blockProps={ innerBlocksProps }
618
644
  insertBlocksAfter={ insertBlocksAfter }
645
+ multiGallerySelection={ multiGallerySelection }
619
646
  />
620
647
  </>
621
648
  );
@@ -24,6 +24,7 @@ export default function Gallery( props ) {
24
24
  blockProps,
25
25
  __unstableLayoutClassNames: layoutClassNames,
26
26
  isContentLocked,
27
+ multiGallerySelection,
27
28
  } = props;
28
29
 
29
30
  const { align, columns, imageCrop } = attributes;
@@ -54,7 +55,9 @@ export default function Gallery( props ) {
54
55
  setAttributes={ setAttributes }
55
56
  isSelected={ isSelected }
56
57
  insertBlocksAfter={ insertBlocksAfter }
57
- showToolbarButton={ ! isContentLocked }
58
+ showToolbarButton={
59
+ ! multiGallerySelection && ! isContentLocked
60
+ }
58
61
  className="blocks-gallery-caption"
59
62
  label={ __( 'Gallery caption text' ) }
60
63
  placeholder={ __( 'Add gallery caption' ) }
@@ -32,6 +32,21 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
32
32
 
33
33
  add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
34
34
 
35
+ /**
36
+ * Filter to randomize the order of image blocks.
37
+ *
38
+ * @param array $parsed_block The block being rendered.
39
+ * @return array The block object with randomized order of image blocks.
40
+ */
41
+ function block_core_gallery_random_order( $parsed_block ) {
42
+ if ( 'core/gallery' === $parsed_block['blockName'] && ! empty( $parsed_block['attrs']['randomOrder'] ) ) {
43
+ shuffle( $parsed_block['innerBlocks'] );
44
+ }
45
+ return $parsed_block;
46
+ }
47
+
48
+ add_filter( 'render_block_data', 'block_core_gallery_random_order' );
49
+
35
50
  /**
36
51
  * Adds a style tag for the --wp--style--unstable-gallery-gap var.
37
52
  *
@@ -13,10 +13,6 @@ import {
13
13
  LINK_DESTINATION_NONE,
14
14
  LINK_DESTINATION_MEDIA,
15
15
  } from './constants';
16
- import {
17
- LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
18
- LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
19
- } from './v1/constants';
20
16
  import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
21
17
 
22
18
  const parseShortcodeIds = ( ids ) => {
@@ -177,57 +173,7 @@ const transforms = {
177
173
  {
178
174
  type: 'shortcode',
179
175
  tag: 'gallery',
180
-
181
- attributes: {
182
- images: {
183
- type: 'array',
184
- shortcode: ( { named: { ids } } ) => {
185
- if ( ! isGalleryV2Enabled() ) {
186
- return parseShortcodeIds( ids ).map( ( id ) => ( {
187
- id: id.toString(),
188
- } ) );
189
- }
190
- },
191
- },
192
- ids: {
193
- type: 'array',
194
- shortcode: ( { named: { ids } } ) => {
195
- if ( ! isGalleryV2Enabled() ) {
196
- return parseShortcodeIds( ids );
197
- }
198
- },
199
- },
200
- columns: {
201
- type: 'number',
202
- shortcode: ( { named: { columns = '3' } } ) => {
203
- return parseInt( columns, 10 );
204
- },
205
- },
206
- linkTo: {
207
- type: 'string',
208
- shortcode: ( { named: { link } } ) => {
209
- if ( ! isGalleryV2Enabled() ) {
210
- switch ( link ) {
211
- case 'post':
212
- return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
213
- case 'file':
214
- return DEPRECATED_LINK_DESTINATION_MEDIA;
215
- default:
216
- return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
217
- }
218
- }
219
- switch ( link ) {
220
- case 'post':
221
- return LINK_DESTINATION_ATTACHMENT;
222
- case 'file':
223
- return LINK_DESTINATION_MEDIA;
224
- default:
225
- return LINK_DESTINATION_NONE;
226
- }
227
- },
228
- },
229
- },
230
- transform( { named: { ids, columns = 3, link } } ) {
176
+ transform( { named: { ids, columns = 3, link, orderby } } ) {
231
177
  const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
232
178
  parseInt( id, 10 )
233
179
  );
@@ -244,6 +190,7 @@ const transforms = {
244
190
  {
245
191
  columns: parseInt( columns, 10 ),
246
192
  linkTo,
193
+ randomOrder: orderby === 'rand',
247
194
  },
248
195
  imageIds.map( ( imageId ) =>
249
196
  createBlock( 'core/image', { id: imageId } )
@@ -29,7 +29,11 @@
29
29
  "ariaLabel": true,
30
30
  "html": false,
31
31
  "background": {
32
- "backgroundImage": true
32
+ "backgroundImage": true,
33
+ "backgroundSize": true,
34
+ "__experimentalDefaultControls": {
35
+ "backgroundImage": true
36
+ }
33
37
  },
34
38
  "color": {
35
39
  "gradients": true,
@@ -651,6 +651,14 @@ const v6 = {
651
651
  },
652
652
  },
653
653
  },
654
+ migrate( attributes ) {
655
+ const { height, width } = attributes;
656
+ return {
657
+ ...attributes,
658
+ width: typeof width === 'number' ? `${ width }px` : width,
659
+ height: typeof height === 'number' ? `${ height }px` : height,
660
+ };
661
+ },
654
662
  save( { attributes } ) {
655
663
  const {
656
664
  url,
@@ -812,6 +812,7 @@ export class ImageEdit extends Component {
812
812
  { ! this.state.isCaptionSelected &&
813
813
  getToolbarEditButton( openMediaOptions ) }
814
814
  <MediaUploadProgress
815
+ enablePausedUploads
815
816
  coverUrl={ url }
816
817
  mediaId={ id }
817
818
  onUpdateMediaProgress={ this.updateMediaProgress }
@@ -825,6 +826,7 @@ export class ImageEdit extends Component {
825
826
  this.mediaUploadStateReset
826
827
  }
827
828
  renderContent={ ( {
829
+ isUploadPaused,
828
830
  isUploadInProgress,
829
831
  isUploadFailed,
830
832
  retryMessage,
@@ -843,6 +845,7 @@ export class ImageEdit extends Component {
843
845
  ! isCaptionSelected
844
846
  }
845
847
  isUploadFailed={ isUploadFailed }
848
+ isUploadPaused={ isUploadPaused }
846
849
  isUploadInProgress={
847
850
  isUploadInProgress
848
851
  }
@@ -48,6 +48,7 @@ import { Caption } from '../utils/caption';
48
48
  /**
49
49
  * Module constants
50
50
  */
51
+ import { TOOLSPANEL_DROPDOWNMENU_PROPS } from '../utils/constants';
51
52
  import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
52
53
  import { evalAspectRatio } from './utils';
53
54
 
@@ -133,17 +134,49 @@ export default function Image( {
133
134
  const { allowResize = true } = context;
134
135
  const { getBlock } = useSelect( blockEditorStore );
135
136
 
136
- const { image, multiImageSelection } = useSelect(
137
+ const { image } = useSelect(
137
138
  ( select ) => {
138
139
  const { getMedia } = select( coreStore );
139
- const { getMultiSelectedBlockClientIds, getBlockName } =
140
- select( blockEditorStore );
141
- const multiSelectedClientIds = getMultiSelectedBlockClientIds();
142
140
  return {
143
141
  image:
144
142
  id && isSelected
145
143
  ? getMedia( id, { context: 'view' } )
146
144
  : null,
145
+ };
146
+ },
147
+ [ id, isSelected ]
148
+ );
149
+
150
+ const {
151
+ canInsertCover,
152
+ imageEditing,
153
+ imageSizes,
154
+ maxWidth,
155
+ mediaUpload,
156
+ multiImageSelection,
157
+ } = useSelect(
158
+ ( select ) => {
159
+ const {
160
+ getBlockRootClientId,
161
+ getMultiSelectedBlockClientIds,
162
+ getBlockName,
163
+ getSettings,
164
+ canInsertBlockType,
165
+ } = select( blockEditorStore );
166
+
167
+ const rootClientId = getBlockRootClientId( clientId );
168
+ const settings = getSettings();
169
+ const multiSelectedClientIds = getMultiSelectedBlockClientIds();
170
+
171
+ return {
172
+ imageEditing: settings.imageEditing,
173
+ imageSizes: settings.imageSizes,
174
+ maxWidth: settings.maxWidth,
175
+ mediaUpload: settings.mediaUpload,
176
+ canInsertCover: canInsertBlockType(
177
+ 'core/cover',
178
+ rootClientId
179
+ ),
147
180
  multiImageSelection:
148
181
  multiSelectedClientIds.length &&
149
182
  multiSelectedClientIds.every(
@@ -152,33 +185,8 @@ export default function Image( {
152
185
  ),
153
186
  };
154
187
  },
155
- [ id, isSelected ]
188
+ [ clientId ]
156
189
  );
157
- const { canInsertCover, imageEditing, imageSizes, maxWidth, mediaUpload } =
158
- useSelect(
159
- ( select ) => {
160
- const {
161
- getBlockRootClientId,
162
- getSettings,
163
- canInsertBlockType,
164
- } = select( blockEditorStore );
165
-
166
- const rootClientId = getBlockRootClientId( clientId );
167
- const settings = getSettings();
168
-
169
- return {
170
- imageEditing: settings.imageEditing,
171
- imageSizes: settings.imageSizes,
172
- maxWidth: settings.maxWidth,
173
- mediaUpload: settings.mediaUpload,
174
- canInsertCover: canInsertBlockType(
175
- 'core/cover',
176
- rootClientId
177
- ),
178
- };
179
- },
180
- [ clientId ]
181
- );
182
190
 
183
191
  const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
184
192
  const { createErrorNotice, createSuccessNotice } =
@@ -196,7 +204,8 @@ export default function Image( {
196
204
  const isResizable =
197
205
  allowResize &&
198
206
  hasNonContentControls &&
199
- ! ( isWideAligned && isLargeViewport );
207
+ ! isWideAligned &&
208
+ isLargeViewport;
200
209
  const imageSizeOptions = imageSizes
201
210
  .filter(
202
211
  ( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url
@@ -391,7 +400,11 @@ export default function Image( {
391
400
 
392
401
  const sizeControls = (
393
402
  <InspectorControls>
394
- <ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>
403
+ <ToolsPanel
404
+ label={ __( 'Settings' ) }
405
+ resetAll={ resetAll }
406
+ dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
407
+ >
395
408
  { isResizable && dimensionsControl }
396
409
  </ToolsPanel>
397
410
  </InspectorControls>
@@ -446,13 +459,17 @@ export default function Image( {
446
459
  <ToolbarButton
447
460
  onClick={ uploadExternal }
448
461
  icon={ upload }
449
- label={ __( 'Upload external image' ) }
462
+ label={ __( 'Upload image to media library' ) }
450
463
  />
451
464
  </ToolbarGroup>
452
465
  </BlockControls>
453
466
  ) }
454
467
  <InspectorControls>
455
- <ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>
468
+ <ToolsPanel
469
+ label={ __( 'Settings' ) }
470
+ resetAll={ resetAll }
471
+ dropdownMenuProps={ TOOLSPANEL_DROPDOWNMENU_PROPS }
472
+ >
456
473
  { ! multiImageSelection && (
457
474
  <ToolsPanelItem
458
475
  label={ __( 'Alternative text' ) }
@@ -745,7 +762,9 @@ export default function Image( {
745
762
  isSelected={ isSelected }
746
763
  insertBlocksAfter={ insertBlocksAfter }
747
764
  label={ __( 'Image caption text' ) }
748
- showToolbarButton={ hasNonContentControls }
765
+ showToolbarButton={
766
+ ! multiImageSelection && hasNonContentControls
767
+ }
749
768
  />
750
769
  </>
751
770
  );
@@ -97,12 +97,6 @@ function block_core_image_get_lightbox_settings( $block ) {
97
97
  // Get the lightbox setting from the block attributes.
98
98
  if ( isset( $block['attrs']['lightbox'] ) ) {
99
99
  $lightbox_settings = $block['attrs']['lightbox'];
100
- // If the lightbox setting is not set in the block attributes,
101
- // check the legacy lightbox settings that are set using the
102
- // `gutenberg_should_render_lightbox` filter.
103
- // We can remove this elseif statement when the legacy lightbox settings are removed.
104
- } elseif ( isset( $block['legacyLightboxSettings'] ) ) {
105
- $lightbox_settings = $block['legacyLightboxSettings'];
106
100
  }
107
101
 
108
102
  if ( ! isset( $lightbox_settings ) ) {
@@ -239,6 +233,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
239
233
  type="button"
240
234
  aria-haspopup="dialog"
241
235
  aria-label="' . esc_attr( $aria_label ) . '"
236
+ data-wp-init="callbacks.initTriggerButton"
242
237
  data-wp-on--click="actions.showLightbox"
243
238
  data-wp-style--right="context.imageButtonRight"
244
239
  data-wp-style--top="context.imageButtonTop"
package/src/image/view.js CHANGED
@@ -230,13 +230,16 @@ const { state, actions, callbacks } = store( 'core/image', {
230
230
  const ctx = getContext();
231
231
  const { ref } = getElement();
232
232
  ctx.imageRef = ref;
233
- ctx.lightboxTriggerRef =
234
- ref.parentElement.querySelector( '.lightbox-trigger' );
235
233
  if ( ref.complete ) {
236
234
  ctx.imageLoaded = true;
237
235
  ctx.imageCurrentSrc = ref.currentSrc;
238
236
  }
239
237
  },
238
+ initTriggerButton() {
239
+ const ctx = getContext();
240
+ const { ref } = getElement();
241
+ ctx.lightboxTriggerRef = ref;
242
+ },
240
243
  initLightbox() {
241
244
  const ctx = getContext();
242
245
  const { ref } = getElement();
package/src/list/edit.js CHANGED
@@ -68,48 +68,40 @@ function useMigrateOnLoad( attributes, clientId ) {
68
68
  }
69
69
 
70
70
  function useOutdentList( clientId ) {
71
- const { canOutdent } = useSelect(
72
- ( innerSelect ) => {
73
- const { getBlockRootClientId, getBlock } =
74
- innerSelect( blockEditorStore );
75
- const parentId = getBlockRootClientId( clientId );
76
- return {
77
- canOutdent:
78
- !! parentId &&
79
- getBlock( parentId ).name === 'core/list-item',
80
- };
81
- },
82
- [ clientId ]
83
- );
84
71
  const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
85
72
  const { getBlockRootClientId, getBlockAttributes, getBlock } =
86
73
  useSelect( blockEditorStore );
87
74
 
88
- return [
89
- canOutdent,
90
- useCallback( () => {
91
- const parentBlockId = getBlockRootClientId( clientId );
92
- const parentBlockAttributes = getBlockAttributes( parentBlockId );
93
- // Create a new parent block without the inner blocks.
94
- const newParentBlock = createBlock(
95
- 'core/list-item',
96
- parentBlockAttributes
97
- );
98
- const { innerBlocks } = getBlock( clientId );
99
- // Replace the parent block with a new parent block without inner blocks,
100
- // and make the inner blocks siblings of the parent.
101
- replaceBlocks(
102
- [ parentBlockId ],
103
- [ newParentBlock, ...innerBlocks ]
104
- );
105
- // Select the last child of the list being outdent.
106
- selectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );
107
- }, [ clientId ] ),
108
- ];
75
+ return useCallback( () => {
76
+ const parentBlockId = getBlockRootClientId( clientId );
77
+ const parentBlockAttributes = getBlockAttributes( parentBlockId );
78
+ // Create a new parent block without the inner blocks.
79
+ const newParentBlock = createBlock(
80
+ 'core/list-item',
81
+ parentBlockAttributes
82
+ );
83
+ const { innerBlocks } = getBlock( clientId );
84
+ // Replace the parent block with a new parent block without inner blocks,
85
+ // and make the inner blocks siblings of the parent.
86
+ replaceBlocks( [ parentBlockId ], [ newParentBlock, ...innerBlocks ] );
87
+ // Select the last child of the list being outdent.
88
+ selectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );
89
+ }, [ clientId ] );
109
90
  }
110
91
 
111
92
  function IndentUI( { clientId } ) {
112
- const [ canOutdent, outdentList ] = useOutdentList( clientId );
93
+ const outdentList = useOutdentList( clientId );
94
+ const canOutdent = useSelect(
95
+ ( select ) => {
96
+ const { getBlockRootClientId, getBlockName } =
97
+ select( blockEditorStore );
98
+ return (
99
+ getBlockName( getBlockRootClientId( clientId ) ) ===
100
+ 'core/list-item'
101
+ );
102
+ },
103
+ [ clientId ]
104
+ );
113
105
  return (
114
106
  <>
115
107
  <ToolbarButton
@@ -6,6 +6,7 @@ import {
6
6
  useBlockProps,
7
7
  useInnerBlocksProps,
8
8
  BlockControls,
9
+ store as blockEditorStore,
9
10
  } from '@wordpress/block-editor';
10
11
  import { isRTL, __ } from '@wordpress/i18n';
11
12
  import { ToolbarButton } from '@wordpress/components';
@@ -16,6 +17,7 @@ import {
16
17
  formatIndent,
17
18
  } from '@wordpress/icons';
18
19
  import { useMergeRefs } from '@wordpress/compose';
20
+ import { useSelect } from '@wordpress/data';
19
21
 
20
22
  /**
21
23
  * Internal dependencies
@@ -32,8 +34,22 @@ import {
32
34
  import { convertToListItems } from './utils';
33
35
 
34
36
  export function IndentUI( { clientId } ) {
35
- const [ canIndent, indentListItem ] = useIndentListItem( clientId );
36
- const [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );
37
+ const indentListItem = useIndentListItem( clientId );
38
+ const outdentListItem = useOutdentListItem();
39
+ const { canIndent, canOutdent } = useSelect(
40
+ ( select ) => {
41
+ const { getBlockIndex, getBlockRootClientId, getBlockName } =
42
+ select( blockEditorStore );
43
+ return {
44
+ canIndent: getBlockIndex( clientId ) > 0,
45
+ canOutdent:
46
+ getBlockName(
47
+ getBlockRootClientId( getBlockRootClientId( clientId ) )
48
+ ) === 'core/list-item',
49
+ };
50
+ },
51
+ [ clientId ]
52
+ );
37
53
 
38
54
  return (
39
55
  <>