@wordpress/block-library 11.1.0 → 11.2.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 (444) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/accordion-heading/block.json +1 -0
  3. package/build/archives/block.json +3 -0
  4. package/build/audio/edit.cjs +2 -1
  5. package/build/audio/edit.cjs.map +2 -2
  6. package/build/avatar/block.json +4 -0
  7. package/build/avatar/edit.cjs +31 -1
  8. package/build/avatar/edit.cjs.map +3 -3
  9. package/build/button/block.json +6 -0
  10. package/build/button/edit.cjs +9 -6
  11. package/build/button/edit.cjs.map +2 -2
  12. package/build/buttons/block.json +6 -1
  13. package/build/code/block.json +4 -0
  14. package/build/column/edit.cjs +5 -0
  15. package/build/column/edit.cjs.map +2 -2
  16. package/build/columns/block.json +4 -0
  17. package/build/columns/edit.cjs +21 -112
  18. package/build/columns/edit.cjs.map +3 -3
  19. package/build/comments/edit/placeholder.cjs +95 -87
  20. package/build/comments/edit/placeholder.cjs.map +2 -2
  21. package/build/comments-pagination/block.json +11 -0
  22. package/build/cover/block.json +2 -1
  23. package/build/cover/edit/index.cjs +26 -5
  24. package/build/cover/edit/index.cjs.map +2 -2
  25. package/build/cover/edit/inspector-controls.cjs +4 -1
  26. package/build/cover/edit/inspector-controls.cjs.map +2 -2
  27. package/build/cover/embed-video-utils.cjs +9 -8
  28. package/build/cover/embed-video-utils.cjs.map +2 -2
  29. package/build/cover/view.cjs +21 -0
  30. package/build/cover/view.cjs.map +7 -0
  31. package/build/details/block.json +3 -0
  32. package/build/embed/block.json +6 -1
  33. package/build/file/block.json +5 -0
  34. package/build/footnotes/block.json +4 -0
  35. package/build/gallery/block.json +13 -0
  36. package/build/gallery/dynamic-gallery.cjs +32 -93
  37. package/build/gallery/dynamic-gallery.cjs.map +3 -3
  38. package/build/gallery/edit.cjs +103 -40
  39. package/build/gallery/edit.cjs.map +2 -2
  40. package/build/gallery/order-controls.cjs +107 -0
  41. package/build/gallery/order-controls.cjs.map +7 -0
  42. package/build/gallery/order-images.cjs +92 -0
  43. package/build/gallery/order-images.cjs.map +7 -0
  44. package/build/gallery/order-options.cjs +62 -0
  45. package/build/gallery/order-options.cjs.map +7 -0
  46. package/build/gallery/use-dynamic-gallery.cjs +1 -7
  47. package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
  48. package/build/gallery/use-get-media.cjs +2 -3
  49. package/build/gallery/use-get-media.cjs.map +2 -2
  50. package/build/group/edit.cjs +3 -3
  51. package/build/group/edit.cjs.map +2 -2
  52. package/build/heading/block.json +5 -0
  53. package/build/home-link/block.json +12 -0
  54. package/build/icon/components/custom-inserter/index.cjs +3 -1
  55. package/build/icon/components/custom-inserter/index.cjs.map +2 -2
  56. package/build/icon/edit.cjs +49 -5
  57. package/build/icon/edit.cjs.map +2 -2
  58. package/build/image/use-open-image-media-editor-modal.cjs +32 -28
  59. package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
  60. package/build/image/view.cjs +44 -50
  61. package/build/image/view.cjs.map +2 -2
  62. package/build/latest-comments/block.json +10 -0
  63. package/build/latest-posts/block.json +4 -0
  64. package/build/list/block.json +12 -1
  65. package/build/list-item/block.json +8 -1
  66. package/build/list-item/index.cjs +4 -0
  67. package/build/list-item/index.cjs.map +3 -3
  68. package/build/loginout/block.json +4 -0
  69. package/build/math/block.json +4 -0
  70. package/build/media-text/block.json +18 -0
  71. package/build/navigation-link/link-ui/index.cjs +33 -19
  72. package/build/navigation-link/link-ui/index.cjs.map +2 -2
  73. package/build/navigation-link/shared/index.cjs +5 -0
  74. package/build/navigation-link/shared/index.cjs.map +2 -2
  75. package/build/navigation-link/shared/use-block-suggestions.cjs +141 -0
  76. package/build/navigation-link/shared/use-block-suggestions.cjs.map +7 -0
  77. package/build/page-list/block.json +4 -0
  78. package/build/paragraph/block.json +1 -0
  79. package/build/post-author-biography/block.json +1 -0
  80. package/build/post-comments-form/block.json +5 -0
  81. package/build/post-content/block.json +2 -1
  82. package/build/post-excerpt/block.json +4 -0
  83. package/build/post-featured-image/block.json +1 -0
  84. package/build/post-featured-image/edit.cjs +1 -1
  85. package/build/post-featured-image/edit.cjs.map +2 -2
  86. package/build/post-terms/block.json +4 -0
  87. package/build/post-time-to-read/block.json +4 -0
  88. package/build/post-title/block.json +4 -0
  89. package/build/preformatted/block.json +4 -0
  90. package/build/pullquote/block.json +2 -1
  91. package/build/query-no-results/block.json +4 -0
  92. package/build/query-pagination/block.json +17 -0
  93. package/build/query-total/block.json +4 -0
  94. package/build/quote/block.json +2 -0
  95. package/build/read-more/block.json +5 -0
  96. package/build/rss/block.json +4 -0
  97. package/build/search/block.json +2 -1
  98. package/build/site-tagline/block.json +4 -0
  99. package/build/site-title/block.json +4 -0
  100. package/build/social-links/block.json +1 -0
  101. package/build/tab-list/block.json +4 -0
  102. package/build/tab-list/edit.cjs +3 -1
  103. package/build/tab-list/edit.cjs.map +3 -3
  104. package/build/tab-list/save.cjs +3 -1
  105. package/build/tab-list/save.cjs.map +3 -3
  106. package/build/tab-panels/block.json +3 -0
  107. package/build/tabs/block.json +3 -0
  108. package/build/term-count/block.json +5 -0
  109. package/build/term-description/block.json +4 -0
  110. package/build/term-name/block.json +6 -1
  111. package/build/term-template/block.json +4 -0
  112. package/build/utils/waveform-utils.cjs +2 -2
  113. package/build/utils/waveform-utils.cjs.map +2 -2
  114. package/build/verse/block.json +4 -0
  115. package/build/video/block.json +7 -1
  116. package/build/video/edit.cjs +10 -2
  117. package/build/video/edit.cjs.map +2 -2
  118. package/build-module/accordion-heading/block.json +1 -0
  119. package/build-module/archives/block.json +3 -0
  120. package/build-module/audio/edit.mjs +2 -1
  121. package/build-module/audio/edit.mjs.map +2 -2
  122. package/build-module/avatar/block.json +4 -0
  123. package/build-module/avatar/edit.mjs +33 -2
  124. package/build-module/avatar/edit.mjs.map +2 -2
  125. package/build-module/button/block.json +6 -0
  126. package/build-module/button/edit.mjs +11 -7
  127. package/build-module/button/edit.mjs.map +2 -2
  128. package/build-module/buttons/block.json +6 -1
  129. package/build-module/code/block.json +4 -0
  130. package/build-module/column/edit.mjs +5 -0
  131. package/build-module/column/edit.mjs.map +2 -2
  132. package/build-module/columns/block.json +4 -0
  133. package/build-module/columns/edit.mjs +22 -122
  134. package/build-module/columns/edit.mjs.map +2 -2
  135. package/build-module/comments/edit/placeholder.mjs +95 -87
  136. package/build-module/comments/edit/placeholder.mjs.map +2 -2
  137. package/build-module/comments-pagination/block.json +11 -0
  138. package/build-module/cover/block.json +2 -1
  139. package/build-module/cover/edit/index.mjs +32 -6
  140. package/build-module/cover/edit/index.mjs.map +2 -2
  141. package/build-module/cover/edit/inspector-controls.mjs +5 -2
  142. package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
  143. package/build-module/cover/embed-video-utils.mjs +9 -8
  144. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  145. package/build-module/cover/view.mjs +19 -0
  146. package/build-module/cover/view.mjs.map +7 -0
  147. package/build-module/details/block.json +3 -0
  148. package/build-module/embed/block.json +6 -1
  149. package/build-module/file/block.json +5 -0
  150. package/build-module/footnotes/block.json +4 -0
  151. package/build-module/gallery/block.json +13 -0
  152. package/build-module/gallery/dynamic-gallery.mjs +33 -97
  153. package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
  154. package/build-module/gallery/edit.mjs +110 -42
  155. package/build-module/gallery/edit.mjs.map +2 -2
  156. package/build-module/gallery/order-controls.mjs +87 -0
  157. package/build-module/gallery/order-controls.mjs.map +7 -0
  158. package/build-module/gallery/order-images.mjs +66 -0
  159. package/build-module/gallery/order-images.mjs.map +7 -0
  160. package/build-module/gallery/order-options.mjs +33 -0
  161. package/build-module/gallery/order-options.mjs.map +7 -0
  162. package/build-module/gallery/use-dynamic-gallery.mjs +1 -7
  163. package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
  164. package/build-module/gallery/use-get-media.mjs +2 -3
  165. package/build-module/gallery/use-get-media.mjs.map +2 -2
  166. package/build-module/group/edit.mjs +4 -4
  167. package/build-module/group/edit.mjs.map +2 -2
  168. package/build-module/heading/block.json +5 -0
  169. package/build-module/home-link/block.json +12 -0
  170. package/build-module/icon/components/custom-inserter/index.mjs +3 -1
  171. package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
  172. package/build-module/icon/edit.mjs +50 -6
  173. package/build-module/icon/edit.mjs.map +2 -2
  174. package/build-module/image/use-open-image-media-editor-modal.mjs +32 -28
  175. package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
  176. package/build-module/image/view.mjs +44 -50
  177. package/build-module/image/view.mjs.map +2 -2
  178. package/build-module/latest-comments/block.json +10 -0
  179. package/build-module/latest-posts/block.json +4 -0
  180. package/build-module/list/block.json +12 -1
  181. package/build-module/list-item/block.json +8 -1
  182. package/build-module/list-item/index.mjs +4 -0
  183. package/build-module/list-item/index.mjs.map +2 -2
  184. package/build-module/loginout/block.json +4 -0
  185. package/build-module/math/block.json +4 -0
  186. package/build-module/media-text/block.json +18 -0
  187. package/build-module/navigation-link/link-ui/index.mjs +39 -20
  188. package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
  189. package/build-module/navigation-link/shared/index.mjs +6 -0
  190. package/build-module/navigation-link/shared/index.mjs.map +2 -2
  191. package/build-module/navigation-link/shared/use-block-suggestions.mjs +120 -0
  192. package/build-module/navigation-link/shared/use-block-suggestions.mjs.map +7 -0
  193. package/build-module/page-list/block.json +4 -0
  194. package/build-module/paragraph/block.json +1 -0
  195. package/build-module/post-author-biography/block.json +1 -0
  196. package/build-module/post-comments-form/block.json +5 -0
  197. package/build-module/post-content/block.json +2 -1
  198. package/build-module/post-excerpt/block.json +4 -0
  199. package/build-module/post-featured-image/block.json +1 -0
  200. package/build-module/post-featured-image/edit.mjs +1 -1
  201. package/build-module/post-featured-image/edit.mjs.map +2 -2
  202. package/build-module/post-terms/block.json +4 -0
  203. package/build-module/post-time-to-read/block.json +4 -0
  204. package/build-module/post-title/block.json +4 -0
  205. package/build-module/preformatted/block.json +4 -0
  206. package/build-module/pullquote/block.json +2 -1
  207. package/build-module/query-no-results/block.json +4 -0
  208. package/build-module/query-pagination/block.json +17 -0
  209. package/build-module/query-total/block.json +4 -0
  210. package/build-module/quote/block.json +2 -0
  211. package/build-module/read-more/block.json +5 -0
  212. package/build-module/rss/block.json +4 -0
  213. package/build-module/search/block.json +2 -1
  214. package/build-module/site-tagline/block.json +4 -0
  215. package/build-module/site-title/block.json +4 -0
  216. package/build-module/social-links/block.json +1 -0
  217. package/build-module/tab-list/block.json +4 -0
  218. package/build-module/tab-list/edit.mjs +4 -1
  219. package/build-module/tab-list/edit.mjs.map +2 -2
  220. package/build-module/tab-list/save.mjs +4 -1
  221. package/build-module/tab-list/save.mjs.map +2 -2
  222. package/build-module/tab-panels/block.json +3 -0
  223. package/build-module/tabs/block.json +3 -0
  224. package/build-module/term-count/block.json +5 -0
  225. package/build-module/term-description/block.json +4 -0
  226. package/build-module/term-name/block.json +6 -1
  227. package/build-module/term-template/block.json +4 -0
  228. package/build-module/utils/waveform-utils.mjs +1 -1
  229. package/build-module/utils/waveform-utils.mjs.map +1 -1
  230. package/build-module/verse/block.json +4 -0
  231. package/build-module/video/block.json +7 -1
  232. package/build-module/video/edit.mjs +10 -2
  233. package/build-module/video/edit.mjs.map +2 -2
  234. package/build-style/avatar/editor-rtl.css +4 -0
  235. package/build-style/avatar/editor.css +4 -0
  236. package/build-style/comments-pagination/style-rtl.css +3 -0
  237. package/build-style/comments-pagination/style.css +3 -0
  238. package/build-style/common-rtl.css +32 -1
  239. package/build-style/common.css +35 -2
  240. package/build-style/editor-rtl.css +11 -4
  241. package/build-style/editor.css +11 -4
  242. package/build-style/embed/style-rtl.css +4 -1
  243. package/build-style/embed/style.css +4 -1
  244. package/build-style/gallery/editor-rtl.css +1 -3
  245. package/build-style/gallery/editor.css +1 -3
  246. package/build-style/image/style-rtl.css +11 -2
  247. package/build-style/image/style.css +11 -2
  248. package/build-style/media-text/style-rtl.css +4 -1
  249. package/build-style/media-text/style.css +4 -1
  250. package/build-style/query-pagination/style-rtl.css +3 -0
  251. package/build-style/query-pagination/style.css +3 -0
  252. package/build-style/style-rtl.css +70 -9
  253. package/build-style/style.css +73 -10
  254. package/build-style/table/editor-rtl.css +6 -1
  255. package/build-style/table/editor.css +6 -1
  256. package/build-style/table/style-rtl.css +4 -2
  257. package/build-style/table/style.css +4 -2
  258. package/build-style/tag-cloud/style-rtl.css +1 -1
  259. package/build-style/tag-cloud/style.css +1 -1
  260. package/build-style/verse/style-rtl.css +8 -1
  261. package/build-style/verse/style.css +8 -1
  262. package/build-types/gallery/order-controls.d.ts +58 -0
  263. package/build-types/gallery/order-controls.d.ts.map +1 -0
  264. package/build-types/gallery/order-options.d.ts +67 -0
  265. package/build-types/gallery/order-options.d.ts.map +1 -0
  266. package/package.json +44 -41
  267. package/src/accordion-heading/README.md +1 -0
  268. package/src/accordion-heading/block.json +1 -0
  269. package/src/archives/README.md +2 -0
  270. package/src/archives/block.json +3 -0
  271. package/src/audio/edit.jsx +2 -1
  272. package/src/avatar/README.md +2 -0
  273. package/src/avatar/block.json +4 -0
  274. package/src/avatar/edit.jsx +48 -2
  275. package/src/avatar/editor.scss +4 -0
  276. package/src/avatar/index.php +5 -3
  277. package/src/breadcrumbs/index.php +1 -1
  278. package/src/button/README.md +4 -0
  279. package/src/button/block.json +6 -0
  280. package/src/button/edit.jsx +47 -52
  281. package/src/button/index.php +47 -0
  282. package/src/buttons/README.md +4 -0
  283. package/src/buttons/block.json +6 -1
  284. package/src/code/README.md +3 -0
  285. package/src/code/block.json +4 -0
  286. package/src/column/edit.jsx +6 -0
  287. package/src/columns/README.md +3 -0
  288. package/src/columns/block.json +4 -0
  289. package/src/columns/edit.jsx +1 -131
  290. package/src/comments/edit/placeholder.jsx +5 -1
  291. package/src/comments-pagination/README.md +4 -0
  292. package/src/comments-pagination/block.json +11 -0
  293. package/src/comments-pagination/style.scss +3 -0
  294. package/src/common.scss +38 -0
  295. package/src/cover/README.md +1 -0
  296. package/src/cover/block.json +2 -1
  297. package/src/cover/edit/index.jsx +38 -6
  298. package/src/cover/edit/inspector-controls.jsx +10 -1
  299. package/src/cover/embed-video-utils.js +18 -10
  300. package/src/cover/index.php +44 -15
  301. package/src/cover/test/edit.browser.test.js +182 -2
  302. package/src/cover/test/embed-video-utils.test.js +48 -0
  303. package/src/cover/view.js +22 -0
  304. package/src/details/README.md +2 -0
  305. package/src/details/block.json +3 -0
  306. package/src/embed/README.md +4 -0
  307. package/src/embed/block.json +6 -1
  308. package/src/embed/style.scss +7 -1
  309. package/src/file/README.md +4 -0
  310. package/src/file/block.json +5 -0
  311. package/src/footnotes/README.md +3 -0
  312. package/src/footnotes/block.json +4 -0
  313. package/src/gallery/README.md +13 -0
  314. package/src/gallery/block.json +13 -0
  315. package/src/gallery/dynamic-gallery.jsx +11 -91
  316. package/src/gallery/edit.jsx +146 -47
  317. package/src/gallery/editor.scss +5 -9
  318. package/src/gallery/order-controls.tsx +143 -0
  319. package/src/gallery/order-images.js +111 -0
  320. package/src/gallery/order-options.ts +75 -0
  321. package/src/gallery/test/edit.jsdom.test.js +87 -10
  322. package/src/gallery/test/order-images.js +162 -0
  323. package/src/gallery/use-dynamic-gallery.js +1 -9
  324. package/src/gallery/use-get-media.js +7 -2
  325. package/src/group/edit.jsx +5 -5
  326. package/src/heading/README.md +4 -0
  327. package/src/heading/block.json +5 -0
  328. package/src/home-link/README.md +6 -0
  329. package/src/home-link/block.json +12 -0
  330. package/src/icon/components/custom-inserter/index.jsx +5 -1
  331. package/src/icon/edit.jsx +68 -7
  332. package/src/icon/index.php +1 -1
  333. package/src/image/index.php +3 -4
  334. package/src/image/style.scss +14 -2
  335. package/src/image/test/use-open-image-media-editor-modal.jsdom.test.js +122 -60
  336. package/src/image/use-open-image-media-editor-modal.js +37 -41
  337. package/src/image/view.js +64 -68
  338. package/src/latest-comments/README.md +3 -0
  339. package/src/latest-comments/block.json +10 -0
  340. package/src/latest-posts/README.md +3 -0
  341. package/src/latest-posts/block.json +4 -0
  342. package/src/list/README.md +6 -0
  343. package/src/list/block.json +12 -1
  344. package/src/list-item/README.md +6 -0
  345. package/src/list-item/block.json +8 -1
  346. package/src/list-item/index.js +5 -0
  347. package/src/loginout/README.md +3 -0
  348. package/src/loginout/block.json +4 -0
  349. package/src/math/README.md +3 -0
  350. package/src/math/block.json +4 -0
  351. package/src/media-text/README.md +17 -0
  352. package/src/media-text/block.json +18 -0
  353. package/src/media-text/style.scss +5 -1
  354. package/src/navigation/test/use-navigation-menu.jsdom.test.js +1 -1
  355. package/src/navigation-link/README.md +1 -1
  356. package/src/navigation-link/link-ui/index.jsx +60 -27
  357. package/src/navigation-link/link-ui/test/get-suggestions-query.jsdom.test.js +67 -0
  358. package/src/navigation-link/shared/index.js +4 -0
  359. package/src/navigation-link/shared/test/use-block-suggestions.jsdom.test.js +158 -0
  360. package/src/navigation-link/shared/test/use-entity-binding.jsdom.test.js +1 -7
  361. package/src/navigation-link/shared/use-block-suggestions.js +192 -0
  362. package/src/page-list/README.md +3 -0
  363. package/src/page-list/block.json +4 -0
  364. package/src/paragraph/README.md +1 -0
  365. package/src/paragraph/block.json +1 -0
  366. package/src/playlist/test/edit-component.jsdom.test.jsx +11 -11
  367. package/src/playlist-track/test/edit.jsdom.test.jsx +3 -3
  368. package/src/post-author-biography/README.md +1 -0
  369. package/src/post-author-biography/block.json +1 -0
  370. package/src/post-comments-form/README.md +3 -0
  371. package/src/post-comments-form/block.json +5 -0
  372. package/src/post-content/README.md +1 -0
  373. package/src/post-content/block.json +2 -1
  374. package/src/post-excerpt/README.md +3 -0
  375. package/src/post-excerpt/block.json +4 -0
  376. package/src/post-featured-image/block.json +1 -0
  377. package/src/post-featured-image/edit.jsx +2 -2
  378. package/src/post-terms/README.md +3 -0
  379. package/src/post-terms/block.json +4 -0
  380. package/src/post-time-to-read/README.md +3 -0
  381. package/src/post-time-to-read/block.json +4 -0
  382. package/src/post-title/README.md +3 -0
  383. package/src/post-title/block.json +4 -0
  384. package/src/preformatted/README.md +3 -0
  385. package/src/preformatted/block.json +4 -0
  386. package/src/pullquote/README.md +1 -0
  387. package/src/pullquote/block.json +2 -1
  388. package/src/query-no-results/README.md +3 -0
  389. package/src/query-no-results/block.json +4 -0
  390. package/src/query-pagination/README.md +4 -0
  391. package/src/query-pagination/block.json +17 -0
  392. package/src/query-pagination/style.scss +3 -0
  393. package/src/query-total/README.md +3 -0
  394. package/src/query-total/block.json +4 -0
  395. package/src/quote/README.md +2 -0
  396. package/src/quote/block.json +2 -0
  397. package/src/read-more/README.md +3 -0
  398. package/src/read-more/block.json +5 -0
  399. package/src/rss/README.md +3 -0
  400. package/src/rss/block.json +4 -0
  401. package/src/search/README.md +1 -0
  402. package/src/search/block.json +2 -1
  403. package/src/site-tagline/README.md +3 -0
  404. package/src/site-tagline/block.json +4 -0
  405. package/src/site-title/README.md +3 -0
  406. package/src/site-title/block.json +4 -0
  407. package/src/social-links/README.md +1 -0
  408. package/src/social-links/block.json +1 -0
  409. package/src/tab-list/README.md +2 -0
  410. package/src/tab-list/block.json +4 -0
  411. package/src/tab-list/edit.jsx +3 -0
  412. package/src/tab-list/save.jsx +3 -0
  413. package/src/tab-panels/README.md +2 -0
  414. package/src/tab-panels/block.json +3 -0
  415. package/src/table/editor.scss +8 -2
  416. package/src/table/style.scss +4 -4
  417. package/src/tabs/README.md +2 -0
  418. package/src/tabs/block.json +3 -0
  419. package/src/tag-cloud/style.scss +1 -1
  420. package/src/template-part/index.php +16 -3
  421. package/src/term-count/README.md +4 -0
  422. package/src/term-count/block.json +5 -0
  423. package/src/term-description/README.md +3 -0
  424. package/src/term-description/block.json +4 -0
  425. package/src/term-name/README.md +4 -0
  426. package/src/term-name/block.json +6 -1
  427. package/src/term-template/README.md +3 -0
  428. package/src/term-template/block.json +4 -0
  429. package/src/utils/test/waveform-player-auto-init.jsdom.test.js +25 -0
  430. package/src/utils/test/waveform-player-dependency.jsdom.test.js +7 -60
  431. package/src/utils/test/waveform-utils.browser.test.js +3 -15
  432. package/src/utils/waveform-utils.js +1 -1
  433. package/src/verse/README.md +4 -0
  434. package/src/verse/block.json +4 -0
  435. package/src/verse/style.scss +11 -2
  436. package/src/video/README.md +4 -0
  437. package/src/video/block.json +7 -1
  438. package/src/video/edit.jsx +13 -2
  439. package/build/columns/utils.cjs +0 -112
  440. package/build/columns/utils.cjs.map +0 -7
  441. package/build-module/columns/utils.mjs +0 -78
  442. package/build-module/columns/utils.mjs.map +0 -7
  443. package/src/columns/test/utils.js +0 -331
  444. package/src/columns/utils.js +0 -176
@@ -1,12 +1,9 @@
1
1
  import clsx from 'clsx';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import {
4
- Notice,
5
- RangeControl,
6
4
  ToggleControl,
7
5
  __experimentalToolsPanel as ToolsPanel,
8
6
  __experimentalToolsPanelItem as ToolsPanelItem,
9
- __experimentalVStack as VStack,
10
7
  } from '@wordpress/components';
11
8
  import {
12
9
  InspectorControls,
@@ -19,122 +16,16 @@ import {
19
16
  } from '@wordpress/block-editor';
20
17
  import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
21
18
  import {
22
- createBlock,
23
19
  createBlocksFromInnerBlocksTemplate,
24
20
  store as blocksStore,
25
21
  } from '@wordpress/blocks';
26
- import {
27
- hasExplicitPercentColumnWidths,
28
- getMappedColumnWidths,
29
- getRedistributedColumnWidths,
30
- toWidthPrecision,
31
- } from './utils';
32
22
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
33
23
 
34
24
  const DEFAULT_BLOCK = {
35
25
  name: 'core/column',
36
26
  };
37
27
 
38
- function ColumnInspectorControls( {
39
- clientId,
40
- setAttributes,
41
- isStackedOnMobile,
42
- } ) {
43
- const { count, canInsertColumnBlock, minCount } = useSelect(
44
- ( select ) => {
45
- const { canInsertBlockType, canRemoveBlock, getBlockOrder } =
46
- select( blockEditorStore );
47
- const blockOrder = getBlockOrder( clientId );
48
-
49
- // Get the indexes of columns for which removal is prevented.
50
- // The highest index will be used to determine the minimum column count.
51
- const preventRemovalBlockIndexes = blockOrder.reduce(
52
- ( acc, blockId, index ) => {
53
- if ( ! canRemoveBlock( blockId ) ) {
54
- acc.push( index );
55
- }
56
- return acc;
57
- },
58
- []
59
- );
60
-
61
- return {
62
- count: blockOrder.length,
63
- canInsertColumnBlock: canInsertBlockType(
64
- 'core/column',
65
- clientId
66
- ),
67
- minCount: Math.max( ...preventRemovalBlockIndexes ) + 1,
68
- };
69
- },
70
- [ clientId ]
71
- );
72
- const { getBlocks } = useSelect( blockEditorStore );
73
- const { replaceInnerBlocks } = useDispatch( blockEditorStore );
74
-
75
- /**
76
- * Updates the column count, including necessary revisions to child Column
77
- * blocks to grant required or redistribute available space.
78
- *
79
- * @param {number} previousColumns Previous column count.
80
- * @param {number} newColumns New column count.
81
- */
82
- function updateColumns( previousColumns, newColumns ) {
83
- let innerBlocks = getBlocks( clientId );
84
- const hasExplicitWidths = hasExplicitPercentColumnWidths( innerBlocks );
85
-
86
- // Redistribute available width for existing inner blocks.
87
- const isAddingColumn = newColumns > previousColumns;
88
-
89
- if ( isAddingColumn && hasExplicitWidths ) {
90
- // If adding a new column, assign width to the new column equal to
91
- // as if it were `1 / columns` of the total available space.
92
- const newColumnWidth = toWidthPrecision( 100 / newColumns );
93
- const newlyAddedColumns = newColumns - previousColumns;
94
-
95
- // Redistribute in consideration of pending block insertion as
96
- // constraining the available working width.
97
- const widths = getRedistributedColumnWidths(
98
- innerBlocks,
99
- 100 - newColumnWidth * newlyAddedColumns
100
- );
101
-
102
- innerBlocks = [
103
- ...getMappedColumnWidths( innerBlocks, widths ),
104
- ...Array.from( {
105
- length: newlyAddedColumns,
106
- } ).map( () => {
107
- return createBlock( 'core/column', {
108
- width: `${ newColumnWidth }%`,
109
- } );
110
- } ),
111
- ];
112
- } else if ( isAddingColumn ) {
113
- innerBlocks = [
114
- ...innerBlocks,
115
- ...Array.from( {
116
- length: newColumns - previousColumns,
117
- } ).map( () => {
118
- return createBlock( 'core/column' );
119
- } ),
120
- ];
121
- } else if ( newColumns < previousColumns ) {
122
- // The removed column will be the last of the inner blocks.
123
- innerBlocks = innerBlocks.slice(
124
- 0,
125
- -( previousColumns - newColumns )
126
- );
127
- if ( hasExplicitWidths ) {
128
- // Redistribute as if block is already removed.
129
- const widths = getRedistributedColumnWidths( innerBlocks, 100 );
130
-
131
- innerBlocks = getMappedColumnWidths( innerBlocks, widths );
132
- }
133
- }
134
-
135
- replaceInnerBlocks( clientId, innerBlocks );
136
- }
137
-
28
+ function ColumnInspectorControls( { setAttributes, isStackedOnMobile } ) {
138
29
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
139
30
 
140
31
  return (
@@ -147,26 +38,6 @@ function ColumnInspectorControls( {
147
38
  } }
148
39
  dropdownMenuProps={ dropdownMenuProps }
149
40
  >
150
- { canInsertColumnBlock && (
151
- <VStack spacing={ 4 } style={ { gridColumn: '1 / -1' } }>
152
- <RangeControl
153
- label={ __( 'Columns' ) }
154
- value={ count }
155
- onChange={ ( value ) =>
156
- updateColumns( count, Math.max( minCount, value ) )
157
- }
158
- min={ Math.max( 1, minCount ) }
159
- max={ Math.max( 6, count ) }
160
- />
161
- { count > 6 && (
162
- <Notice status="warning" isDismissible={ false }>
163
- { __(
164
- 'This column count exceeds the recommended amount and may cause visual breakage.'
165
- ) }
166
- </Notice>
167
- ) }
168
- </VStack>
169
- ) }
170
41
  <ToolsPanelItem
171
42
  label={ __( 'Stack on mobile' ) }
172
43
  isShownByDefault
@@ -243,7 +114,6 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
243
114
  </BlockControls>
244
115
  <InspectorControls>
245
116
  <ColumnInspectorControls
246
- clientId={ clientId }
247
117
  setAttributes={ setAttributes }
248
118
  isStackedOnMobile={ isStackedOnMobile }
249
119
  />
@@ -3,6 +3,7 @@ import { __, _x, sprintf } from '@wordpress/i18n';
3
3
  import { useSelect } from '@wordpress/data';
4
4
  import { useEntityProp } from '@wordpress/core-data';
5
5
  import { createInterpolateElement } from '@wordpress/element';
6
+ import { inertValue } from '@wordpress/react-inert-value';
6
7
  import CommentsForm from '../../post-comments-form/form';
7
8
 
8
9
  export default function PostCommentsPlaceholder( { postType, postId } ) {
@@ -17,7 +18,10 @@ export default function PostCommentsPlaceholder( { postType, postId } ) {
17
18
  );
18
19
 
19
20
  return (
20
- <div className="wp-block-comments__legacy-placeholder" inert="true">
21
+ <div
22
+ className="wp-block-comments__legacy-placeholder"
23
+ inert={ inertValue( true ) }
24
+ >
21
25
  <h3>
22
26
  {
23
27
  /* translators: %s: Post title. */
@@ -43,6 +43,10 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
43
43
  - [`allowSwitching`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowswitching): `false`
44
44
  - [`allowInheriting`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowinheriting): `false`
45
45
  - [`default`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-default): `{"type":"flex"}`
46
+ - [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
47
+ - `padding`: `true`
48
+ - `margin`: `true`
49
+ - `blockGap`: `true`
46
50
  - [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
47
51
  - [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
48
52
  - [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
@@ -50,6 +50,11 @@
50
50
  "type": "flex"
51
51
  }
52
52
  },
53
+ "spacing": {
54
+ "padding": true,
55
+ "margin": true,
56
+ "blockGap": true
57
+ },
53
58
  "typography": {
54
59
  "fontSize": true,
55
60
  "lineHeight": true,
@@ -63,6 +68,12 @@
63
68
  "fontSize": true
64
69
  }
65
70
  },
71
+ "__experimentalBorder": {
72
+ "color": true,
73
+ "radius": true,
74
+ "style": true,
75
+ "width": true
76
+ },
66
77
  "interactivity": {
67
78
  "clientNavigation": true
68
79
  }
@@ -1,5 +1,8 @@
1
1
  $pagination-margin: 0.5em;
2
2
  .wp-block-comments-pagination {
3
+ // This block has customizable padding, border-box makes that more predictable.
4
+ box-sizing: border-box;
5
+
3
6
  // Increased specificity to override blocks default margin.
4
7
  > .wp-block-comments-pagination-next,
5
8
  > .wp-block-comments-pagination-previous,
package/src/common.scss CHANGED
@@ -243,3 +243,41 @@ html :where(.is-position-sticky) {
243
243
  --wp-admin--admin-bar--position-offset: 0px;
244
244
  }
245
245
  }
246
+
247
+ // Polyfill for two parts of MathML that MathML Core leaves out and that
248
+ // converted LaTeX relies on: the `columnalign` attribute on table cells,
249
+ // which `aligned` and `cases` need, and the `menclose` lines that `\overline`
250
+ // and `\underline` produce. Firefox and Safari render both natively, so the
251
+ // feature query limits the rules to Chromium, which implements MathML Core
252
+ // only. The rules key on the standard attributes, so they apply to any MathML
253
+ // that carries them and can go once Chromium renders them itself.
254
+ // Feature query from https://github.com/ronkok/Temml/blob/v0.10.34/dist/Temml-Local.css#L64-L65
255
+ //
256
+ // The rules live here because both the Math block and the inline math format
257
+ // produce this MathML.
258
+ //
259
+ // Mathematical notation is written left to right in every language, so
260
+ // nothing here is flipped for RTL.
261
+ /*!rtl:begin:ignore*/
262
+ @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
263
+ // Plain `text-align` does not move a cell's content in Chromium, the
264
+ // `-webkit-` values do.
265
+ mtd[columnalign="right"] {
266
+ text-align: -webkit-right;
267
+ }
268
+
269
+ mtd[columnalign="left"] {
270
+ text-align: -webkit-left;
271
+ }
272
+
273
+ menclose[notation~="top"] {
274
+ padding-top: 0.1em;
275
+ border-top: 0.065em solid;
276
+ }
277
+
278
+ menclose[notation~="bottom"] {
279
+ padding-bottom: 0.1em;
280
+ border-bottom: 0.065em solid;
281
+ }
282
+ }
283
+ /*!rtl:end:ignore*/
@@ -160,6 +160,7 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
160
160
  - [`allowJustification`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowjustification): `false`
161
161
  - [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
162
162
  - `clientNavigation`: `true`
163
+ - `interactive`: `true`
163
164
  - [`filter`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter):
164
165
  - [`duotone`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter-duotone): `true`
165
166
  - [`allowedBlocks`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#allowedblocks): `true`
@@ -153,7 +153,8 @@
153
153
  "allowJustification": false
154
154
  },
155
155
  "interactivity": {
156
- "clientNavigation": true
156
+ "clientNavigation": true,
157
+ "interactive": true
157
158
  },
158
159
  "filter": {
159
160
  "duotone": true
@@ -9,7 +9,12 @@ import {
9
9
  useState,
10
10
  } from '@wordpress/element';
11
11
  import { Placeholder, SandBox, Spinner } from '@wordpress/components';
12
- import { compose, useResizeObserver } from '@wordpress/compose';
12
+ import {
13
+ compose,
14
+ useMergeRefs,
15
+ useReducedMotion,
16
+ useResizeObserver,
17
+ } from '@wordpress/compose';
13
18
  import {
14
19
  withColors,
15
20
  ColorPalette,
@@ -445,6 +450,8 @@ function CoverEdit( {
445
450
  [ url, backgroundType ]
446
451
  );
447
452
 
453
+ const prefersReducedMotion = useReducedMotion();
454
+
448
455
  // Compute embed HTML for editor display via SandBox
449
456
  const embedHtml = useMemo( () => {
450
457
  if (
@@ -453,8 +460,10 @@ function CoverEdit( {
453
460
  ) {
454
461
  return null;
455
462
  }
456
- return getBackgroundEmbedHtml( embedPreview.html );
457
- }, [ embedPreview, backgroundType ] );
463
+ return getBackgroundEmbedHtml( embedPreview.html, {
464
+ autoplay: ! prefersReducedMotion,
465
+ } );
466
+ }, [ embedPreview, backgroundType, prefersReducedMotion ] );
458
467
 
459
468
  // Set while the media editor has pointed the cover at a freshly
460
469
  // generated file the browser hasn't finished loading; cleared by the
@@ -513,7 +522,11 @@ function CoverEdit( {
513
522
  );
514
523
 
515
524
  const ref = useRef();
516
- const blockProps = useBlockProps( { ref } );
525
+ // State, not a ref, so that the element is there on the next render.
526
+ const [ dropZoneElement, setDropZoneElement ] = useState( null );
527
+ const blockProps = useBlockProps( {
528
+ ref: useMergeRefs( [ ref, setDropZoneElement ] ),
529
+ } );
517
530
 
518
531
  const innerBlocksProps = useInnerBlocksProps(
519
532
  {
@@ -522,12 +535,20 @@ function CoverEdit( {
522
535
  {
523
536
  allowedBlocks,
524
537
  templateLock,
525
- dropZoneElement: ref.current,
538
+ dropZoneElement,
526
539
  }
527
540
  );
528
541
 
529
542
  const mediaElement = useRef();
530
543
  const editMediaButtonRef = useRef();
544
+
545
+ // `autoPlay` only applies when the video loads, so pause a video that is
546
+ // already playing when the user turns on reduced motion.
547
+ useEffect( () => {
548
+ if ( prefersReducedMotion && isVideoBackground ) {
549
+ mediaElement.current?.pause();
550
+ }
551
+ }, [ prefersReducedMotion, isVideoBackground ] );
531
552
  const currentSettings = {
532
553
  isVideoBackground,
533
554
  isImageBackground,
@@ -543,11 +564,18 @@ function CoverEdit( {
543
564
  return;
544
565
  }
545
566
 
567
+ const previousImage = { id, url: propsRef.current.attributes.url };
568
+ let isUndone = false;
546
569
  openMediaEditorModal( {
547
570
  id,
548
571
  onClose: () => {
549
572
  editMediaButtonRef.current?.focus();
550
573
  },
574
+ onUndo: () => {
575
+ isUndone = true;
576
+ setIsSwappingMedia( false );
577
+ setAttributes( previousImage );
578
+ },
551
579
  onUpdate: async ( { id: newId, url: newUrl } ) => {
552
580
  if ( typeof newId !== 'number' ) {
553
581
  return;
@@ -569,6 +597,10 @@ function CoverEdit( {
569
597
  if ( newUrl ) {
570
598
  const averageBackgroundColor =
571
599
  await getMediaColor( newUrl );
600
+ // Snackbar Undo can run while the image color is loading.
601
+ if ( isUndone ) {
602
+ return;
603
+ }
572
604
 
573
605
  // Read latest values after await to avoid stale closures.
574
606
  const {
@@ -836,7 +868,7 @@ function CoverEdit( {
836
868
  <video
837
869
  ref={ mediaElement }
838
870
  className="wp-block-cover__video-background"
839
- autoPlay
871
+ autoPlay={ ! prefersReducedMotion }
840
872
  muted
841
873
  loop
842
874
  src={ url }
@@ -10,7 +10,7 @@ import {
10
10
  __experimentalUnitControl as UnitControl,
11
11
  __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
12
12
  } from '@wordpress/components';
13
- import { useInstanceId } from '@wordpress/compose';
13
+ import { useInstanceId, useReducedMotion } from '@wordpress/compose';
14
14
  import {
15
15
  InspectorControls,
16
16
  useSettings,
@@ -227,6 +227,8 @@ export default function CoverInspectorControls( {
227
227
 
228
228
  const showFocalPointPicker = isVideoBackground || isImageBackground;
229
229
 
230
+ const prefersReducedMotion = useReducedMotion();
231
+
230
232
  const imperativeFocalPointPreview = ( value ) => {
231
233
  const [ styleOfRef, property ] = mediaElement.current
232
234
  ? [ mediaElement.current.style, 'objectPosition' ]
@@ -396,8 +398,15 @@ export default function CoverInspectorControls( {
396
398
  }
397
399
  >
398
400
  <FocalPointPicker
401
+ // `autoPlay` only applies when the
402
+ // video loads, so remount the picker
403
+ // to stop a preview that is already
404
+ // playing when the user turns on
405
+ // reduced motion.
406
+ key={ prefersReducedMotion }
399
407
  label={ __( 'Focal point' ) }
400
408
  url={ url }
409
+ autoPlay={ ! prefersReducedMotion }
401
410
  value={ focalPoint }
402
411
  onDragStart={ imperativeFocalPointPreview }
403
412
  onDrag={ imperativeFocalPointPreview }
@@ -94,17 +94,19 @@ function findVideoEmbedProvider(
94
94
  /**
95
95
  * Modifies embed HTML to use background video parameters.
96
96
  *
97
- * @param {string} html The original embed HTML.
97
+ * @param {string} html The original embed HTML.
98
+ * @param {Object} options Options.
99
+ * @param {boolean} options.autoplay Whether the video should start playing on load.
98
100
  * @return {string|null} The modified embed HTML, or null if not possible.
99
101
  */
100
- export function getBackgroundEmbedHtml( html ) {
102
+ export function getBackgroundEmbedHtml( html, { autoplay = true } = {} ) {
101
103
  const srcMatch = html?.match( /src=["']([^"']+)["']/ );
102
104
  if ( ! srcMatch ) {
103
105
  return null;
104
106
  }
105
107
 
106
108
  const iframeSrc = srcMatch[ 1 ];
107
- const backgroundSrc = getBackgroundVideoSrc( iframeSrc );
109
+ const backgroundSrc = getBackgroundVideoSrc( iframeSrc, { autoplay } );
108
110
  return html.replace( iframeSrc, backgroundSrc );
109
111
  }
110
112
 
@@ -150,10 +152,12 @@ export function detectProviderFromSrc( src ) {
150
152
  * Modifies an iframe src URL to add background video parameters.
151
153
  * Automatically detects the provider from the URL.
152
154
  *
153
- * @param {string} src The iframe src URL.
155
+ * @param {string} src The iframe src URL.
156
+ * @param {Object} options Options.
157
+ * @param {boolean} options.autoplay Whether the video should start playing on load.
154
158
  * @return {string} The modified URL.
155
159
  */
156
- export function getBackgroundVideoSrc( src ) {
160
+ export function getBackgroundVideoSrc( src, { autoplay = true } = {} ) {
157
161
  if ( ! src ) {
158
162
  return src;
159
163
  }
@@ -164,11 +168,14 @@ export function getBackgroundVideoSrc( src ) {
164
168
  // Detect provider from the iframe src URL
165
169
  const provider = detectProviderFromSrc( src );
166
170
 
171
+ if ( autoplay ) {
172
+ url.searchParams.set( 'autoplay', '1' );
173
+ }
174
+
167
175
  // Add provider-specific parameters for background video behavior
168
176
  switch ( provider ) {
169
177
  case 'youtube':
170
178
  // YouTube parameters for background video
171
- url.searchParams.set( 'autoplay', '1' );
172
179
  url.searchParams.set( 'mute', '1' );
173
180
  url.searchParams.set( 'loop', '1' );
174
181
  url.searchParams.set( 'controls', '0' );
@@ -185,24 +192,25 @@ export function getBackgroundVideoSrc( src ) {
185
192
 
186
193
  case 'vimeo':
187
194
  // Vimeo parameters for background video
188
- url.searchParams.set( 'autoplay', '1' );
189
195
  url.searchParams.set( 'muted', '1' );
190
196
  url.searchParams.set( 'loop', '1' );
191
- url.searchParams.set( 'background', '1' );
197
+ // Vimeo's background mode always autoplays, so it can only be
198
+ // used when autoplay is allowed.
199
+ if ( autoplay ) {
200
+ url.searchParams.set( 'background', '1' );
201
+ }
192
202
  url.searchParams.set( 'controls', '0' );
193
203
  break;
194
204
 
195
205
  case 'videopress':
196
206
  case 'wordpress-tv':
197
207
  // VideoPress parameters
198
- url.searchParams.set( 'autoplay', '1' );
199
208
  url.searchParams.set( 'loop', '1' );
200
209
  url.searchParams.set( 'muted', '1' );
201
210
  break;
202
211
 
203
212
  default:
204
213
  // Generic parameters that might work for other providers
205
- url.searchParams.set( 'autoplay', '1' );
206
214
  url.searchParams.set( 'muted', '1' );
207
215
  url.searchParams.set( 'loop', '1' );
208
216
  break;
@@ -26,6 +26,10 @@ function render_block_core_cover( $attributes, $content ) {
26
26
  ) {
27
27
  $url = $attributes['url'];
28
28
 
29
+ // The view script decides whether the embed may autoplay, so it is only
30
+ // needed for embed backgrounds.
31
+ wp_enqueue_script_module( '@wordpress/block-library/cover/view' );
32
+
29
33
  // Use WordPress's native oEmbed processing (includes caching).
30
34
  $oembed_html = wp_oembed_get( $url );
31
35
 
@@ -50,7 +54,8 @@ function render_block_core_cover( $attributes, $content ) {
50
54
  }
51
55
 
52
56
  // Modify iframe src to add background video parameters based on provider.
53
- $parsed_url = wp_parse_url( $iframe_src );
57
+ $parsed_url = wp_parse_url( $iframe_src );
58
+ $reduced_motion_src = null;
54
59
  if ( $parsed_url && isset( $parsed_url['host'] ) ) {
55
60
  // Parse existing query parameters.
56
61
  $query_params = array();
@@ -58,9 +63,12 @@ function render_block_core_cover( $attributes, $content ) {
58
63
  parse_str( $parsed_url['query'], $query_params );
59
64
  }
60
65
 
61
- // Add background video parameters based on provider.
66
+ // Add background video parameters based on provider. The
67
+ // autoplay parameters are kept separate so a source without
68
+ // them can also be built, which the view script swaps in for
69
+ // a visitor who has asked for reduced motion.
70
+ $autoplay_params = array();
62
71
  if ( 'youtube' === $provider ) {
63
- $query_params['autoplay'] = '1';
64
72
  $query_params['mute'] = '1';
65
73
  $query_params['loop'] = '1';
66
74
  $query_params['controls'] = '0';
@@ -74,32 +82,53 @@ function render_block_core_cover( $attributes, $content ) {
74
82
  if ( $video_id ) {
75
83
  $query_params['playlist'] = $video_id;
76
84
  }
85
+
86
+ $autoplay_params['autoplay'] = '1';
77
87
  } elseif ( 'vimeo' === $provider ) {
78
- $query_params['autoplay'] = '1';
79
88
  $query_params['muted'] = '1';
80
89
  $query_params['loop'] = '1';
81
- $query_params['background'] = '1';
82
90
  $query_params['controls'] = '0';
83
91
  $query_params['transparent'] = '0';
92
+
93
+ // Vimeo's background mode always autoplays, so it can only
94
+ // be used when autoplay is allowed.
95
+ $autoplay_params['autoplay'] = '1';
96
+ $autoplay_params['background'] = '1';
84
97
  } elseif ( 'videopress' === $provider || 'wordpress-tv' === $provider ) {
85
- $query_params['autoplay'] = '1';
86
- $query_params['loop'] = '1';
87
- $query_params['muted'] = '1';
98
+ $query_params['loop'] = '1';
99
+ $query_params['muted'] = '1';
100
+
101
+ $autoplay_params['autoplay'] = '1';
88
102
  }
89
103
 
90
104
  // Rebuild the URL with new parameters.
91
- $iframe_src = $parsed_url['scheme'] . '://' . $parsed_url['host'];
105
+ $iframe_base = $parsed_url['scheme'] . '://' . $parsed_url['host'];
92
106
  if ( isset( $parsed_url['path'] ) ) {
93
- $iframe_src .= $parsed_url['path'];
94
- }
95
- if ( ! empty( $query_params ) ) {
96
- $iframe_src .= '?' . http_build_query( $query_params );
107
+ $iframe_base .= $parsed_url['path'];
97
108
  }
109
+
110
+ $reduced_motion_src = empty( $query_params )
111
+ ? $iframe_base
112
+ : $iframe_base . '?' . http_build_query( $query_params );
113
+
114
+ $iframe_src = empty( $autoplay_params )
115
+ ? $reduced_motion_src
116
+ : $iframe_base . '?' . http_build_query( array_merge( $query_params, $autoplay_params ) );
98
117
  }
99
118
 
100
- // Build the iframe HTML that will replace the figure.
119
+ // Build the iframe HTML that will replace the figure. The server
120
+ // renders the autoplaying source, and the view script swaps in the
121
+ // one without autoplay for a visitor who prefers reduced motion.
101
122
  $iframe_html = sprintf(
102
- '<div class="wp-block-cover__video-background wp-block-cover__embed-background"><iframe src="%s" title="Background video" frameborder="0" allow="autoplay; fullscreen"></iframe></div>',
123
+ '<div class="wp-block-cover__video-background wp-block-cover__embed-background" data-wp-interactive="core/cover" data-wp-context=\'%s\'><iframe src="%s" data-wp-bind--src="state.videoSrc" title="Background video" frameborder="0" allow="autoplay; fullscreen"></iframe></div>',
124
+ esc_attr(
125
+ wp_json_encode(
126
+ array(
127
+ 'src' => $iframe_src,
128
+ 'reducedMotionSrc' => $reduced_motion_src,
129
+ )
130
+ )
131
+ ),
103
132
  esc_url( $iframe_src )
104
133
  );
105
134