@wordpress/block-library 7.12.0 → 7.12.2-next.d6164808d3.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 (626) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/build/archives/index.js +5 -1
  3. package/build/archives/index.js.map +1 -1
  4. package/build/audio/index.js +4 -0
  5. package/build/audio/index.js.map +1 -1
  6. package/build/button/deprecated.js +14 -5
  7. package/build/button/deprecated.js.map +1 -1
  8. package/build/button/index.js +1 -1
  9. package/build/categories/edit.js +3 -1
  10. package/build/categories/edit.js.map +1 -1
  11. package/build/categories/index.js +14 -1
  12. package/build/categories/index.js.map +1 -1
  13. package/build/code/index.js +4 -2
  14. package/build/code/index.js.map +1 -1
  15. package/build/column/index.js +13 -0
  16. package/build/column/index.js.map +1 -1
  17. package/build/columns/deprecated.js +16 -5
  18. package/build/columns/deprecated.js.map +1 -1
  19. package/build/columns/edit.js +6 -2
  20. package/build/columns/edit.js.map +1 -1
  21. package/build/columns/edit.native.js +6 -2
  22. package/build/columns/edit.native.js.map +1 -1
  23. package/build/columns/index.js +13 -0
  24. package/build/columns/index.js.map +1 -1
  25. package/build/comment-author-name/index.js +5 -1
  26. package/build/comment-author-name/index.js.map +1 -1
  27. package/build/comment-content/index.js +5 -1
  28. package/build/comment-content/index.js.map +1 -1
  29. package/build/comment-date/index.js +1 -0
  30. package/build/comment-date/index.js.map +1 -1
  31. package/build/comment-edit-link/index.js +5 -1
  32. package/build/comment-edit-link/index.js.map +1 -1
  33. package/build/comment-reply-link/index.js +5 -1
  34. package/build/comment-reply-link/index.js.map +1 -1
  35. package/build/comment-template/index.js +14 -1
  36. package/build/comment-template/index.js.map +1 -1
  37. package/build/comments/index.js +13 -0
  38. package/build/comments/index.js.map +1 -1
  39. package/build/comments-pagination/index.js +13 -0
  40. package/build/comments-pagination/index.js.map +1 -1
  41. package/build/comments-pagination-next/index.js +4 -2
  42. package/build/comments-pagination-next/index.js.map +1 -1
  43. package/build/comments-pagination-numbers/edit.js +5 -1
  44. package/build/comments-pagination-numbers/edit.js.map +1 -1
  45. package/build/comments-pagination-numbers/index.js +14 -1
  46. package/build/comments-pagination-numbers/index.js.map +1 -1
  47. package/build/comments-pagination-previous/index.js +4 -2
  48. package/build/comments-pagination-previous/index.js.map +1 -1
  49. package/build/comments-title/deprecated.js +4 -2
  50. package/build/comments-title/deprecated.js.map +1 -1
  51. package/build/comments-title/index.js +4 -2
  52. package/build/comments-title/index.js.map +1 -1
  53. package/build/cover/deprecated.js +20 -5
  54. package/build/cover/deprecated.js.map +1 -1
  55. package/build/cover/index.js +13 -0
  56. package/build/cover/index.js.map +1 -1
  57. package/build/cover/shared.js +1 -1
  58. package/build/cover/shared.js.map +1 -1
  59. package/build/embed/icons.js +1 -1
  60. package/build/embed/icons.js.map +1 -1
  61. package/build/gallery/deprecated.js +6 -1
  62. package/build/gallery/deprecated.js.map +1 -1
  63. package/build/gallery/edit.js +15 -2
  64. package/build/gallery/edit.js.map +1 -1
  65. package/build/gallery/index.js +5 -0
  66. package/build/gallery/index.js.map +1 -1
  67. package/build/gallery/transforms.js +20 -7
  68. package/build/gallery/transforms.js.map +1 -1
  69. package/build/gallery/utils.js +7 -6
  70. package/build/gallery/utils.js.map +1 -1
  71. package/build/group/deprecated.js +108 -12
  72. package/build/group/deprecated.js.map +1 -1
  73. package/build/group/edit.js +23 -1
  74. package/build/group/edit.js.map +1 -1
  75. package/build/group/index.js +10 -2
  76. package/build/group/index.js.map +1 -1
  77. package/build/group/variations.js +8 -8
  78. package/build/group/variations.js.map +1 -1
  79. package/build/heading/deprecated.js +5 -3
  80. package/build/heading/deprecated.js.map +1 -1
  81. package/build/heading/index.js +3 -1
  82. package/build/heading/index.js.map +1 -1
  83. package/build/heading/transforms.js +3 -1
  84. package/build/heading/transforms.js.map +1 -1
  85. package/build/home-link/edit.js +8 -4
  86. package/build/home-link/edit.js.map +1 -1
  87. package/build/image/edit.js +13 -1
  88. package/build/image/edit.js.map +1 -1
  89. package/build/image/index.js +13 -7
  90. package/build/image/index.js.map +1 -1
  91. package/build/index.native.js +6 -3
  92. package/build/index.native.js.map +1 -1
  93. package/build/list-item/edit.js +3 -1
  94. package/build/list-item/edit.js.map +1 -1
  95. package/build/list-item/hooks/index.js +8 -0
  96. package/build/list-item/hooks/index.js.map +1 -1
  97. package/build/list-item/hooks/use-copy.js +42 -0
  98. package/build/list-item/hooks/use-copy.js.map +1 -0
  99. package/build/list-item/list-style-type.native.js +4 -1
  100. package/build/list-item/list-style-type.native.js.map +1 -1
  101. package/build/media-text/deprecated.js +5 -1
  102. package/build/media-text/deprecated.js.map +1 -1
  103. package/build/media-text/index.js +13 -0
  104. package/build/media-text/index.js.map +1 -1
  105. package/build/navigation/deprecated.js +6 -1
  106. package/build/navigation/deprecated.js.map +1 -1
  107. package/build/navigation/edit/index.js +119 -38
  108. package/build/navigation/edit/index.js.map +1 -1
  109. package/build/navigation/edit/unsaved-inner-blocks.js +2 -1
  110. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  111. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +4 -7
  112. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  113. package/build/navigation/menu-items-to-blocks.js +1 -7
  114. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  115. package/build/navigation/use-navigation-menu.js +8 -7
  116. package/build/navigation/use-navigation-menu.js.map +1 -1
  117. package/build/navigation-link/edit.js +6 -8
  118. package/build/navigation-link/edit.js.map +1 -1
  119. package/build/navigation-submenu/edit.js +4 -6
  120. package/build/navigation-submenu/edit.js.map +1 -1
  121. package/build/page-list/edit.js +7 -3
  122. package/build/page-list/edit.js.map +1 -1
  123. package/build/paragraph/deprecated.js +18 -10
  124. package/build/paragraph/deprecated.js.map +1 -1
  125. package/build/paragraph/edit.js +1 -0
  126. package/build/paragraph/edit.js.map +1 -1
  127. package/build/paragraph/index.js +5 -0
  128. package/build/paragraph/index.js.map +1 -1
  129. package/build/paragraph/transforms.js +5 -0
  130. package/build/paragraph/transforms.js.map +1 -1
  131. package/build/post-author/index.js +4 -2
  132. package/build/post-author/index.js.map +1 -1
  133. package/build/post-author-biography/index.js +1 -0
  134. package/build/post-author-biography/index.js.map +1 -1
  135. package/build/post-author-name/index.js +5 -1
  136. package/build/post-author-name/index.js.map +1 -1
  137. package/build/post-comments-count/edit.js +11 -1
  138. package/build/post-comments-count/edit.js.map +1 -1
  139. package/build/post-comments-count/index.js +4 -1
  140. package/build/post-comments-count/index.js.map +1 -1
  141. package/build/post-comments-link/index.js +4 -2
  142. package/build/post-comments-link/index.js.map +1 -1
  143. package/build/post-date/edit.js +9 -2
  144. package/build/post-date/edit.js.map +1 -1
  145. package/build/post-date/index.js +9 -0
  146. package/build/post-date/index.js.map +1 -1
  147. package/build/post-featured-image/edit.js +27 -12
  148. package/build/post-featured-image/edit.js.map +1 -1
  149. package/build/post-featured-image/index.js +12 -0
  150. package/build/post-featured-image/index.js.map +1 -1
  151. package/build/post-navigation-link/index.js +3 -2
  152. package/build/post-navigation-link/index.js.map +1 -1
  153. package/build/post-template/edit.js +8 -4
  154. package/build/post-template/edit.js.map +1 -1
  155. package/build/post-template/index.js +14 -1
  156. package/build/post-template/index.js.map +1 -1
  157. package/build/post-terms/index.js +5 -3
  158. package/build/post-terms/index.js.map +1 -1
  159. package/build/post-title/index.js +2 -1
  160. package/build/post-title/index.js.map +1 -1
  161. package/build/preformatted/index.js +4 -2
  162. package/build/preformatted/index.js.map +1 -1
  163. package/build/pullquote/deprecated.js +135 -25
  164. package/build/pullquote/deprecated.js.map +1 -1
  165. package/build/pullquote/edit.js +1 -1
  166. package/build/pullquote/edit.js.map +1 -1
  167. package/build/pullquote/edit.native.js +0 -1
  168. package/build/pullquote/edit.native.js.map +1 -1
  169. package/build/pullquote/index.js +13 -6
  170. package/build/pullquote/index.js.map +1 -1
  171. package/build/pullquote/save.js +2 -2
  172. package/build/pullquote/save.js.map +1 -1
  173. package/build/pullquote/transforms.js +14 -33
  174. package/build/pullquote/transforms.js.map +1 -1
  175. package/build/query/deprecated.js +10 -9
  176. package/build/query/deprecated.js.map +1 -1
  177. package/build/query/edit/index.js +19 -8
  178. package/build/query/edit/index.js.map +1 -1
  179. package/build/query/edit/inspector-controls/taxonomy-controls.js +1 -0
  180. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  181. package/build/query/edit/query-placeholder.js +6 -1
  182. package/build/query/edit/query-placeholder.js.map +1 -1
  183. package/build/query/utils.js +35 -9
  184. package/build/query/utils.js.map +1 -1
  185. package/build/query-no-results/edit.js +1 -1
  186. package/build/query-no-results/edit.js.map +1 -1
  187. package/build/query-title/edit.js +10 -1
  188. package/build/query-title/edit.js.map +1 -1
  189. package/build/query-title/index.js +7 -2
  190. package/build/query-title/index.js.map +1 -1
  191. package/build/quote/deprecated.js +13 -6
  192. package/build/quote/deprecated.js.map +1 -1
  193. package/build/quote/transforms.js +22 -37
  194. package/build/quote/transforms.js.map +1 -1
  195. package/build/separator/deprecated.js +3 -4
  196. package/build/separator/deprecated.js.map +1 -1
  197. package/build/separator/index.js +1 -0
  198. package/build/separator/index.js.map +1 -1
  199. package/build/social-link/icons/reddit.js +1 -1
  200. package/build/social-link/icons/reddit.js.map +1 -1
  201. package/build/social-links/edit.js +2 -1
  202. package/build/social-links/edit.js.map +1 -1
  203. package/build/spacer/index.js +7 -1
  204. package/build/spacer/index.js.map +1 -1
  205. package/build/table/index.js +4 -0
  206. package/build/table/index.js.map +1 -1
  207. package/build/table/state.js +9 -3
  208. package/build/table/state.js.map +1 -1
  209. package/build/table-of-contents/index.js +11 -1
  210. package/build/table-of-contents/index.js.map +1 -1
  211. package/build/tag-cloud/index.js +5 -1
  212. package/build/tag-cloud/index.js.map +1 -1
  213. package/build/template-part/index.js +2 -2
  214. package/build/template-part/index.js.map +1 -1
  215. package/build/term-description/index.js +4 -0
  216. package/build/term-description/index.js.map +1 -1
  217. package/build/text-columns/edit.js +3 -1
  218. package/build/text-columns/edit.js.map +1 -1
  219. package/build/text-columns/save.js +3 -1
  220. package/build/text-columns/save.js.map +1 -1
  221. package/build/verse/index.js +1 -0
  222. package/build/verse/index.js.map +1 -1
  223. package/build/video/index.js +4 -0
  224. package/build/video/index.js.map +1 -1
  225. package/build-module/archives/index.js +5 -1
  226. package/build-module/archives/index.js.map +1 -1
  227. package/build-module/audio/index.js +4 -0
  228. package/build-module/audio/index.js.map +1 -1
  229. package/build-module/button/deprecated.js +14 -4
  230. package/build-module/button/deprecated.js.map +1 -1
  231. package/build-module/button/index.js +1 -1
  232. package/build-module/categories/edit.js +4 -2
  233. package/build-module/categories/edit.js.map +1 -1
  234. package/build-module/categories/index.js +14 -1
  235. package/build-module/categories/index.js.map +1 -1
  236. package/build-module/code/index.js +4 -2
  237. package/build-module/code/index.js.map +1 -1
  238. package/build-module/column/index.js +13 -0
  239. package/build-module/column/index.js.map +1 -1
  240. package/build-module/columns/deprecated.js +16 -4
  241. package/build-module/columns/deprecated.js.map +1 -1
  242. package/build-module/columns/edit.js +7 -3
  243. package/build-module/columns/edit.js.map +1 -1
  244. package/build-module/columns/edit.native.js +7 -3
  245. package/build-module/columns/edit.native.js.map +1 -1
  246. package/build-module/columns/index.js +13 -0
  247. package/build-module/columns/index.js.map +1 -1
  248. package/build-module/comment-author-name/index.js +5 -1
  249. package/build-module/comment-author-name/index.js.map +1 -1
  250. package/build-module/comment-content/index.js +5 -1
  251. package/build-module/comment-content/index.js.map +1 -1
  252. package/build-module/comment-date/index.js +1 -0
  253. package/build-module/comment-date/index.js.map +1 -1
  254. package/build-module/comment-edit-link/index.js +5 -1
  255. package/build-module/comment-edit-link/index.js.map +1 -1
  256. package/build-module/comment-reply-link/index.js +5 -1
  257. package/build-module/comment-reply-link/index.js.map +1 -1
  258. package/build-module/comment-template/index.js +14 -1
  259. package/build-module/comment-template/index.js.map +1 -1
  260. package/build-module/comments/index.js +13 -0
  261. package/build-module/comments/index.js.map +1 -1
  262. package/build-module/comments-pagination/index.js +13 -0
  263. package/build-module/comments-pagination/index.js.map +1 -1
  264. package/build-module/comments-pagination-next/index.js +4 -2
  265. package/build-module/comments-pagination-next/index.js.map +1 -1
  266. package/build-module/comments-pagination-numbers/edit.js +5 -1
  267. package/build-module/comments-pagination-numbers/edit.js.map +1 -1
  268. package/build-module/comments-pagination-numbers/index.js +14 -1
  269. package/build-module/comments-pagination-numbers/index.js.map +1 -1
  270. package/build-module/comments-pagination-previous/index.js +4 -2
  271. package/build-module/comments-pagination-previous/index.js.map +1 -1
  272. package/build-module/comments-title/deprecated.js +4 -2
  273. package/build-module/comments-title/deprecated.js.map +1 -1
  274. package/build-module/comments-title/index.js +4 -2
  275. package/build-module/comments-title/index.js.map +1 -1
  276. package/build-module/cover/deprecated.js +20 -4
  277. package/build-module/cover/deprecated.js.map +1 -1
  278. package/build-module/cover/index.js +13 -0
  279. package/build-module/cover/index.js.map +1 -1
  280. package/build-module/cover/shared.js +1 -1
  281. package/build-module/cover/shared.js.map +1 -1
  282. package/build-module/embed/icons.js +1 -1
  283. package/build-module/embed/icons.js.map +1 -1
  284. package/build-module/gallery/deprecated.js +7 -2
  285. package/build-module/gallery/deprecated.js.map +1 -1
  286. package/build-module/gallery/edit.js +15 -2
  287. package/build-module/gallery/edit.js.map +1 -1
  288. package/build-module/gallery/index.js +5 -0
  289. package/build-module/gallery/index.js.map +1 -1
  290. package/build-module/gallery/transforms.js +20 -7
  291. package/build-module/gallery/transforms.js.map +1 -1
  292. package/build-module/gallery/utils.js +7 -6
  293. package/build-module/gallery/utils.js.map +1 -1
  294. package/build-module/group/deprecated.js +109 -12
  295. package/build-module/group/deprecated.js.map +1 -1
  296. package/build-module/group/edit.js +25 -2
  297. package/build-module/group/edit.js.map +1 -1
  298. package/build-module/group/index.js +10 -2
  299. package/build-module/group/index.js.map +1 -1
  300. package/build-module/group/variations.js +8 -8
  301. package/build-module/group/variations.js.map +1 -1
  302. package/build-module/heading/deprecated.js +5 -2
  303. package/build-module/heading/deprecated.js.map +1 -1
  304. package/build-module/heading/index.js +3 -1
  305. package/build-module/heading/index.js.map +1 -1
  306. package/build-module/heading/transforms.js +3 -1
  307. package/build-module/heading/transforms.js.map +1 -1
  308. package/build-module/home-link/edit.js +10 -6
  309. package/build-module/home-link/edit.js.map +1 -1
  310. package/build-module/image/edit.js +14 -2
  311. package/build-module/image/edit.js.map +1 -1
  312. package/build-module/image/index.js +13 -7
  313. package/build-module/image/index.js.map +1 -1
  314. package/build-module/index.native.js +6 -2
  315. package/build-module/index.native.js.map +1 -1
  316. package/build-module/list-item/edit.js +4 -2
  317. package/build-module/list-item/edit.js.map +1 -1
  318. package/build-module/list-item/hooks/index.js +1 -0
  319. package/build-module/list-item/hooks/index.js.map +1 -1
  320. package/build-module/list-item/hooks/use-copy.js +32 -0
  321. package/build-module/list-item/hooks/use-copy.js.map +1 -0
  322. package/build-module/list-item/list-style-type.native.js +3 -1
  323. package/build-module/list-item/list-style-type.native.js.map +1 -1
  324. package/build-module/media-text/deprecated.js +6 -2
  325. package/build-module/media-text/deprecated.js.map +1 -1
  326. package/build-module/media-text/index.js +13 -0
  327. package/build-module/media-text/index.js.map +1 -1
  328. package/build-module/navigation/deprecated.js +7 -2
  329. package/build-module/navigation/deprecated.js.map +1 -1
  330. package/build-module/navigation/edit/index.js +120 -40
  331. package/build-module/navigation/edit/index.js.map +1 -1
  332. package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -1
  333. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  334. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +4 -7
  335. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  336. package/build-module/navigation/menu-items-to-blocks.js +1 -6
  337. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  338. package/build-module/navigation/use-navigation-menu.js +8 -7
  339. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  340. package/build-module/navigation-link/edit.js +7 -9
  341. package/build-module/navigation-link/edit.js.map +1 -1
  342. package/build-module/navigation-submenu/edit.js +5 -7
  343. package/build-module/navigation-submenu/edit.js.map +1 -1
  344. package/build-module/page-list/edit.js +7 -2
  345. package/build-module/page-list/edit.js.map +1 -1
  346. package/build-module/paragraph/deprecated.js +18 -9
  347. package/build-module/paragraph/deprecated.js.map +1 -1
  348. package/build-module/paragraph/edit.js +1 -0
  349. package/build-module/paragraph/edit.js.map +1 -1
  350. package/build-module/paragraph/index.js +5 -0
  351. package/build-module/paragraph/index.js.map +1 -1
  352. package/build-module/paragraph/transforms.js +5 -0
  353. package/build-module/paragraph/transforms.js.map +1 -1
  354. package/build-module/post-author/index.js +4 -2
  355. package/build-module/post-author/index.js.map +1 -1
  356. package/build-module/post-author-biography/index.js +1 -0
  357. package/build-module/post-author-biography/index.js.map +1 -1
  358. package/build-module/post-author-name/index.js +5 -1
  359. package/build-module/post-author-name/index.js.map +1 -1
  360. package/build-module/post-comments-count/edit.js +10 -1
  361. package/build-module/post-comments-count/edit.js.map +1 -1
  362. package/build-module/post-comments-count/index.js +4 -1
  363. package/build-module/post-comments-count/index.js.map +1 -1
  364. package/build-module/post-comments-link/index.js +4 -2
  365. package/build-module/post-comments-link/index.js.map +1 -1
  366. package/build-module/post-date/edit.js +9 -2
  367. package/build-module/post-date/edit.js.map +1 -1
  368. package/build-module/post-date/index.js +9 -0
  369. package/build-module/post-date/index.js.map +1 -1
  370. package/build-module/post-featured-image/edit.js +28 -13
  371. package/build-module/post-featured-image/edit.js.map +1 -1
  372. package/build-module/post-featured-image/index.js +12 -0
  373. package/build-module/post-featured-image/index.js.map +1 -1
  374. package/build-module/post-navigation-link/index.js +3 -2
  375. package/build-module/post-navigation-link/index.js.map +1 -1
  376. package/build-module/post-template/edit.js +8 -4
  377. package/build-module/post-template/edit.js.map +1 -1
  378. package/build-module/post-template/index.js +14 -1
  379. package/build-module/post-template/index.js.map +1 -1
  380. package/build-module/post-terms/index.js +5 -3
  381. package/build-module/post-terms/index.js.map +1 -1
  382. package/build-module/post-title/index.js +2 -1
  383. package/build-module/post-title/index.js.map +1 -1
  384. package/build-module/preformatted/index.js +4 -2
  385. package/build-module/preformatted/index.js.map +1 -1
  386. package/build-module/pullquote/deprecated.js +134 -25
  387. package/build-module/pullquote/deprecated.js.map +1 -1
  388. package/build-module/pullquote/edit.js +1 -1
  389. package/build-module/pullquote/edit.js.map +1 -1
  390. package/build-module/pullquote/edit.native.js +0 -1
  391. package/build-module/pullquote/edit.native.js.map +1 -1
  392. package/build-module/pullquote/index.js +13 -6
  393. package/build-module/pullquote/index.js.map +1 -1
  394. package/build-module/pullquote/save.js +2 -2
  395. package/build-module/pullquote/save.js.map +1 -1
  396. package/build-module/pullquote/transforms.js +15 -34
  397. package/build-module/pullquote/transforms.js.map +1 -1
  398. package/build-module/query/deprecated.js +10 -8
  399. package/build-module/query/deprecated.js.map +1 -1
  400. package/build-module/query/edit/index.js +23 -12
  401. package/build-module/query/edit/index.js.map +1 -1
  402. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +1 -0
  403. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  404. package/build-module/query/edit/query-placeholder.js +6 -1
  405. package/build-module/query/edit/query-placeholder.js.map +1 -1
  406. package/build-module/query/utils.js +32 -7
  407. package/build-module/query/utils.js.map +1 -1
  408. package/build-module/query-no-results/edit.js +1 -1
  409. package/build-module/query-no-results/edit.js.map +1 -1
  410. package/build-module/query-title/edit.js +10 -1
  411. package/build-module/query-title/edit.js.map +1 -1
  412. package/build-module/query-title/index.js +7 -2
  413. package/build-module/query-title/index.js.map +1 -1
  414. package/build-module/quote/deprecated.js +13 -5
  415. package/build-module/quote/deprecated.js.map +1 -1
  416. package/build-module/quote/transforms.js +23 -38
  417. package/build-module/quote/transforms.js.map +1 -1
  418. package/build-module/separator/deprecated.js +3 -3
  419. package/build-module/separator/deprecated.js.map +1 -1
  420. package/build-module/separator/index.js +1 -0
  421. package/build-module/separator/index.js.map +1 -1
  422. package/build-module/social-link/icons/reddit.js +1 -1
  423. package/build-module/social-link/icons/reddit.js.map +1 -1
  424. package/build-module/social-links/edit.js +2 -1
  425. package/build-module/social-links/edit.js.map +1 -1
  426. package/build-module/spacer/index.js +7 -1
  427. package/build-module/spacer/index.js.map +1 -1
  428. package/build-module/table/index.js +4 -0
  429. package/build-module/table/index.js.map +1 -1
  430. package/build-module/table/state.js +10 -4
  431. package/build-module/table/state.js.map +1 -1
  432. package/build-module/table-of-contents/index.js +11 -1
  433. package/build-module/table-of-contents/index.js.map +1 -1
  434. package/build-module/tag-cloud/index.js +5 -1
  435. package/build-module/tag-cloud/index.js.map +1 -1
  436. package/build-module/template-part/index.js +2 -2
  437. package/build-module/template-part/index.js.map +1 -1
  438. package/build-module/term-description/index.js +4 -0
  439. package/build-module/term-description/index.js.map +1 -1
  440. package/build-module/text-columns/edit.js +4 -2
  441. package/build-module/text-columns/edit.js.map +1 -1
  442. package/build-module/text-columns/save.js +4 -2
  443. package/build-module/text-columns/save.js.map +1 -1
  444. package/build-module/verse/index.js +1 -0
  445. package/build-module/verse/index.js.map +1 -1
  446. package/build-module/video/index.js +4 -0
  447. package/build-module/video/index.js.map +1 -1
  448. package/build-style/audio/style-rtl.css +3 -0
  449. package/build-style/audio/style.css +3 -0
  450. package/build-style/button/style-rtl.css +6 -6
  451. package/build-style/button/style.css +6 -6
  452. package/build-style/editor-rtl.css +105 -122
  453. package/build-style/editor.css +105 -122
  454. package/build-style/group/editor-rtl.css +27 -8
  455. package/build-style/group/editor.css +27 -8
  456. package/build-style/image/editor-rtl.css +21 -2
  457. package/build-style/image/editor.css +21 -2
  458. package/build-style/navigation/editor-rtl.css +8 -4
  459. package/build-style/navigation/editor.css +8 -4
  460. package/build-style/navigation/style-rtl.css +2 -2
  461. package/build-style/navigation/style.css +2 -2
  462. package/build-style/paragraph/editor-rtl.css +1 -1
  463. package/build-style/paragraph/editor.css +1 -1
  464. package/build-style/post-date/style-rtl.css +79 -0
  465. package/build-style/post-date/style.css +79 -0
  466. package/build-style/post-featured-image/editor-rtl.css +45 -43
  467. package/build-style/post-featured-image/editor.css +45 -43
  468. package/build-style/post-featured-image/style-rtl.css +1 -0
  469. package/build-style/post-featured-image/style.css +1 -0
  470. package/build-style/post-title/style-rtl.css +1 -0
  471. package/build-style/post-title/style.css +1 -0
  472. package/build-style/pullquote/editor-rtl.css +0 -12
  473. package/build-style/pullquote/editor.css +0 -12
  474. package/build-style/pullquote/style-rtl.css +1 -8
  475. package/build-style/pullquote/style.css +1 -8
  476. package/build-style/query-title/style-rtl.css +79 -0
  477. package/build-style/query-title/style.css +79 -0
  478. package/build-style/site-logo/editor-rtl.css +3 -52
  479. package/build-style/site-logo/editor.css +3 -52
  480. package/build-style/social-links/style-rtl.css +2 -2
  481. package/build-style/social-links/style.css +2 -2
  482. package/build-style/style-rtl.css +27 -18
  483. package/build-style/style.css +27 -18
  484. package/build-style/video/style-rtl.css +3 -0
  485. package/build-style/video/style.css +3 -0
  486. package/package.json +30 -29
  487. package/src/archives/block.json +5 -1
  488. package/src/audio/block.json +4 -0
  489. package/src/audio/style.scss +2 -0
  490. package/src/button/block.json +1 -1
  491. package/src/button/deprecated.js +21 -22
  492. package/src/button/style.scss +6 -6
  493. package/src/calendar/index.php +2 -2
  494. package/src/categories/block.json +14 -1
  495. package/src/categories/edit.js +2 -2
  496. package/src/code/block.json +4 -2
  497. package/src/column/block.json +13 -0
  498. package/src/columns/block.json +13 -0
  499. package/src/columns/deprecated.js +10 -4
  500. package/src/columns/edit.js +7 -3
  501. package/src/columns/edit.native.js +7 -3
  502. package/src/comment-author-name/block.json +5 -1
  503. package/src/comment-content/block.json +5 -1
  504. package/src/comment-date/block.json +1 -0
  505. package/src/comment-edit-link/block.json +5 -1
  506. package/src/comment-reply-link/block.json +5 -1
  507. package/src/comment-template/block.json +14 -1
  508. package/src/comments/block.json +13 -0
  509. package/src/comments/index.php +6 -5
  510. package/src/comments-pagination/block.json +13 -0
  511. package/src/comments-pagination-next/block.json +4 -2
  512. package/src/comments-pagination-numbers/block.json +14 -1
  513. package/src/comments-pagination-numbers/edit.js +12 -3
  514. package/src/comments-pagination-previous/block.json +4 -2
  515. package/src/comments-title/block.json +4 -2
  516. package/src/cover/block.json +13 -0
  517. package/src/cover/deprecated.js +11 -4
  518. package/src/cover/shared.js +2 -1
  519. package/src/embed/icons.js +1 -1
  520. package/src/gallery/block.json +5 -0
  521. package/src/gallery/deprecated.js +4 -2
  522. package/src/gallery/edit.js +22 -2
  523. package/src/gallery/transforms.js +18 -5
  524. package/src/gallery/utils.js +11 -7
  525. package/src/group/block.json +10 -2
  526. package/src/group/deprecated.js +89 -2
  527. package/src/group/edit.js +15 -2
  528. package/src/group/editor.scss +28 -3
  529. package/src/group/variations.js +4 -3
  530. package/src/heading/block.json +3 -1
  531. package/src/heading/deprecated.js +4 -2
  532. package/src/home-link/edit.js +19 -20
  533. package/src/image/block.json +13 -7
  534. package/src/image/edit.js +19 -1
  535. package/src/image/editor.scss +39 -3
  536. package/src/image/index.php +1 -1
  537. package/src/index.native.js +15 -10
  538. package/src/list-item/edit.js +2 -1
  539. package/src/list-item/hooks/index.js +1 -0
  540. package/src/list-item/hooks/use-copy.js +36 -0
  541. package/src/list-item/list-style-type.native.js +8 -1
  542. package/src/list-item/style.native.scss +4 -0
  543. package/src/media-text/block.json +13 -0
  544. package/src/media-text/deprecated.js +3 -2
  545. package/src/navigation/deprecated.js +4 -2
  546. package/src/navigation/edit/index.js +159 -81
  547. package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
  548. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +31 -37
  549. package/src/navigation/editor.scss +3 -2
  550. package/src/navigation/index.php +11 -16
  551. package/src/navigation/menu-items-to-blocks.js +3 -6
  552. package/src/navigation/style.scss +3 -2
  553. package/src/navigation/use-navigation-menu.js +11 -8
  554. package/src/navigation-link/edit.js +9 -13
  555. package/src/navigation-submenu/edit.js +9 -13
  556. package/src/page-list/edit.js +6 -2
  557. package/src/paragraph/block.json +5 -0
  558. package/src/paragraph/deprecated.js +33 -35
  559. package/src/paragraph/edit.js +1 -0
  560. package/src/paragraph/editor.scss +5 -3
  561. package/src/post-author/block.json +4 -2
  562. package/src/post-author-biography/block.json +1 -0
  563. package/src/post-author-name/block.json +5 -1
  564. package/src/post-comments-count/block.json +4 -1
  565. package/src/post-comments-count/edit.js +10 -2
  566. package/src/post-comments-link/block.json +4 -2
  567. package/src/post-date/block.json +9 -0
  568. package/src/post-date/edit.js +12 -2
  569. package/src/post-date/index.php +10 -2
  570. package/src/post-date/style.scss +4 -0
  571. package/src/post-featured-image/block.json +12 -0
  572. package/src/post-featured-image/edit.js +43 -13
  573. package/src/post-featured-image/editor.scss +44 -53
  574. package/src/post-featured-image/index.php +61 -4
  575. package/src/post-featured-image/style.scss +1 -0
  576. package/src/post-navigation-link/block.json +3 -2
  577. package/src/post-template/block.json +15 -1
  578. package/src/post-template/edit.js +6 -1
  579. package/src/post-template/index.php +7 -4
  580. package/src/post-terms/block.json +5 -3
  581. package/src/post-title/block.json +2 -1
  582. package/src/post-title/style.scss +2 -0
  583. package/src/preformatted/block.json +4 -2
  584. package/src/pullquote/block.json +11 -4
  585. package/src/pullquote/deprecated.js +490 -412
  586. package/src/pullquote/edit.js +1 -1
  587. package/src/pullquote/edit.native.js +0 -1
  588. package/src/pullquote/editor.scss +0 -16
  589. package/src/pullquote/index.js +1 -3
  590. package/src/pullquote/save.js +1 -1
  591. package/src/pullquote/style.scss +0 -11
  592. package/src/pullquote/transforms.js +17 -33
  593. package/src/query/deprecated.js +4 -9
  594. package/src/query/edit/index.js +28 -15
  595. package/src/query/edit/inspector-controls/taxonomy-controls.js +1 -1
  596. package/src/query/edit/query-placeholder.js +17 -2
  597. package/src/query/utils.js +29 -7
  598. package/src/query-no-results/edit.js +1 -1
  599. package/src/query-title/block.json +7 -2
  600. package/src/query-title/edit.js +19 -2
  601. package/src/query-title/index.php +11 -1
  602. package/src/query-title/style.scss +4 -0
  603. package/src/quote/deprecated.js +6 -5
  604. package/src/quote/transforms.js +4 -18
  605. package/src/search/index.php +1 -1
  606. package/src/separator/block.json +1 -0
  607. package/src/separator/deprecated.js +2 -3
  608. package/src/site-logo/editor.scss +8 -66
  609. package/src/social-link/icons/reddit.js +1 -1
  610. package/src/social-link/index.php +1 -1
  611. package/src/social-link/socials-with-bg.scss +1 -1
  612. package/src/social-link/socials-without-bg.scss +1 -1
  613. package/src/social-links/edit.js +1 -0
  614. package/src/spacer/block.json +7 -1
  615. package/src/style.scss +2 -0
  616. package/src/table/block.json +4 -0
  617. package/src/table/state.js +21 -19
  618. package/src/table-of-contents/block.json +11 -1
  619. package/src/tag-cloud/block.json +5 -1
  620. package/src/template-part/index.js +3 -2
  621. package/src/term-description/block.json +4 -0
  622. package/src/text-columns/edit.js +2 -2
  623. package/src/text-columns/save.js +2 -2
  624. package/src/verse/block.json +1 -0
  625. package/src/video/block.json +4 -0
  626. package/src/video/style.scss +2 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/pullquote/index.js"],"names":["name","metadata","settings","icon","example","attributes","value","citation","transforms","edit","save","deprecated"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,KAAK,EACJ,QACA;AACA,oBACC,oEADD,CAFA,GAKA,MAPU;AAQXC,MAAAA,QAAQ,EAAE,cAAI,gBAAJ;AARC;AADJ,GAFc;AAcvBC,EAAAA,UAAU,EAAVA,mBAduB;AAevBC,EAAAA,IAAI,EAAJA,aAfuB;AAgBvBC,EAAAA,IAAI,EAAJA,aAhBuB;AAiBvBC,EAAAA,UAAU,EAAVA;AAjBuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { pullquote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tvalue:\n\t\t\t\t'<p>' +\n\t\t\t\t// translators: Quote serving as example for the Pullquote block. Attributed to Matt Mullenweg.\n\t\t\t\t__(\n\t\t\t\t\t'One of the hardest things to do in technology is disrupt yourself.'\n\t\t\t\t) +\n\t\t\t\t'</p>',\n\t\t\tcitation: __( 'Matt Mullenweg' ),\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/pullquote/index.js"],"names":["name","metadata","settings","icon","example","attributes","value","citation","transforms","edit","save","deprecated"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAEA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,KAAK,EACJ;AACA,oBACC,oEADD,CAHU;AAMXC,MAAAA,QAAQ,EAAE,cAAI,gBAAJ;AANC;AADJ,GAFc;AAYvBC,EAAAA,UAAU,EAAVA,mBAZuB;AAavBC,EAAAA,IAAI,EAAJA,aAbuB;AAcvBC,EAAAA,IAAI,EAAJA,aAduB;AAevBC,EAAAA,UAAU,EAAVA;AAfuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { pullquote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tvalue:\n\t\t\t\t// translators: Quote serving as example for the Pullquote block. Attributed to Matt Mullenweg.\n\t\t\t\t__(\n\t\t\t\t\t'One of the hardest things to do in technology is disrupt yourself.'\n\t\t\t\t),\n\t\t\tcitation: __( 'Matt Mullenweg' ),\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
@@ -35,8 +35,8 @@ function save(_ref) {
35
35
  [`has-text-align-${textAlign}`]: textAlign
36
36
  })
37
37
  }), (0, _element.createElement)("blockquote", null, (0, _element.createElement)(_blockEditor.RichText.Content, {
38
- value: value,
39
- multiline: true
38
+ tagName: "p",
39
+ value: value
40
40
  }), shouldShowCitation && (0, _element.createElement)(_blockEditor.RichText.Content, {
41
41
  tagName: "cite",
42
42
  value: citation
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/pullquote/save.js"],"names":["save","attributes","textAlign","citation","value","shouldShowCitation","RichText","isEmpty","useBlockProps","className"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,IAAT,OAAgC;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AAC9C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA;AAAvB,MAAiCH,UAAvC;AACA,QAAMI,kBAAkB,GAAG,CAAEC,sBAASC,OAAT,CAAkBJ,QAAlB,CAA7B;AAEA,SACC,sCACMK,2BAAcR,IAAd,CAAoB;AACxBS,IAAAA,SAAS,EAAE,yBAAY;AACtB,OAAG,kBAAkBP,SAAW,EAAhC,GAAqCA;AADf,KAAZ;AADa,GAApB,CADN,EAOC,gDACC,4BAAC,qBAAD,CAAU,OAAV;AAAkB,IAAA,KAAK,EAAGE,KAA1B;AAAkC,IAAA,SAAS;AAA3C,IADD,EAEGC,kBAAkB,IACnB,4BAAC,qBAAD,CAAU,OAAV;AAAkB,IAAA,OAAO,EAAC,MAA1B;AAAiC,IAAA,KAAK,EAAGF;AAAzC,IAHF,CAPD,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { textAlign, citation, value } = attributes;\n\tconst shouldShowCitation = ! RichText.isEmpty( citation );\n\n\treturn (\n\t\t<figure\n\t\t\t{ ...useBlockProps.save( {\n\t\t\t\tclassName: classnames( {\n\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t} ),\n\t\t\t} ) }\n\t\t>\n\t\t\t<blockquote>\n\t\t\t\t<RichText.Content value={ value } multiline />\n\t\t\t\t{ shouldShowCitation && (\n\t\t\t\t\t<RichText.Content tagName=\"cite\" value={ citation } />\n\t\t\t\t) }\n\t\t\t</blockquote>\n\t\t</figure>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/pullquote/save.js"],"names":["save","attributes","textAlign","citation","value","shouldShowCitation","RichText","isEmpty","useBlockProps","className"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,IAAT,OAAgC;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AAC9C,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA;AAAvB,MAAiCH,UAAvC;AACA,QAAMI,kBAAkB,GAAG,CAAEC,sBAASC,OAAT,CAAkBJ,QAAlB,CAA7B;AAEA,SACC,sCACMK,2BAAcR,IAAd,CAAoB;AACxBS,IAAAA,SAAS,EAAE,yBAAY;AACtB,OAAG,kBAAkBP,SAAW,EAAhC,GAAqCA;AADf,KAAZ;AADa,GAApB,CADN,EAOC,gDACC,4BAAC,qBAAD,CAAU,OAAV;AAAkB,IAAA,OAAO,EAAC,GAA1B;AAA8B,IAAA,KAAK,EAAGE;AAAtC,IADD,EAEGC,kBAAkB,IACnB,4BAAC,qBAAD,CAAU,OAAV;AAAkB,IAAA,OAAO,EAAC,MAA1B;AAAiC,IAAA,KAAK,EAAGF;AAAzC,IAHF,CAPD,CADD;AAgBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { textAlign, citation, value } = attributes;\n\tconst shouldShowCitation = ! RichText.isEmpty( citation );\n\n\treturn (\n\t\t<figure\n\t\t\t{ ...useBlockProps.save( {\n\t\t\t\tclassName: classnames( {\n\t\t\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t\t\t} ),\n\t\t\t} ) }\n\t\t>\n\t\t\t<blockquote>\n\t\t\t\t<RichText.Content tagName=\"p\" value={ value } />\n\t\t\t\t{ shouldShowCitation && (\n\t\t\t\t\t<RichText.Content tagName=\"cite\" value={ citation } />\n\t\t\t\t) }\n\t\t\t</blockquote>\n\t\t</figure>\n\t);\n}\n"]}
@@ -27,8 +27,7 @@ const transforms = {
27
27
  return (0, _richText.create)({
28
28
  html: content
29
29
  });
30
- }), '\u2028'),
31
- multilineTag: 'p'
30
+ }), '\n')
32
31
  }),
33
32
  anchor: attributes.anchor
34
33
  });
@@ -42,7 +41,7 @@ const transforms = {
42
41
  anchor
43
42
  } = _ref2;
44
43
  return (0, _blocks.createBlock)('core/pullquote', {
45
- value: `<p>${content}</p>`,
44
+ value: content,
46
45
  anchor
47
46
  });
48
47
  }
@@ -57,18 +56,13 @@ const transforms = {
57
56
  } = _ref3;
58
57
  const paragraphs = [];
59
58
 
60
- if (value && value !== '<p></p>') {
61
- paragraphs.push(...(0, _richText.split)((0, _richText.create)({
62
- html: value,
63
- multilineTag: 'p'
64
- }), '\u2028').map(piece => (0, _blocks.createBlock)('core/paragraph', {
65
- content: (0, _richText.toHTMLString)({
66
- value: piece
67
- })
68
- })));
59
+ if (value) {
60
+ paragraphs.push((0, _blocks.createBlock)('core/paragraph', {
61
+ content: value
62
+ }));
69
63
  }
70
64
 
71
- if (citation && citation !== '<p></p>') {
65
+ if (citation) {
72
66
  paragraphs.push((0, _blocks.createBlock)('core/paragraph', {
73
67
  content: citation
74
68
  }));
@@ -88,42 +82,29 @@ const transforms = {
88
82
  transform: _ref4 => {
89
83
  let {
90
84
  value,
91
- citation,
92
- ...attrs
85
+ citation
93
86
  } = _ref4;
94
87
 
95
88
  // If there is no pullquote content, use the citation as the
96
89
  // content of the resulting heading. A nonexistent citation
97
90
  // will result in an empty heading.
98
- if (value === '<p></p>') {
91
+ if (!value) {
99
92
  return (0, _blocks.createBlock)('core/heading', {
100
93
  content: citation
101
94
  });
102
95
  }
103
96
 
104
- const pieces = (0, _richText.split)((0, _richText.create)({
105
- html: value,
106
- multilineTag: 'p'
107
- }), '\u2028');
108
97
  const headingBlock = (0, _blocks.createBlock)('core/heading', {
109
- content: (0, _richText.toHTMLString)({
110
- value: pieces[0]
111
- })
98
+ content: value
112
99
  });
113
100
 
114
- if (!citation && pieces.length === 1) {
101
+ if (!citation) {
115
102
  return headingBlock;
116
103
  }
117
104
 
118
- const quotePieces = pieces.slice(1);
119
- const pullquoteBlock = (0, _blocks.createBlock)('core/pullquote', { ...attrs,
120
- citation,
121
- value: (0, _richText.toHTMLString)({
122
- value: quotePieces.length ? (0, _richText.join)(pieces.slice(1), '\u2028') : (0, _richText.create)(),
123
- multilineTag: 'p'
124
- })
125
- });
126
- return [headingBlock, pullquoteBlock];
105
+ return [headingBlock, (0, _blocks.createBlock)('core/heading', {
106
+ content: citation
107
+ })];
127
108
  }
128
109
  }]
129
110
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/pullquote/transforms.js"],"names":["transforms","from","type","isMultiBlock","blocks","transform","attributes","value","map","content","html","multilineTag","anchor","to","citation","paragraphs","push","piece","length","attrs","pieces","headingBlock","quotePieces","slice","pullquoteBlock"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,CACL;AACCC,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,YAAY,EAAE,IAFf;AAGCC,IAAAA,MAAM,EAAE,CAAE,gBAAF,CAHT;AAICC,IAAAA,SAAS,EAAIC,UAAF,IAAkB;AAC5B,aAAO,yBAAa,gBAAb,EAA+B;AACrCC,QAAAA,KAAK,EAAE,4BAAc;AACpBA,UAAAA,KAAK,EAAE,oBACND,UAAU,CAACE,GAAX,CAAgB;AAAA,gBAAE;AAAEC,cAAAA;AAAF,aAAF;AAAA,mBACf,sBAAQ;AAAEC,cAAAA,IAAI,EAAED;AAAR,aAAR,CADe;AAAA,WAAhB,CADM,EAIN,QAJM,CADa;AAOpBE,UAAAA,YAAY,EAAE;AAPM,SAAd,CAD8B;AAUrCC,QAAAA,MAAM,EAAEN,UAAU,CAACM;AAVkB,OAA/B,CAAP;AAYA;AAjBF,GADK,EAoBL;AACCV,IAAAA,IAAI,EAAE,OADP;AAECE,IAAAA,MAAM,EAAE,CAAE,cAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,SAA2B;AAAA,UAAzB;AAAEI,QAAAA,OAAF;AAAWG,QAAAA;AAAX,OAAyB;AACrC,aAAO,yBAAa,gBAAb,EAA+B;AACrCL,QAAAA,KAAK,EAAG,MAAME,OAAS,MADc;AAErCG,QAAAA;AAFqC,OAA/B,CAAP;AAIA;AARF,GApBK,C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CE,UAAAA,OAAO,EAAEK;AAD0B,SAA7B,CAAP;AAGA;;AACD,YAAMM,MAAM,GAAG,qBACd,sBAAQ;AAAEV,QAAAA,IAAI,EAAEH,KAAR;AAAeI,QAAAA,YAAY,EAAE;AAA7B,OAAR,CADc,EAEd,QAFc,CAAf;AAIA,YAAMU,YAAY,GAAG,yBAAa,cAAb,EAA6B;AACjDZ,QAAAA,OAAO,EAAE,4BAAc;AAAEF,UAAAA,KAAK,EAAEa,MAAM,CAAE,CAAF;AAAf,SAAd;AADwC,OAA7B,CAArB;;AAGA,UAAK,CAAEN,QAAF,IAAcM,MAAM,CAACF,MAAP,KAAkB,CAArC,EAAyC;AACxC,eAAOG,YAAP;AACA;;AACD,YAAMC,WAAW,GAAGF,MAAM,CAACG,KAAP,CAAc,CAAd,CAApB;AACA,YAAMC,cAAc,GAAG,yBAAa,gBAAb,EAA+B,EACrD,GAAGL,KADkD;AAErDL,QAAAA,QAFqD;AAGrDP,QAAAA,KAAK,EAAE,4BAAc;AACpBA,UAAAA,KAAK,EAAEe,WAAW,CAACJ,MAAZ,GACJ,oBAAME,MAAM,CAACG,KAAP,CAAc,CAAd,CAAN,EAAyB,QAAzB,CADI,GAEJ,uBAHiB;AAIpBZ,UAAAA,YAAY,EAAE;AAJM,SAAd;AAH8C,OAA/B,CAAvB;AAUA,aAAO,CAAEU,YAAF,EAAgBG,cAAhB,CAAP;AACA;AAlCF,GAjCG;AAhCc,CAAnB;eAwGexB,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, join, split, toHTMLString } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: toHTMLString( {\n\t\t\t\t\t\tvalue: join(\n\t\t\t\t\t\t\tattributes.map( ( { content } ) =>\n\t\t\t\t\t\t\t\tcreate( { html: content } )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t'\\u2028'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmultilineTag: 'p',\n\t\t\t\t\t} ),\n\t\t\t\t\tanchor: attributes.anchor,\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/heading' ],\n\t\t\ttransform: ( { content, anchor } ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: `<p>${ content }</p>`,\n\t\t\t\t\tanchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\tconst paragraphs = [];\n\t\t\t\tif ( value && value !== '<p></p>' ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\t...split(\n\t\t\t\t\t\t\tcreate( { html: value, multilineTag: 'p' } ),\n\t\t\t\t\t\t\t'\\u2028'\n\t\t\t\t\t\t).map( ( piece ) =>\n\t\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\t\tcontent: toHTMLString( { value: piece } ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( citation && citation !== '<p></p>' ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( paragraphs.length === 0 ) {\n\t\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn paragraphs;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { value, citation, ...attrs } ) => {\n\t\t\t\t// If there is no pullquote content, use the citation as the\n\t\t\t\t// content of the resulting heading. A nonexistent citation\n\t\t\t\t// will result in an empty heading.\n\t\t\t\tif ( value === '<p></p>' ) {\n\t\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tconst pieces = split(\n\t\t\t\t\tcreate( { html: value, multilineTag: 'p' } ),\n\t\t\t\t\t'\\u2028'\n\t\t\t\t);\n\t\t\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\t\t\tcontent: toHTMLString( { value: pieces[ 0 ] } ),\n\t\t\t\t} );\n\t\t\t\tif ( ! citation && pieces.length === 1 ) {\n\t\t\t\t\treturn headingBlock;\n\t\t\t\t}\n\t\t\t\tconst quotePieces = pieces.slice( 1 );\n\t\t\t\tconst pullquoteBlock = createBlock( 'core/pullquote', {\n\t\t\t\t\t...attrs,\n\t\t\t\t\tcitation,\n\t\t\t\t\tvalue: toHTMLString( {\n\t\t\t\t\t\tvalue: quotePieces.length\n\t\t\t\t\t\t\t? join( pieces.slice( 1 ), '\\u2028' )\n\t\t\t\t\t\t\t: create(),\n\t\t\t\t\t\tmultilineTag: 'p',\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\treturn [ headingBlock, pullquoteBlock ];\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/pullquote/transforms.js"],"names":["transforms","from","type","isMultiBlock","blocks","transform","attributes","value","map","content","html","anchor","to","citation","paragraphs","push","length","headingBlock"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,CACL;AACCC,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,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OAAO,EAAEI;AADqB,SAA/B,CADD;AAKA;;AACD,UAAKC,UAAU,CAACE,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,eAAO,yBAAa,gBAAb,EAA+B;AACrCP,UAAAA,OAAO,EAAE;AAD4B,SAA/B,CAAP;AAGA;;AACD,aAAOK,UAAP;AACA;AAzBF,GADG,EA4BH;AACCZ,IAAAA,IAAI,EAAE,OADP;AAECE,IAAAA,MAAM,EAAE,CAAE,cAAF,CAFT;AAGCC,IAAAA,SAAS,EAAE,SAA2B;AAAA,UAAzB;AAAEE,QAAAA,KAAF;AAASM,QAAAA;AAAT,OAAyB;;AACrC;AACA;AACA;AACA,UAAK,CAAEN,KAAP,EAAe;AACd,eAAO,yBAAa,cAAb,EAA6B;AACnCE,UAAAA,OAAO,EAAEI;AAD0B,SAA7B,CAAP;AAGA;;AACD,YAAMI,YAAY,GAAG,yBAAa,cAAb,EAA6B;AACjDR,QAAAA,OAAO,EAAEF;AADwC,OAA7B,CAArB;;AAGA,UAAK,CAAEM,QAAP,EAAkB;AACjB,eAAOI,YAAP;AACA;;AACD,aAAO,CACNA,YADM,EAEN,yBAAa,cAAb,EAA6B;AAC5BR,QAAAA,OAAO,EAAEI;AADmB,OAA7B,CAFM,CAAP;AAMA;AAxBF,GA5BG;AA/Bc,CAAnB;eAwFeb,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, join, toHTMLString } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: toHTMLString( {\n\t\t\t\t\t\tvalue: join(\n\t\t\t\t\t\t\tattributes.map( ( { content } ) =>\n\t\t\t\t\t\t\t\tcreate( { html: content } )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t'\\n'\n\t\t\t\t\t\t),\n\t\t\t\t\t} ),\n\t\t\t\t\tanchor: attributes.anchor,\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/heading' ],\n\t\t\ttransform: ( { content, anchor } ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: content,\n\t\t\t\t\tanchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\tconst paragraphs = [];\n\t\t\t\tif ( value ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( citation ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( paragraphs.length === 0 ) {\n\t\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn paragraphs;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\t// If there is no pullquote content, use the citation as the\n\t\t\t\t// content of the resulting heading. A nonexistent citation\n\t\t\t\t// will result in an empty heading.\n\t\t\t\tif ( ! value ) {\n\t\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t} );\n\t\t\t\tif ( ! citation ) {\n\t\t\t\t\treturn headingBlock;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\theadingBlock,\n\t\t\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
@@ -7,14 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _blockEditor = require("@wordpress/block-editor");
13
11
 
14
- /**
15
- * External dependencies
16
- */
17
-
18
12
  /**
19
13
  * WordPress dependencies
20
14
  */
@@ -24,8 +18,11 @@ const migrateToTaxQuery = attributes => {
24
18
  const {
25
19
  query
26
20
  } = attributes;
27
- const newQuery = { ...(0, _lodash.omit)(query, ['categoryIds', 'tagIds'])
28
- };
21
+ const {
22
+ categoryIds,
23
+ tagIds,
24
+ ...newQuery
25
+ } = query;
29
26
 
30
27
  if ((_query$categoryIds = query.categoryIds) !== null && _query$categoryIds !== void 0 && _query$categoryIds.length || (_query$tagIds = query.tagIds) !== null && _query$tagIds !== void 0 && _query$tagIds.length) {
31
28
  var _query$categoryIds2, _query$tagIds2;
@@ -147,7 +144,11 @@ const deprecated = [// Version with `categoryIds and tagIds`.
147
144
 
148
145
  migrate(attributes) {
149
146
  const withTaxQuery = migrateToTaxQuery(attributes);
150
- return { ...(0, _lodash.omit)(withTaxQuery, ['layout']),
147
+ const {
148
+ layout,
149
+ ...restWithTaxQuery
150
+ } = withTaxQuery;
151
+ return { ...restWithTaxQuery,
151
152
  displayLayout: withTaxQuery.layout
152
153
  };
153
154
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/deprecated.js"],"names":["migrateToTaxQuery","attributes","query","newQuery","categoryIds","length","tagIds","taxQuery","category","undefined","post_tag","deprecated","queryId","type","default","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","tagName","displayLayout","supports","align","html","color","gradients","link","__experimentalLayout","isEligible","migrate","save","Tag","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","layout","withTaxQuery"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAOA,MAAMA,iBAAiB,GAAKC,UAAF,IAAkB;AAAA;;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAYD,UAAlB;AACA,QAAME,QAAQ,GAAG,EAChB,GAAG,kBAAMD,KAAN,EAAa,CAAE,aAAF,EAAiB,QAAjB,CAAb;AADa,GAAjB;;AAGA,MAAK,sBAAAA,KAAK,CAACE,WAAN,kEAAmBC,MAAnB,qBAA6BH,KAAK,CAACI,MAAnC,0CAA6B,cAAcD,MAAhD,EAAyD;AAAA;;AACxDF,IAAAA,QAAQ,CAACI,QAAT,GAAoB;AACnBC,MAAAA,QAAQ,EAAE,CAAC,yBAAEN,KAAK,CAACE,WAAR,gDAAE,oBAAmBC,MAArB,CAAD,GACPH,KAAK,CAACE,WADC,GAEPK,SAHgB;AAInBC,MAAAA,QAAQ,EAAE,CAAC,oBAAER,KAAK,CAACI,MAAR,2CAAE,eAAcD,MAAhB,CAAD,GAA0BH,KAAK,CAACI,MAAhC,GAAyCG;AAJhC,KAApB;AAMA;;AACD,SAAO,EACN,GAAGR,UADG;AAENC,IAAAA,KAAK,EAAEC;AAFD,GAAP;AAIA,CAjBD;;AAmBA,MAAMQ,UAAU,GAAG,CAClB;AACA;AACCV,EAAAA,UAAU,EAAE;AACXW,IAAAA,OAAO,EAAE;AACRC,MAAAA,IAAI,EAAE;AADE,KADE;AAIXX,IAAAA,KAAK,EAAE;AACNW,MAAAA,IAAI,EAAE,QADA;AAENC,MAAAA,OAAO,EAAE;AACRC,QAAAA,OAAO,EAAE,IADD;AAERC,QAAAA,KAAK,EAAE,CAFC;AAGRC,QAAAA,MAAM,EAAE,CAHA;AAIRC,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vDkB,CAAnB;eAqGe1B,U","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nconst migrateToTaxQuery = ( attributes ) => {\n\tconst { query } = attributes;\n\tconst newQuery = {\n\t\t...omit( query, [ 'categoryIds', 'tagIds' ] ),\n\t};\n\tif ( query.categoryIds?.length || query.tagIds?.length ) {\n\t\tnewQuery.taxQuery = {\n\t\t\tcategory: !! query.categoryIds?.length\n\t\t\t\t? query.categoryIds\n\t\t\t\t: undefined,\n\t\t\tpost_tag: !! query.tagIds?.length ? query.tagIds : undefined,\n\t\t};\n\t}\n\treturn {\n\t\t...attributes,\n\t\tquery: newQuery,\n\t};\n};\n\nconst deprecated = [\n\t// Version with `categoryIds and tagIds`.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttagName: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'div',\n\t\t\t},\n\t\t\tdisplayLayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\talign: [ 'wide', 'full' ],\n\t\t\thtml: false,\n\t\t\tcolor: {\n\t\t\t\tgradients: true,\n\t\t\t\tlink: true,\n\t\t\t},\n\t\t\t__experimentalLayout: true,\n\t\t},\n\t\tisEligible: ( { query: { categoryIds, tagIds } = {} } ) =>\n\t\t\tcategoryIds || tagIds,\n\t\tmigrate: migrateToTaxQuery,\n\t\tsave( { attributes: { tagName: Tag = 'div' } } ) {\n\t\t\tconst blockProps = useBlockProps.save();\n\t\t\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\t\t\treturn <Tag { ...innerBlocksProps } />;\n\t\t},\n\t},\n\t// Version with NO wrapper `div` element.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\thtml: false,\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\tconst withTaxQuery = migrateToTaxQuery( attributes );\n\t\t\treturn {\n\t\t\t\t...omit( withTaxQuery, [ 'layout' ] ),\n\t\t\t\tdisplayLayout: withTaxQuery.layout,\n\t\t\t};\n\t\t},\n\t\tsave() {\n\t\t\treturn <InnerBlocks.Content />;\n\t\t},\n\t},\n];\n\nexport default deprecated;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/deprecated.js"],"names":["migrateToTaxQuery","attributes","query","categoryIds","tagIds","newQuery","length","taxQuery","category","undefined","post_tag","deprecated","queryId","type","default","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","tagName","displayLayout","supports","align","html","color","gradients","link","__experimentalLayout","isEligible","migrate","save","Tag","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","layout","withTaxQuery","restWithTaxQuery"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAOA,MAAMA,iBAAiB,GAAKC,UAAF,IAAkB;AAAA;;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAYD,UAAlB;AACA,QAAM;AAAEE,IAAAA,WAAF;AAAeC,IAAAA,MAAf;AAAuB,OAAGC;AAA1B,MAAuCH,KAA7C;;AAEA,MAAK,sBAAAA,KAAK,CAACC,WAAN,kEAAmBG,MAAnB,qBAA6BJ,KAAK,CAACE,MAAnC,0CAA6B,cAAcE,MAAhD,EAAyD;AAAA;;AACxDD,IAAAA,QAAQ,CAACE,QAAT,GAAoB;AACnBC,MAAAA,QAAQ,EAAE,CAAC,yBAAEN,KAAK,CAACC,WAAR,gDAAE,oBAAmBG,MAArB,CAAD,GACPJ,KAAK,CAACC,WADC,GAEPM,SAHgB;AAInBC,MAAAA,QAAQ,EAAE,CAAC,oBAAER,KAAK,CAACE,MAAR,2CAAE,eAAcE,MAAhB,CAAD,GAA0BJ,KAAK,CAACE,MAAhC,GAAyCK;AAJhC,KAApB;AAMA;;AACD,SAAO,EACN,GAAGR,UADG;AAENC,IAAAA,KAAK,EAAEG;AAFD,GAAP;AAIA,CAhBD;;AAkBA,MAAMM,UAAU,GAAG,CAClB;AACA;AACCV,EAAAA,UAAU,EAAE;AACXW,IAAAA,OAAO,EAAE;AACRC,MAAAA,IAAI,EAAE;AADE,KADE;AAIXX,IAAAA,KAAK,EAAE;AACNW,MAAAA,IAAI,EAAE,QADA;AAENC,MAAAA,OAAO,EAAE;AACRC,QAAAA,OAAO,EAAE,IAD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;AAIA,GAxCF;;AAyCCN,EAAAA,IAAI,GAAG;AACN,WAAO,4BAAC,wBAAD,CAAa,OAAb,OAAP;AACA;;AA3CF,CAvDkB,CAAnB;eAsGe1B,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nconst migrateToTaxQuery = ( attributes ) => {\n\tconst { query } = attributes;\n\tconst { categoryIds, tagIds, ...newQuery } = query;\n\n\tif ( query.categoryIds?.length || query.tagIds?.length ) {\n\t\tnewQuery.taxQuery = {\n\t\t\tcategory: !! query.categoryIds?.length\n\t\t\t\t? query.categoryIds\n\t\t\t\t: undefined,\n\t\t\tpost_tag: !! query.tagIds?.length ? query.tagIds : undefined,\n\t\t};\n\t}\n\treturn {\n\t\t...attributes,\n\t\tquery: newQuery,\n\t};\n};\n\nconst deprecated = [\n\t// Version with `categoryIds and tagIds`.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttagName: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'div',\n\t\t\t},\n\t\t\tdisplayLayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\talign: [ 'wide', 'full' ],\n\t\t\thtml: false,\n\t\t\tcolor: {\n\t\t\t\tgradients: true,\n\t\t\t\tlink: true,\n\t\t\t},\n\t\t\t__experimentalLayout: true,\n\t\t},\n\t\tisEligible: ( { query: { categoryIds, tagIds } = {} } ) =>\n\t\t\tcategoryIds || tagIds,\n\t\tmigrate: migrateToTaxQuery,\n\t\tsave( { attributes: { tagName: Tag = 'div' } } ) {\n\t\t\tconst blockProps = useBlockProps.save();\n\t\t\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\t\t\treturn <Tag { ...innerBlocksProps } />;\n\t\t},\n\t},\n\t// Version with NO wrapper `div` element.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\thtml: false,\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\tconst withTaxQuery = migrateToTaxQuery( attributes );\n\t\t\tconst { layout, ...restWithTaxQuery } = withTaxQuery;\n\t\t\treturn {\n\t\t\t\t...restWithTaxQuery,\n\t\t\t\tdisplayLayout: withTaxQuery.layout,\n\t\t\t};\n\t\t},\n\t\tsave() {\n\t\t\treturn <InnerBlocks.Content />;\n\t\t},\n\t},\n];\n\nexport default deprecated;\n"]}
@@ -211,6 +211,7 @@ function QueryPatternSetup(_ref2) {
211
211
  return (0, _element.createElement)(_queryPlaceholder.default, {
212
212
  clientId: clientId,
213
213
  name: name,
214
+ attributes: attributes,
214
215
  setAttributes: setAttributes,
215
216
  icon: icon,
216
217
  label: label
@@ -235,7 +236,8 @@ function QueryPatternSetup(_ref2) {
235
236
  const QueryEdit = props => {
236
237
  const {
237
238
  clientId,
238
- name
239
+ name,
240
+ attributes
239
241
  } = props;
240
242
  const [isPatternSelectionModalOpen, setIsPatternSelectionModalOpen] = (0, _element.useState)(false);
241
243
  const {
@@ -246,15 +248,22 @@ const QueryEdit = props => {
246
248
  const Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;
247
249
 
248
250
  const onBlockPatternSelect = blocks => {
249
- const clonedBlocks = blocks.map(block => (0, _blocks.cloneBlock)(block));
250
- const firstQueryClientId = (0, _utils.getFirstQueryClientIdFromBlocks)(clonedBlocks);
251
- replaceBlock(clientId, clonedBlocks);
251
+ const {
252
+ newBlocks,
253
+ queryClientIds
254
+ } = (0, _utils.getTransformedBlocksFromPattern)(blocks, attributes);
255
+ replaceBlock(clientId, newBlocks);
252
256
 
253
- if (firstQueryClientId) {
254
- selectBlock(firstQueryClientId);
257
+ if (queryClientIds[0]) {
258
+ selectBlock(queryClientIds[0]);
255
259
  }
256
- };
260
+ }; // When we preview Query Loop blocks we should prefer the current
261
+ // block's postType, which is passed through block context.
262
+
257
263
 
264
+ const blockPreviewContext = (0, _element.useMemo)(() => ({
265
+ previewPostType: attributes.query.postType
266
+ }), [attributes.query.postType]);
258
267
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(Component, (0, _extends2.default)({}, props, {
259
268
  openPatternSelectionModal: () => setIsPatternSelectionModalOpen(true)
260
269
  })), isPatternSelectionModalOpen && (0, _element.createElement)(_components.Modal, {
@@ -262,11 +271,13 @@ const QueryEdit = props => {
262
271
  title: (0, _i18n.__)('Choose a pattern'),
263
272
  closeLabel: (0, _i18n.__)('Cancel'),
264
273
  onRequestClose: () => setIsPatternSelectionModalOpen(false)
274
+ }, (0, _element.createElement)(_blockEditor.BlockContextProvider, {
275
+ value: blockPreviewContext
265
276
  }, (0, _element.createElement)(_blockEditor.__experimentalBlockPatternSetup, {
266
277
  blockName: name,
267
278
  clientId: clientId,
268
279
  onBlockPatternSelect: onBlockPatternSelect
269
- })));
280
+ }))));
270
281
  };
271
282
 
272
283
  var _default = QueryEdit;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/index.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","inherit","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value","QueryPatternSetup","isStartingBlank","setIsStartingBlank","blockType","allVariations","hasPatterns","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","matchingVariation","icon","src","title","QueryEdit","props","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","replaceBlock","selectBlock","hasInnerBlocks","getBlocks","Component","onBlockPatternSelect","blocks","clonedBlocks","map","block","firstQueryClientId"],"mappings":";;;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAEA;;AAUA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAuBA;AACA;AACA;AAOA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACO,SAASC,YAAT,OAMH;AAAA,MAN0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,aAF6B;AAG7BC,IAAAA,yBAH6B;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BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,cAAI,QAAJ,CAHd;AAIC,IAAA,cAAc,EAAG,MAChBC,8BAA8B,CAAE,KAAF;AALhC,KAQC,4BAAC,4CAAD;AACC,IAAA,SAAS,EAAGxD,IADb;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,oBAAoB,EAAG6D;AAHxB,IARD,CARF,CADD;AA0BA,CA9CD;;eAgDeT,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore, cloneBlock } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n\t__experimentalBlockPatternSetup as BlockPatternSetup,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tSelectControl,\n\tPlaceholder,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport QueryPlaceholder from './query-placeholder';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\nimport { getFirstQueryClientIdFromBlocks } from '../utils';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nfunction QueryPatternSetup( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon = matchingVariation?.icon || blockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryPlaceholder\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, name } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst { replaceBlock, selectBlock } = useDispatch( blockEditorStore );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;\n\tconst onBlockPatternSelect = ( blocks ) => {\n\t\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\t\tconst firstQueryClientId =\n\t\t\tgetFirstQueryClientIdFromBlocks( clonedBlocks );\n\t\treplaceBlock( clientId, clonedBlocks );\n\t\tif ( firstQueryClientId ) {\n\t\t\tselectBlock( firstQueryClientId );\n\t\t}\n\t};\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-query-pattern__selection-modal\"\n\t\t\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternSetup\n\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tonBlockPatternSelect={ onBlockPatternSelect }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/index.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","inherit","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value","QueryPatternSetup","isStartingBlank","setIsStartingBlank","blockType","allVariations","hasPatterns","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","matchingVariation","icon","src","title","QueryEdit","props","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","replaceBlock","selectBlock","hasInnerBlocks","getBlocks","Component","onBlockPatternSelect","blocks","newBlocks","queryClientIds","blockPreviewContext","previewPostType","postType"],"mappings":";;;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAEA;;AAWA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAwBA;AACA;AACA;AAOA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACO,SAASC,YAAT,OAMH;AAAA,MAN0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,aAF6B;AAG7BC,IAAAA,yBAH6B;AAI7BC,IAAAA,IAJ6B;AAK7BC,IAAAA;AAL6B,GAM1B;AACH,QAAM;AACLC,IAAAA,OADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAJd;AAKLC,IAAAA,MAAM,GAAG;AALJ,MAMFV,UANJ;AAOA,QAAM;AAAEW,IAAAA;AAAF,MACL,uBAAaC,kBAAb,CADD;AAEA,QAAMC,UAAU,GAAG,4BAAed,YAAf,CAAnB;AACA,QAAM;AAAEe,IAAAA;AAAF,MAA0B,qBAAaC,MAAF,IAAc;AAAA;;AACxD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,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B,CAAE,KAAF;AALhC,KAQC,4BAAC,iCAAD;AAAsB,IAAA,KAAK,EAAGU;AAA9B,KACC,4BAAC,4CAAD;AACC,IAAA,SAAS,EAAGlE,IADb;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,oBAAoB,EAAG6D;AAHxB,IADD,CARD,CARF,CADD;AA4BA,CAzDD;;eA2DeT,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n\t__experimentalBlockPatternSetup as BlockPatternSetup,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tSelectControl,\n\tPlaceholder,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport QueryPlaceholder from './query-placeholder';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\nimport { getTransformedBlocksFromPattern } from '../utils';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nfunction QueryPatternSetup( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon = matchingVariation?.icon || blockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryPlaceholder\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, name, attributes } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst { replaceBlock, selectBlock } = useDispatch( blockEditorStore );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;\n\tconst onBlockPatternSelect = ( blocks ) => {\n\t\tconst { newBlocks, queryClientIds } = getTransformedBlocksFromPattern(\n\t\t\tblocks,\n\t\t\tattributes\n\t\t);\n\t\treplaceBlock( clientId, newBlocks );\n\t\tif ( queryClientIds[ 0 ] ) {\n\t\t\tselectBlock( queryClientIds[ 0 ] );\n\t\t}\n\t};\n\t// When we preview Query Loop blocks we should prefer the current\n\t// block's postType, which is passed through block context.\n\tconst blockPreviewContext = useMemo(\n\t\t() => ( {\n\t\t\tpreviewPostType: attributes.query.postType,\n\t\t} ),\n\t\t[ attributes.query.postType ]\n\t);\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-query-pattern__selection-modal\"\n\t\t\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ blockPreviewContext }>\n\t\t\t\t\t\t<BlockPatternSetup\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tonBlockPatternSelect={ onBlockPatternSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"]}
@@ -58,6 +58,7 @@ const useTaxonomiesInfo = postType => {
58
58
  getEntityRecords
59
59
  } = select(_coreData.store);
60
60
  const termsQuery = {
61
+ context: 'view',
61
62
  per_page: _constants.MAX_FETCHED_TERMS
62
63
  };
63
64
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,iBAAF,EAAqBC,SAArB,KAAoC;AAAA;;AAChE;AACA,QAAMC,MAAM,GAAG,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,+BAAiBH,iBAAiB,CAAEC,SAAF,CAAlC,0DAAiB,sBAAgCE,EAAjD,CAAf;AACA,MAAKD,MAAL,EAAc,OAAOA,MAAP;AACd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAME,cAAc,GAAGH,SAAS,CAACI,iBAAV,EAAvB;;AACA,OAAM,MAAMC,IAAZ,IAAoBN,iBAApB,EAAwC;AACvC,QAAKM,IAAI,CAACD,iBAAL,OAA6BD,cAAlC,EAAmD;AAClD,aAAOJ,iBAAiB,CAAEM,IAAF,CAAjB,CAA0BH,EAAjC;AACA;AACD;AACD,CAnBD;;AAqBO,MAAMI,iBA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AAA,QAA3B;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcE,MAAAA;AAAd,KAA2B;;AAChD,QAAK,EAAEA,KAAF,aAAEA,KAAF,+BAAEA,KAAK,CAAEwB,KAAT,yCAAE,aAAcD,MAAhB,CAAL,EAA8B;AAC7B,aAAO,IAAP;AACA;;AACD,WACC;AACC,MAAA,GAAG,EAAG1B,IADP;AAEC,MAAA,SAAS,EAAC;AAFX,OAIC,4BAAC,0BAAD;AACC,MAAA,KAAK,EAAGC,IADT;AAEC,MAAA,KAAK,EAAGqB,wBAAwB,CAAEtB,IAAF,CAFjC;AAGC,MAAA,WAAW,EAAGG,KAAK,CAACwB,KAHrB;AAIC,MAAA,QAAQ,EAAGpB,aAAa,CAAEP,IAAF;AAJzB,MAJD,CADD;AAaA,GAjBD,CAFF,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( termsMappedByName, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId = termValue?.id || termsMappedByName[ termValue ]?.id;\n\tif ( termId ) return termId;\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\tfor ( const term in termsMappedByName ) {\n\t\tif ( term.toLocaleLowerCase() === termValueLower ) {\n\t\t\treturn termsMappedByName[ term ].id;\n\t\t}\n\t}\n};\n\nexport const useTaxonomiesInfo = ( postType ) => {\n\tconst taxonomies = useTaxonomies( postType );\n\tconst taxonomiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst termsQuery = { per_page: MAX_FETCHED_TERMS };\n\t\t\tconst _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => {\n\t\t\t\tconst _terms = getEntityRecords( 'taxonomy', slug, termsQuery );\n\t\t\t\treturn {\n\t\t\t\t\tslug,\n\t\t\t\t\tname,\n\t\t\t\t\tterms: getEntitiesInfo( _terms ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn _taxonomiesInfo;\n\t\t},\n\t\t[ taxonomies ]\n\t);\n\treturn taxonomiesInfo;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst taxonomiesInfo = useTaxonomiesInfo( query.postType );\n\tconst onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return;\n\t\tconst termIds = Array.from(\n\t\t\tnewTermValues.reduce( ( accumulator, termValue ) => {\n\t\t\t\tconst termId = getTermIdByTermValue(\n\t\t\t\t\ttaxonomyInfo.terms.mapByName,\n\t\t\t\t\ttermValue\n\t\t\t\t);\n\t\t\t\tif ( termId ) accumulator.add( termId );\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tconst newTaxQuery = {\n\t\t\t...query.taxQuery,\n\t\t\t[ taxonomySlug ]: termIds,\n\t\t};\n\t\tonChange( { taxQuery: newTaxQuery } );\n\t};\n\t// Returns only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst getExistingTaxQueryValue = ( taxonomySlug ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return [];\n\t\treturn ( query.taxQuery?.[ taxonomySlug ] || [] ).reduce(\n\t\t\t( accumulator, termId ) => {\n\t\t\t\tconst term = taxonomyInfo.terms.mapById[ termId ];\n\t\t\t\tif ( term ) {\n\t\t\t\t\taccumulator.push( {\n\t\t\t\t\t\tid: termId,\n\t\t\t\t\t\tvalue: term.name,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t};\n\treturn (\n\t\t<>\n\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\ttaxonomiesInfo.map( ( { slug, name, terms } ) => {\n\t\t\t\t\tif ( ! terms?.names?.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\tclassName=\"block-library-query-inspector__taxonomy-control\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\t\tlabel={ name }\n\t\t\t\t\t\t\t\tvalue={ getExistingTaxQueryValue( slug ) }\n\t\t\t\t\t\t\t\tsuggestions={ terms.names }\n\t\t\t\t\t\t\t\tonChange={ onTermsChange( slug ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","context","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,iBAAF,EAAqBC,SAArB,KAAoC;AAAA;;AAChE;AACA,QAAMC,MAAM,GAAG,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,+BAAiBH,iBAAiB,CAAEC,SAAF,CAAlC,0DAAiB,sBAAgCE,EAAjD,CAAf;AACA,MAAKD,MAAL,EAAc,OAAOA,MAAP;AACd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAME,cAAc,GAAGH,SAAS,CAACI,iBAAV,EAAvB;;AACA,OAAM,MAAMC,IAAZ,IAAoBN,iBAApB,EAAwC;AACvC,QAAKM,IAAI,CAACD,iBAAL,OAA6BD,cAAlC,EAAmD;AAClD,aAAOJ,iBAAiB,CAAEM,IAAF,CAAjB,CAA0BH,EAAjC;AACA;AACD;AACD,CAnBD;;AAqBO,MAAMI,iBAAiB,GAAKC,QAAF,IAAgB;AAChD,QAAMC,UAAU,GAAG,0BAAeD,QAAf,CAAnB;AACA,QAAME,cAAc,GAAG,qBACpBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,UAAMC,UAAU,GAAG;AAAEC,MAAAA,OAAO,EAAE,MAAX;AAAmBC,MAAAA,QAAQ,EAAEC;AAA7B,KAAnB;;AACA,UAAMC,eAAe,GAAGT,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEU,GAAZ,CAAiB,QAAsB;AAAA,UAApB;AAAEC,QAAAA,IAAF;AAAQC,QAAAA;AAAR,OAAoB;;AAC9D,YAAMC,MAAM,GAAGV,gBAAgB,CAAE,UAAF,EAAcQ,IAAd,E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Aa,CAAEP,IAAF;AAJzB,MAJD,CADD;AAaA,GAjBD,CAFF,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( termsMappedByName, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId = termValue?.id || termsMappedByName[ termValue ]?.id;\n\tif ( termId ) return termId;\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\tfor ( const term in termsMappedByName ) {\n\t\tif ( term.toLocaleLowerCase() === termValueLower ) {\n\t\t\treturn termsMappedByName[ term ].id;\n\t\t}\n\t}\n};\n\nexport const useTaxonomiesInfo = ( postType ) => {\n\tconst taxonomies = useTaxonomies( postType );\n\tconst taxonomiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst termsQuery = { context: 'view', per_page: MAX_FETCHED_TERMS };\n\t\t\tconst _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => {\n\t\t\t\tconst _terms = getEntityRecords( 'taxonomy', slug, termsQuery );\n\t\t\t\treturn {\n\t\t\t\t\tslug,\n\t\t\t\t\tname,\n\t\t\t\t\tterms: getEntitiesInfo( _terms ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn _taxonomiesInfo;\n\t\t},\n\t\t[ taxonomies ]\n\t);\n\treturn taxonomiesInfo;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst taxonomiesInfo = useTaxonomiesInfo( query.postType );\n\tconst onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return;\n\t\tconst termIds = Array.from(\n\t\t\tnewTermValues.reduce( ( accumulator, termValue ) => {\n\t\t\t\tconst termId = getTermIdByTermValue(\n\t\t\t\t\ttaxonomyInfo.terms.mapByName,\n\t\t\t\t\ttermValue\n\t\t\t\t);\n\t\t\t\tif ( termId ) accumulator.add( termId );\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tconst newTaxQuery = {\n\t\t\t...query.taxQuery,\n\t\t\t[ taxonomySlug ]: termIds,\n\t\t};\n\t\tonChange( { taxQuery: newTaxQuery } );\n\t};\n\t// Returns only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst getExistingTaxQueryValue = ( taxonomySlug ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return [];\n\t\treturn ( query.taxQuery?.[ taxonomySlug ] || [] ).reduce(\n\t\t\t( accumulator, termId ) => {\n\t\t\t\tconst term = taxonomyInfo.terms.mapById[ termId ];\n\t\t\t\tif ( term ) {\n\t\t\t\t\taccumulator.push( {\n\t\t\t\t\t\tid: termId,\n\t\t\t\t\t\tvalue: term.name,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t};\n\treturn (\n\t\t<>\n\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\ttaxonomiesInfo.map( ( { slug, name, terms } ) => {\n\t\t\t\t\tif ( ! terms?.names?.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\tclassName=\"block-library-query-inspector__taxonomy-control\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\t\tlabel={ name }\n\t\t\t\t\t\t\t\tvalue={ getExistingTaxQueryValue( slug ) }\n\t\t\t\t\t\t\t\tsuggestions={ terms.names }\n\t\t\t\t\t\t\t\tonChange={ onTermsChange( slug ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
@@ -20,6 +20,7 @@ function QueryPlaceholder(_ref) {
20
20
  let {
21
21
  clientId,
22
22
  name,
23
+ attributes,
23
24
  setAttributes,
24
25
  icon,
25
26
  label
@@ -51,7 +52,11 @@ function QueryPlaceholder(_ref) {
51
52
  let nextVariation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVariation;
52
53
 
53
54
  if (nextVariation.attributes) {
54
- setAttributes(nextVariation.attributes);
55
+ setAttributes({ ...nextVariation.attributes,
56
+ query: { ...nextVariation.attributes.query,
57
+ postType: attributes.query.postType || nextVariation.attributes.query.postType
58
+ }
59
+ });
55
60
  }
56
61
 
57
62
  if (nextVariation.innerBlocks) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","clientId","name","setAttributes","icon","label","defaultVariation","scopeVariations","select","getBlockVariations","getBlockType","getDefaultBlockVariation","blocksStore","blockType","replaceInnerBlocks","blockEditorStore","blockProps","nextVariation","attributes","innerBlocks"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;AAYA,SAASA,gBAAT,OAA4E;AAAA,MAAjD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,IAAZ;AAAkBC,IAAAA,aAAlB;AAAiCC,IAAAA,IAAjC;AAAuCC,IAAAA;AAAvC,GAAiD;AAC3E,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAwC,qBAC3CC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,kBADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,aAAF,CAJV;AAMA,WAAO;AACNC,MAAAA,SAAS,EAAEH,YAAY,CAAER,IAAF,CADjB;AAENI,MAAAA,gBAAgB,EAAEK,wBAAwB,CAAET,IAAF,EAAQ,OAAR,CAFpC;AAGNK,MAAAA,eAAe,EAAEE,kBAAkB,CAAEP,IAAF,EAAQ,OAAR;AAH7B,KAAP;AAKA,GAb4C,EAc7C,CAAEA,IAAF,CAd6C,CAA9C;AAgBA,QAAM;AAAEY,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAMC,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,+CAAD;AACC,IAAA,IAAI,EAAGZ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,UAAU,EAAGE,eAHd;AAIC,IAAA,QAAQ,EAAG,YAAwC;AAAA,UAAtCU,aAAsC,uEAAtBX,gBAAsB;;AAClD,UAAKW,aAAa,CAACC,UAAnB,EAAgC;AAC/Bf,QAAAA,aAAa,CAAEc,aAAa,CAACC,UAAhB,CAAb;AACA;;AACD,UAAKD,aAAa,CAACE,WAAnB,EAAiC;AAChCL,QAAAA,kBAAkB,CACjBb,QADiB,EAEjB,iDACCgB,aAAa,CAACE,WADf,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AAjBF,IADD,CADD;AAuBA;;eAEcnB,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\t__experimentalBlockVariationPicker,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\nfunction QueryPlaceholder( { clientId, name, setAttributes, icon, label } ) {\n\tconst { defaultVariation, scopeVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tscopeVariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( nextVariation.attributes );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default QueryPlaceholder;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","clientId","name","attributes","setAttributes","icon","label","defaultVariation","scopeVariations","select","getBlockVariations","getBlockType","getDefaultBlockVariation","blocksStore","blockType","replaceInnerBlocks","blockEditorStore","blockProps","nextVariation","query","postType","innerBlocks"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;AAYA,SAASA,gBAAT,OAOI;AAAA,MAPuB;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,IAF0B;AAG1BC,IAAAA,UAH0B;AAI1BC,IAAAA,aAJ0B;AAK1BC,IAAAA,IAL0B;AAM1BC,IAAAA;AAN0B,GAOvB;AACH,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAwC,qBAC3CC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,kBADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,aAAF,CAJV;AAMA,WAAO;AACNC,MAAAA,SAAS,EAAEH,YAAY,CAAET,IAAF,CADjB;AAENK,MAAAA,gBAAgB,EAAEK,wBAAwB,CAAEV,IAAF,EAAQ,OAAR,CAFpC;AAGNM,MAAAA,eAAe,EAAEE,kBAAkB,CAAER,IAAF,EAAQ,OAAR;AAH7B,KAAP;AAKA,GAb4C,EAc7C,CAAEA,IAAF,CAd6C,CAA9C;AAgBA,QAAM;AAAEa,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAMC,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,+CAAD;AACC,IAAA,IAAI,EAAGZ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,UAAU,EAAGE,eAHd;AAIC,IAAA,QAAQ,EAAG,YAAwC;AAAA,UAAtCU,aAAsC,uEAAtBX,gBAAsB;;AAClD,UAAKW,aAAa,CAACf,UAAnB,EAAgC;AAC/BC,QAAAA,aAAa,CAAE,EACd,GAAGc,aAAa,CAACf,UADH;AAEdgB,UAAAA,KAAK,EAAE,EACN,GAAGD,aAAa,CAACf,UAAd,CAAyBgB,KADtB;AAENC,YAAAA,QAAQ,EACPjB,UAAU,CAACgB,KAAX,CAAiBC,QAAjB,IACAF,aAAa,CAACf,UAAd,CAAyBgB,KAAzB,CAA+BC;AAJ1B;AAFO,SAAF,CAAb;AASA;;AACD,UAAKF,aAAa,CAACG,WAAnB,EAAiC;AAChCN,QAAAA,kBAAkB,CACjBd,QADiB,EAEjB,iDACCiB,aAAa,CAACG,WADf,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AAzBF,IADD,CADD;AA+BA;;eAEcrB,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\t__experimentalBlockVariationPicker,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\nfunction QueryPlaceholder( {\n\tclientId,\n\tname,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst { defaultVariation, scopeVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tscopeVariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...nextVariation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...nextVariation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tnextVariation.attributes.query.postType,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default QueryPlaceholder;\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useTaxonomies = exports.usePostTypes = exports.mapToIHasNameAndId = exports.getFirstQueryClientIdFromBlocks = exports.getEntitiesInfo = void 0;
6
+ exports.useTaxonomies = exports.usePostTypes = exports.mapToIHasNameAndId = exports.getTransformedBlocksFromPattern = exports.getEntitiesInfo = void 0;
7
7
 
8
8
  var _lodash = require("lodash");
9
9
 
@@ -15,6 +15,8 @@ var _coreData = require("@wordpress/core-data");
15
15
 
16
16
  var _htmlEntities = require("@wordpress/html-entities");
17
17
 
18
+ var _blocks = require("@wordpress/blocks");
19
+
18
20
  /**
19
21
  * External dependencies
20
22
  */
@@ -164,18 +166,33 @@ const useTaxonomies = postType => {
164
166
  return taxonomies;
165
167
  };
166
168
  /**
167
- * Recurses over a list of blocks and returns the first found
168
- * Query Loop block's clientId.
169
+ * Clones a pattern's blocks and then recurses over that list of blocks,
170
+ * transforming them to retain some `query` attribute properties.
171
+ * For now we retain the `postType` and `inherit` properties as they are
172
+ * fundamental for the expected functionality of the block and don't affect
173
+ * its design and presentation.
174
+ *
175
+ * Returns the cloned/transformed blocks and array of existing Query Loop
176
+ * client ids for further manipulation, in order to avoid multiple recursions.
169
177
  *
170
- * @param {WPBlock[]} blocks The list of blocks to look through.
171
- * @return {string=} The first found Query Loop's clientId.
178
+ * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).
179
+ * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.
180
+ * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.
172
181
  */
173
182
 
174
183
 
175
184
  exports.useTaxonomies = useTaxonomies;
176
185
 
177
- const getFirstQueryClientIdFromBlocks = blocks => {
178
- const blocksQueue = [...blocks];
186
+ const getTransformedBlocksFromPattern = (blocks, queryBlockAttributes) => {
187
+ const {
188
+ query: {
189
+ postType,
190
+ inherit
191
+ }
192
+ } = queryBlockAttributes;
193
+ const clonedBlocks = blocks.map(block => (0, _blocks.cloneBlock)(block));
194
+ const queryClientIds = [];
195
+ const blocksQueue = [...clonedBlocks];
179
196
 
180
197
  while (blocksQueue.length > 0) {
181
198
  var _block$innerBlocks;
@@ -183,14 +200,23 @@ const getFirstQueryClientIdFromBlocks = blocks => {
183
200
  const block = blocksQueue.shift();
184
201
 
185
202
  if (block.name === 'core/query') {
186
- return block.clientId;
203
+ block.attributes.query = { ...block.attributes.query,
204
+ postType,
205
+ inherit
206
+ };
207
+ queryClientIds.push(block.clientId);
187
208
  }
188
209
 
189
210
  (_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => {
190
211
  blocksQueue.push(innerBlock);
191
212
  });
192
213
  }
214
+
215
+ return {
216
+ newBlocks: clonedBlocks,
217
+ queryClientIds
218
+ };
193
219
  };
194
220
 
195
- exports.getFirstQueryClientIdFromBlocks = getFirstQueryClientIdFromBlocks;
221
+ exports.getTransformedBlocksFromPattern = getTransformedBlocksFromPattern;
196
222
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","getFirstQueryClientIdFromBlocks","blocks","blocksQueue","block","shift","clientId","innerBlocks","forEach","innerBlock"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEE,MAAV,CACf,CAAEC,WAAF,EAAeC,MAAf,KAA2B;AAC1B,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,SAAX;AAAsBC,MAAAA;AAAtB,QAAgCJ,WAAtC;AACAE,IAAAA,OAAO,CAAED,MAAM,CAACI,EAAT,CAAP,GAAuBJ,MAAvB;AACAE,IAAAA,SAAS,CAAEF,MAAM,CAACK,IAAT,CAAT,GAA2BL,MAA3B;AACAG,IAAAA,KAAK,CAACG,IAAN,CAAYN,MAAM,CAACK,IAAnB;AACA,WAAON,WAAP;AACA,GAPc,EAQf;AAAEE,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,SAAS,EAAE,EAA1B;AAA8BC,IAAAA,KAAK,EAAE;AAArC,GARe,CAAhB;AAUA,SAAO;AACNP,IAAAA,QADM;AAEN,OAAGC;AAFG,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,CAACG,WAAN,0EAAmBC,OAAnB,CAA8BC,UAAF,IAAkB;AAC7CN,MAAAA,WAAW,CAAChC,IAAZ,CAAkBsC,UAAlB;AACA,KAFD;AAGA;AACD,CAXM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Recurses over a list of blocks and returns the first found\n * Query Loop block's clientId.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through.\n * @return {string=} The first found Query Loop's clientId.\n */\nexport const getFirstQueryClientIdFromBlocks = ( blocks ) => {\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\treturn block.clientId;\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","attributes","clientId","innerBlocks","forEach","innerBlock","newBlocks"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEE,MAAV,CACf,CAAEC,WAAF,EAAeC,MAAf,KAA2B;AAC1B,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,SAAX;AA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B,EAUlB,CAAEF,QAAF,CAVkB,CAAnB;AAYA,SAAOP,UAAP;AACA,CAdM;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMW,+BAA+B,GAAG,CAC9CC,MAD8C,EAE9CC,oBAF8C,KAG1C;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAE;AAAEP,MAAAA,QAAF;AAAYQ,MAAAA;AAAZ;AADF,MAEFF,oBAFJ;AAGA,QAAMG,YAAY,GAAGJ,MAAM,CAAC5B,GAAP,CAAciC,KAAF,IAAa,wBAAYA,KAAZ,CAAzB,CAArB;AACA,QAAMC,cAAc,GAAG,EAAvB;AACA,QAAMC,WAAW,GAAG,CAAE,GAAGH,YAAL,CAApB;;AACA,SAAQG,WAAW,CAACrB,MAAZ,GAAqB,CAA7B,EAAiC;AAAA;;AAChC,UAAMmB,KAAK,GAAGE,WAAW,CAACC,KAAZ,EAAd;;AACA,QAAKH,KAAK,CAACrC,IAAN,KAAe,YAApB,EAAmC;AAClCqC,MAAAA,KAAK,CAACI,UAAN,CAAiBP,KAAjB,GAAyB,EACxB,GAAGG,KAAK,CAACI,UAAN,CAAiBP,KADI;AAExBP,QAAAA,QAFwB;AAGxBQ,QAAAA;AAHwB,OAAzB;AAKAG,MAAAA,cAAc,CAACrC,IAAf,CAAqBoC,KAAK,CAACK,QAA3B;AACA;;AACD,0BAAAL,KAAK,CAACM,WAAN,0EAAmBC,OAAnB,CAA8BC,UAAF,IAAkB;AAC7CN,MAAAA,WAAW,CAACtC,IAAZ,CAAkB4C,UAAlB;AACA,KAFD;AAGA;;AACD,SAAO;AAAEC,IAAAA,SAAS,EAAEV,YAAb;AAA2BE,IAAAA;AAA3B,GAAP;AACA,CAzBM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n"]}