@wordpress/block-library 7.10.0 → 7.11.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 (374) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/edit.js +2 -1
  3. package/build/button/edit.js.map +1 -1
  4. package/build/buttons/edit.js +1 -1
  5. package/build/buttons/edit.js.map +1 -1
  6. package/build/columns/edit.native.js +1 -1
  7. package/build/columns/edit.native.js.map +1 -1
  8. package/build/comments/edit/comments-legacy.js +73 -0
  9. package/build/comments/edit/comments-legacy.js.map +1 -0
  10. package/build/comments/{edit.js → edit/index.js} +17 -38
  11. package/build/comments/edit/index.js.map +1 -0
  12. package/build/comments/edit/placeholder.js +117 -0
  13. package/build/comments/edit/placeholder.js.map +1 -0
  14. package/build/comments/edit/template.js +39 -0
  15. package/build/comments/edit/template.js.map +1 -0
  16. package/build/comments/index.js +6 -1
  17. package/build/comments/index.js.map +1 -1
  18. package/build/comments/save.js +12 -4
  19. package/build/comments/save.js.map +1 -1
  20. package/build/cover/transforms.js +3 -2
  21. package/build/cover/transforms.js.map +1 -1
  22. package/build/embed/embed-placeholder.native.js +1 -3
  23. package/build/embed/embed-placeholder.native.js.map +1 -1
  24. package/build/gallery/edit.js +2 -2
  25. package/build/gallery/edit.js.map +1 -1
  26. package/build/gallery/use-get-media.native.js +59 -0
  27. package/build/gallery/use-get-media.native.js.map +1 -0
  28. package/build/group/index.js +1 -0
  29. package/build/group/index.js.map +1 -1
  30. package/build/group/variations.js +1 -1
  31. package/build/group/variations.js.map +1 -1
  32. package/build/image/deprecated.js +77 -9
  33. package/build/image/deprecated.js.map +1 -1
  34. package/build/image/edit.js +3 -1
  35. package/build/image/edit.js.map +1 -1
  36. package/build/image/edit.native.js +18 -8
  37. package/build/image/edit.native.js.map +1 -1
  38. package/build/image/image.js +27 -20
  39. package/build/image/image.js.map +1 -1
  40. package/build/image/index.js +7 -1
  41. package/build/image/index.js.map +1 -1
  42. package/build/image/save.js +8 -2
  43. package/build/image/save.js.map +1 -1
  44. package/build/index.js +1 -3
  45. package/build/index.js.map +1 -1
  46. package/build/index.native.js +3 -13
  47. package/build/index.native.js.map +1 -1
  48. package/build/list/transforms.js +4 -63
  49. package/build/list/transforms.js.map +1 -1
  50. package/build/list/v2/transforms.js +0 -27
  51. package/build/list/v2/transforms.js.map +1 -1
  52. package/build/list-item/edit.js +14 -9
  53. package/build/list-item/edit.js.map +1 -1
  54. package/build/list-item/hooks/index.js +8 -8
  55. package/build/list-item/hooks/index.js.map +1 -1
  56. package/build/list-item/hooks/use-merge.js +174 -0
  57. package/build/list-item/hooks/use-merge.js.map +1 -0
  58. package/build/list-item/hooks/use-outdent-list-item.js +86 -50
  59. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  60. package/build/list-item/utils.js +125 -1
  61. package/build/list-item/utils.js.map +1 -1
  62. package/build/media-text/deprecated.js +134 -7
  63. package/build/media-text/deprecated.js.map +1 -1
  64. package/build/media-text/edit.js +2 -2
  65. package/build/media-text/edit.js.map +1 -1
  66. package/build/media-text/save.js +13 -0
  67. package/build/media-text/save.js.map +1 -1
  68. package/build/more/save.js +1 -7
  69. package/build/more/save.js.map +1 -1
  70. package/build/navigation-link/edit.js +5 -4
  71. package/build/navigation-link/edit.js.map +1 -1
  72. package/build/navigation-submenu/edit.js +2 -1
  73. package/build/navigation-submenu/edit.js.map +1 -1
  74. package/build/page-list/edit.js +8 -1
  75. package/build/page-list/edit.js.map +1 -1
  76. package/build/paragraph/edit.js +7 -11
  77. package/build/paragraph/edit.js.map +1 -1
  78. package/build/post-comments-form/edit.js +4 -45
  79. package/build/post-comments-form/edit.js.map +1 -1
  80. package/build/post-comments-form/form.js +47 -3
  81. package/build/post-comments-form/form.js.map +1 -1
  82. package/build/post-terms/edit.js +3 -2
  83. package/build/post-terms/edit.js.map +1 -1
  84. package/build/query-no-results/edit.js +1 -1
  85. package/build/query-no-results/edit.js.map +1 -1
  86. package/build/query-pagination-next/edit.js +2 -1
  87. package/build/query-pagination-next/edit.js.map +1 -1
  88. package/build/query-pagination-previous/edit.js +2 -1
  89. package/build/query-pagination-previous/edit.js.map +1 -1
  90. package/build/quote/deprecated.js +168 -36
  91. package/build/quote/deprecated.js.map +1 -1
  92. package/build/quote/edit.js +76 -39
  93. package/build/quote/edit.js.map +1 -1
  94. package/build/quote/index.js +9 -45
  95. package/build/quote/index.js.map +1 -1
  96. package/build/quote/save.js +1 -5
  97. package/build/quote/save.js.map +1 -1
  98. package/build/quote/transforms.js +110 -158
  99. package/build/quote/transforms.js.map +1 -1
  100. package/build/social-link/icons/index.js +13 -0
  101. package/build/social-link/icons/index.js.map +1 -1
  102. package/build/social-link/icons/whatsapp.js +25 -0
  103. package/build/social-link/icons/whatsapp.js.map +1 -0
  104. package/build/social-link/variations.js +7 -0
  105. package/build/social-link/variations.js.map +1 -1
  106. package/build/template-part/edit/index.js +17 -8
  107. package/build/template-part/edit/index.js.map +1 -1
  108. package/build/template-part/edit/selection-modal.js +33 -13
  109. package/build/template-part/edit/selection-modal.js.map +1 -1
  110. package/build/template-part/edit/utils/search.js +94 -0
  111. package/build/template-part/edit/utils/search.js.map +1 -0
  112. package/build-module/button/edit.js +2 -1
  113. package/build-module/button/edit.js.map +1 -1
  114. package/build-module/buttons/edit.js +2 -2
  115. package/build-module/buttons/edit.js.map +1 -1
  116. package/build-module/columns/edit.native.js +2 -2
  117. package/build-module/columns/edit.native.js.map +1 -1
  118. package/build-module/comments/edit/comments-legacy.js +59 -0
  119. package/build-module/comments/edit/comments-legacy.js.map +1 -0
  120. package/build-module/comments/edit/index.js +37 -0
  121. package/build-module/comments/edit/index.js.map +1 -0
  122. package/build-module/comments/edit/placeholder.js +102 -0
  123. package/build-module/comments/edit/placeholder.js.map +1 -0
  124. package/build-module/comments/edit/template.js +32 -0
  125. package/build-module/comments/edit/template.js.map +1 -0
  126. package/build-module/comments/index.js +6 -1
  127. package/build-module/comments/index.js.map +1 -1
  128. package/build-module/comments/save.js +9 -4
  129. package/build-module/comments/save.js.map +1 -1
  130. package/build-module/cover/transforms.js +3 -2
  131. package/build-module/cover/transforms.js.map +1 -1
  132. package/build-module/embed/embed-placeholder.native.js +1 -2
  133. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  134. package/build-module/gallery/edit.js +2 -2
  135. package/build-module/gallery/edit.js.map +1 -1
  136. package/build-module/gallery/use-get-media.native.js +50 -0
  137. package/build-module/gallery/use-get-media.native.js.map +1 -0
  138. package/build-module/group/index.js +1 -0
  139. package/build-module/group/index.js.map +1 -1
  140. package/build-module/group/variations.js +2 -2
  141. package/build-module/group/variations.js.map +1 -1
  142. package/build-module/image/deprecated.js +77 -9
  143. package/build-module/image/deprecated.js.map +1 -1
  144. package/build-module/image/edit.js +5 -3
  145. package/build-module/image/edit.js.map +1 -1
  146. package/build-module/image/edit.native.js +18 -8
  147. package/build-module/image/edit.native.js.map +1 -1
  148. package/build-module/image/image.js +29 -22
  149. package/build-module/image/image.js.map +1 -1
  150. package/build-module/image/index.js +7 -1
  151. package/build-module/image/index.js.map +1 -1
  152. package/build-module/image/save.js +9 -3
  153. package/build-module/image/save.js.map +1 -1
  154. package/build-module/index.js +1 -2
  155. package/build-module/index.js.map +1 -1
  156. package/build-module/index.native.js +3 -13
  157. package/build-module/index.native.js.map +1 -1
  158. package/build-module/list/transforms.js +4 -63
  159. package/build-module/list/transforms.js.map +1 -1
  160. package/build-module/list/v2/transforms.js +2 -29
  161. package/build-module/list/v2/transforms.js.map +1 -1
  162. package/build-module/list-item/edit.js +14 -10
  163. package/build-module/list-item/edit.js.map +1 -1
  164. package/build-module/list-item/hooks/index.js +1 -1
  165. package/build-module/list-item/hooks/index.js.map +1 -1
  166. package/build-module/list-item/hooks/use-merge.js +160 -0
  167. package/build-module/list-item/hooks/use-merge.js.map +1 -0
  168. package/build-module/list-item/hooks/use-outdent-list-item.js +82 -46
  169. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  170. package/build-module/list-item/utils.js +123 -2
  171. package/build-module/list-item/utils.js.map +1 -1
  172. package/build-module/media-text/deprecated.js +134 -8
  173. package/build-module/media-text/deprecated.js.map +1 -1
  174. package/build-module/media-text/edit.js +2 -2
  175. package/build-module/media-text/edit.js.map +1 -1
  176. package/build-module/media-text/save.js +13 -0
  177. package/build-module/media-text/save.js.map +1 -1
  178. package/build-module/more/save.js +1 -6
  179. package/build-module/more/save.js.map +1 -1
  180. package/build-module/navigation-link/edit.js +5 -4
  181. package/build-module/navigation-link/edit.js.map +1 -1
  182. package/build-module/navigation-submenu/edit.js +2 -1
  183. package/build-module/navigation-submenu/edit.js.map +1 -1
  184. package/build-module/page-list/edit.js +8 -1
  185. package/build-module/page-list/edit.js.map +1 -1
  186. package/build-module/paragraph/edit.js +8 -12
  187. package/build-module/paragraph/edit.js.map +1 -1
  188. package/build-module/post-comments-form/edit.js +5 -42
  189. package/build-module/post-comments-form/edit.js.map +1 -1
  190. package/build-module/post-comments-form/form.js +46 -5
  191. package/build-module/post-comments-form/form.js.map +1 -1
  192. package/build-module/post-terms/edit.js +3 -2
  193. package/build-module/post-terms/edit.js.map +1 -1
  194. package/build-module/query-no-results/edit.js +2 -2
  195. package/build-module/query-no-results/edit.js.map +1 -1
  196. package/build-module/query-pagination-next/edit.js +2 -1
  197. package/build-module/query-pagination-next/edit.js.map +1 -1
  198. package/build-module/query-pagination-previous/edit.js +2 -1
  199. package/build-module/query-pagination-previous/edit.js.map +1 -1
  200. package/build-module/quote/deprecated.js +162 -36
  201. package/build-module/quote/deprecated.js.map +1 -1
  202. package/build-module/quote/edit.js +77 -43
  203. package/build-module/quote/edit.js.map +1 -1
  204. package/build-module/quote/index.js +9 -39
  205. package/build-module/quote/index.js.map +1 -1
  206. package/build-module/quote/save.js +4 -8
  207. package/build-module/quote/save.js.map +1 -1
  208. package/build-module/quote/transforms.js +111 -158
  209. package/build-module/quote/transforms.js.map +1 -1
  210. package/build-module/social-link/icons/index.js +1 -0
  211. package/build-module/social-link/icons/index.js.map +1 -1
  212. package/build-module/social-link/icons/whatsapp.js +15 -0
  213. package/build-module/social-link/icons/whatsapp.js.map +1 -0
  214. package/build-module/social-link/variations.js +8 -1
  215. package/build-module/social-link/variations.js.map +1 -1
  216. package/build-module/template-part/edit/index.js +20 -11
  217. package/build-module/template-part/edit/index.js.map +1 -1
  218. package/build-module/template-part/edit/selection-modal.js +33 -15
  219. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  220. package/build-module/template-part/edit/utils/search.js +84 -0
  221. package/build-module/template-part/edit/utils/search.js.map +1 -0
  222. package/build-style/button/style-rtl.css +1 -1
  223. package/build-style/button/style.css +1 -1
  224. package/build-style/comments/editor-rtl.css +122 -0
  225. package/build-style/comments/editor.css +122 -0
  226. package/build-style/{post-comments → comments}/style-rtl.css +1 -0
  227. package/build-style/{post-comments → comments}/style.css +1 -0
  228. package/build-style/common-rtl.css +7 -0
  229. package/build-style/common.css +7 -0
  230. package/build-style/cover/style-rtl.css +2 -2
  231. package/build-style/cover/style.css +2 -2
  232. package/build-style/{post-comments/editor.css → editor-elements-rtl.css} +8 -2
  233. package/build-style/{post-comments/editor-rtl.css → editor-elements.css} +8 -2
  234. package/build-style/editor-rtl.css +151 -10
  235. package/build-style/editor.css +151 -10
  236. package/build-style/gallery/style-rtl.css +7 -2
  237. package/build-style/gallery/style.css +7 -2
  238. package/build-style/image/editor-rtl.css +4 -3
  239. package/build-style/image/editor.css +4 -3
  240. package/build-style/image/style-rtl.css +33 -3
  241. package/build-style/image/style.css +33 -3
  242. package/build-style/post-comments-form/style-rtl.css +0 -1
  243. package/build-style/post-comments-form/style.css +0 -1
  244. package/build-style/social-link/editor-rtl.css +1 -0
  245. package/build-style/social-link/editor.css +1 -0
  246. package/build-style/social-links/style-rtl.css +8 -0
  247. package/build-style/social-links/style.css +8 -0
  248. package/build-style/style-rtl.css +170 -127
  249. package/build-style/style.css +170 -127
  250. package/build-style/template-part/editor-rtl.css +14 -3
  251. package/build-style/template-part/editor.css +14 -3
  252. package/package.json +28 -28
  253. package/src/button/edit.js +1 -0
  254. package/src/button/style.scss +3 -1
  255. package/src/buttons/edit.js +1 -5
  256. package/src/columns/edit.native.js +2 -2
  257. package/src/comments/block.json +6 -1
  258. package/src/comments/edit/comments-legacy.js +71 -0
  259. package/src/comments/edit/index.js +35 -0
  260. package/src/comments/edit/placeholder.js +124 -0
  261. package/src/comments/{edit.js → edit/template.js} +1 -28
  262. package/src/comments/editor.scss +9 -0
  263. package/src/comments/index.php +219 -0
  264. package/src/comments/save.js +8 -7
  265. package/src/{post-comments → comments}/style.scss +7 -0
  266. package/src/common.scss +2 -0
  267. package/src/cover/style.scss +2 -2
  268. package/src/cover/transforms.js +2 -2
  269. package/src/editor-elements.scss +10 -0
  270. package/src/editor.scss +2 -1
  271. package/src/embed/embed-placeholder.native.js +2 -3
  272. package/src/gallery/edit.js +4 -2
  273. package/src/gallery/style.scss +10 -1
  274. package/src/gallery/use-get-media.native.js +44 -0
  275. package/src/group/block.json +1 -0
  276. package/src/group/variations.js +2 -2
  277. package/src/image/block.json +7 -1
  278. package/src/image/deprecated.js +86 -0
  279. package/src/image/edit.js +6 -1
  280. package/src/image/edit.native.js +18 -7
  281. package/src/image/editor.scss +9 -4
  282. package/src/image/image.js +26 -16
  283. package/src/image/save.js +10 -1
  284. package/src/image/style.scss +39 -3
  285. package/src/index.js +0 -2
  286. package/src/index.native.js +2 -11
  287. package/src/list/transforms.js +0 -47
  288. package/src/list/v2/transforms.js +2 -40
  289. package/src/list-item/edit.js +10 -12
  290. package/src/list-item/hooks/index.js +1 -1
  291. package/src/list-item/hooks/use-merge.js +141 -0
  292. package/src/list-item/hooks/use-outdent-list-item.js +72 -74
  293. package/src/list-item/utils.js +27 -3
  294. package/src/media-text/deprecated.js +148 -1
  295. package/src/media-text/edit.js +2 -1
  296. package/src/media-text/save.js +18 -0
  297. package/src/more/save.js +3 -6
  298. package/src/navigation-link/edit.js +4 -3
  299. package/src/navigation-submenu/edit.js +1 -0
  300. package/src/page-list/edit.js +9 -0
  301. package/src/paragraph/edit.js +8 -14
  302. package/src/post-comments-form/edit.js +2 -71
  303. package/src/post-comments-form/form.js +80 -5
  304. package/src/post-comments-form/index.php +1 -1
  305. package/src/post-comments-form/style.scss +0 -1
  306. package/src/post-terms/edit.js +3 -2
  307. package/src/query-no-results/edit.js +2 -5
  308. package/src/query-pagination-next/edit.js +1 -0
  309. package/src/query-pagination-previous/edit.js +1 -0
  310. package/src/quote/deprecated.js +213 -99
  311. package/src/quote/edit.js +77 -52
  312. package/src/quote/index.js +10 -33
  313. package/src/quote/save.js +5 -5
  314. package/src/quote/{v2/test → test}/migrate.js +2 -7
  315. package/src/quote/transforms.js +117 -147
  316. package/src/social-link/editor.scss +3 -0
  317. package/src/social-link/icons/index.js +1 -0
  318. package/src/social-link/icons/whatsapp.js +10 -0
  319. package/src/social-link/index.php +4 -0
  320. package/src/social-link/socials-with-bg.scss +5 -0
  321. package/src/social-link/socials-without-bg.scss +5 -0
  322. package/src/social-link/variations.js +7 -0
  323. package/src/style.scss +1 -2
  324. package/src/template-part/edit/index.js +37 -24
  325. package/src/template-part/edit/selection-modal.js +68 -40
  326. package/src/template-part/edit/utils/search.js +76 -0
  327. package/src/template-part/editor.scss +21 -9
  328. package/src/template-part/index.php +56 -2
  329. package/build/comments/edit.js.map +0 -1
  330. package/build/list-item/hooks/use-backspace.js +0 -59
  331. package/build/list-item/hooks/use-backspace.js.map +0 -1
  332. package/build/post-comments/edit.js +0 -184
  333. package/build/post-comments/edit.js.map +0 -1
  334. package/build/post-comments/index.js +0 -72
  335. package/build/post-comments/index.js.map +0 -1
  336. package/build/quote/v2/deprecated.js +0 -133
  337. package/build/quote/v2/deprecated.js.map +0 -1
  338. package/build/quote/v2/edit.js +0 -139
  339. package/build/quote/v2/edit.js.map +0 -1
  340. package/build/quote/v2/index.js +0 -49
  341. package/build/quote/v2/index.js.map +0 -1
  342. package/build/quote/v2/save.js +0 -43
  343. package/build/quote/v2/save.js.map +0 -1
  344. package/build/quote/v2/transforms.js +0 -156
  345. package/build/quote/v2/transforms.js.map +0 -1
  346. package/build-module/comments/edit.js +0 -59
  347. package/build-module/comments/edit.js.map +0 -1
  348. package/build-module/list-item/hooks/use-backspace.js +0 -44
  349. package/build-module/list-item/hooks/use-backspace.js.map +0 -1
  350. package/build-module/post-comments/edit.js +0 -171
  351. package/build-module/post-comments/edit.js.map +0 -1
  352. package/build-module/post-comments/index.js +0 -59
  353. package/build-module/post-comments/index.js.map +0 -1
  354. package/build-module/quote/v2/deprecated.js +0 -116
  355. package/build-module/quote/v2/deprecated.js.map +0 -1
  356. package/build-module/quote/v2/edit.js +0 -122
  357. package/build-module/quote/v2/edit.js.map +0 -1
  358. package/build-module/quote/v2/index.js +0 -33
  359. package/build-module/quote/v2/index.js.map +0 -1
  360. package/build-module/quote/v2/save.js +0 -30
  361. package/build-module/quote/v2/save.js.map +0 -1
  362. package/build-module/quote/v2/transforms.js +0 -147
  363. package/build-module/quote/v2/transforms.js.map +0 -1
  364. package/src/list-item/hooks/use-backspace.js +0 -51
  365. package/src/post-comments/block.json +0 -45
  366. package/src/post-comments/edit.js +0 -247
  367. package/src/post-comments/editor.scss +0 -3
  368. package/src/post-comments/index.js +0 -18
  369. package/src/post-comments/index.php +0 -87
  370. package/src/quote/v2/deprecated.js +0 -107
  371. package/src/quote/v2/edit.js +0 -139
  372. package/src/quote/v2/index.js +0 -36
  373. package/src/quote/v2/save.js +0 -26
  374. package/src/quote/v2/transforms.js +0 -155
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import CommentsInspectorControls from './comments-inspector-controls';
10
+ import CommentsLegacy from './comments-legacy';
11
+ import TEMPLATE from './template';
12
+
13
+ export default function CommentsEdit( props ) {
14
+ const { attributes, setAttributes } = props;
15
+ const { tagName: TagName, legacy } = attributes;
16
+
17
+ const blockProps = useBlockProps();
18
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
19
+ template: TEMPLATE,
20
+ } );
21
+
22
+ if ( legacy ) {
23
+ return <CommentsLegacy { ...props } />;
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <CommentsInspectorControls
29
+ attributes={ attributes }
30
+ setAttributes={ setAttributes }
31
+ />
32
+ <TagName { ...innerBlocksProps } />
33
+ </>
34
+ );
35
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as blockEditorStore } from '@wordpress/block-editor';
5
+ import { __, sprintf } from '@wordpress/i18n';
6
+ import { useSelect } from '@wordpress/data';
7
+ import { useEntityProp } from '@wordpress/core-data';
8
+ import { useDisabled } from '@wordpress/compose';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import CommentsForm from '../../post-comments-form/form';
14
+
15
+ export default function PostCommentsPlaceholder( { postType, postId } ) {
16
+ let [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );
17
+ postTitle = postTitle || __( 'Post Title' );
18
+
19
+ const { avatarURL } = useSelect(
20
+ ( select ) =>
21
+ select( blockEditorStore ).getSettings()
22
+ .__experimentalDiscussionSettings
23
+ );
24
+
25
+ const disabledRef = useDisabled();
26
+
27
+ return (
28
+ <div
29
+ className="wp-block-comments__legacy-placeholder"
30
+ ref={ disabledRef }
31
+ >
32
+ <h3>
33
+ {
34
+ /* translators: %s: Post title. */
35
+ sprintf( __( 'One response to %s' ), postTitle )
36
+ }
37
+ </h3>
38
+
39
+ <div className="navigation">
40
+ <div className="alignleft">
41
+ <a href="#top">« { __( 'Older Comments' ) }</a>
42
+ </div>
43
+ <div className="alignright">
44
+ <a href="#top">{ __( 'Newer Comments' ) } »</a>
45
+ </div>
46
+ </div>
47
+
48
+ <ol className="commentlist">
49
+ <li className="comment even thread-even depth-1">
50
+ <article className="comment-body">
51
+ <footer className="comment-meta">
52
+ <div className="comment-author vcard">
53
+ <img
54
+ alt="Commenter Avatar"
55
+ src={ avatarURL }
56
+ className="avatar avatar-32 photo"
57
+ height="32"
58
+ width="32"
59
+ loading="lazy"
60
+ />
61
+ <b className="fn">
62
+ <a href="#top" className="url">
63
+ { __( 'A WordPress Commenter' ) }
64
+ </a>
65
+ </b>{ ' ' }
66
+ <span className="says">{ __( 'says' ) }:</span>
67
+ </div>
68
+
69
+ <div className="comment-metadata">
70
+ <a href="#top">
71
+ <time dateTime="2000-01-01T00:00:00+00:00">
72
+ { __( 'January 1, 2000 at 00:00 am' ) }
73
+ </time>
74
+ </a>{ ' ' }
75
+ <span className="edit-link">
76
+ <a
77
+ className="comment-edit-link"
78
+ href="#top"
79
+ >
80
+ { __( 'Edit' ) }
81
+ </a>
82
+ </span>
83
+ </div>
84
+ </footer>
85
+
86
+ <div className="comment-content">
87
+ <p>
88
+ { __( 'Hi, this is a comment.' ) }
89
+ <br />
90
+ { __(
91
+ 'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'
92
+ ) }
93
+ <br />
94
+ { __( 'Commenter avatars come from' ) }{ ' ' }
95
+ <a href="https://gravatar.com/">Gravatar</a>.
96
+ </p>
97
+ </div>
98
+
99
+ <div className="reply">
100
+ <a
101
+ className="comment-reply-link"
102
+ href="#top"
103
+ aria-label="Reply to A WordPress Commenter"
104
+ >
105
+ { __( 'Reply' ) }
106
+ </a>
107
+ </div>
108
+ </article>
109
+ </li>
110
+ </ol>
111
+
112
+ <div className="navigation">
113
+ <div className="alignleft">
114
+ <a href="#top">« { __( 'Older Comments' ) }</a>
115
+ </div>
116
+ <div className="alignright">
117
+ <a href="#top">{ __( 'Newer Comments' ) } »</a>
118
+ </div>
119
+ </div>
120
+
121
+ <CommentsForm postId={ postId } postType={ postType } />
122
+ </div>
123
+ );
124
+ }
@@ -1,13 +1,3 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import CommentsInspectorControls from './edit/comments-inspector-controls';
10
-
11
1
  const TEMPLATE = [
12
2
  [ 'core/comments-title' ],
13
3
  [
@@ -88,21 +78,4 @@ const TEMPLATE = [
88
78
  [ 'core/post-comments-form' ],
89
79
  ];
90
80
 
91
- export default function CommentsEdit( { attributes, setAttributes } ) {
92
- const { tagName: TagName } = attributes;
93
-
94
- const blockProps = useBlockProps();
95
- const innerBlocksProps = useInnerBlocksProps( blockProps, {
96
- template: TEMPLATE,
97
- } );
98
-
99
- return (
100
- <>
101
- <CommentsInspectorControls
102
- attributes={ attributes }
103
- setAttributes={ setAttributes }
104
- />
105
- <TagName { ...innerBlocksProps } />
106
- </>
107
- );
108
- }
81
+ export default TEMPLATE;
@@ -1,3 +1,12 @@
1
+ @import "./style.scss";
2
+
1
3
  .block-library-comments-toolbar__popover .components-popover__content {
2
4
  min-width: 230px;
3
5
  }
6
+
7
+ .wp-block-comments__legacy-placeholder {
8
+ @extend .wp-block-post-comments;
9
+ * {
10
+ pointer-events: none;
11
+ }
12
+ }
@@ -0,0 +1,219 @@
1
+ <?php
2
+ /**
3
+ * Server-side rendering of the `core/comments` block.
4
+ *
5
+ * @package WordPress
6
+ */
7
+
8
+ /**
9
+ * Renders the `core/comments` block on the server.
10
+ *
11
+ * This render callback is mainly for rendering a dynamic, legacy version of
12
+ * this block (the old `core/post-comments`). It uses the `comments_template()`
13
+ * function to generate the output, in the same way as classic PHP themes.
14
+ *
15
+ * As this callback will always run during SSR, first we need to check whether
16
+ * the block is in legacy mode. If not, the HTML generated in the editor is
17
+ * returned instead.
18
+ *
19
+ * @param array $attributes Block attributes.
20
+ * @param string $content Block default content.
21
+ * @param WP_Block $block Block instance.
22
+ * @return string Returns the filtered post comments for the current post wrapped inside "p" tags.
23
+ */
24
+ function render_block_core_comments( $attributes, $content, $block ) {
25
+ global $post;
26
+
27
+ $is_legacy = 'core/post-comments' === $block->name || ! empty( $attributes['legacy'] );
28
+ if ( ! $is_legacy ) {
29
+ return $block->render( array( 'dynamic' => false ) );
30
+ }
31
+
32
+ $post_id = $block->context['postId'];
33
+ if ( ! isset( $post_id ) ) {
34
+ return '';
35
+ }
36
+
37
+ $comment_args = array(
38
+ 'post_id' => $post_id,
39
+ 'count' => true,
40
+ 'status' => 'approve',
41
+ );
42
+ // Return early if there are no comments and comments are closed.
43
+ if ( ! comments_open( $post_id ) && get_comments( $comment_args ) === 0 ) {
44
+ return '';
45
+ }
46
+
47
+ $post_before = $post;
48
+ $post = get_post( $post_id );
49
+ setup_postdata( $post );
50
+
51
+ ob_start();
52
+
53
+ /*
54
+ * There's a deprecation warning generated by WP Core.
55
+ * Ideally this deprecation is removed from Core.
56
+ * In the meantime, this removes it from the output.
57
+ */
58
+ add_filter( 'deprecated_file_trigger_error', '__return_false' );
59
+ comments_template();
60
+ remove_filter( 'deprecated_file_trigger_error', '__return_false' );
61
+
62
+ $output = ob_get_clean();
63
+ $post = $post_before;
64
+
65
+ $classnames = array();
66
+ // Adds the old class name for styles' backwards compatibility.
67
+ if ( isset( $attributes['legacy'] ) ) {
68
+ $classnames[] = 'wp-block-post-comments';
69
+ }
70
+ if ( isset( $attributes['textAlign'] ) ) {
71
+ $classnames[] = 'has-text-align-' . $attributes['textAlign'];
72
+ }
73
+
74
+ $wrapper_attributes = get_block_wrapper_attributes(
75
+ array( 'class' => implode( ' ', $classnames ) )
76
+ );
77
+
78
+ /*
79
+ * Enqueues scripts and styles required only for the legacy version. That is
80
+ * why they are not defined in `block.json`.
81
+ */
82
+ wp_enqueue_script( 'comment-reply' );
83
+ enqueue_legacy_post_comments_block_styles( $block->name );
84
+
85
+ return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output );
86
+ }
87
+
88
+ /**
89
+ * Registers the `core/comments` block on the server.
90
+ */
91
+ function register_block_core_comments() {
92
+ register_block_type_from_metadata(
93
+ __DIR__ . '/comments',
94
+ array(
95
+ 'render_callback' => 'render_block_core_comments',
96
+ 'skip_inner_blocks' => true,
97
+ )
98
+ );
99
+ }
100
+ add_action( 'init', 'register_block_core_comments' );
101
+
102
+ /**
103
+ * Use the button block classes for the form-submit button.
104
+ *
105
+ * @param array $fields The default comment form arguments.
106
+ *
107
+ * @return array Returns the modified fields.
108
+ */
109
+ function comments_block_form_defaults( $fields ) {
110
+ if ( wp_is_block_theme() ) {
111
+ $fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' ) . '" value="%4$s" />';
112
+ $fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
113
+ }
114
+
115
+ return $fields;
116
+ }
117
+ add_filter( 'comment_form_defaults', 'comments_block_form_defaults' );
118
+
119
+ /**
120
+ * Enqueues styles from the legacy `core/post-comments` block. These styles are
121
+ * required only by the block's fallback.
122
+ *
123
+ * @param string $block_name Name of the new block type.
124
+ */
125
+ function enqueue_legacy_post_comments_block_styles( $block_name ) {
126
+ static $are_styles_enqueued = false;
127
+
128
+ if ( ! $are_styles_enqueued ) {
129
+ $handles = array(
130
+ 'wp-block-post-comments',
131
+ 'wp-block-buttons',
132
+ 'wp-block-button',
133
+ );
134
+ foreach ( $handles as $handle ) {
135
+ wp_enqueue_block_style( $block_name, array( 'handle' => $handle ) );
136
+ }
137
+ $are_styles_enqueued = true;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Ensures backwards compatibility for any users running the Gutenberg plugin
143
+ * who have used Post Comments before it was merged into Comments Query Loop.
144
+ *
145
+ * The same approach was followed when core/query-loop was renamed to
146
+ * core/post-template.
147
+ *
148
+ * @see https://github.com/WordPress/gutenberg/pull/41807
149
+ * @see https://github.com/WordPress/gutenberg/pull/32514
150
+ */
151
+ function register_legacy_post_comments_block() {
152
+ $registry = WP_Block_Type_Registry::get_instance();
153
+
154
+ /*
155
+ * Remove the old `post-comments` block if it was already registered, as it
156
+ * is about to be replaced by the type defined below.
157
+ */
158
+ if ( $registry->is_registered( 'core/post-comments' ) ) {
159
+ unregister_block_type( 'core/post-comments' );
160
+ }
161
+
162
+ // Recreate the legacy block metadata.
163
+ $metadata = array(
164
+ 'name' => 'core/post-comments',
165
+ 'category' => 'theme',
166
+ 'attributes' => array(
167
+ 'textAlign' => array(
168
+ 'type' => 'string',
169
+ ),
170
+ ),
171
+ 'uses_context' => array(
172
+ 'postId',
173
+ 'postType',
174
+ ),
175
+ 'supports' => array(
176
+ 'html' => false,
177
+ 'align' => array( 'wide', 'full' ),
178
+ 'typography' => array(
179
+ 'fontSize' => true,
180
+ 'lineHeight' => true,
181
+ '__experimentalFontStyle' => true,
182
+ '__experimentalFontWeight' => true,
183
+ '__experimentalLetterSpacing' => true,
184
+ '__experimentalTextTransform' => true,
185
+ '__experimentalDefaultControls' => array(
186
+ 'fontSize' => true,
187
+ ),
188
+ ),
189
+ 'color' => array(
190
+ 'gradients' => true,
191
+ 'link' => true,
192
+ '__experimentalDefaultControls' => array(
193
+ 'background' => true,
194
+ 'text' => true,
195
+ ),
196
+ ),
197
+ 'inserter' => false,
198
+ ),
199
+ 'style' => array(
200
+ 'wp-block-post-comments',
201
+ 'wp-block-buttons',
202
+ 'wp-block-button',
203
+ ),
204
+ 'editorStyle' => 'wp-block-post-comments-editor',
205
+ 'render_callback' => 'render_block_core_comments',
206
+ 'skip_inner_blocks' => true,
207
+ );
208
+
209
+ /*
210
+ * Filters the metadata object, the same way it's done inside
211
+ * `register_block_type_from_metadata()`. This applies some default filters,
212
+ * like `_wp_multiple_block_styles`, which is required in this case because
213
+ * the block has multiple styles.
214
+ */
215
+ $metadata = apply_filters( 'block_type_metadata', $metadata );
216
+
217
+ register_block_type( 'core/post-comments', $metadata );
218
+ }
219
+ add_action( 'init', 'register_legacy_post_comments_block', 21 );
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
4
+ import { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';
5
5
 
6
- export default function CommentsSave( { attributes: { tagName: Tag } } ) {
7
- return (
8
- <Tag { ...useBlockProps.save() }>
9
- <InnerBlocks.Content />
10
- </Tag>
11
- );
6
+ export default function save( { attributes: { tagName: Tag, legacy } } ) {
7
+ const blockProps = useBlockProps.save();
8
+ const innerBlocksProps = useInnerBlocksProps.save( blockProps );
9
+
10
+ // The legacy version is dynamic (i.e. PHP rendered) and doesn't allow inner
11
+ // blocks, so nothing is saved in that case.
12
+ return legacy ? null : <Tag { ...innerBlocksProps } />;
12
13
  }
@@ -1,4 +1,6 @@
1
+ /* Styles for backwards compatibility with the legacy `post-comments` block */
1
2
  .wp-block-post-comments {
3
+
2
4
  /* utility classes */
3
5
  .alignleft {
4
6
  float: left;
@@ -7,6 +9,7 @@
7
9
  .alignright {
8
10
  float: right;
9
11
  }
12
+
10
13
  /* end utility classes */
11
14
 
12
15
  .navigation {
@@ -62,9 +65,11 @@
62
65
  .comment-meta {
63
66
  font-size: 0.875em;
64
67
  line-height: 1.5;
68
+
65
69
  b {
66
70
  font-weight: normal;
67
71
  }
72
+
68
73
  .comment-awaiting-moderation {
69
74
  margin-top: 1em;
70
75
  margin-bottom: 1em;
@@ -87,6 +92,7 @@
87
92
  }
88
93
 
89
94
  .comment-form {
95
+
90
96
  textarea,
91
97
  input:not([type="submit"]):not([type="checkbox"]) {
92
98
  display: block;
@@ -106,6 +112,7 @@
106
112
 
107
113
  .comment-reply-title {
108
114
  margin-bottom: 0;
115
+
109
116
  :where(small) {
110
117
  font-size: var(--wp--preset--font-size--medium, smaller);
111
118
  margin-left: 0.5em;
package/src/common.scss CHANGED
@@ -1,3 +1,5 @@
1
+ @import "./elements.scss";
2
+
1
3
  // The following selectors have increased specificity (using the :root prefix)
2
4
  // to assure colors take effect over another base class color, mainly to let
3
5
  // the colors override the added specificity by link states such as :hover.
@@ -1,10 +1,8 @@
1
1
  .wp-block-cover-image,
2
2
  .wp-block-cover {
3
3
  position: relative;
4
- background-size: cover;
5
4
  background-position: center center;
6
5
  min-height: 430px;
7
- width: 100%;
8
6
  display: flex;
9
7
  justify-content: center;
10
8
  align-items: center;
@@ -201,6 +199,8 @@
201
199
  video.wp-block-cover__video-background {
202
200
  &.has-parallax {
203
201
  background-attachment: fixed;
202
+ background-size: cover;
203
+ background-repeat: no-repeat;
204
204
 
205
205
  // Mobile Safari does not support fixed background attachment properly.
206
206
  // See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
@@ -206,10 +206,10 @@ const transforms = {
206
206
  {
207
207
  type: 'block',
208
208
  blocks: [ 'core/group' ],
209
- isMatch: ( { url } ) => {
209
+ isMatch: ( { url, useFeaturedImage } ) => {
210
210
  // If the Cover block uses background media, skip this transform,
211
211
  // and instead use the Group block's default transform.
212
- if ( url ) {
212
+ if ( url || useFeaturedImage ) {
213
213
  return false;
214
214
  }
215
215
  return true;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Element styles for the editor
3
+ */
4
+ .wp-element-button {
5
+ cursor: revert;
6
+
7
+ &[role="textbox"] {
8
+ cursor: text;
9
+ }
10
+ }
package/src/editor.scss CHANGED
@@ -49,9 +49,10 @@
49
49
  @import "./query-pagination/editor.scss";
50
50
  @import "./query-pagination-numbers/editor.scss";
51
51
  @import "./post-featured-image/editor.scss";
52
- @import "./post-comments/editor.scss";
53
52
  @import "./post-comments-form/editor.scss";
54
53
 
54
+ @import "./editor-elements.scss";
55
+
55
56
  :root .editor-styles-wrapper {
56
57
  @include background-colors-deprecated();
57
58
  @include foreground-colors-deprecated();
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { View, Text, TouchableWithoutFeedback } from 'react-native';
5
- import { compact } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -68,11 +67,11 @@ const EmbedPlaceholder = ( {
68
67
  },
69
68
  };
70
69
 
71
- const options = compact( [
70
+ const options = [
72
71
  cannotEmbed && errorPickerOptions.retry,
73
72
  cannotEmbed && errorPickerOptions.convertToLink,
74
73
  cannotEmbed && errorPickerOptions.editLink,
75
- ] );
74
+ ].filter( Boolean );
76
75
 
77
76
  function onPickerSelect( value ) {
78
77
  const selectedItem = options.find( ( item ) => item.value === value );
@@ -414,8 +414,10 @@ function GalleryEdit( props ) {
414
414
 
415
415
  const hasImages = !! images.length;
416
416
  const hasImageIds = hasImages && images.some( ( image ) => !! image.id );
417
- const imagesUploading = images.some(
418
- ( img ) => ! img.id && img.url?.indexOf( 'blob:' ) === 0
417
+ const imagesUploading = images.some( ( img ) =>
418
+ ! Platform.isNative
419
+ ? ! img.id && img.url?.indexOf( 'blob:' ) === 0
420
+ : img.url?.indexOf( 'file:' ) === 0
419
421
  );
420
422
 
421
423
  // MediaPlaceholder props are different between web and native hence, we provide a platform-specific set.
@@ -22,6 +22,10 @@ figure.wp-block-gallery.has-nested-images {
22
22
  position: relative;
23
23
  flex-direction: column;
24
24
  max-width: 100%;
25
+ // Prevents theme.json and global styles borders that apply to the outer
26
+ // wrapper from incorrectly enlarging gallery images to a point they
27
+ // result in a single column gallery.
28
+ box-sizing: border-box;
25
29
 
26
30
  > div,
27
31
  > a {
@@ -63,7 +67,12 @@ figure.wp-block-gallery.has-nested-images {
63
67
  }
64
68
  }
65
69
 
66
- &.is-style-rounded {
70
+ &.has-custom-border img {
71
+ box-sizing: border-box;
72
+ }
73
+
74
+ &.is-style-rounded,
75
+ &.has-custom-border {
67
76
  > div,
68
77
  > a {
69
78
  flex: 1 1 auto;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+
7
+ const EMPTY_IMAGE_MEDIA = [];
8
+
9
+ /**
10
+ * Retrieves the extended media info for each gallery image from the store. This is used to
11
+ * determine which image size options are available for the current gallery.
12
+ *
13
+ * @param {Array} innerBlockImages An array of the innerBlock images currently in the gallery.
14
+ *
15
+ * @return {Array} An array of media info options for each gallery image.
16
+ */
17
+ export default function useGetMedia( innerBlockImages ) {
18
+ return useSelect(
19
+ ( select ) => {
20
+ const imagesUploading = innerBlockImages.some(
21
+ ( { attributes } ) => attributes?.url?.indexOf( 'file:' ) === 0
22
+ );
23
+ const imageIds = innerBlockImages
24
+ .filter( ( { attributes } ) => {
25
+ const { id, url } = attributes;
26
+ return id !== undefined && url?.indexOf( 'file:' ) !== 0;
27
+ } )
28
+ .map( ( imageBlock ) => imageBlock.attributes.id );
29
+
30
+ if ( imageIds.length === 0 || imagesUploading ) {
31
+ return EMPTY_IMAGE_MEDIA;
32
+ }
33
+
34
+ return (
35
+ select( coreStore ).getMediaItems( {
36
+ include: imageIds.join( ',' ),
37
+ per_page: imageIds.length,
38
+ orderby: 'include',
39
+ } ) ?? EMPTY_IMAGE_MEDIA
40
+ );
41
+ },
42
+ [ innerBlockImages ]
43
+ );
44
+ }
@@ -18,6 +18,7 @@
18
18
  }
19
19
  },
20
20
  "supports": {
21
+ "__experimentalOnEnter": true,
21
22
  "__experimentalSettings": true,
22
23
  "align": [ "wide", "full" ],
23
24
  "anchor": true,