@wordpress/block-library 9.14.0 → 9.15.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 (344) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/archives/edit.js +83 -36
  4. package/build/archives/edit.js.map +1 -1
  5. package/build/button/deprecated.js +182 -1
  6. package/build/button/deprecated.js.map +1 -1
  7. package/build/button/edit.js +47 -25
  8. package/build/button/edit.js.map +1 -1
  9. package/build/button/index.js +8 -2
  10. package/build/button/index.js.map +1 -1
  11. package/build/button/save.js +8 -5
  12. package/build/button/save.js.map +1 -1
  13. package/build/column/edit.js +33 -13
  14. package/build/column/edit.js.map +1 -1
  15. package/build/columns/edit.js +50 -27
  16. package/build/columns/edit.js.map +1 -1
  17. package/build/comments/index.js +1 -0
  18. package/build/comments/index.js.map +1 -1
  19. package/build/cover/edit/index.js +9 -3
  20. package/build/cover/edit/index.js.map +1 -1
  21. package/build/cover/edit.native.js +1 -1
  22. package/build/cover/edit.native.js.map +1 -1
  23. package/build/details/edit.js +29 -7
  24. package/build/details/edit.js.map +1 -1
  25. package/build/image/transforms.js +1 -0
  26. package/build/image/transforms.js.map +1 -1
  27. package/build/latest-posts/deprecated.js +12 -0
  28. package/build/latest-posts/deprecated.js.map +1 -1
  29. package/build/latest-posts/index.js +12 -0
  30. package/build/latest-posts/index.js.map +1 -1
  31. package/build/loginout/edit.js +42 -13
  32. package/build/loginout/edit.js.map +1 -1
  33. package/build/media-text/edit.js +59 -31
  34. package/build/media-text/edit.js.map +1 -1
  35. package/build/more/edit.js +28 -7
  36. package/build/more/edit.js.map +1 -1
  37. package/build/navigation/edit/navigation-menu-selector.js +5 -3
  38. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  39. package/build/navigation-link/edit.js +95 -55
  40. package/build/navigation-link/edit.js.map +1 -1
  41. package/build/navigation-submenu/edit.js +105 -53
  42. package/build/navigation-submenu/edit.js.map +1 -1
  43. package/build/page-list/edit.js +44 -25
  44. package/build/page-list/edit.js.map +1 -1
  45. package/build/paragraph/edit.js +14 -4
  46. package/build/paragraph/edit.js.map +1 -1
  47. package/build/post-author/edit.js +15 -3
  48. package/build/post-author/edit.js.map +1 -1
  49. package/build/post-author/index.js +4 -2
  50. package/build/post-author/index.js.map +1 -1
  51. package/build/post-author-name/edit.js +11 -5
  52. package/build/post-author-name/edit.js.map +1 -1
  53. package/build/post-author-name/index.js +4 -2
  54. package/build/post-author-name/index.js.map +1 -1
  55. package/build/post-comments-form/index.js +6 -1
  56. package/build/post-comments-form/index.js.map +1 -1
  57. package/build/post-comments-link/index.js +8 -1
  58. package/build/post-comments-link/index.js.map +1 -1
  59. package/build/post-date/edit.js +58 -18
  60. package/build/post-date/edit.js.map +1 -1
  61. package/build/post-date/index.js +2 -1
  62. package/build/post-date/index.js.map +1 -1
  63. package/build/post-excerpt/edit.js +42 -18
  64. package/build/post-excerpt/edit.js.map +1 -1
  65. package/build/post-featured-image/dimension-controls.js +17 -19
  66. package/build/post-featured-image/dimension-controls.js.map +1 -1
  67. package/build/post-featured-image/edit.js +45 -11
  68. package/build/post-featured-image/edit.js.map +1 -1
  69. package/build/post-featured-image/index.js +6 -3
  70. package/build/post-featured-image/index.js.map +1 -1
  71. package/build/post-navigation-link/index.js +11 -7
  72. package/build/post-navigation-link/index.js.map +1 -1
  73. package/build/post-navigation-link/variations.js +2 -2
  74. package/build/post-navigation-link/variations.js.map +1 -1
  75. package/build/post-template/index.js +11 -1
  76. package/build/post-template/index.js.map +1 -1
  77. package/build/post-title/index.js +6 -3
  78. package/build/post-title/index.js.map +1 -1
  79. package/build/query-no-results/index.js +10 -9
  80. package/build/query-no-results/index.js.map +1 -1
  81. package/build/query-pagination/edit.js +47 -17
  82. package/build/query-pagination/edit.js.map +1 -1
  83. package/build/query-pagination/query-pagination-label-control.js +1 -1
  84. package/build/query-pagination/query-pagination-label-control.js.map +1 -1
  85. package/build/query-pagination-numbers/edit.js +33 -15
  86. package/build/query-pagination-numbers/edit.js.map +1 -1
  87. package/build/query-total/edit.js +8 -10
  88. package/build/query-total/edit.js.map +1 -1
  89. package/build/query-total/index.js +8 -1
  90. package/build/query-total/index.js.map +1 -1
  91. package/build/read-more/index.js +7 -1
  92. package/build/read-more/index.js.map +1 -1
  93. package/build/site-logo/index.js +4 -2
  94. package/build/site-logo/index.js.map +1 -1
  95. package/build/site-title/edit.js +41 -12
  96. package/build/site-title/edit.js.map +1 -1
  97. package/build/site-title/index.js +4 -2
  98. package/build/site-title/index.js.map +1 -1
  99. package/build/social-link/edit.js +19 -3
  100. package/build/social-link/edit.js.map +1 -1
  101. package/build/social-links/edit.js +41 -12
  102. package/build/social-links/edit.js.map +1 -1
  103. package/build/spacer/controls.js +34 -12
  104. package/build/spacer/controls.js.map +1 -1
  105. package/build/table/edit.js +48 -15
  106. package/build/table/edit.js.map +1 -1
  107. package/build/table/index.js +4 -1
  108. package/build/table/index.js.map +1 -1
  109. package/build/table-of-contents/edit.js +1 -1
  110. package/build/table-of-contents/edit.js.map +1 -1
  111. package/build/table-of-contents/index.js +24 -23
  112. package/build/table-of-contents/index.js.map +1 -1
  113. package/build/tag-cloud/edit.js +56 -11
  114. package/build/tag-cloud/edit.js.map +1 -1
  115. package/build/video/edit-common-settings.js +90 -30
  116. package/build/video/edit-common-settings.js.map +1 -1
  117. package/build/video/edit.js +20 -49
  118. package/build/video/edit.js.map +1 -1
  119. package/build/video/poster-image.js +81 -0
  120. package/build/video/poster-image.js.map +1 -0
  121. package/build/video/tracks-editor.js +1 -1
  122. package/build/video/tracks-editor.js.map +1 -1
  123. package/build-module/archives/edit.js +84 -37
  124. package/build-module/archives/edit.js.map +1 -1
  125. package/build-module/button/deprecated.js +183 -2
  126. package/build-module/button/deprecated.js.map +1 -1
  127. package/build-module/button/edit.js +50 -28
  128. package/build-module/button/edit.js.map +1 -1
  129. package/build-module/button/index.js +8 -2
  130. package/build-module/button/index.js.map +1 -1
  131. package/build-module/button/save.js +9 -6
  132. package/build-module/button/save.js.map +1 -1
  133. package/build-module/column/edit.js +34 -14
  134. package/build-module/column/edit.js.map +1 -1
  135. package/build-module/columns/edit.js +52 -29
  136. package/build-module/columns/edit.js.map +1 -1
  137. package/build-module/comments/index.js +1 -0
  138. package/build-module/comments/index.js.map +1 -1
  139. package/build-module/cover/edit/index.js +9 -3
  140. package/build-module/cover/edit/index.js.map +1 -1
  141. package/build-module/cover/edit.native.js +2 -2
  142. package/build-module/cover/edit.native.js.map +1 -1
  143. package/build-module/details/edit.js +30 -8
  144. package/build-module/details/edit.js.map +1 -1
  145. package/build-module/image/transforms.js +1 -0
  146. package/build-module/image/transforms.js.map +1 -1
  147. package/build-module/latest-posts/deprecated.js +12 -0
  148. package/build-module/latest-posts/deprecated.js.map +1 -1
  149. package/build-module/latest-posts/index.js +12 -0
  150. package/build-module/latest-posts/index.js.map +1 -1
  151. package/build-module/loginout/edit.js +42 -14
  152. package/build-module/loginout/edit.js.map +1 -1
  153. package/build-module/media-text/edit.js +59 -31
  154. package/build-module/media-text/edit.js.map +1 -1
  155. package/build-module/more/edit.js +28 -8
  156. package/build-module/more/edit.js.map +1 -1
  157. package/build-module/navigation/edit/navigation-menu-selector.js +5 -3
  158. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  159. package/build-module/navigation-link/edit.js +96 -56
  160. package/build-module/navigation-link/edit.js.map +1 -1
  161. package/build-module/navigation-submenu/edit.js +106 -54
  162. package/build-module/navigation-submenu/edit.js.map +1 -1
  163. package/build-module/page-list/edit.js +45 -26
  164. package/build-module/page-list/edit.js.map +1 -1
  165. package/build-module/paragraph/edit.js +15 -6
  166. package/build-module/paragraph/edit.js.map +1 -1
  167. package/build-module/post-author/edit.js +16 -4
  168. package/build-module/post-author/edit.js.map +1 -1
  169. package/build-module/post-author/index.js +4 -2
  170. package/build-module/post-author/index.js.map +1 -1
  171. package/build-module/post-author-name/edit.js +12 -6
  172. package/build-module/post-author-name/edit.js.map +1 -1
  173. package/build-module/post-author-name/index.js +4 -2
  174. package/build-module/post-author-name/index.js.map +1 -1
  175. package/build-module/post-comments-form/index.js +6 -1
  176. package/build-module/post-comments-form/index.js.map +1 -1
  177. package/build-module/post-comments-link/index.js +8 -1
  178. package/build-module/post-comments-link/index.js.map +1 -1
  179. package/build-module/post-date/edit.js +59 -19
  180. package/build-module/post-date/edit.js.map +1 -1
  181. package/build-module/post-date/index.js +2 -1
  182. package/build-module/post-date/index.js.map +1 -1
  183. package/build-module/post-excerpt/edit.js +44 -20
  184. package/build-module/post-excerpt/edit.js.map +1 -1
  185. package/build-module/post-featured-image/dimension-controls.js +18 -20
  186. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  187. package/build-module/post-featured-image/edit.js +47 -13
  188. package/build-module/post-featured-image/edit.js.map +1 -1
  189. package/build-module/post-featured-image/index.js +6 -3
  190. package/build-module/post-featured-image/index.js.map +1 -1
  191. package/build-module/post-navigation-link/index.js +12 -7
  192. package/build-module/post-navigation-link/index.js.map +1 -1
  193. package/build-module/post-navigation-link/variations.js +2 -2
  194. package/build-module/post-navigation-link/variations.js.map +1 -1
  195. package/build-module/post-template/index.js +11 -1
  196. package/build-module/post-template/index.js.map +1 -1
  197. package/build-module/post-title/index.js +6 -3
  198. package/build-module/post-title/index.js.map +1 -1
  199. package/build-module/query-no-results/index.js +10 -9
  200. package/build-module/query-no-results/index.js.map +1 -1
  201. package/build-module/query-pagination/edit.js +49 -19
  202. package/build-module/query-pagination/edit.js.map +1 -1
  203. package/build-module/query-pagination/query-pagination-label-control.js +1 -1
  204. package/build-module/query-pagination/query-pagination-label-control.js.map +1 -1
  205. package/build-module/query-pagination-numbers/edit.js +34 -16
  206. package/build-module/query-pagination-numbers/edit.js.map +1 -1
  207. package/build-module/query-total/edit.js +8 -10
  208. package/build-module/query-total/edit.js.map +1 -1
  209. package/build-module/query-total/index.js +8 -1
  210. package/build-module/query-total/index.js.map +1 -1
  211. package/build-module/read-more/index.js +7 -1
  212. package/build-module/read-more/index.js.map +1 -1
  213. package/build-module/site-logo/index.js +4 -2
  214. package/build-module/site-logo/index.js.map +1 -1
  215. package/build-module/site-title/edit.js +42 -13
  216. package/build-module/site-title/edit.js.map +1 -1
  217. package/build-module/site-title/index.js +4 -2
  218. package/build-module/site-title/index.js.map +1 -1
  219. package/build-module/social-link/edit.js +20 -4
  220. package/build-module/social-link/edit.js.map +1 -1
  221. package/build-module/social-links/edit.js +42 -13
  222. package/build-module/social-links/edit.js.map +1 -1
  223. package/build-module/spacer/controls.js +35 -13
  224. package/build-module/spacer/controls.js.map +1 -1
  225. package/build-module/table/edit.js +49 -16
  226. package/build-module/table/edit.js.map +1 -1
  227. package/build-module/table/index.js +4 -1
  228. package/build-module/table/index.js.map +1 -1
  229. package/build-module/table-of-contents/edit.js +1 -1
  230. package/build-module/table-of-contents/edit.js.map +1 -1
  231. package/build-module/table-of-contents/index.js +26 -25
  232. package/build-module/table-of-contents/index.js.map +1 -1
  233. package/build-module/tag-cloud/edit.js +57 -12
  234. package/build-module/tag-cloud/edit.js.map +1 -1
  235. package/build-module/video/edit-common-settings.js +91 -31
  236. package/build-module/video/edit-common-settings.js.map +1 -1
  237. package/build-module/video/edit.js +24 -53
  238. package/build-module/video/edit.js.map +1 -1
  239. package/build-module/video/poster-image.js +74 -0
  240. package/build-module/video/poster-image.js.map +1 -0
  241. package/build-module/video/tracks-editor.js +1 -1
  242. package/build-module/video/tracks-editor.js.map +1 -1
  243. package/build-style/comment-template/style-rtl.css +0 -1
  244. package/build-style/comment-template/style.css +0 -1
  245. package/build-style/editor-rtl.css +4 -19
  246. package/build-style/editor.css +4 -19
  247. package/build-style/form-input/style-rtl.css +0 -2
  248. package/build-style/form-input/style.css +0 -2
  249. package/build-style/freeform/editor-rtl.css +4 -8
  250. package/build-style/freeform/editor.css +4 -8
  251. package/build-style/{post-template/editor.css → post-comments-link/style-rtl.css} +2 -4
  252. package/build-style/{post-template/editor-rtl.css → post-comments-link/style.css} +2 -4
  253. package/build-style/post-template/style-rtl.css +1 -0
  254. package/build-style/post-template/style.css +1 -0
  255. package/build-style/query-total/style-rtl.css +103 -0
  256. package/build-style/query-total/style.css +103 -0
  257. package/build-style/read-more/style-rtl.css +0 -1
  258. package/build-style/read-more/style.css +0 -1
  259. package/build-style/style-rtl.css +9 -4
  260. package/build-style/style.css +9 -4
  261. package/build-style/tag-cloud/editor-rtl.css +0 -5
  262. package/build-style/tag-cloud/editor.css +0 -5
  263. package/package.json +35 -35
  264. package/src/archives/edit.js +94 -36
  265. package/src/audio/test/__snapshots__/edit.native.js.snap +1 -1
  266. package/src/block/index.php +20 -0
  267. package/src/button/block.json +17 -2
  268. package/src/button/deprecated.js +189 -0
  269. package/src/button/edit.js +60 -31
  270. package/src/button/save.js +6 -1
  271. package/src/column/edit.js +34 -13
  272. package/src/columns/edit.js +71 -40
  273. package/src/comments/index.js +1 -0
  274. package/src/cover/edit/index.js +12 -5
  275. package/src/cover/edit.native.js +5 -2
  276. package/src/cover/test/edit.js +5 -7
  277. package/src/details/edit.js +40 -11
  278. package/src/editor.scss +0 -1
  279. package/src/file/test/__snapshots__/edit.native.js.snap +1 -1
  280. package/src/image/transforms.js +1 -0
  281. package/src/latest-posts/block.json +12 -0
  282. package/src/loginout/edit.js +56 -20
  283. package/src/media-text/edit.js +57 -28
  284. package/src/more/edit.js +39 -12
  285. package/src/navigation/edit/navigation-menu-selector.js +9 -2
  286. package/src/navigation/index.php +2 -2
  287. package/src/navigation-link/edit.js +101 -61
  288. package/src/navigation-link/index.php +16 -1
  289. package/src/navigation-submenu/edit.js +113 -57
  290. package/src/page-list/edit.js +52 -31
  291. package/src/paragraph/edit.js +18 -4
  292. package/src/post-author/block.json +4 -2
  293. package/src/post-author/edit.js +17 -3
  294. package/src/post-author/index.php +4 -0
  295. package/src/post-author-name/block.json +4 -2
  296. package/src/post-author-name/edit.js +17 -4
  297. package/src/post-author-name/index.php +4 -0
  298. package/src/post-comments-form/block.json +6 -1
  299. package/src/post-comments-link/block.json +8 -1
  300. package/src/post-comments-link/style.scss +4 -0
  301. package/src/post-content/index.php +23 -0
  302. package/src/post-date/block.json +2 -1
  303. package/src/post-date/edit.js +79 -25
  304. package/src/post-excerpt/edit.js +59 -22
  305. package/src/post-featured-image/block.json +6 -3
  306. package/src/post-featured-image/dimension-controls.js +18 -21
  307. package/src/post-featured-image/edit.js +67 -10
  308. package/src/post-navigation-link/block.json +0 -6
  309. package/src/post-navigation-link/index.js +11 -0
  310. package/src/post-navigation-link/variations.js +2 -2
  311. package/src/post-template/block.json +11 -1
  312. package/src/post-template/style.scss +2 -0
  313. package/src/post-title/block.json +6 -3
  314. package/src/query-no-results/block.json +0 -10
  315. package/src/query-no-results/index.js +11 -0
  316. package/src/query-pagination/edit.js +57 -15
  317. package/src/query-pagination/query-pagination-label-control.js +1 -3
  318. package/src/query-pagination-numbers/edit.js +41 -19
  319. package/src/query-pagination-previous/index.php +21 -14
  320. package/src/query-total/block.json +8 -1
  321. package/src/query-total/edit.js +11 -13
  322. package/src/query-total/index.php +9 -13
  323. package/src/query-total/style.scss +4 -0
  324. package/src/read-more/index.js +6 -0
  325. package/src/site-logo/block.json +4 -2
  326. package/src/site-title/block.json +4 -2
  327. package/src/site-title/edit.js +52 -15
  328. package/src/social-link/edit.js +21 -6
  329. package/src/social-links/edit.js +52 -15
  330. package/src/spacer/controls.js +42 -15
  331. package/src/style.scss +2 -0
  332. package/src/table/block.json +4 -1
  333. package/src/table/edit.js +58 -20
  334. package/src/table-of-contents/block.json +0 -52
  335. package/src/table-of-contents/edit.js +1 -1
  336. package/src/table-of-contents/index.js +53 -0
  337. package/src/tag-cloud/edit.js +60 -8
  338. package/src/tag-cloud/editor.scss +0 -8
  339. package/src/video/edit-common-settings.js +97 -39
  340. package/src/video/edit.js +29 -75
  341. package/src/video/poster-image.js +86 -0
  342. package/src/video/tracks-editor.js +1 -1
  343. package/tsconfig.json +0 -2
  344. package/src/post-template/editor.scss +0 -7
@@ -18,31 +18,52 @@ import {
18
18
  } from '@wordpress/block-editor';
19
19
  import {
20
20
  __experimentalUseCustomUnits as useCustomUnits,
21
- PanelBody,
22
21
  __experimentalUnitControl as UnitControl,
22
+ __experimentalToolsPanel as ToolsPanel,
23
+ __experimentalToolsPanelItem as ToolsPanelItem,
23
24
  } from '@wordpress/components';
24
25
  import { useSelect, useDispatch } from '@wordpress/data';
25
26
  import { sprintf, __ } from '@wordpress/i18n';
26
27
 
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
32
+
27
33
  function ColumnInspectorControls( { width, setAttributes } ) {
28
34
  const [ availableUnits ] = useSettings( 'spacing.units' );
29
35
  const units = useCustomUnits( {
30
36
  availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
31
37
  } );
38
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
32
39
  return (
33
- <PanelBody title={ __( 'Settings' ) }>
34
- <UnitControl
40
+ <ToolsPanel
41
+ label={ __( 'Settings' ) }
42
+ resetAll={ () => {
43
+ setAttributes( { width: undefined } );
44
+ } }
45
+ dropdownMenuProps={ dropdownMenuProps }
46
+ >
47
+ <ToolsPanelItem
48
+ hasValue={ () => width !== undefined }
35
49
  label={ __( 'Width' ) }
36
- __unstableInputWidth="calc(50% - 8px)"
37
- __next40pxDefaultSize
38
- value={ width || '' }
39
- onChange={ ( nextWidth ) => {
40
- nextWidth = 0 > parseFloat( nextWidth ) ? '0' : nextWidth;
41
- setAttributes( { width: nextWidth } );
42
- } }
43
- units={ units }
44
- />
45
- </PanelBody>
50
+ onDeselect={ () => setAttributes( { width: undefined } ) }
51
+ isShownByDefault
52
+ >
53
+ <UnitControl
54
+ label={ __( 'Width' ) }
55
+ __unstableInputWidth="calc(50% - 8px)"
56
+ __next40pxDefaultSize
57
+ value={ width || '' }
58
+ onChange={ ( nextWidth ) => {
59
+ nextWidth =
60
+ 0 > parseFloat( nextWidth ) ? '0' : nextWidth;
61
+ setAttributes( { width: nextWidth } );
62
+ } }
63
+ units={ units }
64
+ />
65
+ </ToolsPanelItem>
66
+ </ToolsPanel>
46
67
  );
47
68
  }
48
69
 
@@ -9,9 +9,11 @@ import clsx from 'clsx';
9
9
  import { __ } from '@wordpress/i18n';
10
10
  import {
11
11
  Notice,
12
- PanelBody,
13
12
  RangeControl,
14
13
  ToggleControl,
14
+ __experimentalToolsPanel as ToolsPanel,
15
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
+ __experimentalVStack as VStack,
15
17
  } from '@wordpress/components';
16
18
 
17
19
  import {
@@ -39,6 +41,7 @@ import {
39
41
  getRedistributedColumnWidths,
40
42
  toWidthPrecision,
41
43
  } from './utils';
44
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
42
45
 
43
46
  const DEFAULT_BLOCK = {
44
47
  name: 'core/column',
@@ -51,19 +54,15 @@ function ColumnInspectorControls( {
51
54
  } ) {
52
55
  const { count, canInsertColumnBlock, minCount } = useSelect(
53
56
  ( select ) => {
54
- const {
55
- canInsertBlockType,
56
- canRemoveBlock,
57
- getBlocks,
58
- getBlockCount,
59
- } = select( blockEditorStore );
60
- const innerBlocks = getBlocks( clientId );
57
+ const { canInsertBlockType, canRemoveBlock, getBlockOrder } =
58
+ select( blockEditorStore );
59
+ const blockOrder = getBlockOrder( clientId );
61
60
 
62
61
  // Get the indexes of columns for which removal is prevented.
63
62
  // The highest index will be used to determine the minimum column count.
64
- const preventRemovalBlockIndexes = innerBlocks.reduce(
65
- ( acc, block, index ) => {
66
- if ( ! canRemoveBlock( block.clientId ) ) {
63
+ const preventRemovalBlockIndexes = blockOrder.reduce(
64
+ ( acc, blockId, index ) => {
65
+ if ( ! canRemoveBlock( blockId ) ) {
67
66
  acc.push( index );
68
67
  }
69
68
  return acc;
@@ -72,7 +71,7 @@ function ColumnInspectorControls( {
72
71
  );
73
72
 
74
73
  return {
75
- count: getBlockCount( clientId ),
74
+ count: blockOrder.length,
76
75
  canInsertColumnBlock: canInsertBlockType(
77
76
  'core/column',
78
77
  clientId
@@ -148,41 +147,73 @@ function ColumnInspectorControls( {
148
147
  replaceInnerBlocks( clientId, innerBlocks );
149
148
  }
150
149
 
150
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
151
+
151
152
  return (
152
- <PanelBody title={ __( 'Settings' ) }>
153
+ <ToolsPanel
154
+ label={ __( 'Settings' ) }
155
+ resetAll={ () => {
156
+ updateColumns( count, minCount );
157
+ setAttributes( {
158
+ isStackedOnMobile: true,
159
+ } );
160
+ } }
161
+ dropdownMenuProps={ dropdownMenuProps }
162
+ >
153
163
  { canInsertColumnBlock && (
154
- <>
155
- <RangeControl
156
- __nextHasNoMarginBottom
157
- __next40pxDefaultSize
158
- label={ __( 'Columns' ) }
159
- value={ count }
160
- onChange={ ( value ) =>
161
- updateColumns( count, Math.max( minCount, value ) )
162
- }
163
- min={ Math.max( 1, minCount ) }
164
- max={ Math.max( 6, count ) }
165
- />
166
- { count > 6 && (
167
- <Notice status="warning" isDismissible={ false }>
168
- { __(
169
- 'This column count exceeds the recommended amount and may cause visual breakage.'
170
- ) }
171
- </Notice>
172
- ) }
173
- </>
164
+ <ToolsPanelItem
165
+ label={ __( 'Columns' ) }
166
+ isShownByDefault
167
+ hasValue={ () => count }
168
+ onDeselect={ () => updateColumns( count, minCount ) }
169
+ >
170
+ <VStack spacing={ 4 }>
171
+ <RangeControl
172
+ __nextHasNoMarginBottom
173
+ __next40pxDefaultSize
174
+ label={ __( 'Columns' ) }
175
+ value={ count }
176
+ onChange={ ( value ) =>
177
+ updateColumns(
178
+ count,
179
+ Math.max( minCount, value )
180
+ )
181
+ }
182
+ min={ Math.max( 1, minCount ) }
183
+ max={ Math.max( 6, count ) }
184
+ />
185
+ { count > 6 && (
186
+ <Notice status="warning" isDismissible={ false }>
187
+ { __(
188
+ 'This column count exceeds the recommended amount and may cause visual breakage.'
189
+ ) }
190
+ </Notice>
191
+ ) }
192
+ </VStack>
193
+ </ToolsPanelItem>
174
194
  ) }
175
- <ToggleControl
176
- __nextHasNoMarginBottom
195
+ <ToolsPanelItem
177
196
  label={ __( 'Stack on mobile' ) }
178
- checked={ isStackedOnMobile }
179
- onChange={ () =>
197
+ isShownByDefault
198
+ hasValue={ () => isStackedOnMobile !== true }
199
+ onDeselect={ () =>
180
200
  setAttributes( {
181
- isStackedOnMobile: ! isStackedOnMobile,
201
+ isStackedOnMobile: true,
182
202
  } )
183
203
  }
184
- />
185
- </PanelBody>
204
+ >
205
+ <ToggleControl
206
+ __nextHasNoMarginBottom
207
+ label={ __( 'Stack on mobile' ) }
208
+ checked={ isStackedOnMobile }
209
+ onChange={ () =>
210
+ setAttributes( {
211
+ isStackedOnMobile: ! isStackedOnMobile,
212
+ } )
213
+ }
214
+ />
215
+ </ToolsPanelItem>
216
+ </ToolsPanel>
186
217
  );
187
218
  }
188
219
 
@@ -17,6 +17,7 @@ export { metadata, name };
17
17
 
18
18
  export const settings = {
19
19
  icon,
20
+ example: {},
20
21
  edit,
21
22
  save,
22
23
  deprecated,
@@ -114,11 +114,18 @@ function CoverEdit( {
114
114
 
115
115
  const { __unstableMarkNextChangeAsNotPersistent } =
116
116
  useDispatch( blockEditorStore );
117
- const media = useSelect(
118
- ( select ) =>
119
- featuredImage &&
120
- select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
121
- [ featuredImage ]
117
+ const { media } = useSelect(
118
+ ( select ) => {
119
+ return {
120
+ media:
121
+ featuredImage && useFeaturedImage
122
+ ? select( coreStore ).getMedia( featuredImage, {
123
+ context: 'view',
124
+ } )
125
+ : undefined,
126
+ };
127
+ },
128
+ [ featuredImage, useFeaturedImage ]
122
129
  );
123
130
  const mediaUrl =
124
131
  media?.media_details?.sizes?.[ sizeSlug ]?.source_url ??
@@ -58,7 +58,7 @@ import {
58
58
  useCallback,
59
59
  useMemo,
60
60
  } from '@wordpress/element';
61
- import { cover as icon, replace, image, warning } from '@wordpress/icons';
61
+ import { cover as icon, replace, image, cautionFilled } from '@wordpress/icons';
62
62
  import { getProtocol } from '@wordpress/url';
63
63
  // eslint-disable-next-line no-restricted-imports
64
64
  import { store as editPostStore } from '@wordpress/edit-post';
@@ -665,7 +665,10 @@ const Cover = ( {
665
665
  style={ styles.uploadFailedContainer }
666
666
  >
667
667
  <View style={ styles.uploadFailed }>
668
- <Icon icon={ warning } { ...styles.uploadFailedIcon } />
668
+ <Icon
669
+ icon={ cautionFilled }
670
+ { ...styles.uploadFailedIcon }
671
+ />
669
672
  </View>
670
673
  </View>
671
674
  ) }
@@ -200,9 +200,7 @@ describe( 'Cover block', () => {
200
200
 
201
201
  await selectBlock( 'Block: Cover' );
202
202
  expect(
203
- screen.getByRole( 'heading', {
204
- name: 'Settings',
205
- } )
203
+ await screen.findByRole( 'heading', { name: 'Settings' } )
206
204
  ).toBeInTheDocument();
207
205
  } );
208
206
  } );
@@ -216,7 +214,7 @@ describe( 'Cover block', () => {
216
214
  );
217
215
  await selectBlock( 'Block: Cover' );
218
216
  await userEvent.click(
219
- screen.getByLabelText( 'Fixed background' )
217
+ await screen.findByLabelText( 'Fixed background' )
220
218
  );
221
219
  expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
222
220
  'has-parallax'
@@ -232,7 +230,7 @@ describe( 'Cover block', () => {
232
230
  );
233
231
  await selectBlock( 'Block: Cover' );
234
232
  await userEvent.click(
235
- screen.getByLabelText( 'Repeated background' )
233
+ await screen.findByLabelText( 'Repeated background' )
236
234
  );
237
235
  expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
238
236
  'is-repeated'
@@ -245,7 +243,7 @@ describe( 'Cover block', () => {
245
243
  } );
246
244
 
247
245
  await selectBlock( 'Block: Cover' );
248
- await userEvent.clear( screen.getByLabelText( 'Left' ) );
246
+ await userEvent.clear( await screen.findByLabelText( 'Left' ) );
249
247
  await userEvent.type( screen.getByLabelText( 'Left' ), '100' );
250
248
 
251
249
  expect(
@@ -262,7 +260,7 @@ describe( 'Cover block', () => {
262
260
 
263
261
  await selectBlock( 'Block: Cover' );
264
262
  await userEvent.type(
265
- screen.getByLabelText( 'Alternative text' ),
263
+ await screen.findByLabelText( 'Alternative text' ),
266
264
  'Me'
267
265
  );
268
266
  expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
@@ -9,9 +9,18 @@ import {
9
9
  InspectorControls,
10
10
  } from '@wordpress/block-editor';
11
11
  import { useSelect } from '@wordpress/data';
12
- import { PanelBody, ToggleControl } from '@wordpress/components';
12
+ import {
13
+ ToggleControl,
14
+ __experimentalToolsPanel as ToolsPanel,
15
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
+ } from '@wordpress/components';
13
17
  import { __ } from '@wordpress/i18n';
14
18
 
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
23
+
15
24
  const TEMPLATE = [
16
25
  [
17
26
  'core/paragraph',
@@ -28,6 +37,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
28
37
  template: TEMPLATE,
29
38
  __experimentalCaptureToolbars: true,
30
39
  } );
40
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
31
41
 
32
42
  // Check if either the block or the inner blocks are selected.
33
43
  const hasSelection = useSelect(
@@ -46,18 +56,37 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
46
56
  return (
47
57
  <>
48
58
  <InspectorControls>
49
- <PanelBody title={ __( 'Settings' ) }>
50
- <ToggleControl
51
- __nextHasNoMarginBottom
59
+ <ToolsPanel
60
+ label={ __( 'Settings' ) }
61
+ resetAll={ () => {
62
+ setAttributes( {
63
+ showContent: false,
64
+ } );
65
+ } }
66
+ dropdownMenuProps={ dropdownMenuProps }
67
+ >
68
+ <ToolsPanelItem
69
+ isShownByDefault
52
70
  label={ __( 'Open by default' ) }
53
- checked={ showContent }
54
- onChange={ () =>
71
+ hasValue={ () => showContent }
72
+ onDeselect={ () => {
55
73
  setAttributes( {
56
- showContent: ! showContent,
57
- } )
58
- }
59
- />
60
- </PanelBody>
74
+ showContent: false,
75
+ } );
76
+ } }
77
+ >
78
+ <ToggleControl
79
+ __nextHasNoMarginBottom
80
+ label={ __( 'Open by default' ) }
81
+ checked={ showContent }
82
+ onChange={ () =>
83
+ setAttributes( {
84
+ showContent: ! showContent,
85
+ } )
86
+ }
87
+ />
88
+ </ToolsPanelItem>
89
+ </ToolsPanel>
61
90
  </InspectorControls>
62
91
  <details
63
92
  { ...innerBlocksProps }
package/src/editor.scss CHANGED
@@ -49,7 +49,6 @@
49
49
  @import "./template-part/editor.scss";
50
50
  @import "./text-columns/editor.scss";
51
51
  @import "./video/editor.scss";
52
- @import "./post-template/editor.scss";
53
52
  @import "./query/editor.scss";
54
53
  @import "./query-pagination/editor.scss";
55
54
  @import "./query-pagination-numbers/editor.scss";
@@ -132,7 +132,7 @@ exports[`File block renders file error state without crashing 1`] = `
132
132
  <Svg
133
133
  height={24}
134
134
  style={{}}
135
- viewBox="-2 -2 24 24"
135
+ viewBox="0 0 24 24"
136
136
  width={24}
137
137
  xmlns="http://www.w3.org/2000/svg"
138
138
  >
@@ -59,6 +59,7 @@ const schema = ( { phrasingContentSchema } ) => ( {
59
59
  ...imageSchema,
60
60
  a: {
61
61
  attributes: [ 'href', 'rel', 'target' ],
62
+ classes: [ '*' ],
62
63
  children: imageSchema,
63
64
  },
64
65
  figcaption: {
@@ -111,6 +111,18 @@
111
111
  "fontSize": true
112
112
  }
113
113
  },
114
+ "__experimentalBorder": {
115
+ "radius": true,
116
+ "color": true,
117
+ "width": true,
118
+ "style": true,
119
+ "__experimentalDefaultControls": {
120
+ "radius": true,
121
+ "color": true,
122
+ "width": true,
123
+ "style": true
124
+ }
125
+ },
114
126
  "interactivity": {
115
127
  "clientNavigation": true
116
128
  }
@@ -1,38 +1,74 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { PanelBody, ToggleControl } from '@wordpress/components';
5
- import { __ } from '@wordpress/i18n';
6
4
  import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
5
+ import {
6
+ ToggleControl,
7
+ __experimentalToolsPanel as ToolsPanel,
8
+ __experimentalToolsPanelItem as ToolsPanelItem,
9
+ } from '@wordpress/components';
10
+ import { __ } from '@wordpress/i18n';
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
7
15
 
8
16
  export default function LoginOutEdit( { attributes, setAttributes } ) {
9
17
  const { displayLoginAsForm, redirectToCurrent } = attributes;
18
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
10
19
 
11
20
  return (
12
21
  <>
13
22
  <InspectorControls>
14
- <PanelBody title={ __( 'Settings' ) }>
15
- <ToggleControl
16
- __nextHasNoMarginBottom
23
+ <ToolsPanel
24
+ label={ __( 'Settings' ) }
25
+ resetAll={ () => {
26
+ setAttributes( {
27
+ displayLoginAsForm: false,
28
+ redirectToCurrent: true,
29
+ } );
30
+ } }
31
+ dropdownMenuProps={ dropdownMenuProps }
32
+ >
33
+ <ToolsPanelItem
17
34
  label={ __( 'Display login as form' ) }
18
- checked={ displayLoginAsForm }
19
- onChange={ () =>
20
- setAttributes( {
21
- displayLoginAsForm: ! displayLoginAsForm,
22
- } )
35
+ isShownByDefault
36
+ hasValue={ () => displayLoginAsForm }
37
+ onDeselect={ () =>
38
+ setAttributes( { displayLoginAsForm: false } )
23
39
  }
24
- />
25
- <ToggleControl
26
- __nextHasNoMarginBottom
40
+ >
41
+ <ToggleControl
42
+ __nextHasNoMarginBottom
43
+ label={ __( 'Display login as form' ) }
44
+ checked={ displayLoginAsForm }
45
+ onChange={ () =>
46
+ setAttributes( {
47
+ displayLoginAsForm: ! displayLoginAsForm,
48
+ } )
49
+ }
50
+ />
51
+ </ToolsPanelItem>
52
+ <ToolsPanelItem
27
53
  label={ __( 'Redirect to current URL' ) }
28
- checked={ redirectToCurrent }
29
- onChange={ () =>
30
- setAttributes( {
31
- redirectToCurrent: ! redirectToCurrent,
32
- } )
54
+ isShownByDefault
55
+ hasValue={ () => ! redirectToCurrent }
56
+ onDeselect={ () =>
57
+ setAttributes( { redirectToCurrent: true } )
33
58
  }
34
- />
35
- </PanelBody>
59
+ >
60
+ <ToggleControl
61
+ __nextHasNoMarginBottom
62
+ label={ __( 'Redirect to current URL' ) }
63
+ checked={ redirectToCurrent }
64
+ onChange={ () =>
65
+ setAttributes( {
66
+ redirectToCurrent: ! redirectToCurrent,
67
+ } )
68
+ }
69
+ />
70
+ </ToolsPanelItem>
71
+ </ToolsPanel>
36
72
  </InspectorControls>
37
73
  <div
38
74
  { ...useBlockProps( {
@@ -76,6 +76,7 @@ function attributesFromMedia( {
76
76
  mediaLink: undefined,
77
77
  href: undefined,
78
78
  focalPoint: undefined,
79
+ useFeaturedImage: false,
79
80
  } );
80
81
  return;
81
82
  }
@@ -128,10 +129,37 @@ function attributesFromMedia( {
128
129
  mediaLink: media.link || undefined,
129
130
  href: newHref,
130
131
  focalPoint: undefined,
132
+ useFeaturedImage: false,
131
133
  } );
132
134
  };
133
135
  }
134
136
 
137
+ function MediaTextResolutionTool( { image, value, onChange } ) {
138
+ const { imageSizes } = useSelect( ( select ) => {
139
+ const { getSettings } = select( blockEditorStore );
140
+ return {
141
+ imageSizes: getSettings().imageSizes,
142
+ };
143
+ }, [] );
144
+
145
+ if ( ! imageSizes?.length ) {
146
+ return null;
147
+ }
148
+
149
+ const imageSizeOptions = imageSizes
150
+ .filter( ( { slug } ) => getImageSourceUrlBySizeSlug( image, slug ) )
151
+ .map( ( { name, slug } ) => ( { value: slug, label: name } ) );
152
+
153
+ return (
154
+ <ResolutionTool
155
+ value={ value }
156
+ defaultValue={ DEFAULT_MEDIA_SIZE_SLUG }
157
+ options={ imageSizeOptions }
158
+ onChange={ onChange }
159
+ />
160
+ );
161
+ }
162
+
135
163
  function MediaTextEdit( {
136
164
  attributes,
137
165
  isSelected,
@@ -152,12 +180,12 @@ function MediaTextEdit( {
152
180
  mediaType,
153
181
  mediaUrl,
154
182
  mediaWidth,
183
+ mediaSizeSlug,
155
184
  rel,
156
185
  verticalAlignment,
157
186
  allowedBlocks,
158
187
  useFeaturedImage,
159
188
  } = attributes;
160
- const mediaSizeSlug = attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
161
189
 
162
190
  const [ featuredImage ] = useEntityProp(
163
191
  'postType',
@@ -166,11 +194,32 @@ function MediaTextEdit( {
166
194
  postId
167
195
  );
168
196
 
169
- const featuredImageMedia = useSelect(
170
- ( select ) =>
171
- featuredImage &&
172
- select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
173
- [ featuredImage ]
197
+ const { featuredImageMedia } = useSelect(
198
+ ( select ) => {
199
+ return {
200
+ featuredImageMedia:
201
+ featuredImage && useFeaturedImage
202
+ ? select( coreStore ).getMedia( featuredImage, {
203
+ context: 'view',
204
+ } )
205
+ : undefined,
206
+ };
207
+ },
208
+ [ featuredImage, useFeaturedImage ]
209
+ );
210
+
211
+ const { image } = useSelect(
212
+ ( select ) => {
213
+ return {
214
+ image:
215
+ mediaId && isSelected
216
+ ? select( coreStore ).getMedia( mediaId, {
217
+ context: 'view',
218
+ } )
219
+ : null,
220
+ };
221
+ },
222
+ [ isSelected, mediaId ]
174
223
  );
175
224
 
176
225
  const featuredImageURL = useFeaturedImage
@@ -197,22 +246,6 @@ function MediaTextEdit( {
197
246
  } );
198
247
  };
199
248
 
200
- const { imageSizes, image } = useSelect(
201
- ( select ) => {
202
- const { getSettings } = select( blockEditorStore );
203
- return {
204
- image:
205
- mediaId && isSelected
206
- ? select( coreStore ).getMedia( mediaId, {
207
- context: 'view',
208
- } )
209
- : null,
210
- imageSizes: getSettings()?.imageSizes,
211
- };
212
- },
213
- [ isSelected, mediaId ]
214
- );
215
-
216
249
  const refMedia = useRef();
217
250
  const imperativeFocalPointPreview = ( value ) => {
218
251
  const { style } = refMedia.current;
@@ -260,10 +293,6 @@ function MediaTextEdit( {
260
293
  const onVerticalAlignmentChange = ( alignment ) => {
261
294
  setAttributes( { verticalAlignment: alignment } );
262
295
  };
263
-
264
- const imageSizeOptions = imageSizes
265
- .filter( ( { slug } ) => getImageSourceUrlBySizeSlug( image, slug ) )
266
- .map( ( { name, slug } ) => ( { value: slug, label: name } ) );
267
296
  const updateImage = ( newMediaSizeSlug ) => {
268
297
  const newUrl = getImageSourceUrlBySizeSlug( image, newMediaSizeSlug );
269
298
 
@@ -409,9 +438,9 @@ function MediaTextEdit( {
409
438
  </ToolsPanelItem>
410
439
  ) }
411
440
  { mediaType === 'image' && ! useFeaturedImage && (
412
- <ResolutionTool
441
+ <MediaTextResolutionTool
442
+ image={ image }
413
443
  value={ mediaSizeSlug }
414
- options={ imageSizeOptions }
415
444
  onChange={ updateImage }
416
445
  />
417
446
  ) }