@wordpress/block-library 6.0.9 → 6.0.13

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 (208) hide show
  1. package/build/cover/edit.js +9 -3
  2. package/build/cover/edit.js.map +1 -1
  3. package/build/gallery/deprecated.js +314 -26
  4. package/build/gallery/deprecated.js.map +1 -1
  5. package/build/gallery/edit-wrapper.js +10 -27
  6. package/build/gallery/edit-wrapper.js.map +1 -1
  7. package/build/gallery/edit.js +11 -13
  8. package/build/gallery/edit.js.map +1 -1
  9. package/build/gallery/save.js +3 -3
  10. package/build/gallery/save.js.map +1 -1
  11. package/build/gallery/shared.js +24 -0
  12. package/build/gallery/shared.js.map +1 -1
  13. package/build/gallery/transforms.js +8 -22
  14. package/build/gallery/transforms.js.map +1 -1
  15. package/build/gallery/use-mobile-warning.js +1 -1
  16. package/build/gallery/use-mobile-warning.js.map +1 -1
  17. package/build/gallery/v1/edit.js +2 -21
  18. package/build/gallery/v1/edit.js.map +1 -1
  19. package/build/index.js +3 -2
  20. package/build/index.js.map +1 -1
  21. package/build/navigation/deprecated.js +127 -19
  22. package/build/navigation/deprecated.js.map +1 -1
  23. package/build/navigation/edit/index.js +46 -31
  24. package/build/navigation/edit/index.js.map +1 -1
  25. package/build/navigation/edit/inner-blocks.js +0 -4
  26. package/build/navigation/edit/inner-blocks.js.map +1 -1
  27. package/build/navigation/edit/navigation-menu-selector.js +2 -2
  28. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  29. package/build/navigation/edit/placeholder/index.js +16 -48
  30. package/build/navigation/edit/placeholder/index.js.map +1 -1
  31. package/build/navigation/edit/unsaved-inner-blocks.js +4 -35
  32. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  33. package/build/navigation/edit/use-create-navigation-menu.js +50 -0
  34. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -0
  35. package/build/navigation/edit/use-generate-default-navigation-title.js +73 -0
  36. package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
  37. package/build/navigation/index.js +1 -1
  38. package/build/navigation/save.js +2 -2
  39. package/build/navigation/save.js.map +1 -1
  40. package/build/navigation/use-navigation-menu.js +19 -8
  41. package/build/navigation/use-navigation-menu.js.map +1 -1
  42. package/build/navigation-submenu/edit.js +4 -0
  43. package/build/navigation-submenu/edit.js.map +1 -1
  44. package/build/pattern/index.js +1 -1
  45. package/build/post-featured-image/edit.js +2 -3
  46. package/build/post-featured-image/edit.js.map +1 -1
  47. package/build/post-terms/index.js +1 -1
  48. package/build/post-title/edit.js +2 -2
  49. package/build/post-title/edit.js.map +1 -1
  50. package/build/query-pagination/index.js +1 -1
  51. package/build/query-pagination-next/index.js +2 -2
  52. package/build/query-pagination-numbers/index.js +1 -1
  53. package/build/query-pagination-previous/index.js +2 -2
  54. package/build/query-title/index.js +1 -1
  55. package/build/separator/separator-settings.js +1 -0
  56. package/build/separator/separator-settings.js.map +1 -1
  57. package/build/site-logo/index.js +1 -1
  58. package/build/site-tagline/index.js +1 -1
  59. package/build/site-title/index.js +1 -1
  60. package/build/social-links/edit.js +1 -0
  61. package/build/social-links/edit.js.map +1 -1
  62. package/build/template-part/edit/placeholder/index.js +1 -1
  63. package/build/template-part/edit/placeholder/index.js.map +1 -1
  64. package/build/template-part/index.js +2 -1
  65. package/build/template-part/index.js.map +1 -1
  66. package/build-module/cover/edit.js +9 -3
  67. package/build-module/cover/edit.js.map +1 -1
  68. package/build-module/gallery/deprecated.js +309 -27
  69. package/build-module/gallery/deprecated.js.map +1 -1
  70. package/build-module/gallery/edit-wrapper.js +7 -27
  71. package/build-module/gallery/edit-wrapper.js.map +1 -1
  72. package/build-module/gallery/edit.js +11 -13
  73. package/build-module/gallery/edit.js.map +1 -1
  74. package/build-module/gallery/save.js +2 -3
  75. package/build-module/gallery/save.js.map +1 -1
  76. package/build-module/gallery/shared.js +22 -0
  77. package/build-module/gallery/shared.js.map +1 -1
  78. package/build-module/gallery/transforms.js +9 -21
  79. package/build-module/gallery/transforms.js.map +1 -1
  80. package/build-module/gallery/use-mobile-warning.js +1 -1
  81. package/build-module/gallery/use-mobile-warning.js.map +1 -1
  82. package/build-module/gallery/v1/edit.js +4 -22
  83. package/build-module/gallery/v1/edit.js.map +1 -1
  84. package/build-module/index.js +3 -2
  85. package/build-module/index.js.map +1 -1
  86. package/build-module/navigation/deprecated.js +127 -19
  87. package/build-module/navigation/deprecated.js.map +1 -1
  88. package/build-module/navigation/edit/index.js +47 -31
  89. package/build-module/navigation/edit/index.js.map +1 -1
  90. package/build-module/navigation/edit/inner-blocks.js +0 -4
  91. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  92. package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
  93. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  94. package/build-module/navigation/edit/placeholder/index.js +15 -45
  95. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  96. package/build-module/navigation/edit/unsaved-inner-blocks.js +6 -35
  97. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  98. package/build-module/navigation/edit/use-create-navigation-menu.js +36 -0
  99. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -0
  100. package/build-module/navigation/edit/use-generate-default-navigation-title.js +57 -0
  101. package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
  102. package/build-module/navigation/index.js +1 -1
  103. package/build-module/navigation/save.js +2 -2
  104. package/build-module/navigation/save.js.map +1 -1
  105. package/build-module/navigation/use-navigation-menu.js +19 -8
  106. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  107. package/build-module/navigation-submenu/edit.js +4 -0
  108. package/build-module/navigation-submenu/edit.js.map +1 -1
  109. package/build-module/pattern/index.js +1 -1
  110. package/build-module/post-featured-image/edit.js +2 -3
  111. package/build-module/post-featured-image/edit.js.map +1 -1
  112. package/build-module/post-terms/index.js +1 -1
  113. package/build-module/post-title/edit.js +2 -2
  114. package/build-module/post-title/edit.js.map +1 -1
  115. package/build-module/query-pagination/index.js +1 -1
  116. package/build-module/query-pagination-next/index.js +2 -2
  117. package/build-module/query-pagination-numbers/index.js +1 -1
  118. package/build-module/query-pagination-previous/index.js +2 -2
  119. package/build-module/query-title/index.js +1 -1
  120. package/build-module/separator/separator-settings.js +1 -0
  121. package/build-module/separator/separator-settings.js.map +1 -1
  122. package/build-module/site-logo/index.js +1 -1
  123. package/build-module/site-tagline/index.js +1 -1
  124. package/build-module/site-title/index.js +1 -1
  125. package/build-module/social-links/edit.js +1 -0
  126. package/build-module/social-links/edit.js.map +1 -1
  127. package/build-module/template-part/edit/placeholder/index.js +2 -2
  128. package/build-module/template-part/edit/placeholder/index.js.map +1 -1
  129. package/build-module/template-part/index.js +2 -1
  130. package/build-module/template-part/index.js.map +1 -1
  131. package/build-style/columns/editor-rtl.css +1 -1
  132. package/build-style/columns/editor.css +1 -1
  133. package/build-style/editor-rtl.css +6 -5
  134. package/build-style/editor.css +6 -5
  135. package/build-style/gallery/editor-rtl.css +1 -0
  136. package/build-style/gallery/editor.css +1 -0
  137. package/build-style/navigation/style-rtl.css +5 -1
  138. package/build-style/navigation/style.css +5 -1
  139. package/build-style/post-featured-image/editor-rtl.css +2 -2
  140. package/build-style/post-featured-image/editor.css +2 -2
  141. package/build-style/site-logo/editor-rtl.css +2 -2
  142. package/build-style/site-logo/editor.css +2 -2
  143. package/build-style/style-rtl.css +5 -1
  144. package/build-style/style.css +5 -1
  145. package/package.json +9 -9
  146. package/src/calendar/index.php +2 -2
  147. package/src/columns/editor.scss +3 -2
  148. package/src/cover/edit.js +9 -1
  149. package/src/gallery/deprecated.js +831 -559
  150. package/src/gallery/edit-wrapper.js +7 -27
  151. package/src/gallery/edit.js +11 -13
  152. package/src/gallery/editor.scss +1 -0
  153. package/src/gallery/save.js +2 -1
  154. package/src/gallery/shared.js +24 -0
  155. package/src/gallery/transforms.js +9 -27
  156. package/src/gallery/use-mobile-warning.js +1 -1
  157. package/src/gallery/v1/edit.js +1 -28
  158. package/src/index.js +27 -25
  159. package/src/navigation/block.json +1 -1
  160. package/src/navigation/deprecated.js +115 -13
  161. package/src/navigation/edit/index.js +44 -36
  162. package/src/navigation/edit/inner-blocks.js +0 -5
  163. package/src/navigation/edit/navigation-menu-selector.js +2 -2
  164. package/src/navigation/edit/placeholder/index.js +16 -62
  165. package/src/navigation/edit/unsaved-inner-blocks.js +6 -57
  166. package/src/navigation/edit/use-create-navigation-menu.js +39 -0
  167. package/src/navigation/edit/use-generate-default-navigation-title.js +79 -0
  168. package/src/navigation/index.php +263 -26
  169. package/src/navigation/save.js +2 -2
  170. package/src/navigation/style.scss +5 -1
  171. package/src/navigation/use-navigation-menu.js +20 -9
  172. package/src/navigation-submenu/edit.js +6 -0
  173. package/src/navigation-submenu/index.php +30 -45
  174. package/src/page-list/index.php +10 -9
  175. package/src/pattern/block.json +1 -1
  176. package/src/post-featured-image/edit.js +2 -5
  177. package/src/post-featured-image/editor.scss +2 -2
  178. package/src/post-terms/block.json +1 -1
  179. package/src/post-title/edit.js +2 -2
  180. package/src/query-pagination/block.json +1 -1
  181. package/src/query-pagination-next/block.json +2 -2
  182. package/src/query-pagination-numbers/block.json +1 -1
  183. package/src/query-pagination-previous/block.json +2 -2
  184. package/src/query-title/block.json +1 -1
  185. package/src/separator/separator-settings.js +1 -0
  186. package/src/site-logo/block.json +1 -1
  187. package/src/site-logo/editor.scss +2 -2
  188. package/src/site-tagline/block.json +1 -1
  189. package/src/site-title/block.json +1 -1
  190. package/src/social-links/edit.js +1 -0
  191. package/src/template-part/block.json +2 -1
  192. package/src/template-part/edit/placeholder/index.js +2 -2
  193. package/src/template-part/index.php +38 -1
  194. package/build/gallery/v1/update-gallery-modal.js +0 -114
  195. package/build/gallery/v1/update-gallery-modal.js.map +0 -1
  196. package/build/navigation/edit/navigation-menu-name-modal.js +0 -55
  197. package/build/navigation/edit/navigation-menu-name-modal.js.map +0 -1
  198. package/build/navigation/edit/navigation-menu-publish-button.js +0 -53
  199. package/build/navigation/edit/navigation-menu-publish-button.js.map +0 -1
  200. package/build-module/gallery/v1/update-gallery-modal.js +0 -97
  201. package/build-module/gallery/v1/update-gallery-modal.js.map +0 -1
  202. package/build-module/navigation/edit/navigation-menu-name-modal.js +0 -47
  203. package/build-module/navigation/edit/navigation-menu-name-modal.js.map +0 -1
  204. package/build-module/navigation/edit/navigation-menu-publish-button.js +0 -40
  205. package/build-module/navigation/edit/navigation-menu-publish-button.js.map +0 -1
  206. package/src/gallery/v1/update-gallery-modal.js +0 -97
  207. package/src/navigation/edit/navigation-menu-name-modal.js +0 -69
  208. package/src/navigation/edit/navigation-menu-publish-button.js +0 -57
@@ -1,47 +1,27 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store as blockEditorStore } from '@wordpress/block-editor';
5
- import { useSelect } from '@wordpress/data';
4
+ import { compose } from '@wordpress/compose';
5
+ import { withNotices } from '@wordpress/components';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
10
  import EditWithInnerBlocks from './edit';
11
11
  import EditWithoutInnerBlocks from './v1/edit';
12
+ import { isGalleryV2Enabled } from './shared';
12
13
 
13
14
  /*
14
15
  * Using a wrapper around the logic to load the edit for v1 of Gallery block
15
16
  * or the refactored version with InnerBlocks. This is to prevent conditional
16
17
  * use of hooks lint errors if adding this logic to the top of the edit component.
17
18
  */
18
- export default function GalleryEditWrapper( props ) {
19
- const { attributes, clientId } = props;
20
-
21
- const innerBlockImages = useSelect(
22
- ( select ) => {
23
- return select( blockEditorStore ).getBlock( clientId )?.innerBlocks;
24
- },
25
- [ clientId ]
26
- );
27
-
28
- const __unstableGalleryWithImageBlocks = useSelect( ( select ) => {
29
- const settings = select( blockEditorStore ).getSettings();
30
- return settings.__unstableGalleryWithImageBlocks;
31
- }, [] );
32
-
33
- // This logic is used to infer version information from content with higher
34
- // precedence than the flag. New galleries (and existing empty galleries) will
35
- // honor the flag.
36
- const hasNewVersionContent = !! innerBlockImages?.length;
37
- const hasOldVersionContent =
38
- 0 < attributes?.ids?.length || 0 < attributes?.images?.length;
39
- if (
40
- hasOldVersionContent ||
41
- ( ! hasNewVersionContent && ! __unstableGalleryWithImageBlocks )
42
- ) {
19
+ function GalleryEditWrapper( props ) {
20
+ if ( ! isGalleryV2Enabled() ) {
43
21
  return <EditWithoutInnerBlocks { ...props } />;
44
22
  }
45
23
 
46
24
  return <EditWithInnerBlocks { ...props } />;
47
25
  }
26
+
27
+ export default compose( [ withNotices ] )( GalleryEditWrapper );
@@ -144,7 +144,7 @@ function GalleryEdit( props ) {
144
144
  useEffect( () => {
145
145
  newImages?.forEach( ( newImage ) => {
146
146
  updateBlockAttributes( newImage.clientId, {
147
- ...buildImageAttributes( false, newImage.attributes ),
147
+ ...buildImageAttributes( newImage.attributes ),
148
148
  id: newImage.id,
149
149
  align: undefined,
150
150
  } );
@@ -176,26 +176,24 @@ function GalleryEdit( props ) {
176
176
  * it already existed in the gallery. If the image is in fact new, we need
177
177
  * to apply the gallery's current settings to the image.
178
178
  *
179
- * @param {Object} existingBlock Existing Image block that still exists after gallery update.
180
- * @param {Object} image Media object for the actual image.
181
- * @return {Object} Attributes to set on the new image block.
179
+ * @param {Object} imageAttributes Media object for the actual image.
180
+ * @return {Object} Attributes to set on the new image block.
182
181
  */
183
- function buildImageAttributes( existingBlock, image ) {
184
- if ( existingBlock ) {
185
- return existingBlock.attributes;
186
- }
182
+ function buildImageAttributes( imageAttributes ) {
183
+ const image = imageAttributes.id
184
+ ? find( imageData, { id: imageAttributes.id } )
185
+ : null;
187
186
 
188
187
  let newClassName;
189
- if ( image.className && image.className !== '' ) {
190
- newClassName = image.className;
188
+ if ( imageAttributes.className && imageAttributes.className !== '' ) {
189
+ newClassName = imageAttributes.className;
191
190
  } else {
192
191
  newClassName = preferredStyle
193
192
  ? `is-style-${ preferredStyle }`
194
193
  : undefined;
195
194
  }
196
-
197
195
  return {
198
- ...pickRelevantMediaFiles( image, sizeSlug ),
196
+ ...pickRelevantMediaFiles( imageAttributes, sizeSlug ),
199
197
  ...getHrefAndDestination( image, linkTo ),
200
198
  ...getUpdatedLinkTargetSettings( linkTarget, attributes ),
201
199
  className: newClassName,
@@ -498,7 +496,7 @@ function GalleryEdit( props ) {
498
496
  hideCancelButton={ true }
499
497
  />
500
498
  ) }
501
- { Platform.isWeb && ! imageSizeOptions && (
499
+ { Platform.isWeb && ! imageSizeOptions && hasImageIds && (
502
500
  <BaseControl className={ 'gallery-image-sizes' }>
503
501
  <BaseControl.VisualLabel>
504
502
  { __( 'Image size' ) }
@@ -128,6 +128,7 @@ figure.wp-block-gallery {
128
128
  bottom: 0;
129
129
  left: 0;
130
130
  z-index: 1;
131
+ pointer-events: none;
131
132
  }
132
133
  }
133
134
 
@@ -16,9 +16,10 @@ import {
16
16
  * Internal dependencies
17
17
  */
18
18
  import saveWithoutInnerBlocks from './v1/save';
19
+ import { isGalleryV2Enabled } from './shared';
19
20
 
20
21
  export default function saveWithInnerBlocks( { attributes } ) {
21
- if ( attributes?.ids?.length > 0 || attributes?.images?.length > 0 ) {
22
+ if ( ! isGalleryV2Enabled() ) {
22
23
  return saveWithoutInnerBlocks( { attributes } );
23
24
  }
24
25
 
@@ -21,3 +21,27 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
21
21
  }
22
22
  return imageProps;
23
23
  };
24
+
25
+ /**
26
+ * The new gallery block format is not compatible with the use_BalanceTags option
27
+ * in WP versions <= 5.8 https://core.trac.wordpress.org/ticket/54130. The
28
+ * window.wp.galleryBlockV2Enabled flag is set in lib/compat.php. This method
29
+ * can be removed when minimum supported WP version >=5.9.
30
+ */
31
+ export function isGalleryV2Enabled() {
32
+ // Only run the Gallery version compat check if the plugin is running, otherwise
33
+ // assume we are in 5.9 core and enable by default.
34
+ if ( process.env.GUTENBERG_PHASE === 2 ) {
35
+ // We want to fail early here, at least during beta testing phase, to ensure
36
+ // there aren't instances where undefined values cause false negatives.
37
+ if (
38
+ ! window.wp ||
39
+ typeof window.wp.galleryBlockV2Enabled !== 'boolean'
40
+ ) {
41
+ throw 'window.wp.galleryBlockV2Enabled is not defined';
42
+ }
43
+ return window.wp.galleryBlockV2Enabled;
44
+ }
45
+
46
+ return true;
47
+ }
@@ -8,8 +8,6 @@ import { filter, every, toString } from 'lodash';
8
8
  */
9
9
  import { createBlock } from '@wordpress/blocks';
10
10
  import { createBlobURL } from '@wordpress/blob';
11
- import { select } from '@wordpress/data';
12
- import { store as blockEditorStore } from '@wordpress/block-editor';
13
11
  import { addFilter } from '@wordpress/hooks';
14
12
 
15
13
  /**
@@ -24,7 +22,7 @@ import {
24
22
  LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
25
23
  LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
26
24
  } from './v1/constants';
27
- import { pickRelevantMediaFiles } from './shared';
25
+ import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
28
26
 
29
27
  const parseShortcodeIds = ( ids ) => {
30
28
  if ( ! ids ) {
@@ -49,9 +47,8 @@ const parseShortcodeIds = ( ids ) => {
49
47
  * @return {Block} The transformed block.
50
48
  */
51
49
  function updateThirdPartyTransformToGallery( block ) {
52
- const settings = select( blockEditorStore ).getSettings();
53
50
  if (
54
- settings.__unstableGalleryWithImageBlocks &&
51
+ isGalleryV2Enabled() &&
55
52
  block.name === 'core/gallery' &&
56
53
  block.attributes?.images.length > 0
57
54
  ) {
@@ -145,8 +142,7 @@ const transforms = {
145
142
 
146
143
  const validImages = filter( attributes, ( { url } ) => url );
147
144
 
148
- const settings = select( blockEditorStore ).getSettings();
149
- if ( settings.__unstableGalleryWithImageBlocks ) {
145
+ if ( isGalleryV2Enabled() ) {
150
146
  const innerBlocks = validImages.map( ( image ) => {
151
147
  return createBlock( 'core/image', image );
152
148
  } );
@@ -184,10 +180,7 @@ const transforms = {
184
180
  images: {
185
181
  type: 'array',
186
182
  shortcode: ( { named: { ids } } ) => {
187
- const settings = select(
188
- blockEditorStore
189
- ).getSettings();
190
- if ( ! settings.__unstableGalleryWithImageBlocks ) {
183
+ if ( ! isGalleryV2Enabled() ) {
191
184
  return parseShortcodeIds( ids ).map( ( id ) => ( {
192
185
  id: toString( id ),
193
186
  } ) );
@@ -197,10 +190,7 @@ const transforms = {
197
190
  ids: {
198
191
  type: 'array',
199
192
  shortcode: ( { named: { ids } } ) => {
200
- const settings = select(
201
- blockEditorStore
202
- ).getSettings();
203
- if ( ! settings.__unstableGalleryWithImageBlocks ) {
193
+ if ( ! isGalleryV2Enabled() ) {
204
194
  return parseShortcodeIds( ids );
205
195
  }
206
196
  },
@@ -208,10 +198,7 @@ const transforms = {
208
198
  shortCodeTransforms: {
209
199
  type: 'array',
210
200
  shortcode: ( { named: { ids } } ) => {
211
- const settings = select(
212
- blockEditorStore
213
- ).getSettings();
214
- if ( settings.__unstableGalleryWithImageBlocks ) {
201
+ if ( isGalleryV2Enabled() ) {
215
202
  return parseShortcodeIds( ids ).map( ( id ) => ( {
216
203
  id: parseInt( id ),
217
204
  } ) );
@@ -227,10 +214,7 @@ const transforms = {
227
214
  linkTo: {
228
215
  type: 'string',
229
216
  shortcode: ( { named: { link } } ) => {
230
- const settings = select(
231
- blockEditorStore
232
- ).getSettings();
233
- if ( ! settings.__unstableGalleryWithImageBlocks ) {
217
+ if ( ! isGalleryV2Enabled() ) {
234
218
  switch ( link ) {
235
219
  case 'post':
236
220
  return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
@@ -273,8 +257,7 @@ const transforms = {
273
257
  );
274
258
  },
275
259
  transform( files ) {
276
- const settings = select( blockEditorStore ).getSettings();
277
- if ( settings.__unstableGalleryWithImageBlocks ) {
260
+ if ( isGalleryV2Enabled() ) {
278
261
  const innerBlocks = files.map( ( file ) =>
279
262
  createBlock( 'core/image', {
280
263
  url: createBlobURL( file ),
@@ -299,8 +282,7 @@ const transforms = {
299
282
  type: 'block',
300
283
  blocks: [ 'core/image' ],
301
284
  transform: ( { align, images, ids, sizeSlug }, innerBlocks ) => {
302
- const settings = select( blockEditorStore ).getSettings();
303
- if ( settings.__unstableGalleryWithImageBlocks ) {
285
+ if ( isGalleryV2Enabled() ) {
304
286
  if ( innerBlocks.length > 0 ) {
305
287
  return innerBlocks.map(
306
288
  ( {
@@ -20,7 +20,7 @@ export default function useMobileWarning( newImages ) {
20
20
 
21
21
  createWarningNotice(
22
22
  __(
23
- 'Editing this Gallery in the WordPress mobile app requires version 18.2 or higher.'
23
+ 'If you want to edit the gallery you just added in the mobile app, to avoid losing any data please make sure you use version 18.2 of the app or above.'
24
24
  ),
25
25
  { type: 'snackbar', explicitDismiss: true }
26
26
  );
@@ -24,10 +24,8 @@ import {
24
24
  ToggleControl,
25
25
  withNotices,
26
26
  RangeControl,
27
- ToolbarButton,
28
27
  } from '@wordpress/components';
29
28
  import {
30
- BlockControls,
31
29
  MediaPlaceholder,
32
30
  InspectorControls,
33
31
  useBlockProps,
@@ -53,7 +51,6 @@ import {
53
51
  LINK_DESTINATION_MEDIA,
54
52
  LINK_DESTINATION_NONE,
55
53
  } from './constants';
56
- import UpdateGalleryModal from './update-gallery-modal';
57
54
 
58
55
  const MAX_COLUMNS = 8;
59
56
  const linkOptions = [
@@ -102,13 +99,10 @@ function GalleryEdit( props ) {
102
99
  mediaUpload,
103
100
  getMedia,
104
101
  wasBlockJustInserted,
105
- __unstableGalleryWithImageBlocks,
106
102
  } = useSelect( ( select ) => {
107
103
  const settings = select( blockEditorStore ).getSettings();
108
104
 
109
105
  return {
110
- __unstableGalleryWithImageBlocks:
111
- settings.__unstableGalleryWithImageBlocks,
112
106
  imageSizes: settings.imageSizes,
113
107
  mediaUpload: settings.mediaUpload,
114
108
  getMedia: select( coreStore ).getMedia,
@@ -414,10 +408,6 @@ function GalleryEdit( props ) {
414
408
  />
415
409
  );
416
410
 
417
- const [ isUpdateOpen, setUpdateOpen ] = useState( false );
418
- const openUpdateModal = () => setUpdateOpen( true );
419
- const closeUpdateModal = () => setUpdateOpen( false );
420
-
421
411
  const blockProps = useBlockProps();
422
412
 
423
413
  if ( ! hasImages ) {
@@ -466,24 +456,7 @@ function GalleryEdit( props ) {
466
456
  ) }
467
457
  </PanelBody>
468
458
  </InspectorControls>
469
- { /* TODO: Remove platform condition when native conversion is ready */ }
470
- { Platform.isWeb && __unstableGalleryWithImageBlocks && (
471
- <BlockControls group="other">
472
- <ToolbarButton
473
- onClick={ openUpdateModal }
474
- title={ __( 'Update' ) }
475
- label={ __( 'Update to the new gallery format' ) }
476
- >
477
- { __( 'Update' ) }
478
- </ToolbarButton>
479
- </BlockControls>
480
- ) }
481
- { Platform.isWeb && isUpdateOpen && (
482
- <UpdateGalleryModal
483
- onClose={ closeUpdateModal }
484
- clientId={ clientId }
485
- />
486
- ) }
459
+
487
460
  { noticeUI }
488
461
  <Gallery
489
462
  { ...props }
package/src/index.js CHANGED
@@ -149,53 +149,55 @@ export const __experimentalGetCoreBlocks = () => [
149
149
  html,
150
150
  latestComments,
151
151
  latestPosts,
152
- logInOut,
153
152
  mediaText,
154
153
  missing,
155
154
  more,
156
- navigation,
157
- navigationLink,
158
- navigationSubmenu,
159
155
  nextpage,
160
156
  pageList,
161
157
  pattern,
162
- postAuthor,
163
- postComments,
164
- postContent,
165
- postDate,
166
- postExcerpt,
167
- postFeaturedImage,
168
- postNavigationLink,
169
- postTemplate,
170
- postTerms,
171
- postTitle,
172
158
  preformatted,
173
159
  pullquote,
174
- query,
175
- queryPagination,
176
- queryPaginationNext,
177
- queryPaginationNumbers,
178
- queryPaginationPrevious,
179
- queryTitle,
180
160
  reusableBlock,
181
161
  rss,
182
162
  search,
183
163
  separator,
184
164
  shortcode,
185
- siteLogo,
186
- siteTagline,
187
- siteTitle,
188
165
  socialLink,
189
166
  socialLinks,
190
167
  spacer,
191
168
  table,
192
169
  // tableOfContents,
193
170
  tagCloud,
194
- templatePart,
195
- termDescription,
196
171
  textColumns,
197
172
  verse,
198
173
  video,
174
+
175
+ // theme blocks
176
+ navigation,
177
+ navigationLink,
178
+ navigationSubmenu,
179
+ siteLogo,
180
+ siteTitle,
181
+ siteTagline,
182
+ query,
183
+ templatePart,
184
+ postTitle,
185
+ postExcerpt,
186
+ postFeaturedImage,
187
+ postContent,
188
+ postAuthor,
189
+ postDate,
190
+ postTerms,
191
+ postNavigationLink,
192
+ postTemplate,
193
+ queryPagination,
194
+ queryPaginationNext,
195
+ queryPaginationNumbers,
196
+ queryPaginationPrevious,
197
+ postComments,
198
+ logInOut,
199
+ termDescription,
200
+ queryTitle,
199
201
  ];
200
202
 
201
203
  /**
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "textdomain": "default",
13
13
  "attributes": {
14
- "navigationMenuId": {
14
+ "ref": {
15
15
  "type": "number"
16
16
  },
17
17
  "textColor": {
@@ -21,32 +21,131 @@ const TYPOGRAPHY_PRESET_DEPRECATION_MAP = {
21
21
  textTransform: 'var:preset|text-transform|',
22
22
  };
23
23
 
24
+ const migrateIdToRef = ( { navigationMenuId, ...attributes } ) => {
25
+ return {
26
+ ...attributes,
27
+ ref: navigationMenuId,
28
+ };
29
+ };
30
+
24
31
  const migrateWithLayout = ( attributes ) => {
25
32
  if ( !! attributes.layout ) {
26
33
  return attributes;
27
34
  }
28
35
 
29
- const { itemsJustification, orientation } = attributes;
30
-
31
- const updatedAttributes = {
32
- ...attributes,
33
- };
36
+ const {
37
+ itemsJustification,
38
+ orientation,
39
+ ...updatedAttributes
40
+ } = attributes;
34
41
 
35
42
  if ( itemsJustification || orientation ) {
36
43
  Object.assign( updatedAttributes, {
37
44
  layout: {
38
45
  type: 'flex',
39
- justifyContent: itemsJustification || 'left',
40
- orientation: orientation || 'horizontal',
46
+ setCascadingProperties: 'true',
47
+ ...( itemsJustification && {
48
+ justifyContent: itemsJustification,
49
+ } ),
50
+ ...( orientation && { orientation } ),
41
51
  },
42
52
  } );
43
- delete updatedAttributes.itemsJustification;
44
- delete updatedAttributes.orientation;
45
53
  }
46
54
 
47
55
  return updatedAttributes;
48
56
  };
49
57
 
58
+ const v6 = {
59
+ attributes: {
60
+ navigationMenuId: {
61
+ type: 'number',
62
+ },
63
+ textColor: {
64
+ type: 'string',
65
+ },
66
+ customTextColor: {
67
+ type: 'string',
68
+ },
69
+ rgbTextColor: {
70
+ type: 'string',
71
+ },
72
+ backgroundColor: {
73
+ type: 'string',
74
+ },
75
+ customBackgroundColor: {
76
+ type: 'string',
77
+ },
78
+ rgbBackgroundColor: {
79
+ type: 'string',
80
+ },
81
+ showSubmenuIcon: {
82
+ type: 'boolean',
83
+ default: true,
84
+ },
85
+ openSubmenusOnClick: {
86
+ type: 'boolean',
87
+ default: false,
88
+ },
89
+ overlayMenu: {
90
+ type: 'string',
91
+ default: 'mobile',
92
+ },
93
+ __unstableLocation: {
94
+ type: 'string',
95
+ },
96
+ overlayBackgroundColor: {
97
+ type: 'string',
98
+ },
99
+ customOverlayBackgroundColor: {
100
+ type: 'string',
101
+ },
102
+ overlayTextColor: {
103
+ type: 'string',
104
+ },
105
+ customOverlayTextColor: {
106
+ type: 'string',
107
+ },
108
+ },
109
+ supports: {
110
+ align: [ 'wide', 'full' ],
111
+ anchor: true,
112
+ html: false,
113
+ inserter: true,
114
+ typography: {
115
+ fontSize: true,
116
+ lineHeight: true,
117
+ __experimentalFontStyle: true,
118
+ __experimentalFontWeight: true,
119
+ __experimentalTextTransform: true,
120
+ __experimentalFontFamily: true,
121
+ __experimentalTextDecoration: true,
122
+ __experimentalDefaultControls: {
123
+ fontSize: true,
124
+ },
125
+ },
126
+ spacing: {
127
+ blockGap: true,
128
+ units: [ 'px', 'em', 'rem', 'vh', 'vw' ],
129
+ __experimentalDefaultControls: {
130
+ blockGap: true,
131
+ },
132
+ },
133
+ __experimentalLayout: {
134
+ allowSwitching: false,
135
+ allowInheriting: false,
136
+ default: {
137
+ type: 'flex',
138
+ setCascadingProperties: true,
139
+ },
140
+ },
141
+ },
142
+ save() {
143
+ return <InnerBlocks.Content />;
144
+ },
145
+ isEligible: ( { navigationMenuId } ) => !! navigationMenuId,
146
+ migrate: migrateIdToRef,
147
+ };
148
+
50
149
  const v5 = {
51
150
  attributes: {
52
151
  navigationMenuId: {
@@ -135,7 +234,7 @@ const v5 = {
135
234
  },
136
235
  isEligible: ( { itemsJustification, orientation } ) =>
137
236
  !! itemsJustification || !! orientation,
138
- migrate: migrateWithLayout,
237
+ migrate: compose( migrateIdToRef, migrateWithLayout ),
139
238
  };
140
239
 
141
240
  const v4 = {
@@ -218,7 +317,7 @@ const v4 = {
218
317
  save() {
219
318
  return <InnerBlocks.Content />;
220
319
  },
221
- migrate: compose( migrateWithLayout, migrateFontFamily ),
320
+ migrate: compose( migrateIdToRef, migrateWithLayout, migrateFontFamily ),
222
321
  isEligible( { style } ) {
223
322
  return style?.typography?.fontFamily;
224
323
  },
@@ -259,6 +358,7 @@ const migrateTypographyPresets = function ( attributes ) {
259
358
  };
260
359
 
261
360
  const deprecated = [
361
+ v6,
262
362
  v5,
263
363
  v4,
264
364
  // Remove `isResponsive` attribute.
@@ -336,6 +436,7 @@ const deprecated = [
336
436
  return attributes.isResponsive;
337
437
  },
338
438
  migrate: compose(
439
+ migrateIdToRef,
339
440
  migrateWithLayout,
340
441
  migrateFontFamily,
341
442
  migrateIsResponsive
@@ -410,6 +511,7 @@ const deprecated = [
410
511
  return false;
411
512
  },
412
513
  migrate: compose(
514
+ migrateIdToRef,
413
515
  migrateWithLayout,
414
516
  migrateFontFamily,
415
517
  migrateTypographyPresets
@@ -454,7 +556,7 @@ const deprecated = [
454
556
  html: false,
455
557
  inserter: true,
456
558
  },
457
- migrate( attributes ) {
559
+ migrate: compose( migrateIdToRef, ( attributes ) => {
458
560
  return {
459
561
  ...omit( attributes, [ 'rgbTextColor', 'rgbBackgroundColor' ] ),
460
562
  customTextColor: attributes.textColor
@@ -464,7 +566,7 @@ const deprecated = [
464
566
  ? undefined
465
567
  : attributes.rgbBackgroundColor,
466
568
  };
467
- },
569
+ } ),
468
570
  save() {
469
571
  return <InnerBlocks.Content />;
470
572
  },