@wordpress/block-library 9.17.0 → 9.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 (489) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/index.js +9 -0
  3. package/build/archives/index.js.map +1 -1
  4. package/build/avatar/user-control.js +0 -1
  5. package/build/avatar/user-control.js.map +1 -1
  6. package/build/block/deprecated.js +0 -1
  7. package/build/block/deprecated.js.map +1 -1
  8. package/build/block/edit.js +0 -1
  9. package/build/block/edit.js.map +1 -1
  10. package/build/button/deprecated.js +0 -1
  11. package/build/button/deprecated.js.map +1 -1
  12. package/build/buttons/transforms.js +0 -1
  13. package/build/buttons/transforms.js.map +1 -1
  14. package/build/categories/edit.js +0 -1
  15. package/build/categories/edit.js.map +1 -1
  16. package/build/categories/index.js +9 -0
  17. package/build/categories/index.js.map +1 -1
  18. package/build/column/column-preview.native.js +0 -1
  19. package/build/column/column-preview.native.js.map +1 -1
  20. package/build/columns/columnCalculations.native.js +0 -1
  21. package/build/columns/columnCalculations.native.js.map +1 -1
  22. package/build/columns/deprecated.js +0 -1
  23. package/build/columns/deprecated.js.map +1 -1
  24. package/build/columns/edit.js +0 -1
  25. package/build/columns/edit.js.map +1 -1
  26. package/build/columns/edit.native.js +0 -1
  27. package/build/columns/edit.native.js.map +1 -1
  28. package/build/columns/transforms.js +0 -1
  29. package/build/columns/transforms.js.map +1 -1
  30. package/build/columns/utils.js +0 -1
  31. package/build/columns/utils.js.map +1 -1
  32. package/build/comment-template/edit.js +0 -1
  33. package/build/comment-template/edit.js.map +1 -1
  34. package/build/comment-template/hooks.js +0 -1
  35. package/build/comment-template/hooks.js.map +1 -1
  36. package/build/comment-template/util.js +0 -1
  37. package/build/comment-template/util.js.map +1 -1
  38. package/build/details/transforms.js +0 -1
  39. package/build/details/transforms.js.map +1 -1
  40. package/build/embed/embed-placeholder.native.js +0 -1
  41. package/build/embed/embed-placeholder.native.js.map +1 -1
  42. package/build/embed/util.js +0 -1
  43. package/build/embed/util.js.map +1 -1
  44. package/build/embed/variations.js +0 -1
  45. package/build/embed/variations.js.map +1 -1
  46. package/build/embed/wp-embed-preview.js +0 -1
  47. package/build/embed/wp-embed-preview.js.map +1 -1
  48. package/build/file/transforms.js +0 -1
  49. package/build/file/transforms.js.map +1 -1
  50. package/build/footnotes/edit.js +0 -1
  51. package/build/footnotes/edit.js.map +1 -1
  52. package/build/freeform/modal.js +0 -1
  53. package/build/freeform/modal.js.map +1 -1
  54. package/build/gallery/deprecated.js +0 -1
  55. package/build/gallery/deprecated.js.map +1 -1
  56. package/build/gallery/edit.js +0 -1
  57. package/build/gallery/edit.js.map +1 -1
  58. package/build/gallery/shared.js +0 -1
  59. package/build/gallery/shared.js.map +1 -1
  60. package/build/gallery/transforms.js +0 -1
  61. package/build/gallery/transforms.js.map +1 -1
  62. package/build/gallery/use-get-media.js +0 -1
  63. package/build/gallery/use-get-media.js.map +1 -1
  64. package/build/gallery/use-get-media.native.js +0 -1
  65. package/build/gallery/use-get-media.native.js.map +1 -1
  66. package/build/gallery/use-get-new-images.js +0 -1
  67. package/build/gallery/use-get-new-images.js.map +1 -1
  68. package/build/gallery/use-image-sizes.js +0 -1
  69. package/build/gallery/use-image-sizes.js.map +1 -1
  70. package/build/group/placeholder.js +0 -1
  71. package/build/group/placeholder.js.map +1 -1
  72. package/build/group/transforms.js +0 -1
  73. package/build/group/transforms.js.map +1 -1
  74. package/build/heading/transforms.js +0 -1
  75. package/build/heading/transforms.js.map +1 -1
  76. package/build/html/preview.js +0 -1
  77. package/build/html/preview.js.map +1 -1
  78. package/build/image/edit.js +0 -1
  79. package/build/image/edit.js.map +1 -1
  80. package/build/image/edit.native.js +0 -1
  81. package/build/image/edit.native.js.map +1 -1
  82. package/build/image/image.js +0 -1
  83. package/build/image/image.js.map +1 -1
  84. package/build/image/transforms.js +0 -1
  85. package/build/image/transforms.js.map +1 -1
  86. package/build/image/utils.js +0 -1
  87. package/build/image/utils.js.map +1 -1
  88. package/build/index.native.js +0 -1
  89. package/build/index.native.js.map +1 -1
  90. package/build/latest-posts/edit.js +0 -1
  91. package/build/latest-posts/edit.js.map +1 -1
  92. package/build/list/transforms.js +0 -1
  93. package/build/list/transforms.js.map +1 -1
  94. package/build/list/utils.js +0 -1
  95. package/build/list/utils.js.map +1 -1
  96. package/build/list-item/hooks/use-indent-list-item.js +0 -1
  97. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  98. package/build/list-item/transforms.js +0 -1
  99. package/build/list-item/transforms.js.map +1 -1
  100. package/build/media-text/edit.js +0 -1
  101. package/build/media-text/edit.js.map +1 -1
  102. package/build/more/save.js +0 -1
  103. package/build/more/save.js.map +1 -1
  104. package/build/navigation/deprecated.js +0 -1
  105. package/build/navigation/deprecated.js.map +1 -1
  106. package/build/navigation/edit/index.js +0 -1
  107. package/build/navigation/edit/index.js.map +1 -1
  108. package/build/navigation/edit/use-generate-default-navigation-title.js +0 -1
  109. package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
  110. package/build/navigation/menu-items-to-blocks.js +0 -1
  111. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  112. package/build/navigation/use-template-part-area-label.js +0 -1
  113. package/build/navigation/use-template-part-area-label.js.map +1 -1
  114. package/build/navigation/view.js +0 -1
  115. package/build/navigation/view.js.map +1 -1
  116. package/build/navigation-link/hooks.js +0 -1
  117. package/build/navigation-link/hooks.js.map +1 -1
  118. package/build/page-list/edit.js +0 -1
  119. package/build/page-list/edit.js.map +1 -1
  120. package/build/page-list/use-convert-to-navigation-links.js +0 -1
  121. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  122. package/build/pattern/edit.js +0 -1
  123. package/build/pattern/edit.js.map +1 -1
  124. package/build/post-author/edit.js +0 -1
  125. package/build/post-author/edit.js.map +1 -1
  126. package/build/post-featured-image/dimension-controls.js +2 -39
  127. package/build/post-featured-image/dimension-controls.js.map +1 -1
  128. package/build/post-featured-image/edit.js +45 -3
  129. package/build/post-featured-image/edit.js.map +1 -1
  130. package/build/post-navigation-link/edit.js +0 -1
  131. package/build/post-navigation-link/edit.js.map +1 -1
  132. package/build/post-navigation-link/variations.js +0 -1
  133. package/build/post-navigation-link/variations.js.map +1 -1
  134. package/build/post-template/edit.js +14 -7
  135. package/build/post-template/edit.js.map +1 -1
  136. package/build/post-terms/edit.js +0 -1
  137. package/build/post-terms/edit.js.map +1 -1
  138. package/build/post-terms/hooks.js +0 -1
  139. package/build/post-terms/hooks.js.map +1 -1
  140. package/build/pullquote/blockquote.native.js +0 -1
  141. package/build/pullquote/blockquote.native.js.map +1 -1
  142. package/build/pullquote/transforms.js +0 -1
  143. package/build/pullquote/transforms.js.map +1 -1
  144. package/build/query/deprecated.js +0 -1
  145. package/build/query/deprecated.js.map +1 -1
  146. package/build/query/edit/inspector-controls/author-control.js +0 -1
  147. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  148. package/build/query/edit/inspector-controls/format-controls.js +0 -1
  149. package/build/query/edit/inspector-controls/format-controls.js.map +1 -1
  150. package/build/query/edit/inspector-controls/index.js +0 -1
  151. package/build/query/edit/inspector-controls/index.js.map +1 -1
  152. package/build/query/edit/inspector-controls/parent-control.js +0 -1
  153. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  154. package/build/query/edit/inspector-controls/sticky-control.js +3 -0
  155. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
  156. package/build/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  157. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  158. package/build/query/utils.js +0 -1
  159. package/build/query/utils.js.map +1 -1
  160. package/build/query-title/variations.js +0 -1
  161. package/build/query-title/variations.js.map +1 -1
  162. package/build/quote/deprecated.js +0 -1
  163. package/build/quote/deprecated.js.map +1 -1
  164. package/build/quote/transforms.js +0 -1
  165. package/build/quote/transforms.js.map +1 -1
  166. package/build/rss/edit.js +15 -1
  167. package/build/rss/edit.js.map +1 -1
  168. package/build/rss/index.js +14 -0
  169. package/build/rss/index.js.map +1 -1
  170. package/build/social-link/icons/discord.js +23 -0
  171. package/build/social-link/icons/discord.js.map +1 -0
  172. package/build/social-link/icons/index.js +11 -0
  173. package/build/social-link/icons/index.js.map +1 -1
  174. package/build/social-link/social-list.js +0 -1
  175. package/build/social-link/social-list.js.map +1 -1
  176. package/build/social-link/variations.js +7 -1
  177. package/build/social-link/variations.js.map +1 -1
  178. package/build/social-links/edit.js +0 -1
  179. package/build/social-links/edit.js.map +1 -1
  180. package/build/social-links/edit.native.js +0 -1
  181. package/build/social-links/edit.native.js.map +1 -1
  182. package/build/spacer/controls.js +0 -1
  183. package/build/spacer/controls.js.map +1 -1
  184. package/build/table/deprecated.js +0 -1
  185. package/build/table/deprecated.js.map +1 -1
  186. package/build/table/edit.js +0 -1
  187. package/build/table/edit.js.map +1 -1
  188. package/build/table/save.js +0 -1
  189. package/build/table/save.js.map +1 -1
  190. package/build/table/state.js +0 -1
  191. package/build/table/state.js.map +1 -1
  192. package/build/table/transforms.js +0 -1
  193. package/build/table/transforms.js.map +1 -1
  194. package/build/table-of-contents/list.js +0 -1
  195. package/build/table-of-contents/list.js.map +1 -1
  196. package/build/table-of-contents/utils.js +0 -1
  197. package/build/table-of-contents/utils.js.map +1 -1
  198. package/build/tag-cloud/edit.js +0 -1
  199. package/build/tag-cloud/edit.js.map +1 -1
  200. package/build/template-part/edit/advanced-controls.js +0 -1
  201. package/build/template-part/edit/advanced-controls.js.map +1 -1
  202. package/build/template-part/edit/import-controls.js +0 -1
  203. package/build/template-part/edit/import-controls.js.map +1 -1
  204. package/build/template-part/edit/selection-modal.js +0 -1
  205. package/build/template-part/edit/selection-modal.js.map +1 -1
  206. package/build/template-part/edit/utils/hooks.js +0 -1
  207. package/build/template-part/edit/utils/hooks.js.map +1 -1
  208. package/build/template-part/edit/utils/transformers.js +0 -1
  209. package/build/template-part/edit/utils/transformers.js.map +1 -1
  210. package/build/template-part/variations.js +0 -1
  211. package/build/template-part/variations.js.map +1 -1
  212. package/build/text-columns/edit.js +0 -1
  213. package/build/text-columns/edit.js.map +1 -1
  214. package/build/text-columns/save.js +0 -1
  215. package/build/text-columns/save.js.map +1 -1
  216. package/build/text-columns/transforms.js +0 -1
  217. package/build/text-columns/transforms.js.map +1 -1
  218. package/build/utils/get-transformed-metadata.js +0 -1
  219. package/build/utils/get-transformed-metadata.js.map +1 -1
  220. package/build/utils/search-patterns.js +0 -1
  221. package/build/utils/search-patterns.js.map +1 -1
  222. package/build/utils/transformation-categories.native.js +0 -1
  223. package/build/utils/transformation-categories.native.js.map +1 -1
  224. package/build/video/tracks-editor.js +0 -1
  225. package/build/video/tracks-editor.js.map +1 -1
  226. package/build/video/tracks.js +0 -1
  227. package/build/video/tracks.js.map +1 -1
  228. package/build-module/archives/index.js +9 -0
  229. package/build-module/archives/index.js.map +1 -1
  230. package/build-module/avatar/user-control.js +0 -1
  231. package/build-module/avatar/user-control.js.map +1 -1
  232. package/build-module/block/deprecated.js +0 -1
  233. package/build-module/block/deprecated.js.map +1 -1
  234. package/build-module/block/edit.js +0 -1
  235. package/build-module/block/edit.js.map +1 -1
  236. package/build-module/button/deprecated.js +0 -1
  237. package/build-module/button/deprecated.js.map +1 -1
  238. package/build-module/buttons/transforms.js +0 -1
  239. package/build-module/buttons/transforms.js.map +1 -1
  240. package/build-module/categories/edit.js +0 -1
  241. package/build-module/categories/edit.js.map +1 -1
  242. package/build-module/categories/index.js +9 -0
  243. package/build-module/categories/index.js.map +1 -1
  244. package/build-module/column/column-preview.native.js +0 -1
  245. package/build-module/column/column-preview.native.js.map +1 -1
  246. package/build-module/columns/columnCalculations.native.js +0 -1
  247. package/build-module/columns/columnCalculations.native.js.map +1 -1
  248. package/build-module/columns/deprecated.js +0 -1
  249. package/build-module/columns/deprecated.js.map +1 -1
  250. package/build-module/columns/edit.js +0 -1
  251. package/build-module/columns/edit.js.map +1 -1
  252. package/build-module/columns/edit.native.js +0 -1
  253. package/build-module/columns/edit.native.js.map +1 -1
  254. package/build-module/columns/transforms.js +0 -1
  255. package/build-module/columns/transforms.js.map +1 -1
  256. package/build-module/columns/utils.js +0 -1
  257. package/build-module/columns/utils.js.map +1 -1
  258. package/build-module/comment-template/edit.js +0 -1
  259. package/build-module/comment-template/edit.js.map +1 -1
  260. package/build-module/comment-template/hooks.js +0 -1
  261. package/build-module/comment-template/hooks.js.map +1 -1
  262. package/build-module/comment-template/util.js +0 -1
  263. package/build-module/comment-template/util.js.map +1 -1
  264. package/build-module/details/transforms.js +0 -1
  265. package/build-module/details/transforms.js.map +1 -1
  266. package/build-module/embed/embed-placeholder.native.js +0 -1
  267. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  268. package/build-module/embed/util.js +0 -1
  269. package/build-module/embed/util.js.map +1 -1
  270. package/build-module/embed/variations.js +0 -1
  271. package/build-module/embed/variations.js.map +1 -1
  272. package/build-module/embed/wp-embed-preview.js +0 -1
  273. package/build-module/embed/wp-embed-preview.js.map +1 -1
  274. package/build-module/file/transforms.js +0 -1
  275. package/build-module/file/transforms.js.map +1 -1
  276. package/build-module/footnotes/edit.js +0 -1
  277. package/build-module/footnotes/edit.js.map +1 -1
  278. package/build-module/freeform/modal.js +0 -1
  279. package/build-module/freeform/modal.js.map +1 -1
  280. package/build-module/gallery/deprecated.js +0 -1
  281. package/build-module/gallery/deprecated.js.map +1 -1
  282. package/build-module/gallery/edit.js +0 -1
  283. package/build-module/gallery/edit.js.map +1 -1
  284. package/build-module/gallery/shared.js +0 -1
  285. package/build-module/gallery/shared.js.map +1 -1
  286. package/build-module/gallery/transforms.js +0 -1
  287. package/build-module/gallery/transforms.js.map +1 -1
  288. package/build-module/gallery/use-get-media.js +0 -1
  289. package/build-module/gallery/use-get-media.js.map +1 -1
  290. package/build-module/gallery/use-get-media.native.js +0 -1
  291. package/build-module/gallery/use-get-media.native.js.map +1 -1
  292. package/build-module/gallery/use-get-new-images.js +0 -1
  293. package/build-module/gallery/use-get-new-images.js.map +1 -1
  294. package/build-module/gallery/use-image-sizes.js +0 -1
  295. package/build-module/gallery/use-image-sizes.js.map +1 -1
  296. package/build-module/group/placeholder.js +0 -1
  297. package/build-module/group/placeholder.js.map +1 -1
  298. package/build-module/group/transforms.js +0 -1
  299. package/build-module/group/transforms.js.map +1 -1
  300. package/build-module/heading/transforms.js +0 -1
  301. package/build-module/heading/transforms.js.map +1 -1
  302. package/build-module/html/preview.js +0 -1
  303. package/build-module/html/preview.js.map +1 -1
  304. package/build-module/image/edit.js +0 -1
  305. package/build-module/image/edit.js.map +1 -1
  306. package/build-module/image/edit.native.js +0 -1
  307. package/build-module/image/edit.native.js.map +1 -1
  308. package/build-module/image/image.js +0 -1
  309. package/build-module/image/image.js.map +1 -1
  310. package/build-module/image/transforms.js +0 -1
  311. package/build-module/image/transforms.js.map +1 -1
  312. package/build-module/image/utils.js +0 -1
  313. package/build-module/image/utils.js.map +1 -1
  314. package/build-module/index.native.js +0 -1
  315. package/build-module/index.native.js.map +1 -1
  316. package/build-module/latest-posts/edit.js +0 -1
  317. package/build-module/latest-posts/edit.js.map +1 -1
  318. package/build-module/list/transforms.js +0 -1
  319. package/build-module/list/transforms.js.map +1 -1
  320. package/build-module/list/utils.js +0 -1
  321. package/build-module/list/utils.js.map +1 -1
  322. package/build-module/list-item/hooks/use-indent-list-item.js +0 -1
  323. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  324. package/build-module/list-item/transforms.js +0 -1
  325. package/build-module/list-item/transforms.js.map +1 -1
  326. package/build-module/media-text/edit.js +0 -1
  327. package/build-module/media-text/edit.js.map +1 -1
  328. package/build-module/more/save.js +0 -1
  329. package/build-module/more/save.js.map +1 -1
  330. package/build-module/navigation/deprecated.js +0 -1
  331. package/build-module/navigation/deprecated.js.map +1 -1
  332. package/build-module/navigation/edit/index.js +0 -1
  333. package/build-module/navigation/edit/index.js.map +1 -1
  334. package/build-module/navigation/edit/use-generate-default-navigation-title.js +0 -1
  335. package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
  336. package/build-module/navigation/menu-items-to-blocks.js +0 -1
  337. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  338. package/build-module/navigation/use-template-part-area-label.js +0 -1
  339. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  340. package/build-module/navigation/view.js +0 -1
  341. package/build-module/navigation/view.js.map +1 -1
  342. package/build-module/navigation-link/hooks.js +0 -1
  343. package/build-module/navigation-link/hooks.js.map +1 -1
  344. package/build-module/page-list/edit.js +0 -1
  345. package/build-module/page-list/edit.js.map +1 -1
  346. package/build-module/page-list/use-convert-to-navigation-links.js +0 -1
  347. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  348. package/build-module/pattern/edit.js +0 -1
  349. package/build-module/pattern/edit.js.map +1 -1
  350. package/build-module/post-author/edit.js +0 -1
  351. package/build-module/post-author/edit.js.map +1 -1
  352. package/build-module/post-featured-image/dimension-controls.js +3 -40
  353. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  354. package/build-module/post-featured-image/edit.js +46 -4
  355. package/build-module/post-featured-image/edit.js.map +1 -1
  356. package/build-module/post-navigation-link/edit.js +0 -1
  357. package/build-module/post-navigation-link/edit.js.map +1 -1
  358. package/build-module/post-navigation-link/variations.js +0 -1
  359. package/build-module/post-navigation-link/variations.js.map +1 -1
  360. package/build-module/post-template/edit.js +14 -7
  361. package/build-module/post-template/edit.js.map +1 -1
  362. package/build-module/post-terms/edit.js +0 -1
  363. package/build-module/post-terms/edit.js.map +1 -1
  364. package/build-module/post-terms/hooks.js +0 -1
  365. package/build-module/post-terms/hooks.js.map +1 -1
  366. package/build-module/pullquote/blockquote.native.js +0 -1
  367. package/build-module/pullquote/blockquote.native.js.map +1 -1
  368. package/build-module/pullquote/transforms.js +0 -1
  369. package/build-module/pullquote/transforms.js.map +1 -1
  370. package/build-module/query/deprecated.js +0 -1
  371. package/build-module/query/deprecated.js.map +1 -1
  372. package/build-module/query/edit/inspector-controls/author-control.js +0 -1
  373. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  374. package/build-module/query/edit/inspector-controls/format-controls.js +0 -1
  375. package/build-module/query/edit/inspector-controls/format-controls.js.map +1 -1
  376. package/build-module/query/edit/inspector-controls/index.js +0 -1
  377. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  378. package/build-module/query/edit/inspector-controls/parent-control.js +0 -1
  379. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  380. package/build-module/query/edit/inspector-controls/sticky-control.js +3 -0
  381. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
  382. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  383. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  384. package/build-module/query/utils.js +0 -1
  385. package/build-module/query/utils.js.map +1 -1
  386. package/build-module/query-title/variations.js +0 -1
  387. package/build-module/query-title/variations.js.map +1 -1
  388. package/build-module/quote/deprecated.js +0 -1
  389. package/build-module/quote/deprecated.js.map +1 -1
  390. package/build-module/quote/transforms.js +0 -1
  391. package/build-module/quote/transforms.js.map +1 -1
  392. package/build-module/rss/edit.js +15 -1
  393. package/build-module/rss/edit.js.map +1 -1
  394. package/build-module/rss/index.js +14 -0
  395. package/build-module/rss/index.js.map +1 -1
  396. package/build-module/social-link/icons/discord.js +15 -0
  397. package/build-module/social-link/icons/discord.js.map +1 -0
  398. package/build-module/social-link/icons/index.js +1 -0
  399. package/build-module/social-link/icons/index.js.map +1 -1
  400. package/build-module/social-link/social-list.js +0 -1
  401. package/build-module/social-link/social-list.js.map +1 -1
  402. package/build-module/social-link/variations.js +8 -2
  403. package/build-module/social-link/variations.js.map +1 -1
  404. package/build-module/social-links/edit.js +0 -1
  405. package/build-module/social-links/edit.js.map +1 -1
  406. package/build-module/social-links/edit.native.js +0 -1
  407. package/build-module/social-links/edit.native.js.map +1 -1
  408. package/build-module/spacer/controls.js +0 -1
  409. package/build-module/spacer/controls.js.map +1 -1
  410. package/build-module/table/deprecated.js +0 -1
  411. package/build-module/table/deprecated.js.map +1 -1
  412. package/build-module/table/edit.js +0 -1
  413. package/build-module/table/edit.js.map +1 -1
  414. package/build-module/table/save.js +0 -1
  415. package/build-module/table/save.js.map +1 -1
  416. package/build-module/table/state.js +0 -1
  417. package/build-module/table/state.js.map +1 -1
  418. package/build-module/table/transforms.js +0 -1
  419. package/build-module/table/transforms.js.map +1 -1
  420. package/build-module/table-of-contents/list.js +0 -1
  421. package/build-module/table-of-contents/list.js.map +1 -1
  422. package/build-module/table-of-contents/utils.js +0 -1
  423. package/build-module/table-of-contents/utils.js.map +1 -1
  424. package/build-module/tag-cloud/edit.js +0 -1
  425. package/build-module/tag-cloud/edit.js.map +1 -1
  426. package/build-module/template-part/edit/advanced-controls.js +0 -1
  427. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  428. package/build-module/template-part/edit/import-controls.js +0 -1
  429. package/build-module/template-part/edit/import-controls.js.map +1 -1
  430. package/build-module/template-part/edit/selection-modal.js +0 -1
  431. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  432. package/build-module/template-part/edit/utils/hooks.js +0 -1
  433. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  434. package/build-module/template-part/edit/utils/transformers.js +0 -1
  435. package/build-module/template-part/edit/utils/transformers.js.map +1 -1
  436. package/build-module/template-part/variations.js +0 -1
  437. package/build-module/template-part/variations.js.map +1 -1
  438. package/build-module/text-columns/edit.js +0 -1
  439. package/build-module/text-columns/edit.js.map +1 -1
  440. package/build-module/text-columns/save.js +0 -1
  441. package/build-module/text-columns/save.js.map +1 -1
  442. package/build-module/text-columns/transforms.js +0 -1
  443. package/build-module/text-columns/transforms.js.map +1 -1
  444. package/build-module/utils/get-transformed-metadata.js +0 -1
  445. package/build-module/utils/get-transformed-metadata.js.map +1 -1
  446. package/build-module/utils/search-patterns.js +0 -1
  447. package/build-module/utils/search-patterns.js.map +1 -1
  448. package/build-module/utils/transformation-categories.native.js +0 -1
  449. package/build-module/utils/transformation-categories.native.js.map +1 -1
  450. package/build-module/video/tracks-editor.js +0 -1
  451. package/build-module/video/tracks-editor.js.map +1 -1
  452. package/build-module/video/tracks.js +0 -1
  453. package/build-module/video/tracks.js.map +1 -1
  454. package/build-style/editor-rtl.css +10 -7
  455. package/build-style/editor.css +10 -7
  456. package/build-style/navigation-link/editor-rtl.css +1 -1
  457. package/build-style/navigation-link/editor.css +1 -1
  458. package/build-style/rss/editor-rtl.css +6 -0
  459. package/build-style/rss/editor.css +6 -0
  460. package/build-style/rss/style-rtl.css +6 -8
  461. package/build-style/rss/style.css +6 -8
  462. package/build-style/social-links/editor-rtl.css +3 -6
  463. package/build-style/social-links/editor.css +3 -6
  464. package/build-style/social-links/style-rtl.css +7 -0
  465. package/build-style/social-links/style.css +7 -0
  466. package/build-style/style-rtl.css +13 -8
  467. package/build-style/style.css +13 -8
  468. package/package.json +35 -35
  469. package/src/archives/block.json +9 -0
  470. package/src/block/index.php +1 -18
  471. package/src/categories/block.json +9 -0
  472. package/src/navigation/index.php +11 -69
  473. package/src/navigation-link/editor.scss +1 -1
  474. package/src/post-content/index.php +0 -23
  475. package/src/post-featured-image/dimension-controls.js +2 -43
  476. package/src/post-featured-image/edit.js +39 -3
  477. package/src/post-template/edit.js +15 -6
  478. package/src/query/edit/inspector-controls/sticky-control.js +1 -0
  479. package/src/rss/block.json +14 -0
  480. package/src/rss/edit.js +14 -1
  481. package/src/rss/editor.scss +7 -0
  482. package/src/rss/style.scss +6 -8
  483. package/src/social-link/icons/discord.js +10 -0
  484. package/src/social-link/icons/index.js +1 -0
  485. package/src/social-link/index.php +4 -0
  486. package/src/social-link/socials-with-bg.scss +5 -0
  487. package/src/social-link/socials-without-bg.scss +4 -0
  488. package/src/social-link/variations.js +7 -0
  489. package/src/social-links/editor.scss +4 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","MAXIMUM_SELECTED_BLOCKS","transforms","from","type","isMultiBlock","blocks","__experimentalConvert","columnWidth","length","toFixed","innerBlocksTemplate","map","name","attributes","innerBlocks","width","createBlock","createBlocksFromInnerBlocksTemplate","isMatch","selectedBlocksLength","priority","transform","align","backgroundColor","textColor","style","mediaAlt","alt","mediaId","id","mediaPosition","mediaSizeSlug","sizeSlug","mediaType","mediaUrl","url","mediaWidth","verticalAlignment","media","imageAttrs","linkAttrs","href","linkClass","linkDestination","linkTarget","rel","src","reverse","ungroup","flatMap","innerBlock","_default","exports","default"],"sources":["@wordpress/block-library/src/columns/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n} from '@wordpress/blocks';\n\nconst MAXIMUM_SELECTED_BLOCKS = 6;\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\t__experimentalConvert: ( blocks ) => {\n\t\t\t\tconst columnWidth = +( 100 / blocks.length ).toFixed( 2 );\n\t\t\t\tconst innerBlocksTemplate = blocks.map(\n\t\t\t\t\t( { name, attributes, innerBlocks } ) => [\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: `${ columnWidth }%` },\n\t\t\t\t\t\t[ [ name, { ...attributes }, innerBlocks ] ],\n\t\t\t\t\t]\n\t\t\t\t);\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/columns',\n\t\t\t\t\t{},\n\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocksTemplate )\n\t\t\t\t);\n\t\t\t},\n\t\t\tisMatch: ( { length: selectedBlocksLength }, blocks ) => {\n\t\t\t\t// If a user is trying to transform a single Columns block, skip\n\t\t\t\t// the transformation. Enabling this functiontionality creates\n\t\t\t\t// nested Columns blocks resulting in an unintuitive user experience.\n\t\t\t\t// Multiple Columns blocks can still be transformed.\n\t\t\t\tif (\n\t\t\t\t\tblocks.length === 1 &&\n\t\t\t\t\tblocks[ 0 ].name === 'core/columns'\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tselectedBlocksLength &&\n\t\t\t\t\tselectedBlocksLength <= MAXIMUM_SELECTED_BLOCKS\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/media-text' ],\n\t\t\tpriority: 1,\n\t\t\ttransform: ( attributes, innerBlocks ) => {\n\t\t\t\tconst {\n\t\t\t\t\talign,\n\t\t\t\t\tbackgroundColor,\n\t\t\t\t\ttextColor,\n\t\t\t\t\tstyle,\n\t\t\t\t\tmediaAlt: alt,\n\t\t\t\t\tmediaId: id,\n\t\t\t\t\tmediaPosition,\n\t\t\t\t\tmediaSizeSlug: sizeSlug,\n\t\t\t\t\tmediaType,\n\t\t\t\t\tmediaUrl: url,\n\t\t\t\t\tmediaWidth,\n\t\t\t\t\tverticalAlignment,\n\t\t\t\t} = attributes;\n\t\t\t\tlet media;\n\t\t\t\tif ( mediaType === 'image' || ! mediaType ) {\n\t\t\t\t\tconst imageAttrs = { id, alt, url, sizeSlug };\n\t\t\t\t\tconst linkAttrs = {\n\t\t\t\t\t\thref: attributes.href,\n\t\t\t\t\t\tlinkClass: attributes.linkClass,\n\t\t\t\t\t\tlinkDestination: attributes.linkDestination,\n\t\t\t\t\t\tlinkTarget: attributes.linkTarget,\n\t\t\t\t\t\trel: attributes.rel,\n\t\t\t\t\t};\n\t\t\t\t\tmedia = [ 'core/image', { ...imageAttrs, ...linkAttrs } ];\n\t\t\t\t} else {\n\t\t\t\t\tmedia = [ 'core/video', { id, src: url } ];\n\t\t\t\t}\n\t\t\t\tconst innerBlocksTemplate = [\n\t\t\t\t\t[ 'core/column', { width: `${ mediaWidth }%` }, [ media ] ],\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: `${ 100 - mediaWidth }%` },\n\t\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t],\n\t\t\t\t];\n\t\t\t\tif ( mediaPosition === 'right' ) {\n\t\t\t\t\tinnerBlocksTemplate.reverse();\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/columns',\n\t\t\t\t\t{\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t\tverticalAlignment,\n\t\t\t\t\t},\n\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocksTemplate )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n\tungroup: ( attributes, innerBlocks ) =>\n\t\tinnerBlocks.flatMap( ( innerBlock ) => innerBlock.innerBlocks ),\n};\n\nexport default transforms;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAMA,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,UAAU,GAAG;EAClBC,IAAI,EAAE,CACL;IACCC,IAAI,EAAE,OAAO;IACbC,YAAY,EAAE,IAAI;IAClBC,MAAM,EAAE,CAAE,GAAG,CAAE;IACfC,qBAAqB,EAAID,MAAM,IAAM;MACpC,MAAME,WAAW,GAAG,CAAC,CAAE,GAAG,GAAGF,MAAM,CAACG,MAAM,EAAGC,OAAO,CAAE,CAAE,CAAC;MACzD,MAAMC,mBAAmB,GAAGL,MAAM,CAACM,GAAG,CACrC,CAAE;QAAEC,IAAI;QAAEC,UAAU;QAAEC;MAAY,CAAC,KAAM,CACxC,aAAa,EACb;QAAEC,KAAK,EAAE,GAAIR,WAAW;MAAK,CAAC,EAC9B,CAAE,CAAEK,IAAI,EAAE;QAAE,GAAGC;MAAW,CAAC,EAAEC,WAAW,CAAE,CAAE,CAE9C,CAAC;MACD,OAAO,IAAAE,mBAAW,EACjB,cAAc,EACd,CAAC,CAAC,EACF,IAAAC,2CAAmC,EAAEP,mBAAoB,CAC1D,CAAC;IACF,CAAC;IACDQ,OAAO,EAAEA,CAAE;MAAEV,MAAM,EAA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AC3C;MACA,MAAMzB,mBAAmB,GAAG,CAC3B,CAAE,aAAa,EAAE;QAAEK,KAAK,EAAE,GAAIqB,UAAU;MAAK,CAAC,EAAE,CAAEE,KAAK,CAAE,CAAE,EAC3D,CACC,aAAa,EACb;QAAEvB,KAAK,EAAE,GAAI,GAAG,GAAGqB,UAAU;MAAK,CAAC,EACnCtB,WAAW,CACX,CACD;MACD,IAAKgB,aAAa,KAAK,OAAO,EAAG;QAChCpB,mBAAmB,CAACqC,OAAO,CAAC,CAAC;MAC9B;MACA,OAAO,IAAA/B,mBAAW,EACjB,cAAc,EACd;QACCM,KAAK;QACLC,eAAe;QACfC,SAAS;QACTC,KAAK;QACLY;MACD,CAAC,EACD,IAAApB,2CAAmC,EAAEP,mBAAoB,CAC1D,CAAC;IACF;EACD,CAAC,CACD;EACDsC,OAAO,EAAEA,CAAEnC,UAAU,EAAEC,WAAW,KACjCA,WAAW,CAACmC,OAAO,CAAIC,UAAU,IAAMA,UAAU,CAACpC,WAAY;AAChE,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEapD,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","MAXIMUM_SELECTED_BLOCKS","transforms","from","type","isMultiBlock","blocks","__experimentalConvert","columnWidth","length","toFixed","innerBlocksTemplate","map","name","attributes","innerBlocks","width","createBlock","createBlocksFromInnerBlocksTemplate","isMatch","selectedBlocksLength","priority","transform","align","backgroundColor","textColor","style","mediaAlt","alt","mediaId","id","mediaPosition","mediaSizeSlug","sizeSlug","mediaType","mediaUrl","url","mediaWidth","verticalAlignment","media","imageAttrs","linkAttrs","href","linkClass","linkDestination","linkTarget","rel","src","reverse","ungroup","flatMap","innerBlock","_default","exports","default"],"sources":["@wordpress/block-library/src/columns/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n} from '@wordpress/blocks';\n\nconst MAXIMUM_SELECTED_BLOCKS = 6;\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\t__experimentalConvert: ( blocks ) => {\n\t\t\t\tconst columnWidth = +( 100 / blocks.length ).toFixed( 2 );\n\t\t\t\tconst innerBlocksTemplate = blocks.map(\n\t\t\t\t\t( { name, attributes, innerBlocks } ) => [\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: `${ columnWidth }%` },\n\t\t\t\t\t\t[ [ name, { ...attributes }, innerBlocks ] ],\n\t\t\t\t\t]\n\t\t\t\t);\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/columns',\n\t\t\t\t\t{},\n\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocksTemplate )\n\t\t\t\t);\n\t\t\t},\n\t\t\tisMatch: ( { length: selectedBlocksLength }, blocks ) => {\n\t\t\t\t// If a user is trying to transform a single Columns block, skip\n\t\t\t\t// the transformation. Enabling this functiontionality creates\n\t\t\t\t// nested Columns blocks resulting in an unintuitive user experience.\n\t\t\t\t// Multiple Columns blocks can still be transformed.\n\t\t\t\tif (\n\t\t\t\t\tblocks.length === 1 &&\n\t\t\t\t\tblocks[ 0 ].name === 'core/columns'\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\tselectedBlocksLength &&\n\t\t\t\t\tselectedBlocksLength <= MAXIMUM_SELECTED_BLOCKS\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/media-text' ],\n\t\t\tpriority: 1,\n\t\t\ttransform: ( attributes, innerBlocks ) => {\n\t\t\t\tconst {\n\t\t\t\t\talign,\n\t\t\t\t\tbackgroundColor,\n\t\t\t\t\ttextColor,\n\t\t\t\t\tstyle,\n\t\t\t\t\tmediaAlt: alt,\n\t\t\t\t\tmediaId: id,\n\t\t\t\t\tmediaPosition,\n\t\t\t\t\tmediaSizeSlug: sizeSlug,\n\t\t\t\t\tmediaType,\n\t\t\t\t\tmediaUrl: url,\n\t\t\t\t\tmediaWidth,\n\t\t\t\t\tverticalAlignment,\n\t\t\t\t} = attributes;\n\t\t\t\tlet media;\n\t\t\t\tif ( mediaType === 'image' || ! mediaType ) {\n\t\t\t\t\tconst imageAttrs = { id, alt, url, sizeSlug };\n\t\t\t\t\tconst linkAttrs = {\n\t\t\t\t\t\thref: attributes.href,\n\t\t\t\t\t\tlinkClass: attributes.linkClass,\n\t\t\t\t\t\tlinkDestination: attributes.linkDestination,\n\t\t\t\t\t\tlinkTarget: attributes.linkTarget,\n\t\t\t\t\t\trel: attributes.rel,\n\t\t\t\t\t};\n\t\t\t\t\tmedia = [ 'core/image', { ...imageAttrs, ...linkAttrs } ];\n\t\t\t\t} else {\n\t\t\t\t\tmedia = [ 'core/video', { id, src: url } ];\n\t\t\t\t}\n\t\t\t\tconst innerBlocksTemplate = [\n\t\t\t\t\t[ 'core/column', { width: `${ mediaWidth }%` }, [ media ] ],\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: `${ 100 - mediaWidth }%` },\n\t\t\t\t\t\tinnerBlocks,\n\t\t\t\t\t],\n\t\t\t\t];\n\t\t\t\tif ( mediaPosition === 'right' ) {\n\t\t\t\t\tinnerBlocksTemplate.reverse();\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/columns',\n\t\t\t\t\t{\n\t\t\t\t\t\talign,\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\tstyle,\n\t\t\t\t\t\tverticalAlignment,\n\t\t\t\t\t},\n\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocksTemplate )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n\tungroup: ( attributes, innerBlocks ) =>\n\t\tinnerBlocks.flatMap( ( innerBlock ) => inn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S;QACTC,KAAK;QACLY;MACD,CAAC,EACD,IAAApB,2CAAmC,EAAEP,mBAAoB,CAC1D,CAAC;IACF;EACD,CAAC,CACD;EACDsC,OAAO,EAAEA,CAAEnC,UAAU,EAAEC,WAAW,KACjCA,WAAW,CAACmC,OAAO,CAAIC,UAAU,IAAMA,UAAU,CAACpC,WAAY;AAChE,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEapD,UAAU","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["toWidthPrecision","value","unitlessValue","parseFloat","Number","isFinite","toFixed","undefined","exports","getEffectiveColumnWidth","block","totalBlockCount","width","attributes","getTotalColumnsWidth","blocks","length","reduce","sum","getColumnWidths","accumulator","Object","assign","clientId","getRedistributedColumnWidths","availableWidth","totalWidth","fromEntries","entries","map","newWidth","hasExplicitPercentColumnWidths","every","blockWidth","endsWith","getMappedColumnWidths","widths","getWidths","withParsing","innerColumn","innerColumnWidth","getWidthWithUnit","unit","isPercentageUnit","Math","min"],"sources":["@wordpress/block-library/src/columns/utils.js"],"sourcesContent":["/**\n * Returns a column width attribute value rounded to standard precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {?number} value Raw value.\n *\n * @return {number} Value rounded to standard precision.\n */\nexport const toWidthPrecision = ( value ) => {\n\tconst unitlessValue = parseFloat( value );\n\treturn Number.isFinite( unitlessValue )\n\t\t? parseFloat( unitlessValue.toFixed( 2 ) )\n\t\t: undefined;\n};\n/**\n * Returns an effective width for a given block. An effective width is equal to\n * its attribute value if set, or a computed value assuming equal distribution.\n *\n * @param {WPBlock} block Block object.\n * @param {number} totalBlockCount Total number of blocks in Columns.\n *\n * @return {number} Effective column width.\n */\nexport function getEffectiveColumnWidth( block, totalBlockCount ) {\n\tconst { width = 100 / totalBlockCount } = block.attributes;\n\treturn toWidthPrecision( width );\n}\n\n/**\n * Returns the total width occupied by the given set of column blocks.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {number} Total width occupied by blocks.\n */\nexport function getTotalColumnsWidth(\n\tblocks,\n\ttotalBlockCount = blocks.length\n) {\n\treturn blocks.reduce(\n\t\t( sum, block ) =>\n\t\t\tsum + getEffectiveColumnWidth( block, totalBlockCount ),\n\t\t0\n\t);\n}\n\n/**\n * Returns an object of `clientId` → `width` of effective column widths.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {Object<string,number>} Column widths.\n */\nexport function getColumnWidths( blocks, totalBlockCount = blocks.length ) {\n\treturn blocks.reduce( ( accumulator, block ) => {\n\t\tconst width = getEffectiveColumnWidth( block, totalBlockCount );\n\t\treturn Object.assign( accumulator, { [ block.clientId ]: width } );\n\t}, {} );\n}\n\n/**\n * Returns an object of `clientId` → `width` of column widths as redistributed\n * proportional to their current widths, constrained or expanded to fit within\n * the given available width.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {number} availableWidth Maximum width to fit within.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {Object<string,number>} Redistributed column widths.\n */\nexport function getRedistributedColumnWidths(\n\tblocks,\n\tavailableWidth,\n\ttotalBlockCount = blocks.length\n) {\n\tconst totalWidth = getTotalColumnsWidth( blocks, totalBlockCount );\n\n\treturn Object.fromEntries(\n\t\tObject.entries( getColumnWidths( blocks, totalBlockCount ) ).map(\n\t\t\t( [ clientId, width ] ) => {\n\t\t\t\tconst newWidth = ( availableWidth * width ) / totalWidth;\n\t\t\t\treturn [ clientId, toWidthPrecision( newWidth ) ];\n\t\t\t}\n\t\t)\n\t);\n}\n\n/**\n * Returns true if column blocks within the provided set are assigned with\n * explicit widths, or false otherwise.\n *\n * @param {WPBlock[]} blocks Block objects.\n *\n * @return {boolean} Whether columns have explicit widths.\n */\nexport function hasExplicitPercentColumnWidths( blocks ) {\n\treturn blocks.every( ( block ) => {\n\t\tconst blockWidth = block.attributes.width;\n\t\treturn Number.isFinite(\n\t\t\tblockWidth?.endsWith?.( '%' )\n\t\t\t\t? parseFloat( blockWidth )\n\t\t\t\t: blockWidth\n\t\t);\n\t} );\n}\n\n/**\n * Returns a copy of the given set of blocks with new widths assigned from the\n * provided object of redistributed column widths.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {Object<string,number>} widths Redistributed column widths.\n *\n * @return {WPBlock[]} blocks Mapped block objects.\n */\nexport function getMappedColumnWidths( blocks, widths ) {\n\treturn blocks.map( ( block ) => ( {\n\t\t...block,\n\t\tattributes: {\n\t\t\t...block.attributes,\n\t\t\twidth: `${ widths[ block.clientId ] }%`,\n\t\t},\n\t} ) );\n}\n\n/**\n * Returns an array with columns widths values, parsed or no depends on `withParsing` flag.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?boolean} withParsing Whether value has to be parsed.\n *\n * @return {Array<number,string>} Column widths.\n */\nexport function getWidths( blocks, withParsing = true ) {\n\treturn blocks.map( ( innerColumn ) => {\n\t\tconst innerColumnWidth =\n\t\t\tinnerColumn.attributes.width || 100 / blocks.length;\n\n\t\treturn withParsing ? parseFloat( innerColumnWidth ) : innerColumnWidth;\n\t} );\n}\n\n/**\n * Returns a column width with unit.\n *\n * @param {string} width Column width.\n * @param {string} unit Column width unit.\n *\n * @return {string} Column width with unit.\n */\nexport function getWidthWithUnit( width, unit ) {\n\twidth = 0 > parseFloat( width ) ? '0' : width;\n\n\tif ( isPercentageUnit( unit ) ) {\n\t\twidth = Math.min( width, 100 );\n\t}\n\n\treturn `${ width }${ unit }`;\n}\n\n/**\n * Returns a boolean whether passed unit is percentage\n *\n * @param {string} unit Column width unit.\n *\n * @return {boolean} \tWhether unit is '%'.\n */\nexport function isPercentageUnit( unit ) {\n\treturn unit === '%';\n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AC,CAAG,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,SAASA,CAAEtB,MAAM,EAAEuB,WAAW,GAAG,IAAI,EAAG;EACvD,OAAOvB,MAAM,CAACc,GAAG,CAAIU,WAAW,IAAM;IACrC,MAAMC,gBAAgB,GACrBD,WAAW,CAAC1B,UAAU,CAACD,KAAK,IAAI,GAAG,GAAGG,MAAM,CAACC,MAAM;IAEpD,OAAOsB,WAAW,GAAGnC,UAAU,CAAEqC,gBAAiB,CAAC,GAAGA,gBAAgB;EACvE,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAE7B,KAAK,EAAE8B,IAAI,EAAG;EAC/C9B,KAAK,GAAG,CAAC,GAAGT,UAAU,CAAES,KAAM,CAAC,GAAG,GAAG,GAAGA,KAAK;EAE7C,IAAK+B,gBAAgB,CAAED,IAAK,CAAC,EAAG;IAC/B9B,KAAK,GAAGgC,IAAI,CAACC,GAAG,CAAEjC,KAAK,EAAE,GAAI,CAAC;EAC/B;EAEA,OAAO,GAAIA,KAAK,GAAK8B,IAAI,EAAG;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAED,IAAI,EAAG;EACxC,OAAOA,IAAI,KAAK,GAAG;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["toWidthPrecision","value","unitlessValue","parseFloat","Number","isFinite","toFixed","undefined","exports","getEffectiveColumnWidth","block","totalBlockCount","width","attributes","getTotalColumnsWidth","blocks","length","reduce","sum","getColumnWidths","accumulator","Object","assign","clientId","getRedistributedColumnWidths","availableWidth","totalWidth","fromEntries","entries","map","newWidth","hasExplicitPercentColumnWidths","every","blockWidth","endsWith","getMappedColumnWidths","widths","getWidths","withParsing","innerColumn","innerColumnWidth","getWidthWithUnit","unit","isPercentageUnit","Math","min"],"sources":["@wordpress/block-library/src/columns/utils.js"],"sourcesContent":["/**\n * Returns a column width attribute value rounded to standard precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {?number} value Raw value.\n *\n * @return {number} Value rounded to standard precision.\n */\nexport const toWidthPrecision = ( value ) => {\n\tconst unitlessValue = parseFloat( value );\n\treturn Number.isFinite( unitlessValue )\n\t\t? parseFloat( unitlessValue.toFixed( 2 ) )\n\t\t: undefined;\n};\n/**\n * Returns an effective width for a given block. An effective width is equal to\n * its attribute value if set, or a computed value assuming equal distribution.\n *\n * @param {WPBlock} block Block object.\n * @param {number} totalBlockCount Total number of blocks in Columns.\n *\n * @return {number} Effective column width.\n */\nexport function getEffectiveColumnWidth( block, totalBlockCount ) {\n\tconst { width = 100 / totalBlockCount } = block.attributes;\n\treturn toWidthPrecision( width );\n}\n\n/**\n * Returns the total width occupied by the given set of column blocks.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {number} Total width occupied by blocks.\n */\nexport function getTotalColumnsWidth(\n\tblocks,\n\ttotalBlockCount = blocks.length\n) {\n\treturn blocks.reduce(\n\t\t( sum, block ) =>\n\t\t\tsum + getEffectiveColumnWidth( block, totalBlockCount ),\n\t\t0\n\t);\n}\n\n/**\n * Returns an object of `clientId` → `width` of effective column widths.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {Object<string,number>} Column widths.\n */\nexport function getColumnWidths( blocks, totalBlockCount = blocks.length ) {\n\treturn blocks.reduce( ( accumulator, block ) => {\n\t\tconst width = getEffectiveColumnWidth( block, totalBlockCount );\n\t\treturn Object.assign( accumulator, { [ block.clientId ]: width } );\n\t}, {} );\n}\n\n/**\n * Returns an object of `clientId` → `width` of column widths as redistributed\n * proportional to their current widths, constrained or expanded to fit within\n * the given available width.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {number} availableWidth Maximum width to fit within.\n * @param {?number} totalBlockCount Total number of blocks in Columns.\n * Defaults to number of blocks passed.\n *\n * @return {Object<string,number>} Redistributed column widths.\n */\nexport function getRedistributedColumnWidths(\n\tblocks,\n\tavailableWidth,\n\ttotalBlockCount = blocks.length\n) {\n\tconst totalWidth = getTotalColumnsWidth( blocks, totalBlockCount );\n\n\treturn Object.fromEntries(\n\t\tObject.entries( getColumnWidths( blocks, totalBlockCount ) ).map(\n\t\t\t( [ clientId, width ] ) => {\n\t\t\t\tconst newWidth = ( availableWidth * width ) / totalWidth;\n\t\t\t\treturn [ clientId, toWidthPrecision( newWidth ) ];\n\t\t\t}\n\t\t)\n\t);\n}\n\n/**\n * Returns true if column blocks within the provided set are assigned with\n * explicit widths, or false otherwise.\n *\n * @param {WPBlock[]} blocks Block objects.\n *\n * @return {boolean} Whether columns have explicit widths.\n */\nexport function hasExplicitPercentColumnWidths( blocks ) {\n\treturn blocks.every( ( block ) => {\n\t\tconst blockWidth = block.attributes.width;\n\t\treturn Number.isFinite(\n\t\t\tblockWidth?.endsWith?.( '%' )\n\t\t\t\t? parseFloat( blockWidth )\n\t\t\t\t: blockWidth\n\t\t);\n\t} );\n}\n\n/**\n * Returns a copy of the given set of blocks with new widths assigned from the\n * provided object of redistributed column widths.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {Object<string,number>} widths Redistributed column widths.\n *\n * @return {WPBlock[]} blocks Mapped block objects.\n */\nexport function getMappedColumnWidths( blocks, widths ) {\n\treturn blocks.map( ( block ) => ( {\n\t\t...block,\n\t\tattributes: {\n\t\t\t...block.attributes,\n\t\t\twidth: `${ widths[ block.clientId ] }%`,\n\t\t},\n\t} ) );\n}\n\n/**\n * Returns an array with columns widths values, parsed or no depends on `withParsing` flag.\n *\n * @param {WPBlock[]} blocks Block objects.\n * @param {?boolean} withParsing Whether value has to be parsed.\n *\n * @return {Array<number,string>} Column widths.\n */\nexport function getWidths( blocks, withParsing = true ) {\n\treturn blocks.map( ( innerColumn ) => {\n\t\tconst innerColumnWidth =\n\t\t\tinnerColumn.attributes.width || 100 / blocks.length;\n\n\t\treturn withParsing ? parseFloat( innerColumnWidth ) : innerColumnWidth;\n\t} );\n}\n\n/**\n * Returns a column width with unit.\n *\n * @param {string} width Column width.\n * @param {string} unit Column width unit.\n *\n * @return {string} Column width with unit.\n */\nexport function getWidthWithUnit( width, unit ) {\n\twidth = 0 > parseFloat( width ) ? '0' : width;\n\n\tif ( isPercentageUnit( unit ) ) {\n\t\twidth = Math.min( width, 100 );\n\t}\n\n\treturn `${ width }${ unit }`;\n}\n\n/**\n * Returns a boolean whether passed unit is percentage\n *\n * @param {string} unit Column width unit.\n *\n * @return {boolean} \tWhether unit is '%'.\n */\nexport function isPercentageUnit( unit ) {\n\treturn unit === '%';\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,KAAK,IAAM;EAC5C,MAAMC,aAAa,GAAGC,UAAU,CAAEF,KAAM,CAAC;EACzC,OAAOG,MAAM,CAACC,QAAQ,CAAEH,aAAc,CAAC,GACpCC,UAAU,CAAED,aAAa,CAACI,OAAO,CAAE,CAAE,CAAE,CAAC,GACxCC,SAAS;AACb,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARAC,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AASO,SAASS,uBAAuBA,CAAEC,KAAK,EAAEC,eAAe,EAAG;EACjE,MAAM;IAAEC,KAAK,GAAG,GAAG,GAAGD;EAAgB,CAAC,GAAGD,KAAK,CAACG,UAAU;EAC1D,OAAOb,gBAAgB,CAAEY,KAAM,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,oBAAoBA,CACnCC,MAAM,EACNJ,eAAe,GAAGI,MAAM,CAACC,MAAM,EAC9B;EACD,OAAOD,MAAM,CAACE,MAAM,CACnB,CAAEC,GAAG,EAAER,KAAK,KACXQ,GAAG,GA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A;AACO,SAASC,gBAAgBA,CAAED,IAAI,EAAG;EACxC,OAAOA,IAAI,KAAK,GAAG;AACpB","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_i18n","_blockEditor","_components","_coreData","_hooks","_jsxRuntime","TEMPLATE","getCommentsPlaceholder","perPage","pageComments","threadComments","threadCommentsDepth","commentsDepth","Math","min","buildChildrenComment","commentsLevel","nextLevel","commentId","children","placeholderComments","push","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","useInnerBlocksProps","template","jsxs","jsx","MemoizedCommentTemplatePreview","isHidden","length","CommentsList","comments","CommentTemplatePreview","blockPreviewProps","useBlockPreview","handleOnClick","style","display","undefined","tabIndex","role","onClick","onKeyPress","memo","blockProps","map","index","BlockContextProvider","value","CommentTemplateEdit","clientId","context","postId","useBlockProps","useState","commentOrder","commentsPerPage","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","useCommentQueryArgs","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","useCommentTree","reverse","Spinner","__"],"sources":["@wordpress/block-library/src/comment-template/edit.js"],"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 {Element} \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 currently 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 {Element} \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 requested 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"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAA8D,IAAAO,WAAA,GAAAP,OAAA;AAnB9D;AACA;AACA;;AAcA;AACA;AACA;;AAGA,MAAMQ,QAAQ,GAAG,CAChB,CAAE,aAAa,CAAE,EACjB,CAAE,0BAA0B,CAAE,EAC9B,CAAE,mBAAmB,CAAE,EACvB,CAAE,sBAAsB,CAAE,EAC1B,CAAE,yBAAyB,CAAE,EAC7B,CAAE,wBAAwB,CAA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,eACjB,IAAAd,WAAA,CAAA2B,GAAA,EAAC9B,WAAA,CAAA2E,OAAO,IAAE;IAAC,CACT,CAAC;EAEN;EAEA,IAAK,CAAEnB,MAAM,EAAG;IACfgB,WAAW,GAAGnE,sBAAsB,CAAE;MACrCC,OAAO,EAAEsD,eAAe;MACxBrD,YAAY;MACZC,cAAc;MACdC;IACD,CAAE,CAAC;EACJ;EAEA,IAAK,CAAE+D,WAAW,CAACvC,MAAM,EAAG;IAC3B,oBAAO,IAAA9B,WAAA,CAAA2B,GAAA;MAAA,GAAQkB,UAAU;MAAA/B,QAAA,EAAK,IAAA2D,QAAE,EAAE,mBAAoB;IAAC,CAAK,CAAC;EAC9D;EAEA,oBACC,IAAAzE,WAAA,CAAA2B,GAAA,EAACI,YAAY;IACZC,QAAQ,EAAGqC,WAAa;IACxBxB,UAAU,EAAGA,UAAY;IACzBvB,MAAM,EAAGA,MAAQ;IACjBH,eAAe,EAAGA,eAAiB;IACnCC,kBAAkB,EAAGA,kBAAoB;IACzCC,cAAc,EAAGgD,WAAW,CAAE,CAAC,CAAE,EAAExD;EAAW,CAC9C,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_i18n","_blockEditor","_components","_coreData","_hooks","_jsxRuntime","TEMPLATE","getCommentsPlaceholder","perPage","pageComments","threadComments","threadCommentsDepth","commentsDepth","Math","min","buildChildrenComment","commentsLevel","nextLevel","commentId","children","placeholderComments","push","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","useInnerBlocksProps","template","jsxs","jsx","MemoizedCommentTemplatePreview","isHidden","length","CommentsList","comments","CommentTemplatePreview","blockPreviewProps","useBlockPreview","handleOnClick","style","display","undefined","tabIndex","role","onClick","onKeyPress","memo","blockProps","map","index","BlockContextProvider","value","CommentTemplateEdit","clientId","context","postId","useBlockProps","useState","commentOrder","commentsPerPage","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","useCommentQueryArgs","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","useCommentTree","reverse","Spinner","__"],"sources":["@wordpress/block-library/src/comment-template/edit.js"],"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 {Element} \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 currently 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 {Element} \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 requested 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 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reList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_blockEditor","_url","_apiFetch","_interopRequireDefault","MAX_COMMENTS_PER_PAGE","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","pageComments","commentsPerPage","defaultCommentsPage","defaultPage","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","perPage","Math","min","page","useDefaultPageIndex","useMemo","post","per_page","exports","defaultPages","setDefaultPages","useState","key","useEffect","apiFetch","path","addQueryArgs","_fields","method","parse","then","res","pages","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n// This is limited by WP REST API\nconst MAX_COMMENTS_PER_PAGE = 100;\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tpageComments,\n\t\tcommentsPerPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// WP REST API doesn't allow fetching more than max items limit set per single page of data.\n\t// As for the editor performance is more important than completeness of data and fetching only the\n\t// max allowed for single page should be enough for the purpose of design and laying out the page.\n\t// Fetching over the limit would return an error here but would work with backend query.\n\tconst perPage = pageComments\n\t\t? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )\n\t\t: MAX_COMMENTS_PER_PAGE;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tconst pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAC,sBAAA,CAAAL,OAAA;AAPA;AACA;AACA;;AAOA;AACA,MAAMM,qBAAqB,GAAG,GAAG;;AAEjC;AACA;AACA;AACA;AACA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,CAAC,KAAM;IAC/C,MAAM,CAAEC,QAAQ,CAAE,GAAGD,SAAS,EAAEC,QAAQ,IAAI,CAAE,EAAE,CAAE;IAClD,OAAO;MACNC,SAAS,EAAEH,EAAE;MACbE,QAAQ,EAAEA,QAAQ,CAACH,GAAG,CAAIK,KAAK,KAAQ;QACtCD,SAAS,EAAEC,KAAK,CAACJ;MAClB,CAAC,CAAG;IACL,CAAC;EACF,CAAE,CAAC,EACJ,CAAEH,gBAAgB,CACnB,CAAC;EAED,OAAOC,WAAW;AACnB,CAAC;AAACpB,OAAA,CAAAkB,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_blockEditor","_url","_apiFetch","_interopRequireDefault","MAX_COMMENTS_PER_PAGE","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","pageComments","commentsPerPage","defaultCommentsPage","defaultPage","useSelect","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","perPage","Math","min","page","useDefaultPageIndex","useMemo","post","per_page","exports","defaultPages","setDefaultPages","useState","key","useEffect","apiFetch","path","addQueryArgs","_fields","method","parse","then","res","pages","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n// This is limited by WP REST API\nconst MAX_COMMENTS_PER_PAGE = 100;\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tpageComments,\n\t\tcommentsPerPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// WP REST API doesn't allow fetching more than max items limit set per single page of data.\n\t// As for the editor performance is more important than completeness of data and fetching only the\n\t// max allowed for single page should be enough for the purpose of design and laying out the page.\n\t// Fetching over the limit would return an error here but would work with backend query.\n\tconst perPage = pageComments\n\t\t? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )\n\t\t: MAX_COMMENTS_PER_PAGE;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tconst pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"],"mapp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AAOhB,WAAW,KAAK,QAAQ,GAAGS,IAAI,GAAG,CAAC;AAC3C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMuB,cAAc,GAAKC,gBAAgB,IAAM;EACrD,MAAMC,WAAW,GAAG,IAAAvB,gBAAO,EAC1B,MACCsB,gBAAgB,EAAEE,GAAG,CAAE,CAAE;IAAEC,EAAE;IAAEC;EAAU,CAAC,KAAM;IAC/C,MAAM,CAAEC,QAAQ,CAAE,GAAGD,SAAS,EAAEC,QAAQ,IAAI,CAAE,EAAE,CAAE;IAClD,OAAO;MACNC,SAAS,EAAEH,EAAE;MACbE,QAAQ,EAAEA,QAAQ,CAACH,GAAG,CAAIK,KAAK,KAAQ;QACtCD,SAAS,EAAEC,KAAK,CAACJ;MAClB,CAAC,CAAG;IACL,CAAC;EACF,CAAE,CAAC,EACJ,CAAEH,gBAAgB,CACnB,CAAC;EAED,OAAOC,WAAW;AACnB,CAAC;AAACpB,OAAA,CAAAkB,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push","exports"],"sources":["@wordpress/block-library/src/comment-template/util.js"],"sourcesContent":["/**\n *\n * This function converts a flat list of comment objects with a `parent` property\n * to a nested list of comment objects with a `children` property. The `children`\n * property is itself a list of comment objects.\n *\n * @example\n * ```\n * const comments = [\n * \t{ id: 1, parent: 0 },\n * \t{ id: 2, parent: 1 },\n * \t{ id: 3, parent: 2 },\n * \t{ id: 4, parent: 1 },\n * ];\n * expect( convertToTree( comments ) ).toEqual( [\n * \t{\n * \t\tcommentId: 1,\n * \t\tchildren: [\n * \t\t\t{ commentId: 2, children: [ { commentId: 3, children: [] } ] },\n * \t\t\t{ commentId: 4, children: [] },\n * \t\t],\n * \t},\n * ] );\n * ```\n * @typedef {{id: number, parent: number}} Comment\n * @param {Comment[]} data - List of comment objects.\n *\n * @return {Object[]} Nested list of comment objects with a `children` property.\n */\nexport const convertToTree = ( data ) => {\n\tconst table = {};\n\n\tif ( ! data ) {\n\t\treturn [];\n\t}\n\n\t// First create a hash table of { [id]: { ...comment, children: [] }}\n\tdata.forEach( ( item ) => {\n\t\ttable[ item.id ] = { commentId: item.id, children: [] };\n\t} );\n\n\tconst tree = [];\n\n\t// Iterate over the original comments again\n\tdata.forEach( ( item ) => {\n\t\tif ( item.parent ) {\n\t\t\t// If the comment has a \"parent\", then find that parent in the table that\n\t\t\t// we have created above and push the current comment to the array of its\n\t\t\t// children.\n\t\t\ttable[ item.parent ]?.children.push( table[ item.id ] );\n\t\t} else {\n\t\t\t// Otherwise, if the comment has no parent (also works if parent is 0)\n\t\t\t// that means that it's a top-level comment so we can find it in the table\n\t\t\t// and push it to the final tree.\n\t\t\ttree.push( table[ item.id ] );\n\t\t}\n\t} );\n\treturn tree;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAKC,IAAI,IAAM;EACxC,MAAMC,KAAK,GAAG,CAAC,CAAC;EAEhB,IAAK,CAAED,IAAI,EAAG;IACb,OAAO,EAAE;EACV;;EAEA;EACAA,IAAI,CAACE,OAAO,CAAIC,IAAI,IAAM;IACzBF,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAE,GAAG;MAAEC,SAAS,EAAEF,IAAI,CAACC,EAAE;MAAEE,QAAQ,EAAE;IAAG,CAAC;EACxD,CAAE,CAAC;EAEH,MAAMC,IAAI,GAAG,EAAE;;EAEf;EACAP,IAAI,CAACE,OAAO,CAAIC,IAAI,IAAM;IACzB,IAAKA,IAAI,CAACK,MAAM,EAAG;MAClB;MACA;MACA;MACAP,KAAK,CAAEE,IAAI,CAACK,MAAM,CAAE,EAAEF,QAAQ,CAACG,IAAI,CAAER,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAG,CAAC;IACxD,CAAC,MAAM;MACN;MACA;MACA;MACAG,IAAI,CAACE,IAAI,CAAER,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAG,CAAC;IAC9B;EACD,CAAE,CAAC;EACH,OAAOG,IAAI;AACZ,CAAC;AAACG,OAAA,CAAAX,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push","exports"],"sources":["@wordpress/block-library/src/comment-template/util.js"],"sourcesContent":["/**\n *\n * This function converts a flat list of comment objects with a `parent` property\n * to a nested list of comment objects with a `children` property. The `children`\n * property is itself a list of comment objects.\n *\n * @example\n * ```\n * const comments = [\n * \t{ id: 1, parent: 0 },\n * \t{ id: 2, parent: 1 },\n * \t{ id: 3, parent: 2 },\n * \t{ id: 4, parent: 1 },\n * ];\n * expect( convertToTree( comments ) ).toEqual( [\n * \t{\n * \t\tcommentId: 1,\n * \t\tchildren: [\n * \t\t\t{ commentId: 2, children: [ { commentId: 3, children: [] } ] },\n * \t\t\t{ commentId: 4, children: [] },\n * \t\t],\n * \t},\n * ] );\n * ```\n * @typedef {{id: number, parent: number}} Comment\n * @param {Comment[]} data - List of comment objects.\n *\n * @return {Object[]} Nested list of comment objects with a `children` property.\n */\nexport const convertToTree = ( data ) => {\n\tconst table = {};\n\n\tif ( ! data ) {\n\t\treturn [];\n\t}\n\n\t// First create a hash table of { [id]: { ...comment, children: [] }}\n\tdata.forEach( ( item ) => {\n\t\ttable[ item.id ] = { commentId: item.id, children: [] };\n\t} );\n\n\tconst tree = [];\n\n\t// Iterate over the original comments again\n\tdata.forEach( ( item ) => {\n\t\tif ( item.parent ) {\n\t\t\t// If the comment has a \"parent\", then find that parent in the table that\n\t\t\t// we have created above and push the current comment to the array of its\n\t\t\t// children.\n\t\t\ttable[ item.parent ]?.children.push( table[ item.id ] );\n\t\t} else {\n\t\t\t// Otherwise, if the comment has no parent (also works if parent is 0)\n\t\t\t// that means that it's a top-level comment so we can find it in the table\n\t\t\t// and push it to the final tree.\n\t\t\ttree.push( table[ item.id ] );\n\t\t}\n\t} );\n\treturn tree;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GAAKC,IAAI,IAAM;EACxC,MAAMC,KAAK,GAAG,CAAC,CAAC;EAEhB,IAAK,CAAED,IAAI,EAAG;IACb,OAAO,EAAE;EACV;;EAEA;EACAA,IAAI,CAACE,OAAO,CAAIC,IAAI,IAAM;IACzBF,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAE,GAAG;MAAEC,SAAS,EAAEF,IAAI,CAACC,EAAE;MAAEE,QAAQ,EAAE;IAAG,CAAC;EACxD,CAAE,CAAC;EAEH,MAAMC,IAAI,GAAG,EAAE;;EAEf;EACAP,IAAI,CAACE,OAAO,CAAIC,IAAI,IAAM;IACzB,IAAKA,IAAI,CAACK,MAAM,EAAG;MAClB;MACA;MACA;MACAP,KAAK,CAAEE,IAAI,CAACK,MAAM,CAAE,EAAEF,QAAQ,CAACG,IAAI,CAAER,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAG,CAAC;IACxD,CAAC,MAAM;MACN;MACA;MACA;MACAG,IAAI,CAACE,IAAI,CAAER,KAAK,CAAEE,IAAI,CAACC,EAAE,CAAG,CAAC;IAC9B;EACD,CAAE,CAAC;EACH,OAAOG,IAAI;AACZ,CAAC;AAACG,OAAA,CAAAX,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_default","exports","default","from","type","isMultiBlock","blocks","isMatch","length","name","__experimentalConvert","createBlock","map","block","cloneBlock"],"sources":["@wordpress/block-library/src/details/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, cloneBlock } from '@wordpress/blocks';\n\nexport default {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\tisMatch( {}, blocks ) {\n\t\t\t\treturn ! (\n\t\t\t\t\tblocks.length === 1 && blocks[ 0 ].name === 'core/details'\n\t\t\t\t);\n\t\t\t},\n\t\t\t__experimentalConvert( blocks ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/details',\n\t\t\t\t\t{},\n\t\t\t\t\tblocks.map( ( block ) => cloneBlock( block ) )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACdC,IAAI,EAAE,CACL;IACCC,IAAI,EAAE,OAAO;IACbC,YAAY,EAAE,IAAI;IAClBC,MAAM,EAAE,CAAE,GAAG,CAAE;IACfC,OAAOA,CAAE,CAAC,CAAC,EAAED,MAAM,EAAG;MACrB,OAAO,EACNA,MAAM,CAACE,MAAM,KAAK,CAAC,IAAIF,MAAM,CAAE,CAAC,CAAE,CAACG,IAAI,KAAK,cAAc,CAC1D;IACF,CAAC;IACDC,qBAAqBA,CAAEJ,MAAM,EAAG;MAC/B,OAAO,IAAAK,mBAAW,EACjB,cAAc,EACd,CAAC,CAAC,EACFL,MAAM,CAACM,GAAG,CAAIC,KAAK,IAAM,IAAAC,kBAAU,EAAED,KAAM,CAAE,CAC9C,CAAC;IACF;EACD,CAAC;AAEH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","_default","exports","default","from","type","isMultiBlock","blocks","isMatch","length","name","__experimentalConvert","createBlock","map","block","cloneBlock"],"sources":["@wordpress/block-library/src/details/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, cloneBlock } from '@wordpress/blocks';\n\nexport default {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ '*' ],\n\t\t\tisMatch( {}, blocks ) {\n\t\t\t\treturn ! (\n\t\t\t\t\tblocks.length === 1 && blocks[ 0 ].name === 'core/details'\n\t\t\t\t);\n\t\t\t},\n\t\t\t__experimentalConvert( blocks ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/details',\n\t\t\t\t\t{},\n\t\t\t\t\tblocks.map( ( block ) => cloneBlock( block ) )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t],\n};\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACdC,IAAI,EAAE,CACL;IACCC,IAAI,EAAE,OAAO;IACbC,YAAY,EAAE,IAAI;IAClBC,MAAM,EAAE,CAAE,GAAG,CAAE;IACfC,OAAOA,CAAE,CAAC,CAAC,EAAED,MAAM,EAAG;MACrB,OAAO,EACNA,MAAM,CAACE,MAAM,KAAK,CAAC,IAAIF,MAAM,CAAE,CAAC,CAAE,CAACG,IAAI,KAAK,cAAc,CAC1D;IACF,CAAC;IACDC,qBAAqBA,CAAEJ,MAAM,EAAG;MAC/B,OAAO,IAAAK,mBAAW,EACjB,cAAc,EACd,CAAC,CAAC,EACFL,MAAM,CAACM,GAAG,CAAIC,KAAK,IAAM,IAAAC,kBAAU,EAAED,KAAM,CAAE,CAC9C,CAAC;IACF;EACD,CAAC;AAEH,CAAC","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_i18n","_compose","_components","_blockEditor","_element","_styles","_interopRequireDefault","_gridicons","_jsxRuntime","hitSlop","top","bottom","left","right","EmbedPlaceholder","icon","isSelected","label","onPress","cannotEmbed","fallback","tryAgain","openEmbedLinkSettings","containerSelectedStyle","usePreferredColorSchemeStyle","styles","containerStyle","embed__container","labelStyle","embed__label","descriptionStyle","embed__description","descriptionErrorStyle","actionStyle","embed__action","embedIconErrorStyle","buttonStyles","embed__button","iconStyles","embed__icon","cannotEmbedMenuPickerRef","useRef","errorPickerOptions","retry","id","__","value","onSelect","convertToLink","editLink","options","filter","Boolean","onPickerSelect","selectedItem","find","item","resolveOnPressEvent","current","presentPicker","jsx","Fragment","children","View","style","jsxs","Icon","noticeOutline","fill","Text","TouchableOpacity","activeOpacity","accessibilityRole","accessibilityHint","disabled","Picker","title","ref","onChange","hideCancelButton","leftAlign","BlockIcon","_default","exports","default"],"sources":["@wordpress/block-library/src/embed/embed-placeholder.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableOpacity } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { Icon, Picker } from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\nimport { noticeOutline } from '../../../components/src/mobile/gridicons';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\n\nconst EmbedPlaceholder = ( {\n\ticon,\n\tisSelected,\n\tlabel,\n\tonPress,\n\tcannotEmbed,\n\tfallback,\n\ttryAgain,\n\topenEmbedLinkSettings,\n} ) => {\n\tconst containerSelectedStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'embed__container-selected' ],\n\t\tstyles[ 'embed__container-selected--dark' ]\n\t);\n\tconst containerStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.embed__container,\n\t\t\tstyles[ 'embed__container--dark' ]\n\t\t),\n\t\tisSelected && containerSelectedStyle,\n\t];\n\tconst labelStyle = usePreferredColorSchemeStyle(\n\t\tstyles.embed__label,\n\t\tstyles[ 'embed__label--dark' ]\n\t);\n\tconst descriptionStyle = styles.embed__description;\n\tconst descriptionErrorStyle = styles[ 'embed__description--error' ];\n\tconst actionStyle = usePreferredColorSchemeStyle(\n\t\tstyles.embed__action,\n\t\tstyles[ 'embed__action--dark' ]\n\t);\n\tconst embedIconErrorStyle = styles[ 'embed__icon--error' ];\n\n\tconst buttonStyles = usePreferredColorSchemeStyle(\n\t\tstyles.embed__button,\n\t\tstyles[ 'embed__button--dark' ]\n\t);\n\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\tstyles.embed__icon,\n\t\tstyles[ 'embed__icon--dark' ]\n\t);\n\n\tconst cannotEmbedMenuPickerRef = useRef();\n\n\tconst errorPickerOptions = {\n\t\tretry: {\n\t\t\tid: 'retryOption',\n\t\t\tlabel: __( 'Retry' ),\n\t\t\tvalue: 'retryOption',\n\t\t\tonSelect: tryAgain,\n\t\t},\n\t\tconvertToLink: {\n\t\t\tid: 'convertToLinkOption',\n\t\t\tlabel: __( 'Convert to link' ),\n\t\t\tvalue: 'convertToLinkOption',\n\t\t\tonSelect: fallback,\n\t\t},\n\t\teditLink: {\n\t\t\tid: 'editLinkOption',\n\t\t\tlabel: __( 'Edit link' ),\n\t\t\tvalue: 'editLinkOption',\n\t\t\tonSelect: openEmbedLinkSettings,\n\t\t},\n\t};\n\n\tconst options = [\n\t\tcannotEmbed && errorPickerOptions.retry,\n\t\tcannotEmbed && errorPickerOptions.convertToLink,\n\t\tcannotEmbed && errorPickerOptions.editLink,\n\t].filter( Boolean );\n\n\tfunction onPickerSelect( value ) {\n\t\tconst selectedItem = options.find( ( item ) => item.value === value );\n\t\tselectedItem.onSelect();\n\t}\n\n\t// When the content cannot be embedded the onPress should trigger the Picker instead of the onPress prop.\n\tfunction resolveOnPressEvent() {\n\t\tif ( cannotEmbed ) {\n\t\t\tcannotEmbedMenuPickerRef.current?.presentPicker();\n\t\t} else {\n\t\t\tonPress();\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<View style={ containerStyle }>\n\t\t\t\t{ cannotEmbed ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\ticon={ noticeOutline }\n\t\t\t\t\t\t\tfill={ embedIconErrorStyle.fill }\n\t\t\t\t\t\t\tstyle={ embedIconErrorStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tdescriptionStyle,\n\t\t\t\t\t\t\t\tdescriptionErrorStyle,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Unable to embed media' ) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t'Double tap to view embed options.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\t\thitSlop={ hitSlop }\n\t\t\t\t\t\t\tonPress={ resolveOnPressEvent }\n\t\t\t\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text style={ actionStyle }>\n\t\t\t\t\t\t\t\t{ __( 'More options' ) }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t<Picker\n\t\t\t\t\t\t\ttitle={ __( 'Embed options' ) }\n\t\t\t\t\t\t\tref={ cannotEmbedMenuPickerRef }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\t\t\thideCancelButton\n\t\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<View style={ styles[ 'embed__placeholder-header' ] }>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } fill={ iconStyles.fill } />\n\t\t\t\t\t\t\t<Text style={ labelStyle }>{ label }</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t'Double tap to add a link.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\t\thitSlop={ hitSlop }\n\t\t\t\t\t\t\tonPress={ resolveOnPressEvent }\n\t\t\t\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text style={ actionStyle }>\n\t\t\t\t\t\t\t\t{ __( 'Add link' ) }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedPlaceholder;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,OAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAAyE,IAAAS,WAAA,GAAAT,OAAA;AAlBzE;AACA;AACA;;AAGA;AACA;AACA;;A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AA,CAAAyD,IAAA,EAAAzD,WAAA,CAAAqD,QAAA;QAAAC,QAAA,gBACC,IAAAtD,WAAA,CAAAyD,IAAA,EAACnE,YAAA,CAAAiE,IAAI;UAACC,KAAK,EAAGvC,eAAM,CAAE,2BAA2B,CAAI;UAAAqC,QAAA,gBACpD,IAAAtD,WAAA,CAAAoD,GAAA,EAACzD,YAAA,CAAA8E,SAAS;YAAClE,IAAI,EAAGA,IAAM;YAACqD,IAAI,EAAG9B,UAAU,CAAC8B;UAAM,CAAE,CAAC,eACpD,IAAA5D,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAuE,IAAI;YAACL,KAAK,EAAGpC,UAAY;YAAAkC,QAAA,EAAG7C;UAAK,CAAQ,CAAC;QAAA,CACtC,CAAC,eACP,IAAAT,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAwE,gBAAgB;UAChBC,aAAa,EAAG,GAAK;UACrBC,iBAAiB,EAAC,QAAQ;UAC1BC,iBAAiB,EAAG,IAAA5B,QAAE,EACrB,2BACD,CAAG;UACHmB,KAAK,EAAG5B,YAAc;UACtB3B,OAAO,EAAGA,OAAS;UACnBS,OAAO,EAAGuC,mBAAqB;UAC/BiB,QAAQ,EAAG,CAAE1D,UAAY;UAAA8C,QAAA,eAEzB,IAAAtD,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAuE,IAAI;YAACL,KAAK,EAAG/B,WAAa;YAAA6B,QAAA,EACxB,IAAAjB,QAAE,EAAE,UAAW;UAAC,CACb;QAAC,CACU,CAAC;MAAA,CAClB;IACF,CACI;EAAC,CACN,CAAC;AAEL,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatE,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_i18n","_compose","_components","_blockEditor","_element","_styles","_interopRequireDefault","_gridicons","_jsxRuntime","hitSlop","top","bottom","left","right","EmbedPlaceholder","icon","isSelected","label","onPress","cannotEmbed","fallback","tryAgain","openEmbedLinkSettings","containerSelectedStyle","usePreferredColorSchemeStyle","styles","containerStyle","embed__container","labelStyle","embed__label","descriptionStyle","embed__description","descriptionErrorStyle","actionStyle","embed__action","embedIconErrorStyle","buttonStyles","embed__button","iconStyles","embed__icon","cannotEmbedMenuPickerRef","useRef","errorPickerOptions","retry","id","__","value","onSelect","convertToLink","editLink","options","filter","Boolean","onPickerSelect","selectedItem","find","item","resolveOnPressEvent","current","presentPicker","jsx","Fragment","children","View","style","jsxs","Icon","noticeOutline","fill","Text","TouchableOpacity","activeOpacity","accessibilityRole","accessibilityHint","disabled","Picker","title","ref","onChange","hideCancelButton","leftAlign","BlockIcon","_default","exports","default"],"sources":["@wordpress/block-library/src/embed/embed-placeholder.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text, TouchableOpacity } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { Icon, Picker } from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\nimport { noticeOutline } from '../../../components/src/mobile/gridicons';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\n\nconst EmbedPlaceholder = ( {\n\ticon,\n\tisSelected,\n\tlabel,\n\tonPress,\n\tcannotEmbed,\n\tfallback,\n\ttryAgain,\n\topenEmbedLinkSettings,\n} ) => {\n\tconst containerSelectedStyle = usePreferredColorSchemeStyle(\n\t\tstyles[ 'embed__container-selected' ],\n\t\tstyles[ 'embed__container-selected--dark' ]\n\t);\n\tconst containerStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.embed__container,\n\t\t\tstyles[ 'embed__container--dark' ]\n\t\t),\n\t\tisSelected && containerSelectedStyle,\n\t];\n\tconst labelStyle = usePreferredColorSchemeStyle(\n\t\tstyles.embed__label,\n\t\tstyles[ 'embed__label--dark' ]\n\t);\n\tconst descriptionStyle = styles.embed__description;\n\tconst descriptionErrorStyle = styles[ 'embed__description--error' ];\n\tconst actionStyle = usePreferredColorSchemeStyle(\n\t\tstyles.embed__action,\n\t\tstyles[ 'embed__action--dark' ]\n\t);\n\tconst embedIconErrorStyle = styles[ 'embed__icon--error' ];\n\n\tconst buttonStyles = usePreferredColorSchemeStyle(\n\t\tstyles.embed__button,\n\t\tstyles[ 'embed__button--dark' ]\n\t);\n\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\tstyles.embed__icon,\n\t\tstyles[ 'embed__icon--dark' ]\n\t);\n\n\tconst cannotEmbedMenuPickerRef = useRef();\n\n\tconst errorPickerOptions = {\n\t\tretry: {\n\t\t\tid: 'retryOption',\n\t\t\tlabel: __( 'Retry' ),\n\t\t\tvalue: 'retryOption',\n\t\t\tonSelect: tryAgain,\n\t\t},\n\t\tconvertToLink: {\n\t\t\tid: 'convertToLinkOption',\n\t\t\tlabel: __( 'Convert to link' ),\n\t\t\tvalue: 'convertToLinkOption',\n\t\t\tonSelect: fallback,\n\t\t},\n\t\teditLink: {\n\t\t\tid: 'editLinkOption',\n\t\t\tlabel: __( 'Edit link' ),\n\t\t\tvalue: 'editLinkOption',\n\t\t\tonSelect: openEmbedLinkSettings,\n\t\t},\n\t};\n\n\tconst options = [\n\t\tcannotEmbed && errorPickerOptions.retry,\n\t\tcannotEmbed && errorPickerOptions.convertToLink,\n\t\tcannotEmbed && errorPickerOptions.editLink,\n\t].filter( Boolean );\n\n\tfunction onPickerSelect( value ) {\n\t\tconst selectedItem = options.find( ( item ) => item.value === value );\n\t\tselectedItem.onSelect();\n\t}\n\n\t// When the content cannot be embedded the onPress should trigger the Picker instead of the onPress prop.\n\tfunction resolveOnPressEvent() {\n\t\tif ( cannotEmbed ) {\n\t\t\tcannotEmbedMenuPickerRef.current?.presentPicker();\n\t\t} else {\n\t\t\tonPress();\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<View style={ containerStyle }>\n\t\t\t\t{ cannotEmbed ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\ticon={ noticeOutline }\n\t\t\t\t\t\t\tfill={ embedIconErrorStyle.fill }\n\t\t\t\t\t\t\tstyle={ embedIconErrorStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\tdescriptionStyle,\n\t\t\t\t\t\t\t\tdescriptionErrorStyle,\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Unable to embed media' ) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t'Double tap to view embed options.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\t\thitSlop={ hitSlop }\n\t\t\t\t\t\t\tonPress={ resolveOnPressEvent }\n\t\t\t\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text style={ actionStyle }>\n\t\t\t\t\t\t\t\t{ __( 'More options' ) }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t<Picker\n\t\t\t\t\t\t\ttitle={ __( 'Embed options' ) }\n\t\t\t\t\t\t\tref={ cannotEmbedMenuPickerRef }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tonChange={ onPickerSelect }\n\t\t\t\t\t\t\thideCancelButton\n\t\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<View style={ styles[ 'embed__placeholder-header' ] }>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } fill={ iconStyles.fill } />\n\t\t\t\t\t\t\t<Text style={ labelStyle }>{ label }</Text>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\t\t\taccessibilityHint={ __(\n\t\t\t\t\t\t\t\t'Double tap to add a link.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\t\thitSlop={ hitSlop }\n\t\t\t\t\t\t\tonPress={ resolveOnPressEvent }\n\t\t\t\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text style={ actionStyle }>\n\t\t\t\t\t\t\t\t{ __( 'Add link' ) }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedPlaceholder;\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,OAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAAyE,IAAAS,WAAA,GAAAT,OAAA;AAlBzE;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMU,OAAO,GAAG;EAAEC,GAAG,EAAE,EAAE;EAAEC,MAAM,EAAE,EAAE;EAAEC,IAAI,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE5D,MAAMC,gBAAgB,GAAGA,CAAE;EAC1BC,IAA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tD,WAAA,CAAAoD,GAAA,EAACzD,YAAA,CAAA8E,SAAS;YAAClE,IAAI,EAAGA,IAAM;YAACqD,IAAI,EAAG9B,UAAU,CAAC8B;UAAM,CAAE,CAAC,eACpD,IAAA5D,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAuE,IAAI;YAACL,KAAK,EAAGpC,UAAY;YAAAkC,QAAA,EAAG7C;UAAK,CAAQ,CAAC;QAAA,CACtC,CAAC,eACP,IAAAT,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAwE,gBAAgB;UAChBC,aAAa,EAAG,GAAK;UACrBC,iBAAiB,EAAC,QAAQ;UAC1BC,iBAAiB,EAAG,IAAA5B,QAAE,EACrB,2BACD,CAAG;UACHmB,KAAK,EAAG5B,YAAc;UACtB3B,OAAO,EAAGA,OAAS;UACnBS,OAAO,EAAGuC,mBAAqB;UAC/BiB,QAAQ,EAAG,CAAE1D,UAAY;UAAA8C,QAAA,eAEzB,IAAAtD,WAAA,CAAAoD,GAAA,EAAC9D,YAAA,CAAAuE,IAAI;YAACL,KAAK,EAAG/B,WAAa;YAAA6B,QAAA,EACxB,IAAAjB,QAAE,EAAE,UAAW;UAAC,CACb;QAAC,CACU,CAAC;MAAA,CAClB;IACF,CACI;EAAC,CACN,CAAC;AAEL,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatE,gBAAgB","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_memize","_components","_element","_blocks","_constants","_lockUnlock","_jsxRuntime","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","role","caption","source","selector","providerNameSlug","allowResponsive","responsive","previewable","supports","align","spacing","margin","interactivity","clientNavigation","editorStyle","style","DEFAULT_EMBED_BLOCK","kebabCase","unlock","componentsPrivateApis","getEmbedInfoByProvider","provider","getBlockVariations","find","exports","matchesPatterns","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","jsx","children","src","alt","width","renderToString","createUpgradedEmbedBlock","props","attributesFromPreview","preview","restAttributes","getBlockType","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","createBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","push","outputClassNames","replace","trim","getClassNames","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","clsx","fallback","onReplace","link","href","content","getAttributesFromPreview","memoize","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes"],"sources":["@wordpress/block-library/src/embed/util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\nconst { kebabCase } = unlock( componentsPrivateApis );\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test against.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) {\n\t\treturn;\n\t}\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an empty string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator.push( className );\n\t\t\treturn accumulator;\n\t\t},\n\t\t[ 'wp-has-aspect-ratio' ]\n\t);\n\tlet outputClassNames = existingClassNames;\n\tfor ( const className of aspectRatioClassNames ) {\n\t\toutputClassNames = outputClassNames.replace( className, '' );\n\t}\n\treturn outputClassNames.trim();\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn clsx(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAKA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAUA,IAAAK,UAAA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AA,GAAAA,8BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_memize","_components","_element","_blocks","_constants","_lockUnlock","_jsxRuntime","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","url","type","role","caption","source","selector","providerNameSlug","allowResponsive","responsive","previewable","supports","align","spacing","margin","interactivity","clientNavigation","editorStyle","style","DEFAULT_EMBED_BLOCK","kebabCase","unlock","componentsPrivateApis","getEmbedInfoByProvider","provider","getBlockVariations","find","exports","matchesPatterns","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","jsx","children","src","alt","width","renderToString","createUpgradedEmbedBlock","props","attributesFromPreview","preview","restAttributes","getBlockType","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","createBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","push","outputClassNames","replace","trim","getClassNames","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","clsx","fallback","onReplace","link","href","content","getAttributesFromPreview","memoize","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes"],"sources":["@wordpress/block-library/src/embed/util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\nimport { unlock } from '../lock-unlock';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\nconst { kebabCase } = unlock( componentsPrivateApis );\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test against.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) {\n\t\treturn;\n\t}\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an empty string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator.push( className );\n\t\t\treturn accumulator;\n\t\t},\n\t\t[ 'wp-has-aspect-ratio' ]\n\t);\n\tlet outputClassNames = existingClassNames;\n\tfor ( const className of aspectRatioClassNames ) {\n\t\toutputClassNames = outputClassNames.replace( className, '' );\n\t}\n\treturn outputClassNames.trim();\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn clsx(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t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