@wordpress/block-library 9.14.0 → 9.15.1

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
@@ -20,14 +20,16 @@ import {
20
20
  useBlockProps,
21
21
  useSettings,
22
22
  useBlockEditingMode,
23
+ store as blockEditorStore,
23
24
  } from '@wordpress/block-editor';
25
+ import { useSelect } from '@wordpress/data';
24
26
  import { getBlockSupport } from '@wordpress/blocks';
25
27
  import { formatLtr } from '@wordpress/icons';
26
-
27
28
  /**
28
29
  * Internal dependencies
29
30
  */
30
31
  import { useOnEnter } from './use-enter';
32
+ import { unlock } from '../lock-unlock';
31
33
 
32
34
  function ParagraphRTLControl( { direction, setDirection } ) {
33
35
  return (
@@ -109,7 +111,11 @@ function ParagraphBlock( {
109
111
  isSelected: isSingleSelected,
110
112
  name,
111
113
  } ) {
112
- const { align, content, direction, dropCap, placeholder } = attributes;
114
+ const isZoomOut = useSelect( ( select ) =>
115
+ unlock( select( blockEditorStore ) ).isZoomOut()
116
+ );
117
+
118
+ const { align, content, direction, dropCap } = attributes;
113
119
  const blockProps = useBlockProps( {
114
120
  ref: useOnEnter( { clientId, content } ),
115
121
  className: clsx( {
@@ -119,6 +125,12 @@ function ParagraphBlock( {
119
125
  style: { direction },
120
126
  } );
121
127
  const blockEditingMode = useBlockEditingMode();
128
+ let { placeholder } = attributes;
129
+ if ( isZoomOut ) {
130
+ placeholder = '';
131
+ } else if ( ! placeholder ) {
132
+ placeholder = __( 'Type / to choose a block' );
133
+ }
122
134
 
123
135
  return (
124
136
  <>
@@ -170,8 +182,10 @@ function ParagraphBlock( {
170
182
  : __( 'Block: Paragraph' )
171
183
  }
172
184
  data-empty={ RichText.isEmpty( content ) }
173
- placeholder={ placeholder || __( 'Type / to choose a block' ) }
174
- data-custom-placeholder={ placeholder ? true : undefined }
185
+ placeholder={ placeholder }
186
+ data-custom-placeholder={
187
+ placeholder && ! isZoomOut ? true : undefined
188
+ }
175
189
  __unstableEmbedURLOnPaste
176
190
  __unstableAllowPrefixTransformations
177
191
  />
@@ -26,11 +26,13 @@
26
26
  },
27
27
  "isLink": {
28
28
  "type": "boolean",
29
- "default": false
29
+ "default": false,
30
+ "role": "content"
30
31
  },
31
32
  "linkTarget": {
32
33
  "type": "string",
33
- "default": "_self"
34
+ "default": "_self",
35
+ "role": "content"
34
36
  }
35
37
  },
36
38
  "usesContext": [ "postType", "postId", "queryId" ],
@@ -21,7 +21,7 @@ import {
21
21
  __experimentalVStack as VStack,
22
22
  } from '@wordpress/components';
23
23
  import { useSelect, useDispatch } from '@wordpress/data';
24
- import { __ } from '@wordpress/i18n';
24
+ import { __, sprintf } from '@wordpress/i18n';
25
25
  import { store as coreStore } from '@wordpress/core-data';
26
26
 
27
27
  const minimumUsersForCombobox = 25;
@@ -38,9 +38,9 @@ function PostAuthorEdit( {
38
38
  setAttributes,
39
39
  } ) {
40
40
  const isDescendentOfQueryLoop = Number.isFinite( queryId );
41
- const { authorId, authorDetails, authors } = useSelect(
41
+ const { authorId, authorDetails, authors, supportsAuthor } = useSelect(
42
42
  ( select ) => {
43
- const { getEditedEntityRecord, getUser, getUsers } =
43
+ const { getEditedEntityRecord, getUser, getUsers, getPostType } =
44
44
  select( coreStore );
45
45
  const _authorId = getEditedEntityRecord(
46
46
  'postType',
@@ -52,6 +52,8 @@ function PostAuthorEdit( {
52
52
  authorId: _authorId,
53
53
  authorDetails: _authorId ? getUser( _authorId ) : null,
54
54
  authors: getUsers( AUTHORS_QUERY ),
55
+ supportsAuthor:
56
+ getPostType( postType )?.supports?.author ?? false,
55
57
  };
56
58
  },
57
59
  [ postType, postId ]
@@ -97,6 +99,18 @@ function PostAuthorEdit( {
97
99
  const showAuthorControl =
98
100
  !! postId && ! isDescendentOfQueryLoop && authorOptions.length > 0;
99
101
 
102
+ if ( ! supportsAuthor ) {
103
+ return (
104
+ <div { ...blockProps }>
105
+ { sprintf(
106
+ // translators: %s: Name of the post type e.g: "post".
107
+ __( 'This post type (%s) does not support the author.' ),
108
+ postType
109
+ ) }
110
+ </div>
111
+ );
112
+ }
113
+
100
114
  return (
101
115
  <>
102
116
  <InspectorControls>
@@ -26,6 +26,10 @@ function render_block_core_post_author( $attributes, $content, $block ) {
26
26
  return '';
27
27
  }
28
28
 
29
+ if ( ! post_type_supports( $block->context['postType'], 'author' ) ) {
30
+ return '';
31
+ }
32
+
29
33
  $avatar = ! empty( $attributes['avatarSize'] ) ? get_avatar(
30
34
  $author_id,
31
35
  $attributes['avatarSize']
@@ -12,11 +12,13 @@
12
12
  },
13
13
  "isLink": {
14
14
  "type": "boolean",
15
- "default": false
15
+ "default": false,
16
+ "role": "content"
16
17
  },
17
18
  "linkTarget": {
18
19
  "type": "string",
19
- "default": "_self"
20
+ "default": "_self",
21
+ "role": "content"
20
22
  }
21
23
  },
22
24
  "usesContext": [ "postType", "postId" ],
@@ -13,7 +13,7 @@ import {
13
13
  useBlockProps,
14
14
  } from '@wordpress/block-editor';
15
15
  import { useSelect } from '@wordpress/data';
16
- import { __ } from '@wordpress/i18n';
16
+ import { __, sprintf } from '@wordpress/i18n';
17
17
  import { store as coreStore } from '@wordpress/core-data';
18
18
  import { PanelBody, ToggleControl } from '@wordpress/components';
19
19
 
@@ -22,9 +22,10 @@ function PostAuthorNameEdit( {
22
22
  attributes: { textAlign, isLink, linkTarget },
23
23
  setAttributes,
24
24
  } ) {
25
- const { authorName } = useSelect(
25
+ const { authorName, supportsAuthor } = useSelect(
26
26
  ( select ) => {
27
- const { getEditedEntityRecord, getUser } = select( coreStore );
27
+ const { getEditedEntityRecord, getUser, getPostType } =
28
+ select( coreStore );
28
29
  const _authorId = getEditedEntityRecord(
29
30
  'postType',
30
31
  postType,
@@ -33,6 +34,8 @@ function PostAuthorNameEdit( {
33
34
 
34
35
  return {
35
36
  authorName: _authorId ? getUser( _authorId ) : null,
37
+ supportsAuthor:
38
+ getPostType( postType )?.supports?.author ?? false,
36
39
  };
37
40
  },
38
41
  [ postType, postId ]
@@ -90,7 +93,17 @@ function PostAuthorNameEdit( {
90
93
  ) }
91
94
  </PanelBody>
92
95
  </InspectorControls>
93
- <div { ...blockProps }> { displayAuthor } </div>
96
+ <div { ...blockProps }>
97
+ { supportsAuthor
98
+ ? displayAuthor
99
+ : sprintf(
100
+ // translators: %s: Name of the post type e.g: "post".
101
+ __(
102
+ 'This post type (%s) does not support the author.'
103
+ ),
104
+ postType
105
+ ) }
106
+ </div>
94
107
  </>
95
108
  );
96
109
  }
@@ -26,6 +26,10 @@ function render_block_core_post_author_name( $attributes, $content, $block ) {
26
26
  return '';
27
27
  }
28
28
 
29
+ if ( ! post_type_supports( $block->context['postType'], 'author' ) ) {
30
+ return '';
31
+ }
32
+
29
33
  $author_name = get_the_author_meta( 'display_name', $author_id );
30
34
  if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
31
35
  $author_name = sprintf( '<a href="%1$s" target="%2$s" class="wp-block-post-author-name__link">%3$s</a>', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $author_name );
@@ -56,5 +56,10 @@
56
56
  "wp-block-post-comments-form",
57
57
  "wp-block-buttons",
58
58
  "wp-block-button"
59
- ]
59
+ ],
60
+ "example": {
61
+ "attributes": {
62
+ "textAlign": "center"
63
+ }
64
+ }
60
65
  }
@@ -42,6 +42,13 @@
42
42
  },
43
43
  "interactivity": {
44
44
  "clientNavigation": true
45
+ },
46
+ "__experimentalBorder": {
47
+ "radius": true,
48
+ "color": true,
49
+ "width": true,
50
+ "style": true
45
51
  }
46
- }
52
+ },
53
+ "style": "wp-block-post-comments-link"
47
54
  }
@@ -0,0 +1,4 @@
1
+ .wp-block-post-comments-link {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
4
+ }
@@ -46,10 +46,33 @@ function render_block_core_post_content( $attributes, $content, $block ) {
46
46
  $content .= wp_link_pages( array( 'echo' => 0 ) );
47
47
  }
48
48
 
49
+ $ignored_hooked_blocks = get_post_meta( $post_id, '_wp_ignored_hooked_blocks', true );
50
+ if ( ! empty( $ignored_hooked_blocks ) ) {
51
+ $ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true );
52
+ $attributes['metadata'] = array(
53
+ 'ignoredHookedBlocks' => $ignored_hooked_blocks,
54
+ );
55
+ }
56
+
57
+ // Wrap in Post Content block so the Block Hooks algorithm can insert blocks
58
+ // that are hooked as first or last child of `core/post-content`.
59
+ $content = get_comment_delimited_block_content(
60
+ 'core/post-content',
61
+ $attributes,
62
+ $content
63
+ );
64
+
65
+ // We need to remove the `core/post-content` block wrapper after the Block Hooks algorithm,
66
+ // but before `do_blocks` runs, as it would otherwise attempt to render the same block again --
67
+ // thus recursing infinitely.
68
+ add_filter( 'the_content', 'remove_serialized_parent_block', 8 );
69
+
49
70
  /** This filter is documented in wp-includes/post-template.php */
50
71
  $content = apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', $content ) );
51
72
  unset( $seen_ids[ $post_id ] );
52
73
 
74
+ remove_filter( 'the_content', 'remove_serialized_parent_block', 8 );
75
+
53
76
  if ( empty( $content ) ) {
54
77
  return '';
55
78
  }
@@ -15,7 +15,8 @@
15
15
  },
16
16
  "isLink": {
17
17
  "type": "boolean",
18
- "default": false
18
+ "default": false,
19
+ "role": "content"
19
20
  },
20
21
  "displayType": {
21
22
  "type": "string",
@@ -26,13 +26,19 @@ import {
26
26
  ToolbarGroup,
27
27
  ToolbarButton,
28
28
  ToggleControl,
29
- PanelBody,
29
+ __experimentalToolsPanel as ToolsPanel,
30
+ __experimentalToolsPanelItem as ToolsPanelItem,
30
31
  } from '@wordpress/components';
31
32
  import { __, _x, sprintf } from '@wordpress/i18n';
32
33
  import { edit } from '@wordpress/icons';
33
34
  import { DOWN } from '@wordpress/keycodes';
34
35
  import { useSelect } from '@wordpress/data';
35
36
 
37
+ /**
38
+ * Internal dependencies
39
+ */
40
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
41
+
36
42
  export default function PostDateEdit( {
37
43
  attributes: { textAlign, format, isLink, displayType },
38
44
  context: { postId, postType: postTypeSlug, queryId },
@@ -44,6 +50,7 @@ export default function PostDateEdit( {
44
50
  [ `wp-block-post-date__modified-date` ]: displayType === 'modified',
45
51
  } ),
46
52
  } );
53
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
47
54
 
48
55
  // Use internal state instead of a ref to make sure that the component
49
56
  // re-renders when the popover's anchor updates.
@@ -160,16 +167,37 @@ export default function PostDateEdit( {
160
167
  </BlockControls>
161
168
 
162
169
  <InspectorControls>
163
- <PanelBody title={ __( 'Settings' ) }>
164
- <DateFormatPicker
165
- format={ format }
166
- defaultFormat={ siteFormat }
167
- onChange={ ( nextFormat ) =>
168
- setAttributes( { format: nextFormat } )
170
+ <ToolsPanel
171
+ label={ __( 'Settings' ) }
172
+ resetAll={ () => {
173
+ setAttributes( {
174
+ format: undefined,
175
+ isLink: false,
176
+ displayType: 'date',
177
+ } );
178
+ } }
179
+ dropdownMenuProps={ dropdownMenuProps }
180
+ >
181
+ <ToolsPanelItem
182
+ hasValue={ () =>
183
+ format !== undefined && format !== siteFormat
184
+ }
185
+ label={ __( 'Date Format' ) }
186
+ onDeselect={ () =>
187
+ setAttributes( { format: undefined } )
169
188
  }
170
- />
171
- <ToggleControl
172
- __nextHasNoMarginBottom
189
+ isShownByDefault
190
+ >
191
+ <DateFormatPicker
192
+ format={ format }
193
+ defaultFormat={ siteFormat }
194
+ onChange={ ( nextFormat ) =>
195
+ setAttributes( { format: nextFormat } )
196
+ }
197
+ />
198
+ </ToolsPanelItem>
199
+ <ToolsPanelItem
200
+ hasValue={ () => isLink !== false }
173
201
  label={
174
202
  postType?.labels.singular_name
175
203
  ? sprintf(
@@ -179,23 +207,49 @@ export default function PostDateEdit( {
179
207
  )
180
208
  : __( 'Link to post' )
181
209
  }
182
- onChange={ () => setAttributes( { isLink: ! isLink } ) }
183
- checked={ isLink }
184
- />
185
- <ToggleControl
186
- __nextHasNoMarginBottom
210
+ onDeselect={ () => setAttributes( { isLink: false } ) }
211
+ isShownByDefault
212
+ >
213
+ <ToggleControl
214
+ __nextHasNoMarginBottom
215
+ label={
216
+ postType?.labels.singular_name
217
+ ? sprintf(
218
+ // translators: %s: Name of the post type e.g: "post".
219
+ __( 'Link to %s' ),
220
+ postType.labels.singular_name.toLowerCase()
221
+ )
222
+ : __( 'Link to post' )
223
+ }
224
+ onChange={ () =>
225
+ setAttributes( { isLink: ! isLink } )
226
+ }
227
+ checked={ isLink }
228
+ />
229
+ </ToolsPanelItem>
230
+ <ToolsPanelItem
231
+ hasValue={ () => displayType !== 'date' }
187
232
  label={ __( 'Display last modified date' ) }
188
- onChange={ ( value ) =>
189
- setAttributes( {
190
- displayType: value ? 'modified' : 'date',
191
- } )
233
+ onDeselect={ () =>
234
+ setAttributes( { displayType: 'date' } )
192
235
  }
193
- checked={ displayType === 'modified' }
194
- help={ __(
195
- 'Only shows if the post has been modified'
196
- ) }
197
- />
198
- </PanelBody>
236
+ isShownByDefault
237
+ >
238
+ <ToggleControl
239
+ __nextHasNoMarginBottom
240
+ label={ __( 'Display last modified date' ) }
241
+ onChange={ ( value ) =>
242
+ setAttributes( {
243
+ displayType: value ? 'modified' : 'date',
244
+ } )
245
+ }
246
+ checked={ displayType === 'modified' }
247
+ help={ __(
248
+ 'Only shows if the post has been modified'
249
+ ) }
250
+ />
251
+ </ToolsPanelItem>
252
+ </ToolsPanel>
199
253
  </InspectorControls>
200
254
 
201
255
  <div { ...blockProps }>{ postDate }</div>
@@ -16,14 +16,22 @@ import {
16
16
  Warning,
17
17
  useBlockProps,
18
18
  } from '@wordpress/block-editor';
19
- import { PanelBody, ToggleControl, RangeControl } from '@wordpress/components';
19
+ import {
20
+ ToggleControl,
21
+ RangeControl,
22
+ __experimentalToolsPanel as ToolsPanel,
23
+ __experimentalToolsPanelItem as ToolsPanelItem,
24
+ } from '@wordpress/components';
20
25
  import { __, _x } from '@wordpress/i18n';
21
26
  import { useSelect } from '@wordpress/data';
22
27
 
23
28
  /**
24
29
  * Internal dependencies
25
30
  */
26
- import { useCanEditEntity } from '../utils/hooks';
31
+ import {
32
+ useCanEditEntity,
33
+ useToolsPanelDropdownMenuProps,
34
+ } from '../utils/hooks';
27
35
 
28
36
  const ELLIPSIS = '…';
29
37
 
@@ -41,6 +49,8 @@ export default function PostExcerptEditor( {
41
49
  { rendered: renderedExcerpt, protected: isProtected } = {},
42
50
  ] = useEntityProp( 'postType', postType, 'excerpt', postId );
43
51
 
52
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
53
+
44
54
  /**
45
55
  * Check if the post type supports excerpts.
46
56
  * Add an exception and return early for the "page" post type,
@@ -219,29 +229,56 @@ export default function PostExcerptEditor( {
219
229
  />
220
230
  </BlockControls>
221
231
  <InspectorControls>
222
- <PanelBody title={ __( 'Settings' ) }>
223
- <ToggleControl
224
- __nextHasNoMarginBottom
232
+ <ToolsPanel
233
+ label={ __( 'Settings' ) }
234
+ resetAll={ () => {
235
+ setAttributes( {
236
+ showMoreOnNewLine: true,
237
+ excerptLength: 55,
238
+ } );
239
+ } }
240
+ dropdownMenuProps={ dropdownMenuProps }
241
+ >
242
+ <ToolsPanelItem
243
+ hasValue={ () => showMoreOnNewLine !== true }
225
244
  label={ __( 'Show link on new line' ) }
226
- checked={ showMoreOnNewLine }
227
- onChange={ ( newShowMoreOnNewLine ) =>
228
- setAttributes( {
229
- showMoreOnNewLine: newShowMoreOnNewLine,
230
- } )
245
+ onDeselect={ () =>
246
+ setAttributes( { showMoreOnNewLine: true } )
231
247
  }
232
- />
233
- <RangeControl
234
- __next40pxDefaultSize
235
- __nextHasNoMarginBottom
248
+ isShownByDefault
249
+ >
250
+ <ToggleControl
251
+ __nextHasNoMarginBottom
252
+ label={ __( 'Show link on new line' ) }
253
+ checked={ showMoreOnNewLine }
254
+ onChange={ ( newShowMoreOnNewLine ) =>
255
+ setAttributes( {
256
+ showMoreOnNewLine: newShowMoreOnNewLine,
257
+ } )
258
+ }
259
+ />
260
+ </ToolsPanelItem>
261
+ <ToolsPanelItem
262
+ hasValue={ () => excerptLength !== 55 }
236
263
  label={ __( 'Max number of words' ) }
237
- value={ excerptLength }
238
- onChange={ ( value ) => {
239
- setAttributes( { excerptLength: value } );
240
- } }
241
- min="10"
242
- max="100"
243
- />
244
- </PanelBody>
264
+ onDeselect={ () =>
265
+ setAttributes( { excerptLength: 55 } )
266
+ }
267
+ isShownByDefault
268
+ >
269
+ <RangeControl
270
+ __next40pxDefaultSize
271
+ __nextHasNoMarginBottom
272
+ label={ __( 'Max number of words' ) }
273
+ value={ excerptLength }
274
+ onChange={ ( value ) => {
275
+ setAttributes( { excerptLength: value } );
276
+ } }
277
+ min="10"
278
+ max="100"
279
+ />
280
+ </ToolsPanelItem>
281
+ </ToolsPanel>
245
282
  </InspectorControls>
246
283
  <div { ...blockProps }>
247
284
  { excerptContent }
@@ -9,7 +9,8 @@
9
9
  "attributes": {
10
10
  "isLink": {
11
11
  "type": "boolean",
12
- "default": false
12
+ "default": false,
13
+ "role": "content"
13
14
  },
14
15
  "aspectRatio": {
15
16
  "type": "string"
@@ -30,11 +31,13 @@
30
31
  "rel": {
31
32
  "type": "string",
32
33
  "attribute": "rel",
33
- "default": ""
34
+ "default": "",
35
+ "role": "content"
34
36
  },
35
37
  "linkTarget": {
36
38
  "type": "string",
37
- "default": "_self"
39
+ "default": "_self",
40
+ "role": "content"
38
41
  },
39
42
  "overlayColor": {
40
43
  "type": "string"
@@ -12,10 +12,18 @@ import {
12
12
  } from '@wordpress/components';
13
13
  import {
14
14
  useSettings,
15
+ privateApis as blockEditorPrivateApis,
15
16
  store as blockEditorStore,
16
17
  } from '@wordpress/block-editor';
17
18
  import { useSelect } from '@wordpress/data';
18
19
 
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ import { unlock } from '../lock-unlock';
24
+
25
+ const { ResolutionTool } = unlock( blockEditorPrivateApis );
26
+
19
27
  const SCALE_OPTIONS = (
20
28
  <>
21
29
  <ToggleGroupControlOption
@@ -223,30 +231,19 @@ const DimensionControls = ( {
223
231
  </ToolsPanelItem>
224
232
  ) }
225
233
  { !! imageSizeOptions.length && (
226
- <ToolsPanelItem
227
- hasValue={ () => !! sizeSlug }
228
- label={ __( 'Resolution' ) }
229
- onDeselect={ () =>
230
- setAttributes( { sizeSlug: undefined } )
234
+ <ResolutionTool
235
+ panelId={ clientId }
236
+ value={ sizeSlug }
237
+ defaultValue={ DEFAULT_SIZE }
238
+ options={ imageSizeOptions }
239
+ onChange={ ( nextSizeSlug ) =>
240
+ setAttributes( { sizeSlug: nextSizeSlug } )
231
241
  }
242
+ isShownByDefault={ false }
232
243
  resetAllFilter={ () => ( {
233
- sizeSlug: undefined,
244
+ sizeSlug: DEFAULT_SIZE,
234
245
  } ) }
235
- isShownByDefault={ false }
236
- panelId={ clientId }
237
- >
238
- <SelectControl
239
- __next40pxDefaultSize
240
- __nextHasNoMarginBottom
241
- label={ __( 'Resolution' ) }
242
- value={ sizeSlug || DEFAULT_SIZE }
243
- options={ imageSizeOptions }
244
- onChange={ ( nextSizeSlug ) =>
245
- setAttributes( { sizeSlug: nextSizeSlug } )
246
- }
247
- help={ __( 'Select the size of the source image.' ) }
248
- />
249
- </ToolsPanelItem>
246
+ />
250
247
  ) }
251
248
  </>
252
249
  );