@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
@@ -11,11 +11,12 @@ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
11
11
  import { useSelect, useDispatch } from '@wordpress/data';
12
12
  import {
13
13
  ToggleControl,
14
- PanelBody,
15
14
  Placeholder,
16
15
  Button,
17
16
  Spinner,
18
17
  TextControl,
18
+ __experimentalToolsPanel as ToolsPanel,
19
+ __experimentalToolsPanelItem as ToolsPanelItem,
19
20
  } from '@wordpress/components';
20
21
  import {
21
22
  InspectorControls,
@@ -38,6 +39,7 @@ import { store as noticesStore } from '@wordpress/notices';
38
39
  import DimensionControls from './dimension-controls';
39
40
  import OverlayControls from './overlay-controls';
40
41
  import Overlay from './overlay';
42
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
41
43
 
42
44
  const ALLOWED_MEDIA_TYPES = [ 'image' ];
43
45
 
@@ -183,6 +185,8 @@ export default function PostFeaturedImageEdit( {
183
185
  setTemporaryURL();
184
186
  };
185
187
 
188
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
189
+
186
190
  const controls = blockEditingMode === 'default' && (
187
191
  <>
188
192
  <InspectorControls group="color">
@@ -201,9 +205,18 @@ export default function PostFeaturedImageEdit( {
201
205
  />
202
206
  </InspectorControls>
203
207
  <InspectorControls>
204
- <PanelBody title={ __( 'Settings' ) }>
205
- <ToggleControl
206
- __nextHasNoMarginBottom
208
+ <ToolsPanel
209
+ label={ __( 'Settings' ) }
210
+ resetAll={ () => {
211
+ setAttributes( {
212
+ isLink: false,
213
+ linkTarget: '_self',
214
+ rel: '',
215
+ } );
216
+ } }
217
+ dropdownMenuProps={ dropdownMenuProps }
218
+ >
219
+ <ToolsPanelItem
207
220
  label={
208
221
  postType?.labels.singular_name
209
222
  ? sprintf(
@@ -213,11 +226,42 @@ export default function PostFeaturedImageEdit( {
213
226
  )
214
227
  : __( 'Link to post' )
215
228
  }
216
- onChange={ () => setAttributes( { isLink: ! isLink } ) }
217
- checked={ isLink }
218
- />
229
+ isShownByDefault
230
+ hasValue={ () => !! isLink }
231
+ onDeselect={ () =>
232
+ setAttributes( {
233
+ isLink: false,
234
+ } )
235
+ }
236
+ >
237
+ <ToggleControl
238
+ __nextHasNoMarginBottom
239
+ label={
240
+ postType?.labels.singular_name
241
+ ? sprintf(
242
+ // translators: %s: Name of the post type e.g: "post".
243
+ __( 'Link to %s' ),
244
+ postType.labels.singular_name
245
+ )
246
+ : __( 'Link to post' )
247
+ }
248
+ onChange={ () =>
249
+ setAttributes( { isLink: ! isLink } )
250
+ }
251
+ checked={ isLink }
252
+ />
253
+ </ToolsPanelItem>
219
254
  { isLink && (
220
- <>
255
+ <ToolsPanelItem
256
+ label={ __( 'Open in new tab' ) }
257
+ isShownByDefault
258
+ hasValue={ () => '_self' !== linkTarget }
259
+ onDeselect={ () =>
260
+ setAttributes( {
261
+ linkTarget: '_self',
262
+ } )
263
+ }
264
+ >
221
265
  <ToggleControl
222
266
  __nextHasNoMarginBottom
223
267
  label={ __( 'Open in new tab' ) }
@@ -228,6 +272,19 @@ export default function PostFeaturedImageEdit( {
228
272
  }
229
273
  checked={ linkTarget === '_blank' }
230
274
  />
275
+ </ToolsPanelItem>
276
+ ) }
277
+ { isLink && (
278
+ <ToolsPanelItem
279
+ label={ __( 'Link rel' ) }
280
+ isShownByDefault
281
+ hasValue={ () => !! rel }
282
+ onDeselect={ () =>
283
+ setAttributes( {
284
+ rel: '',
285
+ } )
286
+ }
287
+ >
231
288
  <TextControl
232
289
  __next40pxDefaultSize
233
290
  __nextHasNoMarginBottom
@@ -237,9 +294,9 @@ export default function PostFeaturedImageEdit( {
237
294
  setAttributes( { rel: newRel } )
238
295
  }
239
296
  />
240
- </>
297
+ </ToolsPanelItem>
241
298
  ) }
242
- </PanelBody>
299
+ </ToolsPanel>
243
300
  </InspectorControls>
244
301
  </>
245
302
  );
@@ -34,12 +34,6 @@
34
34
  "default": ""
35
35
  }
36
36
  },
37
- "example": {
38
- "attributes": {
39
- "label": "Next post",
40
- "arrow": "arrow"
41
- }
42
- },
43
37
  "usesContext": [ "postType" ],
44
38
  "supports": {
45
39
  "reusable": false,
@@ -1,3 +1,8 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+
1
6
  /**
2
7
  * Internal dependencies
3
8
  */
@@ -12,6 +17,12 @@ export { metadata, name };
12
17
  export const settings = {
13
18
  edit,
14
19
  variations,
20
+ example: {
21
+ attributes: {
22
+ label: __( 'Next post' ),
23
+ arrow: 'arrow',
24
+ },
25
+ },
15
26
  };
16
27
 
17
28
  export const init = () => initBlock( { name, metadata, settings } );
@@ -17,7 +17,7 @@ const variations = [
17
17
  scope: [ 'inserter', 'transform' ],
18
18
  example: {
19
19
  attributes: {
20
- label: 'Next post',
20
+ label: __( 'Next post' ),
21
21
  arrow: 'arrow',
22
22
  },
23
23
  },
@@ -33,7 +33,7 @@ const variations = [
33
33
  scope: [ 'inserter', 'transform' ],
34
34
  example: {
35
35
  attributes: {
36
- label: 'Previous post',
36
+ label: __( 'Previous post' ),
37
37
  arrow: 'arrow',
38
38
  },
39
39
  },
@@ -43,15 +43,25 @@
43
43
  }
44
44
  },
45
45
  "spacing": {
46
+ "margin": true,
47
+ "padding": true,
46
48
  "blockGap": {
47
49
  "__experimentalDefault": "1.25em"
48
50
  },
49
51
  "__experimentalDefaultControls": {
50
- "blockGap": true
52
+ "blockGap": true,
53
+ "padding": false,
54
+ "margin": false
51
55
  }
52
56
  },
53
57
  "interactivity": {
54
58
  "clientNavigation": true
59
+ },
60
+ "__experimentalBorder": {
61
+ "radius": true,
62
+ "color": true,
63
+ "width": true,
64
+ "style": true
55
65
  }
56
66
  },
57
67
  "style": "wp-block-post-template",
@@ -4,6 +4,8 @@
4
4
  max-width: 100%;
5
5
  list-style: none;
6
6
  padding: 0;
7
+ // This block has customizable padding, border-box makes that more predictable.
8
+ box-sizing: border-box;
7
9
 
8
10
  // These rules no longer apply but should be kept for backwards compatibility.
9
11
  &.is-flex-container {
@@ -20,16 +20,19 @@
20
20
  },
21
21
  "isLink": {
22
22
  "type": "boolean",
23
- "default": false
23
+ "default": false,
24
+ "role": "content"
24
25
  },
25
26
  "rel": {
26
27
  "type": "string",
27
28
  "attribute": "rel",
28
- "default": ""
29
+ "default": "",
30
+ "role": "content"
29
31
  },
30
32
  "linkTarget": {
31
33
  "type": "string",
32
- "default": "_self"
34
+ "default": "_self",
35
+ "role": "content"
33
36
  }
34
37
  },
35
38
  "example": {
@@ -8,16 +8,6 @@
8
8
  "ancestor": [ "core/query" ],
9
9
  "textdomain": "default",
10
10
  "usesContext": [ "queryId", "query" ],
11
- "example": {
12
- "innerBlocks": [
13
- {
14
- "name": "core/paragraph",
15
- "attributes": {
16
- "content": "No posts were found."
17
- }
18
- }
19
- ]
20
- },
21
11
  "supports": {
22
12
  "align": true,
23
13
  "reusable": false,
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { __ } from '@wordpress/i18n';
4
5
  import { loop as icon } from '@wordpress/icons';
5
6
 
6
7
  /**
@@ -18,6 +19,16 @@ export const settings = {
18
19
  icon,
19
20
  edit,
20
21
  save,
22
+ example: {
23
+ innerBlocks: [
24
+ {
25
+ name: 'core/paragraph',
26
+ attributes: {
27
+ content: __( 'No posts were found.' ),
28
+ },
29
+ },
30
+ ],
31
+ },
21
32
  };
22
33
 
23
34
  export const init = () => initBlock( { name, metadata, settings } );
@@ -8,8 +8,11 @@ import {
8
8
  useInnerBlocksProps,
9
9
  store as blockEditorStore,
10
10
  } from '@wordpress/block-editor';
11
- import { useSelect } from '@wordpress/data';
12
- import { PanelBody } from '@wordpress/components';
11
+ import { useDispatch, useSelect } from '@wordpress/data';
12
+ import {
13
+ __experimentalToolsPanel as ToolsPanel,
14
+ __experimentalToolsPanelItem as ToolsPanelItem,
15
+ } from '@wordpress/components';
13
16
  import { useEffect } from '@wordpress/element';
14
17
 
15
18
  /**
@@ -17,6 +20,7 @@ import { useEffect } from '@wordpress/element';
17
20
  */
18
21
  import { QueryPaginationArrowControls } from './query-pagination-arrow-controls';
19
22
  import { QueryPaginationLabelControl } from './query-pagination-label-control';
23
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
20
24
 
21
25
  const TEMPLATE = [
22
26
  [ 'core/query-pagination-previous' ],
@@ -46,36 +50,74 @@ export default function QueryPaginationEdit( {
46
50
  },
47
51
  [ clientId ]
48
52
  );
53
+ const { __unstableMarkNextChangeAsNotPersistent } =
54
+ useDispatch( blockEditorStore );
55
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
49
56
  const blockProps = useBlockProps();
50
57
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
51
58
  template: TEMPLATE,
52
59
  } );
60
+
53
61
  // Always show label text if paginationArrow is set to 'none'.
54
62
  useEffect( () => {
55
63
  if ( paginationArrow === 'none' && ! showLabel ) {
64
+ __unstableMarkNextChangeAsNotPersistent();
56
65
  setAttributes( { showLabel: true } );
57
66
  }
58
- }, [ paginationArrow, setAttributes, showLabel ] );
67
+ }, [
68
+ paginationArrow,
69
+ setAttributes,
70
+ showLabel,
71
+ __unstableMarkNextChangeAsNotPersistent,
72
+ ] );
73
+
59
74
  return (
60
75
  <>
61
76
  { hasNextPreviousBlocks && (
62
77
  <InspectorControls>
63
- <PanelBody title={ __( 'Settings' ) }>
64
- <QueryPaginationArrowControls
65
- value={ paginationArrow }
66
- onChange={ ( value ) => {
67
- setAttributes( { paginationArrow: value } );
68
- } }
69
- />
70
- { paginationArrow !== 'none' && (
71
- <QueryPaginationLabelControl
72
- value={ showLabel }
78
+ <ToolsPanel
79
+ label={ __( 'Settings' ) }
80
+ resetAll={ () => {
81
+ setAttributes( {
82
+ paginationArrow: 'none',
83
+ showLabel: true,
84
+ } );
85
+ } }
86
+ dropdownMenuProps={ dropdownMenuProps }
87
+ >
88
+ <ToolsPanelItem
89
+ hasValue={ () => paginationArrow !== 'none' }
90
+ label={ __( 'Pagination arrow' ) }
91
+ onDeselect={ () =>
92
+ setAttributes( { paginationArrow: 'none' } )
93
+ }
94
+ isShownByDefault
95
+ >
96
+ <QueryPaginationArrowControls
97
+ value={ paginationArrow }
73
98
  onChange={ ( value ) => {
74
- setAttributes( { showLabel: value } );
99
+ setAttributes( { paginationArrow: value } );
75
100
  } }
76
101
  />
102
+ </ToolsPanelItem>
103
+ { paginationArrow !== 'none' && (
104
+ <ToolsPanelItem
105
+ hasValue={ () => ! showLabel }
106
+ label={ __( 'Show text' ) }
107
+ onDeselect={ () =>
108
+ setAttributes( { showLabel: true } )
109
+ }
110
+ isShownByDefault
111
+ >
112
+ <QueryPaginationLabelControl
113
+ value={ showLabel }
114
+ onChange={ ( value ) => {
115
+ setAttributes( { showLabel: value } );
116
+ } }
117
+ />
118
+ </ToolsPanelItem>
77
119
  ) }
78
- </PanelBody>
120
+ </ToolsPanel>
79
121
  </InspectorControls>
80
122
  ) }
81
123
  <nav { ...innerBlocksProps } />
@@ -9,9 +9,7 @@ export function QueryPaginationLabelControl( { value, onChange } ) {
9
9
  <ToggleControl
10
10
  __nextHasNoMarginBottom
11
11
  label={ __( 'Show label text' ) }
12
- help={ __(
13
- 'Toggle off to hide the label text, e.g. "Next Page".'
14
- ) }
12
+ help={ __( 'Make label text visible, e.g. "Next Page".' ) }
15
13
  onChange={ onChange }
16
14
  checked={ value === true }
17
15
  />
@@ -3,7 +3,16 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
6
- import { PanelBody, RangeControl } from '@wordpress/components';
6
+ import {
7
+ __experimentalToolsPanel as ToolsPanel,
8
+ __experimentalToolsPanelItem as ToolsPanelItem,
9
+ RangeControl,
10
+ } from '@wordpress/components';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
7
16
 
8
17
  const createPaginationItem = ( content, Tag = 'a', extraClass = '' ) => (
9
18
  <Tag key={ content } className={ `page-numbers ${ extraClass }` }>
@@ -46,28 +55,41 @@ export default function QueryPaginationNumbersEdit( {
46
55
  const paginationNumbers = previewPaginationNumbers(
47
56
  parseInt( midSize, 10 )
48
57
  );
58
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
59
+
49
60
  return (
50
61
  <>
51
62
  <InspectorControls>
52
- <PanelBody title={ __( 'Settings' ) }>
53
- <RangeControl
54
- __next40pxDefaultSize
55
- __nextHasNoMarginBottom
63
+ <ToolsPanel
64
+ label={ __( 'Settings' ) }
65
+ resetAll={ () => setAttributes( { midSize: 2 } ) }
66
+ dropdownMenuProps={ dropdownMenuProps }
67
+ >
68
+ <ToolsPanelItem
56
69
  label={ __( 'Number of links' ) }
57
- help={ __(
58
- 'Specify how many links can appear before and after the current page number. Links to the first, current and last page are always visible.'
59
- ) }
60
- value={ midSize }
61
- onChange={ ( value ) => {
62
- setAttributes( {
63
- midSize: parseInt( value, 10 ),
64
- } );
65
- } }
66
- min={ 0 }
67
- max={ 5 }
68
- withInputField={ false }
69
- />
70
- </PanelBody>
70
+ hasValue={ () => midSize !== undefined }
71
+ onDeselect={ () => setAttributes( { midSize: 2 } ) }
72
+ isShownByDefault
73
+ >
74
+ <RangeControl
75
+ __next40pxDefaultSize
76
+ __nextHasNoMarginBottom
77
+ label={ __( 'Number of links' ) }
78
+ help={ __(
79
+ 'Specify how many links can appear before and after the current page number. Links to the first, current and last page are always visible.'
80
+ ) }
81
+ value={ midSize }
82
+ onChange={ ( value ) => {
83
+ setAttributes( {
84
+ midSize: parseInt( value, 10 ),
85
+ } );
86
+ } }
87
+ min={ 0 }
88
+ max={ 5 }
89
+ withInputField={ false }
90
+ />
91
+ </ToolsPanelItem>
92
+ </ToolsPanel>
71
93
  </InspectorControls>
72
94
  <div { ...useBlockProps() }>{ paginationNumbers }</div>
73
95
  </>
@@ -19,14 +19,14 @@
19
19
  function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
20
20
  $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
21
21
  $enhanced_pagination = isset( $block->context['enhancedPagination'] ) && $block->context['enhancedPagination'];
22
+ $max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
22
23
  $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
23
-
24
- $wrapper_attributes = get_block_wrapper_attributes();
25
- $show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
26
- $default_label = __( 'Previous Page' );
27
- $label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label;
28
- $label = $show_label ? $label_text : '';
29
- $pagination_arrow = get_query_pagination_arrow( $block, false );
24
+ $wrapper_attributes = get_block_wrapper_attributes();
25
+ $show_label = isset( $block->context['showLabel'] ) ? (bool) $block->context['showLabel'] : true;
26
+ $default_label = __( 'Previous Page' );
27
+ $label_text = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? esc_html( $attributes['label'] ) : $default_label;
28
+ $label = $show_label ? $label_text : '';
29
+ $pagination_arrow = get_query_pagination_arrow( $block, false );
30
30
  if ( ! $label ) {
31
31
  $wrapper_attributes .= ' aria-label="' . $label_text . '"';
32
32
  }
@@ -44,13 +44,20 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
44
44
  add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
45
45
  $content = get_previous_posts_link( $label );
46
46
  remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
47
- } elseif ( 1 !== $page ) {
48
- $content = sprintf(
49
- '<a href="%1$s" %2$s>%3$s</a>',
50
- esc_url( add_query_arg( $page_key, $page - 1 ) ),
51
- $wrapper_attributes,
52
- $label
53
- );
47
+ } else {
48
+ $block_query = new WP_Query( build_query_vars_from_query_block( $block, $page ) );
49
+ $block_max_pages = $block_query->max_num_pages;
50
+ $total = ! $max_page || $max_page > $block_max_pages ? $block_max_pages : $max_page;
51
+ wp_reset_postdata();
52
+
53
+ if ( 1 < $page && $page <= $total ) {
54
+ $content = sprintf(
55
+ '<a href="%1$s" %2$s>%3$s</a>',
56
+ esc_url( add_query_arg( $page_key, $page - 1 ) ),
57
+ $wrapper_attributes,
58
+ $label
59
+ );
60
+ }
54
61
  }
55
62
 
56
63
  if ( $enhanced_pagination && isset( $content ) ) {
@@ -40,6 +40,13 @@
40
40
  "__experimentalDefaultControls": {
41
41
  "fontSize": true
42
42
  }
43
+ },
44
+ "__experimentalBorder": {
45
+ "radius": true,
46
+ "color": true,
47
+ "width": true,
48
+ "style": true
43
49
  }
44
- }
50
+ },
51
+ "style": "wp-block-query-total"
45
52
  }
@@ -48,27 +48,25 @@ export default function QueryTotalEdit( { attributes, setAttributes } ) {
48
48
 
49
49
  // Controls for the block.
50
50
  const controls = (
51
- <>
52
- <BlockControls>
53
- <ToolbarGroup>
54
- <ToolbarDropdownMenu
55
- icon={ getButtonPositionIcon() }
56
- label={ __( 'Change display type' ) }
57
- controls={ buttonPositionControls }
58
- />
59
- </ToolbarGroup>
60
- </BlockControls>
61
- </>
51
+ <BlockControls>
52
+ <ToolbarGroup>
53
+ <ToolbarDropdownMenu
54
+ icon={ getButtonPositionIcon() }
55
+ label={ __( 'Change display type' ) }
56
+ controls={ buttonPositionControls }
57
+ />
58
+ </ToolbarGroup>
59
+ </BlockControls>
62
60
  );
63
61
 
64
62
  // Render output based on the selected display type.
65
63
  const renderDisplay = () => {
66
64
  if ( displayType === 'total-results' ) {
67
- return <div>{ __( '12 results found' ) }</div>;
65
+ return <>{ __( '12 results found' ) }</>;
68
66
  }
69
67
 
70
68
  if ( displayType === 'range-display' ) {
71
- return <div>{ __( 'Displaying 1 – 10 of 12' ) }</div>;
69
+ return <>{ __( 'Displaying 1 – 10 of 12' ) }</>;
72
70
  }
73
71
 
74
72
  return null;
@@ -40,32 +40,28 @@ function render_block_core_query_total( $attributes, $content, $block ) {
40
40
  switch ( $attributes['displayType'] ) {
41
41
  case 'range-display':
42
42
  if ( $start === $end ) {
43
- $range_text = sprintf(
43
+ $output = sprintf(
44
44
  /* translators: 1: Start index of posts, 2: Total number of posts */
45
45
  __( 'Displaying %1$s of %2$s' ),
46
- '<strong>' . $start . '</strong>',
47
- '<strong>' . $max_rows . '</strong>'
46
+ $start,
47
+ $max_rows
48
48
  );
49
49
  } else {
50
- $range_text = sprintf(
50
+ $output = sprintf(
51
51
  /* translators: 1: Start index of posts, 2: End index of posts, 3: Total number of posts */
52
52
  __( 'Displaying %1$s – %2$s of %3$s' ),
53
- '<strong>' . $start . '</strong>',
54
- '<strong>' . $end . '</strong>',
55
- '<strong>' . $max_rows . '</strong>'
53
+ $start,
54
+ $end,
55
+ $max_rows
56
56
  );
57
57
  }
58
58
 
59
- $output = sprintf( '<p>%s</p>', $range_text );
60
59
  break;
61
60
 
62
61
  case 'total-results':
63
62
  default:
64
- $output = sprintf(
65
- '<p><strong>%d</strong> %s</p>',
66
- $max_rows,
67
- _n( 'result found', 'results found', $max_rows )
68
- );
63
+ // translators: %d: number of results.
64
+ $output = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows );
69
65
  break;
70
66
  }
71
67
 
@@ -0,0 +1,4 @@
1
+ .wp-block-query-total {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
4
+ }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { __ } from '@wordpress/i18n';
4
5
  import { link as icon } from '@wordpress/icons';
5
6
 
6
7
  /**
@@ -16,6 +17,11 @@ export { metadata, name };
16
17
  export const settings = {
17
18
  icon,
18
19
  edit,
20
+ example: {
21
+ attributes: {
22
+ content: __( 'Read more' ),
23
+ },
24
+ },
19
25
  };
20
26
 
21
27
  export const init = () => initBlock( { name, metadata, settings } );