@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
@@ -9,6 +9,7 @@ import { postCommentsCount as icon } from '@wordpress/icons';
9
9
  import initBlock from '../utils/init-block';
10
10
  import metadata from './block.json';
11
11
  import edit from './edit';
12
+ import transforms from './transforms';
12
13
 
13
14
  const { name } = metadata;
14
15
  export { metadata, name };
@@ -16,6 +17,7 @@ export { metadata, name };
16
17
  export const settings = {
17
18
  icon,
18
19
  edit,
20
+ transforms,
19
21
  };
20
22
 
21
23
  export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createBlock } from '@wordpress/blocks';
5
+
6
+ const transforms = {
7
+ to: [
8
+ {
9
+ type: 'block',
10
+ blocks: [ 'core/post-comments-link' ],
11
+ transform: ( { textAlign } ) => {
12
+ return createBlock( 'core/post-comments-link', {
13
+ textAlign,
14
+ } );
15
+ },
16
+ },
17
+ ],
18
+ };
19
+
20
+ export default transforms;
@@ -9,6 +9,7 @@ import { postCommentsCount as icon } from '@wordpress/icons';
9
9
  import initBlock from '../utils/init-block';
10
10
  import metadata from './block.json';
11
11
  import edit from './edit';
12
+ import transforms from './transforms';
12
13
 
13
14
  const { name } = metadata;
14
15
  export { metadata, name };
@@ -16,6 +17,7 @@ export { metadata, name };
16
17
  export const settings = {
17
18
  edit,
18
19
  icon,
20
+ transforms,
19
21
  };
20
22
 
21
23
  export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createBlock } from '@wordpress/blocks';
5
+
6
+ const transforms = {
7
+ to: [
8
+ {
9
+ type: 'block',
10
+ blocks: [ 'core/post-comments-count' ],
11
+ transform: ( { textAlign } ) => {
12
+ return createBlock( 'core/post-comments-count', {
13
+ textAlign,
14
+ } );
15
+ },
16
+ },
17
+ ],
18
+ };
19
+
20
+ export default transforms;
@@ -15,12 +15,22 @@ import {
15
15
  HeadingLevelDropdown,
16
16
  useBlockEditingMode,
17
17
  } from '@wordpress/block-editor';
18
- import { ToggleControl, TextControl, PanelBody } from '@wordpress/components';
18
+ import {
19
+ ToggleControl,
20
+ TextControl,
21
+ __experimentalToolsPanel as ToolsPanel,
22
+ __experimentalToolsPanelItem as ToolsPanelItem,
23
+ } from '@wordpress/components';
19
24
  import { __ } from '@wordpress/i18n';
20
25
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
21
26
  import { useEntityProp, store as coreStore } from '@wordpress/core-data';
22
27
  import { useSelect } from '@wordpress/data';
23
28
 
29
+ /**
30
+ * Internal dependencies
31
+ */
32
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
33
+
24
34
  export default function PostTitleEdit( {
25
35
  attributes: { level, levelOptions, textAlign, isLink, rel, linkTarget },
26
36
  setAttributes,
@@ -66,6 +76,7 @@ export default function PostTitleEdit( {
66
76
  } ),
67
77
  } );
68
78
  const blockEditingMode = useBlockEditingMode();
79
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
69
80
 
70
81
  let titleElement = <TagName { ...blockProps }>{ __( 'Title' ) }</TagName>;
71
82
 
@@ -138,41 +149,82 @@ export default function PostTitleEdit( {
138
149
  />
139
150
  </BlockControls>
140
151
  <InspectorControls>
141
- <PanelBody title={ __( 'Settings' ) }>
142
- <ToggleControl
143
- __nextHasNoMarginBottom
152
+ <ToolsPanel
153
+ label={ __( 'Settings' ) }
154
+ resetAll={ () => {
155
+ setAttributes( {
156
+ rel: '',
157
+ linkTarget: '_self',
158
+ isLink: false,
159
+ } );
160
+ } }
161
+ dropdownMenuProps={ dropdownMenuProps }
162
+ >
163
+ <ToolsPanelItem
144
164
  label={ __( 'Make title a link' ) }
145
- onChange={ () =>
146
- setAttributes( { isLink: ! isLink } )
165
+ isShownByDefault
166
+ hasValue={ () => isLink }
167
+ onDeselect={ () =>
168
+ setAttributes( { isLink: false } )
147
169
  }
148
- checked={ isLink }
149
- />
170
+ >
171
+ <ToggleControl
172
+ __nextHasNoMarginBottom
173
+ label={ __( 'Make title a link' ) }
174
+ onChange={ () =>
175
+ setAttributes( { isLink: ! isLink } )
176
+ }
177
+ checked={ isLink }
178
+ />
179
+ </ToolsPanelItem>
150
180
  { isLink && (
151
181
  <>
152
- <ToggleControl
153
- __nextHasNoMarginBottom
182
+ <ToolsPanelItem
154
183
  label={ __( 'Open in new tab' ) }
155
- onChange={ ( value ) =>
184
+ isShownByDefault
185
+ hasValue={ () =>
186
+ linkTarget === '_blank'
187
+ }
188
+ onDeselect={ () =>
156
189
  setAttributes( {
157
- linkTarget: value
158
- ? '_blank'
159
- : '_self',
190
+ linkTarget: '_self',
160
191
  } )
161
192
  }
162
- checked={ linkTarget === '_blank' }
163
- />
164
- <TextControl
165
- __next40pxDefaultSize
166
- __nextHasNoMarginBottom
193
+ >
194
+ <ToggleControl
195
+ __nextHasNoMarginBottom
196
+ label={ __( 'Open in new tab' ) }
197
+ onChange={ ( value ) =>
198
+ setAttributes( {
199
+ linkTarget: value
200
+ ? '_blank'
201
+ : '_self',
202
+ } )
203
+ }
204
+ checked={ linkTarget === '_blank' }
205
+ />
206
+ </ToolsPanelItem>
207
+ <ToolsPanelItem
167
208
  label={ __( 'Link rel' ) }
168
- value={ rel }
169
- onChange={ ( newRel ) =>
170
- setAttributes( { rel: newRel } )
209
+ isShownByDefault
210
+ hasValue={ () => !! rel }
211
+ onDeselect={ () =>
212
+ setAttributes( { rel: '' } )
171
213
  }
172
- />
214
+ >
215
+ <TextControl
216
+ __next40pxDefaultSize
217
+ __nextHasNoMarginBottom
218
+ label={ __( 'Link rel' ) }
219
+ value={ rel }
220
+ onChange={ ( newRel ) =>
221
+ setAttributes( { rel: newRel } )
222
+ }
223
+ />
224
+ </ToolsPanelItem>
173
225
  </>
174
226
  ) }
175
- </PanelBody>
227
+ </ToolsPanel>
176
228
  </InspectorControls>
177
229
  </>
178
230
  ) }
@@ -12,6 +12,6 @@
12
12
  }
13
13
  }
14
14
 
15
- .wp-block-pullquote .wp-block-pullquote__citation {
15
+ .wp-block-pullquote__citation {
16
16
  color: inherit;
17
17
  }
@@ -6,8 +6,7 @@
6
6
  padding: 4em 0;
7
7
 
8
8
  p,
9
- blockquote,
10
- cite {
9
+ blockquote {
11
10
  color: inherit;
12
11
  }
13
12
 
@@ -74,7 +73,7 @@
74
73
  }
75
74
  }
76
75
 
77
- .wp-block-pullquote cite {
76
+ .wp-block-pullquote :where(cite) {
78
77
  color: inherit;
79
78
  display: block;
80
79
  }
@@ -4,8 +4,8 @@
4
4
  margin-bottom: 1.75em;
5
5
  color: currentColor;
6
6
 
7
- cite,
8
- footer,
7
+ :where(cite),
8
+ :where(footer),
9
9
  &__citation {
10
10
  color: currentColor;
11
11
  text-transform: uppercase;
@@ -27,11 +27,7 @@ export default function EnhancedPaginationModal( {
27
27
  useUnsupportedBlocks( clientId );
28
28
 
29
29
  useEffect( () => {
30
- if (
31
- enhancedPagination &&
32
- hasUnsupportedBlocks &&
33
- ! window.__experimentalFullPageClientSideNavigation
34
- ) {
30
+ if ( enhancedPagination && hasUnsupportedBlocks ) {
35
31
  setAttributes( { enhancedPagination: false } );
36
32
  setOpen( true );
37
33
  }
@@ -15,17 +15,11 @@ export default function EnhancedPaginationControl( {
15
15
  clientId,
16
16
  } ) {
17
17
  const { hasUnsupportedBlocks } = useUnsupportedBlocks( clientId );
18
- const fullPageClientSideNavigation =
19
- window.__experimentalFullPageClientSideNavigation;
20
18
 
21
19
  let help = __(
22
20
  'Reload the full page—instead of just the posts list—when visitors navigate between pages.'
23
21
  );
24
- if ( fullPageClientSideNavigation ) {
25
- help = __(
26
- 'Experimental full-page client-side navigation setting enabled.'
27
- );
28
- } else if ( hasUnsupportedBlocks ) {
22
+ if ( hasUnsupportedBlocks ) {
29
23
  help = __(
30
24
  'Enhancement disabled because there are non-compatible blocks inside the Query block.'
31
25
  );
@@ -37,12 +31,8 @@ export default function EnhancedPaginationControl( {
37
31
  __nextHasNoMarginBottom
38
32
  label={ __( 'Reload full page' ) }
39
33
  help={ help }
40
- checked={
41
- ! enhancedPagination && ! fullPageClientSideNavigation
42
- }
43
- disabled={
44
- hasUnsupportedBlocks || fullPageClientSideNavigation
45
- }
34
+ checked={ ! enhancedPagination }
35
+ disabled={ hasUnsupportedBlocks }
46
36
  onChange={ ( value ) => {
47
37
  setAttributes( {
48
38
  enhancedPagination: ! value,
package/src/rss/edit.js CHANGED
@@ -9,13 +9,14 @@ import {
9
9
  import {
10
10
  Button,
11
11
  Disabled,
12
- PanelBody,
13
12
  Placeholder,
14
13
  RangeControl,
15
14
  ToggleControl,
16
15
  ToolbarGroup,
17
16
  TextControl,
18
17
  __experimentalInputControl as InputControl,
18
+ __experimentalToolsPanel as ToolsPanel,
19
+ __experimentalToolsPanelItem as ToolsPanelItem,
19
20
  } from '@wordpress/components';
20
21
  import { useState } from '@wordpress/element';
21
22
  import { grid, list, edit, rss } from '@wordpress/icons';
@@ -23,6 +24,11 @@ import { __, _x } from '@wordpress/i18n';
23
24
  import { prependHTTP } from '@wordpress/url';
24
25
  import ServerSideRender from '@wordpress/server-side-render';
25
26
 
27
+ /**
28
+ * Internal dependencies
29
+ */
30
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
31
+
26
32
  const DEFAULT_MIN_ITEMS = 1;
27
33
  const DEFAULT_MAX_ITEMS = 20;
28
34
 
@@ -42,6 +48,8 @@ export default function RSSEdit( { attributes, setAttributes } ) {
42
48
  rel,
43
49
  } = attributes;
44
50
 
51
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
52
+
45
53
  function toggleAttribute( propName ) {
46
54
  return () => {
47
55
  const value = attributes[ propName ];
@@ -141,75 +149,153 @@ export default function RSSEdit( { attributes, setAttributes } ) {
141
149
  <ToolbarGroup controls={ toolbarControls } />
142
150
  </BlockControls>
143
151
  <InspectorControls>
144
- <PanelBody title={ __( 'Settings' ) }>
145
- <RangeControl
146
- __nextHasNoMarginBottom
147
- __next40pxDefaultSize
152
+ <ToolsPanel
153
+ label={ __( 'Settings' ) }
154
+ resetAll={ () => {
155
+ setAttributes( {
156
+ itemsToShow: 5,
157
+ displayAuthor: false,
158
+ displayDate: false,
159
+ displayExcerpt: false,
160
+ excerptLength: 55,
161
+ columns: 2,
162
+ openInNewTab: false,
163
+ } );
164
+ } }
165
+ dropdownMenuProps={ dropdownMenuProps }
166
+ >
167
+ <ToolsPanelItem
148
168
  label={ __( 'Number of items' ) }
149
- value={ itemsToShow }
150
- onChange={ ( value ) =>
151
- setAttributes( { itemsToShow: value } )
152
- }
153
- min={ DEFAULT_MIN_ITEMS }
154
- max={ DEFAULT_MAX_ITEMS }
155
- required
156
- />
157
- <ToggleControl
158
- __nextHasNoMarginBottom
159
- label={ __( 'Display author' ) }
160
- checked={ displayAuthor }
161
- onChange={ toggleAttribute( 'displayAuthor' ) }
162
- />
163
- <ToggleControl
164
- __nextHasNoMarginBottom
165
- label={ __( 'Display date' ) }
166
- checked={ displayDate }
167
- onChange={ toggleAttribute( 'displayDate' ) }
168
- />
169
- <ToggleControl
170
- __nextHasNoMarginBottom
171
- label={ __( 'Display excerpt' ) }
172
- checked={ displayExcerpt }
173
- onChange={ toggleAttribute( 'displayExcerpt' ) }
174
- />
175
- { displayExcerpt && (
169
+ hasValue={ () => itemsToShow !== 5 }
170
+ onDeselect={ () => setAttributes( { itemsToShow: 5 } ) }
171
+ isShownByDefault
172
+ >
176
173
  <RangeControl
177
174
  __nextHasNoMarginBottom
178
175
  __next40pxDefaultSize
179
- label={ __( 'Max number of words in excerpt' ) }
180
- value={ excerptLength }
176
+ label={ __( 'Number of items' ) }
177
+ value={ itemsToShow }
181
178
  onChange={ ( value ) =>
182
- setAttributes( { excerptLength: value } )
179
+ setAttributes( { itemsToShow: value } )
183
180
  }
184
- min={ 10 }
185
- max={ 100 }
181
+ min={ DEFAULT_MIN_ITEMS }
182
+ max={ DEFAULT_MAX_ITEMS }
186
183
  required
187
184
  />
185
+ </ToolsPanelItem>
186
+
187
+ <ToolsPanelItem
188
+ label={ __( 'Display author' ) }
189
+ hasValue={ () => !! displayAuthor }
190
+ onDeselect={ () =>
191
+ setAttributes( { displayAuthor: false } )
192
+ }
193
+ isShownByDefault
194
+ >
195
+ <ToggleControl
196
+ __nextHasNoMarginBottom
197
+ label={ __( 'Display author' ) }
198
+ checked={ displayAuthor }
199
+ onChange={ toggleAttribute( 'displayAuthor' ) }
200
+ />
201
+ </ToolsPanelItem>
202
+
203
+ <ToolsPanelItem
204
+ label={ __( 'Display date' ) }
205
+ hasValue={ () => !! displayDate }
206
+ onDeselect={ () =>
207
+ setAttributes( { displayDate: false } )
208
+ }
209
+ isShownByDefault
210
+ >
211
+ <ToggleControl
212
+ __nextHasNoMarginBottom
213
+ label={ __( 'Display date' ) }
214
+ checked={ displayDate }
215
+ onChange={ toggleAttribute( 'displayDate' ) }
216
+ />
217
+ </ToolsPanelItem>
218
+
219
+ <ToolsPanelItem
220
+ label={ __( 'Display excerpt' ) }
221
+ hasValue={ () => !! displayExcerpt }
222
+ onDeselect={ () =>
223
+ setAttributes( { displayExcerpt: false } )
224
+ }
225
+ isShownByDefault
226
+ >
227
+ <ToggleControl
228
+ __nextHasNoMarginBottom
229
+ label={ __( 'Display excerpt' ) }
230
+ checked={ displayExcerpt }
231
+ onChange={ toggleAttribute( 'displayExcerpt' ) }
232
+ />
233
+ </ToolsPanelItem>
234
+
235
+ { displayExcerpt && (
236
+ <ToolsPanelItem
237
+ label={ __( 'Max number of words in excerpt' ) }
238
+ hasValue={ () => excerptLength !== 55 }
239
+ onDeselect={ () =>
240
+ setAttributes( { excerptLength: 55 } )
241
+ }
242
+ isShownByDefault
243
+ >
244
+ <RangeControl
245
+ __nextHasNoMarginBottom
246
+ __next40pxDefaultSize
247
+ label={ __( 'Max number of words in excerpt' ) }
248
+ value={ excerptLength }
249
+ onChange={ ( value ) =>
250
+ setAttributes( { excerptLength: value } )
251
+ }
252
+ min={ 10 }
253
+ max={ 100 }
254
+ required
255
+ />
256
+ </ToolsPanelItem>
188
257
  ) }
258
+
189
259
  { blockLayout === 'grid' && (
190
- <RangeControl
191
- __nextHasNoMarginBottom
192
- __next40pxDefaultSize
260
+ <ToolsPanelItem
193
261
  label={ __( 'Columns' ) }
194
- value={ columns }
195
- onChange={ ( value ) =>
196
- setAttributes( { columns: value } )
197
- }
198
- min={ 2 }
199
- max={ 6 }
200
- required
201
- />
262
+ hasValue={ () => columns !== 2 }
263
+ onDeselect={ () => setAttributes( { columns: 2 } ) }
264
+ isShownByDefault
265
+ >
266
+ <RangeControl
267
+ __nextHasNoMarginBottom
268
+ __next40pxDefaultSize
269
+ label={ __( 'Columns' ) }
270
+ value={ columns }
271
+ onChange={ ( value ) =>
272
+ setAttributes( { columns: value } )
273
+ }
274
+ min={ 2 }
275
+ max={ 6 }
276
+ required
277
+ />
278
+ </ToolsPanelItem>
202
279
  ) }
203
280
 
204
- <ToggleControl
205
- __nextHasNoMarginBottom
281
+ <ToolsPanelItem
206
282
  label={ __( 'Open links in new tab' ) }
207
- checked={ openInNewTab }
208
- onChange={ ( value ) =>
209
- setAttributes( { openInNewTab: value } )
283
+ hasValue={ () => !! openInNewTab }
284
+ onDeselect={ () =>
285
+ setAttributes( { openInNewTab: false } )
210
286
  }
211
- />
212
- </PanelBody>
287
+ isShownByDefault
288
+ >
289
+ <ToggleControl
290
+ __nextHasNoMarginBottom
291
+ label={ __( 'Open links in new tab' ) }
292
+ checked={ openInNewTab }
293
+ onChange={ ( value ) =>
294
+ setAttributes( { openInNewTab: value } )
295
+ }
296
+ />
297
+ </ToolsPanelItem>
298
+ </ToolsPanel>
213
299
  </InspectorControls>
214
300
  <InspectorControls group="advanced">
215
301
  <TextControl
@@ -6,33 +6,59 @@ import clsx from 'clsx';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { HorizontalRule } from '@wordpress/components';
9
+ import {
10
+ HorizontalRule,
11
+ SelectControl,
12
+ PanelBody,
13
+ __experimentalToolsPanel as ToolsPanel,
14
+ __experimentalToolsPanelItem as ToolsPanelItem,
15
+ } from '@wordpress/components';
10
16
  import {
11
17
  useBlockProps,
12
18
  getColorClassName,
13
19
  __experimentalUseColorProps as useColorProps,
14
20
  InspectorControls,
15
- privateApis as blockEditorPrivateApis,
16
21
  } from '@wordpress/block-editor';
22
+ import { Platform } from '@wordpress/element';
17
23
  import { __ } from '@wordpress/i18n';
18
24
 
19
25
  /**
20
26
  * Internal dependencies
21
27
  */
22
28
  import useDeprecatedOpacity from './use-deprecated-opacity';
23
- import { unlock } from '../lock-unlock';
29
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
24
30
 
25
- const { HTMLElementControl } = unlock( blockEditorPrivateApis );
31
+ const HtmlElementControl = ( { tagName, setAttributes } ) => {
32
+ return (
33
+ <SelectControl
34
+ label={ __( 'HTML element' ) }
35
+ value={ tagName }
36
+ onChange={ ( newValue ) => setAttributes( { tagName: newValue } ) }
37
+ options={ [
38
+ { label: __( 'Default (<hr>)' ), value: 'hr' },
39
+ { label: '<div>', value: 'div' },
40
+ ] }
41
+ help={
42
+ tagName === 'hr'
43
+ ? __(
44
+ 'Only select <hr> if the separator conveys important information and should be announced by screen readers.'
45
+ )
46
+ : __(
47
+ 'The <div> element should only be used if the block is a design element with no semantic meaning.'
48
+ )
49
+ }
50
+ __next40pxDefaultSize
51
+ __nextHasNoMarginBottom
52
+ />
53
+ );
54
+ };
26
55
 
27
- export default function SeparatorEdit( {
28
- attributes,
29
- setAttributes,
30
- clientId,
31
- } ) {
56
+ export default function SeparatorEdit( { attributes, setAttributes } ) {
32
57
  const { backgroundColor, opacity, style, tagName } = attributes;
33
58
  const colorProps = useColorProps( attributes );
34
59
  const currentColor = colorProps?.style?.backgroundColor;
35
60
  const hasCustomColor = !! style?.color?.background;
61
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
36
62
 
37
63
  useDeprecatedOpacity( opacity, currentColor, setAttributes );
38
64
 
@@ -58,18 +84,37 @@ export default function SeparatorEdit( {
58
84
 
59
85
  return (
60
86
  <>
61
- <InspectorControls group="advanced">
62
- <HTMLElementControl
63
- tagName={ tagName }
64
- onChange={ ( value ) =>
65
- setAttributes( { tagName: value } )
66
- }
67
- clientId={ clientId }
68
- options={ [
69
- { label: __( 'Default (<hr>)' ), value: 'hr' },
70
- { label: '<div>', value: 'div' },
71
- ] }
72
- />
87
+ <InspectorControls>
88
+ { Platform.isNative ? (
89
+ <PanelBody title={ __( 'Settings' ) }>
90
+ <HtmlElementControl
91
+ tagName={ tagName }
92
+ setAttributes={ setAttributes }
93
+ />
94
+ </PanelBody>
95
+ ) : (
96
+ <ToolsPanel
97
+ label={ __( 'Settings' ) }
98
+ resetAll={ () => {
99
+ setAttributes( { tagName: 'hr' } );
100
+ } }
101
+ dropdownMenuProps={ dropdownMenuProps }
102
+ >
103
+ <ToolsPanelItem
104
+ hasValue={ () => tagName !== 'hr' }
105
+ label={ __( 'HTML element' ) }
106
+ onDeselect={ () =>
107
+ setAttributes( { tagName: 'hr' } )
108
+ }
109
+ isShownByDefault
110
+ >
111
+ <HtmlElementControl
112
+ tagName={ tagName }
113
+ setAttributes={ setAttributes }
114
+ />
115
+ </ToolsPanelItem>
116
+ </ToolsPanel>
117
+ ) }
73
118
  </InspectorControls>
74
119
  <Wrapper
75
120
  { ...useBlockProps( {
@@ -9,7 +9,8 @@
9
9
  "attributes": {
10
10
  "text": {
11
11
  "type": "string",
12
- "source": "raw"
12
+ "source": "raw",
13
+ "role": "content"
13
14
  }
14
15
  },
15
16
  "supports": {
@@ -17,7 +17,7 @@
17
17
  function render_block_core_site_title( $attributes ) {
18
18
  $site_title = get_bloginfo( 'name' );
19
19
  if ( ! trim( $site_title ) ) {
20
- return;
20
+ return '';
21
21
  }
22
22
 
23
23
  $tag_name = 'h1';