@wordpress/block-library 7.15.1-next.4d3b314fd5.0 → 7.17.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 (351) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/build/archives/edit.js +1 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/code/utils.js +3 -3
  5. package/build/code/utils.js.map +1 -1
  6. package/build/comment-template/edit.js +40 -32
  7. package/build/comment-template/edit.js.map +1 -1
  8. package/build/comments/edit/placeholder.js +1 -4
  9. package/build/comments/edit/placeholder.js.map +1 -1
  10. package/build/comments/index.js +5 -1
  11. package/build/comments/index.js.map +1 -1
  12. package/build/comments-title/edit.js +18 -1
  13. package/build/comments-title/edit.js.map +1 -1
  14. package/build/cover/edit/index.js +2 -2
  15. package/build/cover/edit/index.js.map +1 -1
  16. package/build/cover/edit/use-cover-is-dark.js +8 -7
  17. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  18. package/build/embed/variations.js +1 -1
  19. package/build/embed/variations.js.map +1 -1
  20. package/build/gallery/transforms.js +3 -3
  21. package/build/gallery/transforms.js.map +1 -1
  22. package/build/gallery/v1/edit.js +1 -1
  23. package/build/gallery/v1/edit.js.map +1 -1
  24. package/build/group/edit.js +1 -1
  25. package/build/group/edit.js.map +1 -1
  26. package/build/image/image.js +34 -10
  27. package/build/image/image.js.map +1 -1
  28. package/build/image/transforms.js +1 -7
  29. package/build/image/transforms.js.map +1 -1
  30. package/build/list/transforms.js +9 -1
  31. package/build/list/transforms.js.map +1 -1
  32. package/build/list-item/edit.js +3 -2
  33. package/build/list-item/edit.js.map +1 -1
  34. package/build/list-item/edit.native.js +3 -2
  35. package/build/list-item/edit.native.js.map +1 -1
  36. package/build/list-item/hooks/use-merge.js +19 -22
  37. package/build/list-item/hooks/use-merge.js.map +1 -1
  38. package/build/list-item/hooks/use-outdent-list-item.js +19 -3
  39. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  40. package/build/list-item/index.js +14 -1
  41. package/build/list-item/index.js.map +1 -1
  42. package/build/list-item/utils.js +14 -1
  43. package/build/list-item/utils.js.map +1 -1
  44. package/build/navigation/edit/index.js +46 -33
  45. package/build/navigation/edit/index.js.map +1 -1
  46. package/build/navigation/edit/inner-blocks.js +3 -5
  47. package/build/navigation/edit/inner-blocks.js.map +1 -1
  48. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  49. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  50. package/build/navigation/edit/use-create-navigation-menu.js +1 -1
  51. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  52. package/build/navigation/index.js +4 -1
  53. package/build/navigation/index.js.map +1 -1
  54. package/build/navigation-link/edit.js +1 -1
  55. package/build/navigation-link/edit.js.map +1 -1
  56. package/build/page-list/index.js +1 -5
  57. package/build/page-list/index.js.map +1 -1
  58. package/build/paragraph/deprecated.js +49 -10
  59. package/build/paragraph/deprecated.js.map +1 -1
  60. package/build/paragraph/edit.js +22 -14
  61. package/build/paragraph/edit.js.map +1 -1
  62. package/build/paragraph/save.js +3 -1
  63. package/build/paragraph/save.js.map +1 -1
  64. package/build/pattern/edit.js +11 -4
  65. package/build/pattern/edit.js.map +1 -1
  66. package/build/post-author/edit.js +20 -2
  67. package/build/post-author/edit.js.map +1 -1
  68. package/build/post-author/index.js +8 -0
  69. package/build/post-author/index.js.map +1 -1
  70. package/build/post-comments-form/form.js +1 -2
  71. package/build/post-comments-form/form.js.map +1 -1
  72. package/build/post-featured-image/index.js +1 -1
  73. package/build/post-featured-image/overlay.js +2 -2
  74. package/build/post-featured-image/overlay.js.map +1 -1
  75. package/build/post-terms/index.js +4 -0
  76. package/build/post-terms/index.js.map +1 -1
  77. package/build/query/edit/inspector-controls/author-control.js +2 -1
  78. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  79. package/build/query/edit/inspector-controls/index.js +3 -3
  80. package/build/query/edit/inspector-controls/index.js.map +1 -1
  81. package/build/query/edit/inspector-controls/parent-control.js +2 -1
  82. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  83. package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -103
  84. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  85. package/build/query/utils.js +1 -1
  86. package/build/query/utils.js.map +1 -1
  87. package/build/quote/index.js +0 -1
  88. package/build/quote/index.js.map +1 -1
  89. package/build/search/edit.js +2 -1
  90. package/build/search/edit.js.map +1 -1
  91. package/build/site-logo/edit.js +6 -9
  92. package/build/site-logo/edit.js.map +1 -1
  93. package/build/site-title/index.js +2 -1
  94. package/build/site-title/index.js.map +1 -1
  95. package/build/table/state.js +1 -1
  96. package/build/table/state.js.map +1 -1
  97. package/build/table-of-contents/edit.js +1 -4
  98. package/build/table-of-contents/edit.js.map +1 -1
  99. package/build/tag-cloud/edit.js +1 -1
  100. package/build/tag-cloud/edit.js.map +1 -1
  101. package/build/tag-cloud/index.js +8 -0
  102. package/build/tag-cloud/index.js.map +1 -1
  103. package/build/template-part/index.js +2 -2
  104. package/build/template-part/index.js.map +1 -1
  105. package/build/video/edit.js +13 -1
  106. package/build/video/edit.js.map +1 -1
  107. package/build-module/archives/edit.js +1 -0
  108. package/build-module/archives/edit.js.map +1 -1
  109. package/build-module/code/utils.js +3 -3
  110. package/build-module/code/utils.js.map +1 -1
  111. package/build-module/comment-template/edit.js +38 -30
  112. package/build-module/comment-template/edit.js.map +1 -1
  113. package/build-module/comments/edit/placeholder.js +1 -3
  114. package/build-module/comments/edit/placeholder.js.map +1 -1
  115. package/build-module/comments/index.js +5 -1
  116. package/build-module/comments/index.js.map +1 -1
  117. package/build-module/comments-title/edit.js +18 -2
  118. package/build-module/comments-title/edit.js.map +1 -1
  119. package/build-module/cover/edit/index.js +2 -2
  120. package/build-module/cover/edit/index.js.map +1 -1
  121. package/build-module/cover/edit/use-cover-is-dark.js +7 -7
  122. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  123. package/build-module/embed/variations.js +1 -1
  124. package/build-module/embed/variations.js.map +1 -1
  125. package/build-module/gallery/transforms.js +4 -4
  126. package/build-module/gallery/transforms.js.map +1 -1
  127. package/build-module/gallery/v1/edit.js +2 -2
  128. package/build-module/gallery/v1/edit.js.map +1 -1
  129. package/build-module/group/edit.js +1 -1
  130. package/build-module/group/edit.js.map +1 -1
  131. package/build-module/image/image.js +35 -11
  132. package/build-module/image/image.js.map +1 -1
  133. package/build-module/image/transforms.js +1 -6
  134. package/build-module/image/transforms.js.map +1 -1
  135. package/build-module/list/transforms.js +9 -1
  136. package/build-module/list/transforms.js.map +1 -1
  137. package/build-module/list-item/edit.js +3 -2
  138. package/build-module/list-item/edit.js.map +1 -1
  139. package/build-module/list-item/edit.native.js +3 -2
  140. package/build-module/list-item/edit.native.js.map +1 -1
  141. package/build-module/list-item/hooks/use-merge.js +19 -21
  142. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  143. package/build-module/list-item/hooks/use-outdent-list-item.js +19 -3
  144. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  145. package/build-module/list-item/index.js +14 -1
  146. package/build-module/list-item/index.js.map +1 -1
  147. package/build-module/list-item/utils.js +14 -1
  148. package/build-module/list-item/utils.js.map +1 -1
  149. package/build-module/navigation/edit/index.js +46 -33
  150. package/build-module/navigation/edit/index.js.map +1 -1
  151. package/build-module/navigation/edit/inner-blocks.js +3 -5
  152. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  153. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  154. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  155. package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
  156. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  157. package/build-module/navigation/index.js +4 -1
  158. package/build-module/navigation/index.js.map +1 -1
  159. package/build-module/navigation-link/edit.js +1 -1
  160. package/build-module/navigation-link/edit.js.map +1 -1
  161. package/build-module/page-list/index.js +1 -5
  162. package/build-module/page-list/index.js.map +1 -1
  163. package/build-module/paragraph/deprecated.js +49 -11
  164. package/build-module/paragraph/deprecated.js.map +1 -1
  165. package/build-module/paragraph/edit.js +22 -13
  166. package/build-module/paragraph/edit.js.map +1 -1
  167. package/build-module/paragraph/save.js +2 -1
  168. package/build-module/paragraph/save.js.map +1 -1
  169. package/build-module/pattern/edit.js +10 -3
  170. package/build-module/pattern/edit.js.map +1 -1
  171. package/build-module/post-author/edit.js +21 -2
  172. package/build-module/post-author/edit.js.map +1 -1
  173. package/build-module/post-author/index.js +8 -0
  174. package/build-module/post-author/index.js.map +1 -1
  175. package/build-module/post-comments-form/form.js +2 -3
  176. package/build-module/post-comments-form/form.js.map +1 -1
  177. package/build-module/post-featured-image/index.js +1 -1
  178. package/build-module/post-featured-image/overlay.js +2 -2
  179. package/build-module/post-featured-image/overlay.js.map +1 -1
  180. package/build-module/post-terms/index.js +4 -0
  181. package/build-module/post-terms/index.js.map +1 -1
  182. package/build-module/query/edit/inspector-controls/author-control.js +2 -1
  183. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  184. package/build-module/query/edit/inspector-controls/index.js +5 -5
  185. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  186. package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
  187. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  188. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -101
  189. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  190. package/build-module/query/utils.js +1 -1
  191. package/build-module/query/utils.js.map +1 -1
  192. package/build-module/quote/index.js +0 -1
  193. package/build-module/quote/index.js.map +1 -1
  194. package/build-module/search/edit.js +3 -2
  195. package/build-module/search/edit.js.map +1 -1
  196. package/build-module/site-logo/edit.js +6 -9
  197. package/build-module/site-logo/edit.js.map +1 -1
  198. package/build-module/site-title/index.js +2 -1
  199. package/build-module/site-title/index.js.map +1 -1
  200. package/build-module/table/state.js +2 -2
  201. package/build-module/table/state.js.map +1 -1
  202. package/build-module/table-of-contents/edit.js +1 -3
  203. package/build-module/table-of-contents/edit.js.map +1 -1
  204. package/build-module/tag-cloud/edit.js +1 -1
  205. package/build-module/tag-cloud/edit.js.map +1 -1
  206. package/build-module/tag-cloud/index.js +8 -0
  207. package/build-module/tag-cloud/index.js.map +1 -1
  208. package/build-module/template-part/index.js +2 -2
  209. package/build-module/template-part/index.js.map +1 -1
  210. package/build-module/video/edit.js +15 -3
  211. package/build-module/video/edit.js.map +1 -1
  212. package/build-style/archives/style-rtl.css +4 -0
  213. package/build-style/archives/style.css +4 -0
  214. package/build-style/code/style-rtl.css +3 -0
  215. package/build-style/code/style.css +3 -0
  216. package/build-style/comments/editor-rtl.css +1 -0
  217. package/build-style/comments/editor.css +1 -0
  218. package/build-style/comments/style-rtl.css +1 -0
  219. package/build-style/comments/style.css +1 -0
  220. package/build-style/cover/editor-rtl.css +4 -0
  221. package/build-style/cover/editor.css +4 -0
  222. package/build-style/editor-rtl.css +78 -46
  223. package/build-style/editor.css +78 -46
  224. package/build-style/group/editor-rtl.css +1 -0
  225. package/build-style/group/editor.css +1 -0
  226. package/build-style/image/editor-rtl.css +1 -1
  227. package/build-style/image/editor.css +1 -1
  228. package/build-style/navigation/editor-rtl.css +5 -0
  229. package/build-style/navigation/editor.css +5 -0
  230. package/build-style/navigation/style-rtl.css +3 -0
  231. package/build-style/navigation/style.css +3 -0
  232. package/build-style/paragraph/editor-rtl.css +0 -16
  233. package/build-style/paragraph/editor.css +0 -16
  234. package/build-style/paragraph/style-rtl.css +5 -0
  235. package/build-style/paragraph/style.css +5 -0
  236. package/build-style/post-featured-image/editor-rtl.css +39 -29
  237. package/build-style/post-featured-image/editor.css +39 -29
  238. package/build-style/post-terms/style-rtl.css +4 -1
  239. package/build-style/post-terms/style.css +4 -1
  240. package/build-style/site-logo/editor-rtl.css +1 -0
  241. package/build-style/site-logo/editor.css +1 -0
  242. package/build-style/site-title/editor-rtl.css +4 -0
  243. package/build-style/site-title/editor.css +4 -0
  244. package/build-style/site-title/style-rtl.css +79 -0
  245. package/build-style/site-title/style.css +79 -0
  246. package/build-style/style-rtl.css +27 -1
  247. package/build-style/style.css +27 -1
  248. package/build-style/tag-cloud/style-rtl.css +3 -0
  249. package/build-style/tag-cloud/style.css +3 -0
  250. package/build-style/video/editor-rtl.css +22 -0
  251. package/build-style/video/editor.css +22 -0
  252. package/package.json +28 -28
  253. package/src/archives/edit.js +1 -0
  254. package/src/archives/style.scss +5 -0
  255. package/src/avatar/index.php +1 -1
  256. package/src/categories/index.php +1 -1
  257. package/src/code/style.scss +12 -7
  258. package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
  259. package/src/code/test/edit.native.js +46 -32
  260. package/src/code/utils.js +3 -3
  261. package/src/comment-author-name/index.php +1 -1
  262. package/src/comment-reply-link/index.php +1 -1
  263. package/src/comment-template/edit.js +47 -34
  264. package/src/comment-template/index.php +2 -3
  265. package/src/comments/block.json +5 -1
  266. package/src/comments/edit/placeholder.js +1 -7
  267. package/src/comments/style.scss +2 -0
  268. package/src/comments-title/edit.js +24 -1
  269. package/src/cover/edit/index.js +2 -7
  270. package/src/cover/edit/use-cover-is-dark.js +11 -11
  271. package/src/cover/editor.scss +7 -0
  272. package/src/cover/index.php +1 -1
  273. package/src/embed/variations.js +1 -1
  274. package/src/gallery/transforms.js +8 -5
  275. package/src/gallery/v1/edit.js +2 -2
  276. package/src/group/edit.js +1 -1
  277. package/src/group/editor.scss +1 -0
  278. package/src/image/editor.scss +4 -1
  279. package/src/image/image.js +59 -29
  280. package/src/image/transforms.js +1 -7
  281. package/src/latest-posts/index.php +1 -1
  282. package/src/list/test/edit.native.js +102 -3
  283. package/src/list/transforms.js +11 -0
  284. package/src/list-item/block.json +14 -1
  285. package/src/list-item/edit.js +2 -1
  286. package/src/list-item/edit.native.js +2 -1
  287. package/src/list-item/hooks/use-merge.js +4 -23
  288. package/src/list-item/hooks/use-outdent-list-item.js +6 -2
  289. package/src/navigation/block.json +4 -1
  290. package/src/navigation/edit/index.js +60 -32
  291. package/src/navigation/edit/inner-blocks.js +2 -5
  292. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
  293. package/src/navigation/edit/use-create-navigation-menu.js +2 -5
  294. package/src/navigation/editor.scss +7 -0
  295. package/src/navigation/index.php +103 -6
  296. package/src/navigation/style.scss +8 -0
  297. package/src/navigation-link/edit.js +1 -1
  298. package/src/navigation-link/index.php +8 -1
  299. package/src/navigation-submenu/index.php +8 -1
  300. package/src/page-list/block.json +1 -5
  301. package/src/page-list/index.php +10 -8
  302. package/src/paragraph/deprecated.js +36 -0
  303. package/src/paragraph/edit.js +24 -22
  304. package/src/paragraph/editor.scss +0 -20
  305. package/src/paragraph/save.js +5 -1
  306. package/src/paragraph/style.scss +5 -0
  307. package/src/pattern/edit.js +10 -3
  308. package/src/post-author/block.json +8 -0
  309. package/src/post-author/edit.js +29 -3
  310. package/src/post-author/index.php +7 -1
  311. package/src/post-comments-form/form.js +2 -3
  312. package/src/post-featured-image/block.json +1 -1
  313. package/src/post-featured-image/editor.scss +79 -72
  314. package/src/post-featured-image/index.php +18 -24
  315. package/src/post-featured-image/overlay.js +17 -14
  316. package/src/post-terms/block.json +4 -0
  317. package/src/post-terms/style.scss +7 -2
  318. package/src/query/edit/inspector-controls/author-control.js +1 -0
  319. package/src/query/edit/inspector-controls/index.js +5 -7
  320. package/src/query/edit/inspector-controls/parent-control.js +1 -0
  321. package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -86
  322. package/src/query/utils.js +1 -1
  323. package/src/quote/block.json +0 -1
  324. package/src/rss/index.php +3 -3
  325. package/src/search/edit.js +6 -1
  326. package/src/search/index.php +21 -13
  327. package/src/site-logo/edit.js +10 -8
  328. package/src/site-logo/editor.scss +1 -0
  329. package/src/site-title/block.json +2 -1
  330. package/src/site-title/editor.scss +6 -0
  331. package/src/site-title/style.scss +5 -0
  332. package/src/style.scss +1 -0
  333. package/src/table/state.js +2 -2
  334. package/src/table-of-contents/edit.js +1 -3
  335. package/src/tag-cloud/block.json +8 -0
  336. package/src/tag-cloud/edit.js +1 -1
  337. package/src/tag-cloud/style.scss +3 -0
  338. package/src/template-part/index.js +2 -2
  339. package/src/template-part/index.php +4 -0
  340. package/src/video/edit.js +19 -0
  341. package/src/video/editor.scss +37 -0
  342. package/build/navigation-submenu/view.js +0 -56
  343. package/build/navigation-submenu/view.js.map +0 -1
  344. package/build/paragraph/drop-zone.js +0 -99
  345. package/build/paragraph/drop-zone.js.map +0 -1
  346. package/build-module/navigation-submenu/view.js +0 -54
  347. package/build-module/navigation-submenu/view.js.map +0 -1
  348. package/build-module/paragraph/drop-zone.js +0 -88
  349. package/build-module/paragraph/drop-zone.js.map +0 -1
  350. package/src/navigation-submenu/view.js +0 -67
  351. package/src/paragraph/drop-zone.js +0 -105
@@ -6,7 +6,6 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState } from '@wordpress/element';
10
9
  import { __, _x, isRTL } from '@wordpress/i18n';
11
10
  import {
12
11
  ToolbarButton,
@@ -21,7 +20,6 @@ import {
21
20
  useBlockProps,
22
21
  useSetting,
23
22
  } from '@wordpress/block-editor';
24
- import { useMergeRefs } from '@wordpress/compose';
25
23
  import { createBlock } from '@wordpress/blocks';
26
24
  import { formatLtr } from '@wordpress/icons';
27
25
 
@@ -29,7 +27,6 @@ import { formatLtr } from '@wordpress/icons';
29
27
  * Internal dependencies
30
28
  */
31
29
  import { useOnEnter } from './use-enter';
32
- import DropZone from './drop-zone';
33
30
 
34
31
  const name = 'core/paragraph';
35
32
 
@@ -48,6 +45,10 @@ function ParagraphRTLControl( { direction, setDirection } ) {
48
45
  );
49
46
  }
50
47
 
48
+ function hasDropCapDisabled( align ) {
49
+ return align === ( isRTL() ? 'left' : 'right' ) || align === 'center';
50
+ }
51
+
51
52
  function ParagraphBlock( {
52
53
  attributes,
53
54
  mergeBlocks,
@@ -58,26 +59,36 @@ function ParagraphBlock( {
58
59
  } ) {
59
60
  const { align, content, direction, dropCap, placeholder } = attributes;
60
61
  const isDropCapFeatureEnabled = useSetting( 'typography.dropCap' );
61
- const [ paragraphElement, setParagraphElement ] = useState( null );
62
62
  const blockProps = useBlockProps( {
63
- ref: useMergeRefs( [
64
- useOnEnter( { clientId, content } ),
65
- setParagraphElement,
66
- ] ),
63
+ ref: useOnEnter( { clientId, content } ),
67
64
  className: classnames( {
68
- 'has-drop-cap': dropCap,
65
+ 'has-drop-cap': hasDropCapDisabled( align ) ? false : dropCap,
69
66
  [ `has-text-align-${ align }` ]: align,
70
67
  } ),
71
68
  style: { direction },
72
69
  } );
73
70
 
71
+ let helpText;
72
+ if ( hasDropCapDisabled( align ) ) {
73
+ helpText = __( 'Not available for aligned text.' );
74
+ } else if ( dropCap ) {
75
+ helpText = __( 'Showing large initial letter.' );
76
+ } else {
77
+ helpText = __( 'Toggle to show a large initial letter.' );
78
+ }
79
+
74
80
  return (
75
81
  <>
76
82
  <BlockControls group="block">
77
83
  <AlignmentControl
78
84
  value={ align }
79
85
  onChange={ ( newAlign ) =>
80
- setAttributes( { align: newAlign } )
86
+ setAttributes( {
87
+ align: newAlign,
88
+ dropCap: hasDropCapDisabled( newAlign )
89
+ ? false
90
+ : dropCap,
91
+ } )
81
92
  }
82
93
  />
83
94
  <ParagraphRTLControl
@@ -104,23 +115,14 @@ function ParagraphBlock( {
104
115
  onChange={ () =>
105
116
  setAttributes( { dropCap: ! dropCap } )
106
117
  }
107
- help={
108
- dropCap
109
- ? __( 'Showing large initial letter.' )
110
- : __(
111
- 'Toggle to show a large initial letter.'
112
- )
118
+ help={ helpText }
119
+ disabled={
120
+ hasDropCapDisabled( align ) ? true : false
113
121
  }
114
122
  />
115
123
  </ToolsPanelItem>
116
124
  </InspectorControls>
117
125
  ) }
118
- { ! content && (
119
- <DropZone
120
- clientId={ clientId }
121
- paragraphElement={ paragraphElement }
122
- />
123
- ) }
124
126
  <RichText
125
127
  identifier="content"
126
128
  tagName="p"
@@ -17,23 +17,3 @@
17
17
  }
18
18
  }
19
19
  }
20
-
21
- .components-popover.wp-block-paragraph__drop-zone {
22
- .components-popover__content {
23
- border: none;
24
- outline: none;
25
- box-shadow: none;
26
- }
27
-
28
- .wp-block-paragraph__drop-zone-backdrop {
29
- position: absolute;
30
- }
31
-
32
- .wp-block-paragraph__drop-zone-foreground {
33
- position: absolute;
34
- inset: 0;
35
- pointer-events: none;
36
- background-color: var(--wp-admin-theme-color);
37
- border-radius: 2px;
38
- }
39
- }
@@ -7,11 +7,15 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { RichText, useBlockProps } from '@wordpress/block-editor';
10
+ import { isRTL } from '@wordpress/i18n';
10
11
 
11
12
  export default function save( { attributes } ) {
12
13
  const { align, content, dropCap, direction } = attributes;
13
14
  const className = classnames( {
14
- 'has-drop-cap': dropCap,
15
+ 'has-drop-cap':
16
+ align === ( isRTL() ? 'left' : 'right' ) || align === 'center'
17
+ ? false
18
+ : dropCap,
15
19
  [ `has-text-align-${ align }` ]: align,
16
20
  } );
17
21
 
@@ -28,6 +28,11 @@
28
28
  font-style: normal;
29
29
  }
30
30
 
31
+ body.rtl .has-drop-cap:not(:focus)::first-letter {
32
+ float: initial;
33
+ margin-left: 0.1em;
34
+ }
35
+
31
36
  // Prevent the dropcap from breaking out of the box when a background is applied.
32
37
  p.has-drop-cap.has-background {
33
38
  overflow: hidden;
@@ -26,10 +26,17 @@ const PatternEdit = ( { attributes, clientId } ) => {
26
26
  // It will continue to pull from the pattern file unless changes are made to its respective template part.
27
27
  useEffect( () => {
28
28
  if ( selectedPattern?.blocks ) {
29
- __unstableMarkNextChangeAsNotPersistent();
30
- replaceBlocks( clientId, selectedPattern.blocks );
29
+ // We batch updates to block list settings to avoid triggering cascading renders
30
+ // for each container block included in a tree and optimize initial render.
31
+ // Since the above uses microtasks, we need to use a microtask here as well,
32
+ // because nested pattern blocks cannot be inserted if the parent block supports
33
+ // inner blocks but doesn't have blockSettings in the state.
34
+ window.queueMicrotask( () => {
35
+ __unstableMarkNextChangeAsNotPersistent();
36
+ replaceBlocks( clientId, selectedPattern.blocks );
37
+ } );
31
38
  }
32
- }, [ selectedPattern?.blocks ] );
39
+ }, [ clientId, selectedPattern?.blocks ] );
33
40
 
34
41
  const props = useBlockProps();
35
42
 
@@ -23,6 +23,14 @@
23
23
  },
24
24
  "byline": {
25
25
  "type": "string"
26
+ },
27
+ "isLink": {
28
+ "type": "boolean",
29
+ "default": false
30
+ },
31
+ "linkTarget": {
32
+ "type": "string",
33
+ "default": "_self"
26
34
  }
27
35
  },
28
36
  "usesContext": [ "postType", "postId", "queryId" ],
@@ -46,9 +46,10 @@ function PostAuthorEdit( {
46
46
 
47
47
  const { editEntityRecord } = useDispatch( coreStore );
48
48
 
49
- const { textAlign, showAvatar, showBio, byline } = attributes;
50
-
49
+ const { textAlign, showAvatar, showBio, byline, isLink, linkTarget } =
50
+ attributes;
51
51
  const avatarSizes = [];
52
+ const authorName = authorDetails?.name || __( 'Post Author' );
52
53
  if ( authorDetails ) {
53
54
  Object.keys( authorDetails.avatar_urls ).forEach( ( size ) => {
54
55
  avatarSizes.push( {
@@ -118,6 +119,22 @@ function PostAuthorEdit( {
118
119
  setAttributes( { showBio: ! showBio } )
119
120
  }
120
121
  />
122
+ <ToggleControl
123
+ label={ __( 'Link author name to author page' ) }
124
+ checked={ isLink }
125
+ onChange={ () => setAttributes( { isLink: ! isLink } ) }
126
+ />
127
+ { isLink && (
128
+ <ToggleControl
129
+ label={ __( 'Open in new tab' ) }
130
+ onChange={ ( value ) =>
131
+ setAttributes( {
132
+ linkTarget: value ? '_blank' : '_self',
133
+ } )
134
+ }
135
+ checked={ linkTarget === '_blank' }
136
+ />
137
+ ) }
121
138
  </PanelBody>
122
139
  </InspectorControls>
123
140
 
@@ -158,7 +175,16 @@ function PostAuthorEdit( {
158
175
  />
159
176
  ) }
160
177
  <p className="wp-block-post-author__name">
161
- { authorDetails?.name || __( 'Post Author' ) }
178
+ { isLink ? (
179
+ <a
180
+ href="#post-author-pseudo-link"
181
+ onClick={ ( event ) => event.preventDefault() }
182
+ >
183
+ { authorName }
184
+ </a>
185
+ ) : (
186
+ authorName
187
+ ) }
162
188
  </p>
163
189
  { showBio && (
164
190
  <p
@@ -29,6 +29,12 @@ function render_block_core_post_author( $attributes, $content, $block ) {
29
29
  $attributes['avatarSize']
30
30
  ) : null;
31
31
 
32
+ $link = get_author_posts_url( $author_id );
33
+ $author_name = get_the_author_meta( 'display_name', $author_id );
34
+ if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
35
+ $author_name = sprintf( '<a href="%1s" target="%2s">%2s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
36
+ }
37
+
32
38
  $byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
33
39
  $classes = array_merge(
34
40
  isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(),
@@ -41,7 +47,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
41
47
  ( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
42
48
  '<div class="wp-block-post-author__content">' .
43
49
  ( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . wp_kses_post( $byline ) . '</p>' : '' ) .
44
- '<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
50
+ '<p class="wp-block-post-author__name">' . $author_name . '</p>' .
45
51
  ( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
46
52
  '</div>' .
47
53
  '</div>';
@@ -13,18 +13,17 @@ import {
13
13
  __experimentalGetElementClassName,
14
14
  } from '@wordpress/block-editor';
15
15
  import { Button } from '@wordpress/components';
16
- import { useDisabled, useInstanceId } from '@wordpress/compose';
16
+ import { useInstanceId } from '@wordpress/compose';
17
17
  import { useEntityProp, store as coreStore } from '@wordpress/core-data';
18
18
  import { useSelect } from '@wordpress/data';
19
19
 
20
20
  const CommentsFormPlaceholder = () => {
21
- const disabledFormRef = useDisabled();
22
21
  const instanceId = useInstanceId( CommentsFormPlaceholder );
23
22
 
24
23
  return (
25
24
  <div className="comment-respond">
26
25
  <h3 className="comment-reply-title">{ __( 'Leave a Reply' ) }</h3>
27
- <form noValidate className="comment-form" ref={ disabledFormRef }>
26
+ <form noValidate className="comment-form" inert="true">
28
27
  <p>
29
28
  <label htmlFor={ `comment-${ instanceId }` }>
30
29
  { __( 'Comment' ) }
@@ -62,7 +62,7 @@
62
62
  "color": true,
63
63
  "radius": true,
64
64
  "width": true,
65
- "__experimentalSelector": "img, .block-editor-media-placeholder",
65
+ "__experimentalSelector": "img, .block-editor-media-placeholder, .wp-block-post-featured-image__overlay",
66
66
  "__experimentalSkipSerialization": true,
67
67
  "__experimentalDefaultControls": {
68
68
  "color": true,
@@ -6,87 +6,94 @@
6
6
  backdrop-filter: none; // Removes background blur so the overlay's actual color is visible.
7
7
  }
8
8
 
9
- &.wp-block-post-featured-image {
10
- // Style the placeholder.
11
- .wp-block-post-featured-image__placeholder,
12
- .components-placeholder {
13
- justify-content: center;
14
- align-items: center;
15
- padding: 0;
9
+ // Style the placeholder.
10
+ .wp-block-post-featured-image__placeholder,
11
+ .components-placeholder {
12
+ justify-content: center;
13
+ align-items: center;
14
+ padding: 0;
16
15
 
17
- // Hide the upload button, as it's also available in the media library.
18
- .components-form-file-upload {
19
- display: none;
20
- }
16
+ // Hide the upload button, as it's also available in the media library.
17
+ .components-form-file-upload {
18
+ display: none;
19
+ }
21
20
 
22
- // Style the upload button.
23
- .components-button.components-button {
24
- padding: 0;
25
- display: flex;
26
- justify-content: center;
27
- align-items: center;
28
- width: $grid-unit-60;
29
- height: $grid-unit-60;
30
- border-radius: 50%;
31
- position: relative;
32
- background: var(--wp-admin-theme-color);
33
- border-color: var(--wp-admin-theme-color);
34
- border-style: solid;
35
- color: $white;
21
+ // Style the upload button.
22
+ .components-button {
23
+ padding: 0;
24
+ display: flex;
25
+ justify-content: center;
26
+ align-items: center;
27
+ width: $grid-unit-60;
28
+ height: $grid-unit-60;
29
+ border-radius: 50%;
30
+ position: relative;
31
+ background: var(--wp-admin-theme-color);
32
+ border-color: var(--wp-admin-theme-color);
33
+ border-style: solid;
34
+ color: $white;
36
35
 
37
- > svg {
38
- color: inherit;
39
- }
36
+ > svg {
37
+ color: inherit;
40
38
  }
39
+ }
41
40
 
42
- // Show default placeholder height when not resized.
43
- min-height: 200px;
44
-
45
- // The following override the default placeholder styles that remove
46
- // its border so that a user selection for border color or width displays
47
- // a visual border.
48
- &:where(.has-border-color) {
49
- border-style: solid;
50
- }
51
- &:where([style*="border-top-color"]) {
52
- border-top-style: solid;
53
- }
54
- &:where([style*="border-right-color"]) {
55
- border-right-style: solid;
56
- }
57
- &:where([style*="border-bottom-color"]) {
58
- border-bottom-style: solid;
59
- }
60
- &:where([style*="border-left-color"]) {
61
- border-left-style: solid;
62
- }
41
+ // Show default placeholder height when not resized.
42
+ min-height: 200px;
43
+ }
63
44
 
64
- &:where([style*="border-width"]) {
65
- border-style: solid;
66
- }
67
- &:where([style*="border-top-width"]) {
68
- border-top-style: solid;
69
- }
70
- &:where([style*="border-right-width"]) {
71
- border-right-style: solid;
72
- }
73
- &:where([style*="border-bottom-width"]) {
74
- border-bottom-style: solid;
75
- }
76
- &:where([style*="border-left-width"]) {
77
- border-left-style: solid;
78
- }
45
+ // The following override the default placeholder styles that remove
46
+ // its border so that a user selection for border color or width displays
47
+ // a visual border. They also override the `img { border: none; }` applied
48
+ // by core.
49
+ .wp-block-post-featured-image__placeholder,
50
+ .components-placeholder,
51
+ img {
52
+ // The following is required to overcome WP Core applying styles that clear
53
+ // img borders with a higher specificity than those added by the border
54
+ // block support to provide a default border-style of solid when a border
55
+ // color or width has been set.
56
+ &:where(.has-border-color) {
57
+ border-style: solid;
58
+ }
59
+ &:where([style*="border-top-color"]) {
60
+ border-top-style: solid;
61
+ }
62
+ &:where([style*="border-right-color"]) {
63
+ border-right-style: solid;
64
+ }
65
+ &:where([style*="border-bottom-color"]) {
66
+ border-bottom-style: solid;
67
+ }
68
+ &:where([style*="border-left-color"]) {
69
+ border-left-style: solid;
79
70
  }
80
71
 
81
- // Provide a minimum size for the placeholder when resized.
82
- // Note, this should be as small as we can afford it, and exists only
83
- // to ensure there's room for the upload button.
84
- &[style*="height"] .components-placeholder {
85
- min-height: $grid-unit-60;
86
- min-width: $grid-unit-60;
87
- height: 100%;
88
- width: 100%;
72
+ &:where([style*="border-width"]) {
73
+ border-style: solid;
74
+ }
75
+ &:where([style*="border-top-width"]) {
76
+ border-top-style: solid;
77
+ }
78
+ &:where([style*="border-right-width"]) {
79
+ border-right-style: solid;
89
80
  }
81
+ &:where([style*="border-bottom-width"]) {
82
+ border-bottom-style: solid;
83
+ }
84
+ &:where([style*="border-left-width"]) {
85
+ border-left-style: solid;
86
+ }
87
+ }
88
+
89
+ // Provide a minimum size for the placeholder when resized.
90
+ // Note, this should be as small as we can afford it, and exists only
91
+ // to ensure there's room for the upload button.
92
+ &[style*="height"] .components-placeholder {
93
+ min-height: $grid-unit-60;
94
+ min-width: $grid-unit-60;
95
+ height: 100%;
96
+ width: 100%;
90
97
  }
91
98
  }
92
99
 
@@ -76,16 +76,25 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
76
76
  $has_custom_gradient = isset( $attributes['customGradient'] ) && $attributes['customGradient'];
77
77
  $has_solid_overlay = isset( $attributes['overlayColor'] ) && $attributes['overlayColor'];
78
78
  $has_custom_overlay = isset( $attributes['customOverlayColor'] ) && $attributes['customOverlayColor'];
79
- $class_names = array(
80
- 'wp-block-post-featured-image__overlay',
81
- );
82
- $styles_properties = array();
79
+ $class_names = array( 'wp-block-post-featured-image__overlay' );
80
+ $styles = array();
83
81
 
84
82
  if ( ! $has_dim_background ) {
85
83
  return '';
86
84
  }
87
85
 
88
- // Generate required classes for the element.
86
+ // Apply border classes and styles.
87
+ $border_attributes = get_block_core_post_featured_image_border_attributes( $attributes );
88
+
89
+ if ( ! empty( $border_attributes['class'] ) ) {
90
+ $class_names[] = $border_attributes['class'];
91
+ }
92
+
93
+ if ( ! empty( $border_attributes['style'] ) ) {
94
+ $styles[] = $border_attributes['style'];
95
+ }
96
+
97
+ // Apply overlay and gradient classes.
89
98
  if ( $has_dim_background ) {
90
99
  $class_names[] = 'has-background-dim';
91
100
  $class_names[] = "has-background-dim-{$attributes['dimRatio']}";
@@ -103,35 +112,20 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
103
112
  $class_names[] = "has-{$attributes['gradient']}-gradient-background";
104
113
  }
105
114
 
106
- // Generate required CSS properties and their values.
107
- if ( ! empty( $attributes['style']['border']['radius'] ) ) {
108
- $styles_properties['border-radius'] = $attributes['style']['border']['radius'];
109
- }
110
-
111
- if ( ! empty( $attributes['style']['border']['width'] ) ) {
112
- $styles_properties['border-width'] = $attributes['style']['border']['width'];
113
- }
114
-
115
+ // Apply background styles.
115
116
  if ( $has_custom_gradient ) {
116
- $styles_properties['background-image'] = $attributes['customGradient'];
117
+ $styles[] = sprintf( 'background-image: %s;', $attributes['customGradient'] );
117
118
  }
118
119
 
119
120
  if ( $has_custom_overlay ) {
120
- $styles_properties['background-color'] = $attributes['customOverlayColor'];
121
- }
122
-
123
- $styles = '';
124
-
125
- foreach ( $styles_properties as $style_attribute => $style_attribute_value ) {
126
- $styles .= "{$style_attribute}: $style_attribute_value; ";
121
+ $styles[] = sprintf( 'background-color: %s;', $attributes['customOverlayColor'] );
127
122
  }
128
123
 
129
124
  return sprintf(
130
125
  '<span class="%s" style="%s" aria-hidden="true"></span>',
131
126
  esc_attr( implode( ' ', $class_names ) ),
132
- esc_attr( trim( $styles ) )
127
+ esc_attr( safecss_filter_attr( implode( ' ', $styles ) ) )
133
128
  );
134
-
135
129
  }
136
130
 
137
131
  /**
@@ -47,20 +47,23 @@ const Overlay = ( {
47
47
 
48
48
  return (
49
49
  <>
50
- <span
51
- aria-hidden="true"
52
- className={ classnames(
53
- 'wp-block-post-featured-image__overlay',
54
- dimRatioToClass( dimRatio ),
55
- {
56
- [ overlayColor.class ]: overlayColor.class,
57
- 'has-background-dim': dimRatio !== undefined,
58
- 'has-background-gradient': gradientValue,
59
- [ gradientClass ]: gradientClass,
60
- }
61
- ) }
62
- style={ overlayStyles }
63
- />
50
+ { !! dimRatio && (
51
+ <span
52
+ aria-hidden="true"
53
+ className={ classnames(
54
+ 'wp-block-post-featured-image__overlay',
55
+ dimRatioToClass( dimRatio ),
56
+ {
57
+ [ overlayColor.class ]: overlayColor.class,
58
+ 'has-background-dim': dimRatio !== undefined,
59
+ 'has-background-gradient': gradientValue,
60
+ [ gradientClass ]: gradientClass,
61
+ },
62
+ borderProps.className
63
+ ) }
64
+ style={ overlayStyles }
65
+ />
66
+ ) }
64
67
  <InspectorControls __experimentalGroup="color">
65
68
  <ColorGradientSettingsDropdown
66
69
  __experimentalHasMultipleOrigins
@@ -38,6 +38,10 @@
38
38
  "link": true
39
39
  }
40
40
  },
41
+ "spacing": {
42
+ "margin": true,
43
+ "padding": true
44
+ },
41
45
  "typography": {
42
46
  "fontSize": true,
43
47
  "lineHeight": true,
@@ -1,3 +1,8 @@
1
- .wp-block-post-terms__separator {
2
- white-space: pre-wrap;
1
+ .wp-block-post-terms {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
4
+
5
+ .wp-block-post-terms__separator {
6
+ white-space: pre-wrap;
7
+ }
3
8
  }
@@ -71,6 +71,7 @@ function AuthorControl( { value, onChange } ) {
71
71
  value={ sanitizedValue }
72
72
  suggestions={ authorsInfo.names }
73
73
  onChange={ onAuthorChange }
74
+ __experimentalShowHowTo={ false }
74
75
  />
75
76
  );
76
77
  }
@@ -22,13 +22,14 @@ import { useEffect, useState, useCallback } from '@wordpress/element';
22
22
  import OrderControl from './order-control';
23
23
  import AuthorControl from './author-control';
24
24
  import ParentControl from './parent-control';
25
- import { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';
25
+ import { TaxonomyControls } from './taxonomy-controls';
26
26
  import StickyControl from './sticky-control';
27
27
  import {
28
28
  usePostTypes,
29
29
  useIsPostTypeHierarchical,
30
30
  useAllowedControls,
31
31
  isControlAllowed,
32
+ useTaxonomies,
32
33
  } from '../../utils';
33
34
 
34
35
  export default function QueryInspectorControls( {
@@ -50,7 +51,7 @@ export default function QueryInspectorControls( {
50
51
  const allowedControls = useAllowedControls( attributes );
51
52
  const [ showSticky, setShowSticky ] = useState( postType === 'post' );
52
53
  const { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();
53
- const taxonomiesInfo = useTaxonomiesInfo( postType );
54
+ const taxonomies = useTaxonomies( postType );
54
55
  const isPostTypeHierarchical = useIsPostTypeHierarchical( postType );
55
56
  useEffect( () => {
56
57
  setShowSticky( postType === 'post' );
@@ -192,7 +193,7 @@ export default function QueryInspectorControls( {
192
193
  setQuerySearch( '' );
193
194
  } }
194
195
  >
195
- { !! taxonomiesInfo?.length &&
196
+ { !! taxonomies?.length &&
196
197
  isControlAllowed( allowedControls, 'taxQuery' ) && (
197
198
  <ToolsPanelItem
198
199
  label={ __( 'Taxonomies' ) }
@@ -237,10 +238,7 @@ export default function QueryInspectorControls( {
237
238
  </ToolsPanelItem>
238
239
  ) }
239
240
  { isPostTypeHierarchical &&
240
- ! isControlAllowed(
241
- allowedControls,
242
- 'parents'
243
- ) && (
241
+ isControlAllowed( allowedControls, 'parents' ) && (
244
242
  <ToolsPanelItem
245
243
  hasValue={ () => !! parents?.length }
246
244
  label={ __( 'Parents' ) }
@@ -125,6 +125,7 @@ function ParentControl( { parents, postType, onChange } ) {
125
125
  onInputChange={ debouncedSearch }
126
126
  suggestions={ suggestions }
127
127
  onChange={ onParentChange }
128
+ __experimentalShowHowTo={ false }
128
129
  />
129
130
  );
130
131
  }