@wordpress/block-library 9.24.0 → 9.26.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 (300) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/avatar/edit.js +84 -39
  3. package/build/avatar/edit.js.map +1 -1
  4. package/build/avatar/user-control.js +32 -17
  5. package/build/avatar/user-control.js.map +1 -1
  6. package/build/button/edit.js +29 -17
  7. package/build/button/edit.js.map +1 -1
  8. package/build/columns/edit.js +18 -22
  9. package/build/columns/edit.js.map +1 -1
  10. package/build/comment-author-name/edit.js +41 -12
  11. package/build/comment-author-name/edit.js.map +1 -1
  12. package/build/comment-date/edit.js +41 -12
  13. package/build/comment-date/edit.js.map +1 -1
  14. package/build/comment-edit-link/edit.js +27 -7
  15. package/build/comment-edit-link/edit.js.map +1 -1
  16. package/build/comments/edit/comments-inspector-controls.js +1 -3
  17. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  18. package/build/comments-pagination/edit.js +23 -9
  19. package/build/comments-pagination/edit.js.map +1 -1
  20. package/build/comments-title/edit.js +41 -12
  21. package/build/comments-title/edit.js.map +1 -1
  22. package/build/details/edit.js +27 -3
  23. package/build/details/edit.js.map +1 -1
  24. package/build/embed/edit.js +2 -4
  25. package/build/embed/edit.js.map +1 -1
  26. package/build/embed/embed-controls.js +41 -22
  27. package/build/embed/embed-controls.js.map +1 -1
  28. package/build/embed/variations.js +0 -10
  29. package/build/embed/variations.js.map +1 -1
  30. package/build/file/inspector.js +73 -30
  31. package/build/file/inspector.js.map +1 -1
  32. package/build/form/edit.js +67 -38
  33. package/build/form/edit.js.map +1 -1
  34. package/build/form/index.js +3 -3
  35. package/build/form/index.js.map +1 -1
  36. package/build/form-input/edit.js +47 -18
  37. package/build/form-input/edit.js.map +1 -1
  38. package/build/form-input/index.js +2 -1
  39. package/build/form-input/index.js.map +1 -1
  40. package/build/form-submission-notification/index.js +2 -1
  41. package/build/form-submission-notification/index.js.map +1 -1
  42. package/build/form-submit-button/index.js +2 -1
  43. package/build/form-submit-button/index.js.map +1 -1
  44. package/build/image/image.js +1 -0
  45. package/build/image/image.js.map +1 -1
  46. package/build/image/view.js +0 -3
  47. package/build/image/view.js.map +1 -1
  48. package/build/latest-posts/edit.js +154 -82
  49. package/build/latest-posts/edit.js.map +1 -1
  50. package/build/list/ordered-list-settings.js +131 -52
  51. package/build/list/ordered-list-settings.js.map +1 -1
  52. package/build/navigation/edit/index.js +93 -51
  53. package/build/navigation/edit/index.js.map +1 -1
  54. package/build/navigation/edit/overlay-menu-preview.js +43 -27
  55. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  56. package/build/navigation-link/edit.js +11 -0
  57. package/build/navigation-link/edit.js.map +1 -1
  58. package/build/navigation-link/index.js +3 -0
  59. package/build/navigation-link/index.js.map +1 -1
  60. package/build/navigation-link/transforms.js +2 -0
  61. package/build/navigation-link/transforms.js.map +1 -1
  62. package/build/navigation-link/update-attributes.js +1 -0
  63. package/build/navigation-link/update-attributes.js.map +1 -1
  64. package/build/navigation-submenu/index.js +3 -0
  65. package/build/navigation-submenu/index.js.map +1 -1
  66. package/build/post-author/edit.js +75 -18
  67. package/build/post-author/edit.js.map +1 -1
  68. package/build/post-comments-count/index.js +3 -1
  69. package/build/post-comments-count/index.js.map +1 -1
  70. package/build/post-comments-count/transforms.js +26 -0
  71. package/build/post-comments-count/transforms.js.map +1 -0
  72. package/build/post-comments-link/index.js +3 -1
  73. package/build/post-comments-link/index.js.map +1 -1
  74. package/build/post-comments-link/transforms.js +26 -0
  75. package/build/post-comments-link/transforms.js.map +1 -0
  76. package/build/post-navigation-link/edit.js +72 -33
  77. package/build/post-navigation-link/edit.js.map +1 -1
  78. package/build/post-title/edit.js +56 -18
  79. package/build/post-title/edit.js.map +1 -1
  80. package/build/query/edit/enhanced-pagination-modal.js +1 -1
  81. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  82. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  83. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  84. package/build/rss/edit.js +120 -46
  85. package/build/rss/edit.js.map +1 -1
  86. package/build/separator/edit.js +52 -20
  87. package/build/separator/edit.js.map +1 -1
  88. package/build/shortcode/index.js +2 -1
  89. package/build/shortcode/index.js.map +1 -1
  90. package/build/site-logo/edit.js +53 -19
  91. package/build/site-logo/edit.js.map +1 -1
  92. package/build/social-link/edit.js +21 -5
  93. package/build/social-link/edit.js.map +1 -1
  94. package/build/social-link/edit.native.js +13 -5
  95. package/build/social-link/edit.native.js.map +1 -1
  96. package/build/social-link/social-list.js +17 -25
  97. package/build/social-link/social-list.js.map +1 -1
  98. package/build/social-link/variations.js +53 -48
  99. package/build/social-link/variations.js.map +1 -1
  100. package/build/social-links/edit.js +38 -45
  101. package/build/social-links/edit.js.map +1 -1
  102. package/build/video/tracks-editor.js +63 -21
  103. package/build/video/tracks-editor.js.map +1 -1
  104. package/build-module/avatar/edit.js +83 -38
  105. package/build-module/avatar/edit.js.map +1 -1
  106. package/build-module/avatar/user-control.js +33 -18
  107. package/build-module/avatar/user-control.js.map +1 -1
  108. package/build-module/button/edit.js +30 -18
  109. package/build-module/button/edit.js.map +1 -1
  110. package/build-module/columns/edit.js +18 -22
  111. package/build-module/columns/edit.js.map +1 -1
  112. package/build-module/comment-author-name/edit.js +42 -13
  113. package/build-module/comment-author-name/edit.js.map +1 -1
  114. package/build-module/comment-date/edit.js +42 -13
  115. package/build-module/comment-date/edit.js.map +1 -1
  116. package/build-module/comment-edit-link/edit.js +28 -8
  117. package/build-module/comment-edit-link/edit.js.map +1 -1
  118. package/build-module/comments/edit/comments-inspector-controls.js +1 -3
  119. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  120. package/build-module/comments-pagination/edit.js +24 -10
  121. package/build-module/comments-pagination/edit.js.map +1 -1
  122. package/build-module/comments-title/edit.js +42 -13
  123. package/build-module/comments-title/edit.js.map +1 -1
  124. package/build-module/details/edit.js +29 -5
  125. package/build-module/details/edit.js.map +1 -1
  126. package/build-module/embed/edit.js +2 -4
  127. package/build-module/embed/edit.js.map +1 -1
  128. package/build-module/embed/embed-controls.js +42 -23
  129. package/build-module/embed/embed-controls.js.map +1 -1
  130. package/build-module/embed/variations.js +0 -10
  131. package/build-module/embed/variations.js.map +1 -1
  132. package/build-module/file/inspector.js +74 -31
  133. package/build-module/file/inspector.js.map +1 -1
  134. package/build-module/form/edit.js +68 -39
  135. package/build-module/form/edit.js.map +1 -1
  136. package/build-module/form/index.js +3 -3
  137. package/build-module/form/index.js.map +1 -1
  138. package/build-module/form-input/edit.js +48 -19
  139. package/build-module/form-input/edit.js.map +1 -1
  140. package/build-module/form-input/index.js +2 -1
  141. package/build-module/form-input/index.js.map +1 -1
  142. package/build-module/form-submission-notification/index.js +2 -1
  143. package/build-module/form-submission-notification/index.js.map +1 -1
  144. package/build-module/form-submit-button/index.js +2 -1
  145. package/build-module/form-submit-button/index.js.map +1 -1
  146. package/build-module/image/image.js +1 -0
  147. package/build-module/image/image.js.map +1 -1
  148. package/build-module/image/view.js +0 -3
  149. package/build-module/image/view.js.map +1 -1
  150. package/build-module/latest-posts/edit.js +155 -83
  151. package/build-module/latest-posts/edit.js.map +1 -1
  152. package/build-module/list/ordered-list-settings.js +132 -53
  153. package/build-module/list/ordered-list-settings.js.map +1 -1
  154. package/build-module/navigation/edit/index.js +94 -52
  155. package/build-module/navigation/edit/index.js.map +1 -1
  156. package/build-module/navigation/edit/overlay-menu-preview.js +44 -28
  157. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  158. package/build-module/navigation-link/edit.js +11 -0
  159. package/build-module/navigation-link/edit.js.map +1 -1
  160. package/build-module/navigation-link/index.js +3 -0
  161. package/build-module/navigation-link/index.js.map +1 -1
  162. package/build-module/navigation-link/transforms.js +2 -0
  163. package/build-module/navigation-link/transforms.js.map +1 -1
  164. package/build-module/navigation-link/update-attributes.js +1 -0
  165. package/build-module/navigation-link/update-attributes.js.map +1 -1
  166. package/build-module/navigation-submenu/index.js +3 -0
  167. package/build-module/navigation-submenu/index.js.map +1 -1
  168. package/build-module/post-author/edit.js +76 -19
  169. package/build-module/post-author/edit.js.map +1 -1
  170. package/build-module/post-comments-count/index.js +3 -1
  171. package/build-module/post-comments-count/index.js.map +1 -1
  172. package/build-module/post-comments-count/transforms.js +19 -0
  173. package/build-module/post-comments-count/transforms.js.map +1 -0
  174. package/build-module/post-comments-link/index.js +3 -1
  175. package/build-module/post-comments-link/index.js.map +1 -1
  176. package/build-module/post-comments-link/transforms.js +19 -0
  177. package/build-module/post-comments-link/transforms.js.map +1 -0
  178. package/build-module/post-navigation-link/edit.js +73 -34
  179. package/build-module/post-navigation-link/edit.js.map +1 -1
  180. package/build-module/post-title/edit.js +57 -19
  181. package/build-module/post-title/edit.js.map +1 -1
  182. package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
  183. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  184. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  185. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  186. package/build-module/rss/edit.js +121 -47
  187. package/build-module/rss/edit.js.map +1 -1
  188. package/build-module/separator/edit.js +54 -22
  189. package/build-module/separator/edit.js.map +1 -1
  190. package/build-module/shortcode/index.js +2 -1
  191. package/build-module/shortcode/index.js.map +1 -1
  192. package/build-module/site-logo/edit.js +54 -20
  193. package/build-module/site-logo/edit.js.map +1 -1
  194. package/build-module/social-link/edit.js +24 -8
  195. package/build-module/social-link/edit.js.map +1 -1
  196. package/build-module/social-link/edit.native.js +15 -6
  197. package/build-module/social-link/edit.native.js.map +1 -1
  198. package/build-module/social-link/social-list.js +16 -21
  199. package/build-module/social-link/social-list.js.map +1 -1
  200. package/build-module/social-link/variations.js +53 -48
  201. package/build-module/social-link/variations.js.map +1 -1
  202. package/build-module/social-links/edit.js +40 -47
  203. package/build-module/social-links/edit.js.map +1 -1
  204. package/build-module/video/tracks-editor.js +65 -23
  205. package/build-module/video/tracks-editor.js.map +1 -1
  206. package/build-style/calendar/style-rtl.css +7 -7
  207. package/build-style/calendar/style.css +7 -7
  208. package/build-style/comments-pagination/editor-rtl.css +0 -12
  209. package/build-style/comments-pagination/editor.css +0 -14
  210. package/build-style/comments-pagination/style-rtl.css +0 -7
  211. package/build-style/comments-pagination/style.css +0 -9
  212. package/build-style/editor-rtl.css +9 -21
  213. package/build-style/editor.css +9 -23
  214. package/build-style/gallery/style-rtl.css +1 -0
  215. package/build-style/gallery/style.css +1 -0
  216. package/build-style/navigation/editor-rtl.css +8 -3
  217. package/build-style/navigation/editor.css +8 -3
  218. package/build-style/navigation/style-rtl.css +4 -0
  219. package/build-style/navigation/style.css +4 -0
  220. package/build-style/pullquote/editor-rtl.css +1 -1
  221. package/build-style/pullquote/editor.css +1 -1
  222. package/build-style/pullquote/style-rtl.css +2 -3
  223. package/build-style/pullquote/style.css +2 -3
  224. package/build-style/pullquote/theme-rtl.css +2 -2
  225. package/build-style/pullquote/theme.css +2 -2
  226. package/build-style/style-rtl.css +14 -17
  227. package/build-style/style.css +14 -19
  228. package/build-style/theme-rtl.css +2 -2
  229. package/build-style/theme.css +2 -2
  230. package/package.json +35 -35
  231. package/src/avatar/edit.js +99 -51
  232. package/src/avatar/user-control.js +34 -29
  233. package/src/button/edit.js +44 -29
  234. package/src/calendar/style.scss +10 -10
  235. package/src/columns/edit.js +20 -31
  236. package/src/comment-author-name/edit.js +54 -13
  237. package/src/comment-date/edit.js +50 -15
  238. package/src/comment-edit-link/edit.js +39 -11
  239. package/src/comments/edit/comments-inspector-controls.js +0 -2
  240. package/src/comments-pagination/edit.js +29 -9
  241. package/src/comments-pagination/editor.scss +0 -15
  242. package/src/comments-pagination/style.scss +0 -8
  243. package/src/comments-title/edit.js +53 -15
  244. package/src/details/edit.js +36 -4
  245. package/src/editor.scss +0 -1
  246. package/src/embed/edit.js +3 -5
  247. package/src/embed/embed-controls.js +55 -33
  248. package/src/embed/variations.js +0 -8
  249. package/src/file/inspector.js +99 -45
  250. package/src/form/block.json +1 -2
  251. package/src/form/edit.js +91 -47
  252. package/src/form/index.js +1 -0
  253. package/src/form-input/edit.js +56 -18
  254. package/src/form-input/index.js +1 -0
  255. package/src/form-submission-notification/index.js +1 -0
  256. package/src/form-submit-button/index.js +1 -0
  257. package/src/gallery/style.scss +1 -0
  258. package/src/image/image.js +1 -0
  259. package/src/image/index.php +4 -1
  260. package/src/image/view.js +0 -3
  261. package/src/latest-posts/edit.js +206 -98
  262. package/src/list/ordered-list-settings.js +172 -62
  263. package/src/navigation/edit/index.js +127 -64
  264. package/src/navigation/edit/overlay-menu-preview.js +43 -26
  265. package/src/navigation/editor.scss +8 -4
  266. package/src/navigation/style.scss +8 -0
  267. package/src/navigation-link/block.json +3 -0
  268. package/src/navigation-link/edit.js +14 -1
  269. package/src/navigation-link/index.php +4 -0
  270. package/src/navigation-link/transforms.js +2 -1
  271. package/src/navigation-link/update-attributes.js +1 -0
  272. package/src/navigation-submenu/block.json +3 -0
  273. package/src/navigation-submenu/index.php +4 -0
  274. package/src/post-author/edit.js +91 -27
  275. package/src/post-comments-count/index.js +2 -0
  276. package/src/post-comments-count/transforms.js +20 -0
  277. package/src/post-comments-link/index.js +2 -0
  278. package/src/post-comments-link/transforms.js +20 -0
  279. package/src/post-navigation-link/edit.js +96 -51
  280. package/src/post-title/edit.js +76 -24
  281. package/src/pullquote/editor.scss +1 -1
  282. package/src/pullquote/style.scss +2 -3
  283. package/src/pullquote/theme.scss +2 -2
  284. package/src/query/edit/enhanced-pagination-modal.js +1 -5
  285. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -13
  286. package/src/rss/edit.js +141 -55
  287. package/src/separator/edit.js +66 -21
  288. package/src/shortcode/block.json +2 -1
  289. package/src/site-logo/edit.js +69 -26
  290. package/src/site-title/index.php +1 -1
  291. package/src/social-link/edit.js +18 -7
  292. package/src/social-link/edit.native.js +10 -4
  293. package/src/social-link/index.php +62 -49
  294. package/src/social-link/social-list.js +15 -20
  295. package/src/social-link/variations.js +53 -48
  296. package/src/social-links/edit.js +38 -60
  297. package/src/video/tracks-editor.js +75 -22
  298. package/build-style/post-author/editor-rtl.css +0 -140
  299. package/build-style/post-author/editor.css +0 -140
  300. package/src/post-author/editor.scss +0 -7
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": {
@@ -14,7 +14,6 @@ import {
14
14
  } from '@wordpress/element';
15
15
  import { __, isRTL } from '@wordpress/i18n';
16
16
  import {
17
- PanelBody,
18
17
  RangeControl,
19
18
  ResizableBox,
20
19
  Spinner,
@@ -24,6 +23,9 @@ import {
24
23
  Button,
25
24
  DropZone,
26
25
  FlexItem,
26
+ PanelBody,
27
+ __experimentalToolsPanel as ToolsPanel,
28
+ __experimentalToolsPanelItem as ToolsPanelItem,
27
29
  __experimentalItemGroup as ItemGroup,
28
30
  __experimentalHStack as HStack,
29
31
  __experimentalTruncate as Truncate,
@@ -47,6 +49,7 @@ import { store as noticesStore } from '@wordpress/notices';
47
49
  * Internal dependencies
48
50
  */
49
51
  import { MIN_SIZE } from '../image/constants';
52
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
50
53
 
51
54
  const ALLOWED_MEDIA_TYPES = [ 'image' ];
52
55
  const ACCEPT_MEDIA_STRING = 'image/*';
@@ -70,6 +73,7 @@ const SiteLogo = ( {
70
73
  const [ { naturalWidth, naturalHeight }, setNaturalSize ] = useState( {} );
71
74
  const [ isEditingImage, setIsEditingImage ] = useState( false );
72
75
  const { toggleSelection } = useDispatch( blockEditorStore );
76
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
73
77
  const { imageEditing, maxWidth, title } = useSelect( ( select ) => {
74
78
  const settings = select( blockEditorStore ).getSettings();
75
79
  const siteEntities = select( coreStore ).getEntityRecord(
@@ -276,31 +280,61 @@ const SiteLogo = ( {
276
280
  return (
277
281
  <>
278
282
  <InspectorControls>
279
- <PanelBody title={ __( 'Settings' ) }>
280
- <RangeControl
281
- __nextHasNoMarginBottom
282
- __next40pxDefaultSize
283
+ <ToolsPanel
284
+ label={ __( 'Settings' ) }
285
+ dropdownMenuProps={ dropdownMenuProps }
286
+ >
287
+ <ToolsPanelItem
288
+ isShownByDefault
289
+ hasValue={ () => !! width }
283
290
  label={ __( 'Image width' ) }
284
- onChange={ ( newWidth ) =>
285
- setAttributes( { width: newWidth } )
291
+ onDeselect={ () =>
292
+ setAttributes( { width: undefined } )
286
293
  }
287
- min={ minWidth }
288
- max={ maxWidthBuffer }
289
- initialPosition={ Math.min(
290
- defaultWidth,
291
- maxWidthBuffer
292
- ) }
293
- value={ width || '' }
294
- disabled={ ! isResizable }
295
- />
296
- <ToggleControl
297
- __nextHasNoMarginBottom
294
+ >
295
+ <RangeControl
296
+ __nextHasNoMarginBottom
297
+ __next40pxDefaultSize
298
+ label={ __( 'Image width' ) }
299
+ onChange={ ( newWidth ) =>
300
+ setAttributes( { width: newWidth } )
301
+ }
302
+ min={ minWidth }
303
+ max={ maxWidthBuffer }
304
+ initialPosition={ Math.min(
305
+ defaultWidth,
306
+ maxWidthBuffer
307
+ ) }
308
+ value={ width || '' }
309
+ disabled={ ! isResizable }
310
+ />
311
+ </ToolsPanelItem>
312
+
313
+ <ToolsPanelItem
314
+ isShownByDefault
315
+ hasValue={ () => ! isLink }
298
316
  label={ __( 'Link image to home' ) }
299
- onChange={ () => setAttributes( { isLink: ! isLink } ) }
300
- checked={ isLink }
301
- />
317
+ onDeselect={ () => setAttributes( { isLink: true } ) }
318
+ >
319
+ <ToggleControl
320
+ __nextHasNoMarginBottom
321
+ label={ __( 'Link image to home' ) }
322
+ onChange={ () =>
323
+ setAttributes( { isLink: ! isLink } )
324
+ }
325
+ checked={ isLink }
326
+ />
327
+ </ToolsPanelItem>
328
+
302
329
  { isLink && (
303
- <>
330
+ <ToolsPanelItem
331
+ isShownByDefault
332
+ hasValue={ () => linkTarget === '_blank' }
333
+ label={ __( 'Open in new tab' ) }
334
+ onDeselect={ () =>
335
+ setAttributes( { linkTarget: '_self' } )
336
+ }
337
+ >
304
338
  <ToggleControl
305
339
  __nextHasNoMarginBottom
306
340
  label={ __( 'Open in new tab' ) }
@@ -311,10 +345,19 @@ const SiteLogo = ( {
311
345
  }
312
346
  checked={ linkTarget === '_blank' }
313
347
  />
314
- </>
348
+ </ToolsPanelItem>
315
349
  ) }
350
+
316
351
  { canUserEdit && (
317
- <>
352
+ <ToolsPanelItem
353
+ isShownByDefault
354
+ hasValue={ () => !! shouldSyncIcon }
355
+ label={ __( 'Use as Site Icon' ) }
356
+ onDeselect={ () => {
357
+ setAttributes( { shouldSyncIcon: false } );
358
+ setIcon( undefined );
359
+ } }
360
+ >
318
361
  <ToggleControl
319
362
  __nextHasNoMarginBottom
320
363
  label={ __( 'Use as Site Icon' ) }
@@ -325,9 +368,9 @@ const SiteLogo = ( {
325
368
  checked={ !! shouldSyncIcon }
326
369
  help={ syncSiteIconHelpText }
327
370
  />
328
- </>
371
+ </ToolsPanelItem>
329
372
  ) }
330
- </PanelBody>
373
+ </ToolsPanel>
331
374
  </InspectorControls>
332
375
  <BlockControls group="block">
333
376
  { canEditImage && ! isEditingImage && (
@@ -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';
@@ -7,8 +7,7 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { DELETE, BACKSPACE, ENTER } from '@wordpress/keycodes';
10
- import { useDispatch } from '@wordpress/data';
11
-
10
+ import { useDispatch, useSelect } from '@wordpress/data';
12
11
  import {
13
12
  BlockControls,
14
13
  InspectorControls,
@@ -20,6 +19,7 @@ import {
20
19
  } from '@wordpress/block-editor';
21
20
  import { useState, useRef } from '@wordpress/element';
22
21
  import {
22
+ Icon,
23
23
  Button,
24
24
  Dropdown,
25
25
  TextControl,
@@ -31,11 +31,12 @@ import {
31
31
  import { useMergeRefs } from '@wordpress/compose';
32
32
  import { __ } from '@wordpress/i18n';
33
33
  import { keyboardReturn } from '@wordpress/icons';
34
+ import { store as blocksStore } from '@wordpress/blocks';
34
35
 
35
36
  /**
36
37
  * Internal dependencies
37
38
  */
38
- import { getIconBySite, getNameBySite } from './social-list';
39
+ import { getSocialService } from './social-list';
39
40
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
40
41
 
41
42
  const SocialLinkURLPopover = ( {
@@ -108,6 +109,7 @@ const SocialLinkEdit = ( {
108
109
  isSelected,
109
110
  setAttributes,
110
111
  clientId,
112
+ name,
111
113
  } ) => {
112
114
  const { url, service, label = '', rel } = attributes;
113
115
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
@@ -138,8 +140,17 @@ const SocialLinkEdit = ( {
138
140
  const [ popoverAnchor, setPopoverAnchor ] = useState( null );
139
141
  const isContentOnlyMode = useBlockEditingMode() === 'contentOnly';
140
142
 
141
- const IconComponent = getIconBySite( service );
142
- const socialLinkName = getNameBySite( service );
143
+ const { activeVariation } = useSelect(
144
+ ( select ) => {
145
+ const { getActiveBlockVariation } = select( blocksStore );
146
+ return {
147
+ activeVariation: getActiveBlockVariation( name, attributes ),
148
+ };
149
+ },
150
+ [ name, attributes ]
151
+ );
152
+
153
+ const { icon, label: socialLinkName } = getSocialService( activeVariation );
143
154
  // The initial label (ie. the link text) is an empty string.
144
155
  // We want to prevent empty links so that the link text always fallbacks to
145
156
  // the social name, even when users enter and save an empty string or only
@@ -167,7 +178,7 @@ const SocialLinkEdit = ( {
167
178
  // to edit this attribute.
168
179
  <BlockControls group="other">
169
180
  <Dropdown
170
- popoverProps={ { position: 'bottom right' } }
181
+ popoverProps={ { placement: 'bottom-start' } }
171
182
  renderToggle={ ( { isOpen, onToggle } ) => (
172
183
  <ToolbarButton
173
184
  onClick={ onToggle }
@@ -258,7 +269,7 @@ const SocialLinkEdit = ( {
258
269
  */
259
270
  /* eslint-disable jsx-a11y/no-redundant-roles */ }
260
271
  <button aria-haspopup="dialog" { ...blockProps } role="button">
261
- <IconComponent />
272
+ <Icon icon={ icon } />
262
273
  <span
263
274
  className={ clsx( 'wp-block-social-link-label', {
264
275
  'screen-reader-text': ! showLabels,
@@ -20,10 +20,12 @@ import { compose } from '@wordpress/compose';
20
20
  import { __, sprintf } from '@wordpress/i18n';
21
21
  import { link, Icon } from '@wordpress/icons';
22
22
  import { withSelect } from '@wordpress/data';
23
+ import { store as blocksStore } from '@wordpress/blocks';
24
+
23
25
  /**
24
26
  * Internal dependencies
25
27
  */
26
- import { getIconBySite, getNameBySite } from './social-list';
28
+ import { getSocialService } from './social-list';
27
29
  import styles from './editor.scss';
28
30
 
29
31
  const DEFAULT_ACTIVE_ICON_STYLES = {
@@ -54,6 +56,7 @@ const SocialLinkEdit = ( {
54
56
  isSelected,
55
57
  onFocus,
56
58
  name,
59
+ activeVariation,
57
60
  } ) => {
58
61
  const { url, service = name } = attributes;
59
62
  const [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );
@@ -64,8 +67,7 @@ const SocialLinkEdit = ( {
64
67
  DEFAULT_ACTIVE_ICON_STYLES;
65
68
  const animatedValue = useRef( new Animated.Value( 0 ) ).current;
66
69
 
67
- const IconComponent = getIconBySite( service )();
68
- const socialLinkName = getNameBySite( service );
70
+ const { icon, label: socialLinkName } = getSocialService( activeVariation );
69
71
 
70
72
  // When new social icon is added link sheet is opened automatically.
71
73
  useEffect( () => {
@@ -190,7 +192,7 @@ const SocialLinkEdit = ( {
190
192
  >
191
193
  <Icon
192
194
  animated
193
- icon={ IconComponent }
195
+ icon={ icon() }
194
196
  style={ { color: activeIcon.color } }
195
197
  />
196
198
  </Animated.View>
@@ -202,12 +204,16 @@ const SocialLinkEdit = ( {
202
204
  export default compose( [
203
205
  withSelect( ( select, { clientId } ) => {
204
206
  const { getBlock } = select( blockEditorStore );
207
+ const { getActiveBlockVariation } = select( blocksStore );
205
208
 
206
209
  const block = getBlock( clientId );
207
210
  const name = block?.name.substring( 17 );
208
211
 
209
212
  return {
210
213
  name,
214
+ activeVariation: block
215
+ ? getActiveBlockVariation( block.name, block.attributes )
216
+ : undefined,
211
217
  };
212
218
  } ),
213
219
  ] )( SocialLinkEdit );