@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
@@ -17,7 +17,20 @@
17
17
  * @return string The block content.
18
18
  */
19
19
  function render_block_core_button( $attributes, $content ) {
20
- $p = new WP_HTML_Tag_Processor( $content );
20
+ /*
21
+ * The current Gutenberg plugin supports WordPress 6.4, but the next_token()
22
+ * method does not exist in WordPress 6.4. Therefore, if Gutenberg is used
23
+ * as a plugin, use the Gutenberg class that has the `next_token()` method.
24
+ *
25
+ * TODO: After the Gutenberg plugin drops support for WordPress 6.4, this
26
+ * conditional statement will be removed and the core class `WP_HTML_Tag_Processor`
27
+ * should be used.
28
+ */
29
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && class_exists( 'Gutenberg_HTML_Tag_Processor_6_5' ) ) {
30
+ $p = new Gutenberg_HTML_Tag_Processor_6_5( $content );
31
+ } else {
32
+ $p = new WP_HTML_Tag_Processor( $content );
33
+ }
21
34
 
22
35
  /*
23
36
  * The button block can render an `<a>` or `<button>` and also has a
@@ -20,6 +20,7 @@ import {
20
20
  } from '@wordpress/block-editor';
21
21
  import { Component } from '@wordpress/element';
22
22
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
23
+ import { getAuthority } from '@wordpress/url';
23
24
 
24
25
  /**
25
26
  * Internal dependencies
@@ -73,14 +74,11 @@ class EmbedPreview extends Component {
73
74
  const { interactive } = this.state;
74
75
 
75
76
  const html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;
76
- const parsedHost = new URL( url ).host.split( '.' );
77
- const parsedHostBaseUrl = parsedHost
78
- .splice( parsedHost.length - 2, parsedHost.length - 1 )
79
- .join( '.' );
77
+ const embedSourceUrl = getAuthority( url );
80
78
  const iframeTitle = sprintf(
81
79
  // translators: %s: host providing embed content e.g: www.youtube.com
82
80
  __( 'Embedded content from %s' ),
83
- parsedHostBaseUrl
81
+ embedSourceUrl
84
82
  );
85
83
  const sandboxClassnames = clsx(
86
84
  type,
@@ -136,7 +134,7 @@ class EmbedPreview extends Component {
136
134
  __(
137
135
  "Embedded content from %s can't be previewed in the editor."
138
136
  ),
139
- parsedHostBaseUrl
137
+ embedSourceUrl
140
138
  ) }
141
139
  </p>
142
140
  </Placeholder>
@@ -11,6 +11,10 @@
11
11
  "id": {
12
12
  "type": "number"
13
13
  },
14
+ "blob": {
15
+ "type": "string",
16
+ "__experimentalRole": "local"
17
+ },
14
18
  "href": {
15
19
  "type": "string"
16
20
  },
package/src/file/edit.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  store as blockEditorStore,
24
24
  __experimentalGetElementClassName,
25
25
  } from '@wordpress/block-editor';
26
- import { useEffect } from '@wordpress/element';
26
+ import { useEffect, useState } from '@wordpress/element';
27
27
  import { useCopyToClipboard } from '@wordpress/compose';
28
28
  import { __, _x } from '@wordpress/i18n';
29
29
  import { file as icon } from '@wordpress/icons';
@@ -73,6 +73,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
73
73
  displayPreview,
74
74
  previewHeight,
75
75
  } = attributes;
76
+ const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
76
77
  const { media } = useSelect(
77
78
  ( select ) => ( {
78
79
  media:
@@ -88,7 +89,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
88
89
  useDispatch( blockEditorStore );
89
90
 
90
91
  useUploadMediaFromBlobURL( {
91
- url: href,
92
+ url: temporaryURL,
92
93
  onChange: onSelectFile,
93
94
  onError: onUploadError,
94
95
  } );
@@ -108,6 +109,12 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
108
109
 
109
110
  function onSelectFile( newMedia ) {
110
111
  if ( ! newMedia || ! newMedia.url ) {
112
+ setTemporaryURL();
113
+ return;
114
+ }
115
+
116
+ if ( isBlobURL( newMedia.url ) ) {
117
+ setTemporaryURL( newMedia.url );
111
118
  return;
112
119
  }
113
120
 
@@ -120,7 +127,9 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
120
127
  displayPreview: isPdf ? true : undefined,
121
128
  previewHeight: isPdf ? 600 : undefined,
122
129
  fileId: `wp-block-file--media-${ clientId }`,
130
+ blob: undefined,
123
131
  } );
132
+ setTemporaryURL();
124
133
  }
125
134
 
126
135
  function onUploadError( message ) {
@@ -166,16 +175,16 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
166
175
 
167
176
  const blockProps = useBlockProps( {
168
177
  className: clsx(
169
- isBlobURL( href ) && getAnimateClassName( { type: 'loading' } ),
178
+ !! temporaryURL && getAnimateClassName( { type: 'loading' } ),
170
179
  {
171
- 'is-transient': isBlobURL( href ),
180
+ 'is-transient': !! temporaryURL,
172
181
  }
173
182
  ),
174
183
  } );
175
184
 
176
185
  const displayPreviewInEditor = browserSupportsPdfs() && displayPreview;
177
186
 
178
- if ( ! href ) {
187
+ if ( ! href && ! temporaryURL ) {
179
188
  return (
180
189
  <div { ...blockProps }>
181
190
  <MediaPlaceholder
@@ -197,7 +206,11 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
197
206
  return (
198
207
  <>
199
208
  <FileBlockInspector
200
- hrefs={ { href, textLinkHref, attachmentPage } }
209
+ hrefs={ {
210
+ href: href || temporaryURL,
211
+ textLinkHref,
212
+ attachmentPage,
213
+ } }
201
214
  { ...{
202
215
  openInNewWindow: !! textLinkTarget,
203
216
  showDownloadButton,
@@ -26,9 +26,8 @@ const transforms = {
26
26
  // File will be uploaded in componentDidMount()
27
27
  blocks.push(
28
28
  createBlock( 'core/file', {
29
- href: blobURL,
29
+ blob: blobURL,
30
30
  fileName: file.name,
31
- textLinkHref: blobURL,
32
31
  } )
33
32
  );
34
33
  } );
@@ -22,7 +22,6 @@ import {
22
22
  LINK_DESTINATION_MEDIA,
23
23
  LINK_DESTINATION_NONE,
24
24
  } from './constants';
25
- import { isGalleryV2Enabled } from './shared';
26
25
 
27
26
  const DEPRECATED_LINK_DESTINATION_MEDIA = 'file';
28
27
  const DEPRECATED_LINK_DESTINATION_ATTACHMENT = 'post';
@@ -408,11 +407,7 @@ const v6 = {
408
407
  );
409
408
  },
410
409
  migrate( attributes ) {
411
- if ( isGalleryV2Enabled() ) {
412
- return runV2Migration( attributes );
413
- }
414
-
415
- return attributes;
410
+ return runV2Migration( attributes );
416
411
  },
417
412
  };
418
413
  const v5 = {
@@ -498,23 +493,7 @@ const v5 = {
498
493
  return ! linkTo || linkTo === 'attachment' || linkTo === 'media';
499
494
  },
500
495
  migrate( attributes ) {
501
- if ( isGalleryV2Enabled() ) {
502
- return runV2Migration( attributes );
503
- }
504
-
505
- let linkTo = attributes.linkTo;
506
-
507
- if ( ! attributes.linkTo ) {
508
- linkTo = 'none';
509
- } else if ( attributes.linkTo === 'attachment' ) {
510
- linkTo = 'post';
511
- } else if ( attributes.linkTo === 'media' ) {
512
- linkTo = 'file';
513
- }
514
- return {
515
- ...attributes,
516
- linkTo,
517
- };
496
+ return runV2Migration( attributes );
518
497
  },
519
498
  save( { attributes } ) {
520
499
  const {
@@ -661,17 +640,7 @@ const v4 = {
661
640
  return ids && ids.some( ( id ) => typeof id === 'string' );
662
641
  },
663
642
  migrate( attributes ) {
664
- if ( isGalleryV2Enabled() ) {
665
- return runV2Migration( attributes );
666
- }
667
-
668
- return {
669
- ...attributes,
670
- ids: ( attributes.ids ?? [] ).map( ( id ) => {
671
- const parsedId = parseInt( id, 10 );
672
- return Number.isInteger( parsedId ) ? parsedId : null;
673
- } ),
674
- };
643
+ return runV2Migration( attributes );
675
644
  },
676
645
  save( { attributes } ) {
677
646
  const {
@@ -867,10 +836,7 @@ const v3 = {
867
836
  );
868
837
  },
869
838
  migrate( attributes ) {
870
- if ( isGalleryV2Enabled() ) {
871
- return runV2Migration( attributes );
872
- }
873
- return attributes;
839
+ return runV2Migration( attributes );
874
840
  },
875
841
  };
876
842
  const v2 = {
@@ -936,18 +902,7 @@ const v2 = {
936
902
  );
937
903
  },
938
904
  migrate( attributes ) {
939
- if ( isGalleryV2Enabled() ) {
940
- return runV2Migration( attributes );
941
- }
942
- return {
943
- ...attributes,
944
- ids: ( attributes.images ?? [] ).map( ( { id } ) => {
945
- if ( ! id ) {
946
- return null;
947
- }
948
- return parseInt( id, 10 );
949
- } ),
950
- };
905
+ return runV2Migration( attributes );
951
906
  },
952
907
  supports: {
953
908
  align: true,
@@ -1100,11 +1055,7 @@ const v1 = {
1100
1055
  );
1101
1056
  },
1102
1057
  migrate( attributes ) {
1103
- if ( isGalleryV2Enabled() ) {
1104
- return runV2Migration( attributes );
1105
- }
1106
-
1107
- return attributes;
1058
+ return runV2Migration( attributes );
1108
1059
  },
1109
1060
  };
1110
1061
 
@@ -14,6 +14,7 @@ import {
14
14
  ToggleControl,
15
15
  RangeControl,
16
16
  Spinner,
17
+ withNotices,
17
18
  } from '@wordpress/components';
18
19
  import {
19
20
  store as blockEditorStore,
@@ -237,7 +238,7 @@ function GalleryEdit( props ) {
237
238
  return (
238
239
  ALLOWED_MEDIA_TYPES.some(
239
240
  ( mediaType ) => mediaTypeSelector?.indexOf( mediaType ) === 0
240
- ) || file.url?.indexOf( 'blob:' ) === 0
241
+ ) || file.blob
241
242
  );
242
243
  }
243
244
 
@@ -249,9 +250,9 @@ function GalleryEdit( props ) {
249
250
  const imageArray = newFileUploads
250
251
  ? Array.from( selectedImages ).map( ( file ) => {
251
252
  if ( ! file.url ) {
252
- return pickRelevantMediaFiles( {
253
- url: createBlobURL( file ),
254
- } );
253
+ return {
254
+ blob: createBlobURL( file ),
255
+ };
255
256
  }
256
257
 
257
258
  return file;
@@ -271,9 +272,9 @@ function GalleryEdit( props ) {
271
272
  .filter( ( file ) => file.url || isValidFileType( file ) )
272
273
  .map( ( file ) => {
273
274
  if ( ! file.url ) {
274
- return pickRelevantMediaFiles( {
275
- url: createBlobURL( file ),
276
- } );
275
+ return {
276
+ blob: file.blob || createBlobURL( file ),
277
+ };
277
278
  }
278
279
 
279
280
  return file;
@@ -307,6 +308,7 @@ function GalleryEdit( props ) {
307
308
  const newBlocks = newImageList.map( ( image ) => {
308
309
  return createBlock( 'core/image', {
309
310
  id: image.id,
311
+ blob: image.blob,
310
312
  url: image.url,
311
313
  caption: image.caption,
312
314
  alt: image.alt,
@@ -632,6 +634,7 @@ function GalleryEdit( props ) {
632
634
  </>
633
635
  );
634
636
  }
635
- export default compose( [ withViewportMatch( { isNarrow: '< small' } ) ] )(
636
- GalleryEdit
637
- );
637
+ export default compose( [
638
+ withNotices,
639
+ withViewportMatch( { isNarrow: '< small' } ),
640
+ ] )( GalleryEdit );
@@ -1,5 +1,3 @@
1
- @import "./v1/gallery-styles.native.scss";
2
-
3
1
  .galleryAppender {
4
2
  padding-top: $grid-unit-20;
5
3
  }
@@ -8,7 +8,7 @@ import { gallery as icon } from '@wordpress/icons';
8
8
  */
9
9
  import initBlock from '../utils/init-block';
10
10
  import deprecated from './deprecated';
11
- import edit from './edit-wrapper';
11
+ import edit from './edit';
12
12
  import metadata from './block.json';
13
13
  import save from './save';
14
14
  import transforms from './transforms';
@@ -13,17 +13,7 @@ import {
13
13
  __experimentalGetElementClassName,
14
14
  } from '@wordpress/block-editor';
15
15
 
16
- /**
17
- * Internal dependencies
18
- */
19
- import saveWithoutInnerBlocks from './v1/save';
20
- import { isGalleryV2Enabled } from './shared';
21
-
22
16
  export default function saveWithInnerBlocks( { attributes } ) {
23
- if ( ! isGalleryV2Enabled() ) {
24
- return saveWithoutInnerBlocks( { attributes } );
25
- }
26
-
27
17
  const { caption, columns, imageCrop } = attributes;
28
18
 
29
19
  const className = clsx( 'has-nested-images', {
@@ -1,8 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Platform } from '@wordpress/element';
5
-
6
1
  export function defaultColumnsNumber( imageCount ) {
7
2
  return imageCount ? Math.min( 3, imageCount ) : 3;
8
3
  }
@@ -27,26 +22,3 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
27
22
  }
28
23
  return imageProps;
29
24
  };
30
-
31
- function getGalleryBlockV2Enabled() {
32
- // We want to fail early here, at least during beta testing phase, to ensure
33
- // there aren't instances where undefined values cause false negatives.
34
- if ( ! window.wp || typeof window.wp.galleryBlockV2Enabled !== 'boolean' ) {
35
- throw 'window.wp.galleryBlockV2Enabled is not defined';
36
- }
37
- return window.wp.galleryBlockV2Enabled;
38
- }
39
-
40
- /**
41
- * The new gallery block format is not compatible with the use_BalanceTags option
42
- * in WP versions <= 5.8 https://core.trac.wordpress.org/ticket/54130. The
43
- * window.wp.galleryBlockV2Enabled flag is set in lib/compat.php. This method
44
- * can be removed when minimum supported WP version >=5.9.
45
- */
46
- export function isGalleryV2Enabled() {
47
- if ( Platform.isNative ) {
48
- return getGalleryBlockV2Enabled();
49
- }
50
-
51
- return true;
52
- }
@@ -13,7 +13,6 @@ import {
13
13
  LINK_DESTINATION_NONE,
14
14
  LINK_DESTINATION_MEDIA,
15
15
  } from './constants';
16
- import { pickRelevantMediaFiles, isGalleryV2Enabled } from './shared';
17
16
 
18
17
  const parseShortcodeIds = ( ids ) => {
19
18
  if ( ! ids ) {
@@ -39,7 +38,6 @@ const parseShortcodeIds = ( ids ) => {
39
38
  */
40
39
  function updateThirdPartyTransformToGallery( block ) {
41
40
  if (
42
- isGalleryV2Enabled() &&
43
41
  block.name === 'core/gallery' &&
44
42
  block.attributes?.images.length > 0
45
43
  ) {
@@ -137,37 +135,21 @@ const transforms = {
137
135
 
138
136
  const validImages = attributes.filter( ( { url } ) => url );
139
137
 
140
- if ( isGalleryV2Enabled() ) {
141
- const innerBlocks = validImages.map( ( image ) => {
142
- // Gallery images can't currently be resized so make sure height and width are undefined.
143
- image.width = undefined;
144
- image.height = undefined;
145
- return createBlock( 'core/image', image );
146
- } );
147
-
148
- return createBlock(
149
- 'core/gallery',
150
- {
151
- align,
152
- sizeSlug,
153
- },
154
- innerBlocks
155
- );
156
- }
157
-
158
- return createBlock( 'core/gallery', {
159
- images: validImages.map(
160
- ( { id, url, alt, caption } ) => ( {
161
- id: id.toString(),
162
- url,
163
- alt,
164
- caption,
165
- } )
166
- ),
167
- ids: validImages.map( ( { id } ) => parseInt( id, 10 ) ),
168
- align,
169
- sizeSlug,
138
+ const innerBlocks = validImages.map( ( image ) => {
139
+ // Gallery images can't currently be resized so make sure height and width are undefined.
140
+ image.width = undefined;
141
+ image.height = undefined;
142
+ return createBlock( 'core/image', image );
170
143
  } );
144
+
145
+ return createBlock(
146
+ 'core/gallery',
147
+ {
148
+ align,
149
+ sizeSlug,
150
+ },
151
+ innerBlocks
152
+ );
171
153
  },
172
154
  },
173
155
  {
@@ -220,23 +202,13 @@ const transforms = {
220
202
  );
221
203
  },
222
204
  transform( files ) {
223
- if ( isGalleryV2Enabled() ) {
224
- const innerBlocks = files.map( ( file ) =>
225
- createBlock( 'core/image', {
226
- url: createBlobURL( file ),
227
- } )
228
- );
205
+ const innerBlocks = files.map( ( file ) =>
206
+ createBlock( 'core/image', {
207
+ blob: createBlobURL( file ),
208
+ } )
209
+ );
229
210
 
230
- return createBlock( 'core/gallery', {}, innerBlocks );
231
- }
232
- const block = createBlock( 'core/gallery', {
233
- images: files.map( ( file ) =>
234
- pickRelevantMediaFiles( {
235
- url: createBlobURL( file ),
236
- } )
237
- ),
238
- } );
239
- return block;
211
+ return createBlock( 'core/gallery', {}, innerBlocks );
240
212
  },
241
213
  },
242
214
  ],
@@ -244,57 +216,42 @@ const transforms = {
244
216
  {
245
217
  type: 'block',
246
218
  blocks: [ 'core/image' ],
247
- transform: ( { align, images, ids, sizeSlug }, innerBlocks ) => {
248
- if ( isGalleryV2Enabled() ) {
249
- if ( innerBlocks.length > 0 ) {
250
- return innerBlocks.map(
251
- ( {
252
- attributes: {
253
- url,
254
- alt,
255
- caption,
256
- title,
257
- href,
258
- rel,
259
- linkClass,
260
- id,
261
- sizeSlug: imageSizeSlug,
262
- linkDestination,
263
- linkTarget,
264
- anchor,
265
- className,
266
- },
267
- } ) =>
268
- createBlock( 'core/image', {
269
- align,
270
- url,
271
- alt,
272
- caption,
273
- title,
274
- href,
275
- rel,
276
- linkClass,
277
- id,
278
- sizeSlug: imageSizeSlug,
279
- linkDestination,
280
- linkTarget,
281
- anchor,
282
- className,
283
- } )
284
- );
285
- }
286
- return createBlock( 'core/image', { align } );
287
- }
288
- if ( images.length > 0 ) {
289
- return images.map( ( { url, alt, caption }, index ) =>
290
- createBlock( 'core/image', {
291
- id: ids[ index ],
292
- url,
293
- alt,
294
- caption,
295
- align,
296
- sizeSlug,
297
- } )
219
+ transform: ( { align }, innerBlocks ) => {
220
+ if ( innerBlocks.length > 0 ) {
221
+ return innerBlocks.map(
222
+ ( {
223
+ attributes: {
224
+ url,
225
+ alt,
226
+ caption,
227
+ title,
228
+ href,
229
+ rel,
230
+ linkClass,
231
+ id,
232
+ sizeSlug: imageSizeSlug,
233
+ linkDestination,
234
+ linkTarget,
235
+ anchor,
236
+ className,
237
+ },
238
+ } ) =>
239
+ createBlock( 'core/image', {
240
+ align,
241
+ url,
242
+ alt,
243
+ caption,
244
+ title,
245
+ href,
246
+ rel,
247
+ linkClass,
248
+ id,
249
+ sizeSlug: imageSizeSlug,
250
+ linkDestination,
251
+ linkTarget,
252
+ anchor,
253
+ className,
254
+ } )
298
255
  );
299
256
  }
300
257
  return createBlock( 'core/image', { align } );
@@ -45,6 +45,7 @@
45
45
  "text": true
46
46
  }
47
47
  },
48
+ "shadow": true,
48
49
  "spacing": {
49
50
  "margin": [ "top", "bottom" ],
50
51
  "padding": true,
@@ -139,6 +139,13 @@ function GroupPlaceHolder( { name, onSelect } ) {
139
139
  const blockProps = useBlockProps( {
140
140
  className: 'wp-block-group__placeholder',
141
141
  } );
142
+
143
+ useEffect( () => {
144
+ if ( variations && variations.length === 1 ) {
145
+ onSelect( variations[ 0 ] );
146
+ }
147
+ }, [ onSelect, variations ] );
148
+
142
149
  return (
143
150
  <div { ...blockProps }>
144
151
  <Placeholder
@@ -9,6 +9,10 @@
9
9
  "keywords": [ "img", "photo", "picture" ],
10
10
  "textdomain": "default",
11
11
  "attributes": {
12
+ "blob": {
13
+ "type": "string",
14
+ "__experimentalRole": "local"
15
+ },
12
16
  "url": {
13
17
  "type": "string",
14
18
  "source": "attribute",