@wordpress/block-library 8.7.0 → 8.8.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 (270) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/column/index.js +2 -1
  3. package/build/column/index.js.map +1 -1
  4. package/build/columns/edit.js +24 -6
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/columns/index.js +2 -1
  7. package/build/columns/index.js.map +1 -1
  8. package/build/columns/utils.js +4 -9
  9. package/build/columns/utils.js.map +1 -1
  10. package/build/cover/edit/index.js +46 -50
  11. package/build/cover/edit/index.js.map +1 -1
  12. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  13. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  14. package/build/cover/index.js +12 -0
  15. package/build/cover/index.js.map +1 -1
  16. package/build/details/edit.js +67 -0
  17. package/build/details/edit.js.map +1 -0
  18. package/build/details/index.js +110 -0
  19. package/build/details/index.js.map +1 -0
  20. package/build/details/save.js +33 -0
  21. package/build/details/save.js.map +1 -0
  22. package/build/details-content/edit.js +34 -0
  23. package/build/details-content/edit.js.map +1 -0
  24. package/build/details-content/index.js +94 -0
  25. package/build/details-content/index.js.map +1 -0
  26. package/build/details-content/save.js +20 -0
  27. package/build/details-content/save.js.map +1 -0
  28. package/build/details-summary/edit.js +42 -0
  29. package/build/details-summary/edit.js.map +1 -0
  30. package/build/details-summary/index.js +97 -0
  31. package/build/details-summary/index.js.map +1 -0
  32. package/build/details-summary/save.js +24 -0
  33. package/build/details-summary/save.js.map +1 -0
  34. package/build/embed/deprecated.js +4 -1
  35. package/build/embed/deprecated.js.map +1 -1
  36. package/build/embed/embed-link-settings.native.js +1 -1
  37. package/build/embed/embed-link-settings.native.js.map +1 -1
  38. package/build/embed/embed-placeholder.js +1 -1
  39. package/build/embed/embed-placeholder.js.map +1 -1
  40. package/build/embed/index.js +4 -1
  41. package/build/embed/index.js.map +1 -1
  42. package/build/embed/transforms.js +4 -1
  43. package/build/embed/transforms.js.map +1 -1
  44. package/build/embed/util.js +4 -1
  45. package/build/embed/util.js.map +1 -1
  46. package/build/file/edit.native.js +0 -2
  47. package/build/file/edit.native.js.map +1 -1
  48. package/build/gallery/use-get-media.native.js +2 -1
  49. package/build/gallery/use-get-media.native.js.map +1 -1
  50. package/build/image/index.js +4 -2
  51. package/build/image/index.js.map +1 -1
  52. package/build/index.js +24 -6
  53. package/build/index.js.map +1 -1
  54. package/build/media-text/media-container.js +2 -6
  55. package/build/media-text/media-container.js.map +1 -1
  56. package/build/media-text/media-container.native.js +3 -3
  57. package/build/media-text/media-container.native.js.map +1 -1
  58. package/build/navigation/deprecated.js +8 -11
  59. package/build/navigation/deprecated.js.map +1 -1
  60. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  61. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  62. package/build/post-author/index.js +0 -1
  63. package/build/post-author/index.js.map +1 -1
  64. package/build/post-featured-image/dimension-controls.js +2 -1
  65. package/build/post-featured-image/dimension-controls.js.map +1 -1
  66. package/build/post-featured-image/edit.js +8 -22
  67. package/build/post-featured-image/edit.js.map +1 -1
  68. package/build/post-time-to-read/edit.js +1 -1
  69. package/build/post-time-to-read/edit.js.map +1 -1
  70. package/build/post-time-to-read/index.js +7 -0
  71. package/build/post-time-to-read/index.js.map +1 -1
  72. package/build/spacer/controls.js +25 -6
  73. package/build/spacer/controls.js.map +1 -1
  74. package/build/spacer/edit.js +14 -4
  75. package/build/spacer/edit.js.map +1 -1
  76. package/build/spacer/save.js +2 -2
  77. package/build/spacer/save.js.map +1 -1
  78. package/build/table/state.js +35 -35
  79. package/build/table/state.js.map +1 -1
  80. package/build/term-description/index.js +1 -2
  81. package/build/term-description/index.js.map +1 -1
  82. package/build/utils/clean-empty-object.js +5 -2
  83. package/build/utils/clean-empty-object.js.map +1 -1
  84. package/build-module/column/index.js +2 -1
  85. package/build-module/column/index.js.map +1 -1
  86. package/build-module/columns/edit.js +24 -6
  87. package/build-module/columns/edit.js.map +1 -1
  88. package/build-module/columns/index.js +2 -1
  89. package/build-module/columns/index.js.map +1 -1
  90. package/build-module/columns/utils.js +4 -8
  91. package/build-module/columns/utils.js.map +1 -1
  92. package/build-module/cover/edit/index.js +48 -52
  93. package/build-module/cover/edit/index.js.map +1 -1
  94. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  95. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  96. package/build-module/cover/index.js +12 -0
  97. package/build-module/cover/index.js.map +1 -1
  98. package/build-module/details/edit.js +52 -0
  99. package/build-module/details/edit.js.map +1 -0
  100. package/build-module/details/index.js +91 -0
  101. package/build-module/details/index.js.map +1 -0
  102. package/build-module/details/save.js +20 -0
  103. package/build-module/details/save.js.map +1 -0
  104. package/build-module/details-content/edit.js +23 -0
  105. package/build-module/details-content/edit.js.map +1 -0
  106. package/build-module/details-content/index.js +76 -0
  107. package/build-module/details-content/index.js.map +1 -0
  108. package/build-module/details-content/save.js +11 -0
  109. package/build-module/details-content/save.js.map +1 -0
  110. package/build-module/details-summary/edit.js +30 -0
  111. package/build-module/details-summary/edit.js.map +1 -0
  112. package/build-module/details-summary/index.js +79 -0
  113. package/build-module/details-summary/index.js.map +1 -0
  114. package/build-module/details-summary/save.js +16 -0
  115. package/build-module/details-summary/save.js.map +1 -0
  116. package/build-module/embed/deprecated.js +4 -1
  117. package/build-module/embed/deprecated.js.map +1 -1
  118. package/build-module/embed/embed-link-settings.native.js +1 -1
  119. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  120. package/build-module/embed/embed-placeholder.js +1 -1
  121. package/build-module/embed/embed-placeholder.js.map +1 -1
  122. package/build-module/embed/index.js +4 -1
  123. package/build-module/embed/index.js.map +1 -1
  124. package/build-module/embed/transforms.js +4 -1
  125. package/build-module/embed/transforms.js.map +1 -1
  126. package/build-module/embed/util.js +4 -1
  127. package/build-module/embed/util.js.map +1 -1
  128. package/build-module/file/edit.native.js +0 -2
  129. package/build-module/file/edit.native.js.map +1 -1
  130. package/build-module/gallery/use-get-media.native.js +2 -1
  131. package/build-module/gallery/use-get-media.native.js.map +1 -1
  132. package/build-module/image/index.js +4 -2
  133. package/build-module/image/index.js.map +1 -1
  134. package/build-module/index.js +21 -6
  135. package/build-module/index.js.map +1 -1
  136. package/build-module/media-text/media-container.js +1 -5
  137. package/build-module/media-text/media-container.js.map +1 -1
  138. package/build-module/media-text/media-container.native.js +1 -1
  139. package/build-module/media-text/media-container.native.js.map +1 -1
  140. package/build-module/navigation/deprecated.js +8 -10
  141. package/build-module/navigation/deprecated.js.map +1 -1
  142. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  143. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  144. package/build-module/post-author/index.js +0 -1
  145. package/build-module/post-author/index.js.map +1 -1
  146. package/build-module/post-featured-image/dimension-controls.js +2 -1
  147. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  148. package/build-module/post-featured-image/edit.js +8 -22
  149. package/build-module/post-featured-image/edit.js.map +1 -1
  150. package/build-module/post-time-to-read/edit.js +1 -1
  151. package/build-module/post-time-to-read/edit.js.map +1 -1
  152. package/build-module/post-time-to-read/index.js +7 -0
  153. package/build-module/post-time-to-read/index.js.map +1 -1
  154. package/build-module/spacer/controls.js +27 -9
  155. package/build-module/spacer/controls.js.map +1 -1
  156. package/build-module/spacer/edit.js +14 -5
  157. package/build-module/spacer/edit.js.map +1 -1
  158. package/build-module/spacer/save.js +3 -3
  159. package/build-module/spacer/save.js.map +1 -1
  160. package/build-module/table/state.js +35 -33
  161. package/build-module/table/state.js.map +1 -1
  162. package/build-module/term-description/index.js +1 -2
  163. package/build-module/term-description/index.js.map +1 -1
  164. package/build-module/utils/clean-empty-object.js +6 -3
  165. package/build-module/utils/clean-empty-object.js.map +1 -1
  166. package/build-style/columns/style-rtl.css +4 -1
  167. package/build-style/columns/style.css +4 -1
  168. package/build-style/common-rtl.css +1 -1
  169. package/build-style/common.css +1 -1
  170. package/build-style/cover/editor-rtl.css +11 -12
  171. package/build-style/cover/editor.css +11 -12
  172. package/build-style/cover/style-rtl.css +3 -2
  173. package/build-style/cover/style.css +3 -2
  174. package/build-style/details/style-rtl.css +91 -0
  175. package/build-style/details/style.css +91 -0
  176. package/build-style/details-summary/editor-rtl.css +91 -0
  177. package/build-style/details-summary/editor.css +91 -0
  178. package/build-style/details-summary/style-rtl.css +91 -0
  179. package/build-style/details-summary/style.css +91 -0
  180. package/build-style/editor-rtl.css +34 -48
  181. package/build-style/editor.css +34 -48
  182. package/build-style/file/style-rtl.css +4 -3
  183. package/build-style/file/style.css +4 -3
  184. package/build-style/post-excerpt/style-rtl.css +1 -1
  185. package/build-style/post-excerpt/style.css +1 -1
  186. package/build-style/pullquote/style-rtl.css +4 -1
  187. package/build-style/pullquote/style.css +4 -1
  188. package/build-style/shortcode/editor-rtl.css +15 -34
  189. package/build-style/shortcode/editor.css +15 -34
  190. package/build-style/spacer/editor-rtl.css +4 -2
  191. package/build-style/spacer/editor.css +4 -2
  192. package/build-style/style-rtl.css +25 -9
  193. package/build-style/style.css +25 -9
  194. package/package.json +31 -31
  195. package/src/column/block.json +2 -1
  196. package/src/columns/block.json +2 -1
  197. package/src/columns/edit.js +33 -9
  198. package/src/columns/style.scss +5 -1
  199. package/src/columns/utils.js +8 -9
  200. package/src/common.scss +1 -1
  201. package/src/cover/block.json +12 -0
  202. package/src/cover/edit/index.js +44 -37
  203. package/src/cover/edit/resizable-cover-popover.js +82 -0
  204. package/src/cover/editor.scss +20 -13
  205. package/src/cover/index.php +9 -10
  206. package/src/cover/style.scss +2 -1
  207. package/src/cover/test/edit.js +1 -1
  208. package/src/details/block.json +54 -0
  209. package/src/details/edit.js +59 -0
  210. package/src/details/index.js +35 -0
  211. package/src/details/save.js +15 -0
  212. package/src/details/style.scss +3 -0
  213. package/src/details-content/block.json +50 -0
  214. package/src/details-content/edit.js +29 -0
  215. package/src/details-content/index.js +23 -0
  216. package/src/details-content/save.js +12 -0
  217. package/src/details-summary/block.json +53 -0
  218. package/src/details-summary/edit.js +27 -0
  219. package/src/details-summary/editor.scss +3 -0
  220. package/src/details-summary/index.js +23 -0
  221. package/src/details-summary/save.js +13 -0
  222. package/src/details-summary/style.scss +3 -0
  223. package/src/editor.scss +1 -0
  224. package/src/embed/block.json +4 -1
  225. package/src/embed/embed-link-settings.native.js +1 -1
  226. package/src/embed/embed-placeholder.js +1 -1
  227. package/src/file/edit.native.js +0 -2
  228. package/src/file/style.scss +5 -2
  229. package/src/gallery/test/use-get-media.native.js +24 -0
  230. package/src/gallery/use-get-media.native.js +1 -1
  231. package/src/image/block.json +4 -2
  232. package/src/index.js +13 -3
  233. package/src/media-text/media-container.js +1 -5
  234. package/src/media-text/media-container.native.js +1 -1
  235. package/src/navigation/deprecated.js +15 -19
  236. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  237. package/src/navigation/index.php +0 -4
  238. package/src/paragraph/test/edit.native.js +356 -1
  239. package/src/post-author/block.json +0 -1
  240. package/src/post-excerpt/index.php +3 -3
  241. package/src/post-excerpt/style.scss +2 -1
  242. package/src/post-featured-image/dimension-controls.js +5 -1
  243. package/src/post-featured-image/edit.js +8 -29
  244. package/src/post-time-to-read/block.json +7 -0
  245. package/src/post-time-to-read/edit.js +1 -1
  246. package/src/post-time-to-read/index.php +3 -3
  247. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  248. package/src/preformatted/test/edit.native.js +45 -2
  249. package/src/pullquote/style.scss +5 -1
  250. package/src/pullquote/test/edit.native.js +70 -0
  251. package/src/quote/test/edit.native.js +92 -0
  252. package/src/search/index.php +1 -1
  253. package/src/shortcode/editor.scss +26 -5
  254. package/src/spacer/controls.js +42 -17
  255. package/src/spacer/edit.js +23 -4
  256. package/src/spacer/editor.scss +2 -1
  257. package/src/spacer/save.js +3 -3
  258. package/src/style.scss +2 -0
  259. package/src/table/state.js +83 -66
  260. package/src/term-description/block.json +1 -2
  261. package/src/utils/clean-empty-object.js +4 -4
  262. package/src/verse/test/edit.native.js +33 -0
  263. package/build/cover/edit/resizable-cover.js.map +0 -1
  264. package/build/media-text/media-container-icon.js +0 -27
  265. package/build/media-text/media-container-icon.js.map +0 -1
  266. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  267. package/build-module/media-text/media-container-icon.js +0 -17
  268. package/build-module/media-text/media-container-icon.js.map +0 -1
  269. package/src/cover/edit/resizable-cover.js +0 -61
  270. package/src/media-text/media-container-icon.js +0 -12
@@ -7,6 +7,7 @@
7
7
  justify-content: center;
8
8
  align-items: center;
9
9
  padding: 1em;
10
+ overflow: hidden;
10
11
  // This block has customizable padding, border-box makes that more predictable.
11
12
  box-sizing: border-box;
12
13
  // Keep the flex layout direction to the physical direction (LTR) in RTL languages.
@@ -203,7 +204,7 @@ video.wp-block-cover__video-background {
203
204
  // Mobile Safari does not support fixed background attachment properly.
204
205
  // See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
205
206
  // Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
206
- @supports (-webkit-overflow-scrolling: touch) {
207
+ @supports (-webkit-touch-callout: inherit) {
207
208
  background-attachment: scroll;
208
209
  }
209
210
 
@@ -208,7 +208,7 @@ describe( 'Cover block', () => {
208
208
 
209
209
  await selectBlock( 'Block: Cover' );
210
210
  await userEvent.type(
211
- screen.getByLabelText( 'Alt text (alternative text)' ),
211
+ screen.getByLabelText( 'Alternative text' ),
212
212
  'Me'
213
213
  );
214
214
  expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
@@ -0,0 +1,54 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "__experimental": true,
5
+ "name": "core/details",
6
+ "title": "Details",
7
+ "category": "text",
8
+ "description": "A block that displays a summary and shows or hides additional content.",
9
+ "keywords": [ "disclosure", "summary", "hide", "transcript" ],
10
+ "textdomain": "default",
11
+ "attributes": {
12
+ "showContent": {
13
+ "type": "boolean",
14
+ "default": false
15
+ }
16
+ },
17
+ "supports": {
18
+ "align": true,
19
+ "color": {
20
+ "gradients": true,
21
+ "link": true,
22
+ "__experimentalDefaultControls": {
23
+ "background": true,
24
+ "text": true,
25
+ "link": true
26
+ }
27
+ },
28
+ "__experimentalBorder": {
29
+ "radius": true,
30
+ "color": true,
31
+ "width": true,
32
+ "style": true
33
+ },
34
+ "html": false,
35
+ "spacing": {
36
+ "margin": true,
37
+ "padding": true
38
+ },
39
+ "typography": {
40
+ "fontSize": true,
41
+ "lineHeight": true,
42
+ "__experimentalFontFamily": true,
43
+ "__experimentalFontWeight": true,
44
+ "__experimentalFontStyle": true,
45
+ "__experimentalTextTransform": true,
46
+ "__experimentalTextDecoration": true,
47
+ "__experimentalLetterSpacing": true,
48
+ "__experimentalDefaultControls": {
49
+ "fontSize": true
50
+ }
51
+ }
52
+ },
53
+ "style": "wp-block-details"
54
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ useBlockProps,
6
+ useInnerBlocksProps,
7
+ store as blockEditorStore,
8
+ InspectorControls,
9
+ } from '@wordpress/block-editor';
10
+ import { useSelect } from '@wordpress/data';
11
+ import { PanelBody, ToggleControl } from '@wordpress/components';
12
+ import { __ } from '@wordpress/i18n';
13
+
14
+ const TEMPLATE = [ [ 'core/details-summary' ], [ 'core/details-content' ] ];
15
+
16
+ function DetailsEdit( { attributes, setAttributes, clientId } ) {
17
+ const { showContent } = attributes;
18
+ const blockProps = useBlockProps();
19
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
20
+ allowedBlocks: TEMPLATE,
21
+ template: TEMPLATE,
22
+ templateLock: 'all',
23
+ } );
24
+
25
+ // Check if either the block or the inner blocks are selected.
26
+ const hasSelection = useSelect( ( select ) => {
27
+ const { isBlockSelected, hasSelectedInnerBlock } =
28
+ select( blockEditorStore );
29
+ /* Sets deep to true to also find blocks inside the details content block. */
30
+ return (
31
+ hasSelectedInnerBlock( clientId, true ) ||
32
+ isBlockSelected( clientId )
33
+ );
34
+ }, [] );
35
+
36
+ return (
37
+ <>
38
+ <InspectorControls>
39
+ <PanelBody title={ __( 'Settings' ) }>
40
+ <ToggleControl
41
+ label={ __( 'Open by default' ) }
42
+ checked={ showContent }
43
+ onChange={ () =>
44
+ setAttributes( {
45
+ showContent: ! showContent,
46
+ } )
47
+ }
48
+ />
49
+ </PanelBody>
50
+ </InspectorControls>
51
+ <details
52
+ { ...innerBlocksProps }
53
+ open={ hasSelection || showContent }
54
+ ></details>
55
+ </>
56
+ );
57
+ }
58
+
59
+ export default DetailsEdit;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { details as icon } from '@wordpress/icons';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import initBlock from '../utils/init-block';
11
+ import metadata from './block.json';
12
+ import edit from './edit';
13
+ import save from './save';
14
+
15
+ const { name } = metadata;
16
+ export { metadata, name };
17
+
18
+ export const settings = {
19
+ icon,
20
+ example: {
21
+ innerBlocks: [
22
+ {
23
+ name: 'core/details-summary',
24
+ attributes: { summary: __( 'Details' ) },
25
+ },
26
+ {
27
+ name: 'core/details-content',
28
+ },
29
+ ],
30
+ },
31
+ save,
32
+ edit,
33
+ };
34
+
35
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,15 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
5
+
6
+ export default function save( { attributes } ) {
7
+ const { showContent } = attributes;
8
+ const blockProps = useBlockProps.save();
9
+
10
+ return (
11
+ <details { ...blockProps } open={ showContent }>
12
+ <InnerBlocks.Content />
13
+ </details>
14
+ );
15
+ }
@@ -0,0 +1,3 @@
1
+ .wp-block-details {
2
+ overflow: hidden;
3
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "__experimental": true,
5
+ "name": "core/details-content",
6
+ "title": "Details Content",
7
+ "category": "text",
8
+ "parent": [ "core/details" ],
9
+ "description": "Add content that may be shown or hidden via a Details block.",
10
+ "textdomain": "default",
11
+ "supports": {
12
+ "align": false,
13
+ "color": {
14
+ "gradients": true,
15
+ "link": true,
16
+ "__experimentalDefaultControls": {
17
+ "background": true,
18
+ "text": true,
19
+ "link": true
20
+ }
21
+ },
22
+ "__experimentalBorder": {
23
+ "radius": true,
24
+ "color": true,
25
+ "width": true,
26
+ "style": true
27
+ },
28
+ "html": false,
29
+ "lock": false,
30
+ "multiple": false,
31
+ "reusable": false,
32
+ "spacing": {
33
+ "margin": true,
34
+ "padding": true
35
+ },
36
+ "typography": {
37
+ "fontSize": true,
38
+ "lineHeight": true,
39
+ "__experimentalFontFamily": true,
40
+ "__experimentalFontWeight": true,
41
+ "__experimentalFontStyle": true,
42
+ "__experimentalTextTransform": true,
43
+ "__experimentalTextDecoration": true,
44
+ "__experimentalLetterSpacing": true,
45
+ "__experimentalDefaultControls": {
46
+ "fontSize": true
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { View } from '@wordpress/primitives';
7
+
8
+ const TEMPLATE = [
9
+ [
10
+ 'core/paragraph',
11
+ {
12
+ placeholder: __(
13
+ 'Add text or blocks that will display when the details block is opened.'
14
+ ),
15
+ },
16
+ ],
17
+ ];
18
+
19
+ function DetailsContentEdit() {
20
+ const blockProps = useBlockProps();
21
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
22
+ template: TEMPLATE,
23
+ templateLock: false,
24
+ } );
25
+
26
+ return <View { ...innerBlocksProps }></View>;
27
+ }
28
+
29
+ export default DetailsContentEdit;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { postContent as icon } from '@wordpress/icons';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import initBlock from '../utils/init-block';
10
+ import metadata from './block.json';
11
+ import edit from './edit';
12
+ import save from './save';
13
+
14
+ const { name } = metadata;
15
+ export { metadata, name };
16
+
17
+ export const settings = {
18
+ icon,
19
+ save,
20
+ edit,
21
+ };
22
+
23
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,12 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
5
+ export default function save() {
6
+ const blockProps = useBlockProps.save();
7
+ return (
8
+ <div { ...blockProps }>
9
+ <InnerBlocks.Content />
10
+ </div>
11
+ );
12
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "__experimental": true,
5
+ "name": "core/details-summary",
6
+ "title": "Details Summary",
7
+ "category": "text",
8
+ "parent": [ "core/details" ],
9
+ "description": "Provide summary text used to toggle the display of content inside a Details block.",
10
+ "textdomain": "default",
11
+ "attributes": {
12
+ "summary": {
13
+ "type": "string"
14
+ }
15
+ },
16
+ "supports": {
17
+ "align": false,
18
+ "color": {
19
+ "gradients": true,
20
+ "__experimentalDefaultControls": {
21
+ "background": true,
22
+ "text": true
23
+ }
24
+ },
25
+ "__experimentalBorder": {
26
+ "radius": true,
27
+ "color": true,
28
+ "width": true,
29
+ "style": true
30
+ },
31
+ "html": false,
32
+ "lock": false,
33
+ "multiple": false,
34
+ "reusable": false,
35
+ "spacing": {
36
+ "margin": true,
37
+ "padding": true
38
+ },
39
+ "typography": {
40
+ "fontSize": true,
41
+ "lineHeight": true,
42
+ "__experimentalFontFamily": true,
43
+ "__experimentalFontWeight": true,
44
+ "__experimentalFontStyle": true,
45
+ "__experimentalTextTransform": true,
46
+ "__experimentalTextDecoration": true,
47
+ "__experimentalLetterSpacing": true,
48
+ "__experimentalDefaultControls": {
49
+ "fontSize": true
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ function DetailsSummaryEdit( { attributes, setAttributes } ) {
8
+ const summary = attributes.summary ? attributes.summary : __( 'Details' );
9
+ return (
10
+ <summary
11
+ { ...useBlockProps() }
12
+ onClick={ ( event ) => event.preventDefault() }
13
+ >
14
+ <RichText
15
+ aria-label={ __( 'Add summary' ) }
16
+ allowedFormats={ [] }
17
+ withoutInteractiveFormatting
18
+ value={ summary }
19
+ onChange={ ( newSummary ) =>
20
+ setAttributes( { summary: newSummary } )
21
+ }
22
+ />
23
+ </summary>
24
+ );
25
+ }
26
+
27
+ export default DetailsSummaryEdit;
@@ -0,0 +1,3 @@
1
+ .wp-block-details-summary div {
2
+ display: inline;
3
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { heading as icon } from '@wordpress/icons';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import initBlock from '../utils/init-block';
10
+ import metadata from './block.json';
11
+ import edit from './edit';
12
+ import save from './save';
13
+
14
+ const { name } = metadata;
15
+ export { metadata, name };
16
+
17
+ export const settings = {
18
+ icon,
19
+ save,
20
+ edit,
21
+ };
22
+
23
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,13 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
5
+
6
+ export default function save( { attributes } ) {
7
+ const summary = attributes.summary ? attributes.summary : 'Details';
8
+ return (
9
+ <summary { ...useBlockProps.save() }>
10
+ <RichText.Content value={ summary } />
11
+ </summary>
12
+ );
13
+ }
@@ -0,0 +1,3 @@
1
+ .wp-block-details-summary {
2
+ cursor: pointer;
3
+ }
package/src/editor.scss CHANGED
@@ -13,6 +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
17
  @import "./embed/editor.scss";
17
18
  @import "./file/editor.scss";
18
19
  @import "./freeform/editor.scss";
@@ -41,7 +41,10 @@
41
41
  }
42
42
  },
43
43
  "supports": {
44
- "align": true
44
+ "align": true,
45
+ "spacing": {
46
+ "margin": true
47
+ }
45
48
  },
46
49
  "editorStyle": "wp-block-embed-editor",
47
50
  "style": "wp-block-embed"
@@ -39,7 +39,7 @@ const EmbedLinkSettings = ( {
39
39
  label: (
40
40
  <FooterMessageLink
41
41
  href={ __(
42
- 'https://wordpress.org/support/article/embeds/'
42
+ 'https://wordpress.org/documentation/article/embeds/'
43
43
  ) }
44
44
  value={ __( 'Learn more about embeds' ) }
45
45
  />
@@ -40,7 +40,7 @@ const EmbedPlaceholder = ( {
40
40
  <div className="components-placeholder__learn-more">
41
41
  <ExternalLink
42
42
  href={ __(
43
- 'https://wordpress.org/support/article/embeds/'
43
+ 'https://wordpress.org/documentation/article/embeds/'
44
44
  ) }
45
45
  >
46
46
  { __( 'Learn more about embeds' ) }
@@ -466,7 +466,6 @@ export class FileEdit extends Component {
466
466
  __unstableMobileNoFocusOnMount
467
467
  onChange={ this.onChangeFileName }
468
468
  placeholder={ __( 'File name' ) }
469
- rootTagsToEliminate={ [ 'p' ] }
470
469
  tagName="p"
471
470
  underlineColorAndroid="transparent"
472
471
  value={ fileName }
@@ -502,7 +501,6 @@ export class FileEdit extends Component {
502
501
  <RichText
503
502
  withoutInteractiveFormatting
504
503
  __unstableMobileNoFocusOnMount
505
- rootTagsToEliminate={ [ 'p' ] }
506
504
  tagName="p"
507
505
  textAlign="center"
508
506
  minWidth={ minWidth }
@@ -1,6 +1,4 @@
1
1
  .wp-block-file {
2
- margin-bottom: 1.5em;
3
-
4
2
  &:not(.wp-element-button) {
5
3
  font-size: 0.8em;
6
4
  }
@@ -19,6 +17,11 @@
19
17
  }
20
18
  }
21
19
 
20
+ // Lowest specificity to avoid overriding layout styles.
21
+ :where(.wp-block-file) {
22
+ margin-bottom: 1.5em;
23
+ }
24
+
22
25
  .wp-block-file__embed {
23
26
  margin-bottom: 1em;
24
27
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { render } from 'test/helpers';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import useGetMedia from '../use-get-media';
10
+
11
+ describe( 'useGetMedia', () => {
12
+ // TODO: Explore why a Gallery block would ever be without inner blocks.
13
+ // This test and the associated default function parameter might be unnecessary.
14
+ it( 'should not error when receiving zero images', () => {
15
+ // Arrange
16
+ const TestSubject = () => {
17
+ useGetMedia( undefined );
18
+ return null;
19
+ };
20
+
21
+ // Assert
22
+ expect( () => render( <TestSubject /> ) ).not.toThrow();
23
+ } );
24
+ } );
@@ -14,7 +14,7 @@ const EMPTY_IMAGE_MEDIA = [];
14
14
  *
15
15
  * @return {Array} An array of media info options for each gallery image.
16
16
  */
17
- export default function useGetMedia( innerBlockImages ) {
17
+ export default function useGetMedia( innerBlockImages = [] ) {
18
18
  return useSelect(
19
19
  ( select ) => {
20
20
  const imagesUploading = innerBlockImages.some(
@@ -85,10 +85,12 @@
85
85
  "supports": {
86
86
  "anchor": true,
87
87
  "color": {
88
- "__experimentalDuotone": true,
89
88
  "text": false,
90
89
  "background": false
91
90
  },
91
+ "filter": {
92
+ "duotone": true
93
+ },
92
94
  "__experimentalBorder": {
93
95
  "color": true,
94
96
  "radius": true,
@@ -104,7 +106,7 @@
104
106
  "selectors": {
105
107
  "border": ".wp-block-image img, .wp-block-image .wp-block-image__crop-area",
106
108
  "filter": {
107
- "duotone": "img, .components-placeholder"
109
+ "duotone": ".wp-block-image img, .wp-block-image .components-placeholder"
108
110
  }
109
111
  },
110
112
  "styles": [
package/src/index.js CHANGED
@@ -45,6 +45,9 @@ import * as commentsPaginationNext from './comments-pagination-next';
45
45
  import * as commentsPaginationNumbers from './comments-pagination-numbers';
46
46
  import * as commentsTitle from './comments-title';
47
47
  import * as cover from './cover';
48
+ import * as details from './details';
49
+ import * as detailsContent from './details-content';
50
+ import * as detailsSummary from './details-summary';
48
51
  import * as embed from './embed';
49
52
  import * as file from './file';
50
53
  import * as gallery from './gallery';
@@ -121,8 +124,8 @@ import isBlockMetadataExperimental from './utils/is-block-metadata-experimental'
121
124
  /**
122
125
  * Function to get all the block-library blocks in an array
123
126
  */
124
- const getAllBlocks = () =>
125
- [
127
+ const getAllBlocks = () => {
128
+ const blocks = [
126
129
  // Common blocks are grouped at the top to prioritize their display
127
130
  // in various contexts — like the inserter and auto-complete components.
128
131
  paragraph,
@@ -224,7 +227,14 @@ const getAllBlocks = () =>
224
227
  termDescription,
225
228
  queryTitle,
226
229
  postAuthorBiography,
227
- ].filter( Boolean );
230
+ ];
231
+ if ( window?.__experimentalEnableDetailsBlocks ) {
232
+ blocks.push( details );
233
+ blocks.push( detailsContent );
234
+ blocks.push( detailsSummary );
235
+ }
236
+ return blocks.filter( Boolean );
237
+ };
228
238
 
229
239
  /**
230
240
  * Function to get all the core blocks in an array.
@@ -20,11 +20,7 @@ import { useDispatch } from '@wordpress/data';
20
20
  import { forwardRef } from '@wordpress/element';
21
21
  import { isBlobURL } from '@wordpress/blob';
22
22
  import { store as noticesStore } from '@wordpress/notices';
23
-
24
- /**
25
- * Internal dependencies
26
- */
27
- import icon from './media-container-icon';
23
+ import { media as icon } from '@wordpress/icons';
28
24
 
29
25
  /**
30
26
  * Constants
@@ -26,12 +26,12 @@ import { Component } from '@wordpress/element';
26
26
  import { __ } from '@wordpress/i18n';
27
27
  import { isURL, getProtocol } from '@wordpress/url';
28
28
  import { compose, withPreferredColorScheme } from '@wordpress/compose';
29
+ import { media as icon } from '@wordpress/icons';
29
30
 
30
31
  /**
31
32
  * Internal dependencies
32
33
  */
33
34
  import styles from './style.scss';
34
- import icon from './media-container-icon';
35
35
  import SvgIconRetry from './icon-retry';
36
36
 
37
37
  /**