@wordpress/block-library 8.9.0 → 8.10.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 (284) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/comment-author-name/edit.js +1 -1
  3. package/build/comment-author-name/edit.js.map +1 -1
  4. package/build/comment-edit-link/edit.js +1 -1
  5. package/build/comment-edit-link/edit.js.map +1 -1
  6. package/build/cover/edit/inspector-controls.js +1 -1
  7. package/build/cover/edit/inspector-controls.js.map +1 -1
  8. package/build/cover/index.js +1 -1
  9. package/build/cover/variations.js +1 -1
  10. package/build/cover/variations.js.map +1 -1
  11. package/build/details/edit.js +19 -5
  12. package/build/details/edit.js.map +1 -1
  13. package/build/details/index.js +14 -10
  14. package/build/details/index.js.map +1 -1
  15. package/build/details/save.js +4 -1
  16. package/build/details/save.js.map +1 -1
  17. package/build/embed/variations.js +2 -2
  18. package/build/embed/variations.js.map +1 -1
  19. package/build/file/view.js +1 -1
  20. package/build/file/view.js.map +1 -1
  21. package/build/gallery/edit.js +2 -8
  22. package/build/gallery/edit.js.map +1 -1
  23. package/build/index.js +0 -6
  24. package/build/index.js.map +1 -1
  25. package/build/index.native.js +1 -1
  26. package/build/index.native.js.map +1 -1
  27. package/build/list-item/utils.js +5 -1
  28. package/build/list-item/utils.js.map +1 -1
  29. package/build/loginout/index.js +11 -1
  30. package/build/loginout/index.js.map +1 -1
  31. package/build/navigation/constants.js +13 -0
  32. package/build/navigation/constants.js.map +1 -0
  33. package/build/navigation/edit/index.js +16 -26
  34. package/build/navigation/edit/index.js.map +1 -1
  35. package/build/navigation/edit/inner-blocks.js +4 -7
  36. package/build/navigation/edit/inner-blocks.js.map +1 -1
  37. package/build/navigation/edit/unsaved-inner-blocks.js +4 -6
  38. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  39. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  40. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  41. package/build/navigation/interactivity.js +139 -0
  42. package/build/navigation/interactivity.js.map +1 -0
  43. package/build/navigation-link/edit.js +1 -1
  44. package/build/navigation-link/edit.js.map +1 -1
  45. package/build/navigation-submenu/edit.js +1 -1
  46. package/build/navigation-submenu/edit.js.map +1 -1
  47. package/build/paragraph/index.js +5 -1
  48. package/build/paragraph/index.js.map +1 -1
  49. package/build/paragraph/transforms.js +5 -1
  50. package/build/paragraph/transforms.js.map +1 -1
  51. package/build/post-author-name/edit.js +1 -1
  52. package/build/post-author-name/edit.js.map +1 -1
  53. package/build/post-featured-image/edit.js +1 -2
  54. package/build/post-featured-image/edit.js.map +1 -1
  55. package/build/post-featured-image/overlay.js +5 -0
  56. package/build/post-featured-image/overlay.js.map +1 -1
  57. package/build/post-title/edit.js +14 -4
  58. package/build/post-title/edit.js.map +1 -1
  59. package/build/preformatted/edit.native.js +3 -2
  60. package/build/preformatted/edit.native.js.map +1 -1
  61. package/build/quote/transforms.js +16 -27
  62. package/build/quote/transforms.js.map +1 -1
  63. package/build/read-more/edit.js +1 -1
  64. package/build/read-more/edit.js.map +1 -1
  65. package/build/search/edit.js +9 -1
  66. package/build/search/edit.js.map +1 -1
  67. package/build/site-title/edit/index.js +1 -1
  68. package/build/site-title/edit/index.js.map +1 -1
  69. package/build/social-links/edit.js +2 -2
  70. package/build/social-links/edit.js.map +1 -1
  71. package/build/utils/interactivity/constants.js +9 -0
  72. package/build/utils/interactivity/constants.js.map +1 -0
  73. package/build/utils/interactivity/directives.js +208 -0
  74. package/build/utils/interactivity/directives.js.map +1 -0
  75. package/build/utils/interactivity/hooks.js +112 -0
  76. package/build/utils/interactivity/hooks.js.map +1 -0
  77. package/build/utils/interactivity/hydration.js +34 -0
  78. package/build/utils/interactivity/hydration.js.map +1 -0
  79. package/build/utils/interactivity/index.js +34 -0
  80. package/build/utils/interactivity/index.js.map +1 -0
  81. package/build/utils/interactivity/store.js +67 -0
  82. package/build/utils/interactivity/store.js.map +1 -0
  83. package/build/utils/interactivity/utils.js +87 -0
  84. package/build/utils/interactivity/utils.js.map +1 -0
  85. package/build/utils/interactivity/vdom.js +109 -0
  86. package/build/utils/interactivity/vdom.js.map +1 -0
  87. package/build-module/comment-author-name/edit.js +1 -1
  88. package/build-module/comment-author-name/edit.js.map +1 -1
  89. package/build-module/comment-edit-link/edit.js +1 -1
  90. package/build-module/comment-edit-link/edit.js.map +1 -1
  91. package/build-module/cover/edit/inspector-controls.js +1 -1
  92. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  93. package/build-module/cover/index.js +1 -1
  94. package/build-module/cover/variations.js +1 -1
  95. package/build-module/cover/variations.js.map +1 -1
  96. package/build-module/details/edit.js +20 -6
  97. package/build-module/details/edit.js.map +1 -1
  98. package/build-module/details/index.js +14 -10
  99. package/build-module/details/index.js.map +1 -1
  100. package/build-module/details/save.js +5 -2
  101. package/build-module/details/save.js.map +1 -1
  102. package/build-module/embed/variations.js +2 -2
  103. package/build-module/embed/variations.js.map +1 -1
  104. package/build-module/file/view.js +1 -1
  105. package/build-module/file/view.js.map +1 -1
  106. package/build-module/gallery/edit.js +2 -8
  107. package/build-module/gallery/edit.js.map +1 -1
  108. package/build-module/index.js +0 -4
  109. package/build-module/index.js.map +1 -1
  110. package/build-module/index.native.js +1 -1
  111. package/build-module/index.native.js.map +1 -1
  112. package/build-module/list-item/utils.js +5 -1
  113. package/build-module/list-item/utils.js.map +1 -1
  114. package/build-module/loginout/index.js +11 -1
  115. package/build-module/loginout/index.js.map +1 -1
  116. package/build-module/navigation/constants.js +5 -0
  117. package/build-module/navigation/constants.js.map +1 -0
  118. package/build-module/navigation/edit/index.js +18 -27
  119. package/build-module/navigation/edit/index.js.map +1 -1
  120. package/build-module/navigation/edit/inner-blocks.js +1 -4
  121. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  122. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -4
  123. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  124. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  125. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  126. package/build-module/navigation/interactivity.js +136 -0
  127. package/build-module/navigation/interactivity.js.map +1 -0
  128. package/build-module/navigation-link/edit.js +1 -1
  129. package/build-module/navigation-link/edit.js.map +1 -1
  130. package/build-module/navigation-submenu/edit.js +1 -1
  131. package/build-module/navigation-submenu/edit.js.map +1 -1
  132. package/build-module/paragraph/index.js +5 -1
  133. package/build-module/paragraph/index.js.map +1 -1
  134. package/build-module/paragraph/transforms.js +5 -1
  135. package/build-module/paragraph/transforms.js.map +1 -1
  136. package/build-module/post-author-name/edit.js +1 -1
  137. package/build-module/post-author-name/edit.js.map +1 -1
  138. package/build-module/post-featured-image/edit.js +1 -2
  139. package/build-module/post-featured-image/edit.js.map +1 -1
  140. package/build-module/post-featured-image/overlay.js +5 -0
  141. package/build-module/post-featured-image/overlay.js.map +1 -1
  142. package/build-module/post-title/edit.js +13 -4
  143. package/build-module/post-title/edit.js.map +1 -1
  144. package/build-module/preformatted/edit.native.js +3 -2
  145. package/build-module/preformatted/edit.native.js.map +1 -1
  146. package/build-module/quote/transforms.js +16 -27
  147. package/build-module/quote/transforms.js.map +1 -1
  148. package/build-module/read-more/edit.js +1 -1
  149. package/build-module/read-more/edit.js.map +1 -1
  150. package/build-module/search/edit.js +9 -1
  151. package/build-module/search/edit.js.map +1 -1
  152. package/build-module/site-title/edit/index.js +1 -1
  153. package/build-module/site-title/edit/index.js.map +1 -1
  154. package/build-module/social-links/edit.js +2 -2
  155. package/build-module/social-links/edit.js.map +1 -1
  156. package/build-module/utils/interactivity/constants.js +2 -0
  157. package/build-module/utils/interactivity/constants.js.map +1 -0
  158. package/build-module/utils/interactivity/directives.js +193 -0
  159. package/build-module/utils/interactivity/directives.js.map +1 -0
  160. package/build-module/utils/interactivity/hooks.js +98 -0
  161. package/build-module/utils/interactivity/hooks.js.map +1 -0
  162. package/build-module/utils/interactivity/hydration.js +21 -0
  163. package/build-module/utils/interactivity/hydration.js.map +1 -0
  164. package/build-module/utils/interactivity/index.js +17 -0
  165. package/build-module/utils/interactivity/index.js.map +1 -0
  166. package/build-module/utils/interactivity/store.js +56 -0
  167. package/build-module/utils/interactivity/store.js.map +1 -0
  168. package/build-module/utils/interactivity/utils.js +75 -0
  169. package/build-module/utils/interactivity/utils.js.map +1 -0
  170. package/build-module/utils/interactivity/vdom.js +97 -0
  171. package/build-module/utils/interactivity/vdom.js.map +1 -0
  172. package/build-style/cover/style-rtl.css +2 -0
  173. package/build-style/cover/style.css +2 -0
  174. package/build-style/{details-summary → details}/editor-rtl.css +1 -1
  175. package/build-style/{details-summary → details}/editor.css +1 -1
  176. package/build-style/details/style-rtl.css +14 -0
  177. package/build-style/details/style.css +14 -0
  178. package/build-style/editor-rtl.css +3 -5
  179. package/build-style/editor.css +3 -5
  180. package/build-style/gallery/editor-rtl.css +0 -4
  181. package/build-style/gallery/editor.css +0 -4
  182. package/build-style/search/editor-rtl.css +1 -0
  183. package/build-style/search/editor.css +1 -0
  184. package/build-style/site-logo/editor-rtl.css +1 -0
  185. package/build-style/site-logo/editor.css +1 -0
  186. package/build-style/style-rtl.css +13 -1
  187. package/build-style/style.css +13 -1
  188. package/package.json +36 -32
  189. package/src/comment-author-name/edit.js +1 -1
  190. package/src/comment-edit-link/edit.js +1 -1
  191. package/src/comment-template/index.php +8 -7
  192. package/src/cover/block.json +1 -1
  193. package/src/cover/edit/inspector-controls.js +56 -54
  194. package/src/cover/style.scss +5 -0
  195. package/src/cover/test/edit.js +56 -2
  196. package/src/cover/variations.js +1 -3
  197. package/src/details/block.json +8 -6
  198. package/src/details/edit.js +27 -5
  199. package/src/details/editor.scss +3 -0
  200. package/src/details/index.js +10 -5
  201. package/src/details/save.js +5 -1
  202. package/src/details/style.scss +16 -0
  203. package/src/editor.scss +1 -1
  204. package/src/embed/variations.js +2 -2
  205. package/src/file/view.js +4 -1
  206. package/src/gallery/edit.js +5 -8
  207. package/src/gallery/editor.scss +0 -6
  208. package/src/gallery/test/index.native.js +48 -3
  209. package/src/image/test/edit.native.js +38 -16
  210. package/src/index.js +0 -4
  211. package/src/index.native.js +1 -0
  212. package/src/loginout/block.json +11 -1
  213. package/src/navigation/constants.js +16 -0
  214. package/src/navigation/edit/index.js +71 -83
  215. package/src/navigation/edit/inner-blocks.js +1 -16
  216. package/src/navigation/edit/unsaved-inner-blocks.js +1 -16
  217. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  218. package/src/navigation/index.php +209 -203
  219. package/src/navigation/interactivity.js +144 -0
  220. package/src/navigation-link/edit.js +1 -1
  221. package/src/navigation-submenu/edit.js +1 -1
  222. package/src/paragraph/block.json +5 -1
  223. package/src/post-author-name/edit.js +1 -1
  224. package/src/post-featured-image/edit.js +1 -1
  225. package/src/post-featured-image/index.php +1 -1
  226. package/src/post-featured-image/overlay.js +4 -0
  227. package/src/post-terms/index.php +2 -2
  228. package/src/post-title/edit.js +8 -1
  229. package/src/preformatted/edit.native.js +1 -3
  230. package/src/quote/transforms.js +0 -6
  231. package/src/read-more/edit.js +1 -1
  232. package/src/search/edit.js +9 -4
  233. package/src/search/editor.scss +1 -0
  234. package/src/site-logo/editor.scss +2 -1
  235. package/src/site-title/edit/index.js +1 -1
  236. package/src/social-links/edit.js +33 -31
  237. package/src/style.scss +0 -1
  238. package/src/template-part/index.php +20 -5
  239. package/src/utils/interactivity/constants.js +1 -0
  240. package/src/utils/interactivity/directives.js +179 -0
  241. package/src/utils/interactivity/hooks.js +76 -0
  242. package/src/utils/interactivity/hydration.js +22 -0
  243. package/src/utils/interactivity/index.js +17 -0
  244. package/src/utils/interactivity/store.js +45 -0
  245. package/src/utils/interactivity/utils.js +66 -0
  246. package/src/utils/interactivity/vdom.js +94 -0
  247. package/tsconfig.json +1 -0
  248. package/tsconfig.tsbuildinfo +1 -1
  249. package/build/details-content/edit.js +0 -34
  250. package/build/details-content/edit.js.map +0 -1
  251. package/build/details-content/index.js +0 -94
  252. package/build/details-content/index.js.map +0 -1
  253. package/build/details-content/save.js +0 -20
  254. package/build/details-content/save.js.map +0 -1
  255. package/build/details-summary/edit.js +0 -42
  256. package/build/details-summary/edit.js.map +0 -1
  257. package/build/details-summary/index.js +0 -97
  258. package/build/details-summary/index.js.map +0 -1
  259. package/build/details-summary/save.js +0 -24
  260. package/build/details-summary/save.js.map +0 -1
  261. package/build-module/details-content/edit.js +0 -23
  262. package/build-module/details-content/edit.js.map +0 -1
  263. package/build-module/details-content/index.js +0 -76
  264. package/build-module/details-content/index.js.map +0 -1
  265. package/build-module/details-content/save.js +0 -11
  266. package/build-module/details-content/save.js.map +0 -1
  267. package/build-module/details-summary/edit.js +0 -30
  268. package/build-module/details-summary/edit.js.map +0 -1
  269. package/build-module/details-summary/index.js +0 -79
  270. package/build-module/details-summary/index.js.map +0 -1
  271. package/build-module/details-summary/save.js +0 -16
  272. package/build-module/details-summary/save.js.map +0 -1
  273. package/build-style/details-summary/style-rtl.css +0 -91
  274. package/build-style/details-summary/style.css +0 -91
  275. package/src/details-content/block.json +0 -50
  276. package/src/details-content/edit.js +0 -29
  277. package/src/details-content/index.js +0 -23
  278. package/src/details-content/save.js +0 -12
  279. package/src/details-summary/block.json +0 -53
  280. package/src/details-summary/edit.js +0 -27
  281. package/src/details-summary/editor.scss +0 -3
  282. package/src/details-summary/index.js +0 -23
  283. package/src/details-summary/save.js +0 -13
  284. package/src/details-summary/style.scss +0 -3
@@ -5,28 +5,29 @@
5
5
  "name": "core/details",
6
6
  "title": "Details",
7
7
  "category": "text",
8
- "description": "A block that displays a summary and shows or hides additional content.",
9
- "keywords": [ "disclosure", "summary", "hide", "transcript" ],
8
+ "description": "Hide and show additional content.",
9
+ "keywords": [ "disclosure", "summary", "hide", "accordion" ],
10
10
  "textdomain": "default",
11
11
  "attributes": {
12
12
  "showContent": {
13
13
  "type": "boolean",
14
14
  "default": false
15
+ },
16
+ "summary": {
17
+ "type": "string"
15
18
  }
16
19
  },
17
20
  "supports": {
18
- "align": true,
21
+ "align": [ "wide", "full" ],
19
22
  "color": {
20
23
  "gradients": true,
21
24
  "link": true,
22
25
  "__experimentalDefaultControls": {
23
26
  "background": true,
24
- "text": true,
25
- "link": true
27
+ "text": true
26
28
  }
27
29
  },
28
30
  "__experimentalBorder": {
29
- "radius": true,
30
31
  "color": true,
31
32
  "width": true,
32
33
  "style": true
@@ -50,5 +51,6 @@
50
51
  }
51
52
  }
52
53
  },
54
+ "editorStyle": "wp-block-details-editor",
53
55
  "style": "wp-block-details"
54
56
  }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
+ RichText,
5
6
  useBlockProps,
6
7
  useInnerBlocksProps,
7
8
  store as blockEditorStore,
@@ -11,15 +12,21 @@ import { useSelect } from '@wordpress/data';
11
12
  import { PanelBody, ToggleControl } from '@wordpress/components';
12
13
  import { __ } from '@wordpress/i18n';
13
14
 
14
- const TEMPLATE = [ [ 'core/details-summary' ], [ 'core/details-content' ] ];
15
+ const TEMPLATE = [
16
+ [
17
+ 'core/paragraph',
18
+ {
19
+ placeholder: __( 'Type / to add a hidden block' ),
20
+ },
21
+ ],
22
+ ];
15
23
 
16
24
  function DetailsEdit( { attributes, setAttributes, clientId } ) {
17
- const { showContent } = attributes;
25
+ const { showContent, summary } = attributes;
18
26
  const blockProps = useBlockProps();
19
27
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
20
- allowedBlocks: TEMPLATE,
21
28
  template: TEMPLATE,
22
- templateLock: 'all',
29
+ __experimentalCaptureToolbars: true,
23
30
  } );
24
31
 
25
32
  // Check if either the block or the inner blocks are selected.
@@ -51,7 +58,22 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
51
58
  <details
52
59
  { ...innerBlocksProps }
53
60
  open={ hasSelection || showContent }
54
- ></details>
61
+ >
62
+ <summary onClick={ ( event ) => event.preventDefault() }>
63
+ <RichText
64
+ aria-label={ __( 'Write summary' ) }
65
+ placeholder={ __( 'Write summary…' ) }
66
+ allowedFormats={ [] }
67
+ withoutInteractiveFormatting
68
+ value={ summary }
69
+ onChange={ ( newSummary ) =>
70
+ setAttributes( { summary: newSummary } )
71
+ }
72
+ multiline={ false }
73
+ />
74
+ </summary>
75
+ { innerBlocksProps.children }
76
+ </details>
55
77
  </>
56
78
  );
57
79
  }
@@ -0,0 +1,3 @@
1
+ .wp-block-details summary div {
2
+ display: inline;
3
+ }
@@ -18,13 +18,18 @@ export { metadata, name };
18
18
  export const settings = {
19
19
  icon,
20
20
  example: {
21
+ attributes: {
22
+ summary: 'La Mancha',
23
+ showContent: true,
24
+ },
21
25
  innerBlocks: [
22
26
  {
23
- name: 'core/details-summary',
24
- attributes: { summary: __( 'Details' ) },
25
- },
26
- {
27
- name: 'core/details-content',
27
+ name: 'core/paragraph',
28
+ attributes: {
29
+ content: __(
30
+ 'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'
31
+ ),
32
+ },
28
33
  },
29
34
  ],
30
35
  },
@@ -1,14 +1,18 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
4
+ import { RichText, useBlockProps, InnerBlocks } from '@wordpress/block-editor';
5
5
 
6
6
  export default function save( { attributes } ) {
7
7
  const { showContent } = attributes;
8
+ const summary = attributes.summary ? attributes.summary : 'Details';
8
9
  const blockProps = useBlockProps.save();
9
10
 
10
11
  return (
11
12
  <details { ...blockProps } open={ showContent }>
13
+ <summary>
14
+ <RichText.Content value={ summary } />
15
+ </summary>
12
16
  <InnerBlocks.Content />
13
17
  </details>
14
18
  );
@@ -1,3 +1,19 @@
1
1
  .wp-block-details {
2
+ box-sizing: border-box;
2
3
  overflow: hidden;
3
4
  }
5
+
6
+ .wp-block-details summary {
7
+ cursor: pointer;
8
+ }
9
+
10
+ // Use block gap for block; falls back to browser default if not supported.
11
+ .wp-block-details > *:not(summary) {
12
+ margin-block-start: var(--wp--style--block-gap);
13
+ margin-block-end: 0;
14
+ }
15
+
16
+ // Remove excess margin from the last block.
17
+ .wp-block-details > *:last-child {
18
+ margin-bottom: 0;
19
+ }
package/src/editor.scss CHANGED
@@ -13,7 +13,7 @@
13
13
  @import "./comments-pagination-numbers/editor.scss";
14
14
  @import "./comments-title/editor.scss";
15
15
  @import "./cover/editor.scss";
16
- @import "./details-summary/editor.scss";
16
+ @import "./details/editor.scss";
17
17
  @import "./embed/editor.scss";
18
18
  @import "./file/editor.scss";
19
19
  @import "./freeform/editor.scss";
@@ -218,13 +218,13 @@ const variations = [
218
218
  attributes: { providerNameSlug: 'mixcloud', responsive: true },
219
219
  },
220
220
  {
221
- name: 'pocketcasts',
221
+ name: 'pocket-casts',
222
222
  title: 'Pocket Casts',
223
223
  icon: embedPocketCastsIcon,
224
224
  keywords: [ __( 'podcast' ), __( 'audio' ) ],
225
225
  description: __( 'Embed a podcast player from Pocket Casts.' ),
226
226
  patterns: [ /^https:\/\/pca.st\/\w+/i ],
227
- attributes: { providerNameSlug: 'pocketcasts', responsive: true },
227
+ attributes: { providerNameSlug: 'pocket-casts', responsive: true },
228
228
  },
229
229
  {
230
230
  name: 'reddit',
package/src/file/view.js CHANGED
@@ -3,4 +3,7 @@
3
3
  */
4
4
  import { hidePdfEmbedsOnUnsupportedBrowsers } from './utils';
5
5
 
6
- hidePdfEmbedsOnUnsupportedBrowsers();
6
+ document.addEventListener(
7
+ 'DOMContentLoaded',
8
+ hidePdfEmbedsOnUnsupportedBrowsers
9
+ );
@@ -127,7 +127,6 @@ function GalleryEdit( props ) {
127
127
  replaceInnerBlocks,
128
128
  updateBlockAttributes,
129
129
  selectBlock,
130
- clearSelectedBlock,
131
130
  } = useDispatch( blockEditorStore );
132
131
  const { createSuccessNotice, createErrorNotice } =
133
132
  useDispatch( noticesStore );
@@ -186,9 +185,6 @@ function GalleryEdit( props ) {
186
185
  align: undefined,
187
186
  } );
188
187
  } );
189
- if ( newImages?.length > 0 ) {
190
- clearSelectedBlock();
191
- }
192
188
  }, [ newImages ] );
193
189
 
194
190
  const imageSizeOptions = useImageSizes(
@@ -343,10 +339,6 @@ function GalleryEdit( props ) {
343
339
  } );
344
340
  } );
345
341
 
346
- if ( newBlocks?.length > 0 ) {
347
- selectBlock( newBlocks[ 0 ].clientId );
348
- }
349
-
350
342
  replaceInnerBlocks(
351
343
  clientId,
352
344
  existingImageBlocks
@@ -357,6 +349,11 @@ function GalleryEdit( props ) {
357
349
  newOrderMap[ b.attributes.id ]
358
350
  )
359
351
  );
352
+
353
+ // Select the first block to scroll into view when new blocks are added.
354
+ if ( newBlocks?.length > 0 ) {
355
+ selectBlock( newBlocks[ 0 ].clientId );
356
+ }
360
357
  }
361
358
 
362
359
  function onUploadError( message ) {
@@ -4,12 +4,6 @@ figure.wp-block-gallery {
4
4
  // See https://github.com/WordPress/gutenberg/pull/10358
5
5
 
6
6
  display: block;
7
- &.has-nested-images {
8
- .components-drop-zone {
9
- display: none;
10
- pointer-events: none;
11
- }
12
- }
13
7
 
14
8
  > .blocks-gallery-caption {
15
9
  flex: 0 0 100%;
@@ -14,7 +14,9 @@ import {
14
14
  setupMediaUpload,
15
15
  triggerBlockListLayout,
16
16
  within,
17
+ setupPicker,
17
18
  } from 'test/helpers';
19
+ import { ActionSheetIOS } from 'react-native';
18
20
 
19
21
  /**
20
22
  * WordPress dependencies
@@ -36,6 +38,12 @@ import {
36
38
  generateGalleryBlock,
37
39
  } from './helpers';
38
40
 
41
+ const MEDIA_OPTIONS = [
42
+ 'Choose from device',
43
+ 'Take a Photo',
44
+ 'WordPress Media Library',
45
+ ];
46
+
39
47
  const media = [
40
48
  {
41
49
  localId: 1,
@@ -96,9 +104,44 @@ describe( 'Gallery block', () => {
96
104
  expect( getByText( 'WordPress Media Library' ) ).toBeVisible();
97
105
  } );
98
106
 
107
+ it( 'displays correct media options picker', async () => {
108
+ // Initialize with an empty gallery
109
+ const screen = await initializeEditor( {
110
+ initialHtml: generateGalleryBlock( 0 ),
111
+ } );
112
+ const { getByText } = screen;
113
+
114
+ // Tap on Gallery block
115
+ const block = await getBlock( screen, 'Gallery' );
116
+ fireEvent.press( block );
117
+ fireEvent.press( within( block ).getByText( 'ADD MEDIA' ) );
118
+
119
+ // Observe that media options picker is displayed
120
+ /* eslint-disable jest/no-conditional-expect */
121
+ if ( Platform.isIOS ) {
122
+ // On iOS the picker is rendered natively, so we have
123
+ // to check the arguments passed to `ActionSheetIOS`.
124
+ expect(
125
+ ActionSheetIOS.showActionSheetWithOptions
126
+ ).toHaveBeenCalledWith(
127
+ expect.objectContaining( {
128
+ title: 'Choose images',
129
+ options: [ 'Cancel', ...MEDIA_OPTIONS ],
130
+ } ),
131
+ expect.any( Function )
132
+ );
133
+ } else {
134
+ expect( getByText( 'Choose images' ) ).toBeVisible();
135
+ MEDIA_OPTIONS.forEach( ( option ) =>
136
+ expect( getByText( option ) ).toBeVisible()
137
+ );
138
+ }
139
+ /* eslint-enable jest/no-conditional-expect */
140
+ } );
141
+
99
142
  // This case is disabled until the issue (https://github.com/WordPress/gutenberg/issues/38444)
100
143
  // is addressed.
101
- it.skip( 'displays media options picker when selecting the block', async () => {
144
+ it.skip( 'block remains selected after dimissing the media options picker', async () => {
102
145
  // Initialize with an empty gallery
103
146
  const { getByLabelText, getByText, getByTestId } =
104
147
  await initializeEditor( {
@@ -213,11 +256,13 @@ describe( 'Gallery block', () => {
213
256
  setupMediaPicker();
214
257
 
215
258
  // Initialize with an empty gallery
216
- const { galleryBlock, getByText } = await initializeWithGalleryBlock();
259
+ const screen = await initializeWithGalleryBlock();
260
+ const { galleryBlock, getByText } = screen;
261
+ const { selectOption } = setupPicker( screen, MEDIA_OPTIONS );
217
262
 
218
263
  // Upload images from device
219
264
  fireEvent.press( getByText( 'ADD MEDIA' ) );
220
- fireEvent.press( getByText( 'Choose from device' ) );
265
+ selectOption( 'Choose from device' );
221
266
  expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
222
267
 
223
268
  // Return media items picked
@@ -8,6 +8,7 @@ import {
8
8
  getEditorHtml,
9
9
  render,
10
10
  waitFor,
11
+ setupApiFetch,
11
12
  } from 'test/helpers';
12
13
  import { Image } from 'react-native';
13
14
  import Clipboard from '@react-native-clipboard/clipboard';
@@ -22,9 +23,10 @@ import {
22
23
  sendMediaUpload,
23
24
  subscribeMediaUpload,
24
25
  } from '@wordpress/react-native-bridge';
25
- import { select } from '@wordpress/data';
26
+ import { select, dispatch } from '@wordpress/data';
26
27
  import { store as editorStore } from '@wordpress/editor';
27
28
  import { store as coreStore } from '@wordpress/core-data';
29
+ import apiFetch from '@wordpress/api-fetch';
28
30
  import '@wordpress/jest-console';
29
31
 
30
32
  /**
@@ -45,7 +47,15 @@ function mockGetMedia( media ) {
45
47
  jest.spyOn( select( coreStore ), 'getMedia' ).mockReturnValue( media );
46
48
  }
47
49
 
48
- const apiFetchPromise = Promise.resolve( {} );
50
+ const FETCH_MEDIA = {
51
+ request: {
52
+ path: `/wp/v2/media/1?context=edit`,
53
+ },
54
+ response: {
55
+ source_url: 'https://cldup.com/cXyG__fTLN.jpg',
56
+ id: 1,
57
+ },
58
+ };
49
59
 
50
60
  const clipboardPromise = Promise.resolve( '' );
51
61
  Clipboard.getString.mockImplementation( () => clipboardPromise );
@@ -58,6 +68,18 @@ beforeAll( () => {
58
68
  getSizeSpy.mockImplementation( ( _url, callback ) => callback( 300, 200 ) );
59
69
  } );
60
70
 
71
+ beforeEach( () => {
72
+ // Mock media fetch requests
73
+ setupApiFetch( [ FETCH_MEDIA ] );
74
+
75
+ // Invalidate `getMedia` resolutions to allow requesting to the API the same media id
76
+ dispatch( coreStore ).invalidateResolutionForStoreSelector( 'getMedia' );
77
+ } );
78
+
79
+ afterEach( () => {
80
+ apiFetch.mockReset();
81
+ } );
82
+
61
83
  afterAll( () => {
62
84
  getBlockTypes().forEach( ( { name } ) => {
63
85
  unregisterBlockType( name );
@@ -78,8 +100,8 @@ describe( 'Image Block', () => {
78
100
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
79
101
  <!-- /wp:image -->`;
80
102
  const screen = await initializeEditor( { initialHtml } );
81
- // We must await the image fetch via `getMedia`
82
- await act( () => apiFetchPromise );
103
+ // Check that image is fetched via `getMedia`
104
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
83
105
 
84
106
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
85
107
  fireEvent.press( imageBlock );
@@ -105,8 +127,8 @@ describe( 'Image Block', () => {
105
127
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
106
128
  <!-- /wp:image -->`;
107
129
  const screen = await initializeEditor( { initialHtml } );
108
- // We must await the image fetch via `getMedia`
109
- await act( () => apiFetchPromise );
130
+ // Check that image is fetched via `getMedia`
131
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
110
132
 
111
133
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
112
134
  fireEvent.press( imageBlock );
@@ -132,8 +154,8 @@ describe( 'Image Block', () => {
132
154
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
133
155
  <!-- /wp:image -->`;
134
156
  const screen = await initializeEditor( { initialHtml } );
135
- // We must await the image fetch via `getMedia`
136
- await act( () => apiFetchPromise );
157
+ // Check that image is fetched via `getMedia`
158
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
137
159
 
138
160
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
139
161
  fireEvent.press( imageBlock );
@@ -169,8 +191,8 @@ describe( 'Image Block', () => {
169
191
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
170
192
  <!-- /wp:image -->`;
171
193
  const screen = await initializeEditor( { initialHtml } );
172
- // We must await the image fetch via `getMedia`
173
- await act( () => apiFetchPromise );
194
+ // Check that image is fetched via `getMedia`
195
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
174
196
 
175
197
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
176
198
  fireEvent.press( imageBlock );
@@ -211,8 +233,8 @@ describe( 'Image Block', () => {
211
233
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
212
234
  <!-- /wp:image -->`;
213
235
  const screen = await initializeEditor( { initialHtml } );
214
- // We must await the image fetch via `getMedia`
215
- await act( () => apiFetchPromise );
236
+ // Check that image is not fetched via `getMedia` due to the presence of query parameters in the URL.
237
+ expect( apiFetch ).not.toHaveBeenCalledWith( FETCH_MEDIA.request );
216
238
 
217
239
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
218
240
  fireEvent.press( imageBlock );
@@ -236,8 +258,8 @@ describe( 'Image Block', () => {
236
258
  <figcaption class="wp-element-caption">Mountain</figcaption></figure>
237
259
  <!-- /wp:image -->`;
238
260
  const screen = await initializeEditor( { initialHtml } );
239
- // We must await the image fetch via `getMedia`
240
- await act( () => apiFetchPromise );
261
+ // Check that image is fetched via `getMedia`
262
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
241
263
 
242
264
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
243
265
  fireEvent.press( imageBlock );
@@ -267,8 +289,8 @@ describe( 'Image Block', () => {
267
289
  </figure>
268
290
  <!-- /wp:image -->`;
269
291
  const screen = await initializeEditor( { initialHtml } );
270
- // We must await the image fetch via `getMedia`
271
- await act( () => apiFetchPromise );
292
+ // Check that image is fetched via `getMedia`
293
+ expect( apiFetch ).toHaveBeenCalledWith( FETCH_MEDIA.request );
272
294
 
273
295
  const [ imageBlock ] = screen.getAllByLabelText( /Image Block/ );
274
296
  fireEvent.press( imageBlock );
package/src/index.js CHANGED
@@ -46,8 +46,6 @@ import * as commentsPaginationNumbers from './comments-pagination-numbers';
46
46
  import * as commentsTitle from './comments-title';
47
47
  import * as cover from './cover';
48
48
  import * as details from './details';
49
- import * as detailsContent from './details-content';
50
- import * as detailsSummary from './details-summary';
51
49
  import * as embed from './embed';
52
50
  import * as file from './file';
53
51
  import * as gallery from './gallery';
@@ -230,8 +228,6 @@ const getAllBlocks = () => {
230
228
  ];
231
229
  if ( window?.__experimentalEnableDetailsBlocks ) {
232
230
  blocks.push( details );
233
- blocks.push( detailsContent );
234
- blocks.push( detailsSummary );
235
231
  }
236
232
  return blocks.filter( Boolean );
237
233
  };
@@ -88,6 +88,7 @@ export const coreBlocks = [
88
88
  column,
89
89
  cover,
90
90
  embed,
91
+ group,
91
92
  file,
92
93
  html,
93
94
  mediaText,
@@ -21,7 +21,17 @@
21
21
  "anchor": true,
22
22
  "className": true,
23
23
  "typography": {
24
- "fontSize": false
24
+ "fontSize": true,
25
+ "lineHeight": true,
26
+ "__experimentalFontFamily": true,
27
+ "__experimentalFontWeight": true,
28
+ "__experimentalFontStyle": true,
29
+ "__experimentalTextTransform": true,
30
+ "__experimentalTextDecoration": true,
31
+ "__experimentalLetterSpacing": true,
32
+ "__experimentalDefaultControls": {
33
+ "fontSize": true
34
+ }
25
35
  }
26
36
  }
27
37
  }
@@ -0,0 +1,16 @@
1
+ export const DEFAULT_BLOCK = {
2
+ name: 'core/navigation-link',
3
+ };
4
+
5
+ export const ALLOWED_BLOCKS = [
6
+ 'core/navigation-link',
7
+ 'core/search',
8
+ 'core/social-links',
9
+ 'core/page-list',
10
+ 'core/spacer',
11
+ 'core/home-link',
12
+ 'core/site-title',
13
+ 'core/site-logo',
14
+ 'core/navigation-submenu',
15
+ 'core/loginout',
16
+ ];