@wordpress/block-library 7.3.2 → 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 (266) 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 +1 -1
  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/hooks.js +11 -3
  15. package/build/comment-template/hooks.js.map +1 -1
  16. package/build/comments-pagination/edit.js +18 -1
  17. package/build/comments-pagination/edit.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -1
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-title/edit.js +149 -0
  21. package/build/comments-title/edit.js.map +1 -0
  22. package/build/comments-title/index.js +101 -0
  23. package/build/comments-title/index.js.map +1 -0
  24. package/build/embed/edit.js +12 -18
  25. package/build/embed/edit.js.map +1 -1
  26. package/build/embed/edit.native.js +1 -7
  27. package/build/embed/edit.native.js.map +1 -1
  28. package/build/embed/util.js +29 -4
  29. package/build/embed/util.js.map +1 -1
  30. package/build/file/inspector.js +2 -4
  31. package/build/file/inspector.js.map +1 -1
  32. package/build/gallery/edit.js +1 -1
  33. package/build/gallery/edit.js.map +1 -1
  34. package/build/gallery/v1/edit.js +1 -1
  35. package/build/gallery/v1/edit.js.map +1 -1
  36. package/build/html/edit.js +2 -2
  37. package/build/html/edit.js.map +1 -1
  38. package/build/image/edit.js +4 -6
  39. package/build/image/edit.js.map +1 -1
  40. package/build/image/edit.native.js +1 -1
  41. package/build/image/edit.native.js.map +1 -1
  42. package/build/image/image.js +1 -1
  43. package/build/image/image.js.map +1 -1
  44. package/build/index.js +3 -1
  45. package/build/index.js.map +1 -1
  46. package/build/index.native.js +14 -3
  47. package/build/index.native.js.map +1 -1
  48. package/build/latest-comments/edit.js +1 -1
  49. package/build/latest-comments/edit.js.map +1 -1
  50. package/build/loginout/edit.js +1 -1
  51. package/build/loginout/edit.js.map +1 -1
  52. package/build/media-text/edit.js +1 -2
  53. package/build/media-text/edit.js.map +1 -1
  54. package/build/media-text/edit.native.js +1 -1
  55. package/build/media-text/edit.native.js.map +1 -1
  56. package/build/navigation/edit/index.js +17 -1
  57. package/build/navigation/edit/index.js.map +1 -1
  58. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  59. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  60. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  61. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  62. package/build/navigation/index.js +1 -1
  63. package/build/navigation/view-modal.js +37 -0
  64. package/build/navigation/view-modal.js.map +1 -0
  65. package/build/navigation/view.js +1 -34
  66. package/build/navigation/view.js.map +1 -1
  67. package/build/paragraph/edit.native.js +6 -2
  68. package/build/paragraph/edit.native.js.map +1 -1
  69. package/build/post-author/edit.js +1 -1
  70. package/build/post-author/edit.js.map +1 -1
  71. package/build/post-excerpt/edit.js +1 -1
  72. package/build/post-excerpt/edit.js.map +1 -1
  73. package/build/quote/index.js +6 -0
  74. package/build/quote/index.js.map +1 -1
  75. package/build/quote/v2/edit.js +11 -3
  76. package/build/quote/v2/edit.js.map +1 -1
  77. package/build/rss/edit.js +1 -1
  78. package/build/rss/edit.js.map +1 -1
  79. package/build/search/edit.js +11 -9
  80. package/build/search/edit.js.map +1 -1
  81. package/build/spacer/constants.js +9 -0
  82. package/build/spacer/constants.js.map +1 -0
  83. package/build/spacer/controls.js +3 -3
  84. package/build/spacer/controls.js.map +1 -1
  85. package/build/spacer/controls.native.js +2 -2
  86. package/build/spacer/controls.native.js.map +1 -1
  87. package/build/spacer/edit.js +5 -6
  88. package/build/spacer/edit.js.map +1 -1
  89. package/build/table/edit.js +8 -2
  90. package/build/table/edit.js.map +1 -1
  91. package/build/tag-cloud/edit.js +1 -1
  92. package/build/tag-cloud/edit.js.map +1 -1
  93. package/build/video/edit.js +1 -1
  94. package/build/video/edit.js.map +1 -1
  95. package/build/video/edit.native.js +1 -1
  96. package/build/video/edit.native.js.map +1 -1
  97. package/build-module/archives/edit.js +1 -1
  98. package/build-module/archives/edit.js.map +1 -1
  99. package/build-module/audio/edit.js +1 -1
  100. package/build-module/audio/edit.js.map +1 -1
  101. package/build-module/audio/edit.native.js +1 -1
  102. package/build-module/audio/edit.native.js.map +1 -1
  103. package/build-module/categories/edit.js +8 -3
  104. package/build-module/categories/edit.js.map +1 -1
  105. package/build-module/categories/index.js +4 -0
  106. package/build-module/categories/index.js.map +1 -1
  107. package/build-module/column/index.js +10 -0
  108. package/build-module/column/index.js.map +1 -1
  109. package/build-module/comment-template/hooks.js +11 -3
  110. package/build-module/comment-template/hooks.js.map +1 -1
  111. package/build-module/comments-pagination/edit.js +19 -2
  112. package/build-module/comments-pagination/edit.js.map +1 -1
  113. package/build-module/comments-query-loop/edit.js +1 -1
  114. package/build-module/comments-query-loop/edit.js.map +1 -1
  115. package/build-module/comments-title/edit.js +133 -0
  116. package/build-module/comments-title/edit.js.map +1 -0
  117. package/build-module/comments-title/index.js +88 -0
  118. package/build-module/comments-title/index.js.map +1 -0
  119. package/build-module/embed/edit.js +13 -19
  120. package/build-module/embed/edit.js.map +1 -1
  121. package/build-module/embed/edit.native.js +2 -8
  122. package/build-module/embed/edit.native.js.map +1 -1
  123. package/build-module/embed/util.js +25 -3
  124. package/build-module/embed/util.js.map +1 -1
  125. package/build-module/file/inspector.js +2 -4
  126. package/build-module/file/inspector.js.map +1 -1
  127. package/build-module/gallery/edit.js +1 -1
  128. package/build-module/gallery/edit.js.map +1 -1
  129. package/build-module/gallery/v1/edit.js +1 -1
  130. package/build-module/gallery/v1/edit.js.map +1 -1
  131. package/build-module/html/edit.js +2 -2
  132. package/build-module/html/edit.js.map +1 -1
  133. package/build-module/image/edit.js +4 -6
  134. package/build-module/image/edit.js.map +1 -1
  135. package/build-module/image/edit.native.js +1 -1
  136. package/build-module/image/edit.native.js.map +1 -1
  137. package/build-module/image/image.js +1 -1
  138. package/build-module/image/image.js.map +1 -1
  139. package/build-module/index.js +2 -1
  140. package/build-module/index.js.map +1 -1
  141. package/build-module/index.native.js +14 -3
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/latest-comments/edit.js +1 -1
  144. package/build-module/latest-comments/edit.js.map +1 -1
  145. package/build-module/loginout/edit.js +1 -1
  146. package/build-module/loginout/edit.js.map +1 -1
  147. package/build-module/media-text/edit.js +1 -2
  148. package/build-module/media-text/edit.js.map +1 -1
  149. package/build-module/media-text/edit.native.js +1 -1
  150. package/build-module/media-text/edit.native.js.map +1 -1
  151. package/build-module/navigation/edit/index.js +17 -1
  152. package/build-module/navigation/edit/index.js.map +1 -1
  153. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  154. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  155. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  156. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  157. package/build-module/navigation/index.js +1 -1
  158. package/build-module/navigation/view-modal.js +32 -0
  159. package/build-module/navigation/view-modal.js.map +1 -0
  160. package/build-module/navigation/view.js +1 -30
  161. package/build-module/navigation/view.js.map +1 -1
  162. package/build-module/paragraph/edit.native.js +6 -2
  163. package/build-module/paragraph/edit.native.js.map +1 -1
  164. package/build-module/post-author/edit.js +1 -1
  165. package/build-module/post-author/edit.js.map +1 -1
  166. package/build-module/post-excerpt/edit.js +1 -1
  167. package/build-module/post-excerpt/edit.js.map +1 -1
  168. package/build-module/quote/index.js +1 -1
  169. package/build-module/quote/index.js.map +1 -1
  170. package/build-module/quote/v2/edit.js +10 -3
  171. package/build-module/quote/v2/edit.js.map +1 -1
  172. package/build-module/rss/edit.js +1 -1
  173. package/build-module/rss/edit.js.map +1 -1
  174. package/build-module/search/edit.js +11 -9
  175. package/build-module/search/edit.js.map +1 -1
  176. package/build-module/spacer/constants.js +2 -0
  177. package/build-module/spacer/constants.js.map +1 -0
  178. package/build-module/spacer/controls.js +2 -2
  179. package/build-module/spacer/controls.js.map +1 -1
  180. package/build-module/spacer/controls.native.js +1 -1
  181. package/build-module/spacer/controls.native.js.map +1 -1
  182. package/build-module/spacer/edit.js +1 -1
  183. package/build-module/spacer/edit.js.map +1 -1
  184. package/build-module/table/edit.js +9 -3
  185. package/build-module/table/edit.js.map +1 -1
  186. package/build-module/tag-cloud/edit.js +1 -1
  187. package/build-module/tag-cloud/edit.js.map +1 -1
  188. package/build-module/video/edit.js +1 -1
  189. package/build-module/video/edit.js.map +1 -1
  190. package/build-module/video/edit.native.js +1 -1
  191. package/build-module/video/edit.native.js.map +1 -1
  192. package/build-style/comments-title/editor-rtl.css +79 -0
  193. package/build-style/comments-title/editor.css +79 -0
  194. package/build-style/common-rtl.css +32 -0
  195. package/build-style/common.css +32 -0
  196. package/build-style/editor-rtl.css +12 -0
  197. package/build-style/editor.css +12 -0
  198. package/build-style/post-comments-form/style-rtl.css +9 -0
  199. package/build-style/post-comments-form/style.css +9 -0
  200. package/build-style/style-rtl.css +79 -0
  201. package/build-style/style.css +79 -0
  202. package/build-style/table/editor-rtl.css +8 -0
  203. package/build-style/table/editor.css +8 -0
  204. package/build-style/table/style-rtl.css +38 -0
  205. package/build-style/table/style.css +38 -0
  206. package/package.json +28 -28
  207. package/src/archives/edit.js +1 -1
  208. package/src/audio/edit.js +1 -1
  209. package/src/audio/edit.native.js +1 -1
  210. package/src/categories/block.json +4 -0
  211. package/src/categories/edit.js +8 -2
  212. package/src/categories/index.php +1 -0
  213. package/src/column/block.json +10 -0
  214. package/src/comment-template/hooks.js +13 -1
  215. package/src/comment-template/index.php +13 -4
  216. package/src/comments-pagination/edit.js +23 -0
  217. package/src/comments-query-loop/edit.js +1 -0
  218. package/src/comments-title/block.json +70 -0
  219. package/src/comments-title/edit.js +197 -0
  220. package/src/comments-title/editor.scss +4 -0
  221. package/src/comments-title/index.js +18 -0
  222. package/src/comments-title/index.php +68 -0
  223. package/src/common.scss +24 -1
  224. package/src/editor.scss +1 -0
  225. package/src/embed/edit.js +19 -24
  226. package/src/embed/edit.native.js +9 -14
  227. package/src/embed/util.js +34 -2
  228. package/src/file/inspector.js +1 -3
  229. package/src/gallery/edit.js +1 -1
  230. package/src/gallery/v1/edit.js +1 -1
  231. package/src/html/edit.js +2 -2
  232. package/src/image/edit.js +2 -4
  233. package/src/image/edit.native.js +1 -1
  234. package/src/image/image.js +1 -1
  235. package/src/index.js +3 -0
  236. package/src/index.native.js +12 -2
  237. package/src/latest-comments/edit.js +1 -1
  238. package/src/loginout/edit.js +1 -1
  239. package/src/media-text/edit.js +1 -2
  240. package/src/media-text/edit.native.js +1 -1
  241. package/src/navigation/block.json +1 -1
  242. package/src/navigation/edit/index.js +24 -0
  243. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  244. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  245. package/src/navigation/index.php +5 -0
  246. package/src/navigation/view-modal.js +36 -0
  247. package/src/navigation/view.js +0 -35
  248. package/src/paragraph/edit.native.js +13 -1
  249. package/src/post-author/edit.js +1 -1
  250. package/src/post-comments-form/style.scss +11 -0
  251. package/src/post-excerpt/edit.js +1 -1
  252. package/src/quote/index.js +1 -1
  253. package/src/quote/v2/edit.js +3 -0
  254. package/src/rss/edit.js +1 -1
  255. package/src/search/edit.js +13 -7
  256. package/src/search/index.php +84 -33
  257. package/src/spacer/constants.js +1 -0
  258. package/src/spacer/controls.js +2 -2
  259. package/src/spacer/controls.native.js +1 -1
  260. package/src/spacer/edit.js +1 -2
  261. package/src/table/edit.js +11 -2
  262. package/src/table/editor.scss +13 -0
  263. package/src/table/style.scss +52 -0
  264. package/src/tag-cloud/edit.js +1 -1
  265. package/src/video/edit.js +1 -1
  266. package/src/video/edit.native.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["classnames","getBlobByURL","isBlobURL","Disabled","PanelBody","SelectControl","Spinner","ToggleControl","withNotices","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","useEffect","__","_x","useSelect","audio","icon","createBlock","createUpgradedEmbedBlock","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","noticeOperations","setAttributes","onReplace","isSelected","noticeUI","insertBlocksAfter","id","autoplay","caption","loop","preload","src","isTemporaryAudio","mediaUpload","select","getSettings","file","filesList","onFileChange","mediaId","url","onError","e","undefined","createErrorNotice","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","onUploadError","message","removeAllNotices","getAutoplayHelp","checked","onSelectAudio","media","classes","blockProps","value","label","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SACCC,QADD,EAECC,SAFD,EAGCC,aAHD,EAICC,OAJD,EAKCC,aALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,aADD,EAECC,SAFD,EAGCC,iBAHD,EAICC,gBAJD,EAKCC,gBALD,EAMCC,QAND,EAOCC,aAPD,EAQCC,KAAK,IAAIC,gBARV,QASO,yBATP;AAUA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,IAAlB,QAA8B,kBAA9B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,eAAzC;AAEA,MAAMC,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT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AC2D,OAAT,CAAkBnC,OAAlB,CAAF,IAAiCL,UAAnC,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAad,EAAE,CAAE,oBAAF,CAFhB;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CAHjB;AAIC,IAAA,KAAK,EAAGmB,OAJT;AAKC,IAAA,QAAQ,EAAKiC,KAAF,IACVxC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEiC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxBpC,iBAAiB,CAAEX,WAAW,CAAE,gBAAF,CAAb;AAVnB,IAXF,CA9CD,CADD;AA2EA;;AACD,eAAehB,WAAW,CAAEmB,SAAF,CAA1B","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tnoticeOperations,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tnoticeUI,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { id: mediaId, url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { id: mediaId, src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( e ) => {\n\t\t\t\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( e );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Audio settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', 'Preload value' ),\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\nexport default withNotices( AudioEdit );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["classnames","getBlobByURL","isBlobURL","Disabled","PanelBody","SelectControl","Spinner","ToggleControl","withNotices","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","useEffect","__","_x","useSelect","audio","icon","createBlock","createUpgradedEmbedBlock","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","noticeOperations","setAttributes","onReplace","isSelected","noticeUI","insertBlocksAfter","id","autoplay","caption","loop","preload","src","isTemporaryAudio","mediaUpload","select","getSettings","file","filesList","onFileChange","mediaId","url","onError","e","undefined","createErrorNotice","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","onUploadError","message","removeAllNotices","getAutoplayHelp","checked","onSelectAudio","media","classes","blockProps","value","label","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SACCC,QADD,EAECC,SAFD,EAGCC,aAHD,EAICC,OAJD,EAKCC,aALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,aADD,EAECC,SAFD,EAGCC,iBAHD,EAICC,gBAJD,EAKCC,gBALD,EAMCC,QAND,EAOCC,aAPD,EAQCC,KAAK,IAAIC,gBARV,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,MAAAA,KAAK,EAAEpD,EAAE,CAAE,MAAF,EAAU,eAAV;AAFV,KAJS;AATX,IAZD,CADD,CAZD,EA8CC,wBAAakD,UAAb,EAMC,cAAC,QAAD;AAAU,IAAA,UAAU,EAAG,CAAErC;AAAzB,KACC;AAAO,IAAA,QAAQ,EAAC,UAAhB;AAA2B,IAAA,GAAG,EAAGQ;AAAjC,IADD,CAND,EASGC,gBAAgB,IAAI,cAAC,OAAD,OATvB,EAUG,CAAE,CAAE5B,QAAQ,CAAC2D,OAAT,CAAkBnC,OAAlB,CAAF,IAAiCL,UAAnC,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAad,EAAE,CAAE,oBAAF,CAFhB;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CAHjB;AAIC,IAAA,KAAK,EAAGmB,OAJT;AAKC,IAAA,QAAQ,EAAKiC,KAAF,IACVxC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEiC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxBpC,iBAAiB,CAAEX,WAAW,CAAE,gBAAF,CAAb;AAVnB,IAXF,CA9CD,CADD;AA2EA;;AACD,eAAehB,WAAW,CAAEmB,SAAF,CAA1B","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tnoticeOperations,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tnoticeUI,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { id: mediaId, url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { id: mediaId, src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( e ) => {\n\t\t\t\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( e );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', 'Preload value' ),\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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\nexport default withNotices( AudioEdit );\n"]}
@@ -167,7 +167,7 @@ function AudioEdit(_ref) {
167
167
  onPress: onAudioPress,
168
168
  disabled: !isSelected
169
169
  }, createElement(View, null, createElement(InspectorControls, null, createElement(PanelBody, {
170
- title: __('Audio settings')
170
+ title: __('Settings')
171
171
  }, createElement(ToggleControl, {
172
172
  label: __('Autoplay'),
173
173
  onChange: toggleAttribute('autoplay'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/audio/edit.native.js"],"names":["TouchableWithoutFeedback","isEmpty","View","PanelBody","SelectControl","ToggleControl","ToolbarButton","ToolbarGroup","AudioPlayer","BlockCaption","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadProgress","store","blockEditorStore","__","_x","sprintf","audio","icon","replace","useState","useDispatch","useSelect","noticesStore","isURL","styles","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","select","createErrorNotice","toggleAttribute","attribute","newValue","onSelectURL","newSrc","undefined","onSelectAudio","media","url","onAudioPress","onFocusCaption","getBlockControls","open","getBlockUI","getMediaOptions","progressContainer","progressBar","spinner","isUploadInProgress","isUploadFailed","retryMessage","value","label","caption"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,wBAAT,QAAyC,cAAzC;AACA,SAASC,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SACCC,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,aAJD,EAKCC,YALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,YADD,EAECC,aAFD,EAGCC,SAHD,EAICC,iBAJD,EAKCC,gBALD,EAMCC,WAND,EAOCC,mBAPD,EAQCC,KAAK,IAAIC,gBARV,QASO,yBATP;AAUA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,KAAK,IAAIC,IAAlB,EAAwBC,OAAxB,QAAuC,kBAAvC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASV,KAAK,IAAIW,YAAlB,QAAsC,oBAAtC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OAQI;AAAA,MARgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,aAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,iBAJmB;AAKnBC,IAAAA,OALmB;AAMnBC,IAAAA,MANmB;AAOnBC,IAAAA;AAPmB,GAQhB;AACH,QAAM;AAAEC,IA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,CAAE,sBAAF,CAFL,GAGGE,OAAO;AACP;AACAF,IAAAA,EAAE,CAAE,mBAAF,CAFK,EAGPyD,OAHO,CANZ;AAYC,IAAA,QAAQ,EAAGrC,QAZZ;AAaC,IAAA,UAAU,EAAGM,iBAbd;AAcC,IAAA,OAAO,EAAGkB,cAdX;AAeC,IAAA,MAAM,EAAGzB,MAfV;AAgBC,IAAA,iBAAiB,EAAGF;AAhBrB,IAlDD,CALD,CADD;AA6EA;;AACD,eAAeJ,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\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} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Audio settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" value' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\tisEmpty( caption )\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/audio/edit.native.js"],"names":["TouchableWithoutFeedback","isEmpty","View","PanelBody","SelectControl","ToggleControl","ToolbarButton","ToolbarGroup","AudioPlayer","BlockCaption","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadProgress","store","blockEditorStore","__","_x","sprintf","audio","icon","replace","useState","useDispatch","useSelect","noticesStore","isURL","styles","ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","select","createErrorNotice","toggleAttribute","attribute","newValue","onSelectURL","newSrc","undefined","onSelectAudio","media","url","onAudioPress","onFocusCaption","getBlockControls","open","getBlockUI","getMediaOptions","progressContainer","progressBar","spinner","isUploadInProgress","isUploadFailed","retryMessage","value","label","caption"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,wBAAT,QAAyC,cAAzC;AACA,SAASC,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SACCC,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,aAJD,EAKCC,YALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,YADD,EAECC,aAFD,EAGCC,SAHD,EAICC,iBAJD,EAKCC,gBALD,EAMCC,WAND,EAOCC,mBAPD,EAQCC,KAAK,IAAIC,gBARV,QASO,yBATP;AAUA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,KAAK,IAAIC,IAAlB,EAAwBC,OAAxB,QAAuC,kBAAvC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASV,KAAK,IAAIW,YAAlB,QAAsC,oBAAtC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OAQI;AAAA,MARgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,aAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,iBAJmB;AAKnBC,IAAAA,OALmB;AAMnBC,IAAAA,MANmB;AAOnBC,IAAAA;AAPmB,GAQhB;AACH,Q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,IAAAA,EAAE,CAAE,sBAAF,CAFL,GAGGE,OAAO;AACP;AACAF,IAAAA,EAAE,CAAE,mBAAF,CAFK,EAGPyD,OAHO,CANZ;AAYC,IAAA,QAAQ,EAAGrC,QAZZ;AAaC,IAAA,UAAU,EAAGM,iBAbd;AAcC,IAAA,OAAO,EAAGkB,cAdX;AAeC,IAAA,MAAM,EAAGzB,MAfV;AAgBC,IAAA,iBAAiB,EAAGF;AAhBrB,IAlDD,CALD,CADD;AA6EA;;AACD,eAAeJ,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\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} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" value' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\tisEmpty( caption )\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"]}
@@ -20,14 +20,15 @@ export default function CategoriesEdit(_ref) {
20
20
  displayAsDropdown,
21
21
  showHierarchy,
22
22
  showPostCounts,
23
- showOnlyTopLevel
23
+ showOnlyTopLevel,
24
+ showEmpty
24
25
  },
25
26
  setAttributes
26
27
  } = _ref;
27
28
  const selectId = useInstanceId(CategoriesEdit, 'blocks-category-select');
28
29
  const query = {
29
30
  per_page: -1,
30
- hide_empty: true,
31
+ hide_empty: !showEmpty,
31
32
  context: 'view'
32
33
  };
33
34
 
@@ -121,7 +122,7 @@ export default function CategoriesEdit(_ref) {
121
122
  };
122
123
 
123
124
  return createElement("div", useBlockProps(), createElement(InspectorControls, null, createElement(PanelBody, {
124
- title: __('Categories settings')
125
+ title: __('Settings')
125
126
  }, createElement(ToggleControl, {
126
127
  label: __('Display as dropdown'),
127
128
  checked: displayAsDropdown,
@@ -134,6 +135,10 @@ export default function CategoriesEdit(_ref) {
134
135
  label: __('Show only top level categories'),
135
136
  checked: showOnlyTopLevel,
136
137
  onChange: toggleAttribute('showOnlyTopLevel')
138
+ }), createElement(ToggleControl, {
139
+ label: __('Show empty categories'),
140
+ checked: showEmpty,
141
+ onChange: toggleAttribute('showEmpty')
137
142
  }), !showOnlyTopLevel && createElement(ToggleControl, {
138
143
  label: __('Show hierarchy'),
139
144
  checked: showHierarchy,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/categories/edit.js"],"names":["times","unescape","PanelBody","Placeholder","Spinner","ToggleControl","VisuallyHidden","useInstanceId","InspectorControls","useBlockProps","__","pin","__experimentalUseEntityRecords","useEntityRecords","CategoriesEdit","attributes","displayAsDropdown","showHierarchy","showPostCounts","showOnlyTopLevel","setAttributes","selectId","query","per_page","hide_empty","context","parent","records","categories","isResolving","getCategoriesList","parentId","length","filter","getCategoryListClassName","level","toggleAttribute","attributeName","newValue","renderCategoryName","name","trim","renderCategoryList","categoriesList","map","category","renderCategoryListItem","childCategories","id","link","count","childCategory","renderCategoryDropdown","renderCategoryDropdownItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,QAAhB,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,OAHD,EAICC,aAJD,EAKCC,cALD,QAMO,uBANP;AAOA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,yBAAjD;AACA,SAASC,EAAT,QAAmB,iBAAnB;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BAAF,CADX;AAEC,IAAA,OAAO,EAAGM,iBAFX;AAGC,IAAA,QAAQ,EAAGoB,eAAe,CAAE,mBAAF;AAH3B,IADD,EAMC,cAAC,aAAD;AACC,IAAA,KAAK,EAAG1B,EAAE,CAAE,kBAAF,CADX;AAEC,IAAA,OAAO,EAAGQ,cAFX;AAGC,IAAA,QAAQ,EAAGkB,eAAe,CAAE,gBAAF;AAH3B,IAND,EAWC,cAAC,aAAD;AACC,IAAA,KAAK,EAAG1B,EAAE,CAAE,gCAAF,CADX;AAEC,IAAA,OAAO,EAAGS,gBAFX;AAGC,IAAA,QAAQ,EAAGiB,eAAe,CAAE,kBAAF;AAH3B,IAXD,EAgBG,CAAEjB,gBAAF,IACD,cAAC,aAAD;AACC,IAAA,KAAK,EAAGT,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,OAAO,EAAGO,aAFX;AAGC,IAAA,QAAQ,EAAGmB,eAAe,CAAE,eAAF;AAH3B,IAjBF,CADD,CADD,EA2BGP,WAAW,IACZ,cAAC,WAAD;AAAa,IAAA,IAAI,EAAGlB,GAApB;AAA0B,IAAA,KAAK,EAAGD,EAAE,CAAE,YAAF;AAApC,KACC,cAAC,OAAD,OADD,CA5BF,EAgCG,CAAEmB,WAAF,IAAiB,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,MAAuB,CAAxC,IACD,yBACGtB,EAAE,CACH,uFADG,CADL,CAjCF,EAuCG,CAAEmB,WAAF,IACD,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,IAAqB,CADpB,KAEChB,iBAAiB,GAChBoC,sBAAsB,EADN,GAEhBV,kBAAkB,EAJpB,CAvCH,CADD;AA+CA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { __experimentalUseEntityRecords as useEntityRecords } from '@wordpress/core-data';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t},\n\tsetAttributes,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\tconst query = { per_page: -1, hide_empty: true, context: 'view' };\n\tif ( showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\t'category',\n\t\tquery\n\t);\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\tconst getCategoryListClassName = ( level ) => {\n\t\treturn `wp-block-categories__list wp-block-categories__list-level-${ level }`;\n\t};\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : unescape( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<ul className={ getCategoryListClassName( 0 ) }>\n\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\trenderCategoryListItem( category, 0 )\n\t\t\t\t) }\n\t\t\t</ul>\n\t\t);\n\t};\n\tconst renderCategoryListItem = ( category, level ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id }>\n\t\t\t\t<a href={ link } target=\"_blank\" rel=\"noreferrer noopener\">\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && (\n\t\t\t\t\t<span className=\"wp-block-categories__post-count\">\n\t\t\t\t\t\t{ ` (${ count })` }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ showHierarchy && !! childCategories.length && (\n\t\t\t\t\t<ul className={ getCategoryListClassName( level + 1 ) }>\n\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\trenderCategoryListItem( childCategory, level + 1 )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ul>\n\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t{ __( 'Categories' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<select\n\t\t\t\t\tid={ selectId }\n\t\t\t\t\tclassName=\"wp-block-categories__dropdown\"\n\t\t\t\t>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id }>\n\t\t\t\t{ times( level * 3, () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Categories settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show only top level categories' ) }\n\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showOnlyTopLevel' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Categories' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Your site does not have any posts, so there is nothing to display here at the moment.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/categories/edit.js"],"names":["times","unescape","PanelBody","Placeholder","Spinner","ToggleControl","VisuallyHidden","useInstanceId","InspectorControls","useBlockProps","__","pin","__experimentalUseEntityRecords","useEntityRecords","CategoriesEdit","attributes","displayAsDropdown","showHierarchy","showPostCounts","showOnlyTopLevel","showEmpty","setAttributes","selectId","query","per_page","hide_empty","context","parent","records","categories","isResolving","getCategoriesList","parentId","length","filter","getCategoryListClassName","level","toggleAttribute","attributeName","newValue","renderCategoryName","name","trim","renderCategoryList","categoriesList","map","category","renderCategoryListItem","childCategories","id","link","count","childCategory","renderCategoryDropdown","renderCategoryDropdownItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,QAAhB,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,OAHD,EAICC,aAJD,EAKCC,cALD,QAMO,uBANP;AAOA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,yBAAjD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,GAAT,QAAoB,kBAApB;AACA,SAASC,8BAA8B,IAAIC,gBAA3C,QAAmE,sBAAnE;AAEA,eAAe,SAASC,cAAT,OASX;AAAA,MAToC;AACvCC,IAAAA,UAAU,EAAE;AACXC,MAAAA,iBADW;AAEXC,MAAAA,aAFW;AAGXC,MAAAA,cAHW;AAIXC,MAAAA,gBAJW;AAKXC,MAAAA;AALW,KAD2B;AAQvCC,IAAAA;AARuC,GASpC;AACH,QAAMC,QAAQ,GAAGf,aAAa,CAAEO,cAAF,EAAkB,wBAAlB,CAA9B;AACA,QAAMS,KAAK,GAAG;AAAEC,IAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,IAAAA,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AH3B,IAXD,EAgBC,cAAC,aAAD;AACC,IAAA,KAAK,EAAG3B,EAAE,CAAE,uBAAF,CADX;AAEC,IAAA,OAAO,EAAGU,SAFX;AAGC,IAAA,QAAQ,EAAGiB,eAAe,CAAE,WAAF;AAH3B,IAhBD,EAqBG,CAAElB,gBAAF,IACD,cAAC,aAAD;AACC,IAAA,KAAK,EAAGT,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,OAAO,EAAGO,aAFX;AAGC,IAAA,QAAQ,EAAGoB,eAAe,CAAE,eAAF;AAH3B,IAtBF,CADD,CADD,EAgCGP,WAAW,IACZ,cAAC,WAAD;AAAa,IAAA,IAAI,EAAGnB,GAApB;AAA0B,IAAA,KAAK,EAAGD,EAAE,CAAE,YAAF;AAApC,KACC,cAAC,OAAD,OADD,CAjCF,EAqCG,CAAEoB,WAAF,IAAiB,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,MAAuB,CAAxC,IACD,yBACGvB,EAAE,CACH,uFADG,CADL,CAtCF,EA4CG,CAAEoB,WAAF,IACD,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,IAAqB,CADpB,KAECjB,iBAAiB,GAChBqC,sBAAsB,EADN,GAEhBV,kBAAkB,EAJpB,CA5CH,CADD;AAoDA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { __experimentalUseEntityRecords as useEntityRecords } from '@wordpress/core-data';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t},\n\tsetAttributes,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\t'category',\n\t\tquery\n\t);\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\tconst getCategoryListClassName = ( level ) => {\n\t\treturn `wp-block-categories__list wp-block-categories__list-level-${ level }`;\n\t};\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : unescape( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<ul className={ getCategoryListClassName( 0 ) }>\n\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\trenderCategoryListItem( category, 0 )\n\t\t\t\t) }\n\t\t\t</ul>\n\t\t);\n\t};\n\tconst renderCategoryListItem = ( category, level ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id }>\n\t\t\t\t<a href={ link } target=\"_blank\" rel=\"noreferrer noopener\">\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && (\n\t\t\t\t\t<span className=\"wp-block-categories__post-count\">\n\t\t\t\t\t\t{ ` (${ count })` }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ showHierarchy && !! childCategories.length && (\n\t\t\t\t\t<ul className={ getCategoryListClassName( level + 1 ) }>\n\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\trenderCategoryListItem( childCategory, level + 1 )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ul>\n\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t{ __( 'Categories' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<select\n\t\t\t\t\tid={ selectId }\n\t\t\t\t\tclassName=\"wp-block-categories__dropdown\"\n\t\t\t\t>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id }>\n\t\t\t\t{ times( level * 3, () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show only top level categories' ) }\n\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showOnlyTopLevel' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show empty categories' ) }\n\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Categories' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Your site does not have any posts, so there is nothing to display here at the moment.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</div>\n\t);\n}\n"]}
@@ -30,6 +30,10 @@ const metadata = {
30
30
  showOnlyTopLevel: {
31
31
  type: "boolean",
32
32
  "default": false
33
+ },
34
+ showEmpty: {
35
+ type: "boolean",
36
+ "default": false
33
37
  }
34
38
  },
35
39
  supports: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/categories/index.js"],"names":["category","icon","edit","name","metadata","settings","example"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,IAArB,QAAiC,kBAAjC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBJ,EAAAA,IADuB;AAEvBK,EAAAA,OAAO,EAAE,EAFc;AAGvBJ,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { category as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/categories/index.js"],"names":["category","icon","edit","name","metadata","settings","example"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,IAArB,QAAiC,kBAAjC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBJ,EAAAA,IADuB;AAEvBK,EAAAA,OAAO,EAAE,EAFc;AAGvBJ,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { category as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n"]}
@@ -51,6 +51,16 @@ const metadata = {
51
51
  padding: true
52
52
  }
53
53
  },
54
+ __experimentalBorder: {
55
+ color: true,
56
+ style: true,
57
+ width: true,
58
+ __experimentalDefaultControls: {
59
+ color: true,
60
+ style: true,
61
+ width: true
62
+ }
63
+ },
54
64
  __experimentalLayout: true
55
65
  }
56
66
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["column","icon","deprecated","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBN,EAAAA,IADuB;AAEvBE,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBF,EAAAA;AAJuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { column as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["column","icon","deprecated","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBN,EAAAA,IADuB;AAEvBE,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBF,EAAAA;AAJuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { column as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\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,
@@ -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","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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACpD;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;A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,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\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"]}
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;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACp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,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","innerBlocksProps","template","allowedBlocks","__experimentalLayout","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC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a,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,QAAF,CAA7B;AACA;AACF;AACA;AACA;AACA;;AACE,WAAOM,WAAP,aAAOA,WAAP,uBAAOA,WAAW,CAAEC,IAAb,CAAqBC,UA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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;A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AA5C;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,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,CAFgB,EAwDhB,CAAE,0BAAF,CAxDgB,CAAjB;AA2DA,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[ '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