@wordpress/block-library 7.2.0 → 7.3.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 (425) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/archives/edit.js +21 -1
  4. package/build/archives/edit.js.map +1 -1
  5. package/build/archives/index.js +5 -1
  6. package/build/archives/index.js.map +1 -1
  7. package/build/audio/edit.native.js +0 -5
  8. package/build/audio/edit.native.js.map +1 -1
  9. package/build/avatar/edit.js +17 -11
  10. package/build/avatar/edit.js.map +1 -1
  11. package/build/block/edit.js +2 -1
  12. package/build/block/edit.js.map +1 -1
  13. package/build/column/index.js +1 -0
  14. package/build/column/index.js.map +1 -1
  15. package/build/comment-author-avatar/index.js +3 -3
  16. package/build/comment-author-name/index.js +7 -3
  17. package/build/comment-author-name/index.js.map +1 -1
  18. package/build/comment-content/index.js +1 -1
  19. package/build/comment-date/index.js +7 -3
  20. package/build/comment-date/index.js.map +1 -1
  21. package/build/comment-edit-link/index.js +5 -1
  22. package/build/comment-edit-link/index.js.map +1 -1
  23. package/build/comment-reply-link/index.js +5 -1
  24. package/build/comment-reply-link/index.js.map +1 -1
  25. package/build/comment-template/edit.js +7 -14
  26. package/build/comment-template/edit.js.map +1 -1
  27. package/build/comment-template/hooks.js +7 -23
  28. package/build/comment-template/hooks.js.map +1 -1
  29. package/build/comment-template/index.js +2 -2
  30. package/build/comments-pagination-next/index.js +2 -2
  31. package/build/comments-pagination-numbers/index.js +1 -1
  32. package/build/comments-pagination-previous/index.js +1 -1
  33. package/build/comments-query-loop/edit/comments-inspector-controls.js +2 -69
  34. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  35. package/build/comments-query-loop/edit.js +22 -1
  36. package/build/comments-query-loop/edit.js.map +1 -1
  37. package/build/comments-query-loop/index.js +1 -23
  38. package/build/comments-query-loop/index.js.map +1 -1
  39. package/build/cover/edit.js +35 -6
  40. package/build/cover/edit.js.map +1 -1
  41. package/build/cover/index.js +5 -0
  42. package/build/cover/index.js.map +1 -1
  43. package/build/cover/save.js +3 -2
  44. package/build/cover/save.js.map +1 -1
  45. package/build/gallery/gap-styles.js +8 -2
  46. package/build/gallery/gap-styles.js.map +1 -1
  47. package/build/gallery/index.js +1 -0
  48. package/build/gallery/index.js.map +1 -1
  49. package/build/group/edit.js +3 -1
  50. package/build/group/edit.js.map +1 -1
  51. package/build/group/index.js +2 -4
  52. package/build/group/index.js.map +1 -1
  53. package/build/group/variations.js +31 -9
  54. package/build/group/variations.js.map +1 -1
  55. package/build/heading/edit.js +1 -1
  56. package/build/heading/edit.js.map +1 -1
  57. package/build/html/edit.js +3 -2
  58. package/build/html/edit.js.map +1 -1
  59. package/build/image/edit.native.js +8 -10
  60. package/build/image/edit.native.js.map +1 -1
  61. package/build/index.js +3 -3
  62. package/build/index.js.map +1 -1
  63. package/build/list/deprecated.js +2 -2
  64. package/build/list/deprecated.js.map +1 -1
  65. package/build/list/v2/deprecated.js +117 -0
  66. package/build/list/v2/deprecated.js.map +1 -0
  67. package/build/list/v2/edit.js +106 -3
  68. package/build/list/v2/edit.js.map +1 -1
  69. package/build/list/v2/index.js +4 -1
  70. package/build/list/v2/index.js.map +1 -1
  71. package/build/list/v2/migrate.js +85 -0
  72. package/build/list/v2/migrate.js.map +1 -0
  73. package/build/list-item/edit.js +59 -10
  74. package/build/list-item/edit.js.map +1 -1
  75. package/build/list-item/hooks/index.js +32 -0
  76. package/build/list-item/hooks/index.js.map +1 -0
  77. package/build/list-item/hooks/use-enter.js +93 -0
  78. package/build/list-item/hooks/use-enter.js.map +1 -0
  79. package/build/list-item/hooks/use-indent-list-item.js +74 -0
  80. package/build/list-item/hooks/use-indent-list-item.js.map +1 -0
  81. package/build/list-item/hooks/use-outdent-list-item.js +77 -0
  82. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -0
  83. package/build/list-item/index.js +1 -1
  84. package/build/list-item/index.js.map +1 -1
  85. package/build/list-item/utils.js +16 -0
  86. package/build/list-item/utils.js.map +1 -0
  87. package/build/media-text/media-container.native.js +1 -16
  88. package/build/media-text/media-container.native.js.map +1 -1
  89. package/build/navigation/edit/index.js +36 -17
  90. package/build/navigation/edit/index.js.map +1 -1
  91. package/build/navigation/edit/navigation-menu-delete-control.js +1 -1
  92. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  93. package/build/navigation/edit/unsaved-inner-blocks.js +34 -7
  94. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  95. package/build/navigation/index.js +9 -1
  96. package/build/navigation/index.js.map +1 -1
  97. package/build/navigation/use-navigation-menu.js +1 -0
  98. package/build/navigation/use-navigation-menu.js.map +1 -1
  99. package/build/navigation-link/edit.js +9 -5
  100. package/build/navigation-link/edit.js.map +1 -1
  101. package/build/navigation-link/index.js +1 -1
  102. package/build/navigation-submenu/edit.js +5 -9
  103. package/build/navigation-submenu/edit.js.map +1 -1
  104. package/build/navigation-submenu/index.js +1 -1
  105. package/build/post-comment/edit.js +2 -2
  106. package/build/post-comment/edit.js.map +1 -1
  107. package/build/post-comments-form/edit.js +3 -2
  108. package/build/post-comments-form/edit.js.map +1 -1
  109. package/build/post-featured-image/index.js +1 -1
  110. package/build/post-template/edit.js +7 -2
  111. package/build/post-template/edit.js.map +1 -1
  112. package/build/post-terms/edit.js +3 -1
  113. package/build/post-terms/edit.js.map +1 -1
  114. package/build/post-terms/variations.js +1 -1
  115. package/build/post-terms/variations.js.map +1 -1
  116. package/build/query-pagination/edit.js +1 -1
  117. package/build/query-pagination/edit.js.map +1 -1
  118. package/build/query-pagination-numbers/index.js +19 -1
  119. package/build/query-pagination-numbers/index.js.map +1 -1
  120. package/build/quote/index.js +15 -8
  121. package/build/quote/index.js.map +1 -1
  122. package/build/quote/v2/deprecated.js +133 -0
  123. package/build/quote/v2/deprecated.js.map +1 -0
  124. package/build/quote/v2/edit.js +131 -0
  125. package/build/quote/v2/edit.js.map +1 -0
  126. package/build/quote/v2/index.js +49 -0
  127. package/build/quote/v2/index.js.map +1 -0
  128. package/build/quote/v2/save.js +43 -0
  129. package/build/quote/v2/save.js.map +1 -0
  130. package/build/quote/v2/transforms.js +156 -0
  131. package/build/quote/v2/transforms.js.map +1 -0
  132. package/build/read-more/index.js +1 -1
  133. package/build/rss/edit.js +6 -1
  134. package/build/rss/edit.js.map +1 -1
  135. package/build/site-logo/edit.js +3 -2
  136. package/build/site-logo/edit.js.map +1 -1
  137. package/build/site-logo/index.js +1 -1
  138. package/build/social-links/index.js +1 -0
  139. package/build/social-links/index.js.map +1 -1
  140. package/build/spacer/controls.native.js +1 -1
  141. package/build/spacer/controls.native.js.map +1 -1
  142. package/build/template-part/edit/utils/hooks.js +5 -2
  143. package/build/template-part/edit/utils/hooks.js.map +1 -1
  144. package/build-module/archives/edit.js +22 -2
  145. package/build-module/archives/edit.js.map +1 -1
  146. package/build-module/archives/index.js +5 -1
  147. package/build-module/archives/index.js.map +1 -1
  148. package/build-module/audio/edit.native.js +0 -5
  149. package/build-module/audio/edit.native.js.map +1 -1
  150. package/build-module/avatar/edit.js +16 -11
  151. package/build-module/avatar/edit.js.map +1 -1
  152. package/build-module/block/edit.js +4 -3
  153. package/build-module/block/edit.js.map +1 -1
  154. package/build-module/column/index.js +1 -0
  155. package/build-module/column/index.js.map +1 -1
  156. package/build-module/comment-author-avatar/index.js +3 -3
  157. package/build-module/comment-author-name/index.js +7 -3
  158. package/build-module/comment-author-name/index.js.map +1 -1
  159. package/build-module/comment-content/index.js +1 -1
  160. package/build-module/comment-date/index.js +7 -3
  161. package/build-module/comment-date/index.js.map +1 -1
  162. package/build-module/comment-edit-link/index.js +5 -1
  163. package/build-module/comment-edit-link/index.js.map +1 -1
  164. package/build-module/comment-reply-link/index.js +5 -1
  165. package/build-module/comment-reply-link/index.js.map +1 -1
  166. package/build-module/comment-template/edit.js +7 -14
  167. package/build-module/comment-template/edit.js.map +1 -1
  168. package/build-module/comment-template/hooks.js +7 -23
  169. package/build-module/comment-template/hooks.js.map +1 -1
  170. package/build-module/comment-template/index.js +2 -2
  171. package/build-module/comments-pagination-next/index.js +2 -2
  172. package/build-module/comments-pagination-numbers/index.js +1 -1
  173. package/build-module/comments-pagination-previous/index.js +1 -1
  174. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +4 -70
  175. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  176. package/build-module/comments-query-loop/edit.js +22 -1
  177. package/build-module/comments-query-loop/edit.js.map +1 -1
  178. package/build-module/comments-query-loop/index.js +1 -23
  179. package/build-module/comments-query-loop/index.js.map +1 -1
  180. package/build-module/cover/edit.js +36 -8
  181. package/build-module/cover/edit.js.map +1 -1
  182. package/build-module/cover/index.js +5 -0
  183. package/build-module/cover/index.js.map +1 -1
  184. package/build-module/cover/save.js +3 -2
  185. package/build-module/cover/save.js.map +1 -1
  186. package/build-module/gallery/gap-styles.js +8 -2
  187. package/build-module/gallery/gap-styles.js.map +1 -1
  188. package/build-module/gallery/index.js +1 -0
  189. package/build-module/gallery/index.js.map +1 -1
  190. package/build-module/group/edit.js +3 -1
  191. package/build-module/group/edit.js.map +1 -1
  192. package/build-module/group/index.js +2 -4
  193. package/build-module/group/index.js.map +1 -1
  194. package/build-module/group/variations.js +30 -9
  195. package/build-module/group/variations.js.map +1 -1
  196. package/build-module/heading/edit.js +1 -1
  197. package/build-module/heading/edit.js.map +1 -1
  198. package/build-module/html/edit.js +4 -3
  199. package/build-module/html/edit.js.map +1 -1
  200. package/build-module/image/edit.native.js +8 -10
  201. package/build-module/image/edit.native.js.map +1 -1
  202. package/build-module/index.js +3 -3
  203. package/build-module/index.js.map +1 -1
  204. package/build-module/list/deprecated.js +2 -2
  205. package/build-module/list/deprecated.js.map +1 -1
  206. package/build-module/list/v2/deprecated.js +104 -0
  207. package/build-module/list/v2/deprecated.js.map +1 -0
  208. package/build-module/list/v2/edit.js +104 -5
  209. package/build-module/list/v2/edit.js.map +1 -1
  210. package/build-module/list/v2/index.js +3 -1
  211. package/build-module/list/v2/index.js.map +1 -1
  212. package/build-module/list/v2/migrate.js +77 -0
  213. package/build-module/list/v2/migrate.js.map +1 -0
  214. package/build-module/list-item/edit.js +59 -13
  215. package/build-module/list-item/edit.js.map +1 -1
  216. package/build-module/list-item/hooks/index.js +4 -0
  217. package/build-module/list-item/hooks/index.js.map +1 -0
  218. package/build-module/list-item/hooks/use-enter.js +77 -0
  219. package/build-module/list-item/hooks/use-enter.js.map +1 -0
  220. package/build-module/list-item/hooks/use-indent-list-item.js +62 -0
  221. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -0
  222. package/build-module/list-item/hooks/use-outdent-list-item.js +66 -0
  223. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -0
  224. package/build-module/list-item/index.js +1 -1
  225. package/build-module/list-item/index.js.map +1 -1
  226. package/build-module/list-item/utils.js +8 -0
  227. package/build-module/list-item/utils.js.map +1 -0
  228. package/build-module/media-text/media-container.native.js +1 -14
  229. package/build-module/media-text/media-container.native.js.map +1 -1
  230. package/build-module/navigation/edit/index.js +37 -17
  231. package/build-module/navigation/edit/index.js.map +1 -1
  232. package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -1
  233. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  234. package/build-module/navigation/edit/unsaved-inner-blocks.js +35 -8
  235. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  236. package/build-module/navigation/index.js +9 -1
  237. package/build-module/navigation/index.js.map +1 -1
  238. package/build-module/navigation/use-navigation-menu.js +1 -0
  239. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  240. package/build-module/navigation-link/edit.js +9 -5
  241. package/build-module/navigation-link/edit.js.map +1 -1
  242. package/build-module/navigation-link/index.js +1 -1
  243. package/build-module/navigation-submenu/edit.js +6 -10
  244. package/build-module/navigation-submenu/edit.js.map +1 -1
  245. package/build-module/navigation-submenu/index.js +1 -1
  246. package/build-module/post-comment/edit.js +2 -2
  247. package/build-module/post-comment/edit.js.map +1 -1
  248. package/build-module/post-comments-form/edit.js +3 -2
  249. package/build-module/post-comments-form/edit.js.map +1 -1
  250. package/build-module/post-featured-image/index.js +1 -1
  251. package/build-module/post-template/edit.js +7 -2
  252. package/build-module/post-template/edit.js.map +1 -1
  253. package/build-module/post-terms/edit.js +4 -2
  254. package/build-module/post-terms/edit.js.map +1 -1
  255. package/build-module/post-terms/variations.js +3 -3
  256. package/build-module/post-terms/variations.js.map +1 -1
  257. package/build-module/query-pagination/edit.js +1 -1
  258. package/build-module/query-pagination/edit.js.map +1 -1
  259. package/build-module/query-pagination-numbers/index.js +19 -1
  260. package/build-module/query-pagination-numbers/index.js.map +1 -1
  261. package/build-module/quote/index.js +13 -1
  262. package/build-module/quote/index.js.map +1 -1
  263. package/build-module/quote/v2/deprecated.js +116 -0
  264. package/build-module/quote/v2/deprecated.js.map +1 -0
  265. package/build-module/quote/v2/edit.js +115 -0
  266. package/build-module/quote/v2/edit.js.map +1 -0
  267. package/build-module/quote/v2/index.js +33 -0
  268. package/build-module/quote/v2/index.js.map +1 -0
  269. package/build-module/quote/v2/save.js +30 -0
  270. package/build-module/quote/v2/save.js.map +1 -0
  271. package/build-module/quote/v2/transforms.js +147 -0
  272. package/build-module/quote/v2/transforms.js.map +1 -0
  273. package/build-module/read-more/index.js +1 -1
  274. package/build-module/rss/edit.js +5 -1
  275. package/build-module/rss/edit.js.map +1 -1
  276. package/build-module/site-logo/edit.js +3 -2
  277. package/build-module/site-logo/edit.js.map +1 -1
  278. package/build-module/site-logo/index.js +1 -1
  279. package/build-module/social-links/index.js +1 -0
  280. package/build-module/social-links/index.js.map +1 -1
  281. package/build-module/spacer/controls.native.js +1 -1
  282. package/build-module/spacer/controls.native.js.map +1 -1
  283. package/build-module/template-part/edit/utils/hooks.js +5 -2
  284. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  285. package/build-style/avatar/editor-rtl.css +4 -0
  286. package/build-style/avatar/editor.css +4 -0
  287. package/build-style/avatar/style-rtl.css +79 -0
  288. package/build-style/avatar/style.css +79 -0
  289. package/build-style/editor-rtl.css +30 -9
  290. package/build-style/editor.css +30 -9
  291. package/build-style/group/editor-rtl.css +26 -0
  292. package/build-style/group/editor.css +26 -0
  293. package/build-style/heading/style-rtl.css +0 -8
  294. package/build-style/heading/style.css +0 -8
  295. package/build-style/list/style-rtl.css +1 -1
  296. package/build-style/list/style.css +1 -1
  297. package/build-style/navigation/style-rtl.css +11 -9
  298. package/build-style/navigation/style.css +11 -9
  299. package/build-style/navigation-link/style-rtl.css +3 -0
  300. package/build-style/navigation-link/style.css +3 -0
  301. package/build-style/paragraph/style-rtl.css +0 -4
  302. package/build-style/paragraph/style.css +0 -4
  303. package/build-style/quote/style-rtl.css +1 -0
  304. package/build-style/quote/style.css +1 -0
  305. package/build-style/reset-rtl.css +1 -1
  306. package/build-style/reset.css +1 -1
  307. package/build-style/style-rtl.css +20 -22
  308. package/build-style/style.css +20 -22
  309. package/build-style/template-part/editor-rtl.css +0 -9
  310. package/build-style/template-part/editor.css +0 -9
  311. package/package.json +28 -28
  312. package/src/archives/block.json +5 -1
  313. package/src/archives/edit.js +20 -2
  314. package/src/archives/index.php +4 -4
  315. package/src/audio/edit.native.js +0 -5
  316. package/src/avatar/edit.js +21 -13
  317. package/src/avatar/editor.scss +6 -0
  318. package/src/avatar/index.php +2 -2
  319. package/src/avatar/style.scss +5 -0
  320. package/src/block/edit.js +21 -11
  321. package/src/column/block.json +1 -0
  322. package/src/comment-author-avatar/block.json +3 -3
  323. package/src/comment-author-name/block.json +7 -3
  324. package/src/comment-author-name/index.php +3 -0
  325. package/src/comment-content/block.json +1 -1
  326. package/src/comment-date/block.json +7 -3
  327. package/src/comment-date/index.php +6 -1
  328. package/src/comment-edit-link/block.json +5 -1
  329. package/src/comment-edit-link/index.php +3 -0
  330. package/src/comment-reply-link/block.json +5 -1
  331. package/src/comment-reply-link/index.php +4 -1
  332. package/src/comment-template/block.json +2 -8
  333. package/src/comment-template/edit.js +12 -20
  334. package/src/comment-template/hooks.js +8 -24
  335. package/src/comment-template/index.php +1 -3
  336. package/src/comments-pagination-next/block.json +2 -9
  337. package/src/comments-pagination-numbers/block.json +2 -8
  338. package/src/comments-pagination-previous/block.json +2 -2
  339. package/src/comments-query-loop/block.json +1 -23
  340. package/src/comments-query-loop/edit/comments-inspector-controls.js +2 -83
  341. package/src/comments-query-loop/edit.js +54 -1
  342. package/src/cover/block.json +5 -0
  343. package/src/cover/edit.js +77 -29
  344. package/src/cover/index.php +85 -0
  345. package/src/cover/save.js +18 -14
  346. package/src/gallery/block.json +1 -0
  347. package/src/gallery/gap-styles.js +9 -4
  348. package/src/gallery/index.php +7 -6
  349. package/src/group/block.json +2 -4
  350. package/src/group/edit.js +4 -1
  351. package/src/group/editor.scss +31 -0
  352. package/src/group/variations.js +21 -4
  353. package/src/heading/edit.js +1 -1
  354. package/src/heading/style.scss +0 -3
  355. package/src/html/edit.js +22 -30
  356. package/src/image/edit.native.js +7 -11
  357. package/src/index.js +15 -15
  358. package/src/list/deprecated.js +2 -2
  359. package/src/list/style.scss +1 -2
  360. package/src/list/test/migrate.js +159 -0
  361. package/src/list/v2/deprecated.js +89 -0
  362. package/src/list/v2/edit.js +110 -1
  363. package/src/list/v2/index.js +2 -0
  364. package/src/list/v2/migrate.js +87 -0
  365. package/src/list-item/edit.js +69 -23
  366. package/src/list-item/hooks/index.js +3 -0
  367. package/src/list-item/hooks/use-enter.js +94 -0
  368. package/src/list-item/hooks/use-indent-list-item.js +89 -0
  369. package/src/list-item/hooks/use-outdent-list-item.js +95 -0
  370. package/src/list-item/index.js +1 -1
  371. package/src/list-item/utils.js +14 -0
  372. package/src/media-text/media-container.native.js +1 -14
  373. package/src/navigation/block.json +9 -1
  374. package/src/navigation/edit/index.js +50 -14
  375. package/src/navigation/edit/navigation-menu-delete-control.js +1 -1
  376. package/src/navigation/edit/unsaved-inner-blocks.js +57 -8
  377. package/src/navigation/index.php +6 -1
  378. package/src/navigation/style.scss +15 -13
  379. package/src/navigation/use-navigation-menu.js +4 -0
  380. package/src/navigation-link/block.json +1 -0
  381. package/src/navigation-link/edit.js +43 -35
  382. package/src/navigation-link/index.php +8 -0
  383. package/src/navigation-link/style.scss +6 -0
  384. package/src/navigation-submenu/block.json +1 -0
  385. package/src/navigation-submenu/edit.js +7 -9
  386. package/src/paragraph/style.scss +0 -5
  387. package/src/post-author/index.php +0 -1
  388. package/src/post-comment/edit.js +2 -2
  389. package/src/post-comments-form/edit.js +6 -3
  390. package/src/post-featured-image/block.json +1 -1
  391. package/src/post-template/edit.js +7 -1
  392. package/src/post-terms/edit.js +4 -1
  393. package/src/post-terms/variations.js +3 -3
  394. package/src/query-pagination/edit.js +1 -1
  395. package/src/query-pagination/index.php +9 -2
  396. package/src/query-pagination-numbers/block.json +19 -1
  397. package/src/quote/block.json +8 -0
  398. package/src/quote/index.js +6 -1
  399. package/src/quote/style.scss +1 -0
  400. package/src/quote/v2/deprecated.js +107 -0
  401. package/src/quote/v2/edit.js +136 -0
  402. package/src/quote/v2/index.js +36 -0
  403. package/src/quote/v2/save.js +26 -0
  404. package/src/quote/v2/test/migrate.js +92 -0
  405. package/src/quote/v2/transforms.js +155 -0
  406. package/src/read-more/block.json +1 -1
  407. package/src/reset.scss +1 -1
  408. package/src/rss/edit.js +3 -1
  409. package/src/rss/index.php +14 -1
  410. package/src/site-logo/block.json +1 -1
  411. package/src/site-logo/edit.js +2 -1
  412. package/src/site-logo/index.php +0 -4
  413. package/src/social-link/index.php +1 -2
  414. package/src/social-links/block.json +1 -0
  415. package/src/spacer/controls.native.js +1 -1
  416. package/src/spacer/test/__snapshots__/index.native.js.snap +31 -0
  417. package/src/spacer/test/index.native.js +180 -0
  418. package/src/style.scss +1 -0
  419. package/src/template-part/edit/utils/hooks.js +6 -1
  420. package/src/template-part/editor.scss +0 -10
  421. package/build/navigation/edit/use-list-view-modal.js +0 -73
  422. package/build/navigation/edit/use-list-view-modal.js.map +0 -1
  423. package/build-module/navigation/edit/use-list-view-modal.js +0 -63
  424. package/build-module/navigation/edit/use-list-view-modal.js.map +0 -1
  425. package/src/navigation/edit/use-list-view-modal.js +0 -72
@@ -208,11 +208,7 @@ export default function CommentTemplateEdit(_ref6) {
208
208
  let {
209
209
  clientId,
210
210
  context: {
211
- postId,
212
- 'comments/perPage': perPage,
213
- 'comments/order': order,
214
- 'comments/defaultPage': defaultPage,
215
- 'comments/inherit': inherit
211
+ postId
216
212
  }
217
213
  } = _ref6;
218
214
  const blockProps = useBlockProps();
@@ -220,7 +216,8 @@ export default function CommentTemplateEdit(_ref6) {
220
216
  const {
221
217
  commentOrder,
222
218
  threadCommentsDepth,
223
- threadComments
219
+ threadComments,
220
+ commentsPerPage
224
221
  } = useSelect(select => {
225
222
  const {
226
223
  getSettings
@@ -228,10 +225,7 @@ export default function CommentTemplateEdit(_ref6) {
228
225
  return getSettings().__experimentalDiscussionSettings;
229
226
  });
230
227
  const commentQuery = useCommentQueryArgs({
231
- postId,
232
- perPage,
233
- defaultPage,
234
- inherit
228
+ postId
235
229
  });
236
230
  const {
237
231
  topLevelComments,
@@ -248,11 +242,10 @@ export default function CommentTemplateEdit(_ref6) {
248
242
  topLevelComments: commentQuery ? getEntityRecords('root', 'comment', commentQuery) : null,
249
243
  blocks: getBlocks(clientId)
250
244
  };
251
- }, [clientId, commentQuery]);
252
- order = inherit || !order ? commentOrder : order; // Generate a tree structure of comment IDs.
245
+ }, [clientId, commentQuery]); // Generate a tree structure of comment IDs.
253
246
 
254
247
  let commentTree = useCommentTree( // Reverse the order of top comments if needed.
255
- order === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
248
+ commentOrder === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
256
249
 
257
250
  if (!topLevelComments) {
258
251
  return createElement("p", blockProps, createElement(Spinner, null));
@@ -260,7 +253,7 @@ export default function CommentTemplateEdit(_ref6) {
260
253
 
261
254
  if (!postId) {
262
255
  commentTree = getCommentsPlaceholder({
263
- perPage,
256
+ perPage: commentsPerPage,
264
257
  threadComments,
265
258
  threadCommentsDepth
266
259
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["useState","memo","useSelect","__","BlockContextProvider","useBlockProps","useInnerBlocksProps","store","blockEditorStore","__experimentalUseBlockPreview","useBlockPreview","Spinner","coreStore","useCommentQueryArgs","useCommentTree","TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","order","defaultPage","inherit","commentOrder","select","getSettings","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","getBlocks","commentTree","reverse"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,oBAA/B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,oBADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,KAAK,IAAIC,gBAJV,EAKCC,6BAA6B,IAAIC,eALlC,QAMO,yBANP;AAOA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,EAA8BC,cAA9B,QAAoD,SAApD;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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A,MAAIW,WAAW,GAAGjD,cAAc,EAC/B;AACAsC,EAAAA,KAAK,KAAK,MAAV,IAAoBQ,gBAApB,GACG,CAAE,GAAGA,gBAAL,EAAwBI,OAAxB,EADH,GAEGJ,gBAJ4B,CAAhC;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,mBAAQf,UAAR,EACC,cAAC,OAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfY,IAAAA,WAAW,GAAG/C,sBAAsB,CAAE;AACrCC,MAAAA,OADqC;AAErCC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE4C,WAAW,CAAC7B,MAAnB,EAA4B;AAC3B,WAAO,mBAAQW,UAAR,OAAwB1C,EAAE,CAAE,mBAAF,CAA1B,CAAP;AACA;;AAED,SACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAG4D,WADZ;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBvC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tpostId,\n\t\t'comments/perPage': perPage,\n\t\t'comments/order': order,\n\t\t'comments/defaultPage': defaultPage,\n\t\t'comments/inherit': inherit,\n\t},\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst { commentOrder, threadCommentsDepth, threadComments } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn getSettings().__experimentalDiscussionSettings;\n\t\t}\n\t);\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t\tperPage,\n\t\tdefaultPage,\n\t\tinherit,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\torder = inherit || ! order ? commentOrder : order;\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\torder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["useState","memo","useSelect","__","BlockContextProvider","useBlockProps","useInnerBlocksProps","store","blockEditorStore","__experimentalUseBlockPreview","useBlockPreview","Spinner","coreStore","useCommentQueryArgs","useCommentTree","TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","getBlocks","commentTree","reverse"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,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/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
@@ -10,22 +10,16 @@ import apiFetch from '@wordpress/api-fetch';
10
10
  * Return an object with the query args needed to fetch the default page of
11
11
  * comments.
12
12
  *
13
- * @param {Object} props Hook props.
14
- * @param {number} props.postId ID of the post that contains the comments.
15
- * @param {number} props.perPage The number of comments included per page.
16
- * @param {string} props.defaultPage Page shown by default (newest/oldest).
17
- * @param {boolean} props.inherit Overwrite props with values from WP
18
- * discussion settings.
13
+ * @param {Object} props Hook props.
14
+ * @param {number} props.postId ID of the post that contains the comments.
15
+ * discussion settings.
19
16
  *
20
17
  * @return {Object} Query args to retrieve the comments.
21
18
  */
22
19
 
23
20
  export const useCommentQueryArgs = _ref => {
24
21
  let {
25
- postId,
26
- perPage,
27
- defaultPage,
28
- inherit
22
+ postId
29
23
  } = _ref;
30
24
  // Initialize the query args that are not going to change.
31
25
  const queryArgs = {
@@ -37,8 +31,8 @@ export const useCommentQueryArgs = _ref => {
37
31
  }; // Get the Discussion settings that may be needed to query the comments.
38
32
 
39
33
  const {
40
- commentsPerPage,
41
- defaultCommentsPage
34
+ commentsPerPage: perPage,
35
+ defaultCommentsPage: defaultPage
42
36
  } = useSelect(select => {
43
37
  const {
44
38
  getSettings
@@ -47,17 +41,7 @@ export const useCommentQueryArgs = _ref => {
47
41
  __experimentalDiscussionSettings
48
42
  } = getSettings();
49
43
  return __experimentalDiscussionSettings;
50
- }); // Overwrite the received attributes if `inherit` is true.
51
-
52
- if (inherit) {
53
- perPage = commentsPerPage;
54
- defaultPage = defaultCommentsPage;
55
- } // If a block props is not set, use the settings value to generate the
56
- // appropriate query arg.
57
-
58
-
59
- perPage = perPage || commentsPerPage;
60
- defaultPage = defaultPage || defaultCommentsPage; // Get the number of the default page.
44
+ }); // Get the number of the default page.
61
45
 
62
46
  const page = useDefaultPageIndex({
63
47
  defaultPage,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","useCommentQueryArgs","postId","perPage","defaultPage","inherit","queryArgs","status","order","context","parent","_embed","commentsPerPage","defaultCommentsPage","select","getSettings","__experimentalDiscussionSettings","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SAASC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AAYC,GAAZ,CAAiB,iBAAjB,CAAF;AAFD,OAAF,CAAf;AAIA,KAdD;AAeA,GAtBQ,EAsBN,CAAE5B,WAAF,EAAeF,MAAf,EAAuBC,OAAvB,EAAgCmB,eAAhC,CAtBM,CAAT,CAN8E,CA8B9E;;AACA,SAAOlB,WAAW,KAAK,QAAhB,GAA2Ba,IAA3B,GAAkC,CAAzC;AACA,CAhCD;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMgB,cAAc,GAAKC,gBAAF,IAAwB;AACrD,QAAMC,WAAW,GAAGxC,OAAO,CAC1B,MACCuC,gBADD,aACCA,gBADD,uBACCA,gBAAgB,CAAEE,GAAlB,CAAuB,SAAyB;AAAA,QAAvB;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,KAAuB;AAC/C,UAAM,CAAEC,QAAF,IAAe,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEC,QAAX,KAAuB,CAAE,EAAF,CAA5C;AACA,WAAO;AACNC,MAAAA,SAAS,EAAEH,EADL;AAENE,MAAAA,QAAQ,EAAEA,QAAQ,CAACH,GAAT,CAAgBK,KAAF,KAAe;AACtCD,QAAAA,SAAS,EAAEC,KAAK,CAACJ;AADqB,OAAf,CAAd;AAFJ,KAAP;AAMA,GARD,CAFyB,EAW1B,CAAEH,gBAAF,CAX0B,CAA3B;AAcA,SAAOC,WAAP;AACA,CAhBM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {boolean} props.inherit Overwrite props with values from WP\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( {\n\tpostId,\n\tperPage,\n\tdefaultPage,\n\tinherit,\n} ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst { commentsPerPage, defaultCommentsPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// Overwrite the received attributes if `inherit` is true.\n\tif ( inherit ) {\n\t\tperPage = commentsPerPage;\n\t\tdefaultPage = defaultCommentsPage;\n\t}\n\n\t// If a block props is not set, use the settings value to generate the\n\t// appropriate query arg.\n\tperPage = perPage || commentsPerPage;\n\tdefaultPage = defaultPage || defaultCommentsPage;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","commentsPerPage","perPage","defaultCommentsPage","defaultPage","select","getSettings","__experimentalDiscussionSettings","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACpD;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;AAIjBC,IAAAA,MAAM,EAAE,CAJS;AAKjBC,IAAAA,MAAM,EAAE;AALS,GAAlB,CAFoD,CAUpD;;AACA,QAAM;AACLC,IAAAA,eAAe,EAAEC,OADZ;AAELC,IAAAA,mBAAmB,EAAEC;AAFhB,MAGFhB,SAAS,CAAIiB,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEf,gBAAF,CAA9B;AACA,UAAM;AAAEiB,MAAAA;AAAF,QAAuCD,WAAW,EAAxD;AACA,WAAOC,gCAAP;AACA,GAJY,CAHb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AAM,EAAE,MAPC;AAQTC,MAAAA,KAAK,EAAE;AARE,KAAF,CAAR,CASIC,IATJ,CASYC,GAAF,IAAW;AACpBP,MAAAA,eAAe,CAAE,EAChB,GAAGD,YADa;AAEhB,SAAEE,GAAF,GAASO,QAAQ,CAAED,GAAG,CAACE,OAAJ,CAAYC,GAAZ,CAAiB,iBAAjB,CAAF;AAFD,OAAF,CAAf;AAIA,KAdD;AAeA,GAtBQ,EAsBN,CAAEnB,WAAF,EAAeV,MAAf,EAAuBQ,OAAvB,EAAgCW,eAAhC,CAtBM,CAAT,CAN8E,CA8B9E;;AACA,SAAOT,WAAW,KAAK,QAAhB,GAA2BI,IAA3B,GAAkC,CAAzC;AACA,CAhCD;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMgB,cAAc,GAAKC,gBAAF,IAAwB;AACrD,QAAMC,WAAW,GAAGvC,OAAO,CAC1B,MACCsC,gBADD,aACCA,gBADD,uBACCA,gBAAgB,CAAEE,GAAlB,CAAuB,SAAyB;AAAA,QAAvB;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,KAAuB;AAC/C,UAAM,CAAEC,QAAF,IAAe,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEC,QAAX,KAAuB,CAAE,EAAF,CAA5C;AACA,WAAO;AACNC,MAAAA,SAAS,EAAEH,EADL;AAENE,MAAAA,QAAQ,EAAEA,QAAQ,CAACH,GAAT,CAAgBK,KAAF,KAAe;AACtCD,QAAAA,SAAS,EAAEC,KAAK,CAACJ;AADqB,OAAf,CAAd;AAFJ,KAAP;AAMA,GARD,CAFyB,EAW1B,CAAEH,gBAAF,CAX0B,CAA3B;AAcA,SAAOC,WAAP;AACA,CAhBM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tcommentsPerPage: perPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
@@ -13,9 +13,9 @@ const metadata = {
13
13
  title: "Comment Template",
14
14
  category: "design",
15
15
  parent: ["core/comments-query-loop"],
16
- description: "Contains the block elements used to render a comment, like the title, date, author, avatar and more.",
16
+ description: "Contains the block elements used to display a comment, like the title, date, author, avatar and more.",
17
17
  textdomain: "default",
18
- usesContext: ["comments/defaultPage", "comments/inherit", "comments/order", "comments/perPage", "postId"],
18
+ usesContext: ["postId"],
19
19
  supports: {
20
20
  reusable: false,
21
21
  html: false,
@@ -13,14 +13,14 @@ const metadata = {
13
13
  title: "Next Page",
14
14
  category: "theme",
15
15
  parent: ["core/comments-pagination"],
16
- description: "Displays the next comments page link.",
16
+ description: "Displays the next comment's page link.",
17
17
  textdomain: "default",
18
18
  attributes: {
19
19
  label: {
20
20
  type: "string"
21
21
  }
22
22
  },
23
- usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage", "comments/paginationArrow"],
23
+ usesContext: ["postId", "comments/paginationArrow"],
24
24
  supports: {
25
25
  reusable: false,
26
26
  html: false,
@@ -15,7 +15,7 @@ const metadata = {
15
15
  parent: ["core/comments-pagination"],
16
16
  description: "Displays a list of page numbers for comments pagination.",
17
17
  textdomain: "default",
18
- usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage"],
18
+ usesContext: ["postId"],
19
19
  supports: {
20
20
  reusable: false,
21
21
  html: false
@@ -13,7 +13,7 @@ const metadata = {
13
13
  title: "Previous Page",
14
14
  category: "theme",
15
15
  parent: ["core/comments-pagination"],
16
- description: "Displays the previous comments page link.",
16
+ description: "Displays the previous comment's page link.",
17
17
  textdomain: "default",
18
18
  attributes: {
19
19
  label: {
@@ -1,85 +1,19 @@
1
- import { createElement, Fragment } from "@wordpress/element";
1
+ import { createElement } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { PanelBody, SelectControl, ToggleControl, __experimentalNumberControl as NumberControl } from '@wordpress/components';
6
+ import { SelectControl } from '@wordpress/components';
7
7
  import { __ } from '@wordpress/i18n';
8
8
  import { InspectorControls } from '@wordpress/block-editor';
9
- const orderOptions = [{
10
- label: __('Newest to oldest'),
11
- value: 'desc'
12
- }, {
13
- label: __('Oldest to newest'),
14
- value: 'asc'
15
- }];
16
- const defaultPageOptions = [{
17
- label: __('Newest'),
18
- value: 'newest'
19
- }, {
20
- label: __('Oldest'),
21
- value: 'oldest'
22
- }];
23
9
  export default function CommentsInspectorControls(_ref) {
24
10
  let {
25
11
  attributes: {
26
- TagName,
27
- perPage,
28
- order,
29
- inherit,
30
- defaultPage
12
+ TagName
31
13
  },
32
14
  setAttributes
33
15
  } = _ref;
34
- return createElement(InspectorControls, null, createElement(PanelBody, {
35
- title: __('Settings')
36
- }, createElement(ToggleControl, {
37
- label: __('Inherit from Discussion Settings'),
38
- checked: inherit,
39
- onChange: () => {
40
- setAttributes({
41
- inherit: !inherit
42
- });
43
- }
44
- }), !inherit && createElement(Fragment, null, createElement(SelectControl, {
45
- label: __('Order by'),
46
- value: order,
47
- options: orderOptions,
48
- onChange: value => {
49
- setAttributes({
50
- order: value
51
- });
52
- }
53
- }), createElement(SelectControl, {
54
- label: __('Default page'),
55
- value: defaultPage,
56
- options: defaultPageOptions,
57
- onChange: value => {
58
- setAttributes({
59
- defaultPage: value
60
- });
61
- }
62
- }), createElement(NumberControl, {
63
- __unstableInputWidth: "60px",
64
- label: __('Items per Page'),
65
- labelPosition: "edge",
66
- min: 1,
67
- max: 100,
68
- onChange: value => {
69
- const num = parseInt(value, 10);
70
-
71
- if (isNaN(num) || num < 1 || num > 100) {
72
- return;
73
- }
74
-
75
- setAttributes({
76
- perPage: num
77
- });
78
- },
79
- step: "1",
80
- value: perPage,
81
- isDragEnabled: false
82
- }))), createElement(InspectorControls, {
16
+ return createElement(InspectorControls, null, createElement(InspectorControls, {
83
17
  __experimentalGroup: "advanced"
84
18
  }, createElement(SelectControl, {
85
19
  label: __('HTML element'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["PanelBody","SelectControl","ToggleControl","__experimentalNumberControl","NumberControl","__","InspectorControls","orderOptions","label","value","defaultPageOptions","CommentsInspectorControls","attributes","TagName","perPage","order","inherit","defaultPage","setAttributes","num","parseInt","isNaN","tagName"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,2BAA2B,IAAIC,aAJhC,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,MAAMC,YAAY,GAAG,CACpB;AACCC,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CADoB,EAKpB;AACCD,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CALoB,CAArB;AAWA,MAAMC,kBAAkB,GAAG,CAC1B;AACCF,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CAD0B,EAK1B;AACCD,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CAL0B,CAA3B;AAWA,eAAe,SAASE,yBAAT,OAGX;AAAA,MAH+C;AAClDC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,OAAX;AAAoBC,MAAAA,KAApB;AAA2BC,MAAAA,OAA3B;AAAoCC,MAAAA;AAApC,KADsC;AAElDC,IAAAA;AAFkD,GAG/C;AACH,SACC,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGb,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGA,EAAE,CAAE,kCAAF,CADX;AAEC,IAAA,OAAO,EAAGW,OAFX;AAGC,IAAA,QAAQ,EAAG,MAAM;AAChBE,MAAAA,aAAa,CAAE;AACdF,QAA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,EAAC;AAAvC,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGT,EAAE,CAAE,cAAF,CADX;AAEC,IAAA,OAAO,EAAG,CACT;AAAEG,MAAAA,KAAK,EAAEH,EAAE,CAAE,iBAAF,CAAX;AAAkCI,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAHS,CAFX;AAOC,IAAA,KAAK,EAAGI,OAPT;AAQC,IAAA,QAAQ,EAAKJ,KAAF,IACVS,aAAa,CAAE;AAAEI,MAAAA,OAAO,EAAEb;AAAX,KAAF;AATf,IADD,CAvDD,CADD;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst orderOptions = [\n\t{\n\t\tlabel: __( 'Newest to oldest' ),\n\t\tvalue: 'desc',\n\t},\n\t{\n\t\tlabel: __( 'Oldest to newest' ),\n\t\tvalue: 'asc',\n\t},\n];\n\nconst defaultPageOptions = [\n\t{\n\t\tlabel: __( 'Newest' ),\n\t\tvalue: 'newest',\n\t},\n\t{\n\t\tlabel: __( 'Oldest' ),\n\t\tvalue: 'oldest',\n\t},\n];\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName, perPage, order, inherit, defaultPage },\n\tsetAttributes,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Inherit from Discussion Settings' ) }\n\t\t\t\t\tchecked={ inherit }\n\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tinherit: ! inherit,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\t\tvalue={ order }\n\t\t\t\t\t\t\toptions={ orderOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\torder: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Default page' ) }\n\t\t\t\t\t\t\tvalue={ defaultPage }\n\t\t\t\t\t\t\toptions={ defaultPageOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdefaultPage: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\t__unstableInputWidth=\"60px\"\n\t\t\t\t\t\t\tlabel={ __( 'Items per Page' ) }\n\t\t\t\t\t\t\tlabelPosition=\"edge\"\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tconst num = parseInt( value, 10 );\n\t\t\t\t\t\t\t\tif ( isNaN( num ) || num < 1 || num > 100 ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tperPage: num,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tvalue={ perPage }\n\t\t\t\t\t\t\tisDragEnabled={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</InspectorControls>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["SelectControl","__","InspectorControls","CommentsInspectorControls","attributes","TagName","setAttributes","label","value","tagName"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,eAAe,SAASC,yBAAT,OAGX;AAAA,MAH+C;AAClDC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADsC;AAElDC,IAAAA;AAFkD,GAG/C;AACH,SACC,cAAC,iBAAD,QACC,cAAC,iBAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGL,EAAE,CAAE,cAAF,CADX;AAEC,IAAA,OAAO,EAAG,CACT;AAAEM,MAAAA,KAAK,EAAEN,EAAE,CAAE,iBAAF,CAAX;AAAkCO,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAHS,CAFX;AAOC,IAAA,KAAK,EAAGH,OAPT;AAQC,IAAA,QAAQ,EAAKG,KAAF,IACVF,aAAa,CAAE;AAAEG,MAAAA,OAAO,EAAED;AAAX,KAAF;AATf,IADD,CADD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName },\n\tsetAttributes,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</InspectorControls>\n\t);\n}\n"]}
@@ -9,7 +9,28 @@ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
9
9
  */
10
10
 
11
11
  import CommentsInspectorControls from './edit/comments-inspector-controls';
12
- const TEMPLATE = [['core/comment-template'], ['core/comments-pagination']];
12
+ const TEMPLATE = [['core/comment-template', {}, [['core/columns', {}, [['core/column', {
13
+ width: '40px'
14
+ }, [['core/avatar', {
15
+ size: 40,
16
+ style: {
17
+ border: {
18
+ radius: '20px'
19
+ }
20
+ }
21
+ }]]], ['core/column', {}, [['core/comment-author-name'], ['core/group', {
22
+ layout: {
23
+ type: 'flex'
24
+ },
25
+ style: {
26
+ spacing: {
27
+ margin: {
28
+ top: '0px',
29
+ bottom: '0px'
30
+ }
31
+ }
32
+ }
33
+ }, [['core/comment-date'], ['core/comment-edit-link']]], ['core/comment-content'], ['core/comment-reply-link']]]]]]], ['core/comments-pagination']];
13
34
  export default function CommentsQueryLoopEdit(_ref) {
14
35
  let {
15
36
  attributes,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["useBlockProps","useInnerBlocksProps","CommentsInspectorControls","TEMPLATE","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,mBAAxB,QAAmD,yBAAnD;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,oCAAtC;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,uBAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,CAAjB;AAKA,eAAe,SAASC,qBAAT,OAAgE;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9E,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAuBH,UAA7B;AAEA,QAAMI,UAAU,GAAGT,aAAa,EAAhC;AACA,QAAMU,gBAAgB,GAAGT,mBAAmB,CAAEQ,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAER;AAD+C,GAAd,CAA5C;AAIA,SACC,8BACC,cAAC,yBAAD;AACC,IAAA,UAAU,EAAGE,UADd;AAEC,IAAA,aAAa,EAAGC;AAFjB,IADD,EAKC,cAAC,OAAD,EAAcI,gBAAd,CALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comment-template' ],\n\t[ 'core/comments-pagination' ],\n];\n\nexport default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["useBlockProps","useInnerBlocksProps","CommentsInspectorControls","TEMPLATE","width","size","style","border","radius","layout","type","spacing","margin","top","bottom","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,mBAAxB,QAAmD,yBAAnD;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,oCAAtC;AAEA,MAAMC,QAAQ,GAAG,CAChB,CACC,uBADD,EAEC,EAFD,EAGC,CACC,CACC,cADD,EAEC,EAFD,EAGC,CACC,CACC,aADD,EAEC;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAFD,EAGC,CACC,CACC,aADD,EAEC;AACCC,EAAAA,IAAI,EAAE,EADP;AAECC,EAAAA,KAAK,EAAE;AACNC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAM,EAAE;AAAV;AADF;AAFR,CAFD,CADD,CAHD,CADD,EAgBC,CACC,aADD,EAEC,EAFD,EAGC,CACC,CAAE,0BAAF,CADD,EAEC,CACC,YADD,EAEC;AACCC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,IAAI,EAAE;AAAR,GADT;AAECJ,EAAAA,KAAK,EAAE;AACNK,IAAAA,OAAO,EAAE;AACRC,MAAAA,MAAM,EAAE;AACPC,QAAAA,GAAG,EAAE,KADE;AAEPC,QAAAA,MAAM,EAAE;AAFD;AADA;AADH;AAFR,CAFD,EAaC,CACC,CAAE,mBAAF,CADD,EAEC,CAAE,wBAAF,CAFD,CAbD,CAFD,EAoBC,CAAE,sBAAF,CApBD,EAqBC,CAAE,yBAAF,CArBD,CAHD,CAhBD,CAHD,CADD,CAHD,CADgB,EAuDhB,CAAE,0BAAF,CAvDgB,CAAjB;AA0DA,eAAe,SAASC,qBAAT,OAAgE;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9E,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAuBH,UAA7B;AAEA,QAAMI,UAAU,GAAGpB,aAAa,EAAhC;AACA,QAAMqB,gBAAgB,GAAGpB,mBAAmB,CAAEmB,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAEnB;AAD+C,GAAd,CAA5C;AAIA,SACC,8BACC,cAAC,yBAAD;AACC,IAAA,UAAU,EAAGa,UADd;AAEC,IAAA,aAAa,EAAGC;AAFjB,IADD,EAKC,cAAC,OAAD,EAAcI,gBAAd,CALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[\n\t\t'core/comment-template',\n\t\t{},\n\t\t[\n\t\t\t[\n\t\t\t\t'core/columns',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: '40px' },\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/avatar',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsize: 40,\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tborder: { radius: '20px' },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t[ 'core/comment-author-name' ],\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlayout: { type: 'flex' },\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\t\t\t\ttop: '0px',\n\t\t\t\t\t\t\t\t\t\t\t\tbottom: '0px',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t[ 'core/comment-date' ],\n\t\t\t\t\t\t\t\t\t[ 'core/comment-edit-link' ],\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t[ 'core/comment-content' ],\n\t\t\t\t\t\t\t[ 'core/comment-reply-link' ],\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t],\n\t\t\t],\n\t\t],\n\t],\n\t[ 'core/comments-pagination' ],\n];\n\nexport default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
@@ -12,36 +12,14 @@ const metadata = {
12
12
  name: "core/comments-query-loop",
13
13
  title: "Comments Query Loop",
14
14
  category: "theme",
15
- description: "An advanced block that allows displaying post comments based on different query parameters and visual configurations.",
15
+ description: "An advanced block that allows displaying post comments using different visual configurations.",
16
16
  textdomain: "default",
17
17
  attributes: {
18
- inherit: {
19
- type: "boolean",
20
- "default": true
21
- },
22
- order: {
23
- type: "string",
24
- "default": null
25
- },
26
- perPage: {
27
- type: "number",
28
- "default": null
29
- },
30
18
  tagName: {
31
19
  type: "string",
32
20
  "default": "div"
33
- },
34
- defaultPage: {
35
- type: "string",
36
- "default": "oldest"
37
21
  }
38
22
  },
39
- providesContext: {
40
- "comments/perPage": "perPage",
41
- "comments/order": "order",
42
- "comments/defaultPage": "defaultPage",
43
- "comments/inherit": "inherit"
44
- },
45
23
  supports: {
46
24
  align: ["wide", "full"],
47
25
  html: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["postComments","icon","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBC,EAAAA,IAFuB;AAGvBC,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["postComments","icon","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBC,EAAAA,IAFuB;AAGvBC,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
@@ -12,13 +12,14 @@ import namesPlugin from 'colord/plugins/names';
12
12
  * WordPress dependencies
13
13
  */
14
14
 
15
+ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
15
16
  import { Fragment, useEffect, useRef, useState, useMemo } from '@wordpress/element';
16
- import { BaseControl, Button, ExternalLink, FocalPointPicker, PanelBody, PanelRow, RangeControl, ResizableBox, Spinner, TextareaControl, ToggleControl, __experimentalUseCustomUnits as useCustomUnits, __experimentalBoxControl as BoxControl, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUnitControl as UnitControl, __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue } from '@wordpress/components';
17
+ import { BaseControl, Button, ExternalLink, FocalPointPicker, PanelBody, PanelRow, RangeControl, ResizableBox, Spinner, TextareaControl, ToggleControl, ToolbarButton, __experimentalUseCustomUnits as useCustomUnits, __experimentalBoxControl as BoxControl, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUnitControl as UnitControl, __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue } from '@wordpress/components';
17
18
  import { compose, useInstanceId } from '@wordpress/compose';
18
19
  import { BlockControls, BlockIcon, InspectorControls, MediaPlaceholder, MediaReplaceFlow, withColors, ColorPalette, useBlockProps, useSetting, useInnerBlocksProps, __experimentalUseGradient, __experimentalPanelColorGradientSettings as PanelColorGradientSettings, __experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl, __experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl, store as blockEditorStore } from '@wordpress/block-editor';
19
20
  import { __ } from '@wordpress/i18n';
20
21
  import { useSelect, useDispatch } from '@wordpress/data';
21
- import { cover as icon } from '@wordpress/icons';
22
+ import { postFeaturedImage, cover as icon } from '@wordpress/icons';
22
23
  import { isBlobURL } from '@wordpress/blob';
23
24
  import { store as noticesStore } from '@wordpress/notices';
24
25
  /**
@@ -250,12 +251,16 @@ function CoverEdit(_ref5) {
250
251
  overlayColor,
251
252
  setAttributes,
252
253
  setOverlayColor,
253
- toggleSelection
254
+ toggleSelection,
255
+ context: {
256
+ postId,
257
+ postType
258
+ }
254
259
  } = _ref5;
255
260
  const {
256
261
  contentPosition,
257
262
  id,
258
- backgroundType,
263
+ useFeaturedImage,
259
264
  dimRatio,
260
265
  focalPoint,
261
266
  hasParallax,
@@ -264,11 +269,21 @@ function CoverEdit(_ref5) {
264
269
  minHeight,
265
270
  minHeightUnit,
266
271
  style: styleAttribute,
267
- url,
268
272
  alt,
269
273
  allowedBlocks,
270
274
  templateLock
271
275
  } = attributes;
276
+ const [featuredImage] = useEntityProp('postType', postType, 'featured_media', postId);
277
+ const media = useSelect(select => featuredImage && select(coreStore).getMedia(featuredImage, {
278
+ context: 'view'
279
+ }), [featuredImage]);
280
+ const mediaUrl = media === null || media === void 0 ? void 0 : media.source_url; // instead of destructuring the attributes
281
+ // we define the url and background type
282
+ // depending on the value of the useFeaturedImage flag
283
+ // to preview in edit the dynamic featured image
284
+
285
+ const url = useFeaturedImage ? mediaUrl : attributes.url;
286
+ const backgroundType = useFeaturedImage ? IMAGE_BACKGROUND_TYPE : attributes.backgroundType;
272
287
  const {
273
288
  __unstableMarkNextChangeAsNotPersistent
274
289
  } = useDispatch(blockEditorStore);
@@ -329,6 +344,13 @@ function CoverEdit(_ref5) {
329
344
  });
330
345
  };
331
346
 
347
+ const toggleUseFeaturedImage = () => {
348
+ setAttributes({
349
+ useFeaturedImage: !useFeaturedImage,
350
+ dimRatio: dimRatio === 100 ? 50 : dimRatio
351
+ });
352
+ };
353
+
332
354
  const onUploadError = message => {
333
355
  createErrorNotice(Array.isArray(message) ? message[2] : message, {
334
356
  type: 'snackbar'
@@ -382,7 +404,12 @@ function CoverEdit(_ref5) {
382
404
  isDisabled: !hasInnerBlocks
383
405
  })), createElement(BlockControls, {
384
406
  group: "other"
385
- }, createElement(MediaReplaceFlow, {
407
+ }, createElement(ToolbarButton, {
408
+ icon: postFeaturedImage,
409
+ label: __('Use featured image'),
410
+ isPressed: useFeaturedImage,
411
+ onClick: toggleUseFeaturedImage
412
+ }), !useFeaturedImage && createElement(MediaReplaceFlow, {
386
413
  mediaId: id,
387
414
  mediaURL: url,
388
415
  allowedTypes: ALLOWED_MEDIA_TYPES,
@@ -408,7 +435,7 @@ function CoverEdit(_ref5) {
408
435
  onChange: newFocalPoint => setAttributes({
409
436
  focalPoint: newFocalPoint
410
437
  })
411
- }), url && isImageBackground && isImgElement && createElement(TextareaControl, {
438
+ }), !useFeaturedImage && url && isImageBackground && isImgElement && createElement(TextareaControl, {
412
439
  label: __('Alt text (alternative text)'),
413
440
  value: alt,
414
441
  onChange: newAlt => setAttributes({
@@ -427,7 +454,8 @@ function CoverEdit(_ref5) {
427
454
  backgroundType: undefined,
428
455
  focalPoint: undefined,
429
456
  hasParallax: undefined,
430
- isRepeated: undefined
457
+ isRepeated: undefined,
458
+ useFeaturedImage: false
431
459
  })
432
460
  }, __('Clear Media')))), createElement(PanelColorGradientSettings, {
433
461
  __experimentalHasMultipleOrigins: true,