@wordpress/block-library 7.16.0 → 7.18.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 (419) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/build/archives/edit.js +1 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +44 -4
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/button/edit.js +1 -1
  7. package/build/button/edit.js.map +1 -1
  8. package/build/buttons/edit.native.js +1 -1
  9. package/build/buttons/edit.native.js.map +1 -1
  10. package/build/comment-template/edit.js +40 -32
  11. package/build/comment-template/edit.js.map +1 -1
  12. package/build/comment-template/index.js +6 -2
  13. package/build/comment-template/index.js.map +1 -1
  14. package/build/comments/edit/placeholder.js +1 -4
  15. package/build/comments/edit/placeholder.js.map +1 -1
  16. package/build/comments/index.js +5 -1
  17. package/build/comments/index.js.map +1 -1
  18. package/build/comments-title/edit.js +18 -1
  19. package/build/comments-title/edit.js.map +1 -1
  20. package/build/cover/edit/index.js +2 -2
  21. package/build/cover/edit/index.js.map +1 -1
  22. package/build/cover/edit/inspector-controls.js +3 -7
  23. package/build/cover/edit/inspector-controls.js.map +1 -1
  24. package/build/cover/edit/use-cover-is-dark.js +8 -7
  25. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  26. package/build/embed/deprecated.js +43 -4
  27. package/build/embed/deprecated.js.map +1 -1
  28. package/build/embed/variations.js +1 -1
  29. package/build/embed/variations.js.map +1 -1
  30. package/build/file/deprecated.js +108 -4
  31. package/build/file/deprecated.js.map +1 -1
  32. package/build/file/transforms.js +3 -9
  33. package/build/file/transforms.js.map +1 -1
  34. package/build/gallery/deprecated.js +148 -23
  35. package/build/gallery/deprecated.js.map +1 -1
  36. package/build/gallery/gallery.js +3 -2
  37. package/build/gallery/gallery.js.map +1 -1
  38. package/build/gallery/transforms.js +3 -3
  39. package/build/gallery/transforms.js.map +1 -1
  40. package/build/gallery/use-image-sizes.js +2 -1
  41. package/build/gallery/use-image-sizes.js.map +1 -1
  42. package/build/gallery/v1/edit.js +3 -2
  43. package/build/gallery/v1/edit.js.map +1 -1
  44. package/build/group/edit.js +7 -3
  45. package/build/group/edit.js.map +1 -1
  46. package/build/image/edit.native.js +1 -1
  47. package/build/image/edit.native.js.map +1 -1
  48. package/build/image/image.js +33 -12
  49. package/build/image/image.js.map +1 -1
  50. package/build/image/transforms.js +1 -7
  51. package/build/image/transforms.js.map +1 -1
  52. package/build/latest-posts/edit.js +1 -1
  53. package/build/latest-posts/edit.js.map +1 -1
  54. package/build/list/transforms.js +9 -1
  55. package/build/list/transforms.js.map +1 -1
  56. package/build/list/utils.js +4 -8
  57. package/build/list/utils.js.map +1 -1
  58. package/build/list-item/edit.js +3 -2
  59. package/build/list-item/edit.js.map +1 -1
  60. package/build/list-item/edit.native.js +3 -2
  61. package/build/list-item/edit.native.js.map +1 -1
  62. package/build/list-item/hooks/use-merge.js +19 -22
  63. package/build/list-item/hooks/use-merge.js.map +1 -1
  64. package/build/list-item/hooks/use-outdent-list-item.js +24 -10
  65. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  66. package/build/list-item/index.js +14 -1
  67. package/build/list-item/index.js.map +1 -1
  68. package/build/list-item/utils.js +14 -1
  69. package/build/list-item/utils.js.map +1 -1
  70. package/build/navigation/edit/index.js +45 -31
  71. package/build/navigation/edit/index.js.map +1 -1
  72. package/build/navigation/edit/inner-blocks.js +3 -5
  73. package/build/navigation/edit/inner-blocks.js.map +1 -1
  74. package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
  75. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  76. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  77. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  78. package/build/navigation/edit/use-create-navigation-menu.js +1 -1
  79. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  80. package/build/navigation/index.js +4 -1
  81. package/build/navigation/index.js.map +1 -1
  82. package/build/navigation-link/edit.js +5 -3
  83. package/build/navigation-link/edit.js.map +1 -1
  84. package/build/navigation-submenu/edit.js +4 -4
  85. package/build/navigation-submenu/edit.js.map +1 -1
  86. package/build/page-list/edit.js +29 -10
  87. package/build/page-list/edit.js.map +1 -1
  88. package/build/page-list/index.js +1 -5
  89. package/build/page-list/index.js.map +1 -1
  90. package/build/paragraph/edit.js +3 -11
  91. package/build/paragraph/edit.js.map +1 -1
  92. package/build/pattern/edit.js +11 -4
  93. package/build/pattern/edit.js.map +1 -1
  94. package/build/post-comments-count/index.js +4 -0
  95. package/build/post-comments-count/index.js.map +1 -1
  96. package/build/post-comments-form/form.js +1 -2
  97. package/build/post-comments-form/form.js.map +1 -1
  98. package/build/post-comments-form/index.js +4 -0
  99. package/build/post-comments-form/index.js.map +1 -1
  100. package/build/post-comments-link/index.js +4 -0
  101. package/build/post-comments-link/index.js.map +1 -1
  102. package/build/post-content/edit.js +14 -6
  103. package/build/post-content/edit.js.map +1 -1
  104. package/build/pullquote/deprecated.js +6 -6
  105. package/build/pullquote/deprecated.js.map +1 -1
  106. package/build/query/edit/inspector-controls/index.js +2 -2
  107. package/build/query/edit/inspector-controls/index.js.map +1 -1
  108. package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -104
  109. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  110. package/build/search/edit.js +3 -4
  111. package/build/search/edit.js.map +1 -1
  112. package/build/site-logo/edit.js +7 -10
  113. package/build/site-logo/edit.js.map +1 -1
  114. package/build/site-tagline/edit.js +21 -9
  115. package/build/site-tagline/edit.js.map +1 -1
  116. package/build/site-title/edit/index.js +20 -8
  117. package/build/site-title/edit/index.js.map +1 -1
  118. package/build/social-link/edit.js +11 -2
  119. package/build/social-link/edit.js.map +1 -1
  120. package/build/social-link/index.js +3 -0
  121. package/build/social-link/index.js.map +1 -1
  122. package/build/spacer/controls.js +3 -7
  123. package/build/spacer/controls.js.map +1 -1
  124. package/build/table/deprecated.js +282 -27
  125. package/build/table/deprecated.js.map +1 -1
  126. package/build/table/state.js +2 -2
  127. package/build/table/state.js.map +1 -1
  128. package/build/table-of-contents/edit.js +1 -4
  129. package/build/table-of-contents/edit.js.map +1 -1
  130. package/build/tag-cloud/edit.js +1 -1
  131. package/build/tag-cloud/edit.js.map +1 -1
  132. package/build/tag-cloud/index.js +8 -0
  133. package/build/tag-cloud/index.js.map +1 -1
  134. package/build/utils/clean-empty-object.js +5 -4
  135. package/build/utils/clean-empty-object.js.map +1 -1
  136. package/build/video/deprecated.js +159 -0
  137. package/build/video/deprecated.js.map +1 -0
  138. package/build/video/edit.js +41 -5
  139. package/build/video/edit.js.map +1 -1
  140. package/build/video/index.js +3 -0
  141. package/build/video/index.js.map +1 -1
  142. package/build/video/tracks-editor.js +3 -28
  143. package/build/video/tracks-editor.js.map +1 -1
  144. package/build-module/archives/edit.js +1 -0
  145. package/build-module/archives/edit.js.map +1 -1
  146. package/build-module/audio/edit.js +46 -7
  147. package/build-module/audio/edit.js.map +1 -1
  148. package/build-module/button/edit.js +1 -1
  149. package/build-module/button/edit.js.map +1 -1
  150. package/build-module/buttons/edit.native.js +1 -1
  151. package/build-module/buttons/edit.native.js.map +1 -1
  152. package/build-module/comment-template/edit.js +38 -30
  153. package/build-module/comment-template/edit.js.map +1 -1
  154. package/build-module/comment-template/index.js +6 -2
  155. package/build-module/comment-template/index.js.map +1 -1
  156. package/build-module/comments/edit/placeholder.js +1 -3
  157. package/build-module/comments/edit/placeholder.js.map +1 -1
  158. package/build-module/comments/index.js +5 -1
  159. package/build-module/comments/index.js.map +1 -1
  160. package/build-module/comments-title/edit.js +18 -2
  161. package/build-module/comments-title/edit.js.map +1 -1
  162. package/build-module/cover/edit/index.js +2 -2
  163. package/build-module/cover/edit/index.js.map +1 -1
  164. package/build-module/cover/edit/inspector-controls.js +4 -8
  165. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  166. package/build-module/cover/edit/use-cover-is-dark.js +7 -7
  167. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  168. package/build-module/embed/deprecated.js +44 -5
  169. package/build-module/embed/deprecated.js.map +1 -1
  170. package/build-module/embed/variations.js +1 -1
  171. package/build-module/embed/variations.js.map +1 -1
  172. package/build-module/file/deprecated.js +108 -4
  173. package/build-module/file/deprecated.js.map +1 -1
  174. package/build-module/file/transforms.js +3 -8
  175. package/build-module/file/transforms.js.map +1 -1
  176. package/build-module/gallery/deprecated.js +147 -25
  177. package/build-module/gallery/deprecated.js.map +1 -1
  178. package/build-module/gallery/gallery.js +3 -2
  179. package/build-module/gallery/gallery.js.map +1 -1
  180. package/build-module/gallery/transforms.js +4 -4
  181. package/build-module/gallery/transforms.js.map +1 -1
  182. package/build-module/gallery/use-image-sizes.js +3 -2
  183. package/build-module/gallery/use-image-sizes.js.map +1 -1
  184. package/build-module/gallery/v1/edit.js +4 -3
  185. package/build-module/gallery/v1/edit.js.map +1 -1
  186. package/build-module/group/edit.js +7 -3
  187. package/build-module/group/edit.js.map +1 -1
  188. package/build-module/image/edit.native.js +1 -1
  189. package/build-module/image/edit.native.js.map +1 -1
  190. package/build-module/image/image.js +36 -15
  191. package/build-module/image/image.js.map +1 -1
  192. package/build-module/image/transforms.js +1 -6
  193. package/build-module/image/transforms.js.map +1 -1
  194. package/build-module/latest-posts/edit.js +2 -2
  195. package/build-module/latest-posts/edit.js.map +1 -1
  196. package/build-module/list/transforms.js +9 -1
  197. package/build-module/list/transforms.js.map +1 -1
  198. package/build-module/list/utils.js +5 -9
  199. package/build-module/list/utils.js.map +1 -1
  200. package/build-module/list-item/edit.js +3 -2
  201. package/build-module/list-item/edit.js.map +1 -1
  202. package/build-module/list-item/edit.native.js +3 -2
  203. package/build-module/list-item/edit.native.js.map +1 -1
  204. package/build-module/list-item/hooks/use-merge.js +19 -21
  205. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  206. package/build-module/list-item/hooks/use-outdent-list-item.js +24 -9
  207. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  208. package/build-module/list-item/index.js +14 -1
  209. package/build-module/list-item/index.js.map +1 -1
  210. package/build-module/list-item/utils.js +14 -1
  211. package/build-module/list-item/utils.js.map +1 -1
  212. package/build-module/navigation/edit/index.js +45 -31
  213. package/build-module/navigation/edit/index.js.map +1 -1
  214. package/build-module/navigation/edit/inner-blocks.js +3 -5
  215. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  216. package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
  217. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  218. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  219. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  220. package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
  221. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  222. package/build-module/navigation/index.js +4 -1
  223. package/build-module/navigation/index.js.map +1 -1
  224. package/build-module/navigation-link/edit.js +5 -4
  225. package/build-module/navigation-link/edit.js.map +1 -1
  226. package/build-module/navigation-submenu/edit.js +4 -4
  227. package/build-module/navigation-submenu/edit.js.map +1 -1
  228. package/build-module/page-list/edit.js +29 -10
  229. package/build-module/page-list/edit.js.map +1 -1
  230. package/build-module/page-list/index.js +1 -5
  231. package/build-module/page-list/index.js.map +1 -1
  232. package/build-module/paragraph/edit.js +3 -10
  233. package/build-module/paragraph/edit.js.map +1 -1
  234. package/build-module/pattern/edit.js +10 -3
  235. package/build-module/pattern/edit.js.map +1 -1
  236. package/build-module/post-comments-count/index.js +4 -0
  237. package/build-module/post-comments-count/index.js.map +1 -1
  238. package/build-module/post-comments-form/form.js +2 -3
  239. package/build-module/post-comments-form/form.js.map +1 -1
  240. package/build-module/post-comments-form/index.js +4 -0
  241. package/build-module/post-comments-form/index.js.map +1 -1
  242. package/build-module/post-comments-link/index.js +4 -0
  243. package/build-module/post-comments-link/index.js.map +1 -1
  244. package/build-module/post-content/edit.js +14 -6
  245. package/build-module/post-content/edit.js.map +1 -1
  246. package/build-module/pullquote/deprecated.js +7 -7
  247. package/build-module/pullquote/deprecated.js.map +1 -1
  248. package/build-module/query/edit/inspector-controls/index.js +4 -4
  249. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  250. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -102
  251. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  252. package/build-module/search/edit.js +4 -5
  253. package/build-module/search/edit.js.map +1 -1
  254. package/build-module/site-logo/edit.js +8 -11
  255. package/build-module/site-logo/edit.js.map +1 -1
  256. package/build-module/site-tagline/edit.js +23 -11
  257. package/build-module/site-tagline/edit.js.map +1 -1
  258. package/build-module/site-title/edit/index.js +22 -10
  259. package/build-module/site-title/edit/index.js.map +1 -1
  260. package/build-module/social-link/edit.js +11 -2
  261. package/build-module/social-link/edit.js.map +1 -1
  262. package/build-module/social-link/index.js +3 -0
  263. package/build-module/social-link/index.js.map +1 -1
  264. package/build-module/spacer/controls.js +4 -8
  265. package/build-module/spacer/controls.js.map +1 -1
  266. package/build-module/table/deprecated.js +282 -27
  267. package/build-module/table/deprecated.js.map +1 -1
  268. package/build-module/table/state.js +3 -3
  269. package/build-module/table/state.js.map +1 -1
  270. package/build-module/table-of-contents/edit.js +1 -3
  271. package/build-module/table-of-contents/edit.js.map +1 -1
  272. package/build-module/tag-cloud/edit.js +1 -1
  273. package/build-module/tag-cloud/edit.js.map +1 -1
  274. package/build-module/tag-cloud/index.js +8 -0
  275. package/build-module/tag-cloud/index.js.map +1 -1
  276. package/build-module/utils/clean-empty-object.js +5 -5
  277. package/build-module/utils/clean-empty-object.js.map +1 -1
  278. package/build-module/video/deprecated.js +147 -0
  279. package/build-module/video/deprecated.js.map +1 -0
  280. package/build-module/video/edit.js +45 -9
  281. package/build-module/video/edit.js.map +1 -1
  282. package/build-module/video/index.js +2 -0
  283. package/build-module/video/index.js.map +1 -1
  284. package/build-module/video/tracks-editor.js +4 -29
  285. package/build-module/video/tracks-editor.js.map +1 -1
  286. package/build-style/archives/style-rtl.css +4 -0
  287. package/build-style/archives/style.css +4 -0
  288. package/build-style/button/style-rtl.css +1 -0
  289. package/build-style/button/style.css +1 -0
  290. package/build-style/comment-template/style-rtl.css +1 -0
  291. package/build-style/comment-template/style.css +1 -0
  292. package/build-style/comments/editor-rtl.css +1 -0
  293. package/build-style/comments/editor.css +1 -0
  294. package/build-style/comments/style-rtl.css +1 -0
  295. package/build-style/comments/style.css +1 -0
  296. package/build-style/cover/editor-rtl.css +4 -0
  297. package/build-style/cover/editor.css +4 -0
  298. package/build-style/editor-rtl.css +13 -21
  299. package/build-style/editor.css +13 -21
  300. package/build-style/group/editor-rtl.css +1 -0
  301. package/build-style/group/editor.css +1 -0
  302. package/build-style/image/editor-rtl.css +1 -1
  303. package/build-style/image/editor.css +1 -1
  304. package/build-style/navigation/editor-rtl.css +5 -4
  305. package/build-style/navigation/editor.css +5 -4
  306. package/build-style/navigation/style-rtl.css +3 -1
  307. package/build-style/navigation/style.css +3 -1
  308. package/build-style/paragraph/editor-rtl.css +0 -16
  309. package/build-style/paragraph/editor.css +0 -16
  310. package/build-style/post-comments-form/style-rtl.css +3 -0
  311. package/build-style/post-comments-form/style.css +3 -0
  312. package/build-style/site-logo/editor-rtl.css +1 -0
  313. package/build-style/site-logo/editor.css +1 -0
  314. package/build-style/style-rtl.css +16 -1
  315. package/build-style/style.css +16 -1
  316. package/build-style/tag-cloud/style-rtl.css +3 -0
  317. package/build-style/tag-cloud/style.css +3 -0
  318. package/package.json +29 -28
  319. package/src/archives/edit.js +1 -0
  320. package/src/archives/style.scss +5 -0
  321. package/src/audio/edit.js +79 -24
  322. package/src/avatar/index.php +1 -1
  323. package/src/button/edit.js +1 -1
  324. package/src/button/style.scss +2 -0
  325. package/src/buttons/edit.native.js +1 -1
  326. package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
  327. package/src/code/test/edit.native.js +46 -32
  328. package/src/comment-template/block.json +6 -2
  329. package/src/comment-template/edit.js +47 -34
  330. package/src/comment-template/style.scss +2 -0
  331. package/src/comments/block.json +5 -1
  332. package/src/comments/edit/placeholder.js +1 -7
  333. package/src/comments/style.scss +2 -0
  334. package/src/comments-title/edit.js +24 -1
  335. package/src/cover/edit/index.js +2 -7
  336. package/src/cover/edit/inspector-controls.js +11 -13
  337. package/src/cover/edit/use-cover-is-dark.js +11 -11
  338. package/src/cover/editor.scss +7 -0
  339. package/src/embed/deprecated.js +53 -26
  340. package/src/embed/variations.js +1 -1
  341. package/src/file/deprecated.js +130 -2
  342. package/src/file/transforms.js +3 -8
  343. package/src/gallery/deprecated.js +129 -4
  344. package/src/gallery/gallery.js +2 -0
  345. package/src/gallery/index.php +19 -10
  346. package/src/gallery/transforms.js +8 -5
  347. package/src/gallery/use-image-sizes.js +3 -2
  348. package/src/gallery/v1/edit.js +4 -3
  349. package/src/group/edit.js +10 -2
  350. package/src/group/editor.scss +1 -0
  351. package/src/image/edit.native.js +1 -1
  352. package/src/image/editor.scss +4 -1
  353. package/src/image/image.js +75 -33
  354. package/src/image/transforms.js +1 -7
  355. package/src/latest-posts/edit.js +2 -2
  356. package/src/list/test/edit.native.js +102 -3
  357. package/src/list/transforms.js +11 -0
  358. package/src/list/utils.js +3 -11
  359. package/src/list-item/block.json +14 -1
  360. package/src/list-item/edit.js +2 -1
  361. package/src/list-item/edit.native.js +2 -1
  362. package/src/list-item/hooks/use-merge.js +4 -23
  363. package/src/list-item/hooks/use-outdent-list-item.js +9 -8
  364. package/src/navigation/block.json +4 -1
  365. package/src/navigation/edit/index.js +61 -37
  366. package/src/navigation/edit/inner-blocks.js +2 -5
  367. package/src/navigation/edit/unsaved-inner-blocks.js +9 -2
  368. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
  369. package/src/navigation/edit/use-create-navigation-menu.js +2 -5
  370. package/src/navigation/editor.scss +5 -4
  371. package/src/navigation/index.php +103 -6
  372. package/src/navigation/style.scss +3 -1
  373. package/src/navigation-link/edit.js +6 -5
  374. package/src/navigation-link/index.php +8 -1
  375. package/src/navigation-submenu/edit.js +7 -5
  376. package/src/navigation-submenu/index.php +8 -1
  377. package/src/page-list/block.json +1 -5
  378. package/src/page-list/edit.js +36 -22
  379. package/src/page-list/index.php +8 -6
  380. package/src/paragraph/edit.js +1 -14
  381. package/src/paragraph/editor.scss +0 -20
  382. package/src/pattern/edit.js +10 -3
  383. package/src/post-comments-count/block.json +4 -0
  384. package/src/post-comments-form/block.json +4 -0
  385. package/src/post-comments-form/form.js +2 -3
  386. package/src/post-comments-form/style.scss +3 -0
  387. package/src/post-comments-link/block.json +4 -0
  388. package/src/post-content/edit.js +8 -4
  389. package/src/pullquote/deprecated.js +7 -7
  390. package/src/query/edit/inspector-controls/index.js +4 -3
  391. package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -87
  392. package/src/rss/index.php +3 -3
  393. package/src/search/edit.js +7 -2
  394. package/src/search/index.php +21 -13
  395. package/src/site-logo/edit.js +12 -10
  396. package/src/site-logo/editor.scss +1 -0
  397. package/src/site-tagline/edit.js +25 -18
  398. package/src/site-title/edit/index.js +26 -12
  399. package/src/social-link/block.json +3 -0
  400. package/src/social-link/edit.js +8 -1
  401. package/src/social-link/index.php +11 -7
  402. package/src/spacer/controls.js +10 -12
  403. package/src/table/deprecated.js +587 -348
  404. package/src/table/state.js +3 -3
  405. package/src/table-of-contents/edit.js +1 -3
  406. package/src/tag-cloud/block.json +8 -0
  407. package/src/tag-cloud/edit.js +1 -1
  408. package/src/tag-cloud/style.scss +3 -0
  409. package/src/template-part/index.php +4 -0
  410. package/src/utils/clean-empty-object.js +5 -6
  411. package/src/video/deprecated.js +57 -0
  412. package/src/video/edit.js +71 -23
  413. package/src/video/index.js +2 -0
  414. package/src/video/tracks-editor.js +12 -28
  415. package/build/paragraph/drop-zone.js +0 -99
  416. package/build/paragraph/drop-zone.js.map +0 -1
  417. package/build-module/paragraph/drop-zone.js +0 -88
  418. package/build-module/paragraph/drop-zone.js.map +0 -1
  419. package/src/paragraph/drop-zone.js +0 -105
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.18.0 (2022-11-02)
6
+
7
+ ## 7.17.0 (2022-10-19)
8
+
5
9
  ## 7.16.0 (2022-10-05)
6
10
 
7
11
  ## 7.15.0 (2022-09-21)
@@ -11,7 +15,6 @@
11
15
  ### New Feature
12
16
 
13
17
  - Made it possible to import individual blocks ([#42258](https://github.com/WordPress/gutenberg/pull/42258)). Check [README](./README.md#loading-individual-blocks) for more information.
14
- - Paragraph block: You can now drop files/blocks/HTML on an empty Paragraph block to transform it into relevant blocks ([#42722](https://github.com/WordPress/gutenberg/pull/42722)).
15
18
 
16
19
  ## 7.13.0 (2022-08-24)
17
20
 
@@ -72,6 +72,7 @@ function ArchivesEdit(_ref) {
72
72
  })
73
73
  }))), (0, _element.createElement)("div", (0, _blockEditor.useBlockProps)(), (0, _element.createElement)(_components.Disabled, null, (0, _element.createElement)(_serverSideRender.default, {
74
74
  block: "core/archives",
75
+ skipBlockSupportAttributes: true,
75
76
  attributes: attributes
76
77
  }))));
77
78
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["ArchivesEdit","attributes","setAttributes","showLabel","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;AAWe,SAASA,YAAT,OAAuD;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACrE,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,cAAb;AAA6BC,IAAAA,iBAA7B;AAAgDC,IAAAA;AAAhD,MAAyDL,UAA/D;AAEA,SACC,qDACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,UAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,K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KAAK,EAAC,eADP;AAEC,IAAA,UAAU,EAAGP;AAFd,IADD,CADD,CA/CD,CADD;AA0DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tToggleControl,\n\tSelectControl,\n\tDisabled,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport ServerSideRender from '@wordpress/server-side-render';\n\nexport default function ArchivesEdit( { attributes, setAttributes } ) {\n\tconst { showLabel, showPostCounts, displayAsDropdown, type } = attributes;\n\n\treturn (\n\t\t<>\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={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayAsDropdown: ! displayAsDropdown,\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{ displayAsDropdown && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowLabel: ! showLabel,\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<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={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPostCounts: ! showPostCounts,\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<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Group by:' ) }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ label: __( 'Year' ), value: 'yearly' },\n\t\t\t\t\t\t\t{ label: __( 'Month' ), value: 'monthly' },\n\t\t\t\t\t\t\t{ label: __( 'Week' ), value: 'weekly' },\n\t\t\t\t\t\t\t{ label: __( 'Day' ), value: 'daily' },\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { type: value } )\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<div { ...useBlockProps() }>\n\t\t\t\t<Disabled>\n\t\t\t\t\t<ServerSideRender\n\t\t\t\t\t\tblock=\"core/archives\"\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["ArchivesEdit","attributes","setAttributes","showLabel","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;AAWe,SAASA,YAAT,OAAuD;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACrE,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,cAAb;AAA6BC,IAAAA,iBAA7B;AAAgDC,IAAAA;AAAhD,MAAyDL,UAA/D;AAEA,SACC,qDACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,UAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CADT;AAEC,IAAA,OAAO,EAAGI,iBAFX;AAGC,IAAA,QAAQ,EAA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CA/CD,CADD;AA2DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tToggleControl,\n\tSelectControl,\n\tDisabled,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport ServerSideRender from '@wordpress/server-side-render';\n\nexport default function ArchivesEdit( { attributes, setAttributes } ) {\n\tconst { showLabel, showPostCounts, displayAsDropdown, type } = attributes;\n\n\treturn (\n\t\t<>\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={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayAsDropdown: ! displayAsDropdown,\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{ displayAsDropdown && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowLabel: ! showLabel,\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<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={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPostCounts: ! showPostCounts,\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<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Group by:' ) }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ label: __( 'Year' ), value: 'yearly' },\n\t\t\t\t\t\t\t{ label: __( 'Month' ), value: 'monthly' },\n\t\t\t\t\t\t\t{ label: __( 'Week' ), value: 'weekly' },\n\t\t\t\t\t\t\t{ label: __( 'Day' ), value: 'daily' },\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { type: value } )\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<div { ...useBlockProps() }>\n\t\t\t\t<Disabled>\n\t\t\t\t\t<ServerSideRender\n\t\t\t\t\t\tblock=\"core/archives\"\n\t\t\t\t\t\tskipBlockSupportAttributes\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -27,6 +27,8 @@ var _blocks = require("@wordpress/blocks");
27
27
 
28
28
  var _notices = require("@wordpress/notices");
29
29
 
30
+ var _compose = require("@wordpress/compose");
31
+
30
32
  var _util = require("../embed/util");
31
33
 
32
34
  /**
@@ -59,6 +61,8 @@ function AudioEdit(_ref) {
59
61
  preload,
60
62
  src
61
63
  } = attributes;
64
+ const prevCaption = (0, _compose.usePrevious)(caption);
65
+ const [showCaption, setShowCaption] = (0, _element.useState)(!!caption);
62
66
  const isTemporaryAudio = !id && (0, _blob.isBlobURL)(src);
63
67
  const mediaUpload = (0, _data.useSelect)(select => {
64
68
  const {
@@ -82,7 +86,25 @@ function AudioEdit(_ref) {
82
86
  });
83
87
  }
84
88
  }
85
- }, []);
89
+ }, []); // We need to show the caption when changes come from
90
+ // history navigation(undo/redo).
91
+
92
+ (0, _element.useEffect)(() => {
93
+ if (caption && !prevCaption) {
94
+ setShowCaption(true);
95
+ }
96
+ }, [caption, prevCaption]); // Focus the caption when we click to add one.
97
+
98
+ const captionRef = (0, _element.useCallback)(node => {
99
+ if (node && !caption) {
100
+ node.focus();
101
+ }
102
+ }, [caption]);
103
+ (0, _element.useEffect)(() => {
104
+ if (!isSelected && !caption) {
105
+ setShowCaption(false);
106
+ }
107
+ }, [isSelected, caption]);
86
108
 
87
109
  function toggleAttribute(attribute) {
88
110
  return newValue => {
@@ -135,7 +157,8 @@ function AudioEdit(_ref) {
135
157
  // previous attributes should be removed because they may be temporary blob urls.
136
158
  setAttributes({
137
159
  src: undefined,
138
- id: undefined
160
+ id: undefined,
161
+ caption: undefined
139
162
  });
140
163
  return;
141
164
  } // Sets the block's attribute and updates the edit component from the
@@ -144,7 +167,8 @@ function AudioEdit(_ref) {
144
167
 
145
168
  setAttributes({
146
169
  src: media.url,
147
- id: media.id
170
+ id: media.id,
171
+ caption: media.caption
148
172
  });
149
173
  }
150
174
 
@@ -170,6 +194,21 @@ function AudioEdit(_ref) {
170
194
  }
171
195
 
172
196
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
197
+ group: "block"
198
+ }, (0, _element.createElement)(_components.ToolbarButton, {
199
+ onClick: () => {
200
+ setShowCaption(!showCaption);
201
+
202
+ if (showCaption && caption) {
203
+ setAttributes({
204
+ caption: undefined
205
+ });
206
+ }
207
+ },
208
+ icon: _icons.caption,
209
+ isPressed: showCaption,
210
+ label: showCaption ? (0, _i18n.__)('Remove caption') : (0, _i18n.__)('Add caption')
211
+ })), (0, _element.createElement)(_blockEditor.BlockControls, {
173
212
  group: "other"
174
213
  }, (0, _element.createElement)(_blockEditor.MediaReplaceFlow, {
175
214
  mediaId: id,
@@ -215,9 +254,10 @@ function AudioEdit(_ref) {
215
254
  }, (0, _element.createElement)("audio", {
216
255
  controls: "controls",
217
256
  src: src
218
- })), isTemporaryAudio && (0, _element.createElement)(_components.Spinner, null), (!_blockEditor.RichText.isEmpty(caption) || isSelected) && (0, _element.createElement)(_blockEditor.RichText, {
257
+ })), isTemporaryAudio && (0, _element.createElement)(_components.Spinner, null), showCaption && (!_blockEditor.RichText.isEmpty(caption) || isSelected) && (0, _element.createElement)(_blockEditor.RichText, {
219
258
  tagName: "figcaption",
220
259
  className: (0, _blockEditor.__experimentalGetElementClassName)('caption'),
260
+ ref: captionRef,
221
261
  "aria-label": (0, _i18n.__)('Audio caption text'),
222
262
  placeholder: (0, _i18n.__)('Add caption'),
223
263
  value: caption,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","setAttributes","onReplace","isSelected","insertBlocksAfter","id","autoplay","caption","loop","preload","src","isTemporaryAudio","mediaUpload","select","getSettings","blockEditorStore","file","filesList","onFileChange","media","onSelectAudio","onError","e","onUploadError","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","url","undefined","createErrorNotice","noticesStore","message","type","getAutoplayHelp","checked","classes","blockProps","icon","value","label","RichText","isEmpty"],"mappings":";;;;;;;;;AA2BA;;AAxBA;;AAKA;;AACA;;AAOA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AA2BA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OAOI;AAAA,MAPgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,SAFmB;AAGnBC,IAAAA,aAHmB;AAInBC,IAAAA,SAJmB;AAKnBC,IAAAA,UALmB;AAMnBC,IAAAA;AANmB,GAOhB;AACH,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,QAAN;AAAgBC,IAAAA,OAAhB;AAAyBC,IAAAA,IAAzB;AAA+BC,IAAAA,OAA/B;AAAwCC,IAAAA;AAAxC,MAAgDX,UAAtD;AACA,QAAMY,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWK,GAAX,CAAjC;AACA,QAA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T;AAAqBC,MAAAA,KAAK,EAAE,cAAI,UAAJ;AAA5B,KAHS,EAIT;AACCD,MAAAA,KAAK,EAAE,MADR;AAECC,MAAAA,KAAK,EAAE,cAAI,MAAJ,EAAY,eAAZ;AAFR,KAJS;AATX,IAZD,CADD,CAZD,EA8CC,sCAAaH,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAErC;AAAzB,KACC;AAAO,IAAA,QAAQ,EAAC,UAAhB;AAA2B,IAAA,GAAG,EAAGO;AAAjC,IADD,CAND,EASGC,gBAAgB,IAAI,4BAAC,mBAAD,OATvB,EAUG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBtC,OAAlB,CAAF,IAAiCJ,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,IAAA,SAAS,EAAG,oDACX,SADW,CAFb;AAKC,kBAAa,cAAI,oBAAJ,CALd;AAMC,IAAA,WAAW,EAAG,cAAI,aAAJ,CANf;AAOC,IAAA,KAAK,EAAGI,OAPT;AAQC,IAAA,QAAQ,EAAKmC,KAAF,IACVzC,aAAa,CAAE;AAAEM,MAAAA,OAAO,EAAEmC;AAAX,KAAF,CATf;AAWC,IAAA,aAAa,MAXd;AAYC,IAAA,sBAAsB,EAAG,MACxBtC,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAbnB,IAXF,CA9CD,CADD;AAgFA;;eAEcN,S","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} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\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\tsetAttributes,\n\tonReplace,\n\tisSelected,\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: ( [ media ] ) => onSelectAudio( media ),\n\t\t\t\t\tonError: ( e ) => onUploadError( e ),\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\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\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\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\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t) }\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(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</figure>\n\t\t</>\n\t);\n}\n\nexport default AudioEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","setAttributes","onReplace","isSelected","insertBlocksAfter","id","autoplay","caption","loop","preload","src","prevCaption","showCaption","setShowCaption","isTemporaryAudio","mediaUpload","select","getSettings","blockEditorStore","file","filesList","onFileChange","media","onSelectAudio","onError","e","onUploadError","allowedTypes","captionRef","node","focus","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","url","undefined","createErrorNotice","noticesStore","message","type","getAutoplayHelp","checked","classes","blockProps","icon","captionIcon","value","label","RichText","isEmpty"],"mappings":";;;;;;;;;AA4BA;;AAzBA;;AAKA;;AACA;;AAQA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;A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,CAVf;AAYC,IAAA,aAAa,MAZd;AAaC,IAAA,sBAAsB,EAAG,MACxB7C,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAdnB,IAZH,CA/DD,CADD;AAmGA;;eAEcN,S","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\tToolbarButton,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { audio as icon, caption as captionIcon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { usePrevious } from '@wordpress/compose';\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\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst prevCaption = usePrevious( caption );\n\tconst [ showCaption, setShowCaption ] = useState( !! caption );\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: ( [ media ] ) => onSelectAudio( media ),\n\t\t\t\t\tonError: ( e ) => onUploadError( e ),\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\t// We need to show the caption when changes come from\n\t// history navigation(undo/redo).\n\tuseEffect( () => {\n\t\tif ( caption && ! prevCaption ) {\n\t\t\tsetShowCaption( true );\n\t\t}\n\t}, [ caption, prevCaption ] );\n\n\t// Focus the caption when we click to add one.\n\tconst captionRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( node && ! caption ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ caption ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected && ! caption ) {\n\t\t\tsetShowCaption( false );\n\t\t}\n\t}, [ isSelected, caption ] );\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\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\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( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t} );\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( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tcaption: media.caption,\n\t\t} );\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\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=\"block\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCaption( ! showCaption );\n\t\t\t\t\t\tif ( showCaption && caption ) {\n\t\t\t\t\t\t\tsetAttributes( { caption: undefined } );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\ticon={ captionIcon }\n\t\t\t\t\tisPressed={ showCaption }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCaption\n\t\t\t\t\t\t\t? __( 'Remove caption' )\n\t\t\t\t\t\t\t: __( 'Add caption' )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</BlockControls>\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{ showCaption &&\n\t\t\t\t\t( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\t\tclassName={ __experimentalGetElementClassName(\n\t\t\t\t\t\t\t\t'caption'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tref={ captionRef }\n\t\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\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</figure>\n\t\t</>\n\t);\n}\n\nexport default AudioEdit;\n"]}
@@ -203,7 +203,7 @@ function ButtonEdit(props) {
203
203
  onClick: unlink,
204
204
  isActive: true
205
205
  })), isSelected && (isEditingURL || isURLSet) && (0, _element.createElement)(_components.Popover, {
206
- position: "bottom center",
206
+ placement: "bottom",
207
207
  onClose: () => {
208
208
  var _richTextRef$current2;
209
209
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/button/edit.js"],"names":["NEW_TAB_REL","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","map","widthValue","ButtonEdit","props","attributes","className","isSelected","onReplace","mergeBlocks","linkTarget","placeholder","rel","style","text","url","onSetLinkRel","value","onToggleOpenInNewTab","newLinkTarget","updatedRel","setButtonText","newText","replace","onKeyDown","event","isKeyboardEvent","primary","startEditing","primaryShift","unlink","richTextRef","current","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","ref","blockProps","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","preventDefault","fontSize","border","radius","link","displayShortcut","linkOff","newURL","newOpensInNewTab"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AAQA;;AAWA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;AA2BA,MAAMA,WAAW,GAAG,qBAApB;;AAEA,SAASC,UAAT,OAAwD;AAAA,MAAnC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,GAAmC;;AACvD,WAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACjC;AACA,UAAMC,KAAK,GAAGJ,aAAa,KAAKG,QAAlB,GAA6BE,SAA7B,GAAyCF,QAAvD,CAFiC,CAIjC;;AACAF,IAAAA,aAAa,CAAE;AAAEG,MAAAA;AAAF,KAAF,CAAb;AACA;;AAED,SACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,gBAAJ;AAAnB,KACC,4BAAC,uBAAD;AAAa,kBAAa,cAAI,cAAJ;AAA1B,KACG,CAAE,EAAF,EAAM,EAAN,EAAU,EAAV,EAAc,GAAd,EAAoBE,GAApB,CAA2BC,UAAF,IAAkB;AAC5C,WACC,4BAAC,kBAAD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,EAAG;AAAE1B,MAAAA,GAAF;AAAO6B,MAAAA;AAAP,KAFT;AAGC,IAAA,QAAQ,EAAG,SAGJ;AAAA,UAHM;AACZ7B,QAAAA,GAAG,EAAEqC,MAAM,GAAG,EADF;AAEZR,QAAAA,aAAa,EAAES;AAFH,OAGN;AACNzD,MAAAA,aAAa,CAAE;AAAEmB,QAAAA,GAAG,EAAEqC;AAAP,OAAF,CAAb;;AAEA,UAAKR,aAAa,KAAKS,gBAAvB,EAA0C;AACzCnC,QAAAA,oBAAoB,CAAEmC,gBAAF,CAApB;AACA;AACD,KAZF;AAaC,IAAA,QAAQ,EAAG,MAAM;AAAA;;AAChBvB,MAAAA,MAAM;AACN,+BAAAC,WAAW,CAACC,OAAZ,gFAAqBC,KAArB;AACA,KAhBF;AAiBC,IAAA,kBAAkB,EAAGQ;AAjBtB,IAXD,CAlEF,EAkGC,4BAAC,8BAAD,QACC,4BAAC,UAAD;AACC,IAAA,aAAa,EAAG1C,KADjB;AAEC,IAAA,aAAa,EAAGH;AAFjB,IADD,CAlGD,EAwGC,4BAAC,8BAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,UAAJ,CADT;AAEC,IAAA,KAAK,EAAGgB,GAAG,IAAI,EAFhB;AAGC,IAAA,QAAQ,EAAGI;AAHZ,IADD,CAxGD,CADD;AAkHA;;eAEcb,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\n\nconst NEW_TAB_REL = 'noreferrer noopener';\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t} = props;\n\tconst { linkTarget, placeholder, rel, style, text, url, width } =\n\t\tattributes;\n\tconst onSetLinkRel = useCallback(\n\t\t( value ) => {\n\t\t\tsetAttributes( { rel: value } );\n\t\t},\n\t\t[ setAttributes ]\n\t);\n\n\tfunction onToggleOpenInNewTab( value ) {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel = rel;\n\t\tif ( newLinkTarget && ! rel ) {\n\t\t\tupdatedRel = NEW_TAB_REL;\n\t\t} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {\n\t\t\tupdatedRel = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t} );\n\t}\n\n\tfunction setButtonText( newText ) {\n\t\t// Remove anchor tags from button text content.\n\t\tsetAttributes( { text: newText.replace( /<\\/?a[^>]*>/g, '' ) } );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === '_blank';\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ richTextRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) => setButtonText( value ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ ! isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isSelected && ( isEditingURL || isURLSet ) && (\n\t\t\t\t<Popover\n\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\n\t\t\t\t\t\tvalue={ { url, opensInNewTab } }\n\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\turl: newURL = '',\n\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: newURL } );\n\n\t\t\t\t\t\t\tif ( opensInNewTab !== newOpensInNewTab ) {\n\t\t\t\t\t\t\t\tonToggleOpenInNewTab( newOpensInNewTab );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/button/edit.js"],"names":["NEW_TAB_REL","WidthPanel","selectedWidth","setAttributes","handleChange","newWidth","width","undefined","map","widthValue","ButtonEdit","props","attributes","className","isSelected","onReplace","mergeBlocks","linkTarget","placeholder","rel","style","text","url","onSetLinkRel","value","onToggleOpenInNewTab","newLinkTarget","updatedRel","setButtonText","newText","replace","onKeyDown","event","isKeyboardEvent","primary","startEditing","primaryShift","unlink","richTextRef","current","focus","popoverAnchor","setPopoverAnchor","borderProps","colorProps","spacingProps","ref","blockProps","isEditingURL","setIsEditingURL","isURLSet","opensInNewTab","preventDefault","fontSize","border","radius","link","displayShortcut","linkOff","newURL","newOpensInNewTab"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AAQA;;AAWA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;AA2BA,MAAMA,WAAW,GAAG,qBAApB;;AAEA,SAASC,UAAT,OAAwD;AAAA,MAAnC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,GAAmC;;A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gB,GAAG,IAAI,EAFhB;AAGC,IAAA,QAAQ,EAAGI;AAHZ,IADD,CAxGD,CADD;AAkHA;;eAEcb,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport {\n\tButton,\n\tButtonGroup,\n\tPanelBody,\n\tTextControl,\n\tToolbarButton,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalGetSpacingClassesAndStyles as useSpacingProps,\n\t__experimentalLinkControl as LinkControl,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { link, linkOff } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\n\nconst NEW_TAB_REL = 'noreferrer noopener';\n\nfunction WidthPanel( { selectedWidth, setAttributes } ) {\n\tfunction handleChange( newWidth ) {\n\t\t// Check if we are toggling the width off\n\t\tconst width = selectedWidth === newWidth ? undefined : newWidth;\n\n\t\t// Update attributes.\n\t\tsetAttributes( { width } );\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Width settings' ) }>\n\t\t\t<ButtonGroup aria-label={ __( 'Button width' ) }>\n\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\twidthValue === selectedWidth\n\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => handleChange( widthValue ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ButtonGroup>\n\t\t</PanelBody>\n\t);\n}\n\nfunction ButtonEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tclassName,\n\t\tisSelected,\n\t\tonReplace,\n\t\tmergeBlocks,\n\t} = props;\n\tconst { linkTarget, placeholder, rel, style, text, url, width } =\n\t\tattributes;\n\tconst onSetLinkRel = useCallback(\n\t\t( value ) => {\n\t\t\tsetAttributes( { rel: value } );\n\t\t},\n\t\t[ setAttributes ]\n\t);\n\n\tfunction onToggleOpenInNewTab( value ) {\n\t\tconst newLinkTarget = value ? '_blank' : undefined;\n\n\t\tlet updatedRel = rel;\n\t\tif ( newLinkTarget && ! rel ) {\n\t\t\tupdatedRel = NEW_TAB_REL;\n\t\t} else if ( ! newLinkTarget && rel === NEW_TAB_REL ) {\n\t\t\tupdatedRel = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tlinkTarget: newLinkTarget,\n\t\t\trel: updatedRel,\n\t\t} );\n\t}\n\n\tfunction setButtonText( newText ) {\n\t\t// Remove anchor tags from button text content.\n\t\tsetAttributes( { text: newText.replace( /<\\/?a[^>]*>/g, '' ) } );\n\t}\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tstartEditing( event );\n\t\t} else if ( isKeyboardEvent.primaryShift( event, 'k' ) ) {\n\t\t\tunlink();\n\t\t\trichTextRef.current?.focus();\n\t\t}\n\t}\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst colorProps = useColorProps( attributes );\n\tconst spacingProps = useSpacingProps( attributes );\n\tconst ref = useRef();\n\tconst richTextRef = useRef();\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, ref ] ),\n\t\tonKeyDown,\n\t} );\n\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst isURLSet = !! url;\n\tconst opensInNewTab = linkTarget === '_blank';\n\n\tfunction startEditing( event ) {\n\t\tevent.preventDefault();\n\t\tsetIsEditingURL( true );\n\t}\n\n\tfunction unlink() {\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlinkTarget: undefined,\n\t\t\trel: undefined,\n\t\t} );\n\t\tsetIsEditingURL( false );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsEditingURL( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( blockProps.className, {\n\t\t\t\t\t[ `has-custom-width wp-block-button__width-${ width }` ]:\n\t\t\t\t\t\twidth,\n\t\t\t\t\t[ `has-custom-font-size` ]: blockProps.style.fontSize,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ richTextRef }\n\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Add text…' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tonChange={ ( value ) => setButtonText( value ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'wp-block-button__link',\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// For backwards compatibility add style that isn't\n\t\t\t\t\t\t\t// provided via block support.\n\t\t\t\t\t\t\t'no-border-radius': style?.border?.radius === 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t...colorProps.style,\n\t\t\t\t\t\t...spacingProps.style,\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\t\tcreateBlock( 'core/button', {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\ttext: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t}\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tidentifier=\"text\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t{ ! isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ startEditing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isURLSet && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkOff }\n\t\t\t\t\t\ttitle={ __( 'Unlink' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primaryShift( 'k' ) }\n\t\t\t\t\t\tonClick={ unlink }\n\t\t\t\t\t\tisActive={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\t\t\t{ isSelected && ( isEditingURL || isURLSet ) && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom\"\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t} }\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tfocusOnMount={ isEditingURL ? 'firstElement' : false }\n\t\t\t\t\t__unstableSlotName={ '__unstable-block-tools-after' }\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\n\t\t\t\t\t\tvalue={ { url, opensInNewTab } }\n\t\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\t\turl: newURL = '',\n\t\t\t\t\t\t\topensInNewTab: newOpensInNewTab,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: newURL } );\n\n\t\t\t\t\t\t\tif ( opensInNewTab !== newOpensInNewTab ) {\n\t\t\t\t\t\t\t\tonToggleOpenInNewTab( newOpensInNewTab );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tunlink();\n\t\t\t\t\t\t\trichTextRef.current?.focus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tforceIsEditingLink={ isEditingURL }\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<WidthPanel\n\t\t\t\t\tselectedWidth={ width }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\tonChange={ onSetLinkRel }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n\nexport default ButtonEdit;\n"]}
@@ -143,7 +143,7 @@ function ButtonsEdit(_ref) {
143
143
  }),
144
144
  popoverProps: {
145
145
  position: 'bottom right',
146
- isAlternate: true
146
+ variant: 'toolbar'
147
147
  }
148
148
  })), resizeObserver, (0, _element.createElement)(_blockEditor.InnerBlocks, {
149
149
  allowedBlocks: ALLOWED_BLOCKS,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/buttons/edit.native.js"],"names":["ALLOWED_BLOCKS","buttonBlockName","layoutProp","type","alignments","ButtonsEdit","attributes","layout","align","clientId","isSelected","setAttributes","blockWidth","name","resizeObserver","sizes","maxWidth","setMaxWidth","marginLeft","spacing","styles","layoutBlockSupport","defaultBlockLayout","default","usedLayout","justifyContent","isInnerButtonSelected","shouldDelete","select","getBlockCount","getBlockParents","getSelectedBlockClientId","blockEditorStore","selectedBlockClientId","selectedBlockParents","preferredStyle","preferredStyleVariations","getSettings","__experimentalPreferredStyleVariations","value","getBlockOrder","insertBlock","removeBlock","selectBlock","width","isFullWidth","alignmentHelpers","isFullWidthBlock","onAddNextButton","selectedId","order","selectedButtonIndex","findIndex","i","index","length","insertedBlock","renderFooterAppender","appenderContainer","justifyControls","remove","shouldRenderFooterAppender","position","isAlternate","className","current","undefined"],"mappings":";;;;;;;;;AAiBA;;AAdA;;AAKA;;AAMA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,cAAc,GAAG,CAAEC,YAAF,CAAvB;AAEA,MAAMC,UAAU,GAAG;AAAEC,EAAAA,IAAI,EAAE,SAAR;AAAmBC,EAAAA,UAAU,EAAE;AAA/B,CAAnB;;AAEe,SAASC,WAAT,OAOX;AAAA,MAPiC;AACpCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KADwB;AAEpCC,IAAAA,QAFoC;AAGpCC,IAAAA,UAHoC;AAIpCC,IAAAA,aAJoC;AAKpCC,IAAAA,UALoC;AAMpCC,IAAAA;AANoC,GAOjC;AACH,QAAM,CAAEC,cAAF,EAAkBC,KAAlB,IAA4B,iCAAlC;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,CAAV,CAAlC;AACA,QAAM;AAAEC,IAAAA,UAAU,EAAEC;AAAd,MAA0BC,gBAAOD,OAAvC,CAH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4C,CAAEA,QAAF,CAA5C,CAAf;AACA,QAAMoD,0BAA0B,GAAGnD,UAAU,IAAIgB,qBAAjD;AACA,SACC,qDACGhB,UAAU,IACX,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,kCAAD;AACC,IAAA,eAAe,EAAGiD,eADnB;AAEC,IAAA,KAAK,EAAGlC,cAFT;AAGC,IAAA,QAAQ,EAAKc,KAAF,IACV5B,aAAa,CAAE;AACdJ,MAAAA,MAAM,EAAE,EACP,GAAGiB,UADI;AAEPC,QAAAA,cAAc,EAAEc;AAFT;AADM,KAAF,CAJf;AAWC,IAAA,YAAY,EAAG;AACduB,MAAAA,QAAQ,EAAE,cADI;AAEdC,MAAAA,WAAW,EAAE;AAFC;AAXhB,IADD,CAFF,EAqBGjD,cArBH,EAsBC,4BAAC,wBAAD;AACC,IAAA,aAAa,EAAGd,cADjB;AAEC,IAAA,QAAQ,EAAG,CACV,CACCC,YADD,EAEC;AACC+D,MAAAA,SAAS,EACR7B,cAAc,IACb,YAAYA,cAAgB;AAH/B,KAFD,CADU,CAFZ;AAYC,IAAA,oBAAoB,EACnB0B,0BAA0B,IAAIJ,oBAAoB,CAACQ,OAbrD;AAeC,IAAA,WAAW,EAAC,YAfb;AAgBC,IAAA,mBAAmB,EAAGxC,cAhBvB;AAiBC,IAAA,aAAa,EAAGE,YAAY,GAAGiC,MAAH,GAAYM,SAjBzC;AAkBC,IAAA,UAAU,EAAGlB,eAlBd;AAmBC,IAAA,WAAW,EAAGhC,QAnBf,CAmB0B;AAnB1B;AAoBC,IAAA,gBAAgB,EAAGG,OApBpB;AAqBC,IAAA,cAAc,EAAGA,OArBlB;AAsBC,IAAA,oBAAoB,EAAGjB,UAtBxB;AAuBC,IAAA,8BAA8B,MAvB/B;AAwBC,IAAA,UAAU,EAAGU;AAxBd,IAtBD,CADD;AAmDA","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tJustifyContentControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { createBlock, getBlockSupport } from '@wordpress/blocks';\nimport { debounce, useResizeObserver } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { alignmentHelpers } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { name as buttonBlockName } from '../button/';\nimport styles from './editor.scss';\n\nconst ALLOWED_BLOCKS = [ buttonBlockName ];\n\nconst layoutProp = { type: 'default', alignments: [] };\n\nexport default function ButtonsEdit( {\n\tattributes: { layout, align },\n\tclientId,\n\tisSelected,\n\tsetAttributes,\n\tblockWidth,\n\tname,\n} ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ maxWidth, setMaxWidth ] = useState( 0 );\n\tconst { marginLeft: spacing } = styles.spacing;\n\n\t// Extract attributes from block layout\n\tconst layoutBlockSupport = getBlockSupport( name, '__experimentalLayout' );\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { justifyContent } = usedLayout;\n\n\tconst { isInnerButtonSelected, shouldDelete } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, getBlockParents, getSelectedBlockClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst selectedBlockParents = getBlockParents(\n\t\t\t\tselectedBlockClientId,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tisInnerButtonSelected: selectedBlockParents[ 0 ] === clientId,\n\t\t\t\t// The purpose of `shouldDelete` check is giving the ability to\n\t\t\t\t// pass to mobile toolbar function called `onDelete` which removes\n\t\t\t\t// the whole `Buttons` container along with the last inner button\n\t\t\t\t// when there is exactly one button.\n\t\t\t\tshouldDelete: getBlockCount( clientId ) === 1,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst preferredStyle = useSelect( ( select ) => {\n\t\tconst preferredStyleVariations =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalPreferredStyleVariations;\n\t\treturn preferredStyleVariations?.value?.[ buttonBlockName ];\n\t}, [] );\n\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst { insertBlock, removeBlock, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tconst { width } = sizes || {};\n\t\tconst { isFullWidth } = alignmentHelpers;\n\n\t\tif ( width ) {\n\t\t\tconst isFullWidthBlock = isFullWidth( align );\n\t\t\tsetMaxWidth( isFullWidthBlock ? blockWidth : width );\n\t\t}\n\t}, [ sizes, align ] );\n\n\tconst onAddNextButton = useCallback(\n\t\tdebounce( ( selectedId ) => {\n\t\t\tconst order = getBlockOrder( clientId );\n\t\t\tconst selectedButtonIndex = order.findIndex(\n\t\t\t\t( i ) => i === selectedId\n\t\t\t);\n\n\t\t\tconst index =\n\t\t\t\tselectedButtonIndex === -1\n\t\t\t\t\t? order.length + 1\n\t\t\t\t\t: selectedButtonIndex;\n\n\t\t\tconst insertedBlock = createBlock( 'core/button' );\n\n\t\t\tinsertBlock( insertedBlock, index, clientId );\n\t\t\tselectBlock( insertedBlock.clientId );\n\t\t}, 200 ),\n\t\t[]\n\t);\n\n\tconst renderFooterAppender = useRef( () => (\n\t\t<View style={ styles.appenderContainer }>\n\t\t\t<InnerBlocks.ButtonBlockAppender\n\t\t\t\tisFloating={ true }\n\t\t\t\tonAddBlock={ onAddNextButton }\n\t\t\t/>\n\t\t</View>\n\t) );\n\n\tconst justifyControls = [ 'left', 'center', 'right' ];\n\n\tconst remove = useCallback( () => removeBlock( clientId ), [ clientId ] );\n\tconst shouldRenderFooterAppender = isSelected || isInnerButtonSelected;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<JustifyContentControl\n\t\t\t\t\t\tallowedControls={ justifyControls }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...usedLayout,\n\t\t\t\t\t\t\t\t\tjustifyContent: value,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tisAlternate: true,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ resizeObserver }\n\t\t\t<InnerBlocks\n\t\t\t\tallowedBlocks={ ALLOWED_BLOCKS }\n\t\t\t\ttemplate={ [\n\t\t\t\t\t[\n\t\t\t\t\t\tbuttonBlockName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\tpreferredStyle &&\n\t\t\t\t\t\t\t\t`is-style-${ preferredStyle }`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t] }\n\t\t\t\trenderFooterAppender={\n\t\t\t\t\tshouldRenderFooterAppender && renderFooterAppender.current\n\t\t\t\t}\n\t\t\t\torientation=\"horizontal\"\n\t\t\t\thorizontalAlignment={ justifyContent }\n\t\t\t\tonDeleteBlock={ shouldDelete ? remove : undefined }\n\t\t\t\tonAddBlock={ onAddNextButton }\n\t\t\t\tparentWidth={ maxWidth } // This value controls the width of that the buttons are able to expand to.\n\t\t\t\tmarginHorizontal={ spacing }\n\t\t\t\tmarginVertical={ spacing }\n\t\t\t\t__experimentalLayout={ layoutProp }\n\t\t\t\ttemplateInsertUpdatesSelection\n\t\t\t\tblockWidth={ blockWidth }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/buttons/edit.native.js"],"names":["ALLOWED_BLOCKS","buttonBlockName","layoutProp","type","alignments","ButtonsEdit","attributes","layout","align","clientId","isSelected","setAttributes","blockWidth","name","resizeObserver","sizes","maxWidth","setMaxWidth","marginLeft","spacing","styles","layoutBlockSupport","defaultBlockLayout","default","usedLayout","justifyContent","isInnerButtonSelected","shouldDelete","select","getBlockCount","getBlockParents","getSelectedBlockClientId","blockEditorStore","selectedBlockClientId","selectedBlockParents","preferredStyle","preferredStyleVariations","getSettings","__experimentalPreferredStyleVariations","value","getBlockOrder","insertBlock","removeBlock","selectBlock","width","isFullWidth","alignmentHelpers","isFullWidthBlock","onAddNextButton","selectedId","order","selectedButtonIndex","findIndex","i","index","length","insertedBlock","renderFooterAppender","appenderContainer","justifyControls","remove","shouldRenderFooterAppender","position","variant","className","current","undefined"],"mappings":";;;;;;;;;AAiBA;;AAdA;;AAKA;;AAMA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,cAAc,GAAG,CAAEC,YAAF,CAAvB;AAEA,MAAMC,UAAU,GAAG;AAAEC,EAAAA,IAAI,EAAE,SAAR;AAAmBC,EAAAA,UAAU,EAAE;AAA/B,CAAnB;;AAEe,SAASC,WAAT,OAOX;AAAA,MAPiC;AACpCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KADwB;AAEpCC,IAAAA,QAFoC;AAGpCC,IAAAA,UAHoC;AAIpCC,IAAAA,aAJoC;AAKpCC,IAAAA,UALoC;AAMpCC,IAAAA;AANoC,GAOjC;AACH,QAAM,CAAEC,cAAF,EAAkBC,KAAlB,IAA4B,iCAAlC;AACA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,CAAV,CAAlC;AACA,QAAM;AAAEC,IAAAA,UAAU,EAAEC;AAAd,MAA0BC,gBAAOD,OAAvC,CAHG,CAKH;;AACA,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F,CAA5C,CAAf;AACA,QAAMoD,0BAA0B,GAAGnD,UAAU,IAAIgB,qBAAjD;AACA,SACC,qDACGhB,UAAU,IACX,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,kCAAD;AACC,IAAA,eAAe,EAAGiD,eADnB;AAEC,IAAA,KAAK,EAAGlC,cAFT;AAGC,IAAA,QAAQ,EAAKc,KAAF,IACV5B,aAAa,CAAE;AACdJ,MAAAA,MAAM,EAAE,EACP,GAAGiB,UADI;AAEPC,QAAAA,cAAc,EAAEc;AAFT;AADM,KAAF,CAJf;AAWC,IAAA,YAAY,EAAG;AACduB,MAAAA,QAAQ,EAAE,cADI;AAEdC,MAAAA,OAAO,EAAE;AAFK;AAXhB,IADD,CAFF,EAqBGjD,cArBH,EAsBC,4BAAC,wBAAD;AACC,IAAA,aAAa,EAAGd,cADjB;AAEC,IAAA,QAAQ,EAAG,CACV,CACCC,YADD,EAEC;AACC+D,MAAAA,SAAS,EACR7B,cAAc,IACb,YAAYA,cAAgB;AAH/B,KAFD,CADU,CAFZ;AAYC,IAAA,oBAAoB,EACnB0B,0BAA0B,IAAIJ,oBAAoB,CAACQ,OAbrD;AAeC,IAAA,WAAW,EAAC,YAfb;AAgBC,IAAA,mBAAmB,EAAGxC,cAhBvB;AAiBC,IAAA,aAAa,EAAGE,YAAY,GAAGiC,MAAH,GAAYM,SAjBzC;AAkBC,IAAA,UAAU,EAAGlB,eAlBd;AAmBC,IAAA,WAAW,EAAGhC,QAnBf,CAmB0B;AAnB1B;AAoBC,IAAA,gBAAgB,EAAGG,OApBpB;AAqBC,IAAA,cAAc,EAAGA,OArBlB;AAsBC,IAAA,oBAAoB,EAAGjB,UAtBxB;AAuBC,IAAA,8BAA8B,MAvB/B;AAwBC,IAAA,UAAU,EAAGU;AAxBd,IAtBD,CADD;AAmDA","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tJustifyContentControl,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { createBlock, getBlockSupport } from '@wordpress/blocks';\nimport { debounce, useResizeObserver } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { alignmentHelpers } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { name as buttonBlockName } from '../button/';\nimport styles from './editor.scss';\n\nconst ALLOWED_BLOCKS = [ buttonBlockName ];\n\nconst layoutProp = { type: 'default', alignments: [] };\n\nexport default function ButtonsEdit( {\n\tattributes: { layout, align },\n\tclientId,\n\tisSelected,\n\tsetAttributes,\n\tblockWidth,\n\tname,\n} ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ maxWidth, setMaxWidth ] = useState( 0 );\n\tconst { marginLeft: spacing } = styles.spacing;\n\n\t// Extract attributes from block layout\n\tconst layoutBlockSupport = getBlockSupport( name, '__experimentalLayout' );\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { justifyContent } = usedLayout;\n\n\tconst { isInnerButtonSelected, shouldDelete } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, getBlockParents, getSelectedBlockClientId } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\tconst selectedBlockParents = getBlockParents(\n\t\t\t\tselectedBlockClientId,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tisInnerButtonSelected: selectedBlockParents[ 0 ] === clientId,\n\t\t\t\t// The purpose of `shouldDelete` check is giving the ability to\n\t\t\t\t// pass to mobile toolbar function called `onDelete` which removes\n\t\t\t\t// the whole `Buttons` container along with the last inner button\n\t\t\t\t// when there is exactly one button.\n\t\t\t\tshouldDelete: getBlockCount( clientId ) === 1,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst preferredStyle = useSelect( ( select ) => {\n\t\tconst preferredStyleVariations =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalPreferredStyleVariations;\n\t\treturn preferredStyleVariations?.value?.[ buttonBlockName ];\n\t}, [] );\n\n\tconst { getBlockOrder } = useSelect( blockEditorStore );\n\tconst { insertBlock, removeBlock, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tconst { width } = sizes || {};\n\t\tconst { isFullWidth } = alignmentHelpers;\n\n\t\tif ( width ) {\n\t\t\tconst isFullWidthBlock = isFullWidth( align );\n\t\t\tsetMaxWidth( isFullWidthBlock ? blockWidth : width );\n\t\t}\n\t}, [ sizes, align ] );\n\n\tconst onAddNextButton = useCallback(\n\t\tdebounce( ( selectedId ) => {\n\t\t\tconst order = getBlockOrder( clientId );\n\t\t\tconst selectedButtonIndex = order.findIndex(\n\t\t\t\t( i ) => i === selectedId\n\t\t\t);\n\n\t\t\tconst index =\n\t\t\t\tselectedButtonIndex === -1\n\t\t\t\t\t? order.length + 1\n\t\t\t\t\t: selectedButtonIndex;\n\n\t\t\tconst insertedBlock = createBlock( 'core/button' );\n\n\t\t\tinsertBlock( insertedBlock, index, clientId );\n\t\t\tselectBlock( insertedBlock.clientId );\n\t\t}, 200 ),\n\t\t[]\n\t);\n\n\tconst renderFooterAppender = useRef( () => (\n\t\t<View style={ styles.appenderContainer }>\n\t\t\t<InnerBlocks.ButtonBlockAppender\n\t\t\t\tisFloating={ true }\n\t\t\t\tonAddBlock={ onAddNextButton }\n\t\t\t/>\n\t\t</View>\n\t) );\n\n\tconst justifyControls = [ 'left', 'center', 'right' ];\n\n\tconst remove = useCallback( () => removeBlock( clientId ), [ clientId ] );\n\tconst shouldRenderFooterAppender = isSelected || isInnerButtonSelected;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<JustifyContentControl\n\t\t\t\t\t\tallowedControls={ justifyControls }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...usedLayout,\n\t\t\t\t\t\t\t\t\tjustifyContent: value,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tvariant: 'toolbar',\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ resizeObserver }\n\t\t\t<InnerBlocks\n\t\t\t\tallowedBlocks={ ALLOWED_BLOCKS }\n\t\t\t\ttemplate={ [\n\t\t\t\t\t[\n\t\t\t\t\t\tbuttonBlockName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\tpreferredStyle &&\n\t\t\t\t\t\t\t\t`is-style-${ preferredStyle }`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t] }\n\t\t\t\trenderFooterAppender={\n\t\t\t\t\tshouldRenderFooterAppender && renderFooterAppender.current\n\t\t\t\t}\n\t\t\t\torientation=\"horizontal\"\n\t\t\t\thorizontalAlignment={ justifyContent }\n\t\t\t\tonDeleteBlock={ shouldDelete ? remove : undefined }\n\t\t\t\tonAddBlock={ onAddNextButton }\n\t\t\t\tparentWidth={ maxWidth } // This value controls the width of that the buttons are able to expand to.\n\t\t\t\tmarginHorizontal={ spacing }\n\t\t\t\tmarginVertical={ spacing }\n\t\t\t\t__experimentalLayout={ layoutProp }\n\t\t\t\ttemplateInsertUpdatesSelection\n\t\t\t\tblockWidth={ blockWidth }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -40,6 +40,7 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
40
40
  *
41
41
  * @param {Object} settings Discussion Settings.
42
42
  * @param {number} [settings.perPage] - Comments per page setting or block attribute.
43
+ * @param {boolean} [settings.pageComments] - Enable break comments into pages setting.
43
44
  * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
44
45
  * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
45
46
  *
@@ -50,44 +51,49 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
50
51
  const getCommentsPlaceholder = _ref => {
51
52
  let {
52
53
  perPage,
54
+ pageComments,
53
55
  threadComments,
54
56
  threadCommentsDepth
55
57
  } = _ref;
56
- // In case that `threadCommentsDepth` is falsy, we default to a somewhat
57
- // arbitrary value of 3.
58
- // In case that the value is set but larger than 3 we truncate it to 3.
59
- const commentsDepth = Math.min(threadCommentsDepth || 3, 3); // We set a limit in order not to overload the editor of empty comments.
60
-
61
- const defaultCommentsToShow = perPage <= commentsDepth ? perPage : commentsDepth;
62
-
63
- if (!threadComments || defaultCommentsToShow === 1) {
64
- // If displaying threaded comments is disabled, we only show one comment
65
- // A commentId is negative in order to avoid conflicts with the actual comments.
66
- return [{
67
- commentId: -1,
68
- children: []
69
- }];
70
- } else if (defaultCommentsToShow === 2) {
71
- return [{
72
- commentId: -1,
73
- children: [{
74
- commentId: -2,
75
- children: []
76
- }]
77
- }];
78
- } // In case that the value is set but larger than 3 we truncate it to 3.
58
+ // Limit commentsDepth to 3
59
+ const commentsDepth = !threadComments ? 1 : Math.min(threadCommentsDepth, 3);
60
+
61
+ const buildChildrenComment = commentsLevel => {
62
+ // Render children comments until commentsDepth is reached
63
+ if (commentsLevel < commentsDepth) {
64
+ const nextLevel = commentsLevel + 1;
65
+ return [{
66
+ commentId: -(commentsLevel + 3),
67
+ children: buildChildrenComment(nextLevel)
68
+ }];
69
+ }
70
+
71
+ return [];
72
+ }; // Add the first comment and its children
79
73
 
80
74
 
81
- return [{
75
+ const placeholderComments = [{
82
76
  commentId: -1,
83
- children: [{
77
+ children: buildChildrenComment(1)
78
+ }]; // Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max
79
+
80
+ if ((!pageComments || perPage >= 2) && commentsDepth < 3) {
81
+ placeholderComments.push({
84
82
  commentId: -2,
85
- children: [{
86
- commentId: -3,
87
- children: []
88
- }]
89
- }]
90
- }];
83
+ children: []
84
+ });
85
+ } // Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments
86
+
87
+
88
+ if ((!pageComments || perPage >= 3) && commentsDepth < 2) {
89
+ placeholderComments.push({
90
+ commentId: -3,
91
+ children: []
92
+ });
93
+ } // In case that the value is set but larger than 3 we truncate it to 3.
94
+
95
+
96
+ return placeholderComments;
91
97
  };
92
98
  /**
93
99
  * Component which renders the inner blocks of the Comment Template.
@@ -232,7 +238,8 @@ function CommentTemplateEdit(_ref6) {
232
238
  commentOrder,
233
239
  threadCommentsDepth,
234
240
  threadComments,
235
- commentsPerPage
241
+ commentsPerPage,
242
+ pageComments
236
243
  } = (0, _data.useSelect)(select => {
237
244
  const {
238
245
  getSettings
@@ -269,6 +276,7 @@ function CommentTemplateEdit(_ref6) {
269
276
  if (!postId) {
270
277
  commentTree = getCommentsPlaceholder({
271
278
  perPage: commentsPerPage,
279
+ pageComments,
272
280
  threadComments,
273
281
  threadCommentsDepth
274
282
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,GAAL,CAAUH,mBAAmB,IAAI,CAAjC,EAAoC,CAApC,CAAtB,CAJM,CAMN;;AACA,QAAMI,qBAAqB,GAC1BN,OAAO,IAAIG,aAAX,GAA2BH,OAA3B,GAAqCG,aADtC;;AAEA,MAAK,CAAEF,cAAF,IAAoBK,qBAAqB,KAAK,CAAnD,EAAuD;AACtD;AACA;AACA,WAAO,CAAE;AAAEC,MAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,MAAAA,QAAQ,EAAE;AAA3B,KAAF,CAAP;AACA,GAJD,MAIO,IAAKF,qBAAqB,KAAK,CAA/B,EAAmC;AACzC,WAAO,CACN;AACCC,MAAAA,SAAS,EAAE,CAAC,CADb;AAECC,MAAAA,QAAQ,EAAE,CAAE;AAAED,QAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,QAAAA,QAAQ,EAAE;AAA3B,OAAF;AAFX,KADM,CAAP;AAMA,GApBK,CAsBN;;;AACA,SAAO,CACN;AACCD,IAAAA,SAAS,EAAE,CAAC,CADb;AAECC,IAAAA,QAAQ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,GAXmC,EAYpC,CAAEA,QAAF,EAAYS,YAAZ,CAZoC,CAArC,CAlBG,CAiCH;;AACA,MAAIK,WAAW,GAAG,4BACjB;AACAX,EAAAA,YAAY,KAAK,MAAjB,IAA2BO,gBAA3B,GACG,CAAE,GAAGA,gBAAL,EAAwBK,OAAxB,EADH,GAEGL,gBAJc,CAAlB;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,iCAAQd,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfY,IAAAA,WAAW,GAAG/C,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEoC,eAD4B;AAErCnC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE4C,WAAW,CAAC7B,MAAnB,EAA4B;AAC3B,WAAO,iCAAQW,UAAR,EAAuB,cAAI,mBAAJ,CAAvB,CAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGkB,WADZ;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBvC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }>{ __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","pageComments","threadComments","threadCommentsDepth","commentsDepth","Math","min","buildChildrenComment","commentsLevel","nextLevel","commentId","children","placeholderComments","push","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFg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,EAAE+B,SAAS,CAAEb,QAAF;AALX,KAAP;AAOA,GAXmC,EAYpC,CAAEA,QAAF,EAAYS,YAAZ,CAZoC,CAArC,CAnBG,CAkCH;;AACA,MAAIK,WAAW,GAAG,4BACjB;AACAX,EAAAA,YAAY,KAAK,MAAjB,IAA2BO,gBAA3B,GACG,CAAE,GAAGA,gBAAL,EAAwBK,OAAxB,EADH,GAEGL,gBAJc,CAAlB;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,iCAAQd,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfY,IAAAA,WAAW,GAAGpD,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEyC,eAD4B;AAErCxC,MAAAA,YAFqC;AAGrCC,MAAAA,cAHqC;AAIrCC,MAAAA;AAJqC,KAAF,CAApC;AAMA;;AAED,MAAK,CAAEgD,WAAW,CAAC7B,MAAnB,EAA4B;AAC3B,WAAO,iCAAQW,UAAR,EAAuB,cAAI,mBAAJ,CAAvB,CAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGkB,WADZ;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBzC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.pageComments] - Enable break comments into pages setting.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tpageComments,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// Limit commentsDepth to 3\n\tconst commentsDepth = ! threadComments\n\t\t? 1\n\t\t: Math.min( threadCommentsDepth, 3 );\n\n\tconst buildChildrenComment = ( commentsLevel ) => {\n\t\t// Render children comments until commentsDepth is reached\n\t\tif ( commentsLevel < commentsDepth ) {\n\t\t\tconst nextLevel = commentsLevel + 1;\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -( commentsLevel + 3 ),\n\t\t\t\t\tchildren: buildChildrenComment( nextLevel ),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t};\n\n\t// Add the first comment and its children\n\tconst placeholderComments = [\n\t\t{ commentId: -1, children: buildChildrenComment( 1 ) },\n\t];\n\n\t// Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max\n\tif ( ( ! pageComments || perPage >= 2 ) && commentsDepth < 3 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -2,\n\t\t\tchildren: [],\n\t\t} );\n\t}\n\n\t// Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments\n\tif ( ( ! pageComments || perPage >= 3 ) && commentsDepth < 2 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -3,\n\t\t\tchildren: [],\n\t\t} );\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn placeholderComments;\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\t is ALWAYS rendered and the preview for the active block is hidden.\n\t\t\t This ensures that when switching the active block, the component is not\n\t\t\t mounted again but rather it only toggles the `isHidden` prop.\n\t\t\t The same strategy is used for preventing the flicker in the Post Template\n\t\t\t block. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tpageComments,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }>{ __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
@@ -33,9 +33,13 @@ const metadata = {
33
33
  textdomain: "default",
34
34
  usesContext: ["postId"],
35
35
  supports: {
36
- reusable: false,
37
- html: false,
38
36
  align: true,
37
+ html: false,
38
+ reusable: false,
39
+ spacing: {
40
+ margin: true,
41
+ padding: true
42
+ },
39
43
  typography: {
40
44
  fontSize: true,
41
45
  lineHeight: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/index.js"],"names":["name","metadata","settings","icon","edit","save","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB;;;AAMA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEN,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { layout as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/index.js"],"names":["name","metadata","settings","icon","edit","save","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB;;;AAMA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEN,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { layout as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -17,8 +17,6 @@ var _data = require("@wordpress/data");
17
17
 
18
18
  var _coreData = require("@wordpress/core-data");
19
19
 
20
- var _compose = require("@wordpress/compose");
21
-
22
20
  var _form = _interopRequireDefault(require("../../post-comments-form/form"));
23
21
 
24
22
  /**
@@ -38,10 +36,9 @@ function PostCommentsPlaceholder(_ref) {
38
36
  const {
39
37
  avatarURL
40
38
  } = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings().__experimentalDiscussionSettings);
41
- const disabledRef = (0, _compose.useDisabled)();
42
39
  return (0, _element.createElement)("div", {
43
40
  className: "wp-block-comments__legacy-placeholder",
44
- ref: disabledRef
41
+ inert: "true"
45
42
  }, (0, _element.createElement)("h3", null,
46
43
  /* translators: %s: Post title. */
47
44
  (0, _i18n.sprintf)((0, _i18n.__)('One response to %s'), postTitle)), (0, _element.createElement)("div", {