@wordpress/block-library 8.13.0 → 8.14.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 (366) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/index.js +5 -1
  3. package/build/archives/index.js.map +1 -1
  4. package/build/audio/index.js +5 -1
  5. package/build/audio/index.js.map +1 -1
  6. package/build/avatar/index.js +1 -1
  7. package/build/block/edit.js +1 -1
  8. package/build/block/edit.js.map +1 -1
  9. package/build/block/edit.native.js +6 -9
  10. package/build/block/edit.native.js.map +1 -1
  11. package/build/buttons/edit.js +5 -1
  12. package/build/buttons/edit.js.map +1 -1
  13. package/build/categories/index.js +5 -1
  14. package/build/categories/index.js.map +1 -1
  15. package/build/code/index.js +5 -1
  16. package/build/code/index.js.map +1 -1
  17. package/build/column/index.js +1 -0
  18. package/build/column/index.js.map +1 -1
  19. package/build/comments/index.js +1 -0
  20. package/build/comments/index.js.map +1 -1
  21. package/build/cover/edit/inspector-controls.js +2 -1
  22. package/build/cover/edit/inspector-controls.js.map +1 -1
  23. package/build/cover/index.js +1 -0
  24. package/build/cover/index.js.map +1 -1
  25. package/build/details/index.js +5 -1
  26. package/build/details/index.js.map +1 -1
  27. package/build/embed/util.js +9 -8
  28. package/build/embed/util.js.map +1 -1
  29. package/build/file/index.js +2 -1
  30. package/build/file/index.js.map +1 -1
  31. package/build/file/view.js +15 -1
  32. package/build/file/view.js.map +1 -1
  33. package/build/gallery/index.js +3 -1
  34. package/build/gallery/index.js.map +1 -1
  35. package/build/group/index.js +1 -0
  36. package/build/group/index.js.map +1 -1
  37. package/build/heading/index.js +5 -1
  38. package/build/heading/index.js.map +1 -1
  39. package/build/heading/transforms.js +5 -1
  40. package/build/heading/transforms.js.map +1 -1
  41. package/build/image/deprecated.js +453 -175
  42. package/build/image/deprecated.js.map +1 -1
  43. package/build/image/edit.js +0 -4
  44. package/build/image/edit.js.map +1 -1
  45. package/build/image/image.js +96 -43
  46. package/build/image/image.js.map +1 -1
  47. package/build/image/index.js +6 -0
  48. package/build/image/index.js.map +1 -1
  49. package/build/image/save.js +8 -1
  50. package/build/image/save.js.map +1 -1
  51. package/build/image/utils.js +18 -0
  52. package/build/image/utils.js.map +1 -1
  53. package/build/image/{interactivity.js → view-interactivity.js} +86 -44
  54. package/build/image/view-interactivity.js.map +1 -0
  55. package/build/index.js +12 -3
  56. package/build/index.js.map +1 -1
  57. package/build/list/index.js +5 -1
  58. package/build/list/index.js.map +1 -1
  59. package/build/list-item/utils.js +6 -1
  60. package/build/list-item/utils.js.map +1 -1
  61. package/build/media-text/index.js +1 -0
  62. package/build/media-text/index.js.map +1 -1
  63. package/build/missing/edit.js +22 -8
  64. package/build/missing/edit.js.map +1 -1
  65. package/build/navigation/edit/index.js +1 -1
  66. package/build/navigation/edit/index.js.map +1 -1
  67. package/build/navigation/edit/menu-inspector-controls.js +0 -1
  68. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  69. package/build/navigation/index.js +3 -2
  70. package/build/navigation/index.js.map +1 -1
  71. package/build/navigation/view.js +174 -50
  72. package/build/navigation/view.js.map +1 -1
  73. package/build/navigation-link/edit.js +0 -11
  74. package/build/navigation-link/edit.js.map +1 -1
  75. package/build/navigation-link/link-ui.js +12 -2
  76. package/build/navigation-link/link-ui.js.map +1 -1
  77. package/build/page-list/convert-to-links-modal.js +3 -3
  78. package/build/page-list/convert-to-links-modal.js.map +1 -1
  79. package/build/page-list/edit.js +34 -39
  80. package/build/page-list/edit.js.map +1 -1
  81. package/build/page-list/use-convert-to-navigation-links.js +2 -15
  82. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  83. package/build/paragraph/index.js +1 -0
  84. package/build/paragraph/index.js.map +1 -1
  85. package/build/paragraph/transforms.js +1 -0
  86. package/build/paragraph/transforms.js.map +1 -1
  87. package/build/post-comments-form/index.js +1 -0
  88. package/build/post-comments-form/index.js.map +1 -1
  89. package/build/post-navigation-link/index.js +1 -0
  90. package/build/post-navigation-link/index.js.map +1 -1
  91. package/build/post-time-to-read/index.js +5 -1
  92. package/build/post-time-to-read/index.js.map +1 -1
  93. package/build/query-pagination-numbers/index.js +1 -1
  94. package/build/quote/index.js +1 -0
  95. package/build/quote/index.js.map +1 -1
  96. package/build/site-logo/index.js +5 -1
  97. package/build/site-logo/index.js.map +1 -1
  98. package/build/site-tagline/icon.js +1 -1
  99. package/build/site-tagline/icon.js.map +1 -1
  100. package/build/site-tagline/index.js +5 -1
  101. package/build/site-tagline/index.js.map +1 -1
  102. package/build/site-title/index.js +5 -1
  103. package/build/site-title/index.js.map +1 -1
  104. package/build/social-links/index.js +3 -1
  105. package/build/social-links/index.js.map +1 -1
  106. package/build/table/index.js +5 -1
  107. package/build/table/index.js.map +1 -1
  108. package/build/term-description/index.js +1 -0
  109. package/build/term-description/index.js.map +1 -1
  110. package/build/verse/index.js +5 -1
  111. package/build/verse/index.js.map +1 -1
  112. package/build/video/deprecated.js +5 -1
  113. package/build/video/deprecated.js.map +1 -1
  114. package/build/video/index.js +5 -1
  115. package/build/video/index.js.map +1 -1
  116. package/build-module/archives/index.js +5 -1
  117. package/build-module/archives/index.js.map +1 -1
  118. package/build-module/audio/index.js +5 -1
  119. package/build-module/audio/index.js.map +1 -1
  120. package/build-module/avatar/index.js +1 -1
  121. package/build-module/block/edit.js +1 -1
  122. package/build-module/block/edit.js.map +1 -1
  123. package/build-module/block/edit.native.js +7 -9
  124. package/build-module/block/edit.native.js.map +1 -1
  125. package/build-module/buttons/edit.js +5 -1
  126. package/build-module/buttons/edit.js.map +1 -1
  127. package/build-module/categories/index.js +5 -1
  128. package/build-module/categories/index.js.map +1 -1
  129. package/build-module/code/index.js +5 -1
  130. package/build-module/code/index.js.map +1 -1
  131. package/build-module/column/index.js +1 -0
  132. package/build-module/column/index.js.map +1 -1
  133. package/build-module/comments/index.js +1 -0
  134. package/build-module/comments/index.js.map +1 -1
  135. package/build-module/cover/edit/inspector-controls.js +2 -1
  136. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  137. package/build-module/cover/index.js +1 -0
  138. package/build-module/cover/index.js.map +1 -1
  139. package/build-module/details/index.js +5 -1
  140. package/build-module/details/index.js.map +1 -1
  141. package/build-module/embed/util.js +6 -6
  142. package/build-module/embed/util.js.map +1 -1
  143. package/build-module/file/index.js +2 -1
  144. package/build-module/file/index.js.map +1 -1
  145. package/build-module/file/view.js +15 -2
  146. package/build-module/file/view.js.map +1 -1
  147. package/build-module/gallery/index.js +3 -1
  148. package/build-module/gallery/index.js.map +1 -1
  149. package/build-module/group/index.js +1 -0
  150. package/build-module/group/index.js.map +1 -1
  151. package/build-module/heading/index.js +5 -1
  152. package/build-module/heading/index.js.map +1 -1
  153. package/build-module/heading/transforms.js +5 -1
  154. package/build-module/heading/transforms.js.map +1 -1
  155. package/build-module/image/deprecated.js +454 -176
  156. package/build-module/image/deprecated.js.map +1 -1
  157. package/build-module/image/edit.js +0 -4
  158. package/build-module/image/edit.js.map +1 -1
  159. package/build-module/image/image.js +96 -46
  160. package/build-module/image/image.js.map +1 -1
  161. package/build-module/image/index.js +6 -0
  162. package/build-module/image/index.js.map +1 -1
  163. package/build-module/image/save.js +8 -1
  164. package/build-module/image/save.js.map +1 -1
  165. package/build-module/image/utils.js +16 -0
  166. package/build-module/image/utils.js.map +1 -1
  167. package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
  168. package/build-module/image/view-interactivity.js.map +1 -0
  169. package/build-module/index.js +12 -3
  170. package/build-module/index.js.map +1 -1
  171. package/build-module/list/index.js +5 -1
  172. package/build-module/list/index.js.map +1 -1
  173. package/build-module/list-item/utils.js +6 -1
  174. package/build-module/list-item/utils.js.map +1 -1
  175. package/build-module/media-text/index.js +1 -0
  176. package/build-module/media-text/index.js.map +1 -1
  177. package/build-module/missing/edit.js +22 -8
  178. package/build-module/missing/edit.js.map +1 -1
  179. package/build-module/navigation/edit/index.js +1 -1
  180. package/build-module/navigation/edit/index.js.map +1 -1
  181. package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
  182. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  183. package/build-module/navigation/index.js +3 -2
  184. package/build-module/navigation/index.js.map +1 -1
  185. package/build-module/navigation/view.js +173 -50
  186. package/build-module/navigation/view.js.map +1 -1
  187. package/build-module/navigation-link/edit.js +1 -12
  188. package/build-module/navigation-link/edit.js.map +1 -1
  189. package/build-module/navigation-link/link-ui.js +13 -3
  190. package/build-module/navigation-link/link-ui.js.map +1 -1
  191. package/build-module/page-list/convert-to-links-modal.js +3 -3
  192. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  193. package/build-module/page-list/edit.js +34 -39
  194. package/build-module/page-list/edit.js.map +1 -1
  195. package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
  196. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  197. package/build-module/paragraph/index.js +1 -0
  198. package/build-module/paragraph/index.js.map +1 -1
  199. package/build-module/paragraph/transforms.js +1 -0
  200. package/build-module/paragraph/transforms.js.map +1 -1
  201. package/build-module/post-comments-form/index.js +1 -0
  202. package/build-module/post-comments-form/index.js.map +1 -1
  203. package/build-module/post-navigation-link/index.js +1 -0
  204. package/build-module/post-navigation-link/index.js.map +1 -1
  205. package/build-module/post-time-to-read/index.js +5 -1
  206. package/build-module/post-time-to-read/index.js.map +1 -1
  207. package/build-module/query-pagination-numbers/index.js +1 -1
  208. package/build-module/quote/index.js +1 -0
  209. package/build-module/quote/index.js.map +1 -1
  210. package/build-module/site-logo/index.js +5 -1
  211. package/build-module/site-logo/index.js.map +1 -1
  212. package/build-module/site-tagline/icon.js +1 -1
  213. package/build-module/site-tagline/icon.js.map +1 -1
  214. package/build-module/site-tagline/index.js +5 -1
  215. package/build-module/site-tagline/index.js.map +1 -1
  216. package/build-module/site-title/index.js +5 -1
  217. package/build-module/site-title/index.js.map +1 -1
  218. package/build-module/social-links/index.js +3 -1
  219. package/build-module/social-links/index.js.map +1 -1
  220. package/build-module/table/index.js +5 -1
  221. package/build-module/table/index.js.map +1 -1
  222. package/build-module/term-description/index.js +1 -0
  223. package/build-module/term-description/index.js.map +1 -1
  224. package/build-module/verse/index.js +5 -1
  225. package/build-module/verse/index.js.map +1 -1
  226. package/build-module/video/deprecated.js +5 -1
  227. package/build-module/video/deprecated.js.map +1 -1
  228. package/build-module/video/index.js +5 -1
  229. package/build-module/video/index.js.map +1 -1
  230. package/build-style/footnotes/style-rtl.css +2 -2
  231. package/build-style/footnotes/style.css +2 -2
  232. package/build-style/image/style-rtl.css +16 -2
  233. package/build-style/image/style.css +16 -2
  234. package/build-style/style-rtl.css +18 -4
  235. package/build-style/style.css +18 -4
  236. package/package.json +33 -38
  237. package/src/archives/block.json +5 -1
  238. package/src/audio/block.json +5 -1
  239. package/src/avatar/block.json +1 -1
  240. package/src/block/edit.js +2 -2
  241. package/src/block/edit.native.js +8 -12
  242. package/src/block/test/edit.native.js +4 -4
  243. package/src/buttons/edit.js +2 -2
  244. package/src/categories/block.json +5 -1
  245. package/src/code/block.json +5 -1
  246. package/src/column/block.json +1 -0
  247. package/src/comments/block.json +1 -0
  248. package/src/cover/block.json +1 -0
  249. package/src/cover/edit/inspector-controls.js +1 -0
  250. package/src/details/block.json +5 -1
  251. package/src/embed/util.js +4 -6
  252. package/src/file/block.json +2 -1
  253. package/src/file/index.php +0 -17
  254. package/src/file/view.js +14 -5
  255. package/src/footnotes/index.php +11 -9
  256. package/src/footnotes/style.scss +2 -2
  257. package/src/gallery/block.json +3 -1
  258. package/src/group/block.json +1 -0
  259. package/src/heading/block.json +5 -1
  260. package/src/heading/test/index.native.js +18 -0
  261. package/src/image/block.json +6 -0
  262. package/src/image/deprecated.js +597 -320
  263. package/src/image/edit.js +0 -4
  264. package/src/image/image.js +131 -62
  265. package/src/image/save.js +9 -1
  266. package/src/image/style.scss +15 -2
  267. package/src/image/utils.js +16 -0
  268. package/src/image/{interactivity.js → view-interactivity.js} +99 -50
  269. package/src/index.js +18 -1
  270. package/src/latest-posts/index.php +1 -1
  271. package/src/list/block.json +5 -1
  272. package/src/media-text/block.json +1 -0
  273. package/src/missing/edit.js +31 -11
  274. package/src/navigation/block.json +3 -2
  275. package/src/navigation/edit/index.js +1 -2
  276. package/src/navigation/edit/menu-inspector-controls.js +0 -1
  277. package/src/navigation/index.php +39 -30
  278. package/src/navigation/view.js +189 -67
  279. package/src/navigation-link/edit.js +1 -15
  280. package/src/navigation-link/link-ui.js +14 -2
  281. package/src/navigation-submenu/index.php +2 -12
  282. package/src/page-list/convert-to-links-modal.js +3 -3
  283. package/src/page-list/edit.js +65 -62
  284. package/src/page-list/use-convert-to-navigation-links.js +3 -20
  285. package/src/paragraph/block.json +1 -0
  286. package/src/post-comments-form/block.json +1 -0
  287. package/src/post-navigation-link/block.json +1 -0
  288. package/src/post-time-to-read/block.json +5 -1
  289. package/src/query-pagination-numbers/block.json +1 -1
  290. package/src/quote/block.json +1 -0
  291. package/src/site-logo/block.json +5 -1
  292. package/src/site-tagline/block.json +5 -1
  293. package/src/site-tagline/icon.js +1 -1
  294. package/src/site-title/block.json +5 -1
  295. package/src/social-links/block.json +3 -1
  296. package/src/table/block.json +5 -1
  297. package/src/term-description/block.json +1 -0
  298. package/src/verse/block.json +5 -1
  299. package/src/video/block.json +5 -1
  300. package/build/file/interactivity.js +0 -19
  301. package/build/file/interactivity.js.map +0 -1
  302. package/build/heading/heading-level-icon.js +0 -61
  303. package/build/heading/heading-level-icon.js.map +0 -1
  304. package/build/image/interactivity.js.map +0 -1
  305. package/build/navigation/interactivity.js +0 -167
  306. package/build/navigation/interactivity.js.map +0 -1
  307. package/build/navigation/view-modal.js +0 -64
  308. package/build/navigation/view-modal.js.map +0 -1
  309. package/build/utils/interactivity/constants.js +0 -9
  310. package/build/utils/interactivity/constants.js.map +0 -1
  311. package/build/utils/interactivity/directives.js +0 -222
  312. package/build/utils/interactivity/directives.js.map +0 -1
  313. package/build/utils/interactivity/hooks.js +0 -159
  314. package/build/utils/interactivity/hooks.js.map +0 -1
  315. package/build/utils/interactivity/hydration.js +0 -34
  316. package/build/utils/interactivity/hydration.js.map +0 -1
  317. package/build/utils/interactivity/index.js +0 -32
  318. package/build/utils/interactivity/index.js.map +0 -1
  319. package/build/utils/interactivity/portals.js +0 -108
  320. package/build/utils/interactivity/portals.js.map +0 -1
  321. package/build/utils/interactivity/store.js +0 -66
  322. package/build/utils/interactivity/store.js.map +0 -1
  323. package/build/utils/interactivity/utils.js +0 -87
  324. package/build/utils/interactivity/utils.js.map +0 -1
  325. package/build/utils/interactivity/vdom.js +0 -119
  326. package/build/utils/interactivity/vdom.js.map +0 -1
  327. package/build-module/file/interactivity.js +0 -15
  328. package/build-module/file/interactivity.js.map +0 -1
  329. package/build-module/heading/heading-level-icon.js +0 -53
  330. package/build-module/heading/heading-level-icon.js.map +0 -1
  331. package/build-module/image/interactivity.js.map +0 -1
  332. package/build-module/navigation/interactivity.js +0 -164
  333. package/build-module/navigation/interactivity.js.map +0 -1
  334. package/build-module/navigation/view-modal.js +0 -58
  335. package/build-module/navigation/view-modal.js.map +0 -1
  336. package/build-module/utils/interactivity/constants.js +0 -2
  337. package/build-module/utils/interactivity/constants.js.map +0 -1
  338. package/build-module/utils/interactivity/directives.js +0 -209
  339. package/build-module/utils/interactivity/directives.js.map +0 -1
  340. package/build-module/utils/interactivity/hooks.js +0 -145
  341. package/build-module/utils/interactivity/hooks.js.map +0 -1
  342. package/build-module/utils/interactivity/hydration.js +0 -21
  343. package/build-module/utils/interactivity/hydration.js.map +0 -1
  344. package/build-module/utils/interactivity/index.js +0 -15
  345. package/build-module/utils/interactivity/index.js.map +0 -1
  346. package/build-module/utils/interactivity/portals.js +0 -100
  347. package/build-module/utils/interactivity/portals.js.map +0 -1
  348. package/build-module/utils/interactivity/store.js +0 -55
  349. package/build-module/utils/interactivity/store.js.map +0 -1
  350. package/build-module/utils/interactivity/utils.js +0 -75
  351. package/build-module/utils/interactivity/utils.js.map +0 -1
  352. package/build-module/utils/interactivity/vdom.js +0 -107
  353. package/build-module/utils/interactivity/vdom.js.map +0 -1
  354. package/src/file/interactivity.js +0 -15
  355. package/src/heading/heading-level-icon.js +0 -48
  356. package/src/navigation/interactivity.js +0 -169
  357. package/src/navigation/view-modal.js +0 -78
  358. package/src/utils/interactivity/constants.js +0 -1
  359. package/src/utils/interactivity/directives.js +0 -200
  360. package/src/utils/interactivity/hooks.js +0 -145
  361. package/src/utils/interactivity/hydration.js +0 -22
  362. package/src/utils/interactivity/index.js +0 -15
  363. package/src/utils/interactivity/portals.js +0 -98
  364. package/src/utils/interactivity/store.js +0 -45
  365. package/src/utils/interactivity/utils.js +0 -66
  366. package/src/utils/interactivity/vdom.js +0 -111
@@ -6,355 +6,632 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { RichText, useBlockProps } from '@wordpress/block-editor';
9
+ import {
10
+ RichText,
11
+ useBlockProps,
12
+ __experimentalGetElementClassName as getBorderClassesAndStyles,
13
+ } from '@wordpress/block-editor';
10
14
 
11
- const blockAttributes = {
12
- align: {
13
- type: 'string',
14
- },
15
- url: {
16
- type: 'string',
17
- source: 'attribute',
18
- selector: 'img',
19
- attribute: 'src',
20
- },
21
- alt: {
22
- type: 'string',
23
- source: 'attribute',
24
- selector: 'img',
25
- attribute: 'alt',
26
- default: '',
27
- },
28
- caption: {
29
- type: 'string',
30
- source: 'html',
31
- selector: 'figcaption',
32
- },
33
- title: {
34
- type: 'string',
35
- source: 'attribute',
36
- selector: 'img',
37
- attribute: 'title',
38
- },
39
- href: {
40
- type: 'string',
41
- source: 'attribute',
42
- selector: 'figure > a',
43
- attribute: 'href',
44
- },
45
- rel: {
46
- type: 'string',
47
- source: 'attribute',
48
- selector: 'figure > a',
49
- attribute: 'rel',
50
- },
51
- linkClass: {
52
- type: 'string',
53
- source: 'attribute',
54
- selector: 'figure > a',
55
- attribute: 'class',
56
- },
57
- id: {
58
- type: 'number',
15
+ /**
16
+ * Deprecation for adding the `wp-image-${id}` class to the image block for
17
+ * responsive images.
18
+ *
19
+ * @see https://github.com/WordPress/gutenberg/pull/4898
20
+ */
21
+ const v1 = {
22
+ attributes: {
23
+ url: {
24
+ type: 'string',
25
+ source: 'attribute',
26
+ selector: 'img',
27
+ attribute: 'src',
28
+ },
29
+ alt: {
30
+ type: 'string',
31
+ source: 'attribute',
32
+ selector: 'img',
33
+ attribute: 'alt',
34
+ default: '',
35
+ },
36
+ caption: {
37
+ type: 'array',
38
+ source: 'children',
39
+ selector: 'figcaption',
40
+ },
41
+ href: {
42
+ type: 'string',
43
+ source: 'attribute',
44
+ selector: 'a',
45
+ attribute: 'href',
46
+ },
47
+ id: {
48
+ type: 'number',
49
+ },
50
+ align: {
51
+ type: 'string',
52
+ },
53
+ width: {
54
+ type: 'number',
55
+ },
56
+ height: {
57
+ type: 'number',
58
+ },
59
59
  },
60
- width: {
61
- type: 'number',
60
+ save( { attributes } ) {
61
+ const { url, alt, caption, align, href, width, height } = attributes;
62
+ const extraImageProps = width || height ? { width, height } : {};
63
+ const image = <img src={ url } alt={ alt } { ...extraImageProps } />;
64
+
65
+ let figureStyle = {};
66
+
67
+ if ( width ) {
68
+ figureStyle = { width };
69
+ } else if ( align === 'left' || align === 'right' ) {
70
+ figureStyle = { maxWidth: '50%' };
71
+ }
72
+
73
+ return (
74
+ <figure
75
+ className={ align ? `align${ align }` : null }
76
+ style={ figureStyle }
77
+ >
78
+ { href ? <a href={ href }>{ image }</a> : image }
79
+ { ! RichText.isEmpty( caption ) && (
80
+ <RichText.Content tagName="figcaption" value={ caption } />
81
+ ) }
82
+ </figure>
83
+ );
62
84
  },
63
- height: {
64
- type: 'number',
85
+ };
86
+
87
+ /**
88
+ * Deprecation for adding the `is-resized` class to the image block to fix
89
+ * captions on resized images.
90
+ *
91
+ * @see https://github.com/WordPress/gutenberg/pull/6496
92
+ */
93
+ const v2 = {
94
+ attributes: {
95
+ url: {
96
+ type: 'string',
97
+ source: 'attribute',
98
+ selector: 'img',
99
+ attribute: 'src',
100
+ },
101
+ alt: {
102
+ type: 'string',
103
+ source: 'attribute',
104
+ selector: 'img',
105
+ attribute: 'alt',
106
+ default: '',
107
+ },
108
+ caption: {
109
+ type: 'array',
110
+ source: 'children',
111
+ selector: 'figcaption',
112
+ },
113
+ href: {
114
+ type: 'string',
115
+ source: 'attribute',
116
+ selector: 'a',
117
+ attribute: 'href',
118
+ },
119
+ id: {
120
+ type: 'number',
121
+ },
122
+ align: {
123
+ type: 'string',
124
+ },
125
+ width: {
126
+ type: 'number',
127
+ },
128
+ height: {
129
+ type: 'number',
130
+ },
65
131
  },
66
- sizeSlug: {
67
- type: 'string',
132
+ save( { attributes } ) {
133
+ const { url, alt, caption, align, href, width, height, id } =
134
+ attributes;
135
+
136
+ const image = (
137
+ <img
138
+ src={ url }
139
+ alt={ alt }
140
+ className={ id ? `wp-image-${ id }` : null }
141
+ width={ width }
142
+ height={ height }
143
+ />
144
+ );
145
+
146
+ return (
147
+ <figure className={ align ? `align${ align }` : null }>
148
+ { href ? <a href={ href }>{ image }</a> : image }
149
+ { ! RichText.isEmpty( caption ) && (
150
+ <RichText.Content tagName="figcaption" value={ caption } />
151
+ ) }
152
+ </figure>
153
+ );
68
154
  },
69
- linkDestination: {
70
- type: 'string',
155
+ };
156
+
157
+ /**
158
+ * Deprecation for image floats including a wrapping div.
159
+ *
160
+ * @see https://github.com/WordPress/gutenberg/pull/7721
161
+ */
162
+ const v3 = {
163
+ attributes: {
164
+ url: {
165
+ type: 'string',
166
+ source: 'attribute',
167
+ selector: 'img',
168
+ attribute: 'src',
169
+ },
170
+ alt: {
171
+ type: 'string',
172
+ source: 'attribute',
173
+ selector: 'img',
174
+ attribute: 'alt',
175
+ default: '',
176
+ },
177
+ caption: {
178
+ type: 'array',
179
+ source: 'children',
180
+ selector: 'figcaption',
181
+ },
182
+ href: {
183
+ type: 'string',
184
+ source: 'attribute',
185
+ selector: 'figure > a',
186
+ attribute: 'href',
187
+ },
188
+ id: {
189
+ type: 'number',
190
+ },
191
+ align: {
192
+ type: 'string',
193
+ },
194
+ width: {
195
+ type: 'number',
196
+ },
197
+ height: {
198
+ type: 'number',
199
+ },
200
+ linkDestination: {
201
+ type: 'string',
202
+ default: 'none',
203
+ },
71
204
  },
72
- linkTarget: {
73
- type: 'string',
74
- source: 'attribute',
75
- selector: 'figure > a',
76
- attribute: 'target',
205
+ save( { attributes } ) {
206
+ const { url, alt, caption, align, href, width, height, id } =
207
+ attributes;
208
+
209
+ const classes = classnames( {
210
+ [ `align${ align }` ]: align,
211
+ 'is-resized': width || height,
212
+ } );
213
+
214
+ const image = (
215
+ <img
216
+ src={ url }
217
+ alt={ alt }
218
+ className={ id ? `wp-image-${ id }` : null }
219
+ width={ width }
220
+ height={ height }
221
+ />
222
+ );
223
+
224
+ return (
225
+ <figure className={ classes }>
226
+ { href ? <a href={ href }>{ image }</a> : image }
227
+ { ! RichText.isEmpty( caption ) && (
228
+ <RichText.Content tagName="figcaption" value={ caption } />
229
+ ) }
230
+ </figure>
231
+ );
77
232
  },
78
233
  };
79
234
 
80
- const blockSupports = {
81
- anchor: true,
82
- color: {
83
- __experimentalDuotone: 'img',
84
- text: false,
85
- background: false,
86
- },
87
- __experimentalBorder: {
88
- radius: true,
89
- __experimentalDefaultControls: {
90
- radius: true,
235
+ /**
236
+ * Deprecation for removing the outer div wrapper around aligned images.
237
+ *
238
+ * @see https://github.com/WordPress/gutenberg/pull/38657
239
+ */
240
+ const v4 = {
241
+ attributes: {
242
+ align: {
243
+ type: 'string',
244
+ },
245
+ url: {
246
+ type: 'string',
247
+ source: 'attribute',
248
+ selector: 'img',
249
+ attribute: 'src',
250
+ },
251
+ alt: {
252
+ type: 'string',
253
+ source: 'attribute',
254
+ selector: 'img',
255
+ attribute: 'alt',
256
+ default: '',
257
+ },
258
+ caption: {
259
+ type: 'string',
260
+ source: 'html',
261
+ selector: 'figcaption',
262
+ },
263
+ title: {
264
+ type: 'string',
265
+ source: 'attribute',
266
+ selector: 'img',
267
+ attribute: 'title',
268
+ },
269
+ href: {
270
+ type: 'string',
271
+ source: 'attribute',
272
+ selector: 'figure > a',
273
+ attribute: 'href',
274
+ },
275
+ rel: {
276
+ type: 'string',
277
+ source: 'attribute',
278
+ selector: 'figure > a',
279
+ attribute: 'rel',
280
+ },
281
+ linkClass: {
282
+ type: 'string',
283
+ source: 'attribute',
284
+ selector: 'figure > a',
285
+ attribute: 'class',
286
+ },
287
+ id: {
288
+ type: 'number',
289
+ },
290
+ width: {
291
+ type: 'number',
292
+ },
293
+ height: {
294
+ type: 'number',
295
+ },
296
+ sizeSlug: {
297
+ type: 'string',
298
+ },
299
+ linkDestination: {
300
+ type: 'string',
301
+ },
302
+ linkTarget: {
303
+ type: 'string',
304
+ source: 'attribute',
305
+ selector: 'figure > a',
306
+ attribute: 'target',
91
307
  },
92
308
  },
93
- };
309
+ supports: {
310
+ anchor: true,
311
+ },
312
+ save( { attributes } ) {
313
+ const {
314
+ url,
315
+ alt,
316
+ caption,
317
+ align,
318
+ href,
319
+ rel,
320
+ linkClass,
321
+ width,
322
+ height,
323
+ id,
324
+ linkTarget,
325
+ sizeSlug,
326
+ title,
327
+ } = attributes;
94
328
 
95
- const deprecated = [
96
- // The following deprecation moves existing border radius styles onto the
97
- // inner img element where new border block support styles must be applied.
98
- // It will also add a new `.has-custom-border` class for existing blocks
99
- // with border radii set. This class is required to improve caption position
100
- // and styling when an image within a gallery has a custom border or
101
- // rounded corners.
102
- //
103
- // See: https://github.com/WordPress/gutenberg/pull/31366/
104
- {
105
- attributes: blockAttributes,
106
- supports: blockSupports,
107
- save( { attributes } ) {
108
- const {
109
- url,
110
- alt,
111
- caption,
112
- align,
113
- href,
114
- rel,
115
- linkClass,
116
- width,
117
- height,
118
- id,
119
- linkTarget,
120
- sizeSlug,
121
- title,
122
- } = attributes;
123
-
124
- const newRel = ! rel ? undefined : rel;
125
-
126
- const classes = classnames( {
127
- [ `align${ align }` ]: align,
128
- [ `size-${ sizeSlug }` ]: sizeSlug,
129
- 'is-resized': width || height,
130
- } );
131
-
132
- const image = (
133
- <img
134
- src={ url }
135
- alt={ alt }
136
- className={ id ? `wp-image-${ id }` : null }
137
- width={ width }
138
- height={ height }
139
- title={ title }
140
- />
141
- );
329
+ const newRel = ! rel ? undefined : rel;
142
330
 
143
- const figure = (
144
- <>
145
- { href ? (
146
- <a
147
- className={ linkClass }
148
- href={ href }
149
- target={ linkTarget }
150
- rel={ newRel }
151
- >
152
- { image }
153
- </a>
154
- ) : (
155
- image
156
- ) }
157
- { ! RichText.isEmpty( caption ) && (
158
- <RichText.Content
159
- tagName="figcaption"
160
- value={ caption }
161
- />
162
- ) }
163
- </>
164
- );
331
+ const classes = classnames( {
332
+ [ `align${ align }` ]: align,
333
+ [ `size-${ sizeSlug }` ]: sizeSlug,
334
+ 'is-resized': width || height,
335
+ } );
336
+
337
+ const image = (
338
+ <img
339
+ src={ url }
340
+ alt={ alt }
341
+ className={ id ? `wp-image-${ id }` : null }
342
+ width={ width }
343
+ height={ height }
344
+ title={ title }
345
+ />
346
+ );
347
+
348
+ const figure = (
349
+ <>
350
+ { href ? (
351
+ <a
352
+ className={ linkClass }
353
+ href={ href }
354
+ target={ linkTarget }
355
+ rel={ newRel }
356
+ >
357
+ { image }
358
+ </a>
359
+ ) : (
360
+ image
361
+ ) }
362
+ { ! RichText.isEmpty( caption ) && (
363
+ <RichText.Content tagName="figcaption" value={ caption } />
364
+ ) }
365
+ </>
366
+ );
165
367
 
368
+ if ( 'left' === align || 'right' === align || 'center' === align ) {
166
369
  return (
167
- <figure { ...useBlockProps.save( { className: classes } ) }>
168
- { figure }
169
- </figure>
370
+ <div { ...useBlockProps.save() }>
371
+ <figure className={ classes }>{ figure }</figure>
372
+ </div>
170
373
  );
374
+ }
375
+
376
+ return (
377
+ <figure { ...useBlockProps.save( { className: classes } ) }>
378
+ { figure }
379
+ </figure>
380
+ );
381
+ },
382
+ };
383
+
384
+ /**
385
+ * Deprecation for moving existing border radius styles onto the inner img
386
+ * element where new border block support styles must be applied.
387
+ * It will also add a new `.has-custom-border` class for existing blocks
388
+ * with border radii set. This class is required to improve caption position
389
+ * and styling when an image within a gallery has a custom border or
390
+ * rounded corners.
391
+ *
392
+ * @see https://github.com/WordPress/gutenberg/pull/31366
393
+ */
394
+ const v5 = {
395
+ attributes: {
396
+ align: {
397
+ type: 'string',
398
+ },
399
+ url: {
400
+ type: 'string',
401
+ source: 'attribute',
402
+ selector: 'img',
403
+ attribute: 'src',
404
+ },
405
+ alt: {
406
+ type: 'string',
407
+ source: 'attribute',
408
+ selector: 'img',
409
+ attribute: 'alt',
410
+ default: '',
411
+ },
412
+ caption: {
413
+ type: 'string',
414
+ source: 'html',
415
+ selector: 'figcaption',
416
+ },
417
+ title: {
418
+ type: 'string',
419
+ source: 'attribute',
420
+ selector: 'img',
421
+ attribute: 'title',
422
+ },
423
+ href: {
424
+ type: 'string',
425
+ source: 'attribute',
426
+ selector: 'figure > a',
427
+ attribute: 'href',
428
+ },
429
+ rel: {
430
+ type: 'string',
431
+ source: 'attribute',
432
+ selector: 'figure > a',
433
+ attribute: 'rel',
434
+ },
435
+ linkClass: {
436
+ type: 'string',
437
+ source: 'attribute',
438
+ selector: 'figure > a',
439
+ attribute: 'class',
440
+ },
441
+ id: {
442
+ type: 'number',
443
+ },
444
+ width: {
445
+ type: 'number',
446
+ },
447
+ height: {
448
+ type: 'number',
449
+ },
450
+ sizeSlug: {
451
+ type: 'string',
452
+ },
453
+ linkDestination: {
454
+ type: 'string',
455
+ },
456
+ linkTarget: {
457
+ type: 'string',
458
+ source: 'attribute',
459
+ selector: 'figure > a',
460
+ attribute: 'target',
171
461
  },
172
462
  },
173
- {
174
- attributes: {
175
- ...blockAttributes,
176
- title: {
177
- type: 'string',
178
- source: 'attribute',
179
- selector: 'img',
180
- attribute: 'title',
463
+ supports: {
464
+ anchor: true,
465
+ color: {
466
+ __experimentalDuotone: 'img',
467
+ text: false,
468
+ background: false,
469
+ },
470
+ __experimentalBorder: {
471
+ radius: true,
472
+ __experimentalDefaultControls: {
473
+ radius: true,
181
474
  },
182
- sizeSlug: {
183
- type: 'string',
475
+ },
476
+ __experimentalStyle: {
477
+ spacing: {
478
+ margin: '0 0 1em 0',
184
479
  },
185
480
  },
186
- supports: blockSupports,
187
- save( { attributes } ) {
188
- const {
189
- url,
190
- alt,
191
- caption,
192
- align,
193
- href,
194
- rel,
195
- linkClass,
196
- width,
197
- height,
198
- id,
199
- linkTarget,
200
- sizeSlug,
201
- title,
202
- } = attributes;
203
-
204
- const newRel = ! rel ? undefined : rel;
205
-
206
- const classes = classnames( {
207
- [ `align${ align }` ]: align,
208
- [ `size-${ sizeSlug }` ]: sizeSlug,
209
- 'is-resized': width || height,
210
- } );
211
-
212
- const image = (
213
- <img
214
- src={ url }
215
- alt={ alt }
216
- className={ id ? `wp-image-${ id }` : null }
217
- width={ width }
218
- height={ height }
219
- title={ title }
220
- />
221
- );
481
+ },
482
+ save( { attributes } ) {
483
+ const {
484
+ url,
485
+ alt,
486
+ caption,
487
+ align,
488
+ href,
489
+ rel,
490
+ linkClass,
491
+ width,
492
+ height,
493
+ id,
494
+ linkTarget,
495
+ sizeSlug,
496
+ title,
497
+ } = attributes;
222
498
 
223
- const figure = (
224
- <>
225
- { href ? (
226
- <a
227
- className={ linkClass }
228
- href={ href }
229
- target={ linkTarget }
230
- rel={ newRel }
231
- >
232
- { image }
233
- </a>
234
- ) : (
235
- image
236
- ) }
237
- { ! RichText.isEmpty( caption ) && (
238
- <RichText.Content
239
- tagName="figcaption"
240
- value={ caption }
241
- />
242
- ) }
243
- </>
244
- );
499
+ const newRel = ! rel ? undefined : rel;
245
500
 
246
- if ( 'left' === align || 'right' === align || 'center' === align ) {
247
- return (
248
- <div { ...useBlockProps.save() }>
249
- <figure className={ classes }>{ figure }</figure>
250
- </div>
251
- );
252
- }
501
+ const classes = classnames( {
502
+ [ `align${ align }` ]: align,
503
+ [ `size-${ sizeSlug }` ]: sizeSlug,
504
+ 'is-resized': width || height,
505
+ } );
253
506
 
254
- return (
255
- <figure { ...useBlockProps.save( { className: classes } ) }>
256
- { figure }
257
- </figure>
258
- );
259
- },
260
- },
261
- {
262
- attributes: blockAttributes,
263
- save( { attributes } ) {
264
- const { url, alt, caption, align, href, width, height, id } =
265
- attributes;
266
-
267
- const classes = classnames( {
268
- [ `align${ align }` ]: align,
269
- 'is-resized': width || height,
270
- } );
271
-
272
- const image = (
273
- <img
274
- src={ url }
275
- alt={ alt }
276
- className={ id ? `wp-image-${ id }` : null }
277
- width={ width }
278
- height={ height }
279
- />
280
- );
507
+ const image = (
508
+ <img
509
+ src={ url }
510
+ alt={ alt }
511
+ className={ id ? `wp-image-${ id }` : null }
512
+ width={ width }
513
+ height={ height }
514
+ title={ title }
515
+ />
516
+ );
281
517
 
282
- return (
283
- <figure className={ classes }>
284
- { href ? <a href={ href }>{ image }</a> : image }
285
- { ! RichText.isEmpty( caption ) && (
286
- <RichText.Content
287
- tagName="figcaption"
288
- value={ caption }
289
- />
290
- ) }
291
- </figure>
292
- );
293
- },
294
- },
295
- {
296
- attributes: blockAttributes,
297
- save( { attributes } ) {
298
- const { url, alt, caption, align, href, width, height, id } =
299
- attributes;
300
-
301
- const image = (
302
- <img
303
- src={ url }
304
- alt={ alt }
305
- className={ id ? `wp-image-${ id }` : null }
306
- width={ width }
307
- height={ height }
308
- />
309
- );
518
+ const figure = (
519
+ <>
520
+ { href ? (
521
+ <a
522
+ className={ linkClass }
523
+ href={ href }
524
+ target={ linkTarget }
525
+ rel={ newRel }
526
+ >
527
+ { image }
528
+ </a>
529
+ ) : (
530
+ image
531
+ ) }
532
+ { ! RichText.isEmpty( caption ) && (
533
+ <RichText.Content tagName="figcaption" value={ caption } />
534
+ ) }
535
+ </>
536
+ );
310
537
 
311
- return (
312
- <figure className={ align ? `align${ align }` : null }>
313
- { href ? <a href={ href }>{ image }</a> : image }
314
- { ! RichText.isEmpty( caption ) && (
315
- <RichText.Content
316
- tagName="figcaption"
317
- value={ caption }
318
- />
319
- ) }
320
- </figure>
321
- );
322
- },
538
+ return (
539
+ <figure { ...useBlockProps.save( { className: classes } ) }>
540
+ { figure }
541
+ </figure>
542
+ );
323
543
  },
324
- {
325
- attributes: blockAttributes,
326
- save( { attributes } ) {
327
- const { url, alt, caption, align, href, width, height } =
328
- attributes;
329
- const extraImageProps = width || height ? { width, height } : {};
330
- const image = (
331
- <img src={ url } alt={ alt } { ...extraImageProps } />
332
- );
544
+ };
333
545
 
334
- let figureStyle = {};
546
+ /**
547
+ * Deprecation for adding width and height as style rules on the inner img.
548
+ * It also updates the widht and height attributes to be strings instead of numbers.
549
+ *
550
+ * @see https://github.com/WordPress/gutenberg/pull/31366
551
+ */
552
+ const v6 = {
553
+ save( { attributes } ) {
554
+ const {
555
+ url,
556
+ alt,
557
+ caption,
558
+ align,
559
+ href,
560
+ rel,
561
+ linkClass,
562
+ width,
563
+ height,
564
+ aspectRatio,
565
+ scale,
566
+ id,
567
+ linkTarget,
568
+ sizeSlug,
569
+ title,
570
+ } = attributes;
335
571
 
336
- if ( width ) {
337
- figureStyle = { width };
338
- } else if ( align === 'left' || align === 'right' ) {
339
- figureStyle = { maxWidth: '50%' };
340
- }
572
+ const newRel = ! rel ? undefined : rel;
573
+ const borderProps = getBorderClassesAndStyles( attributes );
341
574
 
342
- return (
343
- <figure
344
- className={ align ? `align${ align }` : null }
345
- style={ figureStyle }
346
- >
347
- { href ? <a href={ href }>{ image }</a> : image }
348
- { ! RichText.isEmpty( caption ) && (
349
- <RichText.Content
350
- tagName="figcaption"
351
- value={ caption }
352
- />
353
- ) }
354
- </figure>
355
- );
356
- },
575
+ const classes = classnames( {
576
+ [ `align${ align }` ]: align,
577
+ [ `size-${ sizeSlug }` ]: sizeSlug,
578
+ 'is-resized': width || height,
579
+ 'has-custom-border':
580
+ !! borderProps.className ||
581
+ ( borderProps.style &&
582
+ Object.keys( borderProps.style ).length > 0 ),
583
+ } );
584
+
585
+ const imageClasses = classnames( borderProps.className, {
586
+ [ `wp-image-${ id }` ]: !! id,
587
+ } );
588
+
589
+ const image = (
590
+ <img
591
+ src={ url }
592
+ alt={ alt }
593
+ className={ imageClasses || undefined }
594
+ style={ {
595
+ ...borderProps.style,
596
+ aspectRatio,
597
+ objectFit: scale,
598
+ } }
599
+ width={ width }
600
+ height={ height }
601
+ title={ title }
602
+ />
603
+ );
604
+
605
+ const figure = (
606
+ <>
607
+ { href ? (
608
+ <a
609
+ className={ linkClass }
610
+ href={ href }
611
+ target={ linkTarget }
612
+ rel={ newRel }
613
+ >
614
+ { image }
615
+ </a>
616
+ ) : (
617
+ image
618
+ ) }
619
+ { ! RichText.isEmpty( caption ) && (
620
+ <RichText.Content
621
+ className={ getBorderClassesAndStyles( 'caption' ) }
622
+ tagName="figcaption"
623
+ value={ caption }
624
+ />
625
+ ) }
626
+ </>
627
+ );
628
+
629
+ return (
630
+ <figure { ...useBlockProps.save( { className: classes } ) }>
631
+ { figure }
632
+ </figure>
633
+ );
357
634
  },
358
- ];
635
+ };
359
636
 
360
- export default deprecated;
637
+ export default [ v6, v5, v4, v3, v2, v1 ];