@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
package/src/more/edit.js CHANGED
@@ -2,10 +2,18 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { PanelBody, ToggleControl } from '@wordpress/components';
5
+ import {
6
+ __experimentalToolsPanel as ToolsPanel,
7
+ __experimentalToolsPanelItem as ToolsPanelItem,
8
+ ToggleControl,
9
+ } from '@wordpress/components';
6
10
  import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
7
11
  import { ENTER } from '@wordpress/keycodes';
8
12
  import { getDefaultBlockName, createBlock } from '@wordpress/blocks';
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
9
17
 
10
18
  const DEFAULT_TEXT = __( 'Read more' );
11
19
 
@@ -37,20 +45,39 @@ export default function MoreEdit( {
37
45
  width: `${ ( customText ? customText : DEFAULT_TEXT ).length + 1.2 }em`,
38
46
  };
39
47
 
48
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
49
+
40
50
  return (
41
51
  <>
42
52
  <InspectorControls>
43
- <PanelBody>
44
- <ToggleControl
45
- __nextHasNoMarginBottom
46
- label={ __(
47
- 'Hide the excerpt on the full content page'
48
- ) }
49
- checked={ !! noTeaser }
50
- onChange={ toggleHideExcerpt }
51
- help={ getHideExcerptHelp }
52
- />
53
- </PanelBody>
53
+ <ToolsPanel
54
+ label={ __( 'Settings' ) }
55
+ resetAll={ () => {
56
+ setAttributes( {
57
+ noTeaser: false,
58
+ } );
59
+ } }
60
+ dropdownMenuProps={ dropdownMenuProps }
61
+ >
62
+ <ToolsPanelItem
63
+ label={ __( 'Hide excerpt' ) }
64
+ isShownByDefault
65
+ hasValue={ () => noTeaser }
66
+ onDeselect={ () =>
67
+ setAttributes( { noTeaser: false } )
68
+ }
69
+ >
70
+ <ToggleControl
71
+ __nextHasNoMarginBottom
72
+ label={ __(
73
+ 'Hide the excerpt on the full content page'
74
+ ) }
75
+ checked={ !! noTeaser }
76
+ onChange={ toggleHideExcerpt }
77
+ help={ getHideExcerptHelp }
78
+ />
79
+ </ToolsPanelItem>
80
+ </ToolsPanel>
54
81
  </InspectorControls>
55
82
  <div { ...useBlockProps() }>
56
83
  <input
@@ -61,7 +61,8 @@ function NavigationMenuSelector( {
61
61
  hasResolvedNavigationMenus,
62
62
  canUserCreateNavigationMenus,
63
63
  canSwitchNavigationMenu,
64
- } = useNavigationMenu();
64
+ isNavigationMenuMissing,
65
+ } = useNavigationMenu( currentMenuId );
65
66
 
66
67
  const [ currentTitle ] = useEntityProp(
67
68
  'postType',
@@ -106,12 +107,18 @@ function NavigationMenuSelector( {
106
107
  const noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;
107
108
  const menuUnavailable =
108
109
  hasResolvedNavigationMenus && currentMenuId === null;
110
+ const navMenuHasBeenDeleted = currentMenuId && isNavigationMenuMissing;
109
111
 
110
112
  let selectorLabel = '';
111
113
 
112
114
  if ( isResolvingNavigationMenus ) {
113
115
  selectorLabel = __( 'Loading…' );
114
- } else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {
116
+ } else if (
117
+ noMenuSelected ||
118
+ noBlockMenus ||
119
+ menuUnavailable ||
120
+ navMenuHasBeenDeleted
121
+ ) {
115
122
  // Note: classic Menus may be available.
116
123
  selectorLabel = __( 'Choose or create a Navigation Menu' );
117
124
  } else {
@@ -539,8 +539,8 @@ class WP_Navigation_Block_Renderer {
539
539
  $inner_blocks_html,
540
540
  $toggle_aria_label_open,
541
541
  $toggle_aria_label_close,
542
- esc_attr( implode( ' ', $responsive_container_classes ) ),
543
- esc_attr( implode( ' ', $open_button_classes ) ),
542
+ esc_attr( trim( implode( ' ', $responsive_container_classes ) ) ),
543
+ esc_attr( trim( implode( ' ', $open_button_classes ) ) ),
544
544
  ( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '',
545
545
  $toggle_button_content,
546
546
  $toggle_close_button_content,
@@ -9,7 +9,8 @@ import clsx from 'clsx';
9
9
  import { createBlock } from '@wordpress/blocks';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import {
12
- PanelBody,
12
+ __experimentalToolsPanel as ToolsPanel,
13
+ __experimentalToolsPanelItem as ToolsPanelItem,
13
14
  TextControl,
14
15
  TextareaControl,
15
16
  ToolbarButton,
@@ -161,71 +162,110 @@ function getMissingText( type ) {
161
162
  function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
162
163
  const { label, url, description, title, rel } = attributes;
163
164
  return (
164
- <PanelBody title={ __( 'Settings' ) }>
165
- <TextControl
166
- __nextHasNoMarginBottom
167
- __next40pxDefaultSize
168
- value={ label ? stripHTML( label ) : '' }
169
- onChange={ ( labelValue ) => {
170
- setAttributes( { label: labelValue } );
171
- } }
165
+ <ToolsPanel label={ __( 'Settings' ) }>
166
+ <ToolsPanelItem
167
+ hasValue={ () => !! label }
172
168
  label={ __( 'Text' ) }
173
- autoComplete="off"
174
- onFocus={ () => setIsLabelFieldFocused( true ) }
175
- onBlur={ () => setIsLabelFieldFocused( false ) }
176
- />
177
- <TextControl
178
- __nextHasNoMarginBottom
179
- __next40pxDefaultSize
180
- value={ url ? safeDecodeURI( url ) : '' }
181
- onChange={ ( urlValue ) => {
182
- updateAttributes(
183
- { url: urlValue },
184
- setAttributes,
185
- attributes
186
- );
187
- } }
169
+ onDeselect={ () => setAttributes( { label: '' } ) }
170
+ isShownByDefault
171
+ >
172
+ <TextControl
173
+ __nextHasNoMarginBottom
174
+ __next40pxDefaultSize
175
+ label={ __( 'Text' ) }
176
+ value={ label ? stripHTML( label ) : '' }
177
+ onChange={ ( labelValue ) => {
178
+ setAttributes( { label: labelValue } );
179
+ } }
180
+ autoComplete="off"
181
+ onFocus={ () => setIsLabelFieldFocused( true ) }
182
+ onBlur={ () => setIsLabelFieldFocused( false ) }
183
+ />
184
+ </ToolsPanelItem>
185
+
186
+ <ToolsPanelItem
187
+ hasValue={ () => !! url }
188
188
  label={ __( 'Link' ) }
189
- autoComplete="off"
190
- />
191
- <TextareaControl
192
- __nextHasNoMarginBottom
193
- value={ description || '' }
194
- onChange={ ( descriptionValue ) => {
195
- setAttributes( { description: descriptionValue } );
196
- } }
189
+ onDeselect={ () => setAttributes( { url: '' } ) }
190
+ isShownByDefault
191
+ >
192
+ <TextControl
193
+ __nextHasNoMarginBottom
194
+ __next40pxDefaultSize
195
+ label={ __( 'Link' ) }
196
+ value={ url ? safeDecodeURI( url ) : '' }
197
+ onChange={ ( urlValue ) => {
198
+ updateAttributes(
199
+ { url: urlValue },
200
+ setAttributes,
201
+ attributes
202
+ );
203
+ } }
204
+ autoComplete="off"
205
+ />
206
+ </ToolsPanelItem>
207
+
208
+ <ToolsPanelItem
209
+ hasValue={ () => !! description }
197
210
  label={ __( 'Description' ) }
198
- help={ __(
199
- 'The description will be displayed in the menu if the current theme supports it.'
200
- ) }
201
- />
202
- <TextControl
203
- __nextHasNoMarginBottom
204
- __next40pxDefaultSize
205
- value={ title || '' }
206
- onChange={ ( titleValue ) => {
207
- setAttributes( { title: titleValue } );
208
- } }
211
+ onDeselect={ () => setAttributes( { description: '' } ) }
212
+ isShownByDefault
213
+ >
214
+ <TextareaControl
215
+ __nextHasNoMarginBottom
216
+ label={ __( 'Description' ) }
217
+ value={ description || '' }
218
+ onChange={ ( descriptionValue ) => {
219
+ setAttributes( { description: descriptionValue } );
220
+ } }
221
+ help={ __(
222
+ 'The description will be displayed in the menu if the current theme supports it.'
223
+ ) }
224
+ />
225
+ </ToolsPanelItem>
226
+
227
+ <ToolsPanelItem
228
+ hasValue={ () => !! title }
209
229
  label={ __( 'Title attribute' ) }
210
- autoComplete="off"
211
- help={ __(
212
- 'Additional information to help clarify the purpose of the link.'
213
- ) }
214
- />
215
- <TextControl
216
- __nextHasNoMarginBottom
217
- __next40pxDefaultSize
218
- value={ rel || '' }
219
- onChange={ ( relValue ) => {
220
- setAttributes( { rel: relValue } );
221
- } }
230
+ onDeselect={ () => setAttributes( { title: '' } ) }
231
+ isShownByDefault
232
+ >
233
+ <TextControl
234
+ __nextHasNoMarginBottom
235
+ __next40pxDefaultSize
236
+ label={ __( 'Title attribute' ) }
237
+ value={ title || '' }
238
+ onChange={ ( titleValue ) => {
239
+ setAttributes( { title: titleValue } );
240
+ } }
241
+ autoComplete="off"
242
+ help={ __(
243
+ 'Additional information to help clarify the purpose of the link.'
244
+ ) }
245
+ />
246
+ </ToolsPanelItem>
247
+
248
+ <ToolsPanelItem
249
+ hasValue={ () => !! rel }
222
250
  label={ __( 'Rel attribute' ) }
223
- autoComplete="off"
224
- help={ __(
225
- 'The relationship of the linked URL as space-separated link types.'
226
- ) }
227
- />
228
- </PanelBody>
251
+ onDeselect={ () => setAttributes( { rel: '' } ) }
252
+ isShownByDefault
253
+ >
254
+ <TextControl
255
+ __nextHasNoMarginBottom
256
+ __next40pxDefaultSize
257
+ label={ __( 'Rel attribute' ) }
258
+ value={ rel || '' }
259
+ onChange={ ( relValue ) => {
260
+ setAttributes( { rel: relValue } );
261
+ } }
262
+ autoComplete="off"
263
+ help={ __(
264
+ 'The relationship of the linked URL as space-separated link types.'
265
+ ) }
266
+ />
267
+ </ToolsPanelItem>
268
+ </ToolsPanel>
229
269
  );
230
270
  }
231
271
 
@@ -177,7 +177,22 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
177
177
  // Don't render the block's subtree if it is a draft or if the ID does not exist.
178
178
  if ( $is_post_type && $navigation_link_has_id ) {
179
179
  $post = get_post( $attributes['id'] );
180
- if ( ! $post || 'publish' !== $post->post_status ) {
180
+ /**
181
+ * Filter allowed post_status for navigation link block to render.
182
+ *
183
+ * @since 6.8.0
184
+ *
185
+ * @param array $post_status
186
+ * @param array $attributes
187
+ * @param WP_Block $block
188
+ */
189
+ $allowed_post_status = (array) apply_filters(
190
+ 'render_block_core_navigation_link_allowed_post_status',
191
+ array( 'publish' ),
192
+ $attributes,
193
+ $block
194
+ );
195
+ if ( ! $post || ! in_array( $post->post_status, $allowed_post_status, true ) ) {
181
196
  return '';
182
197
  }
183
198
  }
@@ -8,11 +8,12 @@ import clsx from 'clsx';
8
8
  */
9
9
  import { useSelect, useDispatch } from '@wordpress/data';
10
10
  import {
11
- PanelBody,
12
11
  TextControl,
13
12
  TextareaControl,
14
13
  ToolbarButton,
15
14
  ToolbarGroup,
15
+ __experimentalToolsPanel as ToolsPanel,
16
+ __experimentalToolsPanelItem as ToolsPanelItem,
16
17
  } from '@wordpress/components';
17
18
  import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
18
19
  import { __ } from '@wordpress/i18n';
@@ -43,6 +44,7 @@ import {
43
44
  getColors,
44
45
  getNavigationChildBlockProps,
45
46
  } from '../navigation/edit/utils';
47
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
46
48
 
47
49
  const ALLOWED_BLOCKS = [
48
50
  'core/navigation-link',
@@ -152,6 +154,7 @@ export default function NavigationSubmenuEdit( {
152
154
  const isDraggingWithin = useIsDraggingWithin( listItemRef );
153
155
  const itemLabelPlaceholder = __( 'Add text…' );
154
156
  const ref = useRef();
157
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
155
158
 
156
159
  const {
157
160
  parentCount,
@@ -382,67 +385,120 @@ export default function NavigationSubmenuEdit( {
382
385
  </BlockControls>
383
386
  { /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }
384
387
  <InspectorControls>
385
- <PanelBody title={ __( 'Settings' ) }>
386
- <TextControl
387
- __nextHasNoMarginBottom
388
- __next40pxDefaultSize
389
- value={ label || '' }
390
- onChange={ ( labelValue ) => {
391
- setAttributes( { label: labelValue } );
392
- } }
388
+ <ToolsPanel
389
+ label={ __( 'Settings' ) }
390
+ resetAll={ () => {
391
+ setAttributes( {
392
+ label: '',
393
+ url: '',
394
+ description: '',
395
+ title: '',
396
+ rel: '',
397
+ } );
398
+ } }
399
+ dropdownMenuProps={ dropdownMenuProps }
400
+ >
401
+ <ToolsPanelItem
393
402
  label={ __( 'Text' ) }
394
- autoComplete="off"
395
- />
396
- <TextControl
397
- __nextHasNoMarginBottom
398
- __next40pxDefaultSize
399
- value={ url || '' }
400
- onChange={ ( urlValue ) => {
401
- setAttributes( { url: urlValue } );
402
- } }
403
+ isShownByDefault
404
+ hasValue={ () => !! label }
405
+ onDeselect={ () => setAttributes( { label: '' } ) }
406
+ >
407
+ <TextControl
408
+ __nextHasNoMarginBottom
409
+ __next40pxDefaultSize
410
+ value={ label || '' }
411
+ onChange={ ( labelValue ) => {
412
+ setAttributes( { label: labelValue } );
413
+ } }
414
+ label={ __( 'Text' ) }
415
+ autoComplete="off"
416
+ />
417
+ </ToolsPanelItem>
418
+
419
+ <ToolsPanelItem
403
420
  label={ __( 'Link' ) }
404
- autoComplete="off"
405
- />
406
- <TextareaControl
407
- __nextHasNoMarginBottom
408
- value={ description || '' }
409
- onChange={ ( descriptionValue ) => {
410
- setAttributes( {
411
- description: descriptionValue,
412
- } );
413
- } }
421
+ isShownByDefault
422
+ hasValue={ () => !! url }
423
+ onDeselect={ () => setAttributes( { url: '' } ) }
424
+ >
425
+ <TextControl
426
+ __nextHasNoMarginBottom
427
+ __next40pxDefaultSize
428
+ value={ url || '' }
429
+ onChange={ ( urlValue ) => {
430
+ setAttributes( { url: urlValue } );
431
+ } }
432
+ label={ __( 'Link' ) }
433
+ autoComplete="off"
434
+ />
435
+ </ToolsPanelItem>
436
+
437
+ <ToolsPanelItem
414
438
  label={ __( 'Description' ) }
415
- help={ __(
416
- 'The description will be displayed in the menu if the current theme supports it.'
417
- ) }
418
- />
419
- <TextControl
420
- __nextHasNoMarginBottom
421
- __next40pxDefaultSize
422
- value={ title || '' }
423
- onChange={ ( titleValue ) => {
424
- setAttributes( { title: titleValue } );
425
- } }
439
+ isShownByDefault
440
+ hasValue={ () => !! description }
441
+ onDeselect={ () =>
442
+ setAttributes( { description: '' } )
443
+ }
444
+ >
445
+ <TextareaControl
446
+ __nextHasNoMarginBottom
447
+ value={ description || '' }
448
+ onChange={ ( descriptionValue ) => {
449
+ setAttributes( {
450
+ description: descriptionValue,
451
+ } );
452
+ } }
453
+ label={ __( 'Description' ) }
454
+ help={ __(
455
+ 'The description will be displayed in the menu if the current theme supports it.'
456
+ ) }
457
+ />
458
+ </ToolsPanelItem>
459
+
460
+ <ToolsPanelItem
426
461
  label={ __( 'Title attribute' ) }
427
- autoComplete="off"
428
- help={ __(
429
- 'Additional information to help clarify the purpose of the link.'
430
- ) }
431
- />
432
- <TextControl
433
- __nextHasNoMarginBottom
434
- __next40pxDefaultSize
435
- value={ rel || '' }
436
- onChange={ ( relValue ) => {
437
- setAttributes( { rel: relValue } );
438
- } }
462
+ isShownByDefault
463
+ hasValue={ () => !! title }
464
+ onDeselect={ () => setAttributes( { title: '' } ) }
465
+ >
466
+ <TextControl
467
+ __nextHasNoMarginBottom
468
+ __next40pxDefaultSize
469
+ value={ title || '' }
470
+ onChange={ ( titleValue ) => {
471
+ setAttributes( { title: titleValue } );
472
+ } }
473
+ label={ __( 'Title attribute' ) }
474
+ autoComplete="off"
475
+ help={ __(
476
+ 'Additional information to help clarify the purpose of the link.'
477
+ ) }
478
+ />
479
+ </ToolsPanelItem>
480
+
481
+ <ToolsPanelItem
439
482
  label={ __( 'Rel attribute' ) }
440
- autoComplete="off"
441
- help={ __(
442
- 'The relationship of the linked URL as space-separated link types.'
443
- ) }
444
- />
445
- </PanelBody>
483
+ isShownByDefault
484
+ hasValue={ () => !! rel }
485
+ onDeselect={ () => setAttributes( { rel: '' } ) }
486
+ >
487
+ <TextControl
488
+ __nextHasNoMarginBottom
489
+ __next40pxDefaultSize
490
+ value={ rel || '' }
491
+ onChange={ ( relValue ) => {
492
+ setAttributes( { rel: relValue } );
493
+ } }
494
+ label={ __( 'Rel attribute' ) }
495
+ autoComplete="off"
496
+ help={ __(
497
+ 'The relationship of the linked URL as space-separated link types.'
498
+ ) }
499
+ />
500
+ </ToolsPanelItem>
501
+ </ToolsPanel>
446
502
  </InspectorControls>
447
503
  <div { ...blockProps }>
448
504
  { /* eslint-disable jsx-a11y/anchor-is-valid */ }
@@ -17,12 +17,13 @@ import {
17
17
  Warning,
18
18
  } from '@wordpress/block-editor';
19
19
  import {
20
- PanelBody,
21
20
  ToolbarButton,
22
21
  Spinner,
23
22
  Notice,
24
23
  ComboboxControl,
25
24
  Button,
25
+ __experimentalToolsPanel as ToolsPanel,
26
+ __experimentalToolsPanelItem as ToolsPanelItem,
26
27
  } from '@wordpress/components';
27
28
  import { __, sprintf } from '@wordpress/i18n';
28
29
  import { useMemo, useState, useEffect, useCallback } from '@wordpress/element';
@@ -37,6 +38,7 @@ import {
37
38
  convertDescription,
38
39
  ConvertToLinksModal,
39
40
  } from './convert-to-links-modal';
41
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
40
42
 
41
43
  // We only show the edit option when page count is <= MAX_PAGE_COUNT
42
44
  // Performance of Navigation Links is not good past this value.
@@ -123,6 +125,7 @@ export default function PageListEdit( {
123
125
  const [ isOpen, setOpen ] = useState( false );
124
126
  const openModal = useCallback( () => setOpen( true ), [] );
125
127
  const closeModal = () => setOpen( false );
128
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
126
129
 
127
130
  const { records: pages, hasResolved: hasResolvedPages } = useEntityRecords(
128
131
  'postType',
@@ -320,38 +323,56 @@ export default function PageListEdit( {
320
323
  return (
321
324
  <>
322
325
  <InspectorControls>
323
- { pagesTree.length > 0 && (
324
- <PanelBody>
325
- <ComboboxControl
326
- __nextHasNoMarginBottom
327
- __next40pxDefaultSize
328
- className="editor-page-attributes__parent"
329
- label={ __( 'Parent' ) }
330
- value={ parentPageID }
331
- options={ pagesTree }
332
- onChange={ ( value ) =>
333
- setAttributes( { parentPageID: value ?? 0 } )
326
+ <ToolsPanel
327
+ label={ __( 'Settings' ) }
328
+ resetAll={ () => {
329
+ setAttributes( { parentPageID: 0 } );
330
+ } }
331
+ dropdownMenuProps={ dropdownMenuProps }
332
+ >
333
+ { pagesTree.length > 0 && (
334
+ <ToolsPanelItem
335
+ label={ __( 'Parent Page' ) }
336
+ hasValue={ () => parentPageID !== 0 }
337
+ onDeselect={ () =>
338
+ setAttributes( { parentPageID: 0 } )
334
339
  }
335
- help={ __(
336
- 'Choose a page to show only its subpages.'
337
- ) }
338
- />
339
- </PanelBody>
340
- ) }
341
- { allowConvertToLinks && (
342
- <PanelBody title={ __( 'Edit this menu' ) }>
343
- <p>{ convertDescription }</p>
344
- <Button
345
- __next40pxDefaultSize
346
- variant="primary"
347
- accessibleWhenDisabled
348
- disabled={ ! hasResolvedPages }
349
- onClick={ convertToNavigationLinks }
340
+ isShownByDefault
350
341
  >
351
- { __( 'Edit' ) }
352
- </Button>
353
- </PanelBody>
354
- ) }
342
+ <ComboboxControl
343
+ __nextHasNoMarginBottom
344
+ __next40pxDefaultSize
345
+ className="editor-page-attributes__parent"
346
+ label={ __( 'Parent' ) }
347
+ value={ parentPageID }
348
+ options={ pagesTree }
349
+ onChange={ ( value ) =>
350
+ setAttributes( {
351
+ parentPageID: value ?? 0,
352
+ } )
353
+ }
354
+ help={ __(
355
+ 'Choose a page to show only its subpages.'
356
+ ) }
357
+ />
358
+ </ToolsPanelItem>
359
+ ) }
360
+
361
+ { allowConvertToLinks && (
362
+ <div style={ { gridColumn: '1 / -1' } }>
363
+ <p>{ convertDescription }</p>
364
+ <Button
365
+ __next40pxDefaultSize
366
+ variant="primary"
367
+ accessibleWhenDisabled
368
+ disabled={ ! hasResolvedPages }
369
+ onClick={ convertToNavigationLinks }
370
+ >
371
+ { __( 'Edit' ) }
372
+ </Button>
373
+ </div>
374
+ ) }
375
+ </ToolsPanel>
355
376
  </InspectorControls>
356
377
  { allowConvertToLinks && (
357
378
  <>