@wordpress/block-library 7.3.0 → 7.4.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 (310) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +1 -1
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +2 -2
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/edit.native.js +1 -1
  7. package/build/audio/edit.native.js.map +1 -1
  8. package/build/categories/edit.js +8 -3
  9. package/build/categories/edit.js.map +1 -1
  10. package/build/categories/index.js +4 -0
  11. package/build/categories/index.js.map +1 -1
  12. package/build/column/index.js +10 -0
  13. package/build/column/index.js.map +1 -1
  14. package/build/comment-template/edit.js +3 -1
  15. package/build/comment-template/edit.js.map +1 -1
  16. package/build/comment-template/hooks.js +14 -4
  17. package/build/comment-template/hooks.js.map +1 -1
  18. package/build/comments-pagination/edit.js +18 -1
  19. package/build/comments-pagination/edit.js.map +1 -1
  20. package/build/comments-query-loop/edit.js +1 -1
  21. package/build/comments-query-loop/edit.js.map +1 -1
  22. package/build/comments-title/edit.js +149 -0
  23. package/build/comments-title/edit.js.map +1 -0
  24. package/build/comments-title/index.js +101 -0
  25. package/build/comments-title/index.js.map +1 -0
  26. package/build/cover/transforms.js +33 -32
  27. package/build/cover/transforms.js.map +1 -1
  28. package/build/embed/edit.js +12 -18
  29. package/build/embed/edit.js.map +1 -1
  30. package/build/embed/edit.native.js +1 -7
  31. package/build/embed/edit.native.js.map +1 -1
  32. package/build/embed/util.js +29 -4
  33. package/build/embed/util.js.map +1 -1
  34. package/build/file/inspector.js +2 -4
  35. package/build/file/inspector.js.map +1 -1
  36. package/build/gallery/edit.js +1 -1
  37. package/build/gallery/edit.js.map +1 -1
  38. package/build/gallery/v1/edit.js +1 -1
  39. package/build/gallery/v1/edit.js.map +1 -1
  40. package/build/html/edit.js +2 -2
  41. package/build/html/edit.js.map +1 -1
  42. package/build/image/edit.js +4 -6
  43. package/build/image/edit.js.map +1 -1
  44. package/build/image/edit.native.js +1 -1
  45. package/build/image/edit.native.js.map +1 -1
  46. package/build/image/image.js +1 -1
  47. package/build/image/image.js.map +1 -1
  48. package/build/index.js +5 -3
  49. package/build/index.js.map +1 -1
  50. package/build/index.native.js +14 -3
  51. package/build/index.native.js.map +1 -1
  52. package/build/latest-comments/edit.js +1 -1
  53. package/build/latest-comments/edit.js.map +1 -1
  54. package/build/list/index.js +13 -2
  55. package/build/list/index.js.map +1 -1
  56. package/build/loginout/edit.js +1 -1
  57. package/build/loginout/edit.js.map +1 -1
  58. package/build/media-text/edit.js +1 -2
  59. package/build/media-text/edit.js.map +1 -1
  60. package/build/media-text/edit.native.js +1 -1
  61. package/build/media-text/edit.native.js.map +1 -1
  62. package/build/navigation/edit/index.js +17 -1
  63. package/build/navigation/edit/index.js.map +1 -1
  64. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  65. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  66. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  67. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  68. package/build/navigation/index.js +1 -1
  69. package/build/navigation/view-modal.js +37 -0
  70. package/build/navigation/view-modal.js.map +1 -0
  71. package/build/navigation/view.js +1 -34
  72. package/build/navigation/view.js.map +1 -1
  73. package/build/paragraph/edit.native.js +6 -2
  74. package/build/paragraph/edit.native.js.map +1 -1
  75. package/build/post-author/edit.js +1 -1
  76. package/build/post-author/edit.js.map +1 -1
  77. package/build/post-comments/index.js +4 -3
  78. package/build/post-comments/index.js.map +1 -1
  79. package/build/post-excerpt/edit.js +1 -1
  80. package/build/post-excerpt/edit.js.map +1 -1
  81. package/build/post-featured-image/edit.js +19 -7
  82. package/build/post-featured-image/edit.js.map +1 -1
  83. package/build/query/edit/index.js +84 -22
  84. package/build/query/edit/index.js.map +1 -1
  85. package/build/query/edit/query-placeholder.js +7 -14
  86. package/build/query/edit/query-placeholder.js.map +1 -1
  87. package/build/query/edit/query-toolbar.js +6 -1
  88. package/build/query/edit/query-toolbar.js.map +1 -1
  89. package/build/quote/index.js +19 -2
  90. package/build/quote/index.js.map +1 -1
  91. package/build/quote/v2/edit.js +11 -3
  92. package/build/quote/v2/edit.js.map +1 -1
  93. package/build/rss/edit.js +1 -1
  94. package/build/rss/edit.js.map +1 -1
  95. package/build/search/edit.js +11 -9
  96. package/build/search/edit.js.map +1 -1
  97. package/build/spacer/constants.js +9 -0
  98. package/build/spacer/constants.js.map +1 -0
  99. package/build/spacer/controls.js +3 -3
  100. package/build/spacer/controls.js.map +1 -1
  101. package/build/spacer/controls.native.js +2 -2
  102. package/build/spacer/controls.native.js.map +1 -1
  103. package/build/spacer/edit.js +5 -6
  104. package/build/spacer/edit.js.map +1 -1
  105. package/build/table/edit.js +8 -2
  106. package/build/table/edit.js.map +1 -1
  107. package/build/tag-cloud/edit.js +1 -1
  108. package/build/tag-cloud/edit.js.map +1 -1
  109. package/build/video/edit.js +1 -1
  110. package/build/video/edit.js.map +1 -1
  111. package/build/video/edit.native.js +1 -1
  112. package/build/video/edit.native.js.map +1 -1
  113. package/build-module/archives/edit.js +1 -1
  114. package/build-module/archives/edit.js.map +1 -1
  115. package/build-module/audio/edit.js +2 -2
  116. package/build-module/audio/edit.js.map +1 -1
  117. package/build-module/audio/edit.native.js +1 -1
  118. package/build-module/audio/edit.native.js.map +1 -1
  119. package/build-module/categories/edit.js +8 -3
  120. package/build-module/categories/edit.js.map +1 -1
  121. package/build-module/categories/index.js +4 -0
  122. package/build-module/categories/index.js.map +1 -1
  123. package/build-module/column/index.js +10 -0
  124. package/build-module/column/index.js.map +1 -1
  125. package/build-module/comment-template/edit.js +3 -1
  126. package/build-module/comment-template/edit.js.map +1 -1
  127. package/build-module/comment-template/hooks.js +14 -4
  128. package/build-module/comment-template/hooks.js.map +1 -1
  129. package/build-module/comments-pagination/edit.js +19 -2
  130. package/build-module/comments-pagination/edit.js.map +1 -1
  131. package/build-module/comments-query-loop/edit.js +1 -1
  132. package/build-module/comments-query-loop/edit.js.map +1 -1
  133. package/build-module/comments-title/edit.js +133 -0
  134. package/build-module/comments-title/edit.js.map +1 -0
  135. package/build-module/comments-title/index.js +88 -0
  136. package/build-module/comments-title/index.js.map +1 -0
  137. package/build-module/cover/transforms.js +33 -32
  138. package/build-module/cover/transforms.js.map +1 -1
  139. package/build-module/embed/edit.js +13 -19
  140. package/build-module/embed/edit.js.map +1 -1
  141. package/build-module/embed/edit.native.js +2 -8
  142. package/build-module/embed/edit.native.js.map +1 -1
  143. package/build-module/embed/util.js +25 -3
  144. package/build-module/embed/util.js.map +1 -1
  145. package/build-module/file/inspector.js +2 -4
  146. package/build-module/file/inspector.js.map +1 -1
  147. package/build-module/gallery/edit.js +1 -1
  148. package/build-module/gallery/edit.js.map +1 -1
  149. package/build-module/gallery/v1/edit.js +1 -1
  150. package/build-module/gallery/v1/edit.js.map +1 -1
  151. package/build-module/html/edit.js +2 -2
  152. package/build-module/html/edit.js.map +1 -1
  153. package/build-module/image/edit.js +4 -6
  154. package/build-module/image/edit.js.map +1 -1
  155. package/build-module/image/edit.native.js +1 -1
  156. package/build-module/image/edit.native.js.map +1 -1
  157. package/build-module/image/image.js +1 -1
  158. package/build-module/image/image.js.map +1 -1
  159. package/build-module/index.js +4 -3
  160. package/build-module/index.js.map +1 -1
  161. package/build-module/index.native.js +14 -3
  162. package/build-module/index.native.js.map +1 -1
  163. package/build-module/latest-comments/edit.js +1 -1
  164. package/build-module/latest-comments/edit.js.map +1 -1
  165. package/build-module/list/index.js +9 -3
  166. package/build-module/list/index.js.map +1 -1
  167. package/build-module/loginout/edit.js +1 -1
  168. package/build-module/loginout/edit.js.map +1 -1
  169. package/build-module/media-text/edit.js +1 -2
  170. package/build-module/media-text/edit.js.map +1 -1
  171. package/build-module/media-text/edit.native.js +1 -1
  172. package/build-module/media-text/edit.native.js.map +1 -1
  173. package/build-module/navigation/edit/index.js +17 -1
  174. package/build-module/navigation/edit/index.js.map +1 -1
  175. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  176. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  177. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  178. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  179. package/build-module/navigation/index.js +1 -1
  180. package/build-module/navigation/view-modal.js +32 -0
  181. package/build-module/navigation/view-modal.js.map +1 -0
  182. package/build-module/navigation/view.js +1 -30
  183. package/build-module/navigation/view.js.map +1 -1
  184. package/build-module/paragraph/edit.native.js +6 -2
  185. package/build-module/paragraph/edit.native.js.map +1 -1
  186. package/build-module/post-author/edit.js +1 -1
  187. package/build-module/post-author/edit.js.map +1 -1
  188. package/build-module/post-comments/index.js +4 -3
  189. package/build-module/post-comments/index.js.map +1 -1
  190. package/build-module/post-excerpt/edit.js +1 -1
  191. package/build-module/post-excerpt/edit.js.map +1 -1
  192. package/build-module/post-featured-image/edit.js +19 -7
  193. package/build-module/post-featured-image/edit.js.map +1 -1
  194. package/build-module/query/edit/index.js +87 -26
  195. package/build-module/query/edit/index.js.map +1 -1
  196. package/build-module/query/edit/query-placeholder.js +8 -15
  197. package/build-module/query/edit/query-placeholder.js.map +1 -1
  198. package/build-module/query/edit/query-toolbar.js +6 -1
  199. package/build-module/query/edit/query-toolbar.js.map +1 -1
  200. package/build-module/quote/index.js +10 -4
  201. package/build-module/quote/index.js.map +1 -1
  202. package/build-module/quote/v2/edit.js +10 -3
  203. package/build-module/quote/v2/edit.js.map +1 -1
  204. package/build-module/rss/edit.js +1 -1
  205. package/build-module/rss/edit.js.map +1 -1
  206. package/build-module/search/edit.js +11 -9
  207. package/build-module/search/edit.js.map +1 -1
  208. package/build-module/spacer/constants.js +2 -0
  209. package/build-module/spacer/constants.js.map +1 -0
  210. package/build-module/spacer/controls.js +2 -2
  211. package/build-module/spacer/controls.js.map +1 -1
  212. package/build-module/spacer/controls.native.js +1 -1
  213. package/build-module/spacer/controls.native.js.map +1 -1
  214. package/build-module/spacer/edit.js +1 -1
  215. package/build-module/spacer/edit.js.map +1 -1
  216. package/build-module/table/edit.js +9 -3
  217. package/build-module/table/edit.js.map +1 -1
  218. package/build-module/tag-cloud/edit.js +1 -1
  219. package/build-module/tag-cloud/edit.js.map +1 -1
  220. package/build-module/video/edit.js +1 -1
  221. package/build-module/video/edit.js.map +1 -1
  222. package/build-module/video/edit.native.js +1 -1
  223. package/build-module/video/edit.native.js.map +1 -1
  224. package/build-style/comments-title/editor-rtl.css +79 -0
  225. package/build-style/comments-title/editor.css +79 -0
  226. package/build-style/common-rtl.css +32 -0
  227. package/build-style/common.css +32 -0
  228. package/build-style/editor-rtl.css +51 -0
  229. package/build-style/editor.css +51 -0
  230. package/build-style/post-comments-form/style-rtl.css +9 -0
  231. package/build-style/post-comments-form/style.css +9 -0
  232. package/build-style/query/editor-rtl.css +39 -0
  233. package/build-style/query/editor.css +39 -0
  234. package/build-style/style-rtl.css +79 -0
  235. package/build-style/style.css +79 -0
  236. package/build-style/table/editor-rtl.css +8 -0
  237. package/build-style/table/editor.css +8 -0
  238. package/build-style/table/style-rtl.css +38 -0
  239. package/build-style/table/style.css +38 -0
  240. package/package.json +28 -28
  241. package/src/archives/edit.js +1 -1
  242. package/src/audio/edit.js +2 -2
  243. package/src/audio/edit.native.js +1 -1
  244. package/src/categories/block.json +4 -0
  245. package/src/categories/edit.js +8 -2
  246. package/src/categories/index.php +1 -0
  247. package/src/column/block.json +10 -0
  248. package/src/comment-template/edit.js +5 -2
  249. package/src/comment-template/hooks.js +15 -2
  250. package/src/comment-template/index.php +23 -2
  251. package/src/comments-pagination/edit.js +23 -0
  252. package/src/comments-query-loop/edit.js +1 -0
  253. package/src/comments-title/block.json +70 -0
  254. package/src/comments-title/edit.js +197 -0
  255. package/src/comments-title/editor.scss +4 -0
  256. package/src/comments-title/index.js +18 -0
  257. package/src/comments-title/index.php +68 -0
  258. package/src/common.scss +24 -1
  259. package/src/cover/transforms.js +51 -28
  260. package/src/editor.scss +1 -0
  261. package/src/embed/edit.js +19 -24
  262. package/src/embed/edit.native.js +9 -14
  263. package/src/embed/util.js +34 -2
  264. package/src/file/inspector.js +1 -3
  265. package/src/gallery/edit.js +1 -1
  266. package/src/gallery/v1/edit.js +1 -1
  267. package/src/html/edit.js +2 -2
  268. package/src/image/edit.js +2 -4
  269. package/src/image/edit.native.js +1 -1
  270. package/src/image/image.js +1 -1
  271. package/src/index.js +7 -1
  272. package/src/index.native.js +12 -2
  273. package/src/latest-comments/edit.js +1 -1
  274. package/src/list/index.js +7 -3
  275. package/src/loginout/edit.js +1 -1
  276. package/src/media-text/edit.js +1 -2
  277. package/src/media-text/edit.native.js +1 -1
  278. package/src/navigation/block.json +1 -1
  279. package/src/navigation/edit/index.js +24 -0
  280. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  281. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  282. package/src/navigation/index.php +5 -0
  283. package/src/navigation/view-modal.js +36 -0
  284. package/src/navigation/view.js +0 -35
  285. package/src/paragraph/edit.native.js +13 -1
  286. package/src/post-author/edit.js +1 -1
  287. package/src/post-comments/block.json +4 -3
  288. package/src/post-comments-form/index.php +12 -4
  289. package/src/post-comments-form/style.scss +11 -0
  290. package/src/post-excerpt/edit.js +1 -1
  291. package/src/post-featured-image/edit.js +24 -12
  292. package/src/query/edit/index.js +125 -26
  293. package/src/query/edit/query-placeholder.js +3 -13
  294. package/src/query/edit/query-toolbar.js +6 -0
  295. package/src/query/editor.scss +38 -0
  296. package/src/quote/index.js +8 -4
  297. package/src/quote/v2/edit.js +3 -0
  298. package/src/rss/edit.js +1 -1
  299. package/src/search/edit.js +13 -7
  300. package/src/search/index.php +84 -33
  301. package/src/spacer/constants.js +1 -0
  302. package/src/spacer/controls.js +2 -2
  303. package/src/spacer/controls.native.js +1 -1
  304. package/src/spacer/edit.js +1 -2
  305. package/src/table/edit.js +11 -2
  306. package/src/table/editor.scss +13 -0
  307. package/src/table/style.scss +52 -0
  308. package/src/tag-cloud/edit.js +1 -1
  309. package/src/video/edit.js +1 -1
  310. package/src/video/edit.native.js +1 -1
@@ -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","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,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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ACC,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"]}
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,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,cA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CAZ6C,CAA9C,CAlBG,CAiCH;;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,WACC,gCAAQW,UAAR;AAAqB,qBAAY;AAAjC,QACG1C,EAAE,CAAE,mBAAF,CADL,CADD;AAKA;;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\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 (\n\t\t\t<p { ...blockProps } data-testid=\"noresults\">\n\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t</p>\n\t\t);\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"]}
@@ -5,7 +5,9 @@ import { useState, useEffect, useMemo } from '@wordpress/element';
5
5
  import { useSelect } from '@wordpress/data';
6
6
  import { store as blockEditorStore } from '@wordpress/block-editor';
7
7
  import { addQueryArgs } from '@wordpress/url';
8
- import apiFetch from '@wordpress/api-fetch';
8
+ import apiFetch from '@wordpress/api-fetch'; // This is limited by WP REST API
9
+
10
+ const MAX_COMMENTS_PER_PAGE = 100;
9
11
  /**
10
12
  * Return an object with the query args needed to fetch the default page of
11
13
  * comments.
@@ -31,7 +33,8 @@ export const useCommentQueryArgs = _ref => {
31
33
  }; // Get the Discussion settings that may be needed to query the comments.
32
34
 
33
35
  const {
34
- commentsPerPage: perPage,
36
+ pageComments,
37
+ commentsPerPage,
35
38
  defaultCommentsPage: defaultPage
36
39
  } = useSelect(select => {
37
40
  const {
@@ -41,7 +44,12 @@ export const useCommentQueryArgs = _ref => {
41
44
  __experimentalDiscussionSettings
42
45
  } = getSettings();
43
46
  return __experimentalDiscussionSettings;
44
- }); // Get the number of the default page.
47
+ }); // WP REST API doesn't allow fetching more than max items limit set per single page of data.
48
+ // As for the editor performance is more important than completeness of data and fetching only the
49
+ // max allowed for single page should be enough for the purpose of design and laying out the page.
50
+ // Fetching over the limit would return an error here but would work with backend query.
51
+
52
+ const perPage = pageComments ? Math.min(commentsPerPage, MAX_COMMENTS_PER_PAGE) : MAX_COMMENTS_PER_PAGE; // Get the number of the default page.
45
53
 
46
54
  const page = useDefaultPageIndex({
47
55
  defaultPage,
@@ -102,8 +110,10 @@ const useDefaultPageIndex = _ref2 => {
102
110
  method: 'HEAD',
103
111
  parse: false
104
112
  }).then(res => {
113
+ const pages = parseInt(res.headers.get('X-WP-TotalPages'));
105
114
  setDefaultPages({ ...defaultPages,
106
- [key]: parseInt(res.headers.get('X-WP-TotalPages'))
115
+ [key]: pages <= 1 ? 1 : pages // If there are 0 pages, it means that there are no comments, but there is no 0th page.
116
+
107
117
  });
108
118
  });
109
119
  }, [defaultPage, postId, perPage, setDefaultPages]); // The oldest one is always the first one.
@@ -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","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,sBA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,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"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","MAX_COMMENTS_PER_PAGE","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","pageComments","commentsPerPage","defaultCommentsPage","defaultPage","select","getSettings","__experimentalDiscussionSettings","perPage","Math","min","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","pages","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,C,CAEA;;AACA,MAAMC,qBAAqB,GAAG,GAA9B;AAEA;AACA;AACA;AACA;AACA;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K,QAAhB,GAA2BO,IAA3B,GAAkC,CAAzC;AACA,CAjCD;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMiB,cAAc,GAAKC,gBAAF,IAAwB;AACrD,QAAMC,WAAW,GAAG5C,OAAO,CAC1B,MACC2C,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// This is limited by WP REST API\nconst MAX_COMMENTS_PER_PAGE = 100;\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\tpageComments,\n\t\tcommentsPerPage,\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// WP REST API doesn't allow fetching more than max items limit set per single page of data.\n\t// As for the editor performance is more important than completeness of data and fetching only the\n\t// max allowed for single page should be enough for the purpose of design and laying out the page.\n\t// Fetching over the limit would return an error here but would work with backend query.\n\tconst perPage = pageComments\n\t\t? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )\n\t\t: MAX_COMMENTS_PER_PAGE;\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\tconst pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.\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"]}
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
- import { InspectorControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
7
+ import { InspectorControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore, Warning } from '@wordpress/block-editor';
8
8
  import { useSelect } from '@wordpress/data';
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
10
  import { PanelBody } from '@wordpress/components';
@@ -51,7 +51,24 @@ export default function QueryPaginationEdit(_ref) {
51
51
  template: TEMPLATE,
52
52
  allowedBlocks: ['core/comments-pagination-previous', 'core/comments-pagination-numbers', 'core/comments-pagination-next'],
53
53
  __experimentalLayout: usedLayout
54
- });
54
+ }); // Get the Discussion settings
55
+
56
+ const pageComments = useSelect(select => {
57
+ const {
58
+ getSettings
59
+ } = select(blockEditorStore);
60
+ const {
61
+ __experimentalDiscussionSettings
62
+ } = getSettings();
63
+ return __experimentalDiscussionSettings === null || __experimentalDiscussionSettings === void 0 ? void 0 : __experimentalDiscussionSettings.pageComments;
64
+ }, []); // If paging comments is not enabled in the Discussion Settings then hide the pagination
65
+ // controls. We don't want to remove them from the template so that when the user enables
66
+ // paging comments, the controls will be visible.
67
+
68
+ if (!pageComments) {
69
+ return createElement(Warning, null, __('Comments Pagination block: paging comments is disabled in the Discussion Settings'));
70
+ }
71
+
55
72
  return createElement(Fragment, null, hasNextPreviousBlocks && createElement(InspectorControls, null, createElement(PanelBody, {
56
73
  title: __('Settings')
57
74
  }, createElement(CommentsPaginationArrowControls, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-pagination/edit.js"],"names":["__","InspectorControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","useSelect","getBlockSupport","PanelBody","CommentsPaginationArrowControls","TEMPLATE","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","QueryPaginationEdit","attributes","paginationArrow","layout","setAttributes","clientId","name","usedLayout","hasNextPreviousBlocks","select","getBlocks","innerBlocks","find","innerBlock","includes","blockProps","innerBloc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,UAAU,CAACP,IAHhB,CAAP;AAIA,KALM,CAAP;AAMA,GAdsC,EAcpC,EAdoC,CAAvC;AAeA,QAAMS,UAAU,GAAG5B,aAAa,EAAhC;AACA,QAAM6B,gBAAgB,GAAG5B,mBAAmB,CAAE2B,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAEtB,QAD+C;AAEzDuB,IAAAA,aAAa,EAAE,CACd,mCADc,EAEd,kCAFc,EAGd,+BAHc,CAF0C;AAOzDC,IAAAA,oBAAoB,EAAEZ;AAPmC,GAAd,CAA5C;AASA,SACC,8BACGC,qBAAqB,IACtB,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGvB,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,+BAAD;AACC,IAAA,KAAK,EAAGiB,eADT;AAEC,IAAA,QAAQ,EAAKkB,KAAF,IAAa;AACvBhB,MAAAA,aAAa,CAAE;AAAEF,QAAAA,eAAe,EAAEkB;AAAnB,OAAF,CAAb;AACA;AAJF,IADD,CADD,CAFF,EAaC,qBAAUJ,gBAAV,CAbD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comments-pagination-previous' ],\n\t[ 'core/comments-pagination-numbers' ],\n\t[ 'core/comments-pagination-next' ],\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport default function QueryPaginationEdit( {\n\tattributes: { paginationArrow, layout },\n\tsetAttributes,\n\tclientId,\n\tname,\n} ) {\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\tconst hasNextPreviousBlocks = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst innerBlocks = getBlocks( clientId );\n\t\t/**\n\t\t * Show the `paginationArrow` control only if a\n\t\t * Comments Pagination Next or Comments Pagination Previous\n\t\t * block exists.\n\t\t */\n\t\treturn innerBlocks?.find( ( innerBlock ) => {\n\t\t\treturn [\n\t\t\t\t'core/comments-pagination-previous',\n\t\t\t\t'core/comments-pagination-next',\n\t\t\t].includes( innerBlock.name );\n\t\t} );\n\t}, [] );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\tallowedBlocks: [\n\t\t\t'core/comments-pagination-previous',\n\t\t\t'core/comments-pagination-numbers',\n\t\t\t'core/comments-pagination-next',\n\t\t],\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\treturn (\n\t\t<>\n\t\t\t{ hasNextPreviousBlocks && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<CommentsPaginationArrowControls\n\t\t\t\t\t\t\tvalue={ paginationArrow }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-pagination/edit.js"],"names":["__","InspectorControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","Warning","useSelect","getBlockSupport","PanelBody","CommentsPaginationArrowControls","TEMPLATE","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","QueryPaginationEdit","attributes","paginationArrow","layout","setAttributes","clientId","name","usedLayout","hasNextPreviousBlocks","select","getBlocks","innerBlocks","find","innerBlock","includes","blockProps","innerBlocksProps","template","allowedBlocks","__experimentalLayout","pageComments","getSettings","__experimentalDiscussionSettings","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,KAAK,IAAIC,gBAJV,EAKCC,OALD,QAMO,yBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,SAAT,QAA0B,uBAA1B;AAEA;AACA;AACA;;AACA,SAASC,+BAAT,QAAgD,sCAAhD;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,mCAAF,CADgB,EAEhB,CAAE,kCAAF,CAFgB,EAGhB,CAAE,+BAAF,CAHgB,CAAjB;;AAMA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAGN,eAAe,CAC/CK,eAD+C,EAE/C,sBAF+C,CAAhD;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,wBAAwB,CAAEC,OAAjC;AACA,CAND;;AAQA,eAAe,SAASC,mBAAT,OAKX;AAAA,MALyC;AAC5CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,KADgC;AAE5CC,IAAAA,aAF4C;AAG5CC,IAAAA,QAH4C;AAI5CC,IAAAA;AAJ4C,GAKzC;AACH,QAAMC,UAAU,GAAGJ,MAAM,IAAIP,qBAAqB,CAAEU,IAAF,CAAlD;AACA,QAAME,qBAAqB,GAAGjB,SAAS,CAAIkB,MAAF,IAAc;AACtD,UAAM;AAAEC,MAAAA;AAAF,QAAgBD,MAAM,CAAEpB,gBAAF,CAA5B;AACA,UAAMsB,WAAW,GAAGD,SAAS,CAAEL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,CAFF,EAaC,qBAAUP,gBAAV,CAbD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comments-pagination-previous' ],\n\t[ 'core/comments-pagination-numbers' ],\n\t[ 'core/comments-pagination-next' ],\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport default function QueryPaginationEdit( {\n\tattributes: { paginationArrow, layout },\n\tsetAttributes,\n\tclientId,\n\tname,\n} ) {\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\tconst hasNextPreviousBlocks = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst innerBlocks = getBlocks( clientId );\n\t\t/**\n\t\t * Show the `paginationArrow` control only if a\n\t\t * Comments Pagination Next or Comments Pagination Previous\n\t\t * block exists.\n\t\t */\n\t\treturn innerBlocks?.find( ( innerBlock ) => {\n\t\t\treturn [\n\t\t\t\t'core/comments-pagination-previous',\n\t\t\t\t'core/comments-pagination-next',\n\t\t\t].includes( innerBlock.name );\n\t\t} );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\tallowedBlocks: [\n\t\t\t'core/comments-pagination-previous',\n\t\t\t'core/comments-pagination-numbers',\n\t\t\t'core/comments-pagination-next',\n\t\t],\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\t// Get the Discussion settings\n\tconst pageComments = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings?.pageComments;\n\t}, [] );\n\n\t// If paging comments is not enabled in the Discussion Settings then hide the pagination\n\t// controls. We don't want to remove them from the template so that when the user enables\n\t// paging comments, the controls will be visible.\n\tif ( ! pageComments ) {\n\t\treturn (\n\t\t\t<Warning>\n\t\t\t\t{ __(\n\t\t\t\t\t'Comments Pagination block: paging comments is disabled in the Discussion Settings'\n\t\t\t\t) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ hasNextPreviousBlocks && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<CommentsPaginationArrowControls\n\t\t\t\t\t\t\tvalue={ paginationArrow }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
@@ -9,7 +9,7 @@ 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/columns', {}, [['core/column', {
12
+ const TEMPLATE = [['core/comments-title'], ['core/comment-template', {}, [['core/columns', {}, [['core/column', {
13
13
  width: '40px'
14
14
  }, [['core/avatar', {
15
15
  size: 40,
@@ -1 +1 @@
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"]}
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,CAAE,qBAAF,CADgB,EAEhB,CACC,uBADD,EAEC,EAFD,EAGC,CACC,CACC,cADD,EAEC,EAFD,EAGC,CACC,C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@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comments-title' ],\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"]}
@@ -0,0 +1,133 @@
1
+ import { createElement, Fragment } from "@wordpress/element";
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import classnames from 'classnames';
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+
11
+ import { AlignmentControl, BlockControls, useBlockProps, PlainText, InspectorControls } from '@wordpress/block-editor';
12
+ import { __ } from '@wordpress/i18n';
13
+ import { useEntityProp } from '@wordpress/core-data';
14
+ import { PanelBody, ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption } from '@wordpress/components';
15
+ import { useState, useEffect } from '@wordpress/element';
16
+ import apiFetch from '@wordpress/api-fetch';
17
+ import { addQueryArgs } from '@wordpress/url';
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ import HeadingLevelDropdown from '../heading/heading-level-dropdown';
23
+ export default function Edit(_ref) {
24
+ let {
25
+ attributes: {
26
+ textAlign,
27
+ singleCommentLabel,
28
+ multipleCommentsLabel,
29
+ showPostTitle,
30
+ showCommentsCount,
31
+ level
32
+ },
33
+ setAttributes,
34
+ context: {
35
+ postType,
36
+ postId
37
+ }
38
+ } = _ref;
39
+ const TagName = 'h' + level;
40
+ const [commentsCount, setCommentsCount] = useState();
41
+ const [editingMode, setEditingMode] = useState('plural');
42
+ const [rawTitle] = useEntityProp('postType', postType, 'title', postId);
43
+ const isSiteEditor = typeof postId === 'undefined';
44
+ const blockProps = useBlockProps({
45
+ className: classnames({
46
+ [`has-text-align-${textAlign}`]: textAlign
47
+ })
48
+ });
49
+ useEffect(() => {
50
+ if (isSiteEditor) {
51
+ setCommentsCount(3);
52
+ return;
53
+ }
54
+
55
+ const currentPostId = postId;
56
+ apiFetch({
57
+ path: addQueryArgs('/wp/v2/comments', {
58
+ post: postId,
59
+ _fields: 'id'
60
+ }),
61
+ method: 'HEAD',
62
+ parse: false
63
+ }).then(res => {
64
+ // Stale requests will have the `currentPostId` of an older closure.
65
+ if (currentPostId === postId) {
66
+ setCommentsCount(parseInt(res.headers.get('X-WP-Total')));
67
+ }
68
+ }).catch(() => {
69
+ setCommentsCount(0);
70
+ });
71
+ }, [postId]);
72
+ const blockControls = createElement(BlockControls, {
73
+ group: "block"
74
+ }, createElement(AlignmentControl, {
75
+ value: textAlign,
76
+ onChange: newAlign => setAttributes({
77
+ textAlign: newAlign
78
+ })
79
+ }), createElement(HeadingLevelDropdown, {
80
+ selectedLevel: level,
81
+ onChange: newLevel => setAttributes({
82
+ level: newLevel
83
+ })
84
+ }));
85
+ const inspectorControls = createElement(InspectorControls, null, createElement(PanelBody, {
86
+ title: __('Settings')
87
+ }, isSiteEditor && createElement(ToggleGroupControl, {
88
+ label: __('Editing mode'),
89
+ onChange: setEditingMode,
90
+ value: editingMode
91
+ }, createElement(ToggleGroupControlOption, {
92
+ label: __('Singular'),
93
+ value: "singular"
94
+ }), createElement(ToggleGroupControlOption, {
95
+ label: __('Plural'),
96
+ value: "plural"
97
+ })), createElement(ToggleControl, {
98
+ label: __('Show post title'),
99
+ checked: showPostTitle,
100
+ onChange: value => setAttributes({
101
+ showPostTitle: value
102
+ })
103
+ }), createElement(ToggleControl, {
104
+ label: __('Show comments count'),
105
+ checked: showCommentsCount,
106
+ onChange: value => setAttributes({
107
+ showCommentsCount: value
108
+ })
109
+ })));
110
+ const postTitle = isSiteEditor ? __('"Post Title"') : `"${rawTitle}"`;
111
+ const singlePlaceholder = showPostTitle ? __('One response to ') : __('One response');
112
+ const multiplePlaceholder = showPostTitle ? __('Responses to ') : __('Responses');
113
+ return createElement(Fragment, null, blockControls, inspectorControls, createElement(TagName, blockProps, editingMode === 'singular' || commentsCount === 1 ? createElement(Fragment, null, createElement(PlainText, {
114
+ __experimentalVersion: 2,
115
+ tagName: "span",
116
+ "aria-label": singlePlaceholder,
117
+ placeholder: singlePlaceholder,
118
+ value: singleCommentLabel,
119
+ onChange: newLabel => setAttributes({
120
+ singleCommentLabel: newLabel
121
+ })
122
+ }), showPostTitle ? postTitle : null) : createElement(Fragment, null, showCommentsCount ? commentsCount : null, createElement(PlainText, {
123
+ __experimentalVersion: 2,
124
+ tagName: "span",
125
+ "aria-label": showCommentsCount ? ` ${multiplePlaceholder}` : multiplePlaceholder,
126
+ placeholder: showCommentsCount ? ` ${multiplePlaceholder}` : multiplePlaceholder,
127
+ value: multipleCommentsLabel,
128
+ onChange: newLabel => setAttributes({
129
+ multipleCommentsLabel: newLabel
130
+ })
131
+ }), showPostTitle ? postTitle : null)));
132
+ }
133
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["classnames","AlignmentControl","BlockControls","useBlockProps","PlainText","InspectorControls","__","useEntityProp","PanelBody","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useState","useEffect","apiFetch","addQueryArgs","HeadingLevelDropdown","Edit","attributes","textAlign","singleCommentLabel","multipleCommentsLabel","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","editingMode","setEditingMode","rawTitle","isSiteEditor","blockProps","className","currentPostId","path","post","_fields","method","parse","then","res","parseInt","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","singlePlaceholder","multiplePlaceholder","newLabel"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,aAFD,EAGCC,aAHD,EAICC,SAJD,EAKCC,iBALD,QAMO,yBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SACCC,SADD,EAECC,aAFD,EAGCC,gCAAgC,IAAIC,kBAHrC,EAICC,sCAAsC,IAAIC,wBAJ3C,QAKO,uBALP;AAMA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,mCAAjC;AAEA,eAAe,SAASC,IAAT,OAWX;AAAA,MAX0B;AAC7BC,IAAAA,UAAU,EAAE;AACXC,MAAAA,SADW;AAEXC,MAAAA,kBAFW;AAGXC,MAAAA,qBAHW;AAIXC,MAAAA,aAJW;AAKXC,MAAAA,iBALW;AAMXC,MAAAA;AANW,KADiB;AAS7BC,IAAAA,aAT6B;AAU7BC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AAVoB,GAW1B;AACH,QAAMC,OAAO,GAAG,MAAML,KAAtB;AACA,QAAM,CAAEM,aAAF,EAAiBC,gBAAjB,IAAsCnB,QAAQ,EAApD;AACA,QAAM,CAAEoB,WAAF,EAAeC,cAAf,IAAkCrB,QAAQ,CAAE,QAAF,CAAhD;AACA,QAAM,CAAEsB,QAAF,IAAe7B,aAAa,CAAE,UAAF,EAAcsB,QAAd,EAAwB,OAAxB,EAAiCC,MAAjC,CAAlC;AACA,QAAMO,YAAY,GAAG,OAAOP,MAAP,KAAkB,WAAvC;AACA,QAAMQ,UAAU,GAAGnC,aAAa,CAAE;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,EAAcjB,UAAd,EACGJ,WAAW,KAAK,UAAhB,IAA8BF,aAAa,KAAK,CAAhD,GACD,8BACC,cAAC,SAAD;AACC,IAAA,qBAAqB,EAAG,CADzB;AAEC,IAAA,OAAO,EAAC,MAFT;AAGC,kBAAa0B,iBAHd;AAIC,IAAA,WAAW,EAAGA,iBAJf;AAKC,IAAA,KAAK,EAAGpC,kBALT;AAMC,IAAA,QAAQ,EAAKsC,QAAF,IACVjC,aAAa,CAAE;AACdL,MAAAA,kBAAkB,EAAEsC;AADN,KAAF;AAPf,IADD,EAaGpC,aAAa,GAAGiC,SAAH,GAAe,IAb/B,CADC,GAiBD,8BACGhC,iBAAiB,GAAGO,aAAH,GAAmB,IADvC,EAEC,cAAC,SAAD;AACC,IAAA,qBAAqB,EAAG,CADzB;AAEC,IAAA,OAAO,EAAC,MAFT;AAGC,kBACCP,iBAAiB,GACb,IAAIkC,mBAAqB,EADZ,GAEdA,mBANL;AAQC,IAAA,WAAW,EACVlC,iBAAiB,GACb,IAAIkC,mBAAqB,EADZ,GAEdA,mBAXL;AAaC,IAAA,KAAK,EAAGpC,qBAbT;AAcC,IAAA,QAAQ,EAAKqC,QAAF,IACVjC,aAAa,CAAE;AACdJ,MAAAA,qBAAqB,EAAEqC;AADT,KAAF;AAff,IAFD,EAsBGpC,aAAa,GAAGiC,SAAH,GAAe,IAtB/B,CAlBF,CAHD,CADD;AAkDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tPlainText,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport {\n\tPanelBody,\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: {\n\t\ttextAlign,\n\t\tsingleCommentLabel,\n\t\tmultipleCommentsLabel,\n\t\tshowPostTitle,\n\t\tshowCommentsCount,\n\t\tlevel,\n\t},\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ editingMode, setEditingMode ] = useState( 'plural' );\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\tsetCommentsCount( 3 );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t{ isSiteEditor && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tlabel={ __( 'Editing mode' ) }\n\t\t\t\t\t\tonChange={ setEditingMode }\n\t\t\t\t\t\tvalue={ editingMode }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tlabel={ __( 'Singular' ) }\n\t\t\t\t\t\t\tvalue=\"singular\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tlabel={ __( 'Plural' ) }\n\t\t\t\t\t\t\tvalue=\"plural\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '\"Post Title\"' ) : `\"${ rawTitle }\"`;\n\n\tconst singlePlaceholder = showPostTitle\n\t\t? __( 'One response to ' )\n\t\t: __( 'One response' );\n\n\tconst multiplePlaceholder = showPostTitle\n\t\t? __( 'Responses to ' )\n\t\t: __( 'Responses' );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t{ editingMode === 'singular' || commentsCount === 1 ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\taria-label={ singlePlaceholder }\n\t\t\t\t\t\t\tplaceholder={ singlePlaceholder }\n\t\t\t\t\t\t\tvalue={ singleCommentLabel }\n\t\t\t\t\t\t\tonChange={ ( newLabel ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tsingleCommentLabel: newLabel,\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{ showPostTitle ? postTitle : null }\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ showCommentsCount ? commentsCount : null }\n\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\tshowCommentsCount\n\t\t\t\t\t\t\t\t\t? ` ${ multiplePlaceholder }`\n\t\t\t\t\t\t\t\t\t: multiplePlaceholder\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\tshowCommentsCount\n\t\t\t\t\t\t\t\t\t? ` ${ multiplePlaceholder }`\n\t\t\t\t\t\t\t\t\t: multiplePlaceholder\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ multipleCommentsLabel }\n\t\t\t\t\t\t\tonChange={ ( newLabel ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmultipleCommentsLabel: newLabel,\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{ showPostTitle ? postTitle : null }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</TagName>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { commentTitle as icon } from '@wordpress/icons';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ const metadata = {
10
+ $schema: "https://schemas.wp.org/trunk/block.json",
11
+ apiVersion: 2,
12
+ name: "core/comments-title",
13
+ title: "Comments Title",
14
+ category: "theme",
15
+ ancestor: ["core/comments-query-loop"],
16
+ description: "Displays a title with the number of comments",
17
+ textdomain: "default",
18
+ usesContext: ["postId", "postType"],
19
+ attributes: {
20
+ textAlign: {
21
+ type: "string"
22
+ },
23
+ singleCommentLabel: {
24
+ type: "string"
25
+ },
26
+ multipleCommentsLabel: {
27
+ type: "string"
28
+ },
29
+ showPostTitle: {
30
+ type: "boolean",
31
+ "default": true
32
+ },
33
+ showCommentsCount: {
34
+ type: "boolean",
35
+ "default": true
36
+ },
37
+ level: {
38
+ type: "number",
39
+ "default": 2
40
+ }
41
+ },
42
+ supports: {
43
+ anchor: false,
44
+ align: true,
45
+ html: false,
46
+ __experimentalBorder: {
47
+ radius: true,
48
+ color: true,
49
+ width: true,
50
+ style: true
51
+ },
52
+ color: {
53
+ gradients: true,
54
+ __experimentalDefaultControls: {
55
+ background: true,
56
+ text: true
57
+ }
58
+ },
59
+ spacing: {
60
+ margin: true,
61
+ padding: true
62
+ },
63
+ typography: {
64
+ fontSize: true,
65
+ lineHeight: true,
66
+ __experimentalFontStyle: true,
67
+ __experimentalFontWeight: true,
68
+ __experimentalFontFamily: true,
69
+ __experimentalTextTransform: true,
70
+ __experimentalDefaultControls: {
71
+ fontSize: true,
72
+ __experimentalFontFamily: true,
73
+ __experimentalFontStyle: true,
74
+ __experimentalFontWeight: true
75
+ }
76
+ }
77
+ }
78
+ };
79
+ import edit from './edit';
80
+ const {
81
+ name
82
+ } = metadata;
83
+ export { metadata, name };
84
+ export const settings = {
85
+ icon,
86
+ edit
87
+ };
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-title/index.js"],"names":["commentTitle","icon","edit","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;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 { commentTitle 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"]}