@wordpress/block-library 8.24.1 → 8.25.1-next.79a6196f.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 (509) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/audio/edit.js +15 -62
  4. package/build/audio/edit.js.map +1 -1
  5. package/build/audio/edit.native.js +1 -1
  6. package/build/audio/edit.native.js.map +1 -1
  7. package/build/audio/index.js +2 -2
  8. package/build/block/edit.js +157 -19
  9. package/build/block/edit.js.map +1 -1
  10. package/build/block/index.js +3 -2
  11. package/build/block/index.js.map +1 -1
  12. package/build/block/v1/edit.js +116 -0
  13. package/build/block/v1/edit.js.map +1 -0
  14. package/build/block/{edit.native.js → v1/edit.native.js} +2 -2
  15. package/build/block/v1/edit.native.js.map +1 -0
  16. package/build/button/index.js +2 -2
  17. package/build/button/save.js +1 -1
  18. package/build/button/save.js.map +1 -1
  19. package/build/code/edit.native.js +13 -14
  20. package/build/code/edit.native.js.map +1 -1
  21. package/build/code/index.js +2 -2
  22. package/build/code/save.js +6 -2
  23. package/build/code/save.js.map +1 -1
  24. package/build/comments-title/deprecated.js +1 -1
  25. package/build/comments-title/index.js +1 -1
  26. package/build/cover/edit/inspector-controls.js +1 -1
  27. package/build/cover/edit/inspector-controls.js.map +1 -1
  28. package/build/cover/edit.native.js +1 -0
  29. package/build/cover/edit.native.js.map +1 -1
  30. package/build/details/index.js +2 -2
  31. package/build/embed/deprecated.js +2 -2
  32. package/build/embed/embed-preview.native.js +1 -1
  33. package/build/embed/embed-preview.native.js.map +1 -1
  34. package/build/embed/icons.js +1 -1
  35. package/build/embed/icons.js.map +1 -1
  36. package/build/embed/index.js +2 -2
  37. package/build/embed/transforms.js +2 -2
  38. package/build/embed/util.js +6 -6
  39. package/build/embed/util.js.map +1 -1
  40. package/build/file/edit.js +20 -28
  41. package/build/file/edit.js.map +1 -1
  42. package/build/file/edit.native.js +1 -1
  43. package/build/file/edit.native.js.map +1 -1
  44. package/build/file/index.js +4 -4
  45. package/build/file/save.js +4 -1
  46. package/build/file/save.js.map +1 -1
  47. package/build/form-input/deprecated.js +147 -0
  48. package/build/form-input/deprecated.js.map +1 -0
  49. package/build/form-input/edit.js +1 -1
  50. package/build/form-input/edit.js.map +1 -1
  51. package/build/form-input/index.js +4 -2
  52. package/build/form-input/index.js.map +1 -1
  53. package/build/form-input/save.js +7 -9
  54. package/build/form-input/save.js.map +1 -1
  55. package/build/gallery/edit.js +38 -58
  56. package/build/gallery/edit.js.map +1 -1
  57. package/build/gallery/gallery.js +19 -24
  58. package/build/gallery/gallery.js.map +1 -1
  59. package/build/gallery/gallery.native.js +1 -1
  60. package/build/gallery/gallery.native.js.map +1 -1
  61. package/build/gallery/index.js +8 -4
  62. package/build/gallery/index.js.map +1 -1
  63. package/build/gallery/transforms.js +4 -68
  64. package/build/gallery/transforms.js.map +1 -1
  65. package/build/gallery/v1/gallery.native.js +1 -1
  66. package/build/gallery/v1/gallery.native.js.map +1 -1
  67. package/build/group/edit.js +6 -1
  68. package/build/group/edit.js.map +1 -1
  69. package/build/group/index.js +5 -1
  70. package/build/group/index.js.map +1 -1
  71. package/build/heading/index.js +3 -6
  72. package/build/heading/index.js.map +1 -1
  73. package/build/image/deprecated.js +11 -0
  74. package/build/image/deprecated.js.map +1 -1
  75. package/build/image/edit.native.js +4 -1
  76. package/build/image/edit.native.js.map +1 -1
  77. package/build/image/image.js +35 -71
  78. package/build/image/image.js.map +1 -1
  79. package/build/image/index.js +2 -2
  80. package/build/image/save.js +3 -1
  81. package/build/image/save.js.map +1 -1
  82. package/build/image/view.js +7 -1
  83. package/build/image/view.js.map +1 -1
  84. package/build/list/edit.js +10 -15
  85. package/build/list/edit.js.map +1 -1
  86. package/build/list-item/edit.js +17 -2
  87. package/build/list-item/edit.js.map +1 -1
  88. package/build/list-item/hooks/use-enter.js +5 -3
  89. package/build/list-item/hooks/use-enter.js.map +1 -1
  90. package/build/list-item/hooks/use-enter.native.js +4 -3
  91. package/build/list-item/hooks/use-enter.native.js.map +1 -1
  92. package/build/list-item/hooks/use-indent-list-item.js +2 -3
  93. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  94. package/build/list-item/hooks/use-merge.js +1 -1
  95. package/build/list-item/hooks/use-merge.js.map +1 -1
  96. package/build/list-item/hooks/use-outdent-list-item.js +3 -17
  97. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  98. package/build/list-item/hooks/use-space.js +8 -4
  99. package/build/list-item/hooks/use-space.js.map +1 -1
  100. package/build/list-item/index.js +10 -3
  101. package/build/list-item/index.js.map +1 -1
  102. package/build/media-text/media-container.native.js +3 -0
  103. package/build/media-text/media-container.native.js.map +1 -1
  104. package/build/navigation/constants.js +3 -1
  105. package/build/navigation/constants.js.map +1 -1
  106. package/build/navigation/edit/index.js +5 -1
  107. package/build/navigation/edit/index.js.map +1 -1
  108. package/build/navigation/view.js +25 -1
  109. package/build/navigation/view.js.map +1 -1
  110. package/build/page-list/convert-to-links-modal.js +2 -2
  111. package/build/page-list/convert-to-links-modal.js.map +1 -1
  112. package/build/paragraph/edit.js +54 -32
  113. package/build/paragraph/edit.js.map +1 -1
  114. package/build/paragraph/index.js +2 -4
  115. package/build/paragraph/index.js.map +1 -1
  116. package/build/paragraph/transforms.js +2 -4
  117. package/build/paragraph/transforms.js.map +1 -1
  118. package/build/pattern/edit.js +24 -2
  119. package/build/pattern/edit.js.map +1 -1
  120. package/build/pattern/recursion-detector.js +147 -0
  121. package/build/pattern/recursion-detector.js.map +1 -0
  122. package/build/post-featured-image/edit.js +19 -2
  123. package/build/post-featured-image/edit.js.map +1 -1
  124. package/build/post-featured-image/index.js +4 -0
  125. package/build/post-featured-image/index.js.map +1 -1
  126. package/build/post-title/index.js +1 -3
  127. package/build/post-title/index.js.map +1 -1
  128. package/build/preformatted/index.js +2 -3
  129. package/build/preformatted/index.js.map +1 -1
  130. package/build/pullquote/index.js +5 -7
  131. package/build/pullquote/index.js.map +1 -1
  132. package/build/query/edit/inspector-controls/index.js +3 -1
  133. package/build/query/edit/inspector-controls/index.js.map +1 -1
  134. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  135. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  136. package/build/query-pagination-numbers/index.js +1 -1
  137. package/build/query-title/index.js +1 -3
  138. package/build/query-title/index.js.map +1 -1
  139. package/build/quote/index.js +3 -5
  140. package/build/quote/index.js.map +1 -1
  141. package/build/quote/transforms.js +7 -6
  142. package/build/quote/transforms.js.map +1 -1
  143. package/build/search/edit.js +3 -5
  144. package/build/search/edit.js.map +1 -1
  145. package/build/search/index.js +0 -4
  146. package/build/search/index.js.map +1 -1
  147. package/build/site-logo/edit.js +7 -6
  148. package/build/site-logo/edit.js.map +1 -1
  149. package/build/site-title/index.js +1 -5
  150. package/build/site-title/index.js.map +1 -1
  151. package/build/social-link/icons/gravatar.js +22 -0
  152. package/build/social-link/icons/gravatar.js.map +1 -0
  153. package/build/social-link/icons/index.js +11 -0
  154. package/build/social-link/icons/index.js.map +1 -1
  155. package/build/social-link/variations.js +7 -0
  156. package/build/social-link/variations.js.map +1 -1
  157. package/build/spacer/edit.native.js +2 -2
  158. package/build/spacer/edit.native.js.map +1 -1
  159. package/build/table/edit.js +3 -1
  160. package/build/table/edit.js.map +1 -1
  161. package/build/table/index.js +9 -10
  162. package/build/table/index.js.map +1 -1
  163. package/build/table-of-contents/edit.js +2 -2
  164. package/build/table-of-contents/edit.js.map +1 -1
  165. package/build/table-of-contents/index.js +5 -2
  166. package/build/table-of-contents/index.js.map +1 -1
  167. package/build/tag-cloud/edit.js +5 -9
  168. package/build/tag-cloud/edit.js.map +1 -1
  169. package/build/utils/caption.js +90 -0
  170. package/build/utils/caption.js.map +1 -0
  171. package/build/utils/constants.js +16 -0
  172. package/build/utils/constants.js.map +1 -0
  173. package/build/utils/remove-anchor-tag.js +2 -1
  174. package/build/utils/remove-anchor-tag.js.map +1 -1
  175. package/build/verse/index.js +3 -5
  176. package/build/verse/index.js.map +1 -1
  177. package/build/video/deprecated.js +2 -2
  178. package/build/video/edit.js +16 -57
  179. package/build/video/edit.js.map +1 -1
  180. package/build/video/edit.native.js +1 -1
  181. package/build/video/edit.native.js.map +1 -1
  182. package/build/video/index.js +2 -2
  183. package/build-module/audio/edit.js +19 -66
  184. package/build-module/audio/edit.js.map +1 -1
  185. package/build-module/audio/edit.native.js +2 -2
  186. package/build-module/audio/edit.native.js.map +1 -1
  187. package/build-module/audio/index.js +2 -2
  188. package/build-module/block/edit.js +160 -22
  189. package/build-module/block/edit.js.map +1 -1
  190. package/build-module/block/index.js +3 -2
  191. package/build-module/block/index.js.map +1 -1
  192. package/build-module/block/v1/edit.js +108 -0
  193. package/build-module/block/v1/edit.js.map +1 -0
  194. package/build-module/block/{edit.native.js → v1/edit.native.js} +2 -2
  195. package/build-module/block/v1/edit.native.js.map +1 -0
  196. package/build-module/button/index.js +2 -2
  197. package/build-module/button/save.js +1 -1
  198. package/build-module/button/save.js.map +1 -1
  199. package/build-module/code/edit.native.js +14 -16
  200. package/build-module/code/edit.native.js.map +1 -1
  201. package/build-module/code/index.js +2 -2
  202. package/build-module/code/save.js +6 -2
  203. package/build-module/code/save.js.map +1 -1
  204. package/build-module/comments-title/deprecated.js +1 -1
  205. package/build-module/comments-title/index.js +1 -1
  206. package/build-module/cover/edit/inspector-controls.js +1 -1
  207. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  208. package/build-module/cover/edit.native.js +1 -0
  209. package/build-module/cover/edit.native.js.map +1 -1
  210. package/build-module/details/index.js +2 -2
  211. package/build-module/embed/deprecated.js +2 -2
  212. package/build-module/embed/embed-preview.native.js +2 -2
  213. package/build-module/embed/embed-preview.native.js.map +1 -1
  214. package/build-module/embed/icons.js +1 -1
  215. package/build-module/embed/icons.js.map +1 -1
  216. package/build-module/embed/index.js +2 -2
  217. package/build-module/embed/transforms.js +2 -2
  218. package/build-module/embed/util.js +6 -6
  219. package/build-module/embed/util.js.map +1 -1
  220. package/build-module/file/edit.js +20 -28
  221. package/build-module/file/edit.js.map +1 -1
  222. package/build-module/file/edit.native.js +1 -1
  223. package/build-module/file/edit.native.js.map +1 -1
  224. package/build-module/file/index.js +4 -4
  225. package/build-module/file/save.js +4 -1
  226. package/build-module/file/save.js.map +1 -1
  227. package/build-module/form-input/deprecated.js +138 -0
  228. package/build-module/form-input/deprecated.js.map +1 -0
  229. package/build-module/form-input/edit.js +1 -1
  230. package/build-module/form-input/edit.js.map +1 -1
  231. package/build-module/form-input/index.js +4 -2
  232. package/build-module/form-input/index.js.map +1 -1
  233. package/build-module/form-input/save.js +8 -10
  234. package/build-module/form-input/save.js.map +1 -1
  235. package/build-module/gallery/edit.js +41 -61
  236. package/build-module/gallery/edit.js.map +1 -1
  237. package/build-module/gallery/gallery.js +18 -21
  238. package/build-module/gallery/gallery.js.map +1 -1
  239. package/build-module/gallery/gallery.native.js +2 -2
  240. package/build-module/gallery/gallery.native.js.map +1 -1
  241. package/build-module/gallery/index.js +8 -4
  242. package/build-module/gallery/index.js.map +1 -1
  243. package/build-module/gallery/transforms.js +4 -68
  244. package/build-module/gallery/transforms.js.map +1 -1
  245. package/build-module/gallery/v1/gallery.native.js +2 -2
  246. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  247. package/build-module/group/edit.js +6 -1
  248. package/build-module/group/edit.js.map +1 -1
  249. package/build-module/group/index.js +5 -1
  250. package/build-module/group/index.js.map +1 -1
  251. package/build-module/heading/index.js +3 -6
  252. package/build-module/heading/index.js.map +1 -1
  253. package/build-module/image/deprecated.js +11 -0
  254. package/build-module/image/deprecated.js.map +1 -1
  255. package/build-module/image/edit.native.js +5 -2
  256. package/build-module/image/edit.native.js.map +1 -1
  257. package/build-module/image/image.js +35 -71
  258. package/build-module/image/image.js.map +1 -1
  259. package/build-module/image/index.js +2 -2
  260. package/build-module/image/save.js +3 -1
  261. package/build-module/image/save.js.map +1 -1
  262. package/build-module/image/view.js +7 -1
  263. package/build-module/image/view.js.map +1 -1
  264. package/build-module/list/edit.js +10 -15
  265. package/build-module/list/edit.js.map +1 -1
  266. package/build-module/list-item/edit.js +18 -3
  267. package/build-module/list-item/edit.js.map +1 -1
  268. package/build-module/list-item/hooks/use-enter.js +5 -3
  269. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  270. package/build-module/list-item/hooks/use-enter.native.js +4 -3
  271. package/build-module/list-item/hooks/use-enter.native.js.map +1 -1
  272. package/build-module/list-item/hooks/use-indent-list-item.js +2 -3
  273. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  274. package/build-module/list-item/hooks/use-merge.js +1 -1
  275. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  276. package/build-module/list-item/hooks/use-outdent-list-item.js +3 -17
  277. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  278. package/build-module/list-item/hooks/use-space.js +8 -4
  279. package/build-module/list-item/hooks/use-space.js.map +1 -1
  280. package/build-module/list-item/index.js +10 -3
  281. package/build-module/list-item/index.js.map +1 -1
  282. package/build-module/media-text/media-container.native.js +3 -0
  283. package/build-module/media-text/media-container.native.js.map +1 -1
  284. package/build-module/navigation/constants.js +1 -0
  285. package/build-module/navigation/constants.js.map +1 -1
  286. package/build-module/navigation/edit/index.js +7 -3
  287. package/build-module/navigation/edit/index.js.map +1 -1
  288. package/build-module/navigation/view.js +25 -1
  289. package/build-module/navigation/view.js.map +1 -1
  290. package/build-module/page-list/convert-to-links-modal.js +2 -2
  291. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  292. package/build-module/paragraph/edit.js +54 -32
  293. package/build-module/paragraph/edit.js.map +1 -1
  294. package/build-module/paragraph/index.js +2 -4
  295. package/build-module/paragraph/index.js.map +1 -1
  296. package/build-module/paragraph/transforms.js +2 -4
  297. package/build-module/paragraph/transforms.js.map +1 -1
  298. package/build-module/pattern/edit.js +26 -4
  299. package/build-module/pattern/edit.js.map +1 -1
  300. package/build-module/pattern/recursion-detector.js +139 -0
  301. package/build-module/pattern/recursion-detector.js.map +1 -0
  302. package/build-module/post-featured-image/edit.js +19 -2
  303. package/build-module/post-featured-image/edit.js.map +1 -1
  304. package/build-module/post-featured-image/index.js +4 -0
  305. package/build-module/post-featured-image/index.js.map +1 -1
  306. package/build-module/post-title/index.js +1 -3
  307. package/build-module/post-title/index.js.map +1 -1
  308. package/build-module/preformatted/index.js +2 -3
  309. package/build-module/preformatted/index.js.map +1 -1
  310. package/build-module/pullquote/index.js +5 -7
  311. package/build-module/pullquote/index.js.map +1 -1
  312. package/build-module/query/edit/inspector-controls/index.js +3 -1
  313. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  314. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  315. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  316. package/build-module/query-pagination-numbers/index.js +1 -1
  317. package/build-module/query-title/index.js +1 -3
  318. package/build-module/query-title/index.js.map +1 -1
  319. package/build-module/quote/index.js +3 -5
  320. package/build-module/quote/index.js.map +1 -1
  321. package/build-module/quote/transforms.js +7 -6
  322. package/build-module/quote/transforms.js.map +1 -1
  323. package/build-module/search/edit.js +3 -5
  324. package/build-module/search/edit.js.map +1 -1
  325. package/build-module/search/index.js +0 -4
  326. package/build-module/search/index.js.map +1 -1
  327. package/build-module/site-logo/edit.js +7 -6
  328. package/build-module/site-logo/edit.js.map +1 -1
  329. package/build-module/site-title/index.js +1 -5
  330. package/build-module/site-title/index.js.map +1 -1
  331. package/build-module/social-link/icons/gravatar.js +14 -0
  332. package/build-module/social-link/icons/gravatar.js.map +1 -0
  333. package/build-module/social-link/icons/index.js +1 -0
  334. package/build-module/social-link/icons/index.js.map +1 -1
  335. package/build-module/social-link/variations.js +8 -1
  336. package/build-module/social-link/variations.js.map +1 -1
  337. package/build-module/spacer/edit.native.js +2 -2
  338. package/build-module/spacer/edit.native.js.map +1 -1
  339. package/build-module/table/edit.js +3 -1
  340. package/build-module/table/edit.js.map +1 -1
  341. package/build-module/table/index.js +9 -10
  342. package/build-module/table/index.js.map +1 -1
  343. package/build-module/table-of-contents/edit.js +1 -1
  344. package/build-module/table-of-contents/edit.js.map +1 -1
  345. package/build-module/table-of-contents/index.js +5 -1
  346. package/build-module/table-of-contents/index.js.map +1 -1
  347. package/build-module/tag-cloud/edit.js +6 -10
  348. package/build-module/tag-cloud/edit.js.map +1 -1
  349. package/build-module/utils/caption.js +82 -0
  350. package/build-module/utils/caption.js.map +1 -0
  351. package/build-module/utils/constants.js +9 -0
  352. package/build-module/utils/constants.js.map +1 -0
  353. package/build-module/utils/remove-anchor-tag.js +2 -1
  354. package/build-module/utils/remove-anchor-tag.js.map +1 -1
  355. package/build-module/verse/index.js +3 -5
  356. package/build-module/verse/index.js.map +1 -1
  357. package/build-module/video/deprecated.js +2 -2
  358. package/build-module/video/edit.js +21 -62
  359. package/build-module/video/edit.js.map +1 -1
  360. package/build-module/video/edit.native.js +2 -2
  361. package/build-module/video/edit.native.js.map +1 -1
  362. package/build-module/video/index.js +2 -2
  363. package/build-style/button/editor-rtl.css +0 -37
  364. package/build-style/button/editor.css +0 -37
  365. package/build-style/button/style-rtl.css +6 -6
  366. package/build-style/button/style.css +6 -6
  367. package/build-style/editor-rtl.css +3 -55
  368. package/build-style/editor.css +3 -55
  369. package/build-style/navigation/editor-rtl.css +2 -4
  370. package/build-style/navigation/editor.css +2 -4
  371. package/build-style/navigation/style-rtl.css +14 -18
  372. package/build-style/navigation/style.css +14 -18
  373. package/build-style/search/style-rtl.css +26 -27
  374. package/build-style/search/style.css +26 -27
  375. package/build-style/social-links/style-rtl.css +14 -2
  376. package/build-style/social-links/style.css +14 -2
  377. package/build-style/style-rtl.css +60 -53
  378. package/build-style/style.css +60 -53
  379. package/build-style/table/editor-rtl.css +1 -14
  380. package/build-style/table/editor.css +1 -14
  381. package/package.json +32 -32
  382. package/src/audio/block.json +2 -2
  383. package/src/audio/edit.js +29 -92
  384. package/src/audio/edit.native.js +2 -1
  385. package/src/audio/test/__snapshots__/edit.native.js.snap +12 -0
  386. package/src/audio/test/edit.native.js +29 -0
  387. package/src/block/edit.js +218 -37
  388. package/src/block/index.js +3 -2
  389. package/src/block/index.php +48 -0
  390. package/src/block/v1/edit.js +163 -0
  391. package/src/block/{edit.native.js → v1/edit.native.js} +2 -2
  392. package/src/button/block.json +2 -2
  393. package/src/button/editor.scss +0 -43
  394. package/src/button/save.js +1 -1
  395. package/src/button/style.scss +6 -6
  396. package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
  397. package/src/buttons/test/edit.native.js +49 -0
  398. package/src/code/block.json +2 -2
  399. package/src/code/edit.native.js +11 -13
  400. package/src/code/save.js +4 -1
  401. package/src/code/test/edit.native.js +2 -2
  402. package/src/comments-title/block.json +1 -1
  403. package/src/cover/edit/inspector-controls.js +1 -1
  404. package/src/cover/edit.native.js +1 -0
  405. package/src/cover/test/edit.native.js +7 -1
  406. package/src/details/block.json +2 -2
  407. package/src/embed/block.json +2 -2
  408. package/src/embed/embed-preview.native.js +2 -1
  409. package/src/embed/icons.js +1 -1
  410. package/src/embed/util.js +2 -2
  411. package/src/file/block.json +4 -4
  412. package/src/file/edit.js +18 -25
  413. package/src/file/edit.native.js +1 -1
  414. package/src/file/save.js +5 -1
  415. package/src/form-input/block.json +2 -2
  416. package/src/form-input/deprecated.js +142 -0
  417. package/src/form-input/edit.js +1 -1
  418. package/src/form-input/index.js +2 -0
  419. package/src/form-input/save.js +27 -24
  420. package/src/gallery/block.json +8 -4
  421. package/src/gallery/edit.js +70 -98
  422. package/src/gallery/gallery.js +22 -36
  423. package/src/gallery/gallery.native.js +6 -2
  424. package/src/gallery/index.php +15 -0
  425. package/src/gallery/transforms.js +2 -55
  426. package/src/gallery/v1/gallery.native.js +2 -1
  427. package/src/group/block.json +5 -1
  428. package/src/group/edit.js +4 -1
  429. package/src/heading/block.json +3 -6
  430. package/src/image/block.json +2 -2
  431. package/src/image/deprecated.js +8 -0
  432. package/src/image/edit.native.js +5 -3
  433. package/src/image/image.js +77 -127
  434. package/src/image/index.php +1 -6
  435. package/src/image/save.js +3 -1
  436. package/src/image/view.js +5 -2
  437. package/src/list/edit.js +27 -35
  438. package/src/list-item/block.json +10 -3
  439. package/src/list-item/edit.js +18 -2
  440. package/src/list-item/hooks/use-enter.js +63 -62
  441. package/src/list-item/hooks/use-enter.native.js +9 -5
  442. package/src/list-item/hooks/use-indent-list-item.js +43 -53
  443. package/src/list-item/hooks/use-merge.js +1 -1
  444. package/src/list-item/hooks/use-outdent-list-item.js +50 -69
  445. package/src/list-item/hooks/use-space.js +7 -4
  446. package/src/media-text/media-container.native.js +3 -1
  447. package/src/navigation/constants.js +2 -0
  448. package/src/navigation/edit/index.js +18 -3
  449. package/src/navigation/editor.scss +1 -1
  450. package/src/navigation/index.php +1 -1
  451. package/src/navigation/style.scss +18 -16
  452. package/src/navigation/view.js +29 -3
  453. package/src/navigation-link/test/__snapshots__/hooks.js.snap +6 -3
  454. package/src/page-list/convert-to-links-modal.js +2 -2
  455. package/src/paragraph/block.json +2 -4
  456. package/src/paragraph/edit.js +53 -40
  457. package/src/paragraph/test/__snapshots__/edit.native.js.snap +12 -0
  458. package/src/paragraph/test/edit.native.js +114 -0
  459. package/src/pattern/edit.js +35 -3
  460. package/src/pattern/index.php +16 -0
  461. package/src/pattern/recursion-detector.js +145 -0
  462. package/src/pattern/test/index.js +74 -0
  463. package/src/post-featured-image/block.json +4 -0
  464. package/src/post-featured-image/edit.js +32 -1
  465. package/src/post-featured-image/index.php +31 -0
  466. package/src/post-title/block.json +1 -3
  467. package/src/preformatted/block.json +2 -3
  468. package/src/pullquote/block.json +5 -7
  469. package/src/query/edit/inspector-controls/index.js +2 -0
  470. package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -0
  471. package/src/query-pagination-numbers/block.json +1 -1
  472. package/src/query-title/block.json +1 -3
  473. package/src/quote/block.json +3 -5
  474. package/src/quote/transforms.js +12 -11
  475. package/src/search/block.json +0 -4
  476. package/src/search/edit.js +2 -8
  477. package/src/search/index.php +3 -7
  478. package/src/search/style.scss +27 -29
  479. package/src/site-logo/edit.js +3 -4
  480. package/src/site-title/block.json +1 -5
  481. package/src/social-link/icons/gravatar.js +10 -0
  482. package/src/social-link/icons/index.js +1 -0
  483. package/src/social-link/index.php +5 -1
  484. package/src/social-link/socials-with-bg.scss +5 -0
  485. package/src/social-link/socials-without-bg.scss +4 -0
  486. package/src/social-link/variations.js +7 -0
  487. package/src/social-links/style.scss +14 -8
  488. package/src/spacer/edit.native.js +4 -2
  489. package/src/table/block.json +9 -10
  490. package/src/table/edit.js +3 -1
  491. package/src/table/editor.scss +1 -17
  492. package/src/table-of-contents/edit.js +1 -1
  493. package/src/table-of-contents/index.js +5 -1
  494. package/src/tag-cloud/edit.js +7 -7
  495. package/src/template-part/index.php +6 -0
  496. package/src/utils/caption.js +108 -0
  497. package/src/utils/constants.js +8 -0
  498. package/src/utils/remove-anchor-tag.js +2 -1
  499. package/src/verse/block.json +3 -5
  500. package/src/video/block.json +2 -2
  501. package/src/video/edit.js +40 -100
  502. package/src/video/edit.native.js +2 -1
  503. package/build/block/edit.native.js.map +0 -1
  504. package/build/table-of-contents/icon.js +0 -22
  505. package/build/table-of-contents/icon.js.map +0 -1
  506. package/build-module/block/edit.native.js.map +0 -1
  507. package/build-module/table-of-contents/icon.js +0 -15
  508. package/build-module/table-of-contents/icon.js.map +0 -1
  509. package/src/table-of-contents/icon.js +0 -18
@@ -33,10 +33,9 @@ const metadata = {
33
33
  type: "string"
34
34
  },
35
35
  content: {
36
- type: "string",
37
- source: "html",
36
+ type: "rich-text",
37
+ source: "rich-text",
38
38
  selector: "p",
39
- "default": "",
40
39
  __experimentalRole: "content"
41
40
  },
42
41
  dropCap: {
@@ -62,7 +61,6 @@ const metadata = {
62
61
  text: true
63
62
  }
64
63
  },
65
- __experimentalConnections: true,
66
64
  spacing: {
67
65
  margin: true,
68
66
  padding: true,
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","usesContext","attributes","align","type","content","source","selector","__experimentalRole","dropCap","placeholder","direction","supports","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","__experimentalConnections","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalTextDecoration","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalWritingMode","__experimentalSelector","__unstablePasteTextInline","editorStyle","style","exports","settings","icon","example","__","__experimentalLabel","context","customName","length","transforms","deprecated","merge","attributesToMerge","edit","save","init","initBlock"],"sources":["@wordpress/block-library/src/paragraph/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\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\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t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IAAI;EAAEH,QAAQ;EAAEgD;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAe,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","usesContext","attributes","align","type","content","source","selector","__experimentalRole","dropCap","placeholder","direction","supports","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalTextDecoration","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalWritingMode","__experimentalSelector","__unstablePasteTextInline","editorStyle","style","exports","settings","icon","example","__","__experimentalLabel","context","customName","length","transforms","deprecated","merge","attributesToMerge","edit","save","init","initBlock"],"sources":["@wordpress/block-library/src/paragraph/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\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\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif ( context === 'list-view' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAdA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAQ,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAD,IAAA;MAAAE,MAAA;MAAAC,QAAA;MAAAC,kBAAA;IAAA;IAAAC,OAAA;MAAAL,IAAA;MAAA;IAAA;IAAAM,WAAA;MAAAN,IAAA;IAAA;IAAAO,SAAA;MAAAP,IAAA;MAAA;IAAA;EAAA;EAAAQ,QAAA;IAAAC,MAAA;IAAAC,SAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAL,6BAAA;QAAAI,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,4BAAA;MAAAC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AA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMc,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE3D,IAAI;EAAEH,QAAQ;EAAE+C;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAe,IAAA,GAAAA,IAAA"}
@@ -28,10 +28,9 @@ const {
28
28
  type: "string"
29
29
  },
30
30
  content: {
31
- type: "string",
32
- source: "html",
31
+ type: "rich-text",
32
+ source: "rich-text",
33
33
  selector: "p",
34
- "default": "",
35
34
  __experimentalRole: "content"
36
35
  },
37
36
  dropCap: {
@@ -57,7 +56,6 @@ const {
57
56
  text: true
58
57
  }
59
58
  },
60
- __experimentalConnections: true,
61
59
  spacing: {
62
60
  margin: true,
63
61
  padding: true,
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","name","$schema","apiVersion","title","category","description","keywords","textdomain","usesContext","attributes","align","type","content","source","selector","__experimentalRole","dropCap","placeholder","direction","supports","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","__experimentalConnections","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalTextDecoration","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalWritingMode","__experimentalSelector","__unstablePasteTextInline","editorStyle","style","transforms","from","priority","schema","phrasingContentSchema","isPaste","p","children","transform","node","getBlockAttributes","outerHTML","textAlign","createBlock","_default","exports","default"],"sources":["@wordpress/block-library/src/paragraph/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, getBlockAttributes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\t// Paragraph is a fallback and should be matched last.\n\t\t\tpriority: 20,\n\t\t\tselector: 'p',\n\t\t\tschema: ( { phrasingContentSchema, isPaste } ) => ( {\n\t\t\t\tp: {\n\t\t\t\t\tchildren: phrasingContentSchema,\n\t\t\t\t\tattributes: isPaste ? [] : [ 'style', 'id' ],\n\t\t\t\t},\n\t\t\t} ),\n\t\t\ttransform( node ) {\n\t\t\t\tconst attributes = getBlockAttributes( name, node.outerHTML );\n\t\t\t\tconst { textAlign } = node.style || {};\n\n\t\t\t\tif (\n\t\t\t\t\ttextAlign === 'left' ||\n\t\t\t\t\ttextAlign === 'center' ||\n\t\t\t\t\ttextAlign === 'right'\n\t\t\t\t) {\n\t\t\t\t\tattributes.align = textAlign;\n\t\t\t\t}\n\n\t\t\t\treturn createBlock( name, attributes );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAGA;AACA;AACA;AAFA;EAAAC,IAAA,EAAAA;AAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAF,IAAA;EAAAG,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAD,IAAA;MAAAE,MAAA;MAAAC,QAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAC,OAAA;MAAAL,IAAA;MAAA;IAAA;IAAAM,WAAA;MAAAN,IAAA;IAAA;IAAAO,SAAA;MAAAP,IAAA;MAAA;IAAA;EAAA;EAAAQ,QAAA;IAAAC,MAAA;IAAAC,SAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,yBAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAN,6BAAA;QAAAK,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,4BAAA;MAAAC,uBAAA;MAAAC,wBAAA;MAAAC,2BAAA;MAAAC,2BAAA;MAAAC,yBAAA;MAAAhB,6BAAA;QAAAQ,QAAA;MAAA;IAAA;IAAAS,sBAAA;IAAAC,yBAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAKA,MAAMC,UAAU,GAAG;EAClBC,IAAI,EAAE,CACL;IACCpC,IAAI,EAAE,KAAK;IACX;IACAqC,QAAQ,EAAE,EAAE;IACZlC,QAAQ,EAAE,GAAG;IACbmC,MAAM,EAAEA,CAAE;MAAEC,qBAAqB;MAAEC;IAAQ,CAAC,MAAQ;MACnDC,CAAC,EAAE;QACFC,QAAQ,EAAEH,qBAAqB;QAC/BzC,UAAU,EAAE0C,OAAO,GAAG,EAAE,GAAG,CAAE,OAAO,EAAE,IAAI;MAC3C;IACD,CAAC,CAAE;IACHG,SAASA,CAAEC,IAAI,EAAG;MACjB,MAAM9C,UAAU,GAAG,IAAA+C,0BAAkB,EAAExD,IAAI,EAAEuD,IAAI,CAACE,SAAU,CAAC;MAC7D,MAAM;QAAEC;MAAU,CAAC,GAAGH,IAAI,CAACV,KAAK,IAAI,CAAC,CAAC;MAEtC,IACCa,SAAS,KAAK,MAAM,IACpBA,SAAS,KAAK,QAAQ,IACtBA,SAAS,KAAK,OAAO,EACpB;QACDjD,UAAU,CAACC,KAAK,GAAGgD,SAAS;MAC7B;MAEA,OAAO,IAAAC,mBAAW,EAAE3D,IAAI,EAAES,UAAW,CAAC;IACvC;EACD,CAAC;AAEH,CAAC;AAAC,IAAAmD,QAAA,GAEad,UAAU;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_blocks","require","name","$schema","apiVersion","title","category","description","keywords","textdomain","usesContext","attributes","align","type","content","source","selector","__experimentalRole","dropCap","placeholder","direction","supports","anchor","className","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalTextDecoration","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalWritingMode","__experimentalSelector","__unstablePasteTextInline","editorStyle","style","transforms","from","priority","schema","phrasingContentSchema","isPaste","p","children","transform","node","getBlockAttributes","outerHTML","textAlign","createBlock","_default","exports","default"],"sources":["@wordpress/block-library/src/paragraph/transforms.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, getBlockAttributes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\t// Paragraph is a fallback and should be matched last.\n\t\t\tpriority: 20,\n\t\t\tselector: 'p',\n\t\t\tschema: ( { phrasingContentSchema, isPaste } ) => ( {\n\t\t\t\tp: {\n\t\t\t\t\tchildren: phrasingContentSchema,\n\t\t\t\t\tattributes: isPaste ? [] : [ 'style', 'id' ],\n\t\t\t\t},\n\t\t\t} ),\n\t\t\ttransform( node ) {\n\t\t\t\tconst attributes = getBlockAttributes( name, node.outerHTML );\n\t\t\t\tconst { textAlign } = node.style || {};\n\n\t\t\t\tif (\n\t\t\t\t\ttextAlign === 'left' ||\n\t\t\t\t\ttextAlign === 'center' ||\n\t\t\t\t\ttextAlign === 'right'\n\t\t\t\t) {\n\t\t\t\t\tattributes.align = textAlign;\n\t\t\t\t}\n\n\t\t\t\treturn createBlock( name, attributes );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAHA;AACA;AACA;AAGA;AACA;AACA;AAFA;EAAAC,IAAA,EAAAA;AAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAF,IAAA;EAAAG,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAD,IAAA;MAAAE,MAAA;MAAAC,QAAA;MAAAC,kBAAA;IAAA;IAAAC,OAAA;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K,GAAG+C,SAAS;MAC7B;MAEA,OAAO,IAAAC,mBAAW,EAAE1D,IAAI,EAAES,UAAW,CAAC;IACvC;EACD,CAAC;AAEH,CAAC;AAAC,IAAAkD,QAAA,GAEad,UAAU;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -10,10 +10,16 @@ var _data = require("@wordpress/data");
10
10
  var _element = require("@wordpress/element");
11
11
  var _blockEditor = require("@wordpress/block-editor");
12
12
  var _coreData = require("@wordpress/core-data");
13
+ var _i18n = require("@wordpress/i18n");
14
+ var _recursionDetector = require("./recursion-detector");
13
15
  /**
14
16
  * WordPress dependencies
15
17
  */
16
18
 
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+
17
23
  const PatternEdit = ({
18
24
  attributes,
19
25
  clientId
@@ -29,6 +35,8 @@ const PatternEdit = ({
29
35
  getBlockRootClientId,
30
36
  getBlockEditingMode
31
37
  } = (0, _data.useSelect)(_blockEditor.store);
38
+ const [hasRecursionError, setHasRecursionError] = (0, _element.useState)(false);
39
+ const parsePatternDependencies = (0, _recursionDetector.useParsePatternDependencies)();
32
40
 
33
41
  // Duplicated in packages/edit-site/src/components/start-template-options/index.js.
34
42
  function injectThemeAttributeInBlockTemplateContent(block) {
@@ -51,7 +59,14 @@ const PatternEdit = ({
51
59
  // This change won't be saved.
52
60
  // It will continue to pull from the pattern file unless changes are made to its respective template part.
53
61
  (0, _element.useEffect)(() => {
54
- if (selectedPattern?.blocks) {
62
+ if (!hasRecursionError && selectedPattern?.blocks) {
63
+ try {
64
+ parsePatternDependencies(selectedPattern);
65
+ } catch (error) {
66
+ setHasRecursionError(true);
67
+ return;
68
+ }
69
+
55
70
  // We batch updates to block list settings to avoid triggering cascading renders
56
71
  // for each container block included in a tree and optimize initial render.
57
72
  // Since the above uses microtasks, we need to use a microtask here as well,
@@ -74,8 +89,15 @@ const PatternEdit = ({
74
89
  setBlockEditingMode(rootClientId, rootEditingMode);
75
90
  });
76
91
  }
77
- }, [clientId, selectedPattern?.blocks, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
92
+ }, [clientId, hasRecursionError, selectedPattern, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
78
93
  const props = (0, _blockEditor.useBlockProps)();
94
+ if (hasRecursionError) {
95
+ return (0, _react.createElement)("div", {
96
+ ...props
97
+ }, (0, _react.createElement)(_blockEditor.Warning, null, (0, _i18n.sprintf)(
98
+ // translators: A warning in which %s is the name of a pattern.
99
+ (0, _i18n.__)('Pattern "%s" cannot be rendered inside itself.'), selectedPattern?.name)));
100
+ }
79
101
  return (0, _react.createElement)("div", {
80
102
  ...props
81
103
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_data","_element","_blockEditor","_coreData","PatternEdit","attributes","clientId","selectedPattern","useSelect","select","blockEditorStore","__experimentalGetParsedPattern","slug","currentThemeStylesheet","coreStore","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","useDispatch","getBlockRootClientId","getBlockEditingMode","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","useEffect","blocks","window","queueMicrotask","rootClientId","clonedBlocks","cloneBlock","rootEditingMode","props","useBlockProps","_react","createElement","_default","exports","default"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( selectedPattern?.blocks ) {\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tselectedPattern?.blocks,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,SAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAUA,MAAMK,WAAW,GAAGA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,KAAM;EACnD,MAAMC,eAAe,GAAG,IAAAC,eAAS,EAC9BC,MAAM,IACPA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,8BAA8B,CACxDN,UAAU,CAACO,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D;QACA;QACA,MAAM+B,YAAY,GAAG9B,eAAe,CAAC0B,MAAM,CAACJ,GAAG,CAAIL,KAAK,IACvD,IAAAc,kBAAU,EACTf,0CAA0C,CAAEC,KAAM,CACnD,CACD,CAAC;QACD,MAAMe,eAAe,GAAGjB,mBAAmB,CAAEc,YAAa,CAAC;QAC3D;QACA;QACAjB,uCAAuC,CAAC,CAAC;QACzCD,mBAAmB,CAAEkB,YAAY,EAAE,SAAU,CAAC;QAC9CjB,uCAAuC,CAAC,CAAC;QACzCF,aAAa,CAAEX,QAAQ,EAAE+B,YAAa,CAAC;QACvC;QACAlB,uCAAuC,CAAC,CAAC;QACzCD,mBAAmB,CAAEkB,YAAY,EAAEG,eAAgB,CAAC;MACrD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACFjC,QAAQ,EACRC,eAAe,EAAE0B,MAAM,EACvBd,uCAAuC,EACvCF,aAAa,EACbK,mBAAmB,EACnBJ,mBAAmB,EACnBG,oBAAoB,CACnB,CAAC;EAEH,MAAMmB,KAAK,GAAG,IAAAC,0BAAa,EAAC,CAAC;EAE7B,OAAO,IAAAC,MAAA,CAAAC,aAAA;IAAA,GAAUH;EAAK,CAAI,CAAC;AAC5B,CAAC;AAAC,IAAAI,QAAA,GAEaxC,WAAW;AAAAyC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_blocks","require","_data","_element","_blockEditor","_coreData","_i18n","_recursionDetector","PatternEdit","attributes","clientId","selectedPattern","useSelect","select","blockEditorStore","__experimentalGetParsedPattern","slug","currentThemeStylesheet","coreStore","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","useDispatch","getBlockRootClientId","getBlockEditingMode","hasRecursionError","setHasRecursionError","useState","parsePatternDependencies","useParsePatternDependencies","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","useEffect","blocks","error","window","queueMicrotask","rootClientId","clonedBlocks","cloneBlock","rootEditingMode","props","useBlockProps","_react","createElement","Warning","sprintf","__","_default","exports","default"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch ( error ) {\n\t\t\t\tsetHasRecursionError( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\thasRecursionError,\n\t\tselectedPattern,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\tif ( hasRecursionError ) {\n\t\treturn (\n\t\t\t<div { ...props }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: A warning in which %s is the name of a pattern.\n\t\t\t\t\t\t__( 'Pattern \"%s\" cannot be rendered inside itself.' ),\n\t\t\t\t\t\tselectedPattern?.name\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,kBAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAYA;AACA;AACA;;AAGA,MAAMO,WAAW,GAAGA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,KAAM;EACnD,MAAMC,eAAe,GAAG,IAAAC,eAAS,EAC9BC,MAAM,IACPA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,8BAA8B,CACxDN,UAAU,CAACO,IACZ,CAAC,EACF,CAAEP,UAAU,CAACO,IAAI,CAClB,CAAC;EAED,MAAMC,sBAAsB,GAAG,IAAAL,eAAS,EACrCC,MAAM,IAAMA,MAAM,CAAEK,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,WAAW;AAAAkD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parsePatternDependencies = parsePatternDependencies;
7
+ exports.registerDependency = registerDependency;
8
+ exports.useParsePatternDependencies = useParsePatternDependencies;
9
+ var _data = require("@wordpress/data");
10
+ /**
11
+ * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.
12
+ *
13
+ * This is because this approach for preventing infinite loops due to
14
+ * recursively rendering blocks is specific to the way that the `core/pattern`
15
+ * block behaves in the editor. Any other block types that deal with recursion
16
+ * SHOULD USE THE STANDARD METHOD for avoiding loops:
17
+ *
18
+ * @see https://github.com/WordPress/gutenberg/pull/31455
19
+ * @see packages/block-editor/src/components/recursion-provider/README.md
20
+ */
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+
26
+ /**
27
+ * Naming is hard.
28
+ *
29
+ * @see useParsePatternDependencies
30
+ *
31
+ * @type {WeakMap<Object, Function>}
32
+ */
33
+ const cachedParsers = new WeakMap();
34
+
35
+ /**
36
+ * Hook used by PatternEdit to parse block patterns. It returns a function that
37
+ * takes a pattern and returns nothing but throws an error if the pattern is
38
+ * recursive.
39
+ *
40
+ * @example
41
+ * ```js
42
+ * const parsePatternDependencies = useParsePatternDependencies();
43
+ * parsePatternDependencies( selectedPattern );
44
+ * ```
45
+ *
46
+ * @see parsePatternDependencies
47
+ *
48
+ * @return {Function} A function to parse block patterns.
49
+ */
50
+ function useParsePatternDependencies() {
51
+ const registry = (0, _data.useRegistry)();
52
+
53
+ // Instead of caching maps, go straight to the point and cache bound
54
+ // functions. Each of those functions is bound to a different Map that will
55
+ // keep track of patterns in the context of the given registry.
56
+ if (!cachedParsers.has(registry)) {
57
+ const deps = new Map();
58
+ cachedParsers.set(registry, parsePatternDependencies.bind(null, deps));
59
+ }
60
+ return cachedParsers.get(registry);
61
+ }
62
+
63
+ /**
64
+ * Parse a given pattern and traverse its contents to detect any subsequent
65
+ * patterns on which it may depend. Such occurrences will be added to an
66
+ * internal dependency graph. If a circular dependency is detected, an
67
+ * error will be thrown.
68
+ *
69
+ * EXPORTED FOR TESTING PURPOSES ONLY.
70
+ *
71
+ * @param {Map<string, Set<string>>} deps Map of pattern dependencies.
72
+ * @param {Object} pattern Pattern.
73
+ * @param {string} pattern.name Pattern name.
74
+ * @param {Array} pattern.blocks Pattern's block list.
75
+ *
76
+ * @throws {Error} If a circular dependency is detected.
77
+ */
78
+ function parsePatternDependencies(deps, {
79
+ name,
80
+ blocks
81
+ }) {
82
+ const queue = [...blocks];
83
+ while (queue.length) {
84
+ const block = queue.shift();
85
+ for (const innerBlock of (_block$innerBlocks = block.innerBlocks) !== null && _block$innerBlocks !== void 0 ? _block$innerBlocks : []) {
86
+ var _block$innerBlocks;
87
+ queue.unshift(innerBlock);
88
+ }
89
+ if (block.name === 'core/pattern') {
90
+ registerDependency(deps, name, block.attributes.slug);
91
+ }
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Declare that pattern `a` depends on pattern `b`. If a circular
97
+ * dependency is detected, an error will be thrown.
98
+ *
99
+ * EXPORTED FOR TESTING PURPOSES ONLY.
100
+ *
101
+ * @param {Map<string, Set<string>>} deps Map of pattern dependencies.
102
+ * @param {string} a Slug for pattern A.
103
+ * @param {string} b Slug for pattern B.
104
+ *
105
+ * @throws {Error} If a circular dependency is detected.
106
+ */
107
+ function registerDependency(deps, a, b) {
108
+ if (!deps.has(a)) {
109
+ deps.set(a, new Set());
110
+ }
111
+ deps.get(a).add(b);
112
+ if (hasCycle(deps, a)) {
113
+ throw new TypeError(`Pattern ${a} has a circular dependency and cannot be rendered.`);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Determine if a given pattern has circular dependencies on other patterns.
119
+ * This will be determined by running a depth-first search on the current state
120
+ * of the graph represented by `patternDependencies`.
121
+ *
122
+ * @param {Map<string, Set<string>>} deps Map of pattern dependencies.
123
+ * @param {string} slug Pattern slug.
124
+ * @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.
125
+ * @param {Set<string>} [currentPath] Set to track and backtrack graph paths.
126
+ * @return {boolean} Whether any cycle was found.
127
+ */
128
+ function hasCycle(deps, slug, visitedNodes = new Set(), currentPath = new Set()) {
129
+ var _deps$get;
130
+ visitedNodes.add(slug);
131
+ currentPath.add(slug);
132
+ const dependencies = (_deps$get = deps.get(slug)) !== null && _deps$get !== void 0 ? _deps$get : new Set();
133
+ for (const dependency of dependencies) {
134
+ if (!visitedNodes.has(dependency)) {
135
+ if (hasCycle(deps, dependency, visitedNodes, currentPath)) {
136
+ return true;
137
+ }
138
+ } else if (currentPath.has(dependency)) {
139
+ return true;
140
+ }
141
+ }
142
+
143
+ // Remove the current node from the current path when backtracking
144
+ currentPath.delete(slug);
145
+ return false;
146
+ }
147
+ //# sourceMappingURL=recursion-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","cachedParsers","WeakMap","useParsePatternDependencies","registry","useRegistry","has","deps","Map","set","parsePatternDependencies","bind","get","name","blocks","queue","length","block","shift","innerBlock","_block$innerBlocks","innerBlocks","unshift","registerDependency","attributes","slug","a","b","Set","add","hasCycle","TypeError","visitedNodes","currentPath","_deps$get","dependencies","dependency","delete"],"sources":["@wordpress/block-library/src/pattern/recursion-detector.js"],"sourcesContent":["/**\n * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.\n *\n * This is because this approach for preventing infinite loops due to\n * recursively rendering blocks is specific to the way that the `core/pattern`\n * block behaves in the editor. Any other block types that deal with recursion\n * SHOULD USE THE STANDARD METHOD for avoiding loops:\n *\n * @see https://github.com/WordPress/gutenberg/pull/31455\n * @see packages/block-editor/src/components/recursion-provider/README.md\n */\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Naming is hard.\n *\n * @see useParsePatternDependencies\n *\n * @type {WeakMap<Object, Function>}\n */\nconst cachedParsers = new WeakMap();\n\n/**\n * Hook used by PatternEdit to parse block patterns. It returns a function that\n * takes a pattern and returns nothing but throws an error if the pattern is\n * recursive.\n *\n * @example\n * ```js\n * const parsePatternDependencies = useParsePatternDependencies();\n * parsePatternDependencies( selectedPattern );\n * ```\n *\n * @see parsePatternDependencies\n *\n * @return {Function} A function to parse block patterns.\n */\nexport function useParsePatternDependencies() {\n\tconst registry = useRegistry();\n\n\t// Instead of caching maps, go straight to the point and cache bound\n\t// functions. Each of those functions is bound to a different Map that will\n\t// keep track of patterns in the context of the given registry.\n\tif ( ! cachedParsers.has( registry ) ) {\n\t\tconst deps = new Map();\n\t\tcachedParsers.set(\n\t\t\tregistry,\n\t\t\tparsePatternDependencies.bind( null, deps )\n\t\t);\n\t}\n\treturn cachedParsers.get( registry );\n}\n\n/**\n * Parse a given pattern and traverse its contents to detect any subsequent\n * patterns on which it may depend. Such occurrences will be added to an\n * internal dependency graph. If a circular dependency is detected, an\n * error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {Object} pattern Pattern.\n * @param {string} pattern.name Pattern name.\n * @param {Array} pattern.blocks Pattern's block list.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function parsePatternDependencies( deps, { name, blocks } ) {\n\tconst queue = [ ...blocks ];\n\twhile ( queue.length ) {\n\t\tconst block = queue.shift();\n\t\tfor ( const innerBlock of block.innerBlocks ?? [] ) {\n\t\t\tqueue.unshift( innerBlock );\n\t\t}\n\t\tif ( block.name === 'core/pattern' ) {\n\t\t\tregisterDependency( deps, name, block.attributes.slug );\n\t\t}\n\t}\n}\n\n/**\n * Declare that pattern `a` depends on pattern `b`. If a circular\n * dependency is detected, an error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} a Slug for pattern A.\n * @param {string} b Slug for pattern B.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function registerDependency( deps, a, b ) {\n\tif ( ! deps.has( a ) ) {\n\t\tdeps.set( a, new Set() );\n\t}\n\tdeps.get( a ).add( b );\n\tif ( hasCycle( deps, a ) ) {\n\t\tthrow new TypeError(\n\t\t\t`Pattern ${ a } has a circular dependency and cannot be rendered.`\n\t\t);\n\t}\n}\n\n/**\n * Determine if a given pattern has circular dependencies on other patterns.\n * This will be determined by running a depth-first search on the current state\n * of the graph represented by `patternDependencies`.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} slug Pattern slug.\n * @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.\n * @param {Set<string>} [currentPath] Set to track and backtrack graph paths.\n * @return {boolean} Whether any cycle was found.\n */\nfunction hasCycle(\n\tdeps,\n\tslug,\n\tvisitedNodes = new Set(),\n\tcurrentPath = new Set()\n) {\n\tvisitedNodes.add( slug );\n\tcurrentPath.add( slug );\n\n\tconst dependencies = deps.get( slug ) ?? new Set();\n\n\tfor ( const dependency of dependencies ) {\n\t\tif ( ! visitedNodes.has( dependency ) ) {\n\t\t\tif ( hasCycle( deps, dependency, visitedNodes, currentPath ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if ( currentPath.has( dependency ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Remove the current node from the current path when backtracking\n\tcurrentPath.delete( slug );\n\treturn false;\n}\n"],"mappings":";;;;;;;;AAeA,IAAAA,KAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,2BAA2BA,CAAA,EAAG;EAC7C,MAAMC,Q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AE,CAAC;EACzB;EACArB,IAAI,CAACK,GAAG,CAAEc,CAAE,CAAC,CAACG,GAAG,CAAEF,CAAE,CAAC;EACtB,IAAKG,QAAQ,CAAEvB,IAAI,EAAEmB,CAAE,CAAC,EAAG;IAC1B,MAAM,IAAIK,SAAS,CACjB,WAAWL,CAAG,oDAChB,CAAC;EACF;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,QAAQA,CAChBvB,IAAI,EACJkB,IAAI,EACJO,YAAY,GAAG,IAAIJ,GAAG,CAAC,CAAC,EACxBK,WAAW,GAAG,IAAIL,GAAG,CAAC,CAAC,EACtB;EAAA,IAAAM,SAAA;EACDF,YAAY,CAACH,GAAG,CAAEJ,IAAK,CAAC;EACxBQ,WAAW,CAACJ,GAAG,CAAEJ,IAAK,CAAC;EAEvB,MAAMU,YAAY,IAAAD,SAAA,GAAG3B,IAAI,CAACK,GAAG,CAAEa,IAAK,CAAC,cAAAS,SAAA,cAAAA,SAAA,GAAI,IAAIN,GAAG,CAAC,CAAC;EAElD,KAAM,MAAMQ,UAAU,IAAID,YAAY,EAAG;IACxC,IAAK,CAAEH,YAAY,CAAC1B,GAAG,CAAE8B,UAAW,CAAC,EAAG;MACvC,IAAKN,QAAQ,CAAEvB,IAAI,EAAE6B,UAAU,EAAEJ,YAAY,EAAEC,WAAY,CAAC,EAAG;QAC9D,OAAO,IAAI;MACZ;IACD,CAAC,MAAM,IAAKA,WAAW,CAAC3B,GAAG,CAAE8B,UAAW,CAAC,EAAG;MAC3C,OAAO,IAAI;IACZ;EACD;;EAEA;EACAH,WAAW,CAACI,MAAM,CAAEZ,IAAK,CAAC;EAC1B,OAAO,KAAK;AACb"}
@@ -11,6 +11,7 @@ var _coreData = require("@wordpress/core-data");
11
11
  var _data = require("@wordpress/data");
12
12
  var _components = require("@wordpress/components");
13
13
  var _blockEditor = require("@wordpress/block-editor");
14
+ var _element = require("@wordpress/element");
14
15
  var _i18n = require("@wordpress/i18n");
15
16
  var _icons = require("@wordpress/icons");
16
17
  var _notices = require("@wordpress/notices");
@@ -55,9 +56,25 @@ function PostFeaturedImageEdit({
55
56
  scale,
56
57
  sizeSlug,
57
58
  rel,
58
- linkTarget
59
+ linkTarget,
60
+ useFirstImageFromPost
59
61
  } = attributes;
60
- const [featuredImage, setFeaturedImage] = (0, _coreData.useEntityProp)('postType', postTypeSlug, 'featured_media', postId);
62
+ const [storedFeaturedImage, setFeaturedImage] = (0, _coreData.useEntityProp)('postType', postTypeSlug, 'featured_media', postId);
63
+
64
+ // Fallback to post content if no featured image is set.
65
+ // This is needed for the "Use first image from post" option.
66
+ const [postContent] = (0, _coreData.useEntityProp)('postType', postTypeSlug, 'content', postId);
67
+ const featuredImage = (0, _element.useMemo)(() => {
68
+ if (storedFeaturedImage) {
69
+ return storedFeaturedImage;
70
+ }
71
+ if (!useFirstImageFromPost) {
72
+ return;
73
+ }
74
+ const imageOpener = /<!--\s+wp:(?:core\/)?image\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\s+\/?-->).)*)?}\s+)?-->/.exec(postContent);
75
+ const imageId = imageOpener?.groups?.attrs && JSON.parse(imageOpener.groups.attrs)?.id;
76
+ return imageId;
77
+ }, [storedFeaturedImage, useFirstImageFromPost, postContent]);
61
78
  const {
62
79
  media,
63
80
  postType,
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_coreData","_data","_components","_blockEditor","_i18n","_icons","_notices","_dimensionControls","_overlay","ALLOWED_MEDIA_TYPES","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","disabledClickProps","onClick","event","preventDefault","PostFeaturedImageEdit","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","aspectRatio","height","width","scale","sizeSlug","rel","linkTarget","featuredImage","setFeaturedImage","useEntityProp","postPermalink","useSelect","select","getMedia","getPostType","getEditedEntityRecord","coreStore","link","mediaUrl","imageSizes","blockEditorStore","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","useBlockProps","style","borderProps","useBorderProps","placeholder","content","_react","createElement","Placeholder","className","classnames","withIllustration","onSelectImage","id","createErrorNotice","useDispatch","noticesStore","onUploadError","message","type","controls","Fragment","default","InspectorControls","PanelBody","title","__","ToggleControl","__nextHasNoMarginBottom","labels","singular_name","sprintf","onChange","checked","TextControl","newRel","image","href","target","imageStyles","objectFit","MediaPlaceholder","onSelect","accept","allowedTypes","onError","mediaLibraryButton","open","Button","icon","upload","variant","showTooltip","tooltipPosition","src","alt","alt_text","BlockControls","group","MediaReplaceFlow","mediaId","mediaURL","MenuItem"],"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\nimport Overlay from './overlay';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nconst disabledClickProps = {\n\tonClick: ( event ) => event.preventDefault(),\n\t'aria-disabled': true,\n};\n\nexport default function PostFeaturedImageEdit( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst {\n\t\tisLink,\n\t\taspectRatio,\n\t\theight,\n\t\twidth,\n\t\tscale,\n\t\tsizeSlug,\n\t\trel,\n\t\tlinkTarget,\n\t} = attributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { media, postType, postPermalink } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia, getPostType, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetMedia( featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t\tpostPermalink: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\tpostId\n\t\t\t\t)?.link,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug, postId ]\n\t);\n\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\tborderProps.className\n\t\t\t\t) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: !! aspectRatio && '100%',\n\t\t\t\t\twidth: !! aspectRatio && '100%',\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Page\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\n\t/**\n\t * A Post Featured Image block should not have image replacement\n\t * or upload options in the following cases:\n\t * - Is placed in a Query Loop. This is a consious decision to\n\t * prevent content editing of different posts in Query Loop, and\n\t * this could change in the future.\n\t * - Is in a context where it does not have a postId (for example\n\t * in a template or template part).\n\t */\n\tif ( ! featuredImage && ( isDescendentOfQueryLoop || ! postId ) ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ placeholder() }\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tplaceholder()\n\t\t\t\t\t) }\n\t\t\t\t\t<Overlay\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\tconst imageStyles = {\n\t\t...borderProps.style,\n\t\theight: aspectRatio ? '100%' : height,\n\t\twidth: !! aspectRatio && '100%',\n\t\tobjectFit: !! ( height || aspectRatio ) && scale,\n\t};\n\n\t/**\n\t * When the post featured image block is placed in a context where:\n\t * - It has a postId (for example in a single post)\n\t * - It is not inside a query loop\n\t * - It has no image assigned yet\n\t * Then display the placeholder with the image upload option.\n\t */\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ imageStyles }\n\t\t\t/>\n\t\t);\n\t}\n\n\t/**\n\t * When the post featured image block:\n\t * - Has an image assigned\n\t * - Is not inside a query loop\n\t * Then display the image and the image replacement option.\n\t */\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }\n\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ image }\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\timage\n\t\t\t\t) }\n\t\t\t\t<Overlay\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n"],"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AAC,CAAE7B,MAAM,GACV,IAAAoC,MAAA,CAAAC,aAAA;IACC8B,IAAI,EAAGxD,aAAe;IACtByD,MAAM,EAAG7D,UAAY;IAAA,GAChBvB;EAAkB,GAErBkF,KACA,CAAC,GAEJA,KACA,EACD,IAAA9B,MAAA,CAAAC,aAAA,EAAC7D,QAAA,CAAA4E,OAAO;IACP9D,UAAU,EAAGA,UAAY;IACzBC,aAAa,EAAGA,aAAe;IAC/BF,QAAQ,EAAGA;EAAU,CACrB,CACM,CACP,CAAC;AAEL"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_coreData","_data","_components","_blockEditor","_element","_i18n","_icons","_notices","_dimensionControls","_overlay","ALLOWED_MEDIA_TYPES","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","disabledClickProps","onClick","event","preventDefault","PostFeaturedImageEdit","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","aspectRatio","height","width","scale","sizeSlug","rel","linkTarget","useFirstImageFromPost","storedFeaturedImage","setFeaturedImage","useEntityProp","postContent","featuredImage","useMemo","imageOpener","exec","imageId","groups","attrs","JSON","parse","id","postPermalink","useSelect","select","getMedia","getPostType","getEditedEntityRecord","coreStore","link","mediaUrl","imageSizes","blockEditorStore","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","useBlockProps","style","borderProps","useBorderProps","placeholder","content","_react","createElement","Placeholder","className","classnames","withIllustration","onSelectImage","createErrorNotice","useDispatch","noticesStore","onUploadError","message","type","controls","Fragment","default","InspectorControls","PanelBody","title","__","ToggleControl","__nextHasNoMarginBottom","labels","singular_name","sprintf","onChange","checked","TextControl","newRel","image","href","target","imageStyles","objectFit","MediaPlaceholder","onSelect","accept","allowedTypes","onError","mediaLibraryButton","open","Button","icon","upload","variant","showTooltip","tooltipPosition","src","alt","alt_text","BlockControls","group","MediaReplaceFlow","mediaId","mediaURL","MenuItem"],"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\nimport Overlay from './overlay';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nconst disabledClickProps = {\n\tonClick: ( event ) => event.preventDefault(),\n\t'aria-disabled': true,\n};\n\nexport default function PostFeaturedImageEdit( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst {\n\t\tisLink,\n\t\taspectRatio,\n\t\theight,\n\t\twidth,\n\t\tscale,\n\t\tsizeSlug,\n\t\trel,\n\t\tlinkTarget,\n\t\tuseFirstImageFromPost,\n\t} = attributes;\n\n\tconst [ storedFeaturedImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\t// Fallback to post content if no featured image is set.\n\t// This is needed for the \"Use first image from post\" option.\n\tconst [ postContent ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'content',\n\t\tpostId\n\t);\n\n\tconst featuredImage = useMemo( () => {\n\t\tif ( storedFeaturedImage ) {\n\t\t\treturn storedFeaturedImage;\n\t\t}\n\n\t\tif ( ! useFirstImageFromPost ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst imageOpener =\n\t\t\t/<!--\\s+wp:(?:core\\/)?image\\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\\s+\\/?-->).)*)?}\\s+)?-->/.exec(\n\t\t\t\tpostContent\n\t\t\t);\n\t\tconst imageId =\n\t\t\timageOpener?.groups?.attrs &&\n\t\t\tJSON.parse( imageOpener.groups.attrs )?.id;\n\t\treturn imageId;\n\t}, [ storedFeaturedImage, useFirstImageFromPost, postContent ] );\n\n\tconst { media, postType, postPermalink } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia, getPostType, getEditedEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetMedia( featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t\tpostPermalink: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\tpostId\n\t\t\t\t)?.link,\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug, postId ]\n\t);\n\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height, aspectRatio },\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\tborderProps.className\n\t\t\t\t) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\tstyle={ {\n\t\t\t\t\theight: !! aspectRatio && '100%',\n\t\t\t\t\twidth: !! aspectRatio && '100%',\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Page\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\n\t/**\n\t * A Post Featured Image block should not have image replacement\n\t * or upload options in the following cases:\n\t * - Is placed in a Query Loop. This is a consious decision to\n\t * prevent content editing of different posts in Query Loop, and\n\t * this could change in the future.\n\t * - Is in a context where it does not have a postId (for example\n\t * in a template or template part).\n\t */\n\tif ( ! featuredImage && ( isDescendentOfQueryLoop || ! postId ) ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ placeholder() }\n\t\t\t\t\t\t</a>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tplaceholder()\n\t\t\t\t\t) }\n\t\t\t\t\t<Overlay\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\tconst imageStyles = {\n\t\t...borderProps.style,\n\t\theight: aspectRatio ? '100%' : height,\n\t\twidth: !! aspectRatio && '100%',\n\t\tobjectFit: !! ( height || aspectRatio ) && scale,\n\t};\n\n\t/**\n\t * When the post featured image block is placed in a context where:\n\t * - It has a postId (for example in a single post)\n\t * - It is not inside a query loop\n\t * - It has no image assigned yet\n\t * Then display the placeholder with the image upload option.\n\t */\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ imageStyles }\n\t\t\t/>\n\t\t);\n\t}\n\n\t/**\n\t * When the post featured image block:\n\t * - Has an image assigned\n\t * - Is not inside a query loop\n\t * Then display the image and the image replacement option.\n\t */\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }\n\t\t\t\t{ !! isLink ? (\n\t\t\t\t\t<a\n\t\t\t\t\t\thref={ postPermalink }\n\t\t\t\t\t\ttarget={ linkTarget }\n\t\t\t\t\t\t{ ...disabledClickProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ image }\n\t\t\t\t\t</a>\n\t\t\t\t) : (\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72
+ type: "boolean",
73
+ "default": false
70
74
  }
71
75
  },
72
76
  usesContext: ["postId", "postType", "queryId"],
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","isLink","type","aspectRatio","width","height","scale","sizeSlug","rel","attribute","linkTarget","overlayColor","customOverlayColor","dimRatio","gradient","customGradient","usesContext","supports","align","color","__experimentalDuotone","text","background","__experimentalBorder","radius","__experimentalSelector","__experimentalSkipSerialization","__experimentalDefaultControls","html","spacing","margin","padding","editorStyle","style","exports","settings","icon","edit","init","initBlock"],"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postFeaturedImage as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,MAAA;MAAAC,IAAA;MAAA;IAAA;IAAAC,WAAA;MAAAD,IAAA;IAAA;IAAAE,KAAA;MAAAF,IAAA;IAAA;IAAAG,MAAA;MAAAH,IAAA;IAAA;IAAAI,KAAA;MAAAJ,IAAA;MAAA;IAAA;IAAAK,QAAA;MAAAL,IAAA;IAAA;IAAAM,GAAA;MAAAN,IAAA;MAAAO,SAAA;MAAA;IAAA;IAAAC,UAAA;MAAAR,IAAA;MAAA;IAAA;IAAAS,YAAA;MAAAT,IAAA;IAAA;IAAAU,kBAAA;MAAAV,IAAA;IAAA;IAAAW,QAAA;MAAAX,IAAA;MAAA;IAAA;IAAAY,QAAA;MAAAZ,IAAA;IAAA;IAAAa,cAAA;MAAAb,IAAA;IAAA;EAAA;EAAAc,WAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,KAAA;MAAAC,qBAAA;MAAAC,IAAA;MAAAC,UAAA;IAAA;IAAAC,oBAAA;MAAAJ,KAAA;MAAAK,MAAA;MAAApB,KAAA;MAAAqB,sBAAA;MAAAC,+BAAA;MAAAC,6BAAA;QAAAR,KAAA;QAAAK,MAAA;QAAApB,KAAA;MAAA;IAAA;IAAAwB,IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;IAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAAAC,OAAA,CAAA1C,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAAC0C,OAAA,CAAAvC,IAAA,GAAAA,IAAA;AAGnB,MAAMwC,QAAQ,GAAG;EACvBC,IAAI,EAAJA,wBAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE5C,IAAI;EAAEH,QAAQ;EAAE2C;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","isLink","type","aspectRatio","width","height","scale","sizeSlug","rel","attribute","linkTarget","overlayColor","customOverlayColor","dimRatio","gradient","customGradient","useFirstImageFromPost","usesContext","supports","align","color","__experimentalDuotone","text","background","__experimentalBorder","radius","__experimentalSelector","__experimentalSkipSerialization","__experimentalDefaultControls","html","spacing","margin","padding","editorStyle","style","exports","settings","icon","edit","init","initBlock"],"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postFeaturedImage as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAI,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,MAAA;MAAAC,IAAA;MAAA;IAAA;IAAAC,WAAA;MAAAD,IAAA;IAAA;IAAAE,KAAA;MAAAF,IAAA;IAAA;IAAAG,MAAA;MAAAH,IAAA;IAAA;IAAAI,KAAA;MAAAJ,IAAA;MAAA;IAAA;IAAAK,QAAA;MAAAL,IAAA;IAAA;IAAAM,GAAA;MAAAN,IAAA;MAAAO,SAAA;MAAA;IAAA;IAAAC,UAAA;MAAAR,IAAA;MAAA;IAAA;IAAAS,YAAA;MAAAT,IAAA;IAAA;IAAAU,kBAAA;MAAAV,IAAA;IAAA;IAAAW,QAAA;MAAAX,IAAA;MAAA;IAAA;IAAAY,QAAA;MAAAZ,IAAA;IAAA;IAAAa,cAAA;MAAAb,IAAA;IAAA;IAAAc,qBAAA;MAAAd,IAAA;MAAA;IAAA;EAAA;EAAAe,WAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,KAAA;MAAAC,qBAAA;MAAAC,IAAA;MAAAC,UAAA;IAAA;IAAAC,oBAAA;MAAAJ,KAAA;MAAAK,MAAA;MAAArB,KAAA;MAAAsB,sBAAA;MAAAC,+BAAA;MAAAC,6BAAA;QAAAR,KAAA;QAAAK,MAAA;QAAArB,KAAA;MAAA;IAAA;IAAAyB,IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;IAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAAAC,OAAA,CAAA3C,QAAA,GAAAA,QAAA;AAOA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAAC2C,OAAA,CAAAxC,IAAA,GAAAA,IAAA;AAGnB,MAAMyC,QAAQ,GAAG;EACvBC,IAAI,EAAJA,wBAAI;EACJC,IAAI,EAAJA;AACD,CAAC;AAACH,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMG,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE7C,IAAI;EAAEH,QAAQ;EAAE4C;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAI,IAAA,GAAAA,IAAA"}
@@ -72,9 +72,7 @@ const metadata = {
72
72
  __experimentalTextDecoration: true,
73
73
  __experimentalLetterSpacing: true,
74
74
  __experimentalDefaultControls: {
75
- fontSize: true,
76
- fontAppearance: true,
77
- textTransform: true
75
+ fontSize: true
78
76
  }
79
77
  }
80
78
  },
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","_deprecated","metadata","$schema","apiVersion","name","title","category","description","textdomain","usesContext","attributes","textAlign","type","level","isLink","rel","attribute","linkTarget","supports","align","html","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","fontAppearance","textTransform","style","exports","settings","icon","edit","deprecated","init","initBlock"],"sources":["@wordpress/block-library/src/post-title/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { title as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;AAGA;AACA;AACA;AAFA,MAAAK,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;IAAAC,KAAA;MAAAD,IAAA;MAAA;IAAA;IAAAE,MAAA;MAAAF,IAAA;MAAA;IAAA;IAAAG,GAAA;MAAAH,IAAA;MAAAI,SAAA;MAAA;IAAA;IAAAC,UAAA;MAAAL,IAAA;MAAA;IAAA;EAAA;EAAAM,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;QAAAH,IAAA;MAAA;IAAA;IAAAI,OAAA;MAAAC,MAAA;MAAAC,OAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;QAAAQ,cAAA;QAAAC,aAAA;MAAA;IAAA;EAAA;EAAAC,KAAA;AAAA;AAAAC,OAAA,CAAAzC,QAAA,GAAAA,QAAA;AAQA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACyC,OAAA,CAAAtC,IAAA,GAAAA,IAAA;AAGnB,MAAMuC,QAAQ,GAAG;EACvBC,IAAI,EAAJA,YAAI;EACJC,IAAI,EAAJA,aAAI;EACJC,UAAU,EAAVA;AACD,CAAC;AAACJ,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMI,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE5C,IAAI;EAAEH,QAAQ;EAAE0C;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAK,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_icons","require","_initBlock","_interopRequireDefault","_edit","_deprecated","metadata","$schema","apiVersion","name","title","category","description","textdomain","usesContext","attributes","textAlign","type","level","isLink","rel","attribute","linkTarget","supports","align","html","color","gradients","link","__experimentalDefaultControls","background","text","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","style","exports","settings","icon","edit","deprecated","init","initBlock"],"sources":["@wordpress/block-library/src/post-title/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { title as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AAXA;AACA;AACA;AAGA;AACA;AACA;A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: "string",
31
- source: "html",
30
+ type: "rich-text",
31
+ source: "rich-text",
32
32
  selector: "pre",
33
- "default": "",
34
33
  __unstablePreserveWhiteSpace: true,
35
34
  __experimentalRole: "content"
36
35
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","supports","anchor","color","gradients","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","style","exports","settings","icon","example","__","transforms","edit","save","merge","attributesToMerge","init","initBlock"],"sources":["@wordpress/block-library/src/preformatted/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\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\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nex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A,aAAI;EACJC,IAAI,EAAJA,aAAI;EACJC,KAAKA,CAAEnC,UAAU,EAAEoC,iBAAiB,EAAG;IACtC,OAAO;MACNnC,OAAO,EAAED,UAAU,CAACC,OAAO,GAAG,MAAM,GAAGmC,iBAAiB,CAACnC;IAC1D,CAAC;EACF;AACD,CAAC;AAAC0B,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMS,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE3C,IAAI;EAAEH,QAAQ;EAAEoC;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAU,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","supports","anchor","color","gradients","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","style","exports","settings","icon","example","__","transforms","edit","save","merge","attributesToMerge","init","initBlock"],"sources":["@wordpress/block-library/src/preformatted/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { preformatted as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\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\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Preformatted block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'EXT. XANADU - FAINT DAWN - 1940 (MINIATURE)\\nWindow, very small in the distance, illuminated.\\nAll around this is an almost totally black screen. Now, as the camera moves slowly towards the window which is almost a postage stamp in the frame, other forms appear;'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,WAAA,GAAAH,sBAAA,CAAAH,OAAA;AAbA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAO,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAAC,4BAAA;MAAAC,kBAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,MAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;EAAAQ,KAAA;AAAA;AAAAC,OAAA,CAAAnC,QAAA,GAAAA,QAAA;AASA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACmC,O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