@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
@@ -26,6 +26,15 @@ const IMAGE_ATTRIBUTES = {
26
26
 
27
27
  const VIEWPORT_STATE_INITIALIZER = 'test/viewport-state-initializer';
28
28
 
29
+ const createGallery = ( attributes = {} ) =>
30
+ createBlock( 'core/gallery', attributes, [
31
+ createBlock( 'core/image', IMAGE_ATTRIBUTES ),
32
+ createBlock( 'core/image', {
33
+ ...IMAGE_ATTRIBUTES,
34
+ id: 2,
35
+ } ),
36
+ ] );
37
+
29
38
  // The Gallery only offers its aspect ratio control when the theme or the
30
39
  // defaults provide ratios to choose from.
31
40
  const ASPECT_RATIO_SETTINGS = {
@@ -110,16 +119,84 @@ describe( 'Gallery block', () => {
110
119
  } );
111
120
  } );
112
121
 
113
- describe( 'Layout', () => {
114
- const createGallery = ( attributes = {} ) =>
115
- createBlock( 'core/gallery', attributes, [
116
- createBlock( 'core/image', IMAGE_ATTRIBUTES ),
117
- createBlock( 'core/image', {
118
- ...IMAGE_ATTRIBUTES,
119
- id: 2,
120
- } ),
121
- ] );
122
+ describe( 'Order by', () => {
123
+ test( 'offers a sort control in Settings for a static gallery that reads as a custom order until the media resolves', async () => {
124
+ await setup( createGallery() );
125
+ await selectBlock( 'Block: Gallery' );
122
126
 
127
+ const orderBy = await screen.findByRole( 'combobox', {
128
+ name: 'Order by',
129
+ } );
130
+ expect( orderBy ).toHaveDisplayValue( 'Custom' );
131
+ // The attachment records never resolve in this environment, so
132
+ // there's nothing to sort by yet; Random doesn't need them. Custom
133
+ // is only choosable while Random is on, since that's all it does.
134
+ expect(
135
+ screen.getByRole( 'option', { name: 'Newest to oldest' } )
136
+ ).toBeDisabled();
137
+ expect(
138
+ screen.getByRole( 'option', { name: 'Custom' } )
139
+ ).toBeDisabled();
140
+ expect(
141
+ screen.getByRole( 'option', { name: 'Random' } )
142
+ ).toBeEnabled();
143
+ } );
144
+
145
+ test( 'stores a random order for a static gallery and clears it when choosing the custom order', async () => {
146
+ await setup( createGallery() );
147
+ await selectBlock( 'Block: Gallery' );
148
+
149
+ const orderBy = await screen.findByRole( 'combobox', {
150
+ name: 'Order by',
151
+ } );
152
+ // The select is controlled from the `randomOrder` attribute, so
153
+ // its display value reflects the stored state after each change.
154
+ await userEvent.selectOptions( orderBy, 'random' );
155
+ expect( orderBy ).toHaveDisplayValue( 'Random' );
156
+ expect(
157
+ screen.getByRole( 'option', { name: 'Custom' } )
158
+ ).toBeEnabled();
159
+
160
+ await userEvent.selectOptions( orderBy, 'custom' );
161
+ expect( orderBy ).toHaveDisplayValue( 'Custom' );
162
+ expect(
163
+ screen.getByRole( 'option', { name: 'Custom' } )
164
+ ).toBeDisabled();
165
+ } );
166
+
167
+ test( 'offers a random order but no custom order for a dynamic gallery', async () => {
168
+ await setup(
169
+ createBlock( 'core/gallery', {
170
+ dynamicContent: { source: 'core/attached-media' },
171
+ } )
172
+ );
173
+ await selectBlock( 'Block: Dynamic Gallery' );
174
+
175
+ const orderBy = await screen.findByRole( 'combobox', {
176
+ name: 'Order by',
177
+ } );
178
+ expect( orderBy ).toHaveDisplayValue( 'Newest to oldest' );
179
+ expect(
180
+ screen.queryByRole( 'option', { name: 'Custom' } )
181
+ ).not.toBeInTheDocument();
182
+ // The order lives in Settings; the Source panel is a plain
183
+ // PanelBody with no resettable items, hence no options menu.
184
+ expect(
185
+ screen.getByRole( 'button', { name: 'Settings options' } )
186
+ ).toBeInTheDocument();
187
+ expect(
188
+ screen.queryByRole( 'button', { name: 'Source options' } )
189
+ ).not.toBeInTheDocument();
190
+
191
+ await userEvent.selectOptions( orderBy, 'random' );
192
+ expect( orderBy ).toHaveDisplayValue( 'Random' );
193
+
194
+ await userEvent.selectOptions( orderBy, 'title/asc' );
195
+ expect( orderBy ).toHaveDisplayValue( 'A → Z' );
196
+ } );
197
+ } );
198
+
199
+ describe( 'Layout', () => {
123
200
  test( 'keeps the custom Gallery controls for the default Flex layout', async () => {
124
201
  await setup( createGallery() );
125
202
  await selectBlock( 'Block: Gallery' );
@@ -149,7 +226,7 @@ describe( 'Gallery block', () => {
149
226
  screen.getByLabelText( 'Crop images to fit' )
150
227
  ).toBeInTheDocument();
151
228
  expect(
152
- screen.queryByLabelText( 'Randomize order' )
229
+ screen.queryByRole( 'combobox', { name: 'Order by' } )
153
230
  ).not.toBeInTheDocument();
154
231
  } );
155
232
 
@@ -0,0 +1,162 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { hasSortableImages, sortImageBlocks } from '../order-images';
3
+
4
+ const NEWEST_FIRST = { orderby: 'date', order: 'desc' };
5
+ const OLDEST_FIRST = { orderby: 'date', order: 'asc' };
6
+ const TITLE_A_TO_Z = { orderby: 'title', order: 'asc' };
7
+ const TITLE_Z_TO_A = { orderby: 'title', order: 'desc' };
8
+
9
+ /**
10
+ * Creates the minimal `core/image` block the helpers read: an attachment id
11
+ * and a client ID, which defaults from the id.
12
+ *
13
+ * @param {number|undefined} id Attachment id, or `undefined` for an external image.
14
+ * @param {string} clientId Block client ID.
15
+ */
16
+ function createImageBlock( id, clientId = `block-${ id }` ) {
17
+ return { clientId, attributes: { id } };
18
+ }
19
+
20
+ /**
21
+ * Creates image blocks for the given attachment ids, in that order.
22
+ *
23
+ * @param {...number} ids Attachment ids.
24
+ */
25
+ function createImageBlocks( ...ids ) {
26
+ return ids.map( ( id ) => createImageBlock( id ) );
27
+ }
28
+
29
+ /**
30
+ * Creates the minimal attachment record the helpers read.
31
+ *
32
+ * @param {number} id Attachment id.
33
+ * @param {string} title Attachment title.
34
+ * @param {string} date Upload date, ISO 8601.
35
+ */
36
+ function createAttachment( id, title, date ) {
37
+ return { id, title: { raw: title, rendered: title }, date };
38
+ }
39
+
40
+ // Listed oldest to newest, so the date order reads top to bottom: 2, 3, 1, 4.
41
+ // The ids deliberately don't follow the dates, so a sort keyed on the id (or
42
+ // on the position in this list) can't pass the date tests by accident. The
43
+ // title order is different again: apple, Beach, IMG_2, IMG_10 (2, 1, 4, 3),
44
+ // which requires the compare to ignore case and treat numbers naturally.
45
+ const ATTACHMENTS = [
46
+ createAttachment( 2, 'apple', '2024-01-15T10:00:00' ),
47
+ createAttachment( 3, 'IMG_10', '2024-02-01T10:00:00' ),
48
+ createAttachment( 1, 'Beach', '2024-03-01T10:00:00' ),
49
+ createAttachment( 4, 'IMG_2', '2024-04-01T10:00:00' ),
50
+ ];
51
+
52
+ const getImageIds = ( blocks ) =>
53
+ blocks.map( ( { attributes } ) => attributes.id );
54
+
55
+ describe( 'sortImageBlocks', () => {
56
+ it( 'sorts by date, newest first', () => {
57
+ const blocks = createImageBlocks( 1, 2, 3, 4 );
58
+ expect(
59
+ getImageIds( sortImageBlocks( blocks, ATTACHMENTS, NEWEST_FIRST ) )
60
+ ).toEqual( [ 4, 1, 3, 2 ] );
61
+ } );
62
+
63
+ it( 'sorts by date, oldest first', () => {
64
+ const blocks = createImageBlocks( 1, 2, 3, 4 );
65
+ expect(
66
+ getImageIds( sortImageBlocks( blocks, ATTACHMENTS, OLDEST_FIRST ) )
67
+ ).toEqual( [ 2, 3, 1, 4 ] );
68
+ } );
69
+
70
+ it( 'sorts by title ascending, ignoring case and comparing numbers naturally', () => {
71
+ const blocks = createImageBlocks( 1, 2, 3, 4 );
72
+ expect(
73
+ getImageIds( sortImageBlocks( blocks, ATTACHMENTS, TITLE_A_TO_Z ) )
74
+ ).toEqual( [ 2, 1, 4, 3 ] );
75
+ } );
76
+
77
+ it( 'sorts by title descending', () => {
78
+ const blocks = createImageBlocks( 1, 2, 3, 4 );
79
+ expect(
80
+ getImageIds( sortImageBlocks( blocks, ATTACHMENTS, TITLE_Z_TO_A ) )
81
+ ).toEqual( [ 3, 4, 1, 2 ] );
82
+ } );
83
+
84
+ it( 'returns a new array containing the same block objects', () => {
85
+ const blocks = createImageBlocks( 1, 2 );
86
+ const sorted = sortImageBlocks( blocks, ATTACHMENTS, OLDEST_FIRST );
87
+ expect( sorted ).not.toBe( blocks );
88
+ expect( sorted[ 0 ] ).toBe( blocks[ 1 ] );
89
+ expect( sorted[ 1 ] ).toBe( blocks[ 0 ] );
90
+ } );
91
+
92
+ it( 'moves images without an id or attachment record to the end, in their existing order', () => {
93
+ const blocks = [
94
+ createImageBlock( undefined, 'external-a' ),
95
+ createImageBlock( 1 ),
96
+ createImageBlock( 99 ),
97
+ createImageBlock( 2 ),
98
+ createImageBlock( undefined, 'external-b' ),
99
+ ];
100
+ const sorted = sortImageBlocks( blocks, ATTACHMENTS, OLDEST_FIRST );
101
+ expect( sorted.map( ( { clientId } ) => clientId ) ).toEqual( [
102
+ 'block-2',
103
+ 'block-1',
104
+ 'external-a',
105
+ 'block-99',
106
+ 'external-b',
107
+ ] );
108
+ } );
109
+
110
+ it( 'keeps the existing order of images with equal keys', () => {
111
+ const media = [
112
+ createAttachment( 1, 'Same', '2024-01-01T00:00:00' ),
113
+ createAttachment( 2, 'Same', '2024-01-01T00:00:00' ),
114
+ ];
115
+ const blocks = createImageBlocks( 2, 1 );
116
+ expect(
117
+ getImageIds( sortImageBlocks( blocks, media, NEWEST_FIRST ) )
118
+ ).toEqual( [ 2, 1 ] );
119
+ expect(
120
+ getImageIds( sortImageBlocks( blocks, media, TITLE_A_TO_Z ) )
121
+ ).toEqual( [ 2, 1 ] );
122
+ } );
123
+
124
+ it( 'falls back to the rendered title when there is no raw title', () => {
125
+ const media = [
126
+ { id: 1, title: { rendered: 'b' }, date: '' },
127
+ { id: 2, title: { rendered: 'a' }, date: '' },
128
+ ];
129
+ expect(
130
+ getImageIds(
131
+ sortImageBlocks(
132
+ createImageBlocks( 1, 2 ),
133
+ media,
134
+ TITLE_A_TO_Z
135
+ )
136
+ )
137
+ ).toEqual( [ 2, 1 ] );
138
+ } );
139
+ } );
140
+
141
+ describe( 'hasSortableImages', () => {
142
+ it( 'is true with two or more images that have an attachment record', () => {
143
+ expect(
144
+ hasSortableImages( createImageBlocks( 1, 2 ), ATTACHMENTS )
145
+ ).toBe( true );
146
+ } );
147
+
148
+ it( 'is false while the attachment records have not resolved', () => {
149
+ expect( hasSortableImages( createImageBlocks( 1, 2 ), [] ) ).toBe(
150
+ false
151
+ );
152
+ } );
153
+
154
+ it( 'does not count images without an id or attachment record', () => {
155
+ expect(
156
+ hasSortableImages(
157
+ createImageBlocks( 1, undefined, 99 ),
158
+ ATTACHMENTS
159
+ )
160
+ ).toBe( false );
161
+ } );
162
+ } );
@@ -235,7 +235,7 @@ export default function useDynamicGallery( {
235
235
 
236
236
  // Updates the source ordering within `dynamicContent.args`. Passing
237
237
  // `undefined` (or the default order) strips the keys so they aren't
238
- // persisted redundantly and the ToolsPanel item reads as unset.
238
+ // persisted redundantly and the Settings "Order by" item reads as unset.
239
239
  function setSourceOrder( nextOrderby, nextOrder ) {
240
240
  const nextArgs = { ...dynamicContent?.args };
241
241
  delete nextArgs.orderBy;
@@ -256,13 +256,6 @@ export default function useDynamicGallery( {
256
256
  setAttributes( { dynamicContent: nextSource } );
257
257
  }
258
258
 
259
- // Resets the source to its bare form: keeps the source kind, drops its args.
260
- function resetSource() {
261
- setAttributes( {
262
- dynamicContent: { source: dynamicContent.source },
263
- } );
264
- }
265
-
266
259
  return {
267
260
  dynamicContent,
268
261
  canUseDynamicSource,
@@ -278,6 +271,5 @@ export default function useDynamicGallery( {
278
271
  enableDynamicMode,
279
272
  convertToStatic,
280
273
  setSourceOrder,
281
- resetSource,
282
274
  };
283
275
  }
@@ -14,9 +14,15 @@ const EMPTY_IMAGE_MEDIA = [];
14
14
  export default function useGetMedia( innerBlockImages ) {
15
15
  return useSelect(
16
16
  ( select ) => {
17
+ // Sorted so the query only changes when the set of images changes,
18
+ // not when they're reordered: a reorder would otherwise be a new
19
+ // query, and the records would read as empty until it resolved.
20
+ // Consumers look records up by id, so the returned order doesn't
21
+ // matter.
17
22
  const imageIds = innerBlockImages
18
23
  .map( ( imageBlock ) => imageBlock.attributes.id )
19
- .filter( ( id ) => id !== undefined );
24
+ .filter( ( id ) => id !== undefined )
25
+ .sort( ( a, b ) => a - b );
20
26
 
21
27
  if ( imageIds.length === 0 ) {
22
28
  return EMPTY_IMAGE_MEDIA;
@@ -29,7 +35,6 @@ export default function useGetMedia( innerBlockImages ) {
29
35
  {
30
36
  include: imageIds.join( ',' ),
31
37
  per_page: -1,
32
- orderby: 'include',
33
38
  }
34
39
  ) ?? EMPTY_IMAGE_MEDIA
35
40
  );
@@ -7,7 +7,7 @@ import {
7
7
  store as blockEditorStore,
8
8
  privateApis as blockEditorPrivateApis,
9
9
  } from '@wordpress/block-editor';
10
- import { useRef } from '@wordpress/element';
10
+ import { useState } from '@wordpress/element';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';
13
13
  import { unlock } from '../lock-unlock';
@@ -70,9 +70,9 @@ function GroupEdit( { attributes, name, setAttributes, clientId } ) {
70
70
  const layoutSupportEnabled =
71
71
  themeSupportsLayout || type === 'flex' || type === 'grid';
72
72
 
73
- // Hooks.
74
- const ref = useRef();
75
- const blockProps = useBlockProps( { ref } );
73
+ // State, not a ref, so that the element is there on the next render.
74
+ const [ dropZoneElement, setDropZoneElement ] = useState( null );
75
+ const blockProps = useBlockProps( { ref: setDropZoneElement } );
76
76
 
77
77
  const [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {
78
78
  attributes,
@@ -99,7 +99,7 @@ function GroupEdit( { attributes, name, setAttributes, clientId } ) {
99
99
  ? blockProps
100
100
  : { className: 'wp-block-group__inner-container' },
101
101
  {
102
- dropZoneElement: ref.current,
102
+ dropZoneElement,
103
103
  templateLock,
104
104
  allowedBlocks,
105
105
  renderAppender,
@@ -35,6 +35,9 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
35
35
  - [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color):
36
36
  - [`gradients`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients): `true`
37
37
  - [`link`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-link): `true`
38
+ - [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
39
+ - `minHeight`: `true`
40
+ - `minWidth`: `true`
38
41
  - [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow): `true`
39
42
  - [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
40
43
  - `margin`: `true`
@@ -43,6 +46,7 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
43
46
  - [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
44
47
  - [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
45
48
  - [`textAlign`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-textalign): `true`
49
+ - `textIndent`: `true`
46
50
  - [`textShadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-textshadow): `true`
47
51
  - `fitText`: `true`
48
52
  - [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
@@ -53,6 +53,10 @@
53
53
  "text": true
54
54
  }
55
55
  },
56
+ "dimensions": {
57
+ "minHeight": true,
58
+ "minWidth": true
59
+ },
56
60
  "shadow": true,
57
61
  "spacing": {
58
62
  "margin": true,
@@ -66,6 +70,7 @@
66
70
  "fontSize": true,
67
71
  "lineHeight": true,
68
72
  "textAlign": true,
73
+ "textIndent": true,
69
74
  "__experimentalFontFamily": true,
70
75
  "__experimentalFontStyle": true,
71
76
  "__experimentalFontWeight": true,
@@ -38,6 +38,12 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
38
38
  - [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
39
39
  - [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
40
40
  - [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow): `true`
41
+ - [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
42
+ - `minHeight`: `true`
43
+ - `minWidth`: `true`
44
+ - [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
45
+ - `margin`: `true`
46
+ - `padding`: `true`
41
47
  - [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
42
48
  - `clientNavigation`: `true`
43
49
 
@@ -52,6 +52,10 @@
52
52
  }
53
53
  },
54
54
  "shadow": true,
55
+ "dimensions": {
56
+ "minHeight": true,
57
+ "minWidth": true
58
+ },
55
59
  "__experimentalBorder": {
56
60
  "color": true,
57
61
  "radius": true,
@@ -64,6 +68,14 @@
64
68
  "width": false
65
69
  }
66
70
  },
71
+ "spacing": {
72
+ "margin": true,
73
+ "padding": true,
74
+ "__experimentalDefaultControls": {
75
+ "margin": false,
76
+ "padding": false
77
+ }
78
+ },
67
79
  "interactivity": {
68
80
  "clientNavigation": true
69
81
  }
@@ -65,7 +65,11 @@ export default function CustomInserterModal( { onClose, value, onChange } ) {
65
65
  const iconLabel = normalizeSearchInput( icon.label );
66
66
 
67
67
  return (
68
- iconName.includes( input ) || iconLabel.includes( input )
68
+ iconName.includes( input ) ||
69
+ iconLabel.includes( input ) ||
70
+ ( icon.keywords ?? [] ).some( ( keyword ) =>
71
+ normalizeSearchInput( keyword ).includes( input )
72
+ )
69
73
  );
70
74
  } );
71
75
  }
package/src/icon/edit.jsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import clsx from 'clsx';
2
- import { __ } from '@wordpress/i18n';
2
+ import { __, sprintf } from '@wordpress/i18n';
3
3
  import {
4
4
  DropdownMenu,
5
5
  TextControl,
@@ -22,6 +22,7 @@ import {
22
22
  __experimentalGetSpacingClassesAndStyles as useSpacingProps,
23
23
  getDimensionsClassesAndStyles as useDimensionsProps,
24
24
  } from '@wordpress/block-editor';
25
+ import { getBlockBindingsSource } from '@wordpress/blocks';
25
26
  import { useState } from '@wordpress/element';
26
27
  import { SVG, Rect, Path } from '@wordpress/primitives';
27
28
  import { useSelect } from '@wordpress/data';
@@ -30,6 +31,10 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
30
31
  import HtmlRenderer from '../utils/html-renderer';
31
32
  import { CustomInserterModal } from './components';
32
33
 
34
+ // Matches the icon name pattern accepted by /wp/v2/icons/<name> REST route.
35
+ const ICON_NAME_REGEX =
36
+ /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?\/[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/;
37
+
33
38
  const IconPlaceholder = ( { className, style } ) => (
34
39
  <SVG
35
40
  xmlns="http://www.w3.org/2000/svg"
@@ -50,13 +55,50 @@ const IconPlaceholder = ( { className, style } ) => (
50
55
  </SVG>
51
56
  );
52
57
 
53
- export function Edit( { attributes, setAttributes } ) {
54
- const { icon, ariaLabel, flipHorizontal, flipVertical, rotation } =
55
- attributes;
58
+ export function Edit( { attributes, setAttributes, isSelected, context } ) {
59
+ const {
60
+ icon,
61
+ ariaLabel,
62
+ flipHorizontal,
63
+ flipVertical,
64
+ rotation,
65
+ metadata,
66
+ } = attributes;
56
67
 
57
68
  const [ isInserterOpen, setInserterOpen ] = useState( false );
58
69
 
59
70
  const isContentOnlyMode = useBlockEditingMode() === 'contentOnly';
71
+ const { isIconBindingReadOnly = false, iconBindingReadOnlyMessage } =
72
+ useSelect(
73
+ ( select ) => {
74
+ if ( ! isSelected ) {
75
+ return {};
76
+ }
77
+
78
+ const iconBinding = metadata?.bindings?.icon;
79
+ const blockBindingsSource = getBlockBindingsSource(
80
+ iconBinding?.source
81
+ );
82
+
83
+ return {
84
+ isIconBindingReadOnly:
85
+ !! iconBinding &&
86
+ ! blockBindingsSource?.canUserEditValue?.( {
87
+ select,
88
+ context,
89
+ args: iconBinding.args,
90
+ } ),
91
+ iconBindingReadOnlyMessage: blockBindingsSource?.label
92
+ ? sprintf(
93
+ /* translators: %s: Label of the bindings source. */
94
+ __( 'Connected to %s' ),
95
+ blockBindingsSource.label
96
+ )
97
+ : __( 'Connected to dynamic data' ),
98
+ };
99
+ },
100
+ [ context, isSelected, metadata?.bindings?.icon ]
101
+ );
60
102
 
61
103
  const colorProps = useColorProps( attributes );
62
104
  // Only padding is applied to the inner SVG element, matching the front
@@ -73,8 +115,14 @@ export function Edit( { attributes, setAttributes } ) {
73
115
 
74
116
  const selectedIcon = useSelect(
75
117
  ( select ) => {
76
- const { getEntityRecord } = select( coreDataStore );
77
- return icon ? getEntityRecord( 'root', 'icon', icon ) : null;
118
+ if ( typeof icon !== 'string' || ! ICON_NAME_REGEX.test( icon ) ) {
119
+ return null;
120
+ }
121
+ return select( coreDataStore ).getEntityRecord(
122
+ 'root',
123
+ 'icon',
124
+ icon
125
+ );
78
126
  },
79
127
  [ icon ]
80
128
  );
@@ -87,6 +135,7 @@ export function Edit( { attributes, setAttributes } ) {
87
135
  };
88
136
 
89
137
  const rotationStyle = rotation ? { rotate: `${ rotation }deg` } : {};
138
+ const iconToolbarButtonLabel = icon ? __( 'Replace' ) : __( 'Choose icon' );
90
139
 
91
140
  const blockControls = (
92
141
  <>
@@ -125,11 +174,23 @@ export function Edit( { attributes, setAttributes } ) {
125
174
  ) }
126
175
  <BlockControls group="other">
127
176
  <ToolbarButton
177
+ disabled={ isIconBindingReadOnly }
178
+ label={
179
+ isIconBindingReadOnly
180
+ ? iconBindingReadOnlyMessage
181
+ : undefined
182
+ }
183
+ showTooltip={ isIconBindingReadOnly }
184
+ aria-label={
185
+ isIconBindingReadOnly
186
+ ? iconToolbarButtonLabel
187
+ : undefined
188
+ }
128
189
  onClick={ () => {
129
190
  setInserterOpen( true );
130
191
  } }
131
192
  >
132
- { icon ? __( 'Replace' ) : __( 'Choose icon' ) }
193
+ { iconToolbarButtonLabel }
133
194
  </ToolbarButton>
134
195
  { isContentOnlyMode && icon && (
135
196
  // Add some extra controls for content attributes when content only mode is active.
@@ -15,7 +15,7 @@
15
15
  * @return string Returns the Icon.
16
16
  */
17
17
  function render_block_core_icon( $attributes ) {
18
- if ( empty( $attributes['icon'] ) ) {
18
+ if ( empty( $attributes['icon'] ) || ! is_string( $attributes['icon'] ) ) {
19
19
  return;
20
20
  }
21
21
 
@@ -369,13 +369,12 @@ function block_core_image_print_lightbox_overlay() {
369
369
  data-wp-on--touchstart="actions.handleTouchStart"
370
370
  data-wp-on--touchmove="actions.handleTouchMove"
371
371
  data-wp-on--touchend="actions.handleTouchEnd"
372
- data-wp-on--click="actions.hideLightbox"
373
372
  data-wp-on-window--resize="callbacks.setOverlayStyles"
374
373
  data-wp-on-window--scroll="actions.handleScroll"
375
374
  data-wp-bind--style="state.overlayStyles"
376
375
  tabindex="-1"
377
376
  >
378
- <button type="button" style="fill:{$close_button_color}" class="wp-lightbox-close-button" data-wp-bind--aria-label="state.closeButtonAriaLabel">
377
+ <button type="button" style="fill:{$close_button_color}" class="wp-lightbox-close-button" data-wp-on--click="actions.hideLightbox" data-wp-bind--aria-label="state.closeButtonAriaLabel">
379
378
  <span class="wp-lightbox-close-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$close_button_icon}</span>
380
379
  <span class="wp-lightbox-close-text" data-wp-bind--hidden="!state.hasNavigationText">{$close_button_text}</span>
381
380
  </button>
@@ -383,7 +382,7 @@ function block_core_image_print_lightbox_overlay() {
383
382
  <span class="wp-lightbox-navigation-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$prev_button_icon}</span>
384
383
  <span class="wp-lightbox-navigation-text" data-wp-bind--hidden="!state.hasNavigationText">{$prev_button_text}</span>
385
384
  </button>
386
- <div class="lightbox-image-container">
385
+ <div class="lightbox-image-container lightbox-thumbnail-container">
387
386
  <figure data-wp-bind--class="state.selectedImage.figureClassNames" data-wp-bind--style="state.figureStyles">
388
387
  <img data-wp-bind--alt="state.selectedImage.alt" data-wp-bind--class="state.selectedImage.imgClassNames" data-wp-bind--style="state.imgStyles" data-wp-bind--src="state.selectedImage.currentSrc">
389
388
  </figure>
@@ -405,7 +404,7 @@ function block_core_image_print_lightbox_overlay() {
405
404
  <span class="wp-lightbox-navigation-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$next_button_icon}</span>
406
405
  </button>
407
406
  <div data-wp-text="state.ariaLabel" aria-live="polite" aria-atomic="true" class="screen-reader-text"></div>
408
- <div class="scrim" style="background-color: {$background_color}" aria-hidden="true"></div>
407
+ <div class="scrim" style="background-color: {$background_color}" aria-hidden="true" data-wp-on--click="actions.hideLightbox"></div>
409
408
  </div>
410
409
  HTML;
411
410
  }