@wordpress/block-library 7.1.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 (634) hide show
  1. package/CHANGELOG.md +13 -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 +211 -0
  10. package/build/avatar/edit.js.map +1 -0
  11. package/build/avatar/hooks.js +111 -0
  12. package/build/avatar/hooks.js.map +1 -0
  13. package/build/avatar/index.js +83 -0
  14. package/build/avatar/index.js.map +1 -0
  15. package/build/avatar/user-control.js +63 -0
  16. package/build/avatar/user-control.js.map +1 -0
  17. package/build/block/edit.js +2 -1
  18. package/build/block/edit.js.map +1 -1
  19. package/build/column/index.js +3 -1
  20. package/build/column/index.js.map +1 -1
  21. package/build/comment-author-avatar/index.js +4 -3
  22. package/build/comment-author-avatar/index.js.map +1 -1
  23. package/build/comment-author-name/index.js +7 -3
  24. package/build/comment-author-name/index.js.map +1 -1
  25. package/build/comment-content/index.js +1 -1
  26. package/build/comment-date/edit.js +10 -25
  27. package/build/comment-date/edit.js.map +1 -1
  28. package/build/comment-date/index.js +7 -3
  29. package/build/comment-date/index.js.map +1 -1
  30. package/build/comment-edit-link/index.js +5 -1
  31. package/build/comment-edit-link/index.js.map +1 -1
  32. package/build/comment-reply-link/index.js +5 -1
  33. package/build/comment-reply-link/index.js.map +1 -1
  34. package/build/comment-template/edit.js +86 -66
  35. package/build/comment-template/edit.js.map +1 -1
  36. package/build/comment-template/hooks.js +7 -23
  37. package/build/comment-template/hooks.js.map +1 -1
  38. package/build/comment-template/index.js +2 -2
  39. package/build/comments-pagination-next/index.js +2 -2
  40. package/build/comments-pagination-numbers/index.js +1 -1
  41. package/build/comments-pagination-previous/index.js +1 -1
  42. package/build/comments-query-loop/edit/comments-inspector-controls.js +2 -69
  43. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  44. package/build/comments-query-loop/edit.js +22 -1
  45. package/build/comments-query-loop/edit.js.map +1 -1
  46. package/build/comments-query-loop/index.js +1 -23
  47. package/build/comments-query-loop/index.js.map +1 -1
  48. package/build/cover/edit.js +58 -39
  49. package/build/cover/edit.js.map +1 -1
  50. package/build/cover/index.js +5 -0
  51. package/build/cover/index.js.map +1 -1
  52. package/build/cover/save.js +3 -2
  53. package/build/cover/save.js.map +1 -1
  54. package/build/embed/variations.js +2 -2
  55. package/build/embed/variations.js.map +1 -1
  56. package/build/gallery/edit.js +18 -5
  57. package/build/gallery/edit.js.map +1 -1
  58. package/build/gallery/gallery.js +1 -1
  59. package/build/gallery/gallery.js.map +1 -1
  60. package/build/gallery/gap-styles.js +35 -0
  61. package/build/gallery/gap-styles.js.map +1 -0
  62. package/build/gallery/index.js +18 -1
  63. package/build/gallery/index.js.map +1 -1
  64. package/build/group/edit.js +3 -1
  65. package/build/group/edit.js.map +1 -1
  66. package/build/group/index.js +1 -1
  67. package/build/group/variations.js +30 -9
  68. package/build/group/variations.js.map +1 -1
  69. package/build/heading/edit.js +1 -1
  70. package/build/heading/edit.js.map +1 -1
  71. package/build/html/edit.js +3 -2
  72. package/build/html/edit.js.map +1 -1
  73. package/build/image/edit.native.js +8 -10
  74. package/build/image/edit.native.js.map +1 -1
  75. package/build/image/image.js +3 -1
  76. package/build/image/image.js.map +1 -1
  77. package/build/index.js +10 -4
  78. package/build/index.js.map +1 -1
  79. package/build/list/deprecated.js +2 -2
  80. package/build/list/deprecated.js.map +1 -1
  81. package/build/list/index.js +5 -7
  82. package/build/list/index.js.map +1 -1
  83. package/build/list/v2/deprecated.js +117 -0
  84. package/build/list/v2/deprecated.js.map +1 -0
  85. package/build/list/v2/edit.js +188 -0
  86. package/build/list/v2/edit.js.map +1 -0
  87. package/build/list/v2/index.js +36 -0
  88. package/build/list/v2/index.js.map +1 -0
  89. package/build/list/v2/migrate.js +85 -0
  90. package/build/list/v2/migrate.js.map +1 -0
  91. package/build/list/v2/save.js +34 -0
  92. package/build/list/v2/save.js.map +1 -0
  93. package/build/list/v2/transforms.js +121 -0
  94. package/build/list/v2/transforms.js.map +1 -0
  95. package/build/list-item/edit.js +96 -0
  96. package/build/list-item/edit.js.map +1 -0
  97. package/build/list-item/hooks/index.js +32 -0
  98. package/build/list-item/hooks/index.js.map +1 -0
  99. package/build/list-item/hooks/use-enter.js +93 -0
  100. package/build/list-item/hooks/use-enter.js.map +1 -0
  101. package/build/list-item/hooks/use-indent-list-item.js +74 -0
  102. package/build/list-item/hooks/use-indent-list-item.js.map +1 -0
  103. package/build/list-item/hooks/use-outdent-list-item.js +77 -0
  104. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -0
  105. package/build/list-item/index.js +67 -0
  106. package/build/list-item/index.js.map +1 -0
  107. package/build/list-item/save.js +23 -0
  108. package/build/list-item/save.js.map +1 -0
  109. package/build/list-item/utils.js +16 -0
  110. package/build/list-item/utils.js.map +1 -0
  111. package/build/media-text/edit.js +3 -1
  112. package/build/media-text/edit.js.map +1 -1
  113. package/build/media-text/media-container.native.js +1 -16
  114. package/build/media-text/media-container.native.js.map +1 -1
  115. package/build/navigation/edit/index.js +36 -17
  116. package/build/navigation/edit/index.js.map +1 -1
  117. package/build/navigation/edit/navigation-menu-delete-control.js +1 -1
  118. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  119. package/build/navigation/edit/unsaved-inner-blocks.js +34 -7
  120. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  121. package/build/navigation/index.js +9 -1
  122. package/build/navigation/index.js.map +1 -1
  123. package/build/navigation/use-navigation-entities.js +26 -54
  124. package/build/navigation/use-navigation-entities.js.map +1 -1
  125. package/build/navigation/use-navigation-menu.js +1 -0
  126. package/build/navigation/use-navigation-menu.js.map +1 -1
  127. package/build/navigation-link/edit.js +95 -37
  128. package/build/navigation-link/edit.js.map +1 -1
  129. package/build/navigation-link/index.js +1 -1
  130. package/build/navigation-submenu/edit.js +5 -9
  131. package/build/navigation-submenu/edit.js.map +1 -1
  132. package/build/navigation-submenu/index.js +1 -1
  133. package/build/post-comment/edit.js +2 -2
  134. package/build/post-comment/edit.js.map +1 -1
  135. package/build/post-comments-form/edit.js +3 -2
  136. package/build/post-comments-form/edit.js.map +1 -1
  137. package/build/post-date/edit.js +31 -37
  138. package/build/post-date/edit.js.map +1 -1
  139. package/build/post-featured-image/edit.js +2 -1
  140. package/build/post-featured-image/edit.js.map +1 -1
  141. package/build/post-featured-image/index.js +1 -1
  142. package/build/post-template/edit.js +7 -2
  143. package/build/post-template/edit.js.map +1 -1
  144. package/build/post-terms/edit.js +3 -1
  145. package/build/post-terms/edit.js.map +1 -1
  146. package/build/post-terms/variations.js +1 -1
  147. package/build/post-terms/variations.js.map +1 -1
  148. package/build/pullquote/edit.js +5 -3
  149. package/build/pullquote/edit.js.map +1 -1
  150. package/build/query/variations.js +4 -4
  151. package/build/query/variations.js.map +1 -1
  152. package/build/query-no-results/edit.js +28 -0
  153. package/build/query-no-results/edit.js.map +1 -0
  154. package/build/query-no-results/index.js +54 -0
  155. package/build/query-no-results/index.js.map +1 -0
  156. package/build/query-no-results/save.js +18 -0
  157. package/build/query-no-results/save.js.map +1 -0
  158. package/build/query-pagination/edit.js +1 -1
  159. package/build/query-pagination/edit.js.map +1 -1
  160. package/build/query-pagination-numbers/index.js +19 -1
  161. package/build/query-pagination-numbers/index.js.map +1 -1
  162. package/build/quote/index.js +15 -8
  163. package/build/quote/index.js.map +1 -1
  164. package/build/quote/v2/deprecated.js +133 -0
  165. package/build/quote/v2/deprecated.js.map +1 -0
  166. package/build/quote/v2/edit.js +131 -0
  167. package/build/quote/v2/edit.js.map +1 -0
  168. package/build/quote/v2/index.js +49 -0
  169. package/build/quote/v2/index.js.map +1 -0
  170. package/build/quote/v2/save.js +43 -0
  171. package/build/quote/v2/save.js.map +1 -0
  172. package/build/quote/v2/transforms.js +156 -0
  173. package/build/quote/v2/transforms.js.map +1 -0
  174. package/build/read-more/index.js +1 -1
  175. package/build/rss/edit.js +6 -1
  176. package/build/rss/edit.js.map +1 -1
  177. package/build/search/edit.js +2 -3
  178. package/build/search/edit.js.map +1 -1
  179. package/build/separator/deprecated.js +83 -0
  180. package/build/separator/deprecated.js.map +1 -0
  181. package/build/separator/edit.js +31 -23
  182. package/build/separator/edit.js.map +1 -1
  183. package/build/separator/index.js +17 -7
  184. package/build/separator/index.js.map +1 -1
  185. package/build/separator/save.js +18 -13
  186. package/build/separator/save.js.map +1 -1
  187. package/build/separator/use-deprecated-opacity.js +39 -0
  188. package/build/separator/use-deprecated-opacity.js.map +1 -0
  189. package/build/site-logo/edit.js +3 -2
  190. package/build/site-logo/edit.js.map +1 -1
  191. package/build/site-logo/index.js +1 -1
  192. package/build/social-links/edit.js +14 -3
  193. package/build/social-links/edit.js.map +1 -1
  194. package/build/social-links/index.js +2 -1
  195. package/build/social-links/index.js.map +1 -1
  196. package/build/spacer/controls.js +6 -16
  197. package/build/spacer/controls.js.map +1 -1
  198. package/build/spacer/controls.native.js +3 -1
  199. package/build/spacer/controls.native.js.map +1 -1
  200. package/build/spacer/edit.js +4 -5
  201. package/build/spacer/edit.js.map +1 -1
  202. package/build/table/deprecated.js +1 -1
  203. package/build/table/deprecated.js.map +1 -1
  204. package/build/tag-cloud/edit.js +58 -2
  205. package/build/tag-cloud/edit.js.map +1 -1
  206. package/build/tag-cloud/index.js +8 -0
  207. package/build/tag-cloud/index.js.map +1 -1
  208. package/build/template-part/edit/utils/hooks.js +5 -2
  209. package/build/template-part/edit/utils/hooks.js.map +1 -1
  210. package/build-module/archives/edit.js +22 -2
  211. package/build-module/archives/edit.js.map +1 -1
  212. package/build-module/archives/index.js +5 -1
  213. package/build-module/archives/index.js.map +1 -1
  214. package/build-module/audio/edit.native.js +0 -5
  215. package/build-module/audio/edit.native.js.map +1 -1
  216. package/build-module/avatar/edit.js +195 -0
  217. package/build-module/avatar/edit.js.map +1 -0
  218. package/build-module/avatar/hooks.js +99 -0
  219. package/build-module/avatar/hooks.js.map +1 -0
  220. package/build-module/avatar/index.js +70 -0
  221. package/build-module/avatar/index.js.map +1 -0
  222. package/build-module/avatar/user-control.js +52 -0
  223. package/build-module/avatar/user-control.js.map +1 -0
  224. package/build-module/block/edit.js +4 -3
  225. package/build-module/block/edit.js.map +1 -1
  226. package/build-module/column/index.js +3 -1
  227. package/build-module/column/index.js.map +1 -1
  228. package/build-module/comment-author-avatar/index.js +4 -3
  229. package/build-module/comment-author-avatar/index.js.map +1 -1
  230. package/build-module/comment-author-name/index.js +7 -3
  231. package/build-module/comment-author-name/index.js.map +1 -1
  232. package/build-module/comment-content/index.js +1 -1
  233. package/build-module/comment-date/edit.js +13 -30
  234. package/build-module/comment-date/edit.js.map +1 -1
  235. package/build-module/comment-date/index.js +7 -3
  236. package/build-module/comment-date/index.js.map +1 -1
  237. package/build-module/comment-edit-link/index.js +5 -1
  238. package/build-module/comment-edit-link/index.js.map +1 -1
  239. package/build-module/comment-reply-link/index.js +5 -1
  240. package/build-module/comment-reply-link/index.js.map +1 -1
  241. package/build-module/comment-template/edit.js +86 -66
  242. package/build-module/comment-template/edit.js.map +1 -1
  243. package/build-module/comment-template/hooks.js +7 -23
  244. package/build-module/comment-template/hooks.js.map +1 -1
  245. package/build-module/comment-template/index.js +2 -2
  246. package/build-module/comments-pagination-next/index.js +2 -2
  247. package/build-module/comments-pagination-numbers/index.js +1 -1
  248. package/build-module/comments-pagination-previous/index.js +1 -1
  249. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +4 -70
  250. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  251. package/build-module/comments-query-loop/edit.js +22 -1
  252. package/build-module/comments-query-loop/edit.js.map +1 -1
  253. package/build-module/comments-query-loop/index.js +1 -23
  254. package/build-module/comments-query-loop/index.js.map +1 -1
  255. package/build-module/cover/edit.js +58 -41
  256. package/build-module/cover/edit.js.map +1 -1
  257. package/build-module/cover/index.js +5 -0
  258. package/build-module/cover/index.js.map +1 -1
  259. package/build-module/cover/save.js +3 -2
  260. package/build-module/cover/save.js.map +1 -1
  261. package/build-module/embed/variations.js +2 -2
  262. package/build-module/embed/variations.js.map +1 -1
  263. package/build-module/gallery/edit.js +17 -5
  264. package/build-module/gallery/edit.js.map +1 -1
  265. package/build-module/gallery/gallery.js +1 -1
  266. package/build-module/gallery/gallery.js.map +1 -1
  267. package/build-module/gallery/gap-styles.js +28 -0
  268. package/build-module/gallery/gap-styles.js.map +1 -0
  269. package/build-module/gallery/index.js +18 -1
  270. package/build-module/gallery/index.js.map +1 -1
  271. package/build-module/group/edit.js +3 -1
  272. package/build-module/group/edit.js.map +1 -1
  273. package/build-module/group/index.js +1 -1
  274. package/build-module/group/variations.js +29 -9
  275. package/build-module/group/variations.js.map +1 -1
  276. package/build-module/heading/edit.js +1 -1
  277. package/build-module/heading/edit.js.map +1 -1
  278. package/build-module/html/edit.js +4 -3
  279. package/build-module/html/edit.js.map +1 -1
  280. package/build-module/image/edit.native.js +8 -10
  281. package/build-module/image/edit.native.js.map +1 -1
  282. package/build-module/image/image.js +3 -1
  283. package/build-module/image/image.js.map +1 -1
  284. package/build-module/index.js +7 -4
  285. package/build-module/index.js.map +1 -1
  286. package/build-module/list/deprecated.js +2 -2
  287. package/build-module/list/deprecated.js.map +1 -1
  288. package/build-module/list/index.js +5 -1
  289. package/build-module/list/index.js.map +1 -1
  290. package/build-module/list/v2/deprecated.js +104 -0
  291. package/build-module/list/v2/deprecated.js.map +1 -0
  292. package/build-module/list/v2/edit.js +168 -0
  293. package/build-module/list/v2/edit.js.map +1 -0
  294. package/build-module/list/v2/index.js +21 -0
  295. package/build-module/list/v2/index.js.map +1 -0
  296. package/build-module/list/v2/migrate.js +77 -0
  297. package/build-module/list/v2/migrate.js.map +1 -0
  298. package/build-module/list/v2/save.js +23 -0
  299. package/build-module/list/v2/save.js.map +1 -0
  300. package/build-module/list/v2/transforms.js +111 -0
  301. package/build-module/list/v2/transforms.js.map +1 -0
  302. package/build-module/list-item/edit.js +83 -0
  303. package/build-module/list-item/edit.js.map +1 -0
  304. package/build-module/list-item/hooks/index.js +4 -0
  305. package/build-module/list-item/hooks/index.js.map +1 -0
  306. package/build-module/list-item/hooks/use-enter.js +77 -0
  307. package/build-module/list-item/hooks/use-enter.js.map +1 -0
  308. package/build-module/list-item/hooks/use-indent-list-item.js +62 -0
  309. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -0
  310. package/build-module/list-item/hooks/use-outdent-list-item.js +66 -0
  311. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -0
  312. package/build-module/list-item/index.js +53 -0
  313. package/build-module/list-item/index.js.map +1 -0
  314. package/build-module/list-item/save.js +15 -0
  315. package/build-module/list-item/save.js.map +1 -0
  316. package/build-module/list-item/utils.js +8 -0
  317. package/build-module/list-item/utils.js.map +1 -0
  318. package/build-module/media-text/edit.js +3 -1
  319. package/build-module/media-text/edit.js.map +1 -1
  320. package/build-module/media-text/media-container.native.js +1 -14
  321. package/build-module/media-text/media-container.native.js.map +1 -1
  322. package/build-module/navigation/edit/index.js +37 -17
  323. package/build-module/navigation/edit/index.js.map +1 -1
  324. package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -1
  325. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  326. package/build-module/navigation/edit/unsaved-inner-blocks.js +35 -8
  327. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  328. package/build-module/navigation/index.js +9 -1
  329. package/build-module/navigation/index.js.map +1 -1
  330. package/build-module/navigation/use-navigation-entities.js +27 -54
  331. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  332. package/build-module/navigation/use-navigation-menu.js +1 -0
  333. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  334. package/build-module/navigation-link/edit.js +95 -36
  335. package/build-module/navigation-link/edit.js.map +1 -1
  336. package/build-module/navigation-link/index.js +1 -1
  337. package/build-module/navigation-submenu/edit.js +6 -10
  338. package/build-module/navigation-submenu/edit.js.map +1 -1
  339. package/build-module/navigation-submenu/index.js +1 -1
  340. package/build-module/post-comment/edit.js +2 -2
  341. package/build-module/post-comment/edit.js.map +1 -1
  342. package/build-module/post-comments-form/edit.js +3 -2
  343. package/build-module/post-comments-form/edit.js.map +1 -1
  344. package/build-module/post-date/edit.js +32 -43
  345. package/build-module/post-date/edit.js.map +1 -1
  346. package/build-module/post-featured-image/edit.js +2 -1
  347. package/build-module/post-featured-image/edit.js.map +1 -1
  348. package/build-module/post-featured-image/index.js +1 -1
  349. package/build-module/post-template/edit.js +7 -2
  350. package/build-module/post-template/edit.js.map +1 -1
  351. package/build-module/post-terms/edit.js +4 -2
  352. package/build-module/post-terms/edit.js.map +1 -1
  353. package/build-module/post-terms/variations.js +3 -3
  354. package/build-module/post-terms/variations.js.map +1 -1
  355. package/build-module/pullquote/edit.js +6 -3
  356. package/build-module/pullquote/edit.js.map +1 -1
  357. package/build-module/query/variations.js +4 -4
  358. package/build-module/query/variations.js.map +1 -1
  359. package/build-module/query-no-results/edit.js +18 -0
  360. package/build-module/query-no-results/edit.js.map +1 -0
  361. package/build-module/query-no-results/index.js +40 -0
  362. package/build-module/query-no-results/index.js.map +1 -0
  363. package/build-module/query-no-results/save.js +10 -0
  364. package/build-module/query-no-results/save.js.map +1 -0
  365. package/build-module/query-pagination/edit.js +1 -1
  366. package/build-module/query-pagination/edit.js.map +1 -1
  367. package/build-module/query-pagination-numbers/index.js +19 -1
  368. package/build-module/query-pagination-numbers/index.js.map +1 -1
  369. package/build-module/quote/index.js +13 -1
  370. package/build-module/quote/index.js.map +1 -1
  371. package/build-module/quote/v2/deprecated.js +116 -0
  372. package/build-module/quote/v2/deprecated.js.map +1 -0
  373. package/build-module/quote/v2/edit.js +115 -0
  374. package/build-module/quote/v2/edit.js.map +1 -0
  375. package/build-module/quote/v2/index.js +33 -0
  376. package/build-module/quote/v2/index.js.map +1 -0
  377. package/build-module/quote/v2/save.js +30 -0
  378. package/build-module/quote/v2/save.js.map +1 -0
  379. package/build-module/quote/v2/transforms.js +147 -0
  380. package/build-module/quote/v2/transforms.js.map +1 -0
  381. package/build-module/read-more/index.js +1 -1
  382. package/build-module/rss/edit.js +5 -1
  383. package/build-module/rss/edit.js.map +1 -1
  384. package/build-module/search/edit.js +2 -3
  385. package/build-module/search/edit.js.map +1 -1
  386. package/build-module/separator/deprecated.js +70 -0
  387. package/build-module/separator/deprecated.js.map +1 -0
  388. package/build-module/separator/edit.js +31 -22
  389. package/build-module/separator/edit.js.map +1 -1
  390. package/build-module/separator/index.js +16 -7
  391. package/build-module/separator/index.js.map +1 -1
  392. package/build-module/separator/save.js +19 -14
  393. package/build-module/separator/save.js.map +1 -1
  394. package/build-module/separator/use-deprecated-opacity.js +30 -0
  395. package/build-module/separator/use-deprecated-opacity.js.map +1 -0
  396. package/build-module/site-logo/edit.js +3 -2
  397. package/build-module/site-logo/edit.js.map +1 -1
  398. package/build-module/site-logo/index.js +1 -1
  399. package/build-module/social-links/edit.js +15 -4
  400. package/build-module/social-links/edit.js.map +1 -1
  401. package/build-module/social-links/index.js +2 -1
  402. package/build-module/social-links/index.js.map +1 -1
  403. package/build-module/spacer/controls.js +8 -19
  404. package/build-module/spacer/controls.js.map +1 -1
  405. package/build-module/spacer/controls.native.js +2 -1
  406. package/build-module/spacer/controls.native.js.map +1 -1
  407. package/build-module/spacer/edit.js +3 -3
  408. package/build-module/spacer/edit.js.map +1 -1
  409. package/build-module/table/deprecated.js +1 -1
  410. package/build-module/table/deprecated.js.map +1 -1
  411. package/build-module/tag-cloud/edit.js +60 -4
  412. package/build-module/tag-cloud/edit.js.map +1 -1
  413. package/build-module/tag-cloud/index.js +8 -0
  414. package/build-module/tag-cloud/index.js.map +1 -1
  415. package/build-module/template-part/edit/utils/hooks.js +5 -2
  416. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  417. package/build-style/avatar/editor-rtl.css +83 -0
  418. package/build-style/avatar/editor.css +83 -0
  419. package/build-style/avatar/style-rtl.css +79 -0
  420. package/build-style/avatar/style.css +79 -0
  421. package/build-style/editor-rtl.css +53 -11
  422. package/build-style/editor.css +53 -11
  423. package/build-style/gallery/editor-rtl.css +0 -1
  424. package/build-style/gallery/editor.css +0 -1
  425. package/build-style/gallery/style-rtl.css +102 -169
  426. package/build-style/gallery/style.css +102 -169
  427. package/build-style/group/editor-rtl.css +26 -0
  428. package/build-style/group/editor.css +26 -0
  429. package/build-style/heading/style-rtl.css +0 -8
  430. package/build-style/heading/style.css +0 -8
  431. package/build-style/image/style-rtl.css +2 -0
  432. package/build-style/image/style.css +2 -0
  433. package/build-style/list/style-rtl.css +1 -1
  434. package/build-style/list/style.css +1 -1
  435. package/build-style/navigation/style-rtl.css +11 -9
  436. package/build-style/navigation/style.css +11 -9
  437. package/build-style/navigation-link/editor-rtl.css +13 -0
  438. package/build-style/navigation-link/editor.css +13 -0
  439. package/build-style/navigation-link/style-rtl.css +3 -0
  440. package/build-style/navigation-link/style.css +3 -0
  441. package/build-style/paragraph/style-rtl.css +0 -4
  442. package/build-style/paragraph/style.css +0 -4
  443. package/build-style/pullquote/style-rtl.css +0 -4
  444. package/build-style/pullquote/style.css +0 -4
  445. package/build-style/quote/style-rtl.css +1 -0
  446. package/build-style/quote/style.css +1 -0
  447. package/build-style/reset-rtl.css +1 -1
  448. package/build-style/reset.css +1 -1
  449. package/build-style/separator/editor-rtl.css +3 -0
  450. package/build-style/separator/editor.css +3 -0
  451. package/build-style/separator/theme-rtl.css +7 -1
  452. package/build-style/separator/theme.css +7 -1
  453. package/build-style/site-logo/editor-rtl.css +3 -1
  454. package/build-style/site-logo/editor.css +3 -1
  455. package/build-style/style-rtl.css +124 -195
  456. package/build-style/style.css +124 -195
  457. package/build-style/template-part/editor-rtl.css +0 -9
  458. package/build-style/template-part/editor.css +0 -9
  459. package/build-style/theme-rtl.css +7 -1
  460. package/build-style/theme.css +7 -1
  461. package/package.json +28 -28
  462. package/src/archives/block.json +5 -1
  463. package/src/archives/edit.js +20 -2
  464. package/src/archives/index.php +4 -4
  465. package/src/audio/edit.native.js +0 -5
  466. package/src/avatar/block.json +53 -0
  467. package/src/avatar/edit.js +230 -0
  468. package/src/avatar/editor.scss +9 -0
  469. package/src/avatar/hooks.js +96 -0
  470. package/src/avatar/index.js +18 -0
  471. package/src/avatar/index.php +146 -0
  472. package/src/avatar/style.scss +5 -0
  473. package/src/avatar/user-control.js +56 -0
  474. package/src/block/edit.js +21 -11
  475. package/src/column/block.json +3 -1
  476. package/src/comment-author-avatar/block.json +4 -3
  477. package/src/comment-author-name/block.json +7 -3
  478. package/src/comment-author-name/index.php +3 -0
  479. package/src/comment-content/block.json +1 -1
  480. package/src/comment-date/block.json +7 -3
  481. package/src/comment-date/edit.js +20 -30
  482. package/src/comment-date/index.php +6 -1
  483. package/src/comment-edit-link/block.json +5 -1
  484. package/src/comment-edit-link/index.php +3 -0
  485. package/src/comment-reply-link/block.json +5 -1
  486. package/src/comment-reply-link/index.php +4 -1
  487. package/src/comment-template/block.json +2 -8
  488. package/src/comment-template/edit.js +77 -64
  489. package/src/comment-template/hooks.js +8 -24
  490. package/src/comment-template/index.php +1 -3
  491. package/src/comments-pagination-next/block.json +2 -9
  492. package/src/comments-pagination-numbers/block.json +2 -8
  493. package/src/comments-pagination-previous/block.json +2 -2
  494. package/src/comments-query-loop/block.json +1 -23
  495. package/src/comments-query-loop/edit/comments-inspector-controls.js +2 -83
  496. package/src/comments-query-loop/edit.js +54 -1
  497. package/src/cover/block.json +5 -0
  498. package/src/cover/edit.js +103 -60
  499. package/src/cover/index.php +85 -0
  500. package/src/cover/save.js +18 -14
  501. package/src/editor.scss +1 -0
  502. package/src/embed/variations.js +2 -2
  503. package/src/gallery/block.json +18 -1
  504. package/src/gallery/deprecated.scss +2 -2
  505. package/src/gallery/edit.js +15 -8
  506. package/src/gallery/editor.scss +0 -1
  507. package/src/gallery/gallery.js +8 -7
  508. package/src/gallery/gap-styles.js +26 -0
  509. package/src/gallery/index.php +43 -1
  510. package/src/gallery/style.scss +11 -44
  511. package/src/group/block.json +1 -1
  512. package/src/group/edit.js +4 -1
  513. package/src/group/editor.scss +31 -0
  514. package/src/group/variations.js +21 -4
  515. package/src/heading/edit.js +1 -1
  516. package/src/heading/style.scss +0 -3
  517. package/src/html/edit.js +22 -30
  518. package/src/image/edit.native.js +7 -11
  519. package/src/image/image.js +4 -1
  520. package/src/image/style.scss +3 -0
  521. package/src/index.js +19 -14
  522. package/src/list/deprecated.js +2 -2
  523. package/src/list/index.js +6 -1
  524. package/src/list/style.scss +1 -2
  525. package/src/list/test/migrate.js +159 -0
  526. package/src/list/v2/deprecated.js +89 -0
  527. package/src/list/v2/edit.js +186 -0
  528. package/src/list/v2/index.js +22 -0
  529. package/src/list/v2/migrate.js +87 -0
  530. package/src/list/v2/save.js +18 -0
  531. package/src/list/v2/transforms.js +116 -0
  532. package/src/list-item/block.json +26 -0
  533. package/src/list-item/edit.js +93 -0
  534. package/src/list-item/hooks/index.js +3 -0
  535. package/src/list-item/hooks/use-enter.js +94 -0
  536. package/src/list-item/hooks/use-indent-list-item.js +89 -0
  537. package/src/list-item/hooks/use-outdent-list-item.js +95 -0
  538. package/src/list-item/index.js +27 -0
  539. package/src/list-item/save.js +13 -0
  540. package/src/list-item/utils.js +14 -0
  541. package/src/media-text/edit.js +1 -1
  542. package/src/media-text/media-container.native.js +1 -14
  543. package/src/navigation/block.json +9 -1
  544. package/src/navigation/edit/index.js +50 -14
  545. package/src/navigation/edit/navigation-menu-delete-control.js +1 -1
  546. package/src/navigation/edit/unsaved-inner-blocks.js +57 -8
  547. package/src/navigation/index.php +28 -3
  548. package/src/navigation/style.scss +15 -13
  549. package/src/navigation/use-navigation-entities.js +37 -73
  550. package/src/navigation/use-navigation-menu.js +4 -0
  551. package/src/navigation-link/block.json +1 -0
  552. package/src/navigation-link/edit.js +156 -64
  553. package/src/navigation-link/editor.scss +11 -0
  554. package/src/navigation-link/index.php +8 -0
  555. package/src/navigation-link/style.scss +6 -0
  556. package/src/navigation-submenu/block.json +1 -0
  557. package/src/navigation-submenu/edit.js +7 -9
  558. package/src/paragraph/style.scss +0 -5
  559. package/src/post-author/index.php +0 -1
  560. package/src/post-comment/edit.js +2 -2
  561. package/src/post-comments-form/edit.js +6 -3
  562. package/src/post-date/edit.js +63 -52
  563. package/src/post-date/index.php +1 -1
  564. package/src/post-date/test/edit.js +17 -0
  565. package/src/post-featured-image/block.json +1 -1
  566. package/src/post-featured-image/edit.js +9 -1
  567. package/src/post-featured-image/index.php +2 -1
  568. package/src/post-template/edit.js +7 -1
  569. package/src/post-terms/edit.js +4 -1
  570. package/src/post-terms/variations.js +3 -3
  571. package/src/pullquote/edit.js +4 -3
  572. package/src/pullquote/style.scss +0 -5
  573. package/src/query/variations.js +4 -0
  574. package/src/query-no-results/block.json +20 -0
  575. package/src/query-no-results/edit.js +28 -0
  576. package/src/query-no-results/index.js +20 -0
  577. package/src/query-no-results/index.php +59 -0
  578. package/src/query-no-results/save.js +8 -0
  579. package/src/query-pagination/edit.js +1 -1
  580. package/src/query-pagination/index.php +9 -2
  581. package/src/query-pagination-numbers/block.json +19 -1
  582. package/src/quote/block.json +8 -0
  583. package/src/quote/index.js +6 -1
  584. package/src/quote/style.scss +1 -0
  585. package/src/quote/v2/deprecated.js +107 -0
  586. package/src/quote/v2/edit.js +136 -0
  587. package/src/quote/v2/index.js +36 -0
  588. package/src/quote/v2/save.js +26 -0
  589. package/src/quote/v2/test/migrate.js +92 -0
  590. package/src/quote/v2/transforms.js +155 -0
  591. package/src/read-more/block.json +1 -1
  592. package/src/reset.scss +1 -1
  593. package/src/rss/edit.js +3 -1
  594. package/src/rss/index.php +14 -1
  595. package/src/search/edit.js +1 -2
  596. package/src/separator/block.json +13 -6
  597. package/src/separator/deprecated.js +57 -0
  598. package/src/separator/deprecated.scss +6 -0
  599. package/src/separator/edit.js +36 -14
  600. package/src/separator/editor.scss +6 -0
  601. package/src/separator/index.js +2 -0
  602. package/src/separator/save.js +22 -14
  603. package/src/separator/test/edit.js +113 -0
  604. package/src/separator/theme.scss +7 -1
  605. package/src/separator/use-deprecated-opacity.js +41 -0
  606. package/src/site-logo/block.json +1 -1
  607. package/src/site-logo/edit.js +2 -1
  608. package/src/site-logo/editor.scss +3 -1
  609. package/src/site-logo/index.php +0 -4
  610. package/src/social-link/index.php +1 -2
  611. package/src/social-links/block.json +2 -1
  612. package/src/social-links/edit.js +15 -5
  613. package/src/spacer/controls.js +12 -18
  614. package/src/spacer/controls.native.js +2 -1
  615. package/src/spacer/edit.js +3 -6
  616. package/src/spacer/test/__snapshots__/index.native.js.snap +31 -0
  617. package/src/spacer/test/index.native.js +180 -0
  618. package/src/style.scss +1 -0
  619. package/src/table/deprecated.js +5 -1
  620. package/src/tag-cloud/block.json +8 -0
  621. package/src/tag-cloud/edit.js +82 -2
  622. package/src/tag-cloud/index.php +6 -0
  623. package/src/template-part/edit/utils/hooks.js +6 -1
  624. package/src/template-part/editor.scss +0 -10
  625. package/build/navigation/edit/use-list-view-modal.js +0 -73
  626. package/build/navigation/edit/use-list-view-modal.js.map +0 -1
  627. package/build/separator/separator-settings.js +0 -36
  628. package/build/separator/separator-settings.js.map +0 -1
  629. package/build-module/navigation/edit/use-list-view-modal.js +0 -63
  630. package/build-module/navigation/edit/use-list-view-modal.js.map +0 -1
  631. package/build-module/separator/separator-settings.js +0 -27
  632. package/build-module/separator/separator-settings.js.map +0 -1
  633. package/src/navigation/edit/use-list-view-modal.js +0 -72
  634. package/src/separator/separator-settings.js +0 -24
@@ -4,9 +4,9 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { useEntityProp } from '@wordpress/core-data';
7
- import { __experimentalGetSettings, dateI18n } from '@wordpress/date';
8
- import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
9
- import { PanelBody, CustomSelectControl, ToggleControl } from '@wordpress/components';
7
+ import { dateI18n, __experimentalGetSettings as getDateSettings } from '@wordpress/date';
8
+ import { InspectorControls, useBlockProps, __experimentalDateFormatPicker as DateFormatPicker } from '@wordpress/block-editor';
9
+ import { PanelBody, ToggleControl } from '@wordpress/components';
10
10
  import { __, _x } from '@wordpress/i18n';
11
11
  /**
12
12
  * Renders the `core/comment-date` block on the editor.
@@ -35,33 +35,16 @@ export default function Edit(_ref) {
35
35
  } = _ref;
36
36
  const blockProps = useBlockProps();
37
37
  const [date] = useEntityProp('root', 'comment', 'date', commentId);
38
- const [siteDateFormat] = useEntityProp('root', 'site', 'date_format');
39
-
40
- const settings = __experimentalGetSettings();
41
-
42
- const formatOptions = Object.values(settings.formats).map(formatOption => ({
43
- key: formatOption,
44
- name: dateI18n(formatOption, date || new Date())
45
- }));
46
- const resolvedFormat = format || siteDateFormat || settings.formats.date;
38
+ const [siteFormat = getDateSettings().formats.date] = useEntityProp('root', 'site', 'date_format');
47
39
  const inspectorControls = createElement(InspectorControls, null, createElement(PanelBody, {
48
- title: __('Format settings')
49
- }, createElement(CustomSelectControl, {
50
- hideLabelFromVision: true,
51
- label: __('Date Format'),
52
- options: formatOptions,
53
- onChange: _ref2 => {
54
- let {
55
- selectedItem
56
- } = _ref2;
57
- return setAttributes({
58
- format: selectedItem.key
59
- });
60
- },
61
- value: formatOptions.find(option => option.key === resolvedFormat)
62
- })), createElement(PanelBody, {
63
- title: __('Link settings')
64
- }, createElement(ToggleControl, {
40
+ title: __('Settings')
41
+ }, createElement(DateFormatPicker, {
42
+ format: format,
43
+ defaultFormat: siteFormat,
44
+ onChange: nextFormat => setAttributes({
45
+ format: nextFormat
46
+ })
47
+ }), createElement(ToggleControl, {
65
48
  label: __('Link to comment'),
66
49
  onChange: () => setAttributes({
67
50
  isLink: !isLink
@@ -75,7 +58,7 @@ export default function Edit(_ref) {
75
58
 
76
59
  let commentDate = createElement("time", {
77
60
  dateTime: dateI18n('c', date)
78
- }, dateI18n(resolvedFormat, date));
61
+ }, dateI18n(format || siteFormat, date));
79
62
 
80
63
  if (isLink) {
81
64
  commentDate = createElement("a", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-date/edit.js"],"names":["useEntityProp","__experimentalGetSettings","dateI18n","InspectorControls","useBlockProps","PanelBody","CustomSelectControl","ToggleControl","__","_x","Edit","attributes","format","isLink","context","commentId","setAttributes","blockProps","date","siteDateFormat","settings","formatOptions","Object","values","formats","map","formatOption","key","name","Date","resolvedFormat","inspectorControls","selectedItem","find","option","commentDate","event","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,sBAA9B;AACA,SAASC,yBAAT,EAAoCC,QAApC,QAAoD,iBAApD;AACA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,yBAAjD;AACA,SACCC,SADD,EAECC,mBAFD,EAGCC,aAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,IAAT,OAIX;AAAA,MAJ0B;AAC7BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KADiB;AAE7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA;AAAF,KAFoB;AAG7BC,IAAAA;AAH6B,GAI1B;AACH,QAAMC,UAAU,GAAGb,aAAa,EAAhC;AACA,QAAM,CAAEc,IAAF,IAAWlB,aAAa,CAAE,MAAF,EAAU,SAAV,EAAqB,MAArB,EAA6Be,SAA7B,CAA9B;AACA,QAAM,CAAEI,cAAF,IAAqBnB,aAAa,CAAE,MAAF,EAAU,MAAV,EAAkB,aAAlB,CAAxC;;AAEA,QAAMoB,QAAQ,GAAGnB,yBAAyB,EAA1C;;AACA,QAAMoB,aAAa,GAAGC,MAAM,CAACC,MAAP,CAAeH,QAAQ,CAACI,OAAxB,EAAkCC,GAAlC,CACnBC,YAAF,KAAsB;AACrBC,IAAAA,GAAG,EAAED,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AAE,GAAF,EAAOgB,IAAP;AAAzB,KACGhB,QAAQ,CAAE4B,cAAF,EAAkBZ,IAAlB,CADX,CADD;;AAMA,MAAKL,MAAL,EAAc;AACbsB,IAAAA,WAAW,GACV;AACC,MAAA,IAAI,EAAC,2BADN;AAEC,MAAA,OAAO,EAAKC,KAAF,IAAaA,KAAK,CAACC,cAAN;AAFxB,OAIGF,WAJH,CADD;AAQA;;AAED,SACC,8BACGJ,iBADH,EAEC,qBAAUd,UAAV,EAAyBkB,WAAzB,CAFD,CADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __experimentalGetSettings, dateI18n } from '@wordpress/date';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tCustomSelectControl,\n\tToggleControl,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Renders the `core/comment-date` block on the editor.\n *\n * @param {Object} props React props.\n * @param {Object} props.setAttributes Callback for updating block attributes.\n * @param {Object} props.attributes Block attributes.\n * @param {string} props.attributes.format Format of the date.\n * @param {string} props.attributes.isLink Whether the author name should be linked.\n * @param {Object} props.context Inherited context.\n * @param {string} props.context.commentId The comment ID.\n *\n * @return {JSX.Element} React element.\n */\nexport default function Edit( {\n\tattributes: { format, isLink },\n\tcontext: { commentId },\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst [ date ] = useEntityProp( 'root', 'comment', 'date', commentId );\n\tconst [ siteDateFormat ] = useEntityProp( 'root', 'site', 'date_format' );\n\n\tconst settings = __experimentalGetSettings();\n\tconst formatOptions = Object.values( settings.formats ).map(\n\t\t( formatOption ) => ( {\n\t\t\tkey: formatOption,\n\t\t\tname: dateI18n( formatOption, date || new Date() ),\n\t\t} )\n\t);\n\tconst resolvedFormat = format || siteDateFormat || settings.formats.date;\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Format settings' ) }>\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Date Format' ) }\n\t\t\t\t\toptions={ formatOptions }\n\t\t\t\t\tonChange={ ( { selectedItem } ) =>\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tformat: selectedItem.key,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ formatOptions.find(\n\t\t\t\t\t\t( option ) => option.key === resolvedFormat\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Link to comment' ) }\n\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\tchecked={ isLink }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tif ( ! commentId || ! date ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>{ _x( 'Comment Date', 'block title' ) }</p>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tlet commentDate = (\n\t\t<time dateTime={ dateI18n( 'c', date ) }>\n\t\t\t{ dateI18n( resolvedFormat, date ) }\n\t\t</time>\n\t);\n\n\tif ( isLink ) {\n\t\tcommentDate = (\n\t\t\t<a\n\t\t\t\thref=\"#comment-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ commentDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<div { ...blockProps }>{ commentDate }</div>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-date/edit.js"],"names":["useEntityProp","dateI18n","__experimentalGetSettings","getDateSettings","InspectorControls","useBlockProps","__experimentalDateFormatPicker","DateFormatPicker","PanelBody","ToggleControl","__","_x","Edit","attributes","format","isLink","context","commentId","setAttributes","blockProps","date","siteFormat","formats","inspectorControls","nextFormat","commentDate","event","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,sBAA9B;AACA,SACCC,QADD,EAECC,yBAAyB,IAAIC,eAF9B,QAGO,iBAHP;AAIA,SACCC,iBADD,EAECC,aAFD,EAGCC,8BAA8B,IAAIC,gBAHnC,QAIO,yBAJP;AAKA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,uBAAzC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,IAAT,OAIX;AAAA,MAJ0B;AAC7BC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KADiB;AAE7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA;AAAF,KAFoB;AAG7BC,IAAAA;AAH6B,GAI1B;AACH,QAAMC,UAAU,GAAGd,aAAa,EAAhC;AACA,QAAM,CAAEe,IAAF,IAAWpB,aAAa,CAAE,MAAF,EAAU,SAAV,EAAqB,MAArB,EAA6BiB,SAA7B,CAA9B;AACA,QAAM,CAAEI,UAAU,GAAGlB,eAAe,GAAGmB,OAAlB,CAA0BF,IAAzC,IAAkDpB,aAAa,CACpE,MADoE,EAEpE,MAFoE,EAGpE,aAHoE,CAArE;AAMA,QAAMuB,iBAAiB,GACtB,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGb,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGI,MADV;AAEC,IAAA,aAAa,EAAGO,UAFjB;AAGC,IAAA,QAAQ,EAAKG,UAAF,IACVN,aAAa,CAAE;AAAEJ,MAAAA,MAAM,EAAEU;AAAV,KAAF;AAJf,IADD,EAQC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGd,EAAE,CAAE,iBAAF,CADX;AAEC,IAAA,QAAQ,EAAG,MAAMQ,aAAa,CAAE;AAAEH,MAAAA,MAAM,EAAE,CAAEA;AAAZ,KAAF,CAF/B;AAGC,IAAA,OAAO,EAAGA;AAHX,IARD,CADD,CADD;;AAmBA,MAAK,CAAEE,SAAF,IAAe,CAAEG,IAAtB,EAA6B;AAC5B,WACC,8BACGG,iBADH,EAEC,qBAAUJ,UAAV,EACC,yBAAKR,EAAE,CAAE,cAAF,EAAkB,aAAlB,CAAP,CADD,CAFD,CADD;AAQA;;AAED,MAAIc,WAAW,GACd;AAAM,IAAA,QAAQ,EAAGxB,QAAQ,CAAE,GAAF,EAAOmB,IAAP;AAAzB,KACGnB,QAAQ,CAAEa,MAAM,IAAIO,UAAZ,EAAwBD,IAAxB,CADX,CADD;;AAMA,MAAKL,MAAL,EAAc;AACbU,IAAAA,WAAW,GACV;AACC,MAAA,IAAI,EAAC,2BADN;AAEC,MAAA,OAAO,EAAKC,KAAF,IAAaA,KAAK,CAACC,cAAN;AAFxB,OAIGF,WAJH,CADD;AAQA;;AAED,SACC,8BACGF,iBADH,EAEC,qBAAUJ,UAAV,EAAyBM,WAAzB,CAFD,CADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport {\n\tdateI18n,\n\t__experimentalGetSettings as getDateSettings,\n} from '@wordpress/date';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalDateFormatPicker as DateFormatPicker,\n} from '@wordpress/block-editor';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Renders the `core/comment-date` block on the editor.\n *\n * @param {Object} props React props.\n * @param {Object} props.setAttributes Callback for updating block attributes.\n * @param {Object} props.attributes Block attributes.\n * @param {string} props.attributes.format Format of the date.\n * @param {string} props.attributes.isLink Whether the author name should be linked.\n * @param {Object} props.context Inherited context.\n * @param {string} props.context.commentId The comment ID.\n *\n * @return {JSX.Element} React element.\n */\nexport default function Edit( {\n\tattributes: { format, isLink },\n\tcontext: { commentId },\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst [ date ] = useEntityProp( 'root', 'comment', 'date', commentId );\n\tconst [ siteFormat = getDateSettings().formats.date ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'date_format'\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<DateFormatPicker\n\t\t\t\t\tformat={ format }\n\t\t\t\t\tdefaultFormat={ siteFormat }\n\t\t\t\t\tonChange={ ( nextFormat ) =>\n\t\t\t\t\t\tsetAttributes( { format: nextFormat } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Link to comment' ) }\n\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\tchecked={ isLink }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tif ( ! commentId || ! date ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>{ _x( 'Comment Date', 'block title' ) }</p>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tlet commentDate = (\n\t\t<time dateTime={ dateI18n( 'c', date ) }>\n\t\t\t{ dateI18n( format || siteFormat, date ) }\n\t\t</time>\n\t);\n\n\tif ( isLink ) {\n\t\tcommentDate = (\n\t\t\t<a\n\t\t\t\thref=\"#comment-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ commentDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ inspectorControls }\n\t\t\t<div { ...blockProps }>{ commentDate }</div>\n\t\t</>\n\t);\n}\n"]}
@@ -12,8 +12,8 @@ const metadata = {
12
12
  name: "core/comment-date",
13
13
  title: "Comment Date",
14
14
  category: "theme",
15
- parent: ["core/comment-template"],
16
- description: "Add the date of this comment.",
15
+ ancestor: ["core/comment-template"],
16
+ description: "Displays the date on which the comment was posted.",
17
17
  textdomain: "default",
18
18
  attributes: {
19
19
  format: {
@@ -21,7 +21,11 @@ const metadata = {
21
21
  },
22
22
  isLink: {
23
23
  type: "boolean",
24
- "default": false
24
+ "default": true
25
+ },
26
+ fontSize: {
27
+ type: "string",
28
+ "default": "small"
25
29
  }
26
30
  },
27
31
  usesContext: ["commentId"],
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-date/index.js"],"names":["postDate","icon","edit","deprecated","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,IAArB,QAAiC,kBAAjC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;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 { postDate as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-date/index.js"],"names":["postDate","icon","edit","deprecated","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,IAArB,QAAiC,kBAAjC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;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 { postDate as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n};\n"]}
@@ -12,7 +12,7 @@ const metadata = {
12
12
  name: "core/comment-edit-link",
13
13
  title: "Comment Edit Link",
14
14
  category: "theme",
15
- parent: ["core/comment-template"],
15
+ ancestor: ["core/comment-template"],
16
16
  description: "Displays a link to edit the comment in the WordPress Dashboard. This link is only visible to users with the edit comment capability.",
17
17
  textdomain: "default",
18
18
  usesContext: ["commentId"],
@@ -23,6 +23,10 @@ const metadata = {
23
23
  },
24
24
  textAlign: {
25
25
  type: "string"
26
+ },
27
+ fontSize: {
28
+ type: "string",
29
+ "default": "small"
26
30
  }
27
31
  },
28
32
  supports: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-edit-link/index.js"],"names":["commentEditLink","icon","edit","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAA5B,QAAwC,kBAAxC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBJ,EAAAA,IADuB;AAEvBC,EAAAA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { commentEditLink as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-edit-link/index.js"],"names":["commentEditLink","icon","edit","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAA5B,QAAwC,kBAAxC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBJ,EAAAA,IADuB;AAEvBC,EAAAA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { commentEditLink as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
@@ -12,13 +12,17 @@ const metadata = {
12
12
  name: "core/comment-reply-link",
13
13
  title: "Comment Reply Link",
14
14
  category: "theme",
15
- parent: ["core/comment-template"],
15
+ ancestor: ["core/comment-template"],
16
16
  description: "Displays a link to reply to a comment.",
17
17
  textdomain: "default",
18
18
  usesContext: ["commentId"],
19
19
  attributes: {
20
20
  textAlign: {
21
21
  type: "string"
22
+ },
23
+ fontSize: {
24
+ type: "string",
25
+ "default": "small"
22
26
  }
23
27
  },
24
28
  supports: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-reply-link/index.js"],"names":["commentReplyLink","icon","edit","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,IAAIC,IAA7B,QAAyC,kBAAzC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBH,EAAAA,IADuB;AAEvBD,EAAAA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { commentReplyLink as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\ticon,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-reply-link/index.js"],"names":["commentReplyLink","icon","edit","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,IAAIC,IAA7B,QAAyC,kBAAzC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBH,EAAAA,IADuB;AAEvBD,EAAAA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { commentReplyLink as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\ticon,\n};\n"]}
@@ -15,10 +15,14 @@ import { store as coreStore } from '@wordpress/core-data';
15
15
  */
16
16
 
17
17
  import { useCommentQueryArgs, useCommentTree } from './hooks';
18
- const TEMPLATE = [['core/comment-author-avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
18
+ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
19
19
  /**
20
20
  * Function that returns a comment structure that will be rendered with default placehoders.
21
21
  *
22
+ * Each comment has a `commentId` property that is always a negative number in
23
+ * case of the placeholders. This is to ensure that the comment does not
24
+ * conflict with the actual (real) comments.
25
+ *
22
26
  * @param {Object} settings Discussion Settings.
23
27
  * @param {number} [settings.perPage] - Comments per page setting or block attribute.
24
28
  * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
@@ -43,15 +47,16 @@ const getCommentsPlaceholder = _ref => {
43
47
 
44
48
  if (!threadComments || defaultCommentsToShow === 1) {
45
49
  // If displaying threaded comments is disabled, we only show one comment
50
+ // A commentId is negative in order to avoid conflicts with the actual comments.
46
51
  return [{
47
- commentId: null,
52
+ commentId: -1,
48
53
  children: []
49
54
  }];
50
55
  } else if (defaultCommentsToShow === 2) {
51
56
  return [{
52
- commentId: null,
57
+ commentId: -1,
53
58
  children: [{
54
- commentId: null,
59
+ commentId: -2,
55
60
  children: []
56
61
  }]
57
62
  }];
@@ -59,11 +64,11 @@ const getCommentsPlaceholder = _ref => {
59
64
 
60
65
 
61
66
  return [{
62
- commentId: null,
67
+ commentId: -1,
63
68
  children: [{
64
- commentId: null,
69
+ commentId: -2,
65
70
  children: [{
66
- commentId: null,
71
+ commentId: -3,
67
72
  children: []
68
73
  }]
69
74
  }]
@@ -72,13 +77,13 @@ const getCommentsPlaceholder = _ref => {
72
77
  /**
73
78
  * Component which renders the inner blocks of the Comment Template.
74
79
  *
75
- * @param {Object} props Component props.
76
- * @param {Array} [props.comment] - A comment object.
77
- * @param {Array} [props.activeComment] - The block that is currently active.
78
- * @param {Array} [props.setActiveComment] - The setter for activeComment.
79
- * @param {Array} [props.firstComment] - First comment in the array.
80
- * @param {Array} [props.blocks] - Array of blocks returned from
81
- * getBlocks() in parent .
80
+ * @param {Object} props Component props.
81
+ * @param {Array} [props.comment] - A comment object.
82
+ * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
83
+ * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
84
+ * @param {Array} [props.firstCommentId] - ID of the first comment in the array.
85
+ * @param {Array} [props.blocks] - Array of blocks returned from
86
+ * getBlocks() in parent .
82
87
  * @return {WPElement} Inner blocks of the Comment Template
83
88
  */
84
89
 
@@ -88,9 +93,9 @@ function CommentTemplateInnerBlocks(_ref2) {
88
93
 
89
94
  let {
90
95
  comment,
91
- activeComment,
92
- setActiveComment,
93
- firstComment,
96
+ activeCommentId,
97
+ setActiveCommentId,
98
+ firstCommentId,
94
99
  blocks
95
100
  } = _ref2;
96
101
  const {
@@ -99,24 +104,25 @@ function CommentTemplateInnerBlocks(_ref2) {
99
104
  } = useInnerBlocksProps({}, {
100
105
  template: TEMPLATE
101
106
  });
102
- return createElement("li", innerBlocksProps, comment === (activeComment || firstComment) ? children : null, createElement(MemoizedCommentTemplatePreview, {
107
+ return createElement("li", innerBlocksProps, comment.commentId === (activeCommentId || firstCommentId) ? children : null, createElement(MemoizedCommentTemplatePreview, {
103
108
  blocks: blocks,
104
- comment: comment,
105
- setActiveComment: setActiveComment,
106
- isHidden: comment === (activeComment || firstComment)
109
+ commentId: comment.commentId,
110
+ setActiveCommentId: setActiveCommentId,
111
+ isHidden: comment.commentId === (activeCommentId || firstCommentId)
107
112
  }), (comment === null || comment === void 0 ? void 0 : (_comment$children = comment.children) === null || _comment$children === void 0 ? void 0 : _comment$children.length) > 0 ? createElement(CommentsList, {
108
113
  comments: comment.children,
109
- activeComment: activeComment,
110
- setActiveComment: setActiveComment,
111
- blocks: blocks
114
+ activeCommentId: activeCommentId,
115
+ setActiveCommentId: setActiveCommentId,
116
+ blocks: blocks,
117
+ firstCommentId: firstCommentId
112
118
  }) : null);
113
119
  }
114
120
 
115
121
  const CommentTemplatePreview = _ref3 => {
116
122
  let {
117
123
  blocks,
118
- comment,
119
- setActiveComment,
124
+ commentId,
125
+ setActiveCommentId,
120
126
  isHidden
121
127
  } = _ref3;
122
128
  const blockPreviewProps = useBlockPreview({
@@ -124,7 +130,7 @@ const CommentTemplatePreview = _ref3 => {
124
130
  });
125
131
 
126
132
  const handleOnClick = () => {
127
- setActiveComment(comment);
133
+ setActiveCommentId(commentId);
128
134
  }; // We have to hide the preview block if the `comment` props points to
129
135
  // the curently active block!
130
136
  // Or, to put it differently, every preview block is visible unless it is the
@@ -148,13 +154,14 @@ const MemoizedCommentTemplatePreview = memo(CommentTemplatePreview);
148
154
  /**
149
155
  * Component that renders a list of (nested) comments. It is called recursively.
150
156
  *
151
- * @param {Object} props Component props.
152
- * @param {Array} [props.comments] - Array of comment objects.
153
- * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.
154
- * @param {Array} [props.activeComment] - The block that is currently active.
155
- * @param {Array} [props.setActiveComment] - The setter for activeComment.
156
- * @param {Array} [props.blocks] - Array of blocks returned from
157
- * getBlocks() in parent .
157
+ * @param {Object} props Component props.
158
+ * @param {Array} [props.comments] - Array of comment objects.
159
+ * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.
160
+ * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
161
+ * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
162
+ * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.
163
+ * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of
164
+ * comment objects.
158
165
  * @return {WPElement} List of comments.
159
166
  */
160
167
 
@@ -162,39 +169,55 @@ const CommentsList = _ref4 => {
162
169
  let {
163
170
  comments,
164
171
  blockProps,
165
- activeComment,
166
- setActiveComment,
167
- blocks
172
+ activeCommentId,
173
+ setActiveCommentId,
174
+ blocks,
175
+ firstCommentId
168
176
  } = _ref4;
169
- return createElement("ol", blockProps, comments && comments.map((comment, index) => createElement(BlockContextProvider, {
170
- key: comment.commentId || index,
171
- value: comment
172
- }, createElement(CommentTemplateInnerBlocks, {
173
- comment: comment,
174
- activeComment: activeComment,
175
- setActiveComment: setActiveComment,
176
- blocks: blocks,
177
- firstComment: comments[0]
178
- }))));
177
+ return createElement("ol", blockProps, comments && comments.map((_ref5, index) => {
178
+ let {
179
+ commentId,
180
+ ...comment
181
+ } = _ref5;
182
+ return createElement(BlockContextProvider, {
183
+ key: comment.commentId || index,
184
+ value: {
185
+ // If the commentId is negative it means that this comment is a
186
+ // "placeholder" and that the block is most likely being used in the
187
+ // site editor. In this case, we have to set the commentId to `null`
188
+ // because otherwise the (non-existent) comment with a negative ID
189
+ // would be reqested from the REST API.
190
+ commentId: commentId < 0 ? null : commentId
191
+ }
192
+ }, createElement(CommentTemplateInnerBlocks, {
193
+ comment: {
194
+ commentId,
195
+ ...comment
196
+ },
197
+ activeCommentId: activeCommentId,
198
+ setActiveCommentId: setActiveCommentId,
199
+ blocks: blocks,
200
+ firstCommentId: firstCommentId
201
+ }));
202
+ }));
179
203
  };
180
204
 
181
- export default function CommentTemplateEdit(_ref5) {
205
+ export default function CommentTemplateEdit(_ref6) {
206
+ var _commentTree$;
207
+
182
208
  let {
183
209
  clientId,
184
210
  context: {
185
- postId,
186
- 'comments/perPage': perPage,
187
- 'comments/order': order,
188
- 'comments/defaultPage': defaultPage,
189
- 'comments/inherit': inherit
211
+ postId
190
212
  }
191
- } = _ref5;
213
+ } = _ref6;
192
214
  const blockProps = useBlockProps();
193
- const [activeComment, setActiveComment] = useState();
215
+ const [activeCommentId, setActiveCommentId] = useState();
194
216
  const {
195
217
  commentOrder,
196
218
  threadCommentsDepth,
197
- threadComments
219
+ threadComments,
220
+ commentsPerPage
198
221
  } = useSelect(select => {
199
222
  const {
200
223
  getSettings
@@ -202,10 +225,7 @@ export default function CommentTemplateEdit(_ref5) {
202
225
  return getSettings().__experimentalDiscussionSettings;
203
226
  });
204
227
  const commentQuery = useCommentQueryArgs({
205
- postId,
206
- perPage,
207
- defaultPage,
208
- inherit
228
+ postId
209
229
  });
210
230
  const {
211
231
  topLevelComments,
@@ -222,11 +242,10 @@ export default function CommentTemplateEdit(_ref5) {
222
242
  topLevelComments: commentQuery ? getEntityRecords('root', 'comment', commentQuery) : null,
223
243
  blocks: getBlocks(clientId)
224
244
  };
225
- }, [clientId, commentQuery]);
226
- order = inherit || !order ? commentOrder : order; // Generate a tree structure of comment IDs.
245
+ }, [clientId, commentQuery]); // Generate a tree structure of comment IDs.
227
246
 
228
247
  let commentTree = useCommentTree( // Reverse the order of top comments if needed.
229
- order === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
248
+ commentOrder === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
230
249
 
231
250
  if (!topLevelComments) {
232
251
  return createElement("p", blockProps, createElement(Spinner, null));
@@ -234,7 +253,7 @@ export default function CommentTemplateEdit(_ref5) {
234
253
 
235
254
  if (!postId) {
236
255
  commentTree = getCommentsPlaceholder({
237
- perPage,
256
+ perPage: commentsPerPage,
238
257
  threadComments,
239
258
  threadCommentsDepth
240
259
  });
@@ -248,8 +267,9 @@ export default function CommentTemplateEdit(_ref5) {
248
267
  comments: commentTree,
249
268
  blockProps: blockProps,
250
269
  blocks: blocks,
251
- activeComment: activeComment,
252
- setActiveComment: setActiveComment
270
+ activeCommentId: activeCommentId,
271
+ setActiveCommentId: setActiveCommentId,
272
+ firstCommentId: (_commentTree$ = commentTree[0]) === null || _commentTree$ === void 0 ? void 0 : _commentTree$.commentId
253
273
  });
254
274
  }
255
275
  //# sourceMappingURL=edit.js.map
@@ -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","activeComment","setActiveComment","firstComment","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,4BAAF,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;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,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,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,aAAa,EAAGH,aAJjB;AAKC,IAAA,gBAAgB,EAAGC;AALpB,IADD;AASA","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/comment-author-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 * @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\treturn [ { commentId: null, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: null,\n\t\t\t\tchildren: [ { commentId: null, 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: null,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: null,\n\t\t\t\t\tchildren: [ { commentId: null, 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.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.firstComment] - 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\tactiveComment,\n\tsetActiveComment,\n\tfirstComment,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment === ( activeComment || firstComment ) ? children : 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\tcomment={ comment }\n\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\tisHidden={ comment === ( activeComment || firstComment ) }\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\tactiveComment={ activeComment }\n\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcomment,\n\tsetActiveComment,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveComment( comment );\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.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveComment,\n\tsetActiveComment,\n\tblocks,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( comment, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ comment }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ comment }\n\t\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstComment={ comments[ 0 ] }\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 [ activeComment, setActiveComment ] = 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\tactiveComment={ activeComment }\n\t\t\tsetActiveComment={ setActiveComment }\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,IAAnB,QAA+B,oBAA/B;AACA,SAASC,S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AAEgD,MAAAA;AAAF,QAAgBN,MAAM,CAAE9C,gBAAF,CAA5B;AAEA,WAAO;AACN;AACAkD,MAAAA,gBAAgB,EAAED,YAAY,GAC3BE,gBAAgB,CAAE,MAAF,EAAU,SAAV,EAAqBF,YAArB,CADW,GAE3B,IAJG;AAKN1B,MAAAA,MAAM,EAAE6B,SAAS,CAAEX,QAAF;AALX,KAAP;AAOA,GAZ4C,EAa7C,CAAEA,QAAF,EAAYQ,YAAZ,CAb6C,CAA9C,CAlBG,CAkCH;;AACA,MAAII,WAAW,GAAG/C,cAAc,EAC/B;AACAsC,EAAAA,YAAY,KAAK,MAAjB,IAA2BM,gBAA3B,GACG,CAAE,GAAGA,gBAAL,EAAwBI,OAAxB,EADH,GAEGJ,gBAJ4B,CAAhC;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,mBAAQb,UAAR,EACC,cAAC,OAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfU,IAAAA,WAAW,GAAG7C,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEoC,eAD4B;AAErCnC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE0C,WAAW,CAAC3B,MAAnB,EAA4B;AAC3B,WAAO,mBAAQW,UAAR,OAAwB1C,EAAE,CAAE,mBAAF,CAA1B,CAAP;AACA;;AAED,SACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAG0D,WADZ;AAEC,IAAA,UAAU,EAAGhB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGgC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBrC;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: { 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,