@wordpress/block-library 11.0.2-next.v.202609171837.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 (686) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/build/accordion/block.json +4 -1
  3. package/build/accordion-heading/block.json +1 -0
  4. package/build/accordion-item/block.json +7 -1
  5. package/build/accordion-panel/block.json +9 -1
  6. package/build/archives/block.json +12 -0
  7. package/build/audio/block.json +8 -0
  8. package/build/audio/edit.cjs +2 -1
  9. package/build/audio/edit.cjs.map +2 -2
  10. package/build/avatar/block.json +4 -0
  11. package/build/avatar/edit.cjs +31 -1
  12. package/build/avatar/edit.cjs.map +3 -3
  13. package/build/breadcrumbs/block.json +3 -0
  14. package/build/breadcrumbs/edit.cjs.map +3 -3
  15. package/build/button/block.json +6 -0
  16. package/build/button/edit.cjs +9 -6
  17. package/build/button/edit.cjs.map +2 -2
  18. package/build/buttons/block.json +15 -1
  19. package/build/categories/block.json +12 -1
  20. package/build/code/block.json +13 -0
  21. package/build/column/block.json +9 -0
  22. package/build/column/edit.cjs +5 -0
  23. package/build/column/edit.cjs.map +2 -2
  24. package/build/columns/block.json +13 -0
  25. package/build/columns/edit.cjs +21 -112
  26. package/build/columns/edit.cjs.map +3 -3
  27. package/build/comment-author-name/block.json +3 -0
  28. package/build/comment-content/block.json +5 -0
  29. package/build/comment-date/block.json +3 -0
  30. package/build/comment-edit-link/block.json +3 -0
  31. package/build/comment-reply-link/block.json +3 -0
  32. package/build/comments/block.json +10 -0
  33. package/build/comments/edit/placeholder.cjs +95 -87
  34. package/build/comments/edit/placeholder.cjs.map +2 -2
  35. package/build/comments-pagination/block.json +14 -0
  36. package/build/comments-pagination-next/block.json +3 -0
  37. package/build/comments-pagination-numbers/block.json +3 -0
  38. package/build/comments-pagination-previous/block.json +6 -0
  39. package/build/comments-title/block.json +3 -0
  40. package/build/cover/block.json +2 -1
  41. package/build/cover/edit/index.cjs +30 -6
  42. package/build/cover/edit/index.cjs.map +2 -2
  43. package/build/cover/edit/inspector-controls.cjs +56 -14
  44. package/build/cover/edit/inspector-controls.cjs.map +2 -2
  45. package/build/cover/embed-video-utils.cjs +9 -8
  46. package/build/cover/embed-video-utils.cjs.map +2 -2
  47. package/build/cover/view.cjs +21 -0
  48. package/build/cover/view.cjs.map +7 -0
  49. package/build/details/block.json +14 -0
  50. package/build/embed/block.json +6 -1
  51. package/build/file/block.json +14 -0
  52. package/build/footnotes/block.json +13 -0
  53. package/build/gallery/block.json +22 -0
  54. package/build/gallery/dynamic-gallery.cjs +32 -93
  55. package/build/gallery/dynamic-gallery.cjs.map +3 -3
  56. package/build/gallery/edit.cjs +104 -42
  57. package/build/gallery/edit.cjs.map +2 -2
  58. package/build/gallery/order-controls.cjs +107 -0
  59. package/build/gallery/order-controls.cjs.map +7 -0
  60. package/build/gallery/order-images.cjs +92 -0
  61. package/build/gallery/order-images.cjs.map +7 -0
  62. package/build/gallery/order-options.cjs +62 -0
  63. package/build/gallery/order-options.cjs.map +7 -0
  64. package/build/gallery/use-dynamic-gallery.cjs +1 -7
  65. package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
  66. package/build/gallery/use-get-media.cjs +2 -3
  67. package/build/gallery/use-get-media.cjs.map +2 -2
  68. package/build/group/block.json +1 -0
  69. package/build/group/edit.cjs +3 -3
  70. package/build/group/edit.cjs.map +2 -2
  71. package/build/heading/block.json +14 -0
  72. package/build/home-link/block.json +30 -0
  73. package/build/home-link/edit.cjs.map +3 -3
  74. package/build/icon/components/custom-inserter/index.cjs +3 -1
  75. package/build/icon/components/custom-inserter/index.cjs.map +2 -2
  76. package/build/icon/edit.cjs +49 -5
  77. package/build/icon/edit.cjs.map +2 -2
  78. package/build/image/image.cjs +10 -8
  79. package/build/image/image.cjs.map +3 -3
  80. package/build/image/use-open-image-media-editor-modal.cjs +32 -8
  81. package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
  82. package/build/image/view.cjs +44 -50
  83. package/build/image/view.cjs.map +2 -2
  84. package/build/latest-comments/block.json +20 -0
  85. package/build/latest-posts/block.json +14 -0
  86. package/build/list/block.json +12 -1
  87. package/build/list-item/block.json +8 -1
  88. package/build/list-item/index.cjs +4 -0
  89. package/build/list-item/index.cjs.map +3 -3
  90. package/build/loginout/block.json +14 -0
  91. package/build/math/block.json +14 -0
  92. package/build/media-text/block.json +19 -0
  93. package/build/navigation/edit/index.cjs +1 -4
  94. package/build/navigation/edit/index.cjs.map +2 -2
  95. package/build/navigation-link/link-ui/index.cjs +33 -19
  96. package/build/navigation-link/link-ui/index.cjs.map +2 -2
  97. package/build/navigation-link/link-ui/page-creator.cjs.map +3 -3
  98. package/build/navigation-link/shared/controls.cjs.map +3 -3
  99. package/build/navigation-link/shared/index.cjs +5 -0
  100. package/build/navigation-link/shared/index.cjs.map +2 -2
  101. package/build/navigation-link/shared/use-block-suggestions.cjs +141 -0
  102. package/build/navigation-link/shared/use-block-suggestions.cjs.map +7 -0
  103. package/build/navigation-link/shared/use-link-preview.cjs +13 -13
  104. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  105. package/build/navigation-overlay-close/block.json +7 -0
  106. package/build/navigation-submenu/block.json +6 -0
  107. package/build/navigation-submenu/edit.cjs +9 -1
  108. package/build/navigation-submenu/edit.cjs.map +3 -3
  109. package/build/page-list/block.json +14 -0
  110. package/build/paragraph/block.json +1 -0
  111. package/build/paragraph/edit.cjs +1 -2
  112. package/build/paragraph/edit.cjs.map +2 -2
  113. package/build/playlist/block.json +1 -0
  114. package/build/post-author-biography/block.json +5 -0
  115. package/build/post-author-name/block.json +5 -0
  116. package/build/post-comments-count/block.json +3 -0
  117. package/build/post-comments-form/block.json +15 -0
  118. package/build/post-content/block.json +4 -1
  119. package/build/post-date/block.json +3 -0
  120. package/build/post-excerpt/block.json +9 -0
  121. package/build/post-featured-image/block.json +1 -0
  122. package/build/post-featured-image/edit.cjs +12 -10
  123. package/build/post-featured-image/edit.cjs.map +2 -2
  124. package/build/post-navigation-link/block.json +30 -0
  125. package/build/post-navigation-link/edit.cjs +13 -2
  126. package/build/post-navigation-link/edit.cjs.map +3 -3
  127. package/build/post-template/block.json +13 -1
  128. package/build/post-terms/block.json +10 -0
  129. package/build/post-time-to-read/block.json +10 -0
  130. package/build/post-title/block.json +14 -0
  131. package/build/preformatted/block.json +11 -0
  132. package/build/pullquote/block.json +3 -1
  133. package/build/query-no-results/block.json +14 -2
  134. package/build/query-pagination/block.json +20 -0
  135. package/build/query-pagination-next/block.json +3 -0
  136. package/build/query-pagination-numbers/block.json +3 -0
  137. package/build/query-pagination-previous/block.json +3 -0
  138. package/build/query-title/block.json +3 -0
  139. package/build/query-total/block.json +10 -0
  140. package/build/quote/block.json +3 -0
  141. package/build/read-more/block.json +11 -0
  142. package/build/rss/block.json +10 -0
  143. package/build/search/block.json +2 -1
  144. package/build/site-tagline/block.json +12 -1
  145. package/build/site-title/block.json +11 -1
  146. package/build/social-links/block.json +4 -0
  147. package/build/social-links/edit.cjs +2 -3
  148. package/build/social-links/edit.cjs.map +2 -2
  149. package/build/tab-list/block.json +4 -0
  150. package/build/tab-list/edit.cjs +3 -1
  151. package/build/tab-list/edit.cjs.map +3 -3
  152. package/build/tab-list/save.cjs +3 -1
  153. package/build/tab-list/save.cjs.map +3 -3
  154. package/build/tab-panel/block.json +25 -0
  155. package/build/tab-panel/controls.cjs.map +3 -3
  156. package/build/tab-panels/block.json +21 -1
  157. package/build/table-of-contents/block.json +7 -0
  158. package/build/tabs/block.json +27 -1
  159. package/build/tag-cloud/block.json +19 -0
  160. package/build/template-part/edit/selection-modal.cjs.map +1 -1
  161. package/build/term-count/block.json +12 -0
  162. package/build/term-description/block.json +13 -0
  163. package/build/term-name/block.json +16 -1
  164. package/build/term-template/block.json +14 -1
  165. package/build/utils/search-patterns.cjs +7 -43
  166. package/build/utils/search-patterns.cjs.map +3 -3
  167. package/build/utils/style-state.cjs +4 -6
  168. package/build/utils/style-state.cjs.map +2 -2
  169. package/build/utils/waveform-utils.cjs +2 -2
  170. package/build/utils/waveform-utils.cjs.map +2 -2
  171. package/build/verse/block.json +4 -0
  172. package/build/video/block.json +12 -0
  173. package/build/video/edit.cjs +30 -14
  174. package/build/video/edit.cjs.map +3 -3
  175. package/build/video/index.cjs +0 -2
  176. package/build/video/index.cjs.map +3 -3
  177. package/build/video/save.cjs +5 -1
  178. package/build/video/save.cjs.map +3 -3
  179. package/build-module/accordion/block.json +4 -1
  180. package/build-module/accordion-heading/block.json +1 -0
  181. package/build-module/accordion-item/block.json +7 -1
  182. package/build-module/accordion-panel/block.json +9 -1
  183. package/build-module/archives/block.json +12 -0
  184. package/build-module/audio/block.json +8 -0
  185. package/build-module/audio/edit.mjs +2 -1
  186. package/build-module/audio/edit.mjs.map +2 -2
  187. package/build-module/avatar/block.json +4 -0
  188. package/build-module/avatar/edit.mjs +33 -2
  189. package/build-module/avatar/edit.mjs.map +2 -2
  190. package/build-module/breadcrumbs/block.json +3 -0
  191. package/build-module/breadcrumbs/edit.mjs +3 -3
  192. package/build-module/breadcrumbs/edit.mjs.map +2 -2
  193. package/build-module/button/block.json +6 -0
  194. package/build-module/button/edit.mjs +11 -7
  195. package/build-module/button/edit.mjs.map +2 -2
  196. package/build-module/buttons/block.json +15 -1
  197. package/build-module/categories/block.json +12 -1
  198. package/build-module/code/block.json +13 -0
  199. package/build-module/column/block.json +9 -0
  200. package/build-module/column/edit.mjs +5 -0
  201. package/build-module/column/edit.mjs.map +2 -2
  202. package/build-module/columns/block.json +13 -0
  203. package/build-module/columns/edit.mjs +22 -122
  204. package/build-module/columns/edit.mjs.map +2 -2
  205. package/build-module/comment-author-name/block.json +3 -0
  206. package/build-module/comment-content/block.json +5 -0
  207. package/build-module/comment-date/block.json +3 -0
  208. package/build-module/comment-edit-link/block.json +3 -0
  209. package/build-module/comment-reply-link/block.json +3 -0
  210. package/build-module/comments/block.json +10 -0
  211. package/build-module/comments/edit/placeholder.mjs +95 -87
  212. package/build-module/comments/edit/placeholder.mjs.map +2 -2
  213. package/build-module/comments-pagination/block.json +14 -0
  214. package/build-module/comments-pagination-next/block.json +3 -0
  215. package/build-module/comments-pagination-numbers/block.json +3 -0
  216. package/build-module/comments-pagination-previous/block.json +6 -0
  217. package/build-module/comments-title/block.json +3 -0
  218. package/build-module/cover/block.json +2 -1
  219. package/build-module/cover/edit/index.mjs +36 -7
  220. package/build-module/cover/edit/index.mjs.map +2 -2
  221. package/build-module/cover/edit/inspector-controls.mjs +62 -16
  222. package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
  223. package/build-module/cover/embed-video-utils.mjs +9 -8
  224. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  225. package/build-module/cover/view.mjs +19 -0
  226. package/build-module/cover/view.mjs.map +7 -0
  227. package/build-module/details/block.json +14 -0
  228. package/build-module/embed/block.json +6 -1
  229. package/build-module/file/block.json +14 -0
  230. package/build-module/footnotes/block.json +13 -0
  231. package/build-module/gallery/block.json +22 -0
  232. package/build-module/gallery/dynamic-gallery.mjs +33 -97
  233. package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
  234. package/build-module/gallery/edit.mjs +111 -44
  235. package/build-module/gallery/edit.mjs.map +2 -2
  236. package/build-module/gallery/order-controls.mjs +87 -0
  237. package/build-module/gallery/order-controls.mjs.map +7 -0
  238. package/build-module/gallery/order-images.mjs +66 -0
  239. package/build-module/gallery/order-images.mjs.map +7 -0
  240. package/build-module/gallery/order-options.mjs +33 -0
  241. package/build-module/gallery/order-options.mjs.map +7 -0
  242. package/build-module/gallery/use-dynamic-gallery.mjs +1 -7
  243. package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
  244. package/build-module/gallery/use-get-media.mjs +2 -3
  245. package/build-module/gallery/use-get-media.mjs.map +2 -2
  246. package/build-module/group/block.json +1 -0
  247. package/build-module/group/edit.mjs +4 -4
  248. package/build-module/group/edit.mjs.map +2 -2
  249. package/build-module/heading/block.json +14 -0
  250. package/build-module/home-link/block.json +30 -0
  251. package/build-module/home-link/edit.mjs +2 -2
  252. package/build-module/home-link/edit.mjs.map +2 -2
  253. package/build-module/icon/components/custom-inserter/index.mjs +3 -1
  254. package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
  255. package/build-module/icon/edit.mjs +50 -6
  256. package/build-module/icon/edit.mjs.map +2 -2
  257. package/build-module/image/image.mjs +12 -10
  258. package/build-module/image/image.mjs.map +2 -2
  259. package/build-module/image/use-open-image-media-editor-modal.mjs +32 -8
  260. package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
  261. package/build-module/image/view.mjs +44 -50
  262. package/build-module/image/view.mjs.map +2 -2
  263. package/build-module/latest-comments/block.json +20 -0
  264. package/build-module/latest-posts/block.json +14 -0
  265. package/build-module/list/block.json +12 -1
  266. package/build-module/list-item/block.json +8 -1
  267. package/build-module/list-item/index.mjs +4 -0
  268. package/build-module/list-item/index.mjs.map +2 -2
  269. package/build-module/loginout/block.json +14 -0
  270. package/build-module/math/block.json +14 -0
  271. package/build-module/media-text/block.json +19 -0
  272. package/build-module/navigation/edit/index.mjs +1 -4
  273. package/build-module/navigation/edit/index.mjs.map +2 -2
  274. package/build-module/navigation-link/link-ui/index.mjs +39 -20
  275. package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
  276. package/build-module/navigation-link/link-ui/page-creator.mjs +2 -2
  277. package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
  278. package/build-module/navigation-link/shared/controls.mjs +2 -2
  279. package/build-module/navigation-link/shared/controls.mjs.map +2 -2
  280. package/build-module/navigation-link/shared/index.mjs +6 -0
  281. package/build-module/navigation-link/shared/index.mjs.map +2 -2
  282. package/build-module/navigation-link/shared/use-block-suggestions.mjs +120 -0
  283. package/build-module/navigation-link/shared/use-block-suggestions.mjs.map +7 -0
  284. package/build-module/navigation-link/shared/use-link-preview.mjs +13 -13
  285. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  286. package/build-module/navigation-overlay-close/block.json +7 -0
  287. package/build-module/navigation-submenu/block.json +6 -0
  288. package/build-module/navigation-submenu/edit.mjs +11 -2
  289. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  290. package/build-module/page-list/block.json +14 -0
  291. package/build-module/paragraph/block.json +1 -0
  292. package/build-module/paragraph/edit.mjs +1 -2
  293. package/build-module/paragraph/edit.mjs.map +2 -2
  294. package/build-module/playlist/block.json +1 -0
  295. package/build-module/post-author-biography/block.json +5 -0
  296. package/build-module/post-author-name/block.json +5 -0
  297. package/build-module/post-comments-count/block.json +3 -0
  298. package/build-module/post-comments-form/block.json +15 -0
  299. package/build-module/post-content/block.json +4 -1
  300. package/build-module/post-date/block.json +3 -0
  301. package/build-module/post-excerpt/block.json +9 -0
  302. package/build-module/post-featured-image/block.json +1 -0
  303. package/build-module/post-featured-image/edit.mjs +12 -10
  304. package/build-module/post-featured-image/edit.mjs.map +2 -2
  305. package/build-module/post-navigation-link/block.json +30 -0
  306. package/build-module/post-navigation-link/edit.mjs +17 -3
  307. package/build-module/post-navigation-link/edit.mjs.map +2 -2
  308. package/build-module/post-template/block.json +13 -1
  309. package/build-module/post-terms/block.json +10 -0
  310. package/build-module/post-time-to-read/block.json +10 -0
  311. package/build-module/post-title/block.json +14 -0
  312. package/build-module/preformatted/block.json +11 -0
  313. package/build-module/pullquote/block.json +3 -1
  314. package/build-module/query-no-results/block.json +14 -2
  315. package/build-module/query-pagination/block.json +20 -0
  316. package/build-module/query-pagination-next/block.json +3 -0
  317. package/build-module/query-pagination-numbers/block.json +3 -0
  318. package/build-module/query-pagination-previous/block.json +3 -0
  319. package/build-module/query-title/block.json +3 -0
  320. package/build-module/query-total/block.json +10 -0
  321. package/build-module/quote/block.json +3 -0
  322. package/build-module/read-more/block.json +11 -0
  323. package/build-module/rss/block.json +10 -0
  324. package/build-module/search/block.json +2 -1
  325. package/build-module/site-tagline/block.json +12 -1
  326. package/build-module/site-title/block.json +11 -1
  327. package/build-module/social-links/block.json +4 -0
  328. package/build-module/social-links/edit.mjs +2 -3
  329. package/build-module/social-links/edit.mjs.map +2 -2
  330. package/build-module/tab-list/block.json +4 -0
  331. package/build-module/tab-list/edit.mjs +4 -1
  332. package/build-module/tab-list/edit.mjs.map +2 -2
  333. package/build-module/tab-list/save.mjs +4 -1
  334. package/build-module/tab-list/save.mjs.map +2 -2
  335. package/build-module/tab-panel/block.json +25 -0
  336. package/build-module/tab-panel/controls.mjs +2 -2
  337. package/build-module/tab-panel/controls.mjs.map +2 -2
  338. package/build-module/tab-panels/block.json +21 -1
  339. package/build-module/table-of-contents/block.json +7 -0
  340. package/build-module/tabs/block.json +27 -1
  341. package/build-module/tag-cloud/block.json +19 -0
  342. package/build-module/template-part/edit/selection-modal.mjs.map +1 -1
  343. package/build-module/term-count/block.json +12 -0
  344. package/build-module/term-description/block.json +13 -0
  345. package/build-module/term-name/block.json +16 -1
  346. package/build-module/term-template/block.json +14 -1
  347. package/build-module/utils/search-patterns.mjs +7 -32
  348. package/build-module/utils/search-patterns.mjs.map +2 -2
  349. package/build-module/utils/style-state.mjs +6 -4
  350. package/build-module/utils/style-state.mjs.map +2 -2
  351. package/build-module/utils/waveform-utils.mjs +1 -1
  352. package/build-module/utils/waveform-utils.mjs.map +1 -1
  353. package/build-module/verse/block.json +4 -0
  354. package/build-module/video/block.json +12 -0
  355. package/build-module/video/edit.mjs +32 -15
  356. package/build-module/video/edit.mjs.map +2 -2
  357. package/build-module/video/index.mjs +0 -2
  358. package/build-module/video/index.mjs.map +2 -2
  359. package/build-module/video/save.mjs +7 -2
  360. package/build-module/video/save.mjs.map +2 -2
  361. package/build-style/avatar/editor-rtl.css +4 -0
  362. package/build-style/avatar/editor.css +4 -0
  363. package/build-style/comments-pagination/style-rtl.css +3 -0
  364. package/build-style/comments-pagination/style.css +3 -0
  365. package/build-style/common-rtl.css +32 -1
  366. package/build-style/common.css +35 -2
  367. package/build-style/editor-rtl.css +23 -6
  368. package/build-style/editor.css +23 -6
  369. package/build-style/embed/style-rtl.css +4 -1
  370. package/build-style/embed/style.css +4 -1
  371. package/build-style/gallery/editor-rtl.css +1 -3
  372. package/build-style/gallery/editor.css +1 -3
  373. package/build-style/image/editor-rtl.css +6 -0
  374. package/build-style/image/editor.css +6 -0
  375. package/build-style/image/style-rtl.css +11 -2
  376. package/build-style/image/style.css +11 -2
  377. package/build-style/media-text/style-rtl.css +4 -1
  378. package/build-style/media-text/style.css +4 -1
  379. package/build-style/navigation/style-rtl.css +18 -3
  380. package/build-style/navigation/style.css +18 -3
  381. package/build-style/navigation-link/editor-rtl.css +3 -1
  382. package/build-style/navigation-link/editor.css +3 -1
  383. package/build-style/navigation-overlay-close/style-rtl.css +1 -1
  384. package/build-style/navigation-overlay-close/style.css +1 -1
  385. package/build-style/navigation-submenu/editor-rtl.css +3 -1
  386. package/build-style/navigation-submenu/editor.css +3 -1
  387. package/build-style/post-navigation-link/style-rtl.css +3 -0
  388. package/build-style/post-navigation-link/style.css +3 -0
  389. package/build-style/query-pagination/style-rtl.css +3 -0
  390. package/build-style/query-pagination/style.css +3 -0
  391. package/build-style/style-rtl.css +94 -13
  392. package/build-style/style.css +97 -14
  393. package/build-style/tab-panel/style-rtl.css +2 -0
  394. package/build-style/tab-panel/style.css +2 -0
  395. package/build-style/table/editor-rtl.css +6 -1
  396. package/build-style/table/editor.css +6 -1
  397. package/build-style/table/style-rtl.css +4 -2
  398. package/build-style/table/style.css +4 -2
  399. package/build-style/tag-cloud/style-rtl.css +1 -1
  400. package/build-style/tag-cloud/style.css +1 -1
  401. package/build-style/verse/style-rtl.css +8 -1
  402. package/build-style/verse/style.css +8 -1
  403. package/build-types/gallery/order-controls.d.ts +58 -0
  404. package/build-types/gallery/order-controls.d.ts.map +1 -0
  405. package/build-types/gallery/order-options.d.ts +67 -0
  406. package/build-types/gallery/order-options.d.ts.map +1 -0
  407. package/package.json +46 -44
  408. package/src/accordion/README.md +3 -0
  409. package/src/accordion/block.json +4 -1
  410. package/src/accordion-heading/README.md +1 -0
  411. package/src/accordion-heading/block.json +1 -0
  412. package/src/accordion-item/README.md +5 -0
  413. package/src/accordion-item/block.json +7 -1
  414. package/src/accordion-panel/README.md +7 -0
  415. package/src/accordion-panel/block.json +9 -1
  416. package/src/archives/README.md +6 -0
  417. package/src/archives/block.json +12 -0
  418. package/src/audio/README.md +4 -0
  419. package/src/audio/block.json +8 -0
  420. package/src/audio/edit.jsx +2 -1
  421. package/src/avatar/README.md +2 -0
  422. package/src/avatar/block.json +4 -0
  423. package/src/avatar/edit.jsx +48 -2
  424. package/src/avatar/editor.scss +4 -0
  425. package/src/avatar/index.php +5 -3
  426. package/src/breadcrumbs/README.md +2 -0
  427. package/src/breadcrumbs/block.json +3 -0
  428. package/src/breadcrumbs/edit.jsx +3 -3
  429. package/src/breadcrumbs/index.php +1 -1
  430. package/src/button/README.md +4 -0
  431. package/src/button/block.json +6 -0
  432. package/src/button/edit.jsx +47 -52
  433. package/src/button/index.php +47 -0
  434. package/src/buttons/README.md +8 -0
  435. package/src/buttons/block.json +15 -1
  436. package/src/categories/README.md +6 -0
  437. package/src/categories/block.json +12 -1
  438. package/src/code/README.md +7 -0
  439. package/src/code/block.json +13 -0
  440. package/src/column/README.md +4 -0
  441. package/src/column/block.json +9 -0
  442. package/src/column/edit.jsx +6 -0
  443. package/src/columns/README.md +7 -0
  444. package/src/columns/block.json +13 -0
  445. package/src/columns/edit.jsx +1 -131
  446. package/src/comment-author-name/README.md +2 -0
  447. package/src/comment-author-name/block.json +3 -0
  448. package/src/comment-content/README.md +4 -0
  449. package/src/comment-content/block.json +5 -0
  450. package/src/comment-date/README.md +2 -0
  451. package/src/comment-date/block.json +3 -0
  452. package/src/comment-edit-link/README.md +2 -0
  453. package/src/comment-edit-link/block.json +3 -0
  454. package/src/comment-reply-link/README.md +2 -0
  455. package/src/comment-reply-link/block.json +3 -0
  456. package/src/comments/README.md +5 -0
  457. package/src/comments/block.json +10 -0
  458. package/src/comments/edit/placeholder.jsx +5 -1
  459. package/src/comments-pagination/README.md +6 -0
  460. package/src/comments-pagination/block.json +14 -0
  461. package/src/comments-pagination/style.scss +3 -0
  462. package/src/comments-pagination-next/README.md +2 -0
  463. package/src/comments-pagination-next/block.json +3 -0
  464. package/src/comments-pagination-numbers/README.md +2 -0
  465. package/src/comments-pagination-numbers/block.json +3 -0
  466. package/src/comments-pagination-previous/README.md +2 -0
  467. package/src/comments-pagination-previous/block.json +6 -0
  468. package/src/comments-title/README.md +2 -0
  469. package/src/comments-title/block.json +3 -0
  470. package/src/common.scss +38 -0
  471. package/src/cover/README.md +1 -0
  472. package/src/cover/block.json +2 -1
  473. package/src/cover/edit/index.jsx +41 -6
  474. package/src/cover/edit/inspector-controls.jsx +74 -14
  475. package/src/cover/embed-video-utils.js +18 -10
  476. package/src/cover/index.php +44 -15
  477. package/src/cover/test/edit.browser.test.js +200 -4
  478. package/src/cover/test/embed-video-utils.test.js +48 -0
  479. package/src/cover/view.js +22 -0
  480. package/src/details/README.md +8 -0
  481. package/src/details/block.json +14 -0
  482. package/src/embed/README.md +4 -0
  483. package/src/embed/block.json +6 -1
  484. package/src/embed/style.scss +7 -1
  485. package/src/file/README.md +8 -0
  486. package/src/file/block.json +14 -0
  487. package/src/footnotes/README.md +7 -0
  488. package/src/footnotes/block.json +13 -0
  489. package/src/gallery/README.md +17 -0
  490. package/src/gallery/block.json +22 -0
  491. package/src/gallery/dynamic-gallery.jsx +11 -91
  492. package/src/gallery/edit.jsx +147 -49
  493. package/src/gallery/editor.scss +5 -9
  494. package/src/gallery/order-controls.tsx +143 -0
  495. package/src/gallery/order-images.js +111 -0
  496. package/src/gallery/order-options.ts +75 -0
  497. package/src/gallery/test/edit.jsdom.test.js +87 -10
  498. package/src/gallery/test/order-images.js +162 -0
  499. package/src/gallery/use-dynamic-gallery.js +1 -9
  500. package/src/gallery/use-get-media.js +7 -2
  501. package/src/group/README.md +1 -0
  502. package/src/group/block.json +1 -0
  503. package/src/group/edit.jsx +5 -5
  504. package/src/heading/README.md +8 -0
  505. package/src/heading/block.json +14 -0
  506. package/src/home-link/README.md +11 -0
  507. package/src/home-link/block.json +30 -0
  508. package/src/home-link/edit.jsx +2 -2
  509. package/src/icon/components/custom-inserter/index.jsx +5 -1
  510. package/src/icon/edit.jsx +68 -7
  511. package/src/icon/index.php +10 -1
  512. package/src/image/editor.scss +8 -0
  513. package/src/image/image.jsx +13 -11
  514. package/src/image/index.php +3 -4
  515. package/src/image/style.scss +14 -2
  516. package/src/image/test/use-open-image-media-editor-modal.jsdom.test.js +201 -0
  517. package/src/image/use-open-image-media-editor-modal.js +37 -4
  518. package/src/image/view.js +64 -68
  519. package/src/latest-comments/README.md +8 -0
  520. package/src/latest-comments/block.json +20 -0
  521. package/src/latest-posts/README.md +8 -0
  522. package/src/latest-posts/block.json +14 -0
  523. package/src/list/README.md +6 -0
  524. package/src/list/block.json +12 -1
  525. package/src/list-item/README.md +6 -0
  526. package/src/list-item/block.json +8 -1
  527. package/src/list-item/index.js +5 -0
  528. package/src/loginout/README.md +8 -0
  529. package/src/loginout/block.json +14 -0
  530. package/src/math/README.md +8 -0
  531. package/src/math/block.json +14 -0
  532. package/src/media-text/README.md +18 -0
  533. package/src/media-text/block.json +19 -0
  534. package/src/media-text/style.scss +5 -1
  535. package/src/navigation/edit/index.jsx +2 -4
  536. package/src/navigation/style.scss +40 -4
  537. package/src/navigation/test/use-navigation-menu.jsdom.test.js +1 -1
  538. package/src/navigation-link/README.md +1 -1
  539. package/src/navigation-link/editor.scss +6 -1
  540. package/src/navigation-link/link-ui/index.jsx +60 -27
  541. package/src/navigation-link/link-ui/page-creator.jsx +2 -2
  542. package/src/navigation-link/link-ui/test/get-suggestions-query.jsdom.test.js +67 -0
  543. package/src/navigation-link/shared/controls.jsx +2 -2
  544. package/src/navigation-link/shared/index.js +4 -0
  545. package/src/navigation-link/shared/test/use-block-suggestions.jsdom.test.js +158 -0
  546. package/src/navigation-link/shared/test/use-entity-binding.jsdom.test.js +1 -7
  547. package/src/navigation-link/shared/test/use-link-preview.jsdom.test.js +22 -22
  548. package/src/navigation-link/shared/use-block-suggestions.js +192 -0
  549. package/src/navigation-link/shared/use-link-preview.js +15 -14
  550. package/src/navigation-overlay-close/README.md +1 -0
  551. package/src/navigation-overlay-close/block.json +7 -0
  552. package/src/navigation-overlay-close/style.scss +1 -1
  553. package/src/navigation-submenu/README.md +7 -0
  554. package/src/navigation-submenu/block.json +6 -0
  555. package/src/navigation-submenu/edit.jsx +11 -1
  556. package/src/navigation-submenu/editor.scss +6 -1
  557. package/src/navigation-submenu/index.php +11 -0
  558. package/src/page-list/README.md +8 -0
  559. package/src/page-list/block.json +14 -0
  560. package/src/paragraph/README.md +1 -0
  561. package/src/paragraph/block.json +1 -0
  562. package/src/paragraph/edit.jsx +1 -3
  563. package/src/playlist/README.md +1 -0
  564. package/src/playlist/block.json +1 -0
  565. package/src/playlist/test/edit-component.jsdom.test.jsx +11 -11
  566. package/src/playlist-track/test/edit.jsdom.test.jsx +3 -3
  567. package/src/post-author-biography/README.md +4 -0
  568. package/src/post-author-biography/block.json +5 -0
  569. package/src/post-author-name/README.md +4 -0
  570. package/src/post-author-name/block.json +5 -0
  571. package/src/post-comments-count/README.md +2 -0
  572. package/src/post-comments-count/block.json +3 -0
  573. package/src/post-comments-form/README.md +8 -0
  574. package/src/post-comments-form/block.json +15 -0
  575. package/src/post-content/README.md +3 -0
  576. package/src/post-content/block.json +4 -1
  577. package/src/post-date/README.md +2 -0
  578. package/src/post-date/block.json +3 -0
  579. package/src/post-excerpt/README.md +7 -0
  580. package/src/post-excerpt/block.json +9 -0
  581. package/src/post-featured-image/block.json +1 -0
  582. package/src/post-featured-image/edit.jsx +13 -11
  583. package/src/post-navigation-link/README.md +12 -0
  584. package/src/post-navigation-link/block.json +30 -0
  585. package/src/post-navigation-link/edit.jsx +23 -2
  586. package/src/post-navigation-link/index.php +94 -5
  587. package/src/post-navigation-link/style.scss +2 -0
  588. package/src/post-template/README.md +7 -0
  589. package/src/post-template/block.json +13 -1
  590. package/src/post-terms/README.md +8 -0
  591. package/src/post-terms/block.json +10 -0
  592. package/src/post-time-to-read/README.md +8 -0
  593. package/src/post-time-to-read/block.json +10 -0
  594. package/src/post-title/README.md +8 -0
  595. package/src/post-title/block.json +14 -0
  596. package/src/preformatted/README.md +9 -0
  597. package/src/preformatted/block.json +11 -0
  598. package/src/pullquote/README.md +2 -0
  599. package/src/pullquote/block.json +3 -1
  600. package/src/query-no-results/README.md +10 -0
  601. package/src/query-no-results/block.json +14 -2
  602. package/src/query-pagination/README.md +6 -0
  603. package/src/query-pagination/block.json +20 -0
  604. package/src/query-pagination/style.scss +3 -0
  605. package/src/query-pagination-next/README.md +2 -0
  606. package/src/query-pagination-next/block.json +3 -0
  607. package/src/query-pagination-numbers/README.md +2 -0
  608. package/src/query-pagination-numbers/block.json +3 -0
  609. package/src/query-pagination-previous/README.md +2 -0
  610. package/src/query-pagination-previous/block.json +3 -0
  611. package/src/query-title/README.md +2 -0
  612. package/src/query-title/block.json +3 -0
  613. package/src/query-total/README.md +8 -0
  614. package/src/query-total/block.json +10 -0
  615. package/src/quote/README.md +3 -0
  616. package/src/quote/block.json +3 -0
  617. package/src/read-more/README.md +8 -0
  618. package/src/read-more/block.json +11 -0
  619. package/src/rss/README.md +8 -0
  620. package/src/rss/block.json +10 -0
  621. package/src/search/README.md +1 -0
  622. package/src/search/block.json +2 -1
  623. package/src/site-tagline/README.md +9 -0
  624. package/src/site-tagline/block.json +12 -1
  625. package/src/site-title/README.md +8 -0
  626. package/src/site-title/block.json +11 -1
  627. package/src/social-links/README.md +3 -0
  628. package/src/social-links/block.json +4 -0
  629. package/src/social-links/edit.jsx +2 -3
  630. package/src/tab-list/README.md +2 -0
  631. package/src/tab-list/block.json +4 -0
  632. package/src/tab-list/edit.jsx +3 -0
  633. package/src/tab-list/save.jsx +3 -0
  634. package/src/tab-panel/README.md +9 -0
  635. package/src/tab-panel/block.json +25 -0
  636. package/src/tab-panel/controls.jsx +2 -2
  637. package/src/tab-panel/style.scss +5 -2
  638. package/src/tab-panels/README.md +9 -0
  639. package/src/tab-panels/block.json +21 -1
  640. package/src/table/editor.scss +8 -2
  641. package/src/table/style.scss +4 -4
  642. package/src/table-of-contents/README.md +6 -0
  643. package/src/table-of-contents/block.json +7 -0
  644. package/src/tabs/README.md +11 -0
  645. package/src/tabs/block.json +27 -1
  646. package/src/tag-cloud/README.md +9 -0
  647. package/src/tag-cloud/block.json +19 -0
  648. package/src/tag-cloud/style.scss +1 -1
  649. package/src/template-part/edit/selection-modal.jsx +1 -1
  650. package/src/template-part/index.php +16 -3
  651. package/src/term-count/README.md +10 -0
  652. package/src/term-count/block.json +12 -0
  653. package/src/term-description/README.md +8 -0
  654. package/src/term-description/block.json +13 -0
  655. package/src/term-name/README.md +9 -0
  656. package/src/term-name/block.json +16 -1
  657. package/src/term-name/index.php +1 -1
  658. package/src/term-template/README.md +8 -0
  659. package/src/term-template/block.json +14 -1
  660. package/src/utils/search-patterns.js +9 -53
  661. package/src/utils/style-state.js +6 -4
  662. package/src/utils/test/{search-patterns.js → search-patterns.jsdom.test.js} +1 -22
  663. package/src/utils/test/waveform-player-auto-init.jsdom.test.js +25 -0
  664. package/src/utils/test/waveform-player-dependency.jsdom.test.js +7 -60
  665. package/src/utils/test/waveform-utils.browser.test.js +3 -15
  666. package/src/utils/waveform-utils.js +1 -1
  667. package/src/verse/README.md +4 -0
  668. package/src/verse/block.json +4 -0
  669. package/src/verse/style.scss +11 -2
  670. package/src/video/README.md +11 -0
  671. package/src/video/block.json +12 -0
  672. package/src/video/edit.jsx +65 -49
  673. package/src/video/index.js +0 -2
  674. package/src/video/save.jsx +10 -1
  675. package/build/columns/utils.cjs +0 -112
  676. package/build/columns/utils.cjs.map +0 -7
  677. package/build/video/variations.cjs +0 -75
  678. package/build/video/variations.cjs.map +0 -7
  679. package/build-module/columns/utils.mjs +0 -78
  680. package/build-module/columns/utils.mjs.map +0 -7
  681. package/build-module/video/variations.mjs +0 -50
  682. package/build-module/video/variations.mjs.map +0 -7
  683. package/src/columns/test/utils.js +0 -331
  684. package/src/columns/utils.js +0 -176
  685. package/src/video/test/variations.js +0 -63
  686. package/src/video/variations.js +0 -62
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/image/image.jsx"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport {\n\tExternalLink,\n\tFocalPointPicker,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl as WCTextareaControl,\n\tTextControl,\n\tCheckboxControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\tPlaceholder,\n\tMenuItem,\n\tToolbarItem,\n\tDropdownMenu,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tuseMergeRefs,\n\tuseResizeObserver,\n\tuseViewportMatch,\n} from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tuseSettings,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tprivateApis as blockEditorPrivateApis,\n\tBlockSettingsMenuControls,\n} from '@wordpress/block-editor';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';\nimport { crop, overlayText, upload, chevronDown } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport { isExternalImage } from './edit';\nimport { Caption } from '../utils/caption';\nimport { MediaControl } from '../utils/media-control';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport {\n\tgetActiveDimensionValue,\n\tgetDimensionResetAttributes,\n\tgetDimensionUpdateAttributes,\n\tgetStyleStateKey,\n} from '../utils/style-state';\nimport { useOpenImageMediaEditorModal } from './use-open-image-media-editor-modal';\nimport {\n\tMIN_SIZE,\n\tALLOWED_MEDIA_TYPES,\n\tSIZED_LAYOUTS,\n\tDEFAULT_MEDIA_SIZE_SLUG,\n} from './constants';\nimport { evalAspectRatio, mediaPosition } from './utils';\n\nconst {\n\tDimensionsTool,\n\tisDefaultBlockStyleState,\n\tResolutionTool,\n\tmediaEditKey,\n\tmediaSideloadFromUrlKey,\n} = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nconst WRITEMODE_POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\n// If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles.\nconst ImageWrapper = ( { href, children } ) => {\n\tif ( ! href ) {\n\t\treturn children;\n\t}\n\treturn (\n\t\t<a\n\t\t\thref={ href }\n\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\taria-disabled\n\t\t\tstyle={ {\n\t\t\t\t// When the Image block is linked,\n\t\t\t\t// it's wrapped with a disabled <a /> tag.\n\t\t\t\t// Restore cursor style so it doesn't appear 'clickable'\n\t\t\t\t// and remove pointer events. Safari needs the display property.\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\tcursor: 'default',\n\t\t\t\tdisplay: 'inline',\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</a>\n\t);\n};\n\nfunction ContentOnlyControls( {\n\tattributes,\n\tsetAttributes,\n\tlockAltControls,\n\tlockAltControlsMessage,\n\tlockTitleControls,\n\tlockTitleControlsMessage,\n} ) {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst [ isAltDialogOpen, setIsAltDialogOpen ] = useState( false );\n\tconst [ isTitleDialogOpen, setIsTitleDialogOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarItem ref={ setPopoverAnchor }>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'More' ) }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t\tdescription: __( 'Displays more controls.' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tpopoverProps={ WRITEMODE_POPOVER_PROPS }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsAltDialogOpen( true );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t\t\t\t'Alternative text',\n\t\t\t\t\t\t\t\t\t\t'Alternative text for an image. Block toolbar label, a low character count is preferred.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsTitleDialogOpen( true );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Title text' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t\t{ isAltDialogOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonClose={ () => setIsAltDialogOpen( false ) }\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-image__toolbar_content_textarea__container\">\n\t\t\t\t\t\t<WCTextareaControl\n\t\t\t\t\t\t\tclassName=\"wp-block-image__toolbar_content_textarea\"\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tvalue={ attributes.alt || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={ lockAltControls }\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tlockAltControls ? (\n\t\t\t\t\t\t\t\t\t<>{ lockAltControlsMessage }</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t{ isTitleDialogOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonClose={ () => setIsTitleDialogOpen( false ) }\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-image__toolbar_content_textarea__container\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tclassName=\"wp-block-image__toolbar_content_textarea\"\n\t\t\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\t\t\tvalue={ attributes.title || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\ttitle: value,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={ lockTitleControls }\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tlockTitleControls ? (\n\t\t\t\t\t\t\t\t\t<>{ lockTitleControlsMessage }</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\tcreateInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'Describe the role of this image on the page. <a>(Note: many devices and browsers do not display this text.)</a>'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\" />\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function Image( {\n\ttemporaryURL,\n\tisSideloading,\n\tattributes,\n\tsetAttributes,\n\tisSingleSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n\tparentLayoutType,\n\tmaxContentWidth,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tfocalPoint,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t\tlightbox,\n\t\tmetadata,\n\t\tisDecorative,\n\t} = attributes;\n\tconst [ imageElement, setImageElement ] = useState();\n\tconst [ resizeDelta, setResizeDelta ] = useState( null );\n\tconst [ pixelSize, setPixelSize ] = useState( {} );\n\tconst [ offsetTop, setOffsetTop ] = useState( 0 );\n\tconst setResizeObserved = useResizeObserver( ( [ entry ] ) => {\n\t\tif ( ! resizeDelta ) {\n\t\t\tconst [ box ] = entry.borderBoxSize;\n\t\t\tsetPixelSize( { width: box.inlineSize, height: box.blockSize } );\n\t\t}\n\t\t// This is usually 0 unless the image height is less than the line-height.\n\t\tsetOffsetTop( entry.target.offsetTop );\n\t} );\n\tconst effectResizeableBoxPlacement = useCallback( () => {\n\t\tsetOffsetTop( imageElement?.offsetTop ?? 0 );\n\t}, [ imageElement ] );\n\tconst setRefs = useMergeRefs( [ setImageElement, setResizeObserved ] );\n\tconst { allowResize = true, imageCrop = false } = context;\n\t// Only a cropped gallery (flex layout) controls the image height via its\n\t// own CSS. Grid galleries and standalone images keep the baseline\n\t// `height: auto` so a theme can't squish them.\n\tconst isCroppedGalleryImage = imageCrop && parentLayoutType === 'flex';\n\n\tconst { image, attachmentResolutionError } = useSelect(\n\t\t( select ) => {\n\t\t\tconst imageRecord =\n\t\t\t\tid && isSingleSelected\n\t\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t{ context: 'view' }\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\n\t\t\t// Check if the attachment resolution failed with a specific error.\n\t\t\t// We use getResolutionError instead of hasFinishedResolution so we\n\t\t\t// can distinguish 404 (attachment doesn't exist) from transient\n\t\t\t// errors (500, 403, network) that shouldn't clear the id.\n\t\t\tconst resolutionError =\n\t\t\t\tid && isSingleSelected\n\t\t\t\t\t? select( coreStore ).getResolutionError(\n\t\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t{ context: 'view' },\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\timage: imageRecord,\n\t\t\t\tattachmentResolutionError: resolutionError,\n\t\t\t};\n\t\t},\n\t\t[ id, isSingleSelected ]\n\t);\n\n\tconst {\n\t\tcanInsertCover,\n\t\timageEditing,\n\t\timageSizes,\n\t\tmaxWidth,\n\t\teditMediaEntity,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\teditMediaEntity: settings?.[ mediaEditKey ],\n\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t'core/cover',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { getBlock, getSettings } = useSelect( blockEditorStore );\n\tconst cropButtonRef = useRef();\n\t// URL of a freshly generated file (crop/rotate result) from the media\n\t// editor that the browser may not have finished loading; cleared by the\n\t// <img> load/error handlers, or by the settle effect below when the\n\t// rendered image already shows it.\n\tconst [ pendingSwapUrl, setPendingSwapUrl ] = useState();\n\tconst isSwappingMedia = !! pendingSwapUrl;\n\tconst handleMediaEditorModalClose = useCallback(\n\t\t() => cropButtonRef.current?.focus(),\n\t\t[]\n\t);\n\tconst openImageMediaEditorModal = useOpenImageMediaEditorModal( {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tonClose: handleMediaEditorModalClose,\n\t\tonUrlChange: setPendingSwapUrl,\n\t} );\n\n\tconst {\n\t\treplaceBlocks,\n\t\ttoggleSelection,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ hasImageErrored, setHasImageErrored ] = useState( false );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\tconst showDimensionsControls = allowResize && hasNonContentControls;\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! isWideAligned &&\n\t\tisLargeViewport;\n\t// An image is uploading if it has a temporary blob URL, or if it is\n\t// being processed client-side (e.g. transcoded or generating sub-sizes).\n\tconst isUploading = !! temporaryURL || isSideloading;\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\n\t// If the image has an id but the attachment doesn't exist on this site,\n\t// clear the id so Gutenberg treats the image as external.\n\t// This handles content copied between WordPress sites.\n\t//\n\t// Known limitation: if a different attachment with the same id happens to\n\t// exist on the destination site, the lookup will succeed and the wrong\n\t// local image will be used. URL matching could address this in a follow-up.\n\t// See: https://github.com/WordPress/gutenberg/issues/74156\n\tuseEffect( () => {\n\t\tif ( ! id || ! isSingleSelected ) {\n\t\t\treturn;\n\t\t}\n\t\t// Only clear for confirmed 404s. apiFetch throws the Response object\n\t\t// for HTTP errors, so checking .status === 404 avoids incorrectly\n\t\t// clearing the id on 403, 500, or network failures, which would\n\t\t// cause data loss for valid local attachments.\n\t\tif ( attachmentResolutionError?.status === 404 ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { id: undefined } );\n\t\t}\n\t}, [\n\t\tid,\n\t\tisSingleSelected,\n\t\tattachmentResolutionError,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\t/*\n\t * Externally hosted images can be uploaded to the media library. The\n\t * server sideloads the URL (see mediaSideloadFromUrl), so this works even\n\t * when the editor is cross-origin isolated and the browser cannot read the\n\t * cross-origin image's bytes itself.\n\t */\n\tconst canUploadExternalImage =\n\t\tisSingleSelected &&\n\t\tisExternalImage( id, url ) &&\n\t\t!! getSettings()[ mediaSideloadFromUrlKey ];\n\n\t// Get naturalWidth and naturalHeight from image, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageElement?.naturalWidth || loadedNaturalWidth || undefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageElement?.naturalHeight || loadedNaturalHeight || undefined,\n\t\t};\n\t}, [ loadedNaturalWidth, loadedNaturalHeight, imageElement?.complete ] );\n\n\t// A media editor update can be undone or superseded before its\n\t// attributes land, leaving the rendered image untouched. No load event\n\t// fires in that case, so clear the pending swap whenever the rendered\n\t// image already shows the pending URL.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tpendingSwapUrl &&\n\t\t\tpendingSwapUrl === url &&\n\t\t\timageElement?.complete\n\t\t) {\n\t\t\tsetPendingSwapUrl( undefined );\n\t\t}\n\t}, [ pendingSwapUrl, url, imageElement ] );\n\n\tfunction onImageError() {\n\t\tsetPendingSwapUrl( undefined );\n\t\tsetHasImageErrored( true );\n\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onImageLoad( event ) {\n\t\tsetPendingSwapUrl( undefined );\n\t\tsetHasImageErrored( false );\n\t\tsetLoadedNaturalSize( {\n\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t} );\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetLightbox( enable ) {\n\t\tif ( enable && ! lightboxSetting?.enabled ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: true },\n\t\t\t\tisDecorative: false,\n\t\t\t} );\n\t\t} else if ( ! enable && lightboxSetting?.enabled ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: false },\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction resetLightbox() {\n\t\t// When deleting a link from an image while lightbox settings\n\t\t// are enabled by default, we should disable the lightbox,\n\t\t// otherwise the resulting UX looks like a mistake.\n\t\t// See https://github.com/WordPress/gutenberg/pull/59890/files#r1532286123.\n\t\tif ( lightboxSetting?.enabled && lightboxSetting?.allowEditing ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: false },\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateIsDecorative( value ) {\n\t\tsetAttributes( {\n\t\t\tisDecorative: value || undefined,\n\t\t\t...( value && {\n\t\t\t\talt: '',\n\t\t\t\tcaption: undefined,\n\t\t\t\thref: undefined,\n\t\t\t\tlinkDestination: undefined,\n\t\t\t\tlinkTarget: undefined,\n\t\t\t\trel: undefined,\n\t\t\t} ),\n\t\t} );\n\t}\n\n\tconst imperativeFocalPointPreview = ( value ) => {\n\t\tif ( imageElement ) {\n\t\t\timageElement.style.setProperty(\n\t\t\t\t'object-position',\n\t\t\t\tmediaPosition( value )\n\t\t\t);\n\t\t}\n\t};\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tconst mediaSideloadFromUrl = getSettings()[ mediaSideloadFromUrlKey ];\n\t\tif ( ! mediaSideloadFromUrl ) {\n\t\t\treturn;\n\t\t}\n\t\tmediaSideloadFromUrl( {\n\t\t\turl,\n\t\t\tonSuccess( img ) {\n\t\t\t\tonSelectImage( img );\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst canEditImage =\n\t\tid &&\n\t\tnaturalWidth &&\n\t\tnaturalHeight &&\n\t\timageEditing &&\n\t\t!! editMediaEntity;\n\tconst allowCrop =\n\t\tisSingleSelected &&\n\t\tcanEditImage &&\n\t\t!! openImageMediaEditorModal &&\n\t\t! isContentOnlyMode &&\n\t\t! isUploading;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox component. Calculations later on for that\n\t// component are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst [ lightboxSetting ] = useSettings( 'lightbox' );\n\n\tconst showLightboxSetting =\n\t\t// If a block-level override is set, we should give users the option to\n\t\t// remove that override, even if the lightbox UI is disabled in the settings.\n\t\t( !! lightbox && lightbox?.enabled !== lightboxSetting?.enabled ) ||\n\t\tlightboxSetting?.allowEditing;\n\n\tconst lightboxChecked =\n\t\t!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst selectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst { getSelectedBlockStyleState } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn getSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId, isSingleSelected ]\n\t);\n\tconst hasSelectedStyleState =\n\t\t! isDefaultBlockStyleState( selectedStyleState );\n\tconst selectedStyleStateKey = getStyleStateKey( selectedStyleState );\n\tconst activeWidth = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'width',\n\t} );\n\tconst activeHeight = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'height',\n\t} );\n\tconst activeAspectRatio = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'aspectRatio',\n\t} );\n\tconst activeScale = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'scale',\n\t\tstyleKey: 'objectFit',\n\t} );\n\tconst setDimensionAttributes = ( nextDimensions ) => {\n\t\tsetAttributes(\n\t\t\tgetDimensionUpdateAttributes( {\n\t\t\t\tstyle: attributes.style,\n\t\t\t\tselectedState: selectedStyleState,\n\t\t\t\thasSelectedStyleState,\n\t\t\t\tnextDimensions,\n\t\t\t\tdimensionKeyMap: { scale: 'objectFit' },\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst dimensionsControl =\n\t\tshowDimensionsControls &&\n\t\t( SIZED_LAYOUTS.includes( parentLayoutType ) ? (\n\t\t\t<DimensionsTool\n\t\t\t\tkey={ selectedStyleStateKey }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tvalue={ { aspectRatio: activeAspectRatio, scale: activeScale } }\n\t\t\t\tonChange={ ( { aspectRatio: newAspectRatio } ) => {\n\t\t\t\t\tsetDimensionAttributes( {\n\t\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t\t\tscale: 'cover',\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\ttools={ [ 'aspectRatio' ] }\n\t\t\t/>\n\t\t) : (\n\t\t\t<DimensionsTool\n\t\t\t\tkey={ selectedStyleStateKey }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tvalue={ {\n\t\t\t\t\twidth: activeWidth,\n\t\t\t\t\theight: activeHeight,\n\t\t\t\t\tscale: activeScale,\n\t\t\t\t\taspectRatio: activeAspectRatio,\n\t\t\t\t} }\n\t\t\t\tonChange={ ( {\n\t\t\t\t\twidth: newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} ) => {\n\t\t\t\t\tsetDimensionAttributes( {\n\t\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\t\theight: newHeight,\n\t\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t\t\tscale: newScale,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\ttools={\n\t\t\t\t\tisWideAligned\n\t\t\t\t\t\t? [ 'aspectRatio', 'scale' ]\n\t\t\t\t\t\t: [ 'aspectRatio', 'widthHeight', 'scale' ]\n\t\t\t\t}\n\t\t\t/>\n\t\t) );\n\n\tconst resetSettings = () => {\n\t\tsetAttributes( {\n\t\t\tlightbox: undefined,\n\t\t} );\n\t\tupdateImage( DEFAULT_MEDIA_SIZE_SLUG );\n\t};\n\n\tconst arePatternOverridesEnabled =\n\t\tmetadata?.bindings?.__default?.source === 'core/pattern-overrides';\n\n\tconst {\n\t\tlockUrlControls = false,\n\t\tlockHrefControls = false,\n\t\tlockAltControls = false,\n\t\tlockAltControlsMessage,\n\t\tlockTitleControls = false,\n\t\tlockTitleControlsMessage,\n\t\thideCaptionControls = false,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\turl: urlBinding,\n\t\t\t\talt: altBinding,\n\t\t\t\ttitle: titleBinding,\n\t\t\t\tcaption: captionBinding,\n\t\t\t} = metadata?.bindings || {};\n\t\t\tconst hasParentPattern = !! context[ 'pattern/overrides' ];\n\t\t\tconst urlBindingSource = getBlockBindingsSource(\n\t\t\t\turlBinding?.source\n\t\t\t);\n\t\t\tconst altBindingSource = getBlockBindingsSource(\n\t\t\t\taltBinding?.source\n\t\t\t);\n\t\t\tconst titleBindingSource = getBlockBindingsSource(\n\t\t\t\ttitleBinding?.source\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! urlBinding &&\n\t\t\t\t\t! urlBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: urlBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockHrefControls:\n\t\t\t\t\t// Disable editing the link of the URL if the image is inside a pattern instance.\n\t\t\t\t\t// This is a temporary solution until we support overriding the link on the frontend.\n\t\t\t\t\thasParentPattern || arePatternOverridesEnabled,\n\t\t\t\thideCaptionControls: !! captionBinding,\n\t\t\t\tlockAltControls:\n\t\t\t\t\t!! altBinding &&\n\t\t\t\t\t! altBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: altBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockAltControlsMessage: altBindingSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\taltBindingSource.label\n\t\t\t\t\t\t)\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t\tlockTitleControls:\n\t\t\t\t\t!! titleBinding &&\n\t\t\t\t\t! titleBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: titleBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockTitleControlsMessage: titleBindingSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\ttitleBindingSource.label\n\t\t\t\t\t\t)\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tarePatternOverridesEnabled,\n\t\t\tcontext,\n\t\t\tisSingleSelected,\n\t\t\tmetadata?.bindings,\n\t\t]\n\t);\n\n\tconst showUrlInput =\n\t\tisSingleSelected &&\n\t\t! lockHrefControls &&\n\t\t! lockUrlControls &&\n\t\t! isDecorative;\n\n\tconst showCoverControls =\n\t\tisSingleSelected && canInsertCover && ! isContentOnlyMode;\n\n\tconst showBlockControls = showUrlInput || allowCrop || showCoverControls;\n\n\tconst mediaControls = isSingleSelected && ! lockUrlControls && (\n\t\t<>\n\t\t\t{ /* For contentOnly mode, put this button in its own area so it has borders around it. */ }\n\t\t\t<BlockControls group={ isContentOnlyMode ? 'inline' : 'other' }>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tname={ ! url ? __( 'Add image' ) : __( 'Replace' ) }\n\t\t\t\t\tonReset={ () => onSelectImage( undefined ) }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n\n\tconst controls = (\n\t\t<>\n\t\t\t{ showBlockControls && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t{ showUrlInput && (\n\t\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t\t\tshowLightboxSetting={ showLightboxSetting }\n\t\t\t\t\t\t\tlightboxEnabled={ lightboxChecked }\n\t\t\t\t\t\t\tonSetLightbox={ onSetLightbox }\n\t\t\t\t\t\t\tresetLightbox={ resetLightbox }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ allowCrop && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tref={ cropButtonRef }\n\t\t\t\t\t\t\tonClick={ openImageMediaEditorModal }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\t\tlabel={ __( 'Edit image' ) }\n\t\t\t\t\t\t\t// Disable rather than hide while the edited image\n\t\t\t\t\t\t\t// loads, so the button keeps focus when the modal\n\t\t\t\t\t\t\t// closes instead of dropping it to the canvas.\n\t\t\t\t\t\t\tdisabled={ isSwappingMedia }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showCoverControls && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ canUploadExternalImage && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload to Media Library' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isContentOnlyMode && (\n\t\t\t\t// Add some extra controls for content attributes when content only mode is active.\n\t\t\t\t// With content only mode active, the inspector is hidden, so users need another way\n\t\t\t\t// to edit these attributes.\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ContentOnlyControls\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tlockAltControls={ lockAltControls }\n\t\t\t\t\t\tlockAltControlsMessage={ lockAltControlsMessage }\n\t\t\t\t\t\tlockTitleControls={ lockTitleControls }\n\t\t\t\t\t\tlockTitleControlsMessage={ lockTitleControlsMessage }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Media' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tonSelectImage( undefined );\n\t\t\t\t\t\t\tsetAttributes( { isDecorative: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! lockUrlControls && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\t\t\tonDeselect={ () => onSelectImage( undefined ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<MediaControl\n\t\t\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\t\t\tmediaUrl={ url }\n\t\t\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\t\t\tfilename={\n\t\t\t\t\t\t\t\t\t\timage?.media_details?.sizes?.full\n\t\t\t\t\t\t\t\t\t\t\t?.file ||\n\t\t\t\t\t\t\t\t\t\timage?.slug ||\n\t\t\t\t\t\t\t\t\t\tgetFilename( url )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\t\t\tonReset={ () => onSelectImage( undefined ) }\n\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\temptyLabel={ __( 'Add image' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isDecorative && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! alt }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WCTextareaControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\t\tvalue={ alt || '' }\n\t\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\t\treadOnly={ lockAltControls }\n\t\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t\tlockAltControls ? (\n\t\t\t\t\t\t\t\t\t\t\t<>{ lockAltControlsMessage }</>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t{ ! lockAltControls && ! lightboxChecked && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Mark as decorative' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! isDecorative }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { isDecorative: false } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Mark as decorative' ) }\n\t\t\t\t\t\t\t\t\tchecked={ !! isDecorative }\n\t\t\t\t\t\t\t\t\tonChange={ updateIsDecorative }\n\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t'Hidden from assistive technologies.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tresetAllFilter={ ( attrs ) => {\n\t\t\t\t\treturn getDimensionResetAttributes( {\n\t\t\t\t\t\tattributes: attrs,\n\t\t\t\t\t\tselectedState: selectedStyleState,\n\t\t\t\t\t\thasSelectedStyleState,\n\t\t\t\t\t\tkeys: [ 'aspectRatio', 'height', 'objectFit', 'width' ],\n\t\t\t\t\t\tdefaultAttributes: {\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\tfocalPoint: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ dimensionsControl }\n\t\t\t\t{ ! hasSelectedStyleState && url && scale && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Focal point' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! focalPoint }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfocalPoint: undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FocalPointPicker\n\t\t\t\t\t\t\tlabel={ __( 'Focal point' ) }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tvalue={ focalPoint }\n\t\t\t\t\t\t\tonDragStart={ imperativeFocalPointPreview }\n\t\t\t\t\t\t\tonDrag={ imperativeFocalPointPreview }\n\t\t\t\t\t\t\tonChange={ ( newFocalPoint ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfocalPoint: newFocalPoint,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ !! imageSizeOptions.length && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ resetSettings }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\tdefaultValue={ DEFAULT_MEDIA_SIZE_SLUG }\n\t\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\treadOnly={ lockTitleControls }\n\t\t\t\t\thelp={\n\t\t\t\t\t\tlockTitleControls ? (\n\t\t\t\t\t\t\t<>{ lockTitleControlsMessage }</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tcreateInterpolateElement(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Describe the role of this image on the page. <a>(Note: many devices and browsers do not display this text.)</a>'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\" />\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( isDecorative ) {\n\t\tdefaultedAlt = filename\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'This image has been marked as decorative; its file name is %s'\n\t\t\t\t\t),\n\t\t\t\t\tfilename\n\t\t\t\t)\n\t\t\t: __( 'This image has been marked as decorative.' );\n\t} else if ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst { postType, postId, queryId } = context;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\n\tconst img = (\n\t\t<ImageWrapper href={ href }>\n\t\t\t{ temporaryURL && hasImageErrored ? (\n\t\t\t\t// Show a placeholder during upload when the blob URL can't be loaded. This can\n\t\t\t\t// happen when the user uploads a HEIC image in a browser that doesn't support them.\n\t\t\t\t<Placeholder\n\t\t\t\t\tclassName=\"wp-block-image__placeholder\"\n\t\t\t\t\twithIllustration\n\t\t\t\t>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\t\t\talt={ defaultedAlt }\n\t\t\t\t\t\tonError={ onImageError }\n\t\t\t\t\t\tonLoad={ onImageLoad }\n\t\t\t\t\t\tref={ setRefs }\n\t\t\t\t\t\tclassName={ clsx( borderProps.className, {\n\t\t\t\t\t\t\t'is-swapping-media': isSwappingMedia,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\twidth={ naturalWidth }\n\t\t\t\t\t\theight={ naturalHeight }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t\t...( resizeDelta\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\tpixelSize.width + resizeDelta.width,\n\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\tpixelSize.height +\n\t\t\t\t\t\t\t\t\t\t\tresizeDelta.height,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: ( () => {\n\t\t\t\t\t\t\t\t\t\tconst style = {};\n\t\t\t\t\t\t\t\t\t\tif ( width === 'auto' ) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.width = 'auto';\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\twidth !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\twidth !== null\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.width =\n\t\t\t\t\t\t\t\t\t\t\t\ttypeof width === 'number'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${ width }px`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: width;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif ( height === 'auto' ) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.height = 'auto';\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\theight !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\theight !== null\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.height =\n\t\t\t\t\t\t\t\t\t\t\t\ttypeof height === 'number'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${ height }px`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: height;\n\t\t\t\t\t\t\t\t\t\t} else if ( ! isCroppedGalleryImage ) {\n\t\t\t\t\t\t\t\t\t\t\t// Default to `height: auto` so a\n\t\t\t\t\t\t\t\t\t\t\t// theme that sets an explicit height\n\t\t\t\t\t\t\t\t\t\t\t// on images can't squish them. Inside\n\t\t\t\t\t\t\t\t\t\t\t// a cropped gallery the gallery's own\n\t\t\t\t\t\t\t\t\t\t\t// CSS controls the height instead.\n\t\t\t\t\t\t\t\t\t\t\tstyle.height = 'auto';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn style;\n\t\t\t\t\t\t\t\t\t} )() ),\n\t\t\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t\t\tobjectPosition:\n\t\t\t\t\t\t\t\tfocalPoint && scale\n\t\t\t\t\t\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t\t...shadowProps.style,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ( isUploading || isSwappingMedia ) && <Spinner /> }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</ImageWrapper>\n\t);\n\n\tlet resizableBox;\n\tif (\n\t\tisResizable &&\n\t\tisSingleSelected &&\n\t\t! isUploading &&\n\t\t! SIZED_LAYOUTS.includes( parentLayoutType )\n\t) {\n\t\tconst numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = pixelSize.width / pixelSize.height;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\t\tconst maxResizeWidth = maxContentWidth || maxWidthBuffer;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\t\tresizableBox = (\n\t\t\t<ResizableBox\n\t\t\t\tref={ effectResizeableBoxPlacement }\n\t\t\t\tstyle={ {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t// To match the vertical-align: bottom of the img (from style.scss)\n\t\t\t\t\t// syncs the top with the img. This matters when the img height is\n\t\t\t\t\t// less than the line-height.\n\t\t\t\t\tinset: `${ offsetTop }px 0 0 0`,\n\t\t\t\t} }\n\t\t\t\tsize={ pixelSize }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxResizeWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxResizeWidth / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResize={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetResizeDelta( delta );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\tsetResizeDelta( null );\n\t\t\t\t\tsetPixelSize( ( current ) => ( {\n\t\t\t\t\t\twidth: current.width + delta.width,\n\t\t\t\t\t\theight: current.height + delta.height,\n\t\t\t\t\t} ) );\n\n\t\t\t\t\t// Clear hardcoded width if the resized width is close to the max-content width.\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaxContentWidth &&\n\t\t\t\t\t\t// Only do this if the image is bigger than the container to prevent it from being squished.\n\t\t\t\t\t\t// TODO: Remove this check if the image support setting 100% width.\n\t\t\t\t\t\tnaturalWidth >= maxContentWidth &&\n\t\t\t\t\t\tMath.abs( elt.offsetWidth - maxContentWidth ) < 10\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( ! url && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ mediaControls }\n\t\t\t\t{ controls }\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Set the post's featured image with the current image.\n\t */\n\tconst setPostFeatureImage = () => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tfeatured_media: id,\n\t\t} );\n\t\tcreateSuccessNotice( __( 'Post featured image updated.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst featuredImageControl =\n\t\t! isDescendentOfQueryLoop && postId && id ? (\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { canEdit, selectedClientIds } ) =>\n\t\t\t\t\tcanEdit &&\n\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\tclientId === selectedClientIds[ 0 ] && (\n\t\t\t\t\t\t<MenuItem onClick={ setPostFeatureImage }>\n\t\t\t\t\t\t\t{ __( 'Set as featured image' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</BlockSettingsMenuControls>\n\t\t) : null;\n\n\treturn (\n\t\t<>\n\t\t\t{ mediaControls }\n\t\t\t{ controls }\n\t\t\t{ featuredImageControl }\n\t\t\t{ img }\n\t\t\t{ resizableBox }\n\n\t\t\t{ ! isDecorative && (\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Image caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tisSingleSelected &&\n\t\t\t\t\t\t( hasNonContentControls || isContentOnlyMode ) &&\n\t\t\t\t\t\t! hideCaptionControls\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAkBO;AACP,qBAIO;AACP,kBAAuC;AACvC,0BAWO;AACP,qBAOO;AACP,kBAAuC;AACvC,iBAA4B;AAC5B,oBAA0D;AAC1D,mBAAuD;AACvD,qBAAsC;AACtC,uBAAmC;AACnC,yBAAuB;AACvB,kBAAyC;AACzC,kBAAgC;AAChC,qBAAwB;AACxB,2BAA6B;AAC7B,mBAA+C;AAC/C,yBAKO;AACP,+CAA6C;AAC7C,uBAKO;AACP,mBAA+C;AAiC7C;AA/BF,IAAM;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,cAAe;AAC9B,WACC,4EACG;AAAA;AAAA,MACA;AAAA,OACH;AAAA,EAEF;AAKA,QAAM,sBAAsB,MAAM;AACjC,qBAAkB,YAAY,UAAU,QAAQ;AAAA,MAC/C,gBAAgB;AAAA,IACjB,CAAE;AACF,4BAAqB,gBAAI,8BAA+B,GAAG;AAAA,MAC1D,MAAM;AAAA,IACP,CAAE;AAAA,EACH;AAEA,QAAM,uBACL,CAAE,2BAA2B,UAAU,KACtC,4CAAC,iDACE,WAAE,EAAE,SAAS,kBAAkB,MAChC,WACA,kBAAkB,WAAW,KAC7B,aAAa,kBAAmB,CAAE,KACjC,4CAAC,8BAAS,SAAU,qBACjB,8BAAI,uBAAwB,GAC/B,GAGH,IACG;AAEL,SACC,4EACG;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA,CAAE,gBACH;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAa;AAAA,QACb;AAAA,QACA,WAAQ,gBAAI,oBAAqB;AAAA,QACjC,mBACC,qBACE,yBAAyB,sBAC3B,CAAE;AAAA;AAAA,IAEJ;AAAA,KAEF;AAEF;",
6
- "names": ["blockEditorPrivateApis", "WCTextareaControl", "coreStore", "getSettings", "blockEditorStore", "noticesStore", "img", "useCustomUnits", "ImageURLInputUI", "ToolsPanel", "ToolsPanelItem", "useBorderProps", "getShadowClassesAndStyles", "clsx"]
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport {\n\tExternalLink,\n\tFocalPointPicker,\n\tResizableBox,\n\tSpinner,\n\tTextareaControl as WCTextareaControl,\n\tTextControl,\n\tCheckboxControl as WCCheckboxControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\tPlaceholder,\n\tMenuItem,\n\tToolbarItem,\n\tDropdownMenu,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tuseMergeRefs,\n\tuseResizeObserver,\n\tuseViewportMatch,\n} from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\t__experimentalImageURLInputUI as ImageURLInputUI,\n\tMediaReplaceFlow,\n\tstore as blockEditorStore,\n\tuseSettings,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tprivateApis as blockEditorPrivateApis,\n\tBlockSettingsMenuControls,\n} from '@wordpress/block-editor';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getFilename } from '@wordpress/url';\nimport { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';\nimport { crop, overlayText, upload, chevronDown } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { unlock } from '../lock-unlock';\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport { isExternalImage } from './edit';\nimport { Caption } from '../utils/caption';\nimport { MediaControl } from '../utils/media-control';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nimport {\n\tgetActiveDimensionValue,\n\tgetDimensionResetAttributes,\n\tgetDimensionUpdateAttributes,\n\tgetStyleStateKey,\n} from '../utils/style-state';\nimport { useOpenImageMediaEditorModal } from './use-open-image-media-editor-modal';\nimport {\n\tMIN_SIZE,\n\tALLOWED_MEDIA_TYPES,\n\tSIZED_LAYOUTS,\n\tDEFAULT_MEDIA_SIZE_SLUG,\n} from './constants';\nimport { evalAspectRatio, mediaPosition } from './utils';\n\nconst {\n\tDimensionsTool,\n\tResolutionTool,\n\tmediaEditKey,\n\tmediaSideloadFromUrlKey,\n} = unlock( blockEditorPrivateApis );\n\nconst scaleOptions = [\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image covers the space evenly.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Image is contained without distortion.' ),\n\t},\n];\n\nconst WRITEMODE_POPOVER_PROPS = {\n\tplacement: 'bottom-start',\n};\n\n// If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles.\nconst ImageWrapper = ( { href, children } ) => {\n\tif ( ! href ) {\n\t\treturn children;\n\t}\n\treturn (\n\t\t<a\n\t\t\thref={ href }\n\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\taria-disabled\n\t\t\tstyle={ {\n\t\t\t\t// When the Image block is linked,\n\t\t\t\t// it's wrapped with a disabled <a /> tag.\n\t\t\t\t// Restore cursor style so it doesn't appear 'clickable'\n\t\t\t\t// and remove pointer events. Safari needs the display property.\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\tcursor: 'default',\n\t\t\t\tdisplay: 'inline',\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</a>\n\t);\n};\n\nfunction ContentOnlyControls( {\n\tattributes,\n\tsetAttributes,\n\tlockAltControls,\n\tlockAltControlsMessage,\n\tlockTitleControls,\n\tlockTitleControlsMessage,\n} ) {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst [ isAltDialogOpen, setIsAltDialogOpen ] = useState( false );\n\tconst [ isTitleDialogOpen, setIsTitleDialogOpen ] = useState( false );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarItem ref={ setPopoverAnchor }>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'More' ) }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t\tdescription: __( 'Displays more controls.' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tpopoverProps={ WRITEMODE_POPOVER_PROPS }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsAltDialogOpen( true );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t\t\t\t'Alternative text',\n\t\t\t\t\t\t\t\t\t\t'Alternative text for an image. Block toolbar label, a low character count is preferred.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsTitleDialogOpen( true );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Title text' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t\t{ isAltDialogOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonClose={ () => setIsAltDialogOpen( false ) }\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-image__toolbar_content_textarea__container\">\n\t\t\t\t\t\t<WCTextareaControl\n\t\t\t\t\t\t\tclassName=\"wp-block-image__toolbar_content_textarea\"\n\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\tvalue={ attributes.alt || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { alt: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={ lockAltControls }\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tlockAltControls ? (\n\t\t\t\t\t\t\t\t\t<>{ lockAltControlsMessage }</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t{ __( 'Leave empty if decorative.' ) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t\t{ isTitleDialogOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tonClose={ () => setIsTitleDialogOpen( false ) }\n\t\t\t\t\toffset={ 13 }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-image__toolbar_content_textarea__container\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tclassName=\"wp-block-image__toolbar_content_textarea\"\n\t\t\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\t\t\tvalue={ attributes.title || '' }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\ttitle: value,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={ lockTitleControls }\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tlockTitleControls ? (\n\t\t\t\t\t\t\t\t\t<>{ lockTitleControlsMessage }</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\tcreateInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'Describe the role of this image on the page. <a>(Note: many devices and browsers do not display this text.)</a>'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\" />\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Popover>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function Image( {\n\ttemporaryURL,\n\tisSideloading,\n\tattributes,\n\tsetAttributes,\n\tisSingleSelected,\n\tinsertBlocksAfter,\n\tonReplace,\n\tonSelectImage,\n\tonSelectURL,\n\tonUploadError,\n\tcontext,\n\tclientId,\n\tblockEditingMode,\n\tparentLayoutType,\n\tmaxContentWidth,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\talign,\n\t\tid,\n\t\thref,\n\t\trel,\n\t\tlinkClass,\n\t\tlinkDestination,\n\t\ttitle,\n\t\twidth,\n\t\theight,\n\t\taspectRatio,\n\t\tscale,\n\t\tfocalPoint,\n\t\tlinkTarget,\n\t\tsizeSlug,\n\t\tlightbox,\n\t\tmetadata,\n\t\tisDecorative,\n\t} = attributes;\n\tconst [ imageElement, setImageElement ] = useState();\n\tconst [ resizeDelta, setResizeDelta ] = useState( null );\n\tconst [ pixelSize, setPixelSize ] = useState( {} );\n\tconst [ offsetTop, setOffsetTop ] = useState( 0 );\n\tconst setResizeObserved = useResizeObserver( ( [ entry ] ) => {\n\t\tif ( ! resizeDelta ) {\n\t\t\tconst [ box ] = entry.borderBoxSize;\n\t\t\tsetPixelSize( { width: box.inlineSize, height: box.blockSize } );\n\t\t}\n\t\t// This is usually 0 unless the image height is less than the line-height.\n\t\tsetOffsetTop( entry.target.offsetTop );\n\t} );\n\tconst effectResizeableBoxPlacement = useCallback( () => {\n\t\tsetOffsetTop( imageElement?.offsetTop ?? 0 );\n\t}, [ imageElement ] );\n\tconst setRefs = useMergeRefs( [ setImageElement, setResizeObserved ] );\n\tconst { allowResize = true, imageCrop = false } = context;\n\t// Only a cropped gallery (flex layout) controls the image height via its\n\t// own CSS. Grid galleries and standalone images keep the baseline\n\t// `height: auto` so a theme can't squish them.\n\tconst isCroppedGalleryImage = imageCrop && parentLayoutType === 'flex';\n\n\tconst { image, attachmentResolutionError } = useSelect(\n\t\t( select ) => {\n\t\t\tconst imageRecord =\n\t\t\t\tid && isSingleSelected\n\t\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t{ context: 'view' }\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\n\t\t\t// Check if the attachment resolution failed with a specific error.\n\t\t\t// We use getResolutionError instead of hasFinishedResolution so we\n\t\t\t// can distinguish 404 (attachment doesn't exist) from transient\n\t\t\t// errors (500, 403, network) that shouldn't clear the id.\n\t\t\tconst resolutionError =\n\t\t\t\tid && isSingleSelected\n\t\t\t\t\t? select( coreStore ).getResolutionError(\n\t\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t{ context: 'view' },\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t: null;\n\n\t\t\treturn {\n\t\t\t\timage: imageRecord,\n\t\t\t\tattachmentResolutionError: resolutionError,\n\t\t\t};\n\t\t},\n\t\t[ id, isSingleSelected ]\n\t);\n\n\tconst {\n\t\tcanInsertCover,\n\t\timageEditing,\n\t\timageSizes,\n\t\tmaxWidth,\n\t\teditMediaEntity,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\timageEditing: settings.imageEditing,\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tmaxWidth: settings.maxWidth,\n\t\t\t\teditMediaEntity: settings?.[ mediaEditKey ],\n\t\t\t\tcanInsertCover: canInsertBlockType(\n\t\t\t\t\t'core/cover',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { getBlock, getSettings } = useSelect( blockEditorStore );\n\tconst cropButtonRef = useRef();\n\t// URL of a freshly generated file (crop/rotate result) from the media\n\t// editor that the browser may not have finished loading; cleared by the\n\t// <img> load/error handlers, or by the settle effect below when the\n\t// rendered image already shows it.\n\tconst [ pendingSwapUrl, setPendingSwapUrl ] = useState();\n\tconst isSwappingMedia = !! pendingSwapUrl;\n\tconst handleMediaEditorModalClose = useCallback(\n\t\t() => cropButtonRef.current?.focus(),\n\t\t[]\n\t);\n\tconst openImageMediaEditorModal = useOpenImageMediaEditorModal( {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tonClose: handleMediaEditorModalClose,\n\t\tonUrlChange: setPendingSwapUrl,\n\t} );\n\n\tconst {\n\t\treplaceBlocks,\n\t\ttoggleSelection,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideAligned = [ 'wide', 'full' ].includes( align );\n\tconst [\n\t\t{ loadedNaturalWidth, loadedNaturalHeight },\n\t\tsetLoadedNaturalSize,\n\t] = useState( {} );\n\tconst [ hasImageErrored, setHasImageErrored ] = useState( false );\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\tconst isContentOnlyMode = blockEditingMode === 'contentOnly';\n\tconst showDimensionsControls = allowResize && hasNonContentControls;\n\tconst isResizable =\n\t\tallowResize &&\n\t\thasNonContentControls &&\n\t\t! isWideAligned &&\n\t\tisLargeViewport;\n\t// An image is uploading if it has a temporary blob URL, or if it is\n\t// being processed client-side (e.g. transcoded or generating sub-sizes).\n\tconst isUploading = !! temporaryURL || isSideloading;\n\tconst imageSizeOptions = imageSizes\n\t\t.filter(\n\t\t\t( { slug } ) => image?.media_details?.sizes?.[ slug ]?.source_url\n\t\t)\n\t\t.map( ( { name, slug } ) => ( { value: slug, label: name } ) );\n\n\t// If the image has an id but the attachment doesn't exist on this site,\n\t// clear the id so Gutenberg treats the image as external.\n\t// This handles content copied between WordPress sites.\n\t//\n\t// Known limitation: if a different attachment with the same id happens to\n\t// exist on the destination site, the lookup will succeed and the wrong\n\t// local image will be used. URL matching could address this in a follow-up.\n\t// See: https://github.com/WordPress/gutenberg/issues/74156\n\tuseEffect( () => {\n\t\tif ( ! id || ! isSingleSelected ) {\n\t\t\treturn;\n\t\t}\n\t\t// Only clear for confirmed 404s. apiFetch throws the Response object\n\t\t// for HTTP errors, so checking .status === 404 avoids incorrectly\n\t\t// clearing the id on 403, 500, or network failures, which would\n\t\t// cause data loss for valid local attachments.\n\t\tif ( attachmentResolutionError?.status === 404 ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { id: undefined } );\n\t\t}\n\t}, [\n\t\tid,\n\t\tisSingleSelected,\n\t\tattachmentResolutionError,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\t/*\n\t * Externally hosted images can be uploaded to the media library. The\n\t * server sideloads the URL (see mediaSideloadFromUrl), so this works even\n\t * when the editor is cross-origin isolated and the browser cannot read the\n\t * cross-origin image's bytes itself.\n\t */\n\tconst canUploadExternalImage =\n\t\tisSingleSelected &&\n\t\tisExternalImage( id, url ) &&\n\t\t!! getSettings()[ mediaSideloadFromUrlKey ];\n\n\t// Get naturalWidth and naturalHeight from image, and fall back to loaded natural\n\t// width and height. This resolves an issue in Safari where the loaded natural\n\t// width and height is otherwise lost when switching between alignments.\n\t// See: https://github.com/WordPress/gutenberg/pull/37210.\n\tconst { naturalWidth, naturalHeight } = useMemo( () => {\n\t\treturn {\n\t\t\tnaturalWidth:\n\t\t\t\timageElement?.naturalWidth || loadedNaturalWidth || undefined,\n\t\t\tnaturalHeight:\n\t\t\t\timageElement?.naturalHeight || loadedNaturalHeight || undefined,\n\t\t};\n\t}, [ loadedNaturalWidth, loadedNaturalHeight, imageElement?.complete ] );\n\n\t// A media editor update can be undone or superseded before its\n\t// attributes land, leaving the rendered image untouched. No load event\n\t// fires in that case, so clear the pending swap whenever the rendered\n\t// image already shows the pending URL.\n\tuseEffect( () => {\n\t\tif (\n\t\t\tpendingSwapUrl &&\n\t\t\tpendingSwapUrl === url &&\n\t\t\timageElement?.complete\n\t\t) {\n\t\t\tsetPendingSwapUrl( undefined );\n\t\t}\n\t}, [ pendingSwapUrl, url, imageElement ] );\n\n\tfunction onImageError() {\n\t\tsetPendingSwapUrl( undefined );\n\t\tsetHasImageErrored( true );\n\n\t\t// Check if there's an embed block that handles this URL, e.g., instagram URL.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/11472\n\t\tconst embedBlock = createUpgradedEmbedBlock( { attributes: { url } } );\n\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\tonReplace( embedBlock );\n\t\t}\n\t}\n\n\tfunction onImageLoad( event ) {\n\t\tsetPendingSwapUrl( undefined );\n\t\tsetHasImageErrored( false );\n\t\tsetLoadedNaturalSize( {\n\t\t\tloadedNaturalWidth: event.target?.naturalWidth,\n\t\t\tloadedNaturalHeight: event.target?.naturalHeight,\n\t\t} );\n\t}\n\n\tfunction onSetHref( props ) {\n\t\tsetAttributes( props );\n\t}\n\n\tfunction onSetLightbox( enable ) {\n\t\tif ( enable && ! lightboxSetting?.enabled ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: true },\n\t\t\t\tisDecorative: false,\n\t\t\t} );\n\t\t} else if ( ! enable && lightboxSetting?.enabled ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: false },\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction resetLightbox() {\n\t\t// When deleting a link from an image while lightbox settings\n\t\t// are enabled by default, we should disable the lightbox,\n\t\t// otherwise the resulting UX looks like a mistake.\n\t\t// See https://github.com/WordPress/gutenberg/pull/59890/files#r1532286123.\n\t\tif ( lightboxSetting?.enabled && lightboxSetting?.allowEditing ) {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: { enabled: false },\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( {\n\t\t\t\tlightbox: undefined,\n\t\t\t} );\n\t\t}\n\t}\n\n\tfunction onSetTitle( value ) {\n\t\t// This is the HTML title attribute, separate from the media object\n\t\t// title.\n\t\tsetAttributes( { title: value } );\n\t}\n\n\tfunction updateAlt( newAlt ) {\n\t\tsetAttributes( { alt: newAlt } );\n\t}\n\n\tfunction updateIsDecorative( value ) {\n\t\tsetAttributes( {\n\t\t\tisDecorative: value || undefined,\n\t\t\t...( value && {\n\t\t\t\talt: '',\n\t\t\t\tcaption: undefined,\n\t\t\t\thref: undefined,\n\t\t\t\tlinkDestination: undefined,\n\t\t\t\tlinkTarget: undefined,\n\t\t\t\trel: undefined,\n\t\t\t} ),\n\t\t} );\n\t}\n\n\tconst imperativeFocalPointPreview = ( value ) => {\n\t\tif ( imageElement ) {\n\t\t\timageElement.style.setProperty(\n\t\t\t\t'object-position',\n\t\t\t\tmediaPosition( value )\n\t\t\t);\n\t\t}\n\t};\n\n\tfunction updateImage( newSizeSlug ) {\n\t\tconst newUrl = image?.media_details?.sizes?.[ newSizeSlug ]?.source_url;\n\t\tif ( ! newUrl ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\turl: newUrl,\n\t\t\tsizeSlug: newSizeSlug,\n\t\t} );\n\t}\n\n\tfunction uploadExternal() {\n\t\tconst mediaSideloadFromUrl = getSettings()[ mediaSideloadFromUrlKey ];\n\t\tif ( ! mediaSideloadFromUrl ) {\n\t\t\treturn;\n\t\t}\n\t\tmediaSideloadFromUrl( {\n\t\t\turl,\n\t\t\tonSuccess( img ) {\n\t\t\t\tonSelectImage( img );\n\t\t\t\tcreateSuccessNotice( __( 'Image uploaded.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\t\t},\n\t\t} );\n\t}\n\n\tconst canEditImage =\n\t\tid &&\n\t\tnaturalWidth &&\n\t\tnaturalHeight &&\n\t\timageEditing &&\n\t\t!! editMediaEntity;\n\tconst allowCrop =\n\t\tisSingleSelected &&\n\t\tcanEditImage &&\n\t\t!! openImageMediaEditorModal &&\n\t\t! isContentOnlyMode &&\n\t\t! isUploading;\n\n\tfunction switchToCover() {\n\t\treplaceBlocks(\n\t\t\tclientId,\n\t\t\tswitchToBlockType( getBlock( clientId ), 'core/cover' )\n\t\t);\n\t}\n\n\t// TODO: Can allow more units after figuring out how they should interact\n\t// with the ResizableBox component. Calculations later on for that\n\t// component are currently assuming px units.\n\tconst dimensionsUnitsOptions = useCustomUnits( {\n\t\tavailableUnits: [ 'px' ],\n\t} );\n\n\tconst [ lightboxSetting ] = useSettings( 'lightbox' );\n\n\tconst showLightboxSetting =\n\t\t// If a block-level override is set, we should give users the option to\n\t\t// remove that override, even if the lightbox UI is disabled in the settings.\n\t\t( !! lightbox && lightbox?.enabled !== lightboxSetting?.enabled ) ||\n\t\tlightboxSetting?.allowEditing;\n\n\tconst lightboxChecked =\n\t\t!! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst { selectedStyleState, hasSelectedStyleState } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {\n\t\t\t\t\tselectedStyleState: undefined,\n\t\t\t\t\thasSelectedStyleState: false,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst { getSelectedBlockStyleState, hasSelectedBlockStyleState } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tselectedStyleState: getSelectedBlockStyleState( clientId ),\n\t\t\t\thasSelectedStyleState: hasSelectedBlockStyleState( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSingleSelected ]\n\t);\n\tconst selectedStyleStateKey = getStyleStateKey( selectedStyleState );\n\tconst activeWidth = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'width',\n\t} );\n\tconst activeHeight = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'height',\n\t} );\n\tconst activeAspectRatio = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'aspectRatio',\n\t} );\n\tconst activeScale = getActiveDimensionValue( {\n\t\tattributes,\n\t\tselectedState: selectedStyleState,\n\t\thasSelectedStyleState,\n\t\tattributeKey: 'scale',\n\t\tstyleKey: 'objectFit',\n\t} );\n\tconst setDimensionAttributes = ( nextDimensions ) => {\n\t\tsetAttributes(\n\t\t\tgetDimensionUpdateAttributes( {\n\t\t\t\tstyle: attributes.style,\n\t\t\t\tselectedState: selectedStyleState,\n\t\t\t\thasSelectedStyleState,\n\t\t\t\tnextDimensions,\n\t\t\t\tdimensionKeyMap: { scale: 'objectFit' },\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst dimensionsControl =\n\t\tshowDimensionsControls &&\n\t\t( SIZED_LAYOUTS.includes( parentLayoutType ) ? (\n\t\t\t<DimensionsTool\n\t\t\t\tkey={ selectedStyleStateKey }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tvalue={ { aspectRatio: activeAspectRatio, scale: activeScale } }\n\t\t\t\tonChange={ ( { aspectRatio: newAspectRatio } ) => {\n\t\t\t\t\tsetDimensionAttributes( {\n\t\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t\t\tscale: 'cover',\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\ttools={ [ 'aspectRatio' ] }\n\t\t\t/>\n\t\t) : (\n\t\t\t<DimensionsTool\n\t\t\t\tkey={ selectedStyleStateKey }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tvalue={ {\n\t\t\t\t\twidth: activeWidth,\n\t\t\t\t\theight: activeHeight,\n\t\t\t\t\tscale: activeScale,\n\t\t\t\t\taspectRatio: activeAspectRatio,\n\t\t\t\t} }\n\t\t\t\tonChange={ ( {\n\t\t\t\t\twidth: newWidth,\n\t\t\t\t\theight: newHeight,\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t} ) => {\n\t\t\t\t\tsetDimensionAttributes( {\n\t\t\t\t\t\t// CSS includes `height: auto`, but we need\n\t\t\t\t\t\t// `width: auto` to fix the aspect ratio when\n\t\t\t\t\t\t// only height is set due to the width and\n\t\t\t\t\t\t// height attributes set via the server.\n\t\t\t\t\t\twidth: ! newWidth && newHeight ? 'auto' : newWidth,\n\t\t\t\t\t\theight: newHeight,\n\t\t\t\t\t\taspectRatio: newAspectRatio,\n\t\t\t\t\t\tscale: newScale,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdefaultScale=\"cover\"\n\t\t\t\tdefaultAspectRatio=\"auto\"\n\t\t\t\tscaleOptions={ scaleOptions }\n\t\t\t\tunitsOptions={ dimensionsUnitsOptions }\n\t\t\t\ttools={\n\t\t\t\t\tisWideAligned\n\t\t\t\t\t\t? [ 'aspectRatio', 'scale' ]\n\t\t\t\t\t\t: [ 'aspectRatio', 'widthHeight', 'scale' ]\n\t\t\t\t}\n\t\t\t/>\n\t\t) );\n\n\tconst resetSettings = () => {\n\t\tsetAttributes( {\n\t\t\tlightbox: undefined,\n\t\t} );\n\t\tupdateImage( DEFAULT_MEDIA_SIZE_SLUG );\n\t};\n\n\tconst arePatternOverridesEnabled =\n\t\tmetadata?.bindings?.__default?.source === 'core/pattern-overrides';\n\n\tconst {\n\t\tlockUrlControls = false,\n\t\tlockHrefControls = false,\n\t\tlockAltControls = false,\n\t\tlockAltControlsMessage,\n\t\tlockTitleControls = false,\n\t\tlockTitleControlsMessage,\n\t\thideCaptionControls = false,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\turl: urlBinding,\n\t\t\t\talt: altBinding,\n\t\t\t\ttitle: titleBinding,\n\t\t\t\tcaption: captionBinding,\n\t\t\t} = metadata?.bindings || {};\n\t\t\tconst hasParentPattern = !! context[ 'pattern/overrides' ];\n\t\t\tconst urlBindingSource = getBlockBindingsSource(\n\t\t\t\turlBinding?.source\n\t\t\t);\n\t\t\tconst altBindingSource = getBlockBindingsSource(\n\t\t\t\taltBinding?.source\n\t\t\t);\n\t\t\tconst titleBindingSource = getBlockBindingsSource(\n\t\t\t\ttitleBinding?.source\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! urlBinding &&\n\t\t\t\t\t! urlBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: urlBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockHrefControls:\n\t\t\t\t\t// Disable editing the link of the URL if the image is inside a pattern instance.\n\t\t\t\t\t// This is a temporary solution until we support overriding the link on the frontend.\n\t\t\t\t\thasParentPattern || arePatternOverridesEnabled,\n\t\t\t\thideCaptionControls: !! captionBinding,\n\t\t\t\tlockAltControls:\n\t\t\t\t\t!! altBinding &&\n\t\t\t\t\t! altBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: altBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockAltControlsMessage: altBindingSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\taltBindingSource.label\n\t\t\t\t\t\t)\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t\tlockTitleControls:\n\t\t\t\t\t!! titleBinding &&\n\t\t\t\t\t! titleBindingSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: titleBinding?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockTitleControlsMessage: titleBindingSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\ttitleBindingSource.label\n\t\t\t\t\t\t)\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tarePatternOverridesEnabled,\n\t\t\tcontext,\n\t\t\tisSingleSelected,\n\t\t\tmetadata?.bindings,\n\t\t]\n\t);\n\n\tconst showUrlInput =\n\t\tisSingleSelected &&\n\t\t! lockHrefControls &&\n\t\t! lockUrlControls &&\n\t\t! isDecorative;\n\n\tconst showCoverControls =\n\t\tisSingleSelected && canInsertCover && ! isContentOnlyMode;\n\n\tconst showBlockControls = showUrlInput || allowCrop || showCoverControls;\n\n\tconst mediaControls = isSingleSelected && ! lockUrlControls && (\n\t\t<>\n\t\t\t{ /* For contentOnly mode, put this button in its own area so it has borders around it. */ }\n\t\t\t<BlockControls group={ isContentOnlyMode ? 'inline' : 'other' }>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tname={ ! url ? __( 'Add image' ) : __( 'Replace' ) }\n\t\t\t\t\tonReset={ () => onSelectImage( undefined ) }\n\t\t\t\t\tvariant=\"toolbar\"\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n\n\tconst controls = (\n\t\t<>\n\t\t\t{ showBlockControls && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t{ showUrlInput && (\n\t\t\t\t\t\t<ImageURLInputUI\n\t\t\t\t\t\t\turl={ href || '' }\n\t\t\t\t\t\t\tonChangeUrl={ onSetHref }\n\t\t\t\t\t\t\tlinkDestination={ linkDestination }\n\t\t\t\t\t\t\tmediaUrl={ ( image && image.source_url ) || url }\n\t\t\t\t\t\t\tmediaLink={ image && image.link }\n\t\t\t\t\t\t\tlinkTarget={ linkTarget }\n\t\t\t\t\t\t\tlinkClass={ linkClass }\n\t\t\t\t\t\t\trel={ rel }\n\t\t\t\t\t\t\tshowLightboxSetting={ showLightboxSetting }\n\t\t\t\t\t\t\tlightboxEnabled={ lightboxChecked }\n\t\t\t\t\t\t\tonSetLightbox={ onSetLightbox }\n\t\t\t\t\t\t\tresetLightbox={ resetLightbox }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ allowCrop && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tref={ cropButtonRef }\n\t\t\t\t\t\t\tonClick={ openImageMediaEditorModal }\n\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\ticon={ crop }\n\t\t\t\t\t\t\tlabel={ __( 'Edit image' ) }\n\t\t\t\t\t\t\t// Disable rather than hide while the edited image\n\t\t\t\t\t\t\t// loads, so the button keeps focus when the modal\n\t\t\t\t\t\t\t// closes instead of dropping it to the canvas.\n\t\t\t\t\t\t\tdisabled={ isSwappingMedia }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showCoverControls && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\ticon={ overlayText }\n\t\t\t\t\t\t\tlabel={ __( 'Add text over image' ) }\n\t\t\t\t\t\t\tonClick={ switchToCover }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ canUploadExternalImage && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ uploadExternal }\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tlabel={ __( 'Upload to Media Library' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isContentOnlyMode && (\n\t\t\t\t// Add some extra controls for content attributes when content only mode is active.\n\t\t\t\t// With content only mode active, the inspector is hidden, so users need another way\n\t\t\t\t// to edit these attributes.\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ContentOnlyControls\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tlockAltControls={ lockAltControls }\n\t\t\t\t\t\tlockAltControlsMessage={ lockAltControlsMessage }\n\t\t\t\t\t\tlockTitleControls={ lockTitleControls }\n\t\t\t\t\t\tlockTitleControlsMessage={ lockTitleControlsMessage }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Media' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tonSelectImage( undefined );\n\t\t\t\t\t\t\tsetAttributes( { isDecorative: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! lockUrlControls && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\t\t\t\t\thasValue={ () => !! url }\n\t\t\t\t\t\t\t\tonDeselect={ () => onSelectImage( undefined ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<MediaControl\n\t\t\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\t\t\tmediaUrl={ url }\n\t\t\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\t\t\tfilename={\n\t\t\t\t\t\t\t\t\t\timage?.media_details?.sizes?.full\n\t\t\t\t\t\t\t\t\t\t\t?.file ||\n\t\t\t\t\t\t\t\t\t\timage?.slug ||\n\t\t\t\t\t\t\t\t\t\tgetFilename( url )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\t\t\tonReset={ () => onSelectImage( undefined ) }\n\t\t\t\t\t\t\t\t\tisUploading={ isUploading }\n\t\t\t\t\t\t\t\t\temptyLabel={ __( 'Add image' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isDecorative && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! alt }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { alt: undefined } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WCTextareaControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Alternative text' ) }\n\t\t\t\t\t\t\t\t\tvalue={ alt || '' }\n\t\t\t\t\t\t\t\t\tonChange={ updateAlt }\n\t\t\t\t\t\t\t\t\treadOnly={ lockAltControls }\n\t\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\t\tlockAltControls ? (\n\t\t\t\t\t\t\t\t\t\t\t<>{ lockAltControlsMessage }</>\n\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={\n\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.\n\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'https://www.w3.org/WAI/tutorials/images/decision-tree/'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Describe the purpose of the image.'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t{ ! lockAltControls && ! lightboxChecked && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Mark as decorative' ) }\n\t\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\t\thasValue={ () => !! isDecorative }\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { isDecorative: false } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<WCCheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Mark as decorative' ) }\n\t\t\t\t\t\t\t\t\tchecked={ !! isDecorative }\n\t\t\t\t\t\t\t\t\tonChange={ updateIsDecorative }\n\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t'Hidden from assistive technologies.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls\n\t\t\t\tgroup=\"dimensions\"\n\t\t\t\tresetAllFilter={ ( attrs ) => {\n\t\t\t\t\treturn getDimensionResetAttributes( {\n\t\t\t\t\t\tattributes: attrs,\n\t\t\t\t\t\tselectedState: selectedStyleState,\n\t\t\t\t\t\thasSelectedStyleState,\n\t\t\t\t\t\tkeys: [ 'aspectRatio', 'height', 'objectFit', 'width' ],\n\t\t\t\t\t\tdefaultAttributes: {\n\t\t\t\t\t\t\taspectRatio: undefined,\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t\tscale: undefined,\n\t\t\t\t\t\t\tfocalPoint: undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ dimensionsControl }\n\t\t\t\t{ ! hasSelectedStyleState && url && scale && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Focal point' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! focalPoint }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tfocalPoint: undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FocalPointPicker\n\t\t\t\t\t\t\tlabel={ __( 'Focal point' ) }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tvalue={ focalPoint }\n\t\t\t\t\t\t\tonDragStart={ imperativeFocalPointPreview }\n\t\t\t\t\t\t\tonDrag={ imperativeFocalPointPreview }\n\t\t\t\t\t\t\tonChange={ ( newFocalPoint ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tfocalPoint: newFocalPoint,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ !! imageSizeOptions.length && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\t\tresetAll={ resetSettings }\n\t\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ResolutionTool\n\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\tdefaultValue={ DEFAULT_MEDIA_SIZE_SLUG }\n\t\t\t\t\t\t\tonChange={ updateImage }\n\t\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\tonChange={ onSetTitle }\n\t\t\t\t\treadOnly={ lockTitleControls }\n\t\t\t\t\thelp={\n\t\t\t\t\t\tlockTitleControls ? (\n\t\t\t\t\t\t\t<>{ lockTitleControlsMessage }</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tcreateInterpolateElement(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Describe the role of this image on the page. <a>(Note: many devices and browsers do not display this text.)</a>'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href=\"https://www.w3.org/TR/html52/dom.html#the-title-attribute\" />\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst filename = getFilename( url );\n\tlet defaultedAlt;\n\n\tif ( isDecorative ) {\n\t\tdefaultedAlt = filename\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'This image has been marked as decorative; its file name is %s'\n\t\t\t\t\t),\n\t\t\t\t\tfilename\n\t\t\t\t)\n\t\t\t: __( 'This image has been marked as decorative.' );\n\t} else if ( alt ) {\n\t\tdefaultedAlt = alt;\n\t} else if ( filename ) {\n\t\tdefaultedAlt = sprintf(\n\t\t\t/* translators: %s: file name */\n\t\t\t__( 'This image has an empty alt attribute; its file name is %s' ),\n\t\t\tfilename\n\t\t);\n\t} else {\n\t\tdefaultedAlt = __( 'This image has an empty alt attribute' );\n\t}\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst { postType, postId, queryId } = context;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\n\tconst img = (\n\t\t<ImageWrapper href={ href }>\n\t\t\t{ temporaryURL && hasImageErrored ? (\n\t\t\t\t// Show a placeholder during upload when the blob URL can't be loaded. This can\n\t\t\t\t// happen when the user uploads a HEIC image in a browser that doesn't support them.\n\t\t\t\t<Placeholder\n\t\t\t\t\tclassName=\"wp-block-image__placeholder\"\n\t\t\t\t\twithIllustration\n\t\t\t\t>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={ temporaryURL || url }\n\t\t\t\t\t\talt={ defaultedAlt }\n\t\t\t\t\t\tonError={ onImageError }\n\t\t\t\t\t\tonLoad={ onImageLoad }\n\t\t\t\t\t\tref={ setRefs }\n\t\t\t\t\t\tclassName={ clsx( borderProps.className, {\n\t\t\t\t\t\t\t'is-swapping-media': isSwappingMedia,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\twidth={ naturalWidth }\n\t\t\t\t\t\theight={ naturalHeight }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t\t\t...( resizeDelta\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t\tpixelSize.width + resizeDelta.width,\n\t\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\t\tpixelSize.height +\n\t\t\t\t\t\t\t\t\t\t\tresizeDelta.height,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: ( () => {\n\t\t\t\t\t\t\t\t\t\tconst style = {};\n\t\t\t\t\t\t\t\t\t\tif ( width === 'auto' ) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.width = 'auto';\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\twidth !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\twidth !== null\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.width =\n\t\t\t\t\t\t\t\t\t\t\t\ttypeof width === 'number'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${ width }px`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: width;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif ( height === 'auto' ) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.height = 'auto';\n\t\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t\theight !== undefined &&\n\t\t\t\t\t\t\t\t\t\t\theight !== null\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\tstyle.height =\n\t\t\t\t\t\t\t\t\t\t\t\ttypeof height === 'number'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${ height }px`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: height;\n\t\t\t\t\t\t\t\t\t\t} else if ( ! isCroppedGalleryImage ) {\n\t\t\t\t\t\t\t\t\t\t\t// Default to `height: auto` so a\n\t\t\t\t\t\t\t\t\t\t\t// theme that sets an explicit height\n\t\t\t\t\t\t\t\t\t\t\t// on images can't squish them. Inside\n\t\t\t\t\t\t\t\t\t\t\t// a cropped gallery the gallery's own\n\t\t\t\t\t\t\t\t\t\t\t// CSS controls the height instead.\n\t\t\t\t\t\t\t\t\t\t\tstyle.height = 'auto';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn style;\n\t\t\t\t\t\t\t\t\t} )() ),\n\t\t\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t\t\tobjectPosition:\n\t\t\t\t\t\t\t\tfocalPoint && scale\n\t\t\t\t\t\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t\t\t...shadowProps.style,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ( isUploading || isSwappingMedia ) && <Spinner /> }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</ImageWrapper>\n\t);\n\n\tlet resizableBox;\n\tif (\n\t\tisResizable &&\n\t\tisSingleSelected &&\n\t\t! isUploading &&\n\t\t! SIZED_LAYOUTS.includes( parentLayoutType )\n\t) {\n\t\tconst numericRatio = aspectRatio && evalAspectRatio( aspectRatio );\n\t\tconst customRatio = pixelSize.width / pixelSize.height;\n\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\tconst ratio = numericRatio || customRatio || naturalRatio || 1;\n\t\tconst minWidth =\n\t\t\tnaturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;\n\t\tconst minHeight =\n\t\t\tnaturalHeight < naturalWidth ? MIN_SIZE : MIN_SIZE / ratio;\n\n\t\t// With the current implementation of ResizableBox, an image needs an\n\t\t// explicit pixel value for the max-width. In absence of being able to\n\t\t// set the content-width, this max-width is currently dictated by the\n\t\t// vanilla editor style. The following variable adds a buffer to this\n\t\t// vanilla style, so 3rd party themes have some wiggleroom. This does,\n\t\t// in most cases, allow you to scale the image beyond the width of the\n\t\t// main column, though not infinitely.\n\t\t// @todo It would be good to revisit this once a content-width variable\n\t\t// becomes available.\n\t\tconst maxWidthBuffer = maxWidth * 2.5;\n\t\tconst maxResizeWidth = maxContentWidth || maxWidthBuffer;\n\n\t\tlet showRightHandle = false;\n\t\tlet showLeftHandle = false;\n\n\t\t/* eslint-disable no-lonely-if */\n\t\t// See https://github.com/WordPress/gutenberg/issues/7584.\n\t\tif ( align === 'center' ) {\n\t\t\t// When the image is centered, show both handles.\n\t\t\tshowRightHandle = true;\n\t\t\tshowLeftHandle = true;\n\t\t} else if ( isRTL() ) {\n\t\t\t// In RTL mode the image is on the right by default.\n\t\t\t// Show the right handle and hide the left handle only when it is\n\t\t\t// aligned left. Otherwise always show the left handle.\n\t\t\tif ( align === 'left' ) {\n\t\t\t\tshowRightHandle = true;\n\t\t\t} else {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Show the left handle and hide the right handle only when the\n\t\t\t// image is aligned right. Otherwise always show the right handle.\n\t\t\tif ( align === 'right' ) {\n\t\t\t\tshowLeftHandle = true;\n\t\t\t} else {\n\t\t\t\tshowRightHandle = true;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable no-lonely-if */\n\t\tresizableBox = (\n\t\t\t<ResizableBox\n\t\t\t\tref={ effectResizeableBoxPlacement }\n\t\t\t\tstyle={ {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t// To match the vertical-align: bottom of the img (from style.scss)\n\t\t\t\t\t// syncs the top with the img. This matters when the img height is\n\t\t\t\t\t// less than the line-height.\n\t\t\t\t\tinset: `${ offsetTop }px 0 0 0`,\n\t\t\t\t} }\n\t\t\t\tsize={ pixelSize }\n\t\t\t\tminWidth={ minWidth }\n\t\t\t\tmaxWidth={ maxResizeWidth }\n\t\t\t\tminHeight={ minHeight }\n\t\t\t\tmaxHeight={ maxResizeWidth / ratio }\n\t\t\t\tlockAspectRatio={ ratio }\n\t\t\t\tenable={ {\n\t\t\t\t\ttop: false,\n\t\t\t\t\tright: showRightHandle,\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tleft: showLeftHandle,\n\t\t\t\t} }\n\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResize={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetResizeDelta( delta );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\tsetResizeDelta( null );\n\t\t\t\t\tsetPixelSize( ( current ) => ( {\n\t\t\t\t\t\twidth: current.width + delta.width,\n\t\t\t\t\t\theight: current.height + delta.height,\n\t\t\t\t\t} ) );\n\n\t\t\t\t\t// Clear hardcoded width if the resized width is close to the max-content width.\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaxContentWidth &&\n\t\t\t\t\t\t// Only do this if the image is bigger than the container to prevent it from being squished.\n\t\t\t\t\t\t// TODO: Remove this check if the image support setting 100% width.\n\t\t\t\t\t\tnaturalWidth >= maxContentWidth &&\n\t\t\t\t\t\tMath.abs( elt.offsetWidth - maxContentWidth ) < 10\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\twidth: undefined,\n\t\t\t\t\t\t\theight: undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Since the aspect ratio is locked when resizing, we can\n\t\t\t\t\t// use the width of the resized element to calculate the\n\t\t\t\t\t// height in CSS to prevent stretching when the max-width\n\t\t\t\t\t// is reached.\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: `${ elt.offsetWidth }px`,\n\t\t\t\t\t\theight: 'auto',\n\t\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t\tratio === naturalRatio\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: String( ratio ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tresizeRatio={ align === 'center' ? 2 : 1 }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( ! url && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ mediaControls }\n\t\t\t\t{ controls }\n\t\t\t</>\n\t\t);\n\t}\n\n\t/**\n\t * Set the post's featured image with the current image.\n\t */\n\tconst setPostFeatureImage = () => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tfeatured_media: id,\n\t\t} );\n\t\tcreateSuccessNotice( __( 'Post featured image updated.' ), {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst featuredImageControl =\n\t\t! isDescendentOfQueryLoop && postId && id ? (\n\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t{ ( { canEdit, selectedClientIds } ) =>\n\t\t\t\t\tcanEdit &&\n\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\tclientId === selectedClientIds[ 0 ] && (\n\t\t\t\t\t\t<MenuItem onClick={ setPostFeatureImage }>\n\t\t\t\t\t\t\t{ __( 'Set as featured image' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</BlockSettingsMenuControls>\n\t\t) : null;\n\n\treturn (\n\t\t<>\n\t\t\t{ mediaControls }\n\t\t\t{ controls }\n\t\t\t{ featuredImageControl }\n\t\t\t{ img }\n\t\t\t{ resizableBox }\n\n\t\t\t{ ! isDecorative && (\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Image caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tisSingleSelected &&\n\t\t\t\t\t\t( hasNonContentControls || isContentOnlyMode ) &&\n\t\t\t\t\t\t! hideCaptionControls\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,wBAkBO;AACP,qBAIO;AACP,kBAAuC;AACvC,0BAWO;AACP,qBAOO;AACP,kBAAuC;AACvC,iBAA4B;AAC5B,oBAA0D;AAC1D,mBAAuD;AACvD,qBAAsC;AACtC,uBAAmC;AACnC,yBAAuB;AACvB,kBAAyC;AACzC,kBAAgC;AAChC,qBAAwB;AACxB,2BAA6B;AAC7B,mBAA+C;AAC/C,yBAKO;AACP,+CAA6C;AAC7C,uBAKO;AACP,mBAA+C;AAgC7C;AA9BF,IAAM;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,QAAI,2BAAQ,oBAAAA,WAAuB;AAEnC,IAAM,eAAe;AAAA,EACpB;AAAA,IACC,OAAO;AAAA,IACP,WAAO,gBAAI,SAAS,qCAAsC;AAAA,IAC1D,UAAM,gBAAI,gCAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,WAAO,gBAAI,WAAW,qCAAsC;AAAA,IAC5D,UAAM,gBAAI,wCAAyC;AAAA,EACpD;AACD;AAEA,IAAM,0BAA0B;AAAA,EAC/B,WAAW;AACZ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tC,4CAAC,iDACE,WAAE,EAAE,SAAS,kBAAkB,MAChC,WACA,kBAAkB,WAAW,KAC7B,aAAa,kBAAmB,CAAE,KACjC,4CAAC,8BAAS,SAAU,qBACjB,8BAAI,uBAAwB,GAC/B,GAGH,IACG;AAEL,SACC,4EACG;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA,CAAE,gBACH;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAa;AAAA,QACb;AAAA,QACA,WAAQ,gBAAI,oBAAqB;AAAA,QACjC,mBACC,qBACE,yBAAyB,sBAC3B,CAAE;AAAA;AAAA,IAEJ;AAAA,KAEF;AAEF;",
6
+ "names": ["blockEditorPrivateApis", "WCTextareaControl", "coreStore", "getSettings", "blockEditorStore", "noticesStore", "img", "useCustomUnits", "ImageURLInputUI", "ToolsPanel", "ToolsPanelItem", "WCCheckboxControl", "useBorderProps", "getShadowClassesAndStyles", "clsx"]
7
7
  }
@@ -144,7 +144,7 @@ function useOpenImageMediaEditorModal({
144
144
  onClose,
145
145
  onUrlChange
146
146
  }) {
147
- const { id, url, alt, caption, sizeSlug, linkDestination } = attributes;
147
+ const { id, url, alt, caption, sizeSlug, linkDestination, href } = attributes;
148
148
  const registry = (0, import_data.useRegistry)();
149
149
  const openMediaEditorModal = (0, import_data.useSelect)(
150
150
  (select) => select(import_block_editor.store).getSettings()[openMediaEditorModalKey],
@@ -156,7 +156,8 @@ function useOpenImageMediaEditorModal({
156
156
  alt,
157
157
  caption: caption?.toString(),
158
158
  sizeSlug,
159
- linkDestination
159
+ linkDestination,
160
+ href
160
161
  });
161
162
  const mediaEditorMetadataBaselineRef = (0, import_element.useRef)();
162
163
  const mediaEditorMetadataSyncRequestRef = (0, import_element.useRef)(0);
@@ -167,9 +168,10 @@ function useOpenImageMediaEditorModal({
167
168
  alt,
168
169
  caption: caption?.toString(),
169
170
  sizeSlug,
170
- linkDestination
171
+ linkDestination,
172
+ href
171
173
  };
172
- }, [alt, caption, id, linkDestination, sizeSlug, url]);
174
+ }, [alt, caption, href, id, linkDestination, sizeSlug, url]);
173
175
  const getCachedAttachmentRecord = (0, import_element.useCallback)(
174
176
  (attachmentId) => registry.select(import_core_data.store).getEditedEntityRecord(
175
177
  "postType",
@@ -206,7 +208,7 @@ function useOpenImageMediaEditorModal({
206
208
  [registry, resolveAttachmentRecord]
207
209
  );
208
210
  const handleMediaUpdate = (0, import_element.useCallback)(
209
- async ({ id: newId, url: newUrl }) => {
211
+ async ({ id: newId, url: newUrl }, undoState) => {
210
212
  if (typeof newId !== "number") {
211
213
  return;
212
214
  }
@@ -217,6 +219,8 @@ function useOpenImageMediaEditorModal({
217
219
  const currentBlockAttributes = blockAttributesRef.current;
218
220
  const isNewAttachment = newId !== currentBlockAttributes.id;
219
221
  if (isNewAttachment) {
222
+ undoState.undoAttributes.id = currentBlockAttributes.id;
223
+ undoState.undoAttributes.url = currentBlockAttributes.url;
220
224
  nextAttributes.id = newId;
221
225
  nextAttributes.url = newUrl ?? currentBlockAttributes.url;
222
226
  if (nextAttributes.url !== currentBlockAttributes.url) {
@@ -230,7 +234,7 @@ function useOpenImageMediaEditorModal({
230
234
  }
231
235
  if (originalAttachment || isNewAttachment) {
232
236
  const resolvedAttachment = await resolveFreshAttachmentRecord(newId);
233
- if (syncRequest !== mediaEditorMetadataSyncRequestRef.current) {
237
+ if (undoState.isUndone || syncRequest !== mediaEditorMetadataSyncRequestRef.current) {
234
238
  return;
235
239
  }
236
240
  const attachmentRecord = resolvedAttachment ?? getCachedAttachmentRecord(newId);
@@ -262,6 +266,11 @@ function useOpenImageMediaEditorModal({
262
266
  }
263
267
  }
264
268
  if (Object.keys(nextAttributes).length) {
269
+ for (const key of Object.keys(nextAttributes)) {
270
+ if (!Object.hasOwn(undoState.undoAttributes, key)) {
271
+ undoState.undoAttributes[key] = blockAttributesRef.current[key];
272
+ }
273
+ }
265
274
  blockAttributesRef.current = {
266
275
  ...blockAttributesRef.current,
267
276
  ...nextAttributes
@@ -288,9 +297,22 @@ function useOpenImageMediaEditorModal({
288
297
  cachedAttachmentRecord
289
298
  ) ? void 0 : await resolveAttachmentRecord(id);
290
299
  mediaEditorMetadataBaselineRef.current = resolvedAttachmentRecord || (hasKnownAttachmentMetadata(cachedAttachmentRecord) ? cachedAttachmentRecord : fallbackAttachmentRecord) || cachedAttachmentRecord;
300
+ const undoState = { undoAttributes: {}, isUndone: false };
291
301
  openMediaEditorModal({
292
302
  id,
293
- onUpdate: handleMediaUpdate,
303
+ onUpdate: (updated) => handleMediaUpdate(updated, undoState),
304
+ onUndo: () => {
305
+ undoState.isUndone = true;
306
+ const { undoAttributes } = undoState;
307
+ if (Object.hasOwn(undoAttributes, "url")) {
308
+ onUrlChange?.(undoAttributes.url);
309
+ }
310
+ blockAttributesRef.current = {
311
+ ...blockAttributesRef.current,
312
+ ...undoAttributes
313
+ };
314
+ setAttributes(undoAttributes);
315
+ },
294
316
  onClose
295
317
  });
296
318
  }, [
@@ -298,8 +320,10 @@ function useOpenImageMediaEditorModal({
298
320
  handleMediaUpdate,
299
321
  id,
300
322
  onClose,
323
+ onUrlChange,
301
324
  openMediaEditorModal,
302
- resolveAttachmentRecord
325
+ resolveAttachmentRecord,
326
+ setAttributes
303
327
  ]);
304
328
  return id && openMediaEditorModal ? openImageMediaEditorModal : void 0;
305
329
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/image/use-open-image-media-editor-modal.js"],
4
- "sourcesContent": ["import { store as coreStore } from '@wordpress/core-data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { unlock } from '../lock-unlock';\nimport {\n\tDEFAULT_MEDIA_SIZE_SLUG,\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_MEDIA,\n} from './constants';\n\nfunction normalizeImageBlockCaption( caption ) {\n\tif ( typeof caption !== 'string' ) {\n\t\treturn '';\n\t}\n\n\tconst textContent = stripHTML( caption ).trim();\n\n\tif ( ! textContent ) {\n\t\treturn '';\n\t}\n\n\treturn caption.replace( /\\n/g, '<br>' );\n}\n\nfunction getAttachmentCaption( attachment ) {\n\tconst caption = attachment?.caption;\n\n\tif ( typeof caption === 'string' ) {\n\t\treturn normalizeImageBlockCaption( caption );\n\t}\n\n\tif (\n\t\tcaption &&\n\t\ttypeof caption === 'object' &&\n\t\tObject.hasOwn( caption, 'raw' )\n\t) {\n\t\treturn normalizeImageBlockCaption( caption.raw );\n\t}\n\n\treturn undefined;\n}\n\nexport function getImageBlockMetadataFromAttachment( attachment ) {\n\treturn {\n\t\talt:\n\t\t\ttypeof attachment?.alt_text === 'string'\n\t\t\t\t? attachment.alt_text\n\t\t\t\t: attachment?.alt || '',\n\t\tcaption: getAttachmentCaption( attachment ),\n\t};\n}\n\nfunction normalizeMetadataAttribute( value ) {\n\treturn value || '';\n}\n\nexport function getSyncedImageBlockAttributes(\n\tcurrentAttributes,\n\toriginalAttachment,\n\tupdatedAttachment\n) {\n\tif ( ! originalAttachment || ! updatedAttachment ) {\n\t\treturn {};\n\t}\n\n\tconst originalMetadata =\n\t\tgetImageBlockMetadataFromAttachment( originalAttachment );\n\tconst updatedMetadata =\n\t\tgetImageBlockMetadataFromAttachment( updatedAttachment );\n\tconst syncedAttributes = {};\n\n\tconst normalizedCurrentAlt = normalizeMetadataAttribute(\n\t\tcurrentAttributes.alt\n\t);\n\tif (\n\t\toriginalMetadata.alt !== updatedMetadata.alt &&\n\t\t( normalizedCurrentAlt === originalMetadata.alt ||\n\t\t\t! normalizedCurrentAlt )\n\t) {\n\t\tsyncedAttributes.alt = updatedMetadata.alt;\n\t}\n\n\tconst normalizedCurrentCaption = normalizeMetadataAttribute(\n\t\tcurrentAttributes.caption\n\t);\n\tif (\n\t\toriginalMetadata.caption !== undefined &&\n\t\tupdatedMetadata.caption !== undefined &&\n\t\toriginalMetadata.caption !== updatedMetadata.caption &&\n\t\t( normalizedCurrentCaption === originalMetadata.caption ||\n\t\t\t! normalizedCurrentCaption )\n\t) {\n\t\tsyncedAttributes.caption = updatedMetadata.caption || undefined;\n\t}\n\n\treturn syncedAttributes;\n}\n\n/**\n * Resolves the attributes needed to keep the selected image size on a new\n * attachment.\n *\n * WordPress skips generating a sub-size larger than the file itself, so the\n * selected size may not exist on the edited image; fall back to full when it\n * doesn't.\n *\n * @param {string|undefined} sizeSlug The block's currently selected size.\n * @param {Object} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, if any.\n */\nfunction getNewAttachmentSizeAttributes( sizeSlug, attachment ) {\n\tconst sizes = attachment.media_details?.sizes;\n\n\tif ( ! sizeSlug || sizeSlug === DEFAULT_MEDIA_SIZE_SLUG || ! sizes ) {\n\t\treturn undefined;\n\t}\n\n\tconst sizeUrl = sizes[ sizeSlug ]?.source_url;\n\n\tif ( sizeUrl ) {\n\t\treturn { url: sizeUrl };\n\t}\n\n\tconst fullUrl = attachment.source_url ?? sizes.full?.source_url;\n\n\treturn fullUrl\n\t\t? { url: fullUrl, sizeSlug: DEFAULT_MEDIA_SIZE_SLUG }\n\t\t: undefined;\n}\n\n/**\n * Resolves the link attributes needed to keep the block's link pointing at the\n * new attachment.\n *\n * Only the destinations derived from the attachment follow the edited image. A\n * `custom` link is the user's own URL and a `none` link has nothing to point\n * at, so both are left alone. When the record doesn't carry the field, the\n * existing link is kept rather than cleared.\n *\n * @param {string|undefined} linkDestination The block's link destination.\n * @param {Object} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, if any.\n */\nfunction getNewAttachmentLinkAttributes( linkDestination, attachment ) {\n\t// Media file links point at the full-size file, independently of the size\n\t// the block renders.\n\tif ( linkDestination === LINK_DESTINATION_MEDIA ) {\n\t\treturn attachment.source_url\n\t\t\t? { href: attachment.source_url }\n\t\t\t: undefined;\n\t}\n\n\tif ( linkDestination === LINK_DESTINATION_ATTACHMENT ) {\n\t\treturn attachment.link ? { href: attachment.link } : undefined;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolves the block attributes that are derived from the attachment, for an\n * edit that saved to a different one.\n *\n * Editing media (crop, rotate, flip) creates a new attachment with its own\n * generated sub-sizes and its own attachment page, and the media editor\n * reports the full-size file. Without re-deriving these, the size control\n * keeps reporting e.g. \"Medium\" while the block renders the full-size image,\n * and a \"Media file\" or \"Attachment page\" link still points at the image as it\n * was before the edit. Everything else the user set on the block — dimensions,\n * lightbox, title, custom links — is left untouched.\n *\n * @param {Object} blockAttributes The block's current attributes.\n * @param {Object|undefined} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, or undefined when the\n * attachment record isn't known yet.\n */\nexport function getNewAttachmentImageBlockAttributes(\n\tblockAttributes,\n\tattachment\n) {\n\tif ( ! attachment ) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\t...getNewAttachmentSizeAttributes(\n\t\t\tblockAttributes.sizeSlug,\n\t\t\tattachment\n\t\t),\n\t\t...getNewAttachmentLinkAttributes(\n\t\t\tblockAttributes.linkDestination,\n\t\t\tattachment\n\t\t),\n\t};\n}\n\nconst { openMediaEditorModalKey } = unlock( blockEditorPrivateApis );\n\nfunction getAttachmentFallbackForEmptyBlockMetadata( { alt, caption } ) {\n\tconst attachment = {};\n\n\tif ( ! alt ) {\n\t\tattachment.alt_text = '';\n\t}\n\n\tif ( ! caption?.toString() ) {\n\t\tattachment.caption = '';\n\t}\n\n\treturn Object.keys( attachment ).length ? attachment : undefined;\n}\n\nfunction hasKnownAttachmentMetadata( attachment ) {\n\tif ( ! attachment ) {\n\t\treturn false;\n\t}\n\n\tconst hasKnownAlt =\n\t\ttypeof attachment.alt_text === 'string' ||\n\t\ttypeof attachment.alt === 'string';\n\tconst hasKnownCaption =\n\t\tgetImageBlockMetadataFromAttachment( attachment ).caption !== undefined;\n\n\treturn hasKnownAlt && hasKnownCaption;\n}\n\nexport function useOpenImageMediaEditorModal( {\n\tattributes,\n\tsetAttributes,\n\tonClose,\n\tonUrlChange,\n} ) {\n\t// Keep this hook private to the Image block and pass the block attributes\n\t// object so the callsite stays compact. Destructure only the attributes\n\t// the update needs to read — those synced from the attachment's metadata,\n\t// and those derived from which attachment the block points at; add more\n\t// here if the sync policy grows.\n\tconst { id, url, alt, caption, sizeSlug, linkDestination } = attributes;\n\tconst registry = useRegistry();\n\tconst openMediaEditorModal = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()[ openMediaEditorModalKey ],\n\t\t[]\n\t);\n\t// Track the block's current attachment and metadata in a ref so\n\t// handleMediaUpdate can read the latest values without being listed as\n\t// dependencies (which would recreate the callback and re-register the\n\t// onUpdate handler on every block change while the modal is open).\n\tconst blockAttributesRef = useRef( {\n\t\tid,\n\t\turl,\n\t\talt,\n\t\tcaption: caption?.toString(),\n\t\tsizeSlug,\n\t\tlinkDestination,\n\t} );\n\t// Snapshot of the attachment's metadata taken just before the modal opens,\n\t// used as the baseline for detecting what changed during the editing session.\n\tconst mediaEditorMetadataBaselineRef = useRef();\n\t// Incremented on every handleMediaUpdate call; stale async continuations\n\t// check against this to bail out if a newer update has since started.\n\tconst mediaEditorMetadataSyncRequestRef = useRef( 0 );\n\n\tuseEffect( () => {\n\t\tblockAttributesRef.current = {\n\t\t\tid,\n\t\t\turl,\n\t\t\talt,\n\t\t\tcaption: caption?.toString(),\n\t\t\tsizeSlug,\n\t\t\tlinkDestination,\n\t\t};\n\t}, [ alt, caption, id, linkDestination, sizeSlug, url ] );\n\n\t// Reads the cached attachment record. The `attachment` postType entity\n\t// fetches with `context: 'edit'` by default, so `getEditedEntityRecord`\n\t// returns the edit-context record — carrying `caption` as `{ raw }` and a\n\t// usable `alt_text` — without us specifying a context. It is resolver-\n\t// backed, so on a cold cache this also kicks off the fetch and returns a\n\t// falsy value synchronously; that resolution shares its cache key with the\n\t// `resolveAttachmentRecord` call below (both keyed on the no-query\n\t// `getEntityRecord`), so the two dedupe into a single request.\n\tconst getCachedAttachmentRecord = useCallback(\n\t\t( attachmentId ) =>\n\t\t\tregistry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t),\n\t\t[ registry ]\n\t);\n\n\tconst resolveAttachmentRecord = useCallback(\n\t\tasync ( attachmentId ) => {\n\t\t\tconst resolveSelect = registry.resolveSelect( coreStore );\n\n\t\t\ttry {\n\t\t\t\treturn await resolveSelect.getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t\t[ registry ]\n\t);\n\n\tconst resolveFreshAttachmentRecord = useCallback(\n\t\tasync ( attachmentId ) => {\n\t\t\t// Invalidate the cached resolution so resolveAttachmentRecord\n\t\t\t// re-fetches the server state that reflects the media editor's\n\t\t\t// saved changes.\n\t\t\tconst { invalidateResolution } = registry.dispatch( coreStore );\n\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachmentId,\n\t\t\t] );\n\t\t\treturn resolveAttachmentRecord( attachmentId );\n\t\t},\n\t\t[ registry, resolveAttachmentRecord ]\n\t);\n\n\tconst handleMediaUpdate = useCallback(\n\t\tasync ( { id: newId, url: newUrl } ) => {\n\t\t\tif ( typeof newId !== 'number' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Capture and clear the baseline so a rapid second save doesn't\n\t\t\t// reuse a stale snapshot.\n\t\t\tconst originalAttachment = mediaEditorMetadataBaselineRef.current;\n\t\t\tmediaEditorMetadataBaselineRef.current = undefined;\n\t\t\tconst syncRequest = ++mediaEditorMetadataSyncRequestRef.current;\n\t\t\tconst nextAttributes = {};\n\n\t\t\tconst currentBlockAttributes = blockAttributesRef.current;\n\t\t\tconst isNewAttachment = newId !== currentBlockAttributes.id;\n\n\t\t\tif ( isNewAttachment ) {\n\t\t\t\tnextAttributes.id = newId;\n\t\t\t\tnextAttributes.url = newUrl ?? currentBlockAttributes.url;\n\t\t\t\tif ( nextAttributes.url !== currentBlockAttributes.url ) {\n\t\t\t\t\t// The block is about to point at a freshly generated file\n\t\t\t\t\t// the browser hasn't loaded yet; let the caller show a\n\t\t\t\t\t// loading state until its <img> fires load/error. Raising\n\t\t\t\t\t// it here, before anything is awaited, keeps the rest of\n\t\t\t\t\t// this update behind that loading state: the attributes\n\t\t\t\t\t// land in a single `setAttributes` at the end, so the\n\t\t\t\t\t// image never renders against half-updated settings.\n\t\t\t\t\tonUrlChange?.( nextAttributes.url );\n\t\t\t\t}\n\t\t\t\tblockAttributesRef.current = {\n\t\t\t\t\t...blockAttributesRef.current,\n\t\t\t\t\tid: nextAttributes.id,\n\t\t\t\t\turl: nextAttributes.url,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( originalAttachment || isNewAttachment ) {\n\t\t\t\t// Fetch fresh server state so this reflects what the media\n\t\t\t\t// editor actually saved, not a potentially stale cache.\n\t\t\t\tconst resolvedAttachment =\n\t\t\t\t\tawait resolveFreshAttachmentRecord( newId );\n\n\t\t\t\t// A newer update started while we were awaiting; discard\n\t\t\t\t// this one.\n\t\t\t\tif (\n\t\t\t\t\tsyncRequest !== mediaEditorMetadataSyncRequestRef.current\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// A failed refetch returns nothing, which would leave the\n\t\t\t\t// block pointing at the new file while its size and link\n\t\t\t\t// still describe the old one. The record the media editor\n\t\t\t\t// received when it saved is already in the store, so fall\n\t\t\t\t// back to that rather than half-updating the block.\n\t\t\t\tconst attachmentRecord =\n\t\t\t\t\tresolvedAttachment ?? getCachedAttachmentRecord( newId );\n\n\t\t\t\tconst latestBlockAttributes = blockAttributesRef.current;\n\n\t\t\t\t// Sync alt text and caption back to the block only when\n\t\t\t\t// they were changed in the media editor. Fields the user\n\t\t\t\t// has independently customised on the block (i.e. values\n\t\t\t\t// that don't match the pre-session attachment metadata)\n\t\t\t\t// are left untouched. Without a baseline there's no way to\n\t\t\t\t// tell the two apart, so nothing is synced.\n\t\t\t\tif ( originalAttachment ) {\n\t\t\t\t\tconst resolvedMetadataAttributes =\n\t\t\t\t\t\tgetSyncedImageBlockAttributes(\n\t\t\t\t\t\t\tlatestBlockAttributes,\n\t\t\t\t\t\t\toriginalAttachment,\n\t\t\t\t\t\t\tattachmentRecord\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif ( Object.keys( resolvedMetadataAttributes ).length ) {\n\t\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t\tnextAttributes,\n\t\t\t\t\t\t\tresolvedMetadataAttributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( isNewAttachment ) {\n\t\t\t\t\tconst derivedAttributes =\n\t\t\t\t\t\tgetNewAttachmentImageBlockAttributes(\n\t\t\t\t\t\t\tlatestBlockAttributes,\n\t\t\t\t\t\t\tattachmentRecord\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif ( derivedAttributes ) {\n\t\t\t\t\t\tObject.assign( nextAttributes, derivedAttributes );\n\n\t\t\t\t\t\t// The URL announced before the resolve was the\n\t\t\t\t\t\t// full-size file the media editor reported, and\n\t\t\t\t\t\t// deriving the selected size can change it.\n\t\t\t\t\t\t// Re-announce so the pending swap names the file\n\t\t\t\t\t\t// that actually lands: an update that is undone or\n\t\t\t\t\t\t// superseded never changes the <img> src, and the\n\t\t\t\t\t\t// block then clears its loading state by matching\n\t\t\t\t\t\t// the pending URL against the rendered one.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tderivedAttributes.url &&\n\t\t\t\t\t\t\tderivedAttributes.url !== latestBlockAttributes.url\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonUrlChange?.( derivedAttributes.url );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( Object.keys( nextAttributes ).length ) {\n\t\t\t\tblockAttributesRef.current = {\n\t\t\t\t\t...blockAttributesRef.current,\n\t\t\t\t\t...nextAttributes,\n\t\t\t\t};\n\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetCachedAttachmentRecord,\n\t\t\tonUrlChange,\n\t\t\tresolveFreshAttachmentRecord,\n\t\t\tsetAttributes,\n\t\t]\n\t);\n\n\tconst openImageMediaEditorModal = useCallback( async () => {\n\t\tif ( ! id || ! openMediaEditorModal ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Snapshot the attachment's current metadata before the user makes\n\t\t// any changes so handleMediaUpdate can compare against it later. Use\n\t\t// the cached record when it's already present; only resolve when\n\t\t// nothing is cached yet, then fall back to a minimal object derived\n\t\t// from the block's own attributes.\n\t\tconst cachedAttachmentRecord = getCachedAttachmentRecord( id );\n\t\tconst fallbackAttachmentRecord =\n\t\t\tgetAttachmentFallbackForEmptyBlockMetadata(\n\t\t\t\tblockAttributesRef.current\n\t\t\t);\n\t\tconst resolvedAttachmentRecord = hasKnownAttachmentMetadata(\n\t\t\tcachedAttachmentRecord\n\t\t)\n\t\t\t? undefined\n\t\t\t: await resolveAttachmentRecord( id );\n\n\t\tmediaEditorMetadataBaselineRef.current =\n\t\t\tresolvedAttachmentRecord ||\n\t\t\t( hasKnownAttachmentMetadata( cachedAttachmentRecord )\n\t\t\t\t? cachedAttachmentRecord\n\t\t\t\t: fallbackAttachmentRecord ) ||\n\t\t\tcachedAttachmentRecord;\n\n\t\topenMediaEditorModal( {\n\t\t\tid,\n\t\t\tonUpdate: handleMediaUpdate,\n\t\t\tonClose,\n\t\t} );\n\t}, [\n\t\tgetCachedAttachmentRecord,\n\t\thandleMediaUpdate,\n\t\tid,\n\t\tonClose,\n\t\topenMediaEditorModal,\n\t\tresolveAttachmentRecord,\n\t] );\n\n\treturn id && openMediaEditorModal ? openImageMediaEditorModal : undefined;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAmC;AACnC,0BAGO;AACP,iBAAiD;AACjD,kBAAuC;AACvC,qBAA+C;AAC/C,yBAAuB;AACvB,uBAIO;AAEP,SAAS,2BAA4B,SAAU;AAC9C,MAAK,OAAO,YAAY,UAAW;AAClC,WAAO;AAAA,EACR;AAEA,QAAM,kBAAc,WAAAA,qBAAW,OAAQ,EAAE,KAAK;AAE9C,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SAAO,QAAQ,QAAS,OAAO,MAAO;AACvC;AAEA,SAAS,qBAAsB,YAAa;AAC3C,QAAM,UAAU,YAAY;AAE5B,MAAK,OAAO,YAAY,UAAW;AAClC,WAAO,2BAA4B,OAAQ;AAAA,EAC5C;AAEA,MACC,WACA,OAAO,YAAY,YACnB,OAAO,OAAQ,SAAS,KAAM,GAC7B;AACD,WAAO,2BAA4B,QAAQ,GAAI;AAAA,EAChD;AAEA,SAAO;AACR;AAEO,SAAS,oCAAqC,YAAa;AACjE,SAAO;AAAA,IACN,KACC,OAAO,YAAY,aAAa,WAC7B,WAAW,WACX,YAAY,OAAO;AAAA,IACvB,SAAS,qBAAsB,UAAW;AAAA,EAC3C;AACD;AAEA,SAAS,2BAA4B,OAAQ;AAC5C,SAAO,SAAS;AACjB;AAEO,SAAS,8BACf,mBACA,oBACA,mBACC;AACD,MAAK,CAAE,sBAAsB,CAAE,mBAAoB;AAClD,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,mBACL,oCAAqC,kBAAmB;AACzD,QAAM,kBACL,oCAAqC,iBAAkB;AACxD,QAAM,mBAAmB,CAAC;AAE1B,QAAM,uBAAuB;AAAA,IAC5B,kBAAkB;AAAA,EACnB;AACA,MACC,i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IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO,MAAM,uBAAuB,4BAA4B;AACjE;",
4
+ "sourcesContent": ["import { store as coreStore } from '@wordpress/core-data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { unlock } from '../lock-unlock';\nimport {\n\tDEFAULT_MEDIA_SIZE_SLUG,\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_MEDIA,\n} from './constants';\n\nfunction normalizeImageBlockCaption( caption ) {\n\tif ( typeof caption !== 'string' ) {\n\t\treturn '';\n\t}\n\n\tconst textContent = stripHTML( caption ).trim();\n\n\tif ( ! textContent ) {\n\t\treturn '';\n\t}\n\n\treturn caption.replace( /\\n/g, '<br>' );\n}\n\nfunction getAttachmentCaption( attachment ) {\n\tconst caption = attachment?.caption;\n\n\tif ( typeof caption === 'string' ) {\n\t\treturn normalizeImageBlockCaption( caption );\n\t}\n\n\tif (\n\t\tcaption &&\n\t\ttypeof caption === 'object' &&\n\t\tObject.hasOwn( caption, 'raw' )\n\t) {\n\t\treturn normalizeImageBlockCaption( caption.raw );\n\t}\n\n\treturn undefined;\n}\n\nexport function getImageBlockMetadataFromAttachment( attachment ) {\n\treturn {\n\t\talt:\n\t\t\ttypeof attachment?.alt_text === 'string'\n\t\t\t\t? attachment.alt_text\n\t\t\t\t: attachment?.alt || '',\n\t\tcaption: getAttachmentCaption( attachment ),\n\t};\n}\n\nfunction normalizeMetadataAttribute( value ) {\n\treturn value || '';\n}\n\nexport function getSyncedImageBlockAttributes(\n\tcurrentAttributes,\n\toriginalAttachment,\n\tupdatedAttachment\n) {\n\tif ( ! originalAttachment || ! updatedAttachment ) {\n\t\treturn {};\n\t}\n\n\tconst originalMetadata =\n\t\tgetImageBlockMetadataFromAttachment( originalAttachment );\n\tconst updatedMetadata =\n\t\tgetImageBlockMetadataFromAttachment( updatedAttachment );\n\tconst syncedAttributes = {};\n\n\tconst normalizedCurrentAlt = normalizeMetadataAttribute(\n\t\tcurrentAttributes.alt\n\t);\n\tif (\n\t\toriginalMetadata.alt !== updatedMetadata.alt &&\n\t\t( normalizedCurrentAlt === originalMetadata.alt ||\n\t\t\t! normalizedCurrentAlt )\n\t) {\n\t\tsyncedAttributes.alt = updatedMetadata.alt;\n\t}\n\n\tconst normalizedCurrentCaption = normalizeMetadataAttribute(\n\t\tcurrentAttributes.caption\n\t);\n\tif (\n\t\toriginalMetadata.caption !== undefined &&\n\t\tupdatedMetadata.caption !== undefined &&\n\t\toriginalMetadata.caption !== updatedMetadata.caption &&\n\t\t( normalizedCurrentCaption === originalMetadata.caption ||\n\t\t\t! normalizedCurrentCaption )\n\t) {\n\t\tsyncedAttributes.caption = updatedMetadata.caption || undefined;\n\t}\n\n\treturn syncedAttributes;\n}\n\n/**\n * Resolves the attributes needed to keep the selected image size on a new\n * attachment.\n *\n * WordPress skips generating a sub-size larger than the file itself, so the\n * selected size may not exist on the edited image; fall back to full when it\n * doesn't.\n *\n * @param {string|undefined} sizeSlug The block's currently selected size.\n * @param {Object} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, if any.\n */\nfunction getNewAttachmentSizeAttributes( sizeSlug, attachment ) {\n\tconst sizes = attachment.media_details?.sizes;\n\n\tif ( ! sizeSlug || sizeSlug === DEFAULT_MEDIA_SIZE_SLUG || ! sizes ) {\n\t\treturn undefined;\n\t}\n\n\tconst sizeUrl = sizes[ sizeSlug ]?.source_url;\n\n\tif ( sizeUrl ) {\n\t\treturn { url: sizeUrl };\n\t}\n\n\tconst fullUrl = attachment.source_url ?? sizes.full?.source_url;\n\n\treturn fullUrl\n\t\t? { url: fullUrl, sizeSlug: DEFAULT_MEDIA_SIZE_SLUG }\n\t\t: undefined;\n}\n\n/**\n * Resolves the link attributes needed to keep the block's link pointing at the\n * new attachment.\n *\n * Only the destinations derived from the attachment follow the edited image. A\n * `custom` link is the user's own URL and a `none` link has nothing to point\n * at, so both are left alone. When the record doesn't carry the field, the\n * existing link is kept rather than cleared.\n *\n * @param {string|undefined} linkDestination The block's link destination.\n * @param {Object} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, if any.\n */\nfunction getNewAttachmentLinkAttributes( linkDestination, attachment ) {\n\t// Media file links point at the full-size file, independently of the size\n\t// the block renders.\n\tif ( linkDestination === LINK_DESTINATION_MEDIA ) {\n\t\treturn attachment.source_url\n\t\t\t? { href: attachment.source_url }\n\t\t\t: undefined;\n\t}\n\n\tif ( linkDestination === LINK_DESTINATION_ATTACHMENT ) {\n\t\treturn attachment.link ? { href: attachment.link } : undefined;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolves the block attributes that are derived from the attachment, for an\n * edit that saved to a different one.\n *\n * Editing media (crop, rotate, flip) creates a new attachment with its own\n * generated sub-sizes and its own attachment page, and the media editor\n * reports the full-size file. Without re-deriving these, the size control\n * keeps reporting e.g. \"Medium\" while the block renders the full-size image,\n * and a \"Media file\" or \"Attachment page\" link still points at the image as it\n * was before the edit. Everything else the user set on the block — dimensions,\n * lightbox, title, custom links — is left untouched.\n *\n * @param {Object} blockAttributes The block's current attributes.\n * @param {Object|undefined} attachment The new attachment record.\n *\n * @return {Object|undefined} Attributes to apply, or undefined when the\n * attachment record isn't known yet.\n */\nexport function getNewAttachmentImageBlockAttributes(\n\tblockAttributes,\n\tattachment\n) {\n\tif ( ! attachment ) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\t...getNewAttachmentSizeAttributes(\n\t\t\tblockAttributes.sizeSlug,\n\t\t\tattachment\n\t\t),\n\t\t...getNewAttachmentLinkAttributes(\n\t\t\tblockAttributes.linkDestination,\n\t\t\tattachment\n\t\t),\n\t};\n}\n\nconst { openMediaEditorModalKey } = unlock( blockEditorPrivateApis );\n\nfunction getAttachmentFallbackForEmptyBlockMetadata( { alt, caption } ) {\n\tconst attachment = {};\n\n\tif ( ! alt ) {\n\t\tattachment.alt_text = '';\n\t}\n\n\tif ( ! caption?.toString() ) {\n\t\tattachment.caption = '';\n\t}\n\n\treturn Object.keys( attachment ).length ? attachment : undefined;\n}\n\nfunction hasKnownAttachmentMetadata( attachment ) {\n\tif ( ! attachment ) {\n\t\treturn false;\n\t}\n\n\tconst hasKnownAlt =\n\t\ttypeof attachment.alt_text === 'string' ||\n\t\ttypeof attachment.alt === 'string';\n\tconst hasKnownCaption =\n\t\tgetImageBlockMetadataFromAttachment( attachment ).caption !== undefined;\n\n\treturn hasKnownAlt && hasKnownCaption;\n}\n\nexport function useOpenImageMediaEditorModal( {\n\tattributes,\n\tsetAttributes,\n\tonClose,\n\tonUrlChange,\n} ) {\n\t// Keep this hook private to the Image block and pass the block attributes\n\t// object so the callsite stays compact. Destructure only the attributes\n\t// the update needs to read — those synced from the attachment's metadata,\n\t// and those derived from which attachment the block points at; add more\n\t// here if the sync policy grows.\n\tconst { id, url, alt, caption, sizeSlug, linkDestination, href } =\n\t\tattributes;\n\tconst registry = useRegistry();\n\tconst openMediaEditorModal = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()[ openMediaEditorModalKey ],\n\t\t[]\n\t);\n\t// Track the block's current attachment and metadata in a ref so\n\t// handleMediaUpdate can read the latest values without being listed as\n\t// dependencies (which would recreate the callback and re-register the\n\t// onUpdate handler on every block change while the modal is open).\n\tconst blockAttributesRef = useRef( {\n\t\tid,\n\t\turl,\n\t\talt,\n\t\tcaption: caption?.toString(),\n\t\tsizeSlug,\n\t\tlinkDestination,\n\t\thref,\n\t} );\n\t// Snapshot of the attachment's metadata taken just before the modal opens,\n\t// used as the baseline for detecting what changed during the editing session.\n\tconst mediaEditorMetadataBaselineRef = useRef();\n\t// Incremented on every handleMediaUpdate call; stale async continuations\n\t// check against this to bail out if a newer update has since started.\n\tconst mediaEditorMetadataSyncRequestRef = useRef( 0 );\n\n\tuseEffect( () => {\n\t\tblockAttributesRef.current = {\n\t\t\tid,\n\t\t\turl,\n\t\t\talt,\n\t\t\tcaption: caption?.toString(),\n\t\t\tsizeSlug,\n\t\t\tlinkDestination,\n\t\t\thref,\n\t\t};\n\t}, [ alt, caption, href, id, linkDestination, sizeSlug, url ] );\n\n\t// Reads the cached attachment record. The `attachment` postType entity\n\t// fetches with `context: 'edit'` by default, so `getEditedEntityRecord`\n\t// returns the edit-context record — carrying `caption` as `{ raw }` and a\n\t// usable `alt_text` — without us specifying a context. It is resolver-\n\t// backed, so on a cold cache this also kicks off the fetch and returns a\n\t// falsy value synchronously; that resolution shares its cache key with the\n\t// `resolveAttachmentRecord` call below (both keyed on the no-query\n\t// `getEntityRecord`), so the two dedupe into a single request.\n\tconst getCachedAttachmentRecord = useCallback(\n\t\t( attachmentId ) =>\n\t\t\tregistry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t),\n\t\t[ registry ]\n\t);\n\n\tconst resolveAttachmentRecord = useCallback(\n\t\tasync ( attachmentId ) => {\n\t\t\tconst resolveSelect = registry.resolveSelect( coreStore );\n\n\t\t\ttry {\n\t\t\t\treturn await resolveSelect.getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tattachmentId\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t},\n\t\t[ registry ]\n\t);\n\n\tconst resolveFreshAttachmentRecord = useCallback(\n\t\tasync ( attachmentId ) => {\n\t\t\t// Invalidate the cached resolution so resolveAttachmentRecord\n\t\t\t// re-fetches the server state that reflects the media editor's\n\t\t\t// saved changes.\n\t\t\tconst { invalidateResolution } = registry.dispatch( coreStore );\n\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachmentId,\n\t\t\t] );\n\t\t\treturn resolveAttachmentRecord( attachmentId );\n\t\t},\n\t\t[ registry, resolveAttachmentRecord ]\n\t);\n\n\tconst handleMediaUpdate = useCallback(\n\t\tasync ( { id: newId, url: newUrl }, undoState ) => {\n\t\t\tif ( typeof newId !== 'number' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Capture and clear the baseline so a rapid second save doesn't\n\t\t\t// reuse a stale snapshot.\n\t\t\tconst originalAttachment = mediaEditorMetadataBaselineRef.current;\n\t\t\tmediaEditorMetadataBaselineRef.current = undefined;\n\t\t\tconst syncRequest = ++mediaEditorMetadataSyncRequestRef.current;\n\t\t\tconst nextAttributes = {};\n\n\t\t\tconst currentBlockAttributes = blockAttributesRef.current;\n\t\t\tconst isNewAttachment = newId !== currentBlockAttributes.id;\n\n\t\t\tif ( isNewAttachment ) {\n\t\t\t\t// Capture the block's selected-size URL, not the attachment's\n\t\t\t\t// full-size URL supplied by the modal's fallback Undo.\n\t\t\t\tundoState.undoAttributes.id = currentBlockAttributes.id;\n\t\t\t\tundoState.undoAttributes.url = currentBlockAttributes.url;\n\t\t\t\tnextAttributes.id = newId;\n\t\t\t\tnextAttributes.url = newUrl ?? currentBlockAttributes.url;\n\t\t\t\tif ( nextAttributes.url !== currentBlockAttributes.url ) {\n\t\t\t\t\t// The block is about to point at a freshly generated file\n\t\t\t\t\t// the browser hasn't loaded yet; let the caller show a\n\t\t\t\t\t// loading state until its <img> fires load/error. Raising\n\t\t\t\t\t// it here, before anything is awaited, keeps the rest of\n\t\t\t\t\t// this update behind that loading state: the attributes\n\t\t\t\t\t// land in a single `setAttributes` at the end, so the\n\t\t\t\t\t// image never renders against half-updated settings.\n\t\t\t\t\tonUrlChange?.( nextAttributes.url );\n\t\t\t\t}\n\t\t\t\tblockAttributesRef.current = {\n\t\t\t\t\t...blockAttributesRef.current,\n\t\t\t\t\tid: nextAttributes.id,\n\t\t\t\t\turl: nextAttributes.url,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( originalAttachment || isNewAttachment ) {\n\t\t\t\t// Fetch fresh server state so this reflects what the media\n\t\t\t\t// editor actually saved, not a potentially stale cache.\n\t\t\t\tconst resolvedAttachment =\n\t\t\t\t\tawait resolveFreshAttachmentRecord( newId );\n\n\t\t\t\t// A newer update started while we were awaiting; discard\n\t\t\t\t// this one.\n\t\t\t\tif (\n\t\t\t\t\tundoState.isUndone ||\n\t\t\t\t\tsyncRequest !== mediaEditorMetadataSyncRequestRef.current\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// A failed refetch returns nothing, which would leave the\n\t\t\t\t// block pointing at the new file while its size and link\n\t\t\t\t// still describe the old one. The record the media editor\n\t\t\t\t// received when it saved is already in the store, so fall\n\t\t\t\t// back to that rather than half-updating the block.\n\t\t\t\tconst attachmentRecord =\n\t\t\t\t\tresolvedAttachment ?? getCachedAttachmentRecord( newId );\n\n\t\t\t\tconst latestBlockAttributes = blockAttributesRef.current;\n\n\t\t\t\t// Sync alt text and caption back to the block only when\n\t\t\t\t// they were changed in the media editor. Fields the user\n\t\t\t\t// has independently customised on the block (i.e. values\n\t\t\t\t// that don't match the pre-session attachment metadata)\n\t\t\t\t// are left untouched. Without a baseline there's no way to\n\t\t\t\t// tell the two apart, so nothing is synced.\n\t\t\t\tif ( originalAttachment ) {\n\t\t\t\t\tconst resolvedMetadataAttributes =\n\t\t\t\t\t\tgetSyncedImageBlockAttributes(\n\t\t\t\t\t\t\tlatestBlockAttributes,\n\t\t\t\t\t\t\toriginalAttachment,\n\t\t\t\t\t\t\tattachmentRecord\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif ( Object.keys( resolvedMetadataAttributes ).length ) {\n\t\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t\tnextAttributes,\n\t\t\t\t\t\t\tresolvedMetadataAttributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( isNewAttachment ) {\n\t\t\t\t\tconst derivedAttributes =\n\t\t\t\t\t\tgetNewAttachmentImageBlockAttributes(\n\t\t\t\t\t\t\tlatestBlockAttributes,\n\t\t\t\t\t\t\tattachmentRecord\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif ( derivedAttributes ) {\n\t\t\t\t\t\tObject.assign( nextAttributes, derivedAttributes );\n\n\t\t\t\t\t\t// The URL announced before the resolve was the\n\t\t\t\t\t\t// full-size file the media editor reported, and\n\t\t\t\t\t\t// deriving the selected size can change it.\n\t\t\t\t\t\t// Re-announce so the pending swap names the file\n\t\t\t\t\t\t// that actually lands: an update that is undone or\n\t\t\t\t\t\t// superseded never changes the <img> src, and the\n\t\t\t\t\t\t// block then clears its loading state by matching\n\t\t\t\t\t\t// the pending URL against the rendered one.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tderivedAttributes.url &&\n\t\t\t\t\t\t\tderivedAttributes.url !== latestBlockAttributes.url\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonUrlChange?.( derivedAttributes.url );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( Object.keys( nextAttributes ).length ) {\n\t\t\t\t// Only restore values this save changed. Block-specific\n\t\t\t\t// metadata and unrelated edits must not be overwritten.\n\t\t\t\tfor ( const key of Object.keys( nextAttributes ) ) {\n\t\t\t\t\tif ( ! Object.hasOwn( undoState.undoAttributes, key ) ) {\n\t\t\t\t\t\tundoState.undoAttributes[ key ] =\n\t\t\t\t\t\t\tblockAttributesRef.current[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tblockAttributesRef.current = {\n\t\t\t\t\t...blockAttributesRef.current,\n\t\t\t\t\t...nextAttributes,\n\t\t\t\t};\n\t\t\t\tsetAttributes( nextAttributes );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetCachedAttachmentRecord,\n\t\t\tonUrlChange,\n\t\t\tresolveFreshAttachmentRecord,\n\t\t\tsetAttributes,\n\t\t]\n\t);\n\n\tconst openImageMediaEditorModal = useCallback( async () => {\n\t\tif ( ! id || ! openMediaEditorModal ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Snapshot the attachment's current metadata before the user makes\n\t\t// any changes so handleMediaUpdate can compare against it later. Use\n\t\t// the cached record when it's already present; only resolve when\n\t\t// nothing is cached yet, then fall back to a minimal object derived\n\t\t// from the block's own attributes.\n\t\tconst cachedAttachmentRecord = getCachedAttachmentRecord( id );\n\t\tconst fallbackAttachmentRecord =\n\t\t\tgetAttachmentFallbackForEmptyBlockMetadata(\n\t\t\t\tblockAttributesRef.current\n\t\t\t);\n\t\tconst resolvedAttachmentRecord = hasKnownAttachmentMetadata(\n\t\t\tcachedAttachmentRecord\n\t\t)\n\t\t\t? undefined\n\t\t\t: await resolveAttachmentRecord( id );\n\n\t\tmediaEditorMetadataBaselineRef.current =\n\t\t\tresolvedAttachmentRecord ||\n\t\t\t( hasKnownAttachmentMetadata( cachedAttachmentRecord )\n\t\t\t\t? cachedAttachmentRecord\n\t\t\t\t: fallbackAttachmentRecord ) ||\n\t\t\tcachedAttachmentRecord;\n\n\t\t// Each opening owns its Undo snapshot, so a later opening cannot\n\t\t// replace the values captured by an earlier snackbar.\n\t\tconst undoState = { undoAttributes: {}, isUndone: false };\n\t\topenMediaEditorModal( {\n\t\t\tid,\n\t\t\tonUpdate: ( updated ) => handleMediaUpdate( updated, undoState ),\n\t\t\tonUndo: () => {\n\t\t\t\tundoState.isUndone = true;\n\t\t\t\tconst { undoAttributes } = undoState;\n\t\t\t\tif ( Object.hasOwn( undoAttributes, 'url' ) ) {\n\t\t\t\t\tonUrlChange?.( undoAttributes.url );\n\t\t\t\t}\n\t\t\t\tblockAttributesRef.current = {\n\t\t\t\t\t...blockAttributesRef.current,\n\t\t\t\t\t...undoAttributes,\n\t\t\t\t};\n\t\t\t\tsetAttributes( undoAttributes );\n\t\t\t},\n\t\t\tonClose,\n\t\t} );\n\t}, [\n\t\tgetCachedAttachmentRecord,\n\t\thandleMediaUpdate,\n\t\tid,\n\t\tonClose,\n\t\tonUrlChange,\n\t\topenMediaEditorModal,\n\t\tresolveAttachmentRecord,\n\t\tsetAttributes,\n\t] );\n\n\treturn id && openMediaEditorModal ? openImageMediaEditorModal : undefined;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAmC;AACnC,0BAGO;AACP,iBAAiD;AACjD,kBAAuC;AACvC,qBAA+C;AAC/C,yBAAuB;AACvB,uBAIO;AAEP,SAAS,2BAA4B,SAAU;AAC9C,MAAK,OAAO,YAAY,UAAW;AAClC,WAAO;AAAA,EACR;AAEA,QAAM,kBAAc,WAAAA,qBAAW,OAAQ,EAAE,KAAK;AAE9C,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SAAO,QAAQ,QAAS,OAAO,MAAO;AACvC;AAEA,SAAS,qBAAsB,YAAa;AAC3C,QAAM,UAAU,YAAY;AAE5B,MAAK,OAAO,YAAY,UAAW;AAClC,WAAO,2BAA4B,OAAQ;AAAA,EAC5C;AAEA,MACC,WACA,OAAO,YAAY,YACnB,OAAO,OAAQ,SAAS,KAAM,GAC7B;AACD,WAAO,2BAA4B,QAAQ,GAAI;AAAA,EAChD;AAEA,SAAO;AACR;AAEO,SAAS,oCAAqC,YAAa;AACjE,SAAO;AAAA,IACN,KACC,OAAO,YAAY,aAAa,WAC7B,WAAW,WACX,YAAY,OAAO;AAAA,IACvB,SAAS,qBAAsB,UAAW;AAAA,EAC3C;AACD;AAEA,SAAS,2BAA4B,OAAQ;AAC5C,SAAO,SAAS;AACjB;AAEO,SAAS,8BACf,mBACA,oBACA,mBACC;AACD,MAAK,CAAE,sBAAsB,CAAE,mBAAoB;AAClD,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,mBACL,oCAAqC,kBAAmB;AACzD,QAAM,kBACL,oCAAqC,iBAAkB;AACxD,QAAM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