@wordpress/block-library 9.24.0 → 9.25.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 (202) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/edit.js +29 -17
  3. package/build/button/edit.js.map +1 -1
  4. package/build/columns/edit.js +18 -22
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/comment-author-name/edit.js +41 -12
  7. package/build/comment-author-name/edit.js.map +1 -1
  8. package/build/comment-date/edit.js +41 -12
  9. package/build/comment-date/edit.js.map +1 -1
  10. package/build/comment-edit-link/edit.js +27 -7
  11. package/build/comment-edit-link/edit.js.map +1 -1
  12. package/build/comments/edit/comments-inspector-controls.js +1 -3
  13. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  14. package/build/comments-pagination/edit.js +23 -9
  15. package/build/comments-pagination/edit.js.map +1 -1
  16. package/build/comments-title/edit.js +41 -12
  17. package/build/comments-title/edit.js.map +1 -1
  18. package/build/details/edit.js +27 -3
  19. package/build/details/edit.js.map +1 -1
  20. package/build/embed/edit.js +2 -4
  21. package/build/embed/edit.js.map +1 -1
  22. package/build/embed/embed-controls.js +41 -22
  23. package/build/embed/embed-controls.js.map +1 -1
  24. package/build/file/inspector.js +73 -30
  25. package/build/file/inspector.js.map +1 -1
  26. package/build/form/edit.js +67 -37
  27. package/build/form/edit.js.map +1 -1
  28. package/build/form-input/edit.js +47 -18
  29. package/build/form-input/edit.js.map +1 -1
  30. package/build/latest-posts/edit.js +154 -82
  31. package/build/latest-posts/edit.js.map +1 -1
  32. package/build/list/ordered-list-settings.js +131 -52
  33. package/build/list/ordered-list-settings.js.map +1 -1
  34. package/build/navigation/edit/index.js +93 -51
  35. package/build/navigation/edit/index.js.map +1 -1
  36. package/build/navigation/edit/overlay-menu-preview.js +43 -27
  37. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  38. package/build/navigation-link/index.js +3 -0
  39. package/build/navigation-link/index.js.map +1 -1
  40. package/build/navigation-link/transforms.js +2 -0
  41. package/build/navigation-link/transforms.js.map +1 -1
  42. package/build/navigation-link/update-attributes.js +1 -0
  43. package/build/navigation-link/update-attributes.js.map +1 -1
  44. package/build/navigation-submenu/index.js +3 -0
  45. package/build/navigation-submenu/index.js.map +1 -1
  46. package/build/post-comments-count/index.js +3 -1
  47. package/build/post-comments-count/index.js.map +1 -1
  48. package/build/post-comments-count/transforms.js +26 -0
  49. package/build/post-comments-count/transforms.js.map +1 -0
  50. package/build/post-comments-link/index.js +3 -1
  51. package/build/post-comments-link/index.js.map +1 -1
  52. package/build/post-comments-link/transforms.js +26 -0
  53. package/build/post-comments-link/transforms.js.map +1 -0
  54. package/build/post-title/edit.js +56 -18
  55. package/build/post-title/edit.js.map +1 -1
  56. package/build/query/edit/enhanced-pagination-modal.js +1 -1
  57. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  58. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  59. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  60. package/build/rss/edit.js +120 -46
  61. package/build/rss/edit.js.map +1 -1
  62. package/build/separator/edit.js +52 -20
  63. package/build/separator/edit.js.map +1 -1
  64. package/build/shortcode/index.js +2 -1
  65. package/build/shortcode/index.js.map +1 -1
  66. package/build/social-link/variations.js +53 -48
  67. package/build/social-link/variations.js.map +1 -1
  68. package/build/social-links/edit.js +35 -45
  69. package/build/social-links/edit.js.map +1 -1
  70. package/build/video/tracks-editor.js +40 -12
  71. package/build/video/tracks-editor.js.map +1 -1
  72. package/build-module/button/edit.js +30 -18
  73. package/build-module/button/edit.js.map +1 -1
  74. package/build-module/columns/edit.js +18 -22
  75. package/build-module/columns/edit.js.map +1 -1
  76. package/build-module/comment-author-name/edit.js +42 -13
  77. package/build-module/comment-author-name/edit.js.map +1 -1
  78. package/build-module/comment-date/edit.js +42 -13
  79. package/build-module/comment-date/edit.js.map +1 -1
  80. package/build-module/comment-edit-link/edit.js +28 -8
  81. package/build-module/comment-edit-link/edit.js.map +1 -1
  82. package/build-module/comments/edit/comments-inspector-controls.js +1 -3
  83. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  84. package/build-module/comments-pagination/edit.js +24 -10
  85. package/build-module/comments-pagination/edit.js.map +1 -1
  86. package/build-module/comments-title/edit.js +42 -13
  87. package/build-module/comments-title/edit.js.map +1 -1
  88. package/build-module/details/edit.js +29 -5
  89. package/build-module/details/edit.js.map +1 -1
  90. package/build-module/embed/edit.js +2 -4
  91. package/build-module/embed/edit.js.map +1 -1
  92. package/build-module/embed/embed-controls.js +42 -23
  93. package/build-module/embed/embed-controls.js.map +1 -1
  94. package/build-module/file/inspector.js +74 -31
  95. package/build-module/file/inspector.js.map +1 -1
  96. package/build-module/form/edit.js +68 -38
  97. package/build-module/form/edit.js.map +1 -1
  98. package/build-module/form-input/edit.js +48 -19
  99. package/build-module/form-input/edit.js.map +1 -1
  100. package/build-module/latest-posts/edit.js +155 -83
  101. package/build-module/latest-posts/edit.js.map +1 -1
  102. package/build-module/list/ordered-list-settings.js +132 -53
  103. package/build-module/list/ordered-list-settings.js.map +1 -1
  104. package/build-module/navigation/edit/index.js +94 -52
  105. package/build-module/navigation/edit/index.js.map +1 -1
  106. package/build-module/navigation/edit/overlay-menu-preview.js +44 -28
  107. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  108. package/build-module/navigation-link/index.js +3 -0
  109. package/build-module/navigation-link/index.js.map +1 -1
  110. package/build-module/navigation-link/transforms.js +2 -0
  111. package/build-module/navigation-link/transforms.js.map +1 -1
  112. package/build-module/navigation-link/update-attributes.js +1 -0
  113. package/build-module/navigation-link/update-attributes.js.map +1 -1
  114. package/build-module/navigation-submenu/index.js +3 -0
  115. package/build-module/navigation-submenu/index.js.map +1 -1
  116. package/build-module/post-comments-count/index.js +3 -1
  117. package/build-module/post-comments-count/index.js.map +1 -1
  118. package/build-module/post-comments-count/transforms.js +19 -0
  119. package/build-module/post-comments-count/transforms.js.map +1 -0
  120. package/build-module/post-comments-link/index.js +3 -1
  121. package/build-module/post-comments-link/index.js.map +1 -1
  122. package/build-module/post-comments-link/transforms.js +19 -0
  123. package/build-module/post-comments-link/transforms.js.map +1 -0
  124. package/build-module/post-title/edit.js +57 -19
  125. package/build-module/post-title/edit.js.map +1 -1
  126. package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
  127. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  128. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  129. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  130. package/build-module/rss/edit.js +121 -47
  131. package/build-module/rss/edit.js.map +1 -1
  132. package/build-module/separator/edit.js +54 -22
  133. package/build-module/separator/edit.js.map +1 -1
  134. package/build-module/shortcode/index.js +2 -1
  135. package/build-module/shortcode/index.js.map +1 -1
  136. package/build-module/social-link/variations.js +53 -48
  137. package/build-module/social-link/variations.js.map +1 -1
  138. package/build-module/social-links/edit.js +37 -47
  139. package/build-module/social-links/edit.js.map +1 -1
  140. package/build-module/video/tracks-editor.js +41 -13
  141. package/build-module/video/tracks-editor.js.map +1 -1
  142. package/build-style/editor-rtl.css +9 -4
  143. package/build-style/editor.css +9 -4
  144. package/build-style/gallery/style-rtl.css +1 -0
  145. package/build-style/gallery/style.css +1 -0
  146. package/build-style/navigation/editor-rtl.css +8 -3
  147. package/build-style/navigation/editor.css +8 -3
  148. package/build-style/pullquote/editor-rtl.css +1 -1
  149. package/build-style/pullquote/editor.css +1 -1
  150. package/build-style/pullquote/style-rtl.css +2 -3
  151. package/build-style/pullquote/style.css +2 -3
  152. package/build-style/pullquote/theme-rtl.css +2 -2
  153. package/build-style/pullquote/theme.css +2 -2
  154. package/build-style/style-rtl.css +3 -3
  155. package/build-style/style.css +3 -3
  156. package/build-style/theme-rtl.css +2 -2
  157. package/build-style/theme.css +2 -2
  158. package/package.json +35 -35
  159. package/src/button/edit.js +44 -29
  160. package/src/columns/edit.js +20 -31
  161. package/src/comment-author-name/edit.js +54 -13
  162. package/src/comment-date/edit.js +50 -15
  163. package/src/comment-edit-link/edit.js +39 -11
  164. package/src/comments/edit/comments-inspector-controls.js +0 -2
  165. package/src/comments-pagination/edit.js +29 -9
  166. package/src/comments-title/edit.js +53 -15
  167. package/src/details/edit.js +36 -4
  168. package/src/embed/edit.js +3 -5
  169. package/src/embed/embed-controls.js +55 -33
  170. package/src/file/inspector.js +99 -45
  171. package/src/form/edit.js +91 -46
  172. package/src/form-input/edit.js +56 -18
  173. package/src/gallery/style.scss +1 -0
  174. package/src/latest-posts/edit.js +206 -98
  175. package/src/list/ordered-list-settings.js +172 -62
  176. package/src/navigation/edit/index.js +127 -64
  177. package/src/navigation/edit/overlay-menu-preview.js +43 -26
  178. package/src/navigation/editor.scss +8 -4
  179. package/src/navigation-link/block.json +3 -0
  180. package/src/navigation-link/index.php +4 -0
  181. package/src/navigation-link/transforms.js +2 -1
  182. package/src/navigation-link/update-attributes.js +1 -0
  183. package/src/navigation-submenu/block.json +3 -0
  184. package/src/navigation-submenu/index.php +4 -0
  185. package/src/post-comments-count/index.js +2 -0
  186. package/src/post-comments-count/transforms.js +20 -0
  187. package/src/post-comments-link/index.js +2 -0
  188. package/src/post-comments-link/transforms.js +20 -0
  189. package/src/post-title/edit.js +76 -24
  190. package/src/pullquote/editor.scss +1 -1
  191. package/src/pullquote/style.scss +2 -3
  192. package/src/pullquote/theme.scss +2 -2
  193. package/src/query/edit/enhanced-pagination-modal.js +1 -5
  194. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -13
  195. package/src/rss/edit.js +141 -55
  196. package/src/separator/edit.js +66 -21
  197. package/src/shortcode/block.json +2 -1
  198. package/src/site-title/index.php +1 -1
  199. package/src/social-link/index.php +49 -49
  200. package/src/social-link/variations.js +53 -48
  201. package/src/social-links/edit.js +39 -60
  202. package/src/video/tracks-editor.js +57 -16
@@ -12,9 +12,18 @@ import {
12
12
  InspectorControls,
13
13
  useBlockProps,
14
14
  } from '@wordpress/block-editor';
15
- import { PanelBody, ToggleControl } from '@wordpress/components';
15
+ import {
16
+ ToggleControl,
17
+ __experimentalToolsPanel as ToolsPanel,
18
+ __experimentalToolsPanelItem as ToolsPanelItem,
19
+ } from '@wordpress/components';
16
20
  import { __ } from '@wordpress/i18n';
17
21
 
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
26
+
18
27
  export default function Edit( {
19
28
  attributes: { linkTarget, textAlign },
20
29
  setAttributes,
@@ -25,6 +34,8 @@ export default function Edit( {
25
34
  } ),
26
35
  } );
27
36
 
37
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
38
+
28
39
  const blockControls = (
29
40
  <BlockControls group="block">
30
41
  <AlignmentControl
@@ -37,18 +48,35 @@ export default function Edit( {
37
48
  );
38
49
  const inspectorControls = (
39
50
  <InspectorControls>
40
- <PanelBody title={ __( 'Settings' ) }>
41
- <ToggleControl
42
- __nextHasNoMarginBottom
51
+ <ToolsPanel
52
+ label={ __( 'Settings' ) }
53
+ resetAll={ () => {
54
+ setAttributes( {
55
+ linkTarget: '_self',
56
+ } );
57
+ } }
58
+ dropdownMenuProps={ dropdownMenuProps }
59
+ >
60
+ <ToolsPanelItem
43
61
  label={ __( 'Open in new tab' ) }
44
- onChange={ ( value ) =>
45
- setAttributes( {
46
- linkTarget: value ? '_blank' : '_self',
47
- } )
62
+ isShownByDefault
63
+ hasValue={ () => linkTarget === '_blank' }
64
+ onDeselect={ () =>
65
+ setAttributes( { linkTarget: '_self' } )
48
66
  }
49
- checked={ linkTarget === '_blank' }
50
- />
51
- </PanelBody>
67
+ >
68
+ <ToggleControl
69
+ __nextHasNoMarginBottom
70
+ label={ __( 'Open in new tab' ) }
71
+ onChange={ ( value ) =>
72
+ setAttributes( {
73
+ linkTarget: value ? '_blank' : '_self',
74
+ } )
75
+ }
76
+ checked={ linkTarget === '_blank' }
77
+ />
78
+ </ToolsPanelItem>
79
+ </ToolsPanel>
52
80
  </InspectorControls>
53
81
  );
54
82
 
@@ -17,7 +17,6 @@ const { HTMLElementControl } = unlock( blockEditorPrivateApis );
17
17
  export default function CommentsInspectorControls( {
18
18
  attributes: { tagName },
19
19
  setAttributes,
20
- clientId,
21
20
  } ) {
22
21
  return (
23
22
  <InspectorControls>
@@ -27,7 +26,6 @@ export default function CommentsInspectorControls( {
27
26
  onChange={ ( value ) =>
28
27
  setAttributes( { tagName: value } )
29
28
  }
30
- clientId={ clientId }
31
29
  options={ [
32
30
  { label: __( 'Default (<div>)' ), value: 'div' },
33
31
  { label: '<section>', value: 'section' },
@@ -10,12 +10,16 @@ import {
10
10
  Warning,
11
11
  } from '@wordpress/block-editor';
12
12
  import { useSelect } from '@wordpress/data';
13
- import { PanelBody } from '@wordpress/components';
13
+ import {
14
+ __experimentalToolsPanel as ToolsPanel,
15
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
+ } from '@wordpress/components';
14
17
 
15
18
  /**
16
19
  * Internal dependencies
17
20
  */
18
21
  import { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';
22
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
19
23
 
20
24
  const TEMPLATE = [
21
25
  [ 'core/comments-pagination-previous' ],
@@ -45,6 +49,7 @@ export default function QueryPaginationEdit( {
45
49
  }, [] );
46
50
 
47
51
  const blockProps = useBlockProps();
52
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
48
53
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
49
54
  template: TEMPLATE,
50
55
  } );
@@ -73,14 +78,29 @@ export default function QueryPaginationEdit( {
73
78
  <>
74
79
  { hasNextPreviousBlocks && (
75
80
  <InspectorControls>
76
- <PanelBody title={ __( 'Settings' ) }>
77
- <CommentsPaginationArrowControls
78
- value={ paginationArrow }
79
- onChange={ ( value ) => {
80
- setAttributes( { paginationArrow: value } );
81
- } }
82
- />
83
- </PanelBody>
81
+ <ToolsPanel
82
+ label={ __( 'Settings' ) }
83
+ dropdownMenuProps={ dropdownMenuProps }
84
+ resetAll={ () =>
85
+ setAttributes( { paginationArrow: 'none' } )
86
+ }
87
+ >
88
+ <ToolsPanelItem
89
+ label={ __( 'Arrow' ) }
90
+ hasValue={ () => paginationArrow !== 'none' }
91
+ onDeselect={ () =>
92
+ setAttributes( { paginationArrow: 'none' } )
93
+ }
94
+ isShownByDefault
95
+ >
96
+ <CommentsPaginationArrowControls
97
+ value={ paginationArrow }
98
+ onChange={ ( value ) => {
99
+ setAttributes( { paginationArrow: value } );
100
+ } }
101
+ />
102
+ </ToolsPanelItem>
103
+ </ToolsPanel>
84
104
  </InspectorControls>
85
105
  ) }
86
106
  <div { ...innerBlocksProps } />
@@ -16,12 +16,21 @@ import {
16
16
  } from '@wordpress/block-editor';
17
17
  import { __, _n, sprintf } from '@wordpress/i18n';
18
18
  import { useEntityProp } from '@wordpress/core-data';
19
- import { PanelBody, ToggleControl } from '@wordpress/components';
19
+ import {
20
+ ToggleControl,
21
+ __experimentalToolsPanel as ToolsPanel,
22
+ __experimentalToolsPanelItem as ToolsPanelItem,
23
+ } from '@wordpress/components';
20
24
  import { useState, useEffect } from '@wordpress/element';
21
25
  import { useSelect } from '@wordpress/data';
22
26
  import apiFetch from '@wordpress/api-fetch';
23
27
  import { addQueryArgs } from '@wordpress/url';
24
28
 
29
+ /**
30
+ * Internal dependencies
31
+ */
32
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
33
+
25
34
  export default function Edit( {
26
35
  attributes: {
27
36
  textAlign,
@@ -53,6 +62,8 @@ export default function Edit( {
53
62
  return getSettings().__experimentalDiscussionSettings;
54
63
  } );
55
64
 
65
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
66
+
56
67
  useEffect( () => {
57
68
  if ( isSiteEditor ) {
58
69
  // Match the number of comments that will be shown in the comment-template/edit.js placeholder
@@ -111,24 +122,51 @@ export default function Edit( {
111
122
 
112
123
  const inspectorControls = (
113
124
  <InspectorControls>
114
- <PanelBody title={ __( 'Settings' ) }>
115
- <ToggleControl
116
- __nextHasNoMarginBottom
125
+ <ToolsPanel
126
+ label={ __( 'Settings' ) }
127
+ resetAll={ () => {
128
+ setAttributes( {
129
+ showPostTitle: true,
130
+ showCommentsCount: true,
131
+ } );
132
+ } }
133
+ dropdownMenuProps={ dropdownMenuProps }
134
+ >
135
+ <ToolsPanelItem
117
136
  label={ __( 'Show post title' ) }
118
- checked={ showPostTitle }
119
- onChange={ ( value ) =>
120
- setAttributes( { showPostTitle: value } )
137
+ isShownByDefault
138
+ hasValue={ () => ! showPostTitle }
139
+ onDeselect={ () =>
140
+ setAttributes( { showPostTitle: true } )
121
141
  }
122
- />
123
- <ToggleControl
124
- __nextHasNoMarginBottom
142
+ >
143
+ <ToggleControl
144
+ __nextHasNoMarginBottom
145
+ label={ __( 'Show post title' ) }
146
+ checked={ showPostTitle }
147
+ onChange={ ( value ) =>
148
+ setAttributes( { showPostTitle: value } )
149
+ }
150
+ />
151
+ </ToolsPanelItem>
152
+ <ToolsPanelItem
125
153
  label={ __( 'Show comments count' ) }
126
- checked={ showCommentsCount }
127
- onChange={ ( value ) =>
128
- setAttributes( { showCommentsCount: value } )
154
+ isShownByDefault
155
+ hasValue={ () => ! showCommentsCount }
156
+ onDeselect={ () =>
157
+ setAttributes( { showCommentsCount: true } )
129
158
  }
130
- />
131
- </PanelBody>
159
+ >
160
+ <ToggleControl
161
+ __nextHasNoMarginBottom
162
+ label={ __( 'Show comments count' ) }
163
+ checked={ showCommentsCount }
164
+ onChange={ ( value ) =>
165
+ setAttributes( { showCommentsCount: value } )
166
+ }
167
+ />
168
+ </ToolsPanelItem>
169
+ </ToolsPanel>
132
170
  </InspectorControls>
133
171
  );
134
172
 
@@ -6,20 +6,26 @@ import {
6
6
  useBlockProps,
7
7
  useInnerBlocksProps,
8
8
  InspectorControls,
9
+ store as blockEditorStore,
9
10
  } from '@wordpress/block-editor';
10
11
  import {
11
12
  TextControl,
12
13
  ToggleControl,
13
14
  __experimentalToolsPanel as ToolsPanel,
14
15
  __experimentalToolsPanelItem as ToolsPanelItem,
16
+ privateApis as componentsPrivateApis,
15
17
  } from '@wordpress/components';
16
18
  import { __ } from '@wordpress/i18n';
17
19
  import { useState } from '@wordpress/element';
20
+ import { useSelect } from '@wordpress/data';
18
21
 
19
22
  /**
20
23
  * Internal dependencies
21
24
  */
22
25
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
26
+ import { unlock } from '../lock-unlock';
27
+
28
+ const { withIgnoreIMEEvents } = unlock( componentsPrivateApis );
23
29
 
24
30
  const TEMPLATE = [
25
31
  [
@@ -30,7 +36,7 @@ const TEMPLATE = [
30
36
  ],
31
37
  ];
32
38
 
33
- function DetailsEdit( { attributes, setAttributes } ) {
39
+ function DetailsEdit( { attributes, setAttributes, clientId } ) {
34
40
  const { name, showContent, summary, allowedBlocks, placeholder } =
35
41
  attributes;
36
42
  const blockProps = useBlockProps();
@@ -42,6 +48,27 @@ function DetailsEdit( { attributes, setAttributes } ) {
42
48
  const [ isOpen, setIsOpen ] = useState( showContent );
43
49
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
44
50
 
51
+ // Check if the inner blocks are selected.
52
+ const hasSelectedInnerBlock = useSelect(
53
+ ( select ) =>
54
+ select( blockEditorStore ).hasSelectedInnerBlock( clientId, true ),
55
+ [ clientId ]
56
+ );
57
+
58
+ const handleSummaryKeyDown = ( event ) => {
59
+ if ( event.key === 'Enter' && ! event.shiftKey ) {
60
+ setIsOpen( ( prevIsOpen ) => ! prevIsOpen );
61
+ event.preventDefault();
62
+ }
63
+ };
64
+
65
+ // Prevent spacebar from toggling <details> while typing.
66
+ const handleSummaryKeyUp = ( event ) => {
67
+ if ( event.key === ' ' ) {
68
+ event.preventDefault();
69
+ }
70
+ };
71
+
45
72
  return (
46
73
  <>
47
74
  <InspectorControls>
@@ -93,13 +120,18 @@ function DetailsEdit( { attributes, setAttributes } ) {
93
120
  </InspectorControls>
94
121
  <details
95
122
  { ...innerBlocksProps }
96
- open={ isOpen }
123
+ open={ isOpen || hasSelectedInnerBlock }
97
124
  onToggle={ ( event ) => setIsOpen( event.target.open ) }
98
125
  >
99
- <summary>
126
+ <summary
127
+ onKeyDown={ withIgnoreIMEEvents( handleSummaryKeyDown ) }
128
+ onKeyUp={ handleSummaryKeyUp }
129
+ >
100
130
  <RichText
101
131
  identifier="summary"
102
- aria-label={ __( 'Write summary' ) }
132
+ aria-label={ __(
133
+ 'Write summary. Press Enter to expand or collapse the details.'
134
+ ) }
103
135
  placeholder={ placeholder || __( 'Write summary…' ) }
104
136
  withoutInteractiveFormatting
105
137
  value={ summary }
package/src/embed/edit.js CHANGED
@@ -118,11 +118,9 @@ const EmbedEdit = ( props ) => {
118
118
  responsive
119
119
  );
120
120
 
121
- const toggleResponsive = () => {
122
- const { allowResponsive, className } = attributes;
121
+ function toggleResponsive( newAllowResponsive ) {
122
+ const { className } = attributes;
123
123
  const { html } = preview;
124
- const newAllowResponsive = ! allowResponsive;
125
-
126
124
  setAttributes( {
127
125
  allowResponsive: newAllowResponsive,
128
126
  className: getClassNames(
@@ -131,7 +129,7 @@ const EmbedEdit = ( props ) => {
131
129
  responsive && newAllowResponsive
132
130
  ),
133
131
  } );
134
- };
132
+ }
135
133
 
136
134
  useEffect( () => {
137
135
  if ( preview?.html || ! cannotEmbed || ! hasResolved ) {
@@ -4,13 +4,19 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import {
6
6
  ToolbarButton,
7
- PanelBody,
8
7
  ToggleControl,
9
8
  ToolbarGroup,
9
+ __experimentalToolsPanel as ToolsPanel,
10
+ __experimentalToolsPanelItem as ToolsPanelItem,
10
11
  } from '@wordpress/components';
11
12
  import { BlockControls, InspectorControls } from '@wordpress/block-editor';
12
13
  import { edit } from '@wordpress/icons';
13
14
 
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
19
+
14
20
  function getResponsiveHelp( checked ) {
15
21
  return checked
16
22
  ? __(
@@ -28,37 +34,53 @@ const EmbedControls = ( {
28
34
  allowResponsive,
29
35
  toggleResponsive,
30
36
  switchBackToURLInput,
31
- } ) => (
32
- <>
33
- <BlockControls>
34
- <ToolbarGroup>
35
- { showEditButton && (
36
- <ToolbarButton
37
- className="components-toolbar__control"
38
- label={ __( 'Edit URL' ) }
39
- icon={ edit }
40
- onClick={ switchBackToURLInput }
41
- />
42
- ) }
43
- </ToolbarGroup>
44
- </BlockControls>
45
- { themeSupportsResponsive && blockSupportsResponsive && (
46
- <InspectorControls>
47
- <PanelBody
48
- title={ __( 'Media settings' ) }
49
- className="blocks-responsive"
50
- >
51
- <ToggleControl
52
- __nextHasNoMarginBottom
53
- label={ __( 'Resize for smaller devices' ) }
54
- checked={ allowResponsive }
55
- help={ getResponsiveHelp }
56
- onChange={ toggleResponsive }
57
- />
58
- </PanelBody>
59
- </InspectorControls>
60
- ) }
61
- </>
62
- );
37
+ } ) => {
38
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
39
+
40
+ return (
41
+ <>
42
+ <BlockControls>
43
+ <ToolbarGroup>
44
+ { showEditButton && (
45
+ <ToolbarButton
46
+ className="components-toolbar__control"
47
+ label={ __( 'Edit URL' ) }
48
+ icon={ edit }
49
+ onClick={ switchBackToURLInput }
50
+ />
51
+ ) }
52
+ </ToolbarGroup>
53
+ </BlockControls>
54
+ { themeSupportsResponsive && blockSupportsResponsive && (
55
+ <InspectorControls>
56
+ <ToolsPanel
57
+ label={ __( 'Media settings' ) }
58
+ resetAll={ () => {
59
+ toggleResponsive( true );
60
+ } }
61
+ dropdownMenuProps={ dropdownMenuProps }
62
+ >
63
+ <ToolsPanelItem
64
+ label={ __( 'Media settings' ) }
65
+ isShownByDefault
66
+ hasValue={ () => ! allowResponsive }
67
+ onDeselect={ () => {
68
+ toggleResponsive( ! allowResponsive );
69
+ } }
70
+ >
71
+ <ToggleControl
72
+ __nextHasNoMarginBottom
73
+ label={ __( 'Resize for smaller devices' ) }
74
+ checked={ allowResponsive }
75
+ help={ getResponsiveHelp }
76
+ onChange={ toggleResponsive }
77
+ />
78
+ </ToolsPanelItem>
79
+ </ToolsPanel>
80
+ </InspectorControls>
81
+ ) }
82
+ </>
83
+ );
84
+ };
63
85
 
64
86
  export default EmbedControls;
@@ -3,10 +3,11 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import {
6
- PanelBody,
7
6
  RangeControl,
8
7
  SelectControl,
9
8
  ToggleControl,
9
+ __experimentalToolsPanel as ToolsPanel,
10
+ __experimentalToolsPanelItem as ToolsPanelItem,
10
11
  } from '@wordpress/components';
11
12
  import { InspectorControls } from '@wordpress/block-editor';
12
13
 
@@ -14,6 +15,7 @@ import { InspectorControls } from '@wordpress/block-editor';
14
15
  * Internal dependencies
15
16
  */
16
17
  import { MIN_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT } from './edit';
18
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
17
19
 
18
20
  export default function FileBlockInspector( {
19
21
  hrefs,
@@ -28,6 +30,7 @@ export default function FileBlockInspector( {
28
30
  changePreviewHeight,
29
31
  } ) {
30
32
  const { href, textLinkHref, attachmentPage } = hrefs;
33
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
31
34
 
32
35
  let linkDestinationOptions = [ { value: href, label: __( 'URL' ) } ];
33
36
  if ( attachmentPage ) {
@@ -41,58 +44,109 @@ export default function FileBlockInspector( {
41
44
  <>
42
45
  <InspectorControls>
43
46
  { href.endsWith( '.pdf' ) && (
44
- <PanelBody title={ __( 'PDF settings' ) }>
45
- <ToggleControl
46
- __nextHasNoMarginBottom
47
+ <ToolsPanel
48
+ label={ __( 'PDF settings' ) }
49
+ resetAll={ () => {
50
+ changeDisplayPreview( true );
51
+ changePreviewHeight( 600 );
52
+ } }
53
+ dropdownMenuProps={ dropdownMenuProps }
54
+ >
55
+ <ToolsPanelItem
47
56
  label={ __( 'Show inline embed' ) }
48
- help={
49
- displayPreview
50
- ? __(
51
- "Note: Most phone and tablet browsers won't display embedded PDFs."
52
- )
53
- : null
54
- }
55
- checked={ !! displayPreview }
56
- onChange={ changeDisplayPreview }
57
- />
58
- { displayPreview && (
59
- <RangeControl
57
+ isShownByDefault
58
+ hasValue={ () => ! displayPreview }
59
+ onDeselect={ () => changeDisplayPreview( true ) }
60
+ >
61
+ <ToggleControl
60
62
  __nextHasNoMarginBottom
61
- __next40pxDefaultSize
62
- label={ __( 'Height in pixels' ) }
63
- min={ MIN_PREVIEW_HEIGHT }
64
- max={ Math.max(
65
- MAX_PREVIEW_HEIGHT,
66
- previewHeight
67
- ) }
68
- value={ previewHeight }
69
- onChange={ changePreviewHeight }
63
+ label={ __( 'Show inline embed' ) }
64
+ help={
65
+ displayPreview
66
+ ? __(
67
+ "Note: Most phone and tablet browsers won't display embedded PDFs."
68
+ )
69
+ : null
70
+ }
71
+ checked={ !! displayPreview }
72
+ onChange={ changeDisplayPreview }
70
73
  />
74
+ </ToolsPanelItem>
75
+ { displayPreview && (
76
+ <ToolsPanelItem
77
+ label={ __( 'Height in pixels' ) }
78
+ isShownByDefault
79
+ hasValue={ () => previewHeight !== 600 }
80
+ onDeselect={ () => changePreviewHeight( 600 ) }
81
+ >
82
+ <RangeControl
83
+ __nextHasNoMarginBottom
84
+ __next40pxDefaultSize
85
+ label={ __( 'Height in pixels' ) }
86
+ min={ MIN_PREVIEW_HEIGHT }
87
+ max={ Math.max(
88
+ MAX_PREVIEW_HEIGHT,
89
+ previewHeight
90
+ ) }
91
+ value={ previewHeight }
92
+ onChange={ changePreviewHeight }
93
+ />
94
+ </ToolsPanelItem>
71
95
  ) }
72
- </PanelBody>
96
+ </ToolsPanel>
73
97
  ) }
74
- <PanelBody title={ __( 'Settings' ) }>
75
- <SelectControl
76
- __next40pxDefaultSize
77
- __nextHasNoMarginBottom
98
+
99
+ <ToolsPanel
100
+ label={ __( 'Settings' ) }
101
+ resetAll={ () => {
102
+ changeLinkDestinationOption( href );
103
+ changeOpenInNewWindow( false );
104
+ changeShowDownloadButton( true );
105
+ } }
106
+ dropdownMenuProps={ dropdownMenuProps }
107
+ >
108
+ <ToolsPanelItem
78
109
  label={ __( 'Link to' ) }
79
- value={ textLinkHref }
80
- options={ linkDestinationOptions }
81
- onChange={ changeLinkDestinationOption }
82
- />
83
- <ToggleControl
84
- __nextHasNoMarginBottom
110
+ isShownByDefault
111
+ hasValue={ () => textLinkHref !== href }
112
+ onDeselect={ () => changeLinkDestinationOption( href ) }
113
+ >
114
+ <SelectControl
115
+ __next40pxDefaultSize
116
+ __nextHasNoMarginBottom
117
+ label={ __( 'Link to' ) }
118
+ value={ textLinkHref }
119
+ options={ linkDestinationOptions }
120
+ onChange={ changeLinkDestinationOption }
121
+ />
122
+ </ToolsPanelItem>
123
+ <ToolsPanelItem
85
124
  label={ __( 'Open in new tab' ) }
86
- checked={ openInNewWindow }
87
- onChange={ changeOpenInNewWindow }
88
- />
89
- <ToggleControl
90
- __nextHasNoMarginBottom
125
+ isShownByDefault
126
+ hasValue={ () => !! openInNewWindow }
127
+ onDeselect={ () => changeOpenInNewWindow( false ) }
128
+ >
129
+ <ToggleControl
130
+ __nextHasNoMarginBottom
131
+ label={ __( 'Open in new tab' ) }
132
+ checked={ openInNewWindow }
133
+ onChange={ changeOpenInNewWindow }
134
+ />
135
+ </ToolsPanelItem>
136
+ <ToolsPanelItem
91
137
  label={ __( 'Show download button' ) }
92
- checked={ showDownloadButton }
93
- onChange={ changeShowDownloadButton }
94
- />
95
- </PanelBody>
138
+ isShownByDefault
139
+ hasValue={ () => ! showDownloadButton }
140
+ onDeselect={ () => changeShowDownloadButton( true ) }
141
+ >
142
+ <ToggleControl
143
+ __nextHasNoMarginBottom
144
+ label={ __( 'Show download button' ) }
145
+ checked={ showDownloadButton }
146
+ onChange={ changeShowDownloadButton }
147
+ />
148
+ </ToolsPanelItem>
149
+ </ToolsPanel>
96
150
  </InspectorControls>
97
151
  </>
98
152
  );